Skip to content

Commit

Permalink
Make StatusCheck attribute always require a check string
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse committed Feb 23, 2024
1 parent 93a36a6 commit a47d598
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 212 deletions.
11 changes: 9 additions & 2 deletions codehelp/CodeHelpers/StatusCheckGenerator/MethodModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ public void WriteCallString(IndentedStringBuilder builder)

public void WriteStatusCheck(IndentedStringBuilder builder)
{
builder.AppendFullLine($"__tmpStatus.{StatusCheckMethod};");
if (string.IsNullOrWhiteSpace(StatusCheckMethod))
{
builder.AppendFullLine("__tmpStatus");
}
else
{
builder.AppendFullLine(string.Format(StatusCheckMethod, "__tmpStatus"));
}
}

public void WriteReturn(IndentedStringBuilder builder)
Expand Down Expand Up @@ -184,7 +191,7 @@ internal static class MethodModelExtensions

var classSymbol = symbol.ContainingType;

string statusCheckMethod = "ThrowIfFailed()";
string statusCheckMethod = "";

foreach (var attribute in symbol.GetAttributes())
{
Expand Down
18 changes: 9 additions & 9 deletions src/cscore/Natives/CsNative.Free.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@ namespace CsCore.Natives;

public static unsafe partial class CsNative
{
[LibraryImport("cscore", EntryPoint = "CS_FreeEnumeratedUsbCameras")]
[LibraryImport(LibraryName, EntryPoint = "CS_FreeEnumeratedUsbCameras")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FreeEnumeratedUsbCameras(UsbCameraInfoMarshaller.NativeUsbCameraInfo* cameras, int count);

[LibraryImport("cscore", EntryPoint = "CS_ReleaseEnumeratedSources")]
[LibraryImport(LibraryName, EntryPoint = "CS_ReleaseEnumeratedSources")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void ReleaseEnumeratedSources(int* sources, int count);

[LibraryImport("cscore", EntryPoint = "CS_ReleaseEnumeratedSinks")]
[LibraryImport(LibraryName, EntryPoint = "CS_ReleaseEnumeratedSinks")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void ReleaseEnumeratedSinks(int* sinks, int count);

[LibraryImport("cscore", EntryPoint = "CS_FreeEnumPropertyChoices")]
[LibraryImport(LibraryName, EntryPoint = "CS_FreeEnumPropertyChoices")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FreeEnumPropertyChoices(byte** choices, int count);

[LibraryImport("cscore", EntryPoint = "CS_FreeUsbCameraInfo")]
[LibraryImport(LibraryName, EntryPoint = "CS_FreeUsbCameraInfo")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FreeUsbCameraInfo(UsbCameraInfoMarshaller.NativeUsbCameraInfo* info);

[LibraryImport("cscore", EntryPoint = "CS_FreeHttpCameraUrls")]
[LibraryImport(LibraryName, EntryPoint = "CS_FreeHttpCameraUrls")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FreeHttpCameraUrls(byte** choices, int count);

[LibraryImport("cscore", EntryPoint = "CS_FreeEnumeratedProperties")]
[LibraryImport(LibraryName, EntryPoint = "CS_FreeEnumeratedProperties")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FreeEnumeratedProperties(int* properties, int count);

[LibraryImport("cscore", EntryPoint = "CS_FreeEnumeratedVideoModes")]
[LibraryImport(LibraryName, EntryPoint = "CS_FreeEnumeratedVideoModes")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FreeEnumeratedVideoModes(VideoModeMarshaller.NativeVideoMode* modes, int count);

[LibraryImport("cscore", EntryPoint = "CS_FreeNetworkInterfaces")]
[LibraryImport(LibraryName, EntryPoint = "CS_FreeNetworkInterfaces")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FreeNetworkInterfaces(byte** interfaces, int count);
}
Loading

0 comments on commit a47d598

Please sign in to comment.