Add explicit discards to all value returning expressions

このコミットが含まれているのは:
Sergio Pedri committed 2022-10-15 09:10:18 -07:00
1 親 38adbe6087
コミット 9343ac7f7b
47ファイル変更
+144 -144

検索条件に一致するファイルはありません

+1 -1
ファイルの表示
@@ -47,7 +47,7 @@ internal static partial class BlasHelpers
}
}
Parallel.For(0, c, Kernel);
_ = Parallel.For(0, c, Kernel);
}
/// <summary>
+1 -1
ファイルの表示
@@ -92,7 +92,7 @@ public sealed partial class HlslBokehBlurProcessor
NormalizeKernels();
// Store them in the cache for future use
Cache.TryAdd(parameters, (kernelParameters, kernelsScale, kernels));
_ = Cache.TryAdd(parameters, (kernelParameters, kernelsScale, kernels));
}
}
+6 -6
ファイルの表示
@@ -16,13 +16,13 @@ public sealed class DebugAnalyticsService : IAnalyticsService
{
StringBuilder builder = new();
builder.AppendLine($"[EVENT]: \"{title}\"");
_ = builder.AppendLine($"[EVENT]: \"{title}\"");
if (data is not null)
{
foreach (var info in data)
{
builder.AppendLine($">> {info.Property}: \"{info.Value ?? "<NULL>"}\"");
_ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? "<NULL>"}\"");
}
}
@@ -34,15 +34,15 @@ public sealed class DebugAnalyticsService : IAnalyticsService
{
StringBuilder builder = new();
builder.AppendLine($"[EXCEPTION]: \"{exception.GetType()}\"");
builder.AppendLine(">> Stack trace");
builder.AppendLine(exception.StackTrace);
_ = builder.AppendLine($"[EXCEPTION]: \"{exception.GetType()}\"");
_ = builder.AppendLine(">> Stack trace");
_ = builder.AppendLine(exception.StackTrace);
if (data is not null)
{
foreach (var info in data)
{
builder.AppendLine($">> {info.Property}: \"{info.Value ?? "<NULL>"}\"");
_ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? "<NULL>"}\"");
}
}
+2 -2
ファイルの表示
@@ -31,7 +31,7 @@ public sealed partial class MainView : UserControl
{
Ioc.Default.GetRequiredService<IAnalyticsService>().Log(Event.OpenShaderSelectionPanel);
Root.Resources.Remove("ShaderSelectionPanel");
_ = Root.Resources.Remove("ShaderSelectionPanel");
Root.Children.Add(ShaderSelectionPanel);
}
@@ -40,7 +40,7 @@ public sealed partial class MainView : UserControl
{
Ioc.Default.GetRequiredService<IAnalyticsService>().Log(Event.CloseShaderSelectionPanel);
Root.Children.Remove(ShaderSelectionPanel);
_ = Root.Children.Remove(ShaderSelectionPanel);
}
// Updates the size of the shaders list panel
+2 -2
ファイルの表示
@@ -49,14 +49,14 @@ public sealed partial class MainWindow : Window
// Opens the shader selection panel
private void OpenShaderSelectionPanelButton_Click(object sender, RoutedEventArgs e)
{
Root.Resources.Remove("ShaderSelectionPanel");
_ = Root.Resources.Remove("ShaderSelectionPanel");
Root.Children.Add(ShaderSelectionPanel);
}
// Hides the shader selection panel
private void ShaderSelectionPanel_Tapped(object sender, TappedRoutedEventArgs e)
{
Root.Children.Remove(ShaderSelectionPanel);
_ = Root.Children.Remove(ShaderSelectionPanel);
}
// Updates the size of the shaders list panel
+12 -12
ファイルの表示
@@ -147,7 +147,7 @@ internal sealed class SwapChainApplication<T> : Win32Application
// Create the command allocator to use
fixed (ID3D12CommandAllocator** d3D12CommandAllocator = this.d3D12CommandAllocator)
{
this.d3D12Device.Get()->CreateCommandAllocator(
_ = this.d3D12Device.Get()->CreateCommandAllocator(
D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT,
Windows.__uuidof<ID3D12CommandAllocator>(),
(void**)d3D12CommandAllocator);
@@ -156,7 +156,7 @@ internal sealed class SwapChainApplication<T> : Win32Application
// Create the reusable command list to copy data to the back buffers
fixed (ID3D12GraphicsCommandList** d3D12GraphicsCommandList = this.d3D12GraphicsCommandList)
{
this.d3D12Device.Get()->CreateCommandList(
_ = this.d3D12Device.Get()->CreateCommandList(
0,
D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT,
d3D12CommandAllocator,
@@ -166,7 +166,7 @@ internal sealed class SwapChainApplication<T> : Win32Application
}
// Close the command list to prepare it for future use
this.d3D12GraphicsCommandList.Get()->Close();
_ = this.d3D12GraphicsCommandList.Get()->Close();
}
/// <inheritdoc/>
@@ -180,10 +180,10 @@ internal sealed class SwapChainApplication<T> : Win32Application
/// </summary>
private unsafe void ApplyResize()
{
this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);
_ = this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);
// Wait for the fence again to ensure there are no pending operations
this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
_ = this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
this.nextD3D12FenceValue++;
@@ -192,7 +192,7 @@ internal sealed class SwapChainApplication<T> : Win32Application
this.d3D12Resource1.Dispose();
// Resize the swap chain buffers
this.dxgiSwapChain1.Get()->ResizeBuffers(0, 0, 0, DXGI_FORMAT.DXGI_FORMAT_UNKNOWN, 0);
_ = this.dxgiSwapChain1.Get()->ResizeBuffers(0, 0, 0, DXGI_FORMAT.DXGI_FORMAT_UNKNOWN, 0);
// Get the index of the initial back buffer
using (ComPtr<IDXGISwapChain3> dxgiSwapChain3 = default)
@@ -249,8 +249,8 @@ internal sealed class SwapChainApplication<T> : Win32Application
this.currentBufferIndex ^= 1;
// Reset the command list and command allocator
this.d3D12CommandAllocator.Get()->Reset();
this.d3D12GraphicsCommandList.Get()->Reset(this.d3D12CommandAllocator.Get(), null);
_ = this.d3D12CommandAllocator.Get()->Reset();
_ = this.d3D12GraphicsCommandList.Get()->Reset(this.d3D12CommandAllocator.Get(), null);
D3D12_RESOURCE_BARRIER* d3D12ResourceBarriers = stackalloc D3D12_RESOURCE_BARRIER[]
{
@@ -283,18 +283,18 @@ internal sealed class SwapChainApplication<T> : Win32Application
// Transition the resources back to COMMON and UNORDERED_ACCESS respectively
d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);
d3D12GraphicsCommandList.Get()->Close();
_ = d3D12GraphicsCommandList.Get()->Close();
// Execute the command list to perform the copy
this.d3D12CommandQueue.Get()->ExecuteCommandLists(1, (ID3D12CommandList**)d3D12GraphicsCommandList.GetAddressOf());
this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);
_ = this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);
// Present the new frame
this.dxgiSwapChain1.Get()->Present(0, 0);
_ = this.dxgiSwapChain1.Get()->Present(0, 0);
if (this.nextD3D12FenceValue > this.d3D12Fence.Get()->GetCompletedValue())
{
this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
_ = this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
}
this.nextD3D12FenceValue++;
+2 -2
ファイルの表示
@@ -196,11 +196,11 @@ internal unsafe static class Win32ApplicationRunner
if (isPaused)
{
Windows.SetCapture(hwnd);
_ = Windows.SetCapture(hwnd);
}
else
{
Windows.ReleaseCapture();
_ = Windows.ReleaseCapture();
}
isPaused = !isPaused;
+1 -1
ファイルの表示
@@ -61,7 +61,7 @@ class Program
Console.WriteLine();
Console.WriteLine($"Starting {Samples[index].ShaderName}...");
Win32ApplicationRunner.Run(Samples[index].Application);
_ = Win32ApplicationRunner.Run(Samples[index].Application);
}
}
while (index >= 0 && index < Samples.Length);
@@ -530,13 +530,13 @@ partial class ID2D1ShaderGenerator
void AppendLF()
{
hlslBuilder.Append('\n');
_ = hlslBuilder.Append('\n');
}
void AppendLineAndLF(string text)
{
hlslBuilder.Append(text);
hlslBuilder.Append('\n');
_ = hlslBuilder.Append(text);
_ = hlslBuilder.Append('\n');
}
// Header
+6 -6
ファイルの表示
@@ -26,12 +26,12 @@ public sealed class FxcCompilationException : Exception
{
StringBuilder builder = new(512);
builder.AppendLine("The FXC compiler encountered one or more errors while trying to compile the shader:");
builder.AppendLine();
builder.AppendLine(error.Trim());
builder.AppendLine();
builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp.");
builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.");
_ = builder.AppendLine("The FXC compiler encountered one or more errors while trying to compile the shader:");
_ = builder.AppendLine();
_ = builder.AppendLine(error.Trim());
_ = builder.AppendLine();
_ = builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp.");
_ = builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.");
return builder.ToString();
}
+1 -1
ファイルの表示
@@ -342,7 +342,7 @@ public sealed unsafe class D2D1ResourceTextureManager : ICustomQueryInterface
{
if (this.d2D1ResourceManagerImpl is not null)
{
this.d2D1ResourceManagerImpl->Release();
_ = this.d2D1ResourceManagerImpl->Release();
}
}
+2 -2
ファイルの表示
@@ -178,7 +178,7 @@ unsafe partial struct PixelShaderEffect
using ComPtr<ID2D1ResourceTextureManager> resourceTextureManager = this.resourceTextureManagerBuffer[resourceTextureIndex];
resourceTextureManager.CopyTo((ID2D1ResourceTextureManager**)data);
_ = resourceTextureManager.CopyTo((ID2D1ResourceTextureManager**)data);
if (actualSize is not null)
{
@@ -261,7 +261,7 @@ unsafe partial struct PixelShaderEffect
// If there's already an existing manager at this index, release it
if (currentResourceTextureManager is not null)
{
((IUnknown*)currentResourceTextureManager)->Release();
_ = ((IUnknown*)currentResourceTextureManager)->Release();
}
// Store the resource texture manager into the buffer
@@ -165,7 +165,7 @@ partial struct D2D1ResourceTextureManagerImpl
// If the texture has already been created, just return it
if (@this->d2D1ResourceTexture is not null)
{
@this->d2D1ResourceTexture->AddRef();
_ = @this->d2D1ResourceTexture->AddRef();
*resourceTexture = @this->d2D1ResourceTexture;
@@ -194,10 +194,10 @@ partial struct D2D1ResourceTextureManagerImpl
if (result == S.S_OK)
{
// Store the resource texture for later
d2D1ResourceTexture.CopyTo(&@this->d2D1ResourceTexture);
_ = d2D1ResourceTexture.CopyTo(&@this->d2D1ResourceTexture);
// Also return it to callers
d2D1ResourceTexture.CopyTo(resourceTexture);
_ = d2D1ResourceTexture.CopyTo(resourceTexture);
// Free the staging buffers
NativeMemory.Free(@this->resourceTextureProperties.extents);
+1 -1
ファイルの表示
@@ -31,7 +31,7 @@ internal readonly unsafe struct D2D1DrawInfoDispatchDataLoader : ID2D1DispatchDa
/// <inheritdoc/>
void ID2D1DispatchDataLoader.LoadConstantBuffer(ReadOnlySpan<byte> data)
{
this.d2D1DrawInfo->SetPixelShaderConstantBuffer(
_ = this.d2D1DrawInfo->SetPixelShaderConstantBuffer(
buffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)),
bufferCount: (uint)data.Length);
}
+6 -6
ファイルの表示
@@ -26,12 +26,12 @@ public sealed class DxcCompilationException : Exception
{
StringBuilder builder = new(512);
builder.AppendLine("The DXC compiler encountered one or more errors while trying to compile the shader:");
builder.AppendLine();
builder.AppendLine(error.Trim());
builder.AppendLine();
builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp.");
builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.");
_ = builder.AppendLine("The DXC compiler encountered one or more errors while trying to compile the shader:");
_ = builder.AppendLine();
_ = builder.AppendLine(error.Trim());
_ = builder.AppendLine();
_ = builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp.");
_ = builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.");
return builder.ToString();
}
+2 -2
ファイルの表示
@@ -46,7 +46,7 @@ internal static partial class HlslKnownKeywords
// HLSL primitive names
foreach (var type in HlslKnownTypes.KnownVectorTypes.Concat(HlslKnownTypes.KnownMatrixTypes))
{
knownKeywords.Add(type.Name.ToLowerInvariant());
_ = knownKeywords.Add(type.Name.ToLowerInvariant());
}
// HLSL intrinsics method names
@@ -54,7 +54,7 @@ internal static partial class HlslKnownKeywords
{
string name = method.GetCustomAttribute<HlslIntrinsicNameAttribute>()?.Name ?? method.Name;
knownKeywords.Add(name);
_ = knownKeywords.Add(name);
}
// Let other types inject additional keywords
+2 -2
ファイルの表示
@@ -222,7 +222,7 @@ internal static partial class HlslKnownTypes
// Explicitly prevent bool from being a field in a custom struct
if (type.SpecialType == SpecialType.System_Boolean)
{
invalidTypes.Add(type);
_ = invalidTypes.Add(type);
return;
}
@@ -236,7 +236,7 @@ internal static partial class HlslKnownTypes
type.IsRefLikeType ||
type.GetFullyQualifiedName().StartsWith("System."))
{
invalidTypes.Add(type);
_ = invalidTypes.Add(type);
return;
}
@@ -96,12 +96,12 @@ partial class IShaderGenerator
void AppendLF()
{
textBuilder.Append('\n');
_ = textBuilder.Append('\n');
}
void AppendLine(string text)
{
textBuilder.Append(text);
_ = textBuilder.Append(text);
}
void AppendParsedStatement(string text)
@@ -117,7 +117,7 @@ partial class IShaderGenerator
{
string hlslSource = textBuilder.ToString();
textBuilder.Append(hlslSource);
_ = textBuilder.Append(hlslSource);
sizeHint += textBuilder.Length;
@@ -133,7 +133,7 @@ partial class IShaderGenerator
MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, IdentifierName("builder"), IdentifierName("Append")))
.AddArgumentListArguments(Argument(LiteralExpression(SyntaxKind.StringLiteralExpression, hlslSourceLiteralExpression)))));
textBuilder.Clear();
_ = textBuilder.Clear();
}
}
+7 -7
ファイルの表示
@@ -570,31 +570,31 @@ partial class IShaderGenerator
void AppendLF()
{
hlslBuilder.Append('\n');
_ = hlslBuilder.Append('\n');
}
void AppendLine(string text)
{
hlslBuilder.Append(text);
_ = hlslBuilder.Append(text);
}
void AppendLineAndLF(string text)
{
hlslBuilder.Append(text);
hlslBuilder.Append('\n');
_ = hlslBuilder.Append(text);
_ = hlslBuilder.Append('\n');
}
void AppendCharacterAndLF(char c)
{
hlslBuilder.Append(c);
hlslBuilder.Append('\n');
_ = hlslBuilder.Append(c);
_ = hlslBuilder.Append('\n');
}
string FlushText()
{
string text = hlslBuilder.ToString();
hlslBuilder.Clear();
_ = hlslBuilder.Clear();
return text;
}
+1 -1
ファイルの表示
@@ -224,7 +224,7 @@ partial class IShaderGenerator
string sourceFilename = $"ComputeSharp.SourceGenerators.ComputeSharp.Libraries.{rid}.{name}.dll";
string targetFilename = Path.Combine(folder, rid, $"{name}.dll");
Directory.CreateDirectory(Path.GetDirectoryName(targetFilename));
_ = Directory.CreateDirectory(Path.GetDirectoryName(targetFilename));
using Stream sourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(sourceFilename);
+1 -1
ファイルの表示
@@ -50,7 +50,7 @@ internal static class SemaphoreSlimExtensions
/// <inheritdoc/>
public void Dispose()
{
this.semaphore.Release();
_ = this.semaphore.Release();
}
}
}
+1 -1
ファイルの表示
@@ -210,7 +210,7 @@ partial class SwapChainManager<TOwner>
}
finally
{
this.renderSemaphore.Release();
_ = this.renderSemaphore.Release();
}
}
+1 -1
ファイルの表示
@@ -531,7 +531,7 @@ internal sealed unsafe partial class SwapChainManager<TOwner> : NativeObject
@this.swapChainPanelNative.Get()->SetSwapChain(null).Assert();
@this.swapChainPanelNative.Dispose();
ThreadPool.UnsafeQueueUserWorkItem(static state =>
_ = ThreadPool.UnsafeQueueUserWorkItem(static state =>
{
SwapChainManager<TOwner> @this = (SwapChainManager<TOwner>)state!;
+4 -4
ファイルの表示
@@ -90,8 +90,8 @@ internal readonly unsafe struct ID3D12CommandListPool : IDisposable
{
foreach (D3D12CommandListBundle d3D12CommandListBundle in this.d3D12CommandListBundleQueue)
{
d3D12CommandListBundle.D3D12CommandList->Release();
d3D12CommandListBundle.D3D12CommandAllocator->Release();
_ = d3D12CommandListBundle.D3D12CommandList->Release();
_ = d3D12CommandListBundle.D3D12CommandAllocator->Release();
}
this.d3D12CommandListBundleQueue.Clear();
@@ -114,8 +114,8 @@ internal readonly unsafe struct ID3D12CommandListPool : IDisposable
fixed (ID3D12GraphicsCommandList** d3D12CommandListPtr = &d3D12CommandList)
fixed (ID3D12CommandAllocator** d3D12CommandAllocatorPtr = &d3D12CommandAllocator)
{
d3D12CommandListComPtr.CopyTo(d3D12CommandListPtr);
d3D12CommandAllocatorComPtr.CopyTo(d3D12CommandAllocatorPtr);
_ = d3D12CommandListComPtr.CopyTo(d3D12CommandListPtr);
_ = d3D12CommandAllocatorComPtr.CopyTo(d3D12CommandAllocatorPtr);
}
}
+5 -5
ファイルの表示
@@ -34,11 +34,11 @@ public sealed class GraphicsDeviceMismatchException : InvalidOperationException
{
StringBuilder builder = new(512);
builder.AppendLine("Invalid pairing of graphics devices used to run a compute shader and allocate memory buffers.");
builder.AppendLine($"The target device to run the compute shader is \"{destinationDevice}\".");
builder.AppendLine($"The buffer of type {resource.GetType()} was allocated on device \"{sourceDevice}\".");
builder.Append("Make sure to always allocate buffers on the same device used to actually run the code that accesses them.");
builder.ToString();
_ = builder.AppendLine("Invalid pairing of graphics devices used to run a compute shader and allocate memory buffers.");
_ = builder.AppendLine($"The target device to run the compute shader is \"{destinationDevice}\".");
_ = builder.AppendLine($"The buffer of type {resource.GetType()} was allocated on device \"{sourceDevice}\".");
_ = builder.Append("Make sure to always allocate buffers on the same device used to actually run the code that accesses them.");
_ = builder.ToString();
return new(builder.ToString());
}
+4 -4
ファイルの表示
@@ -26,10 +26,10 @@ public sealed class UnsupportedDoubleOperationException : NotSupportedException
{
StringBuilder builder = new(256);
builder.AppendLine($"The device in use does not support creating resources of type {type}, as it does not support using double precision floating point numbers.");
builder.AppendLine("As a possible workaround, consider replacing usage of the double type with single precision floating point numbers.");
builder.AppendLine("Note that double precision operations are only partially supported on GPU devices, and are far slower than single precision ones.");
builder.ToString();
_ = builder.AppendLine($"The device in use does not support creating resources of type {type}, as it does not support using double precision floating point numbers.");
_ = builder.AppendLine("As a possible workaround, consider replacing usage of the double type with single precision floating point numbers.");
_ = builder.AppendLine("Note that double precision operations are only partially supported on GPU devices, and are far slower than single precision ones.");
_ = builder.ToString();
return new(builder.ToString());
}
+4 -4
ファイルの表示
@@ -28,10 +28,10 @@ public sealed class UnsupportedTextureTypeException : NotSupportedException
{
StringBuilder builder = new(256);
builder.AppendLine($"The device in use does not support creating {rank}D textures of type {type}.");
builder.Append($"Make sure to check the support at runtime by using {nameof(GraphicsDevice)}.");
_ = builder.AppendLine($"The device in use does not support creating {rank}D textures of type {type}.");
_ = builder.Append($"Make sure to check the support at runtime by using {nameof(GraphicsDevice)}.");
builder.AppendLine(rank switch
_ = builder.AppendLine(rank switch
{
1 => $"{nameof(GraphicsDevice.IsReadOnlyTexture1DSupportedForType)}<T>() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture1DSupportedForType)}<T>().",
2 => $"{nameof(GraphicsDevice.IsReadOnlyTexture2DSupportedForType)}<T>() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture2DSupportedForType)}<T>().",
@@ -39,7 +39,7 @@ public sealed class UnsupportedTextureTypeException : NotSupportedException
_ => ThrowHelper.ThrowArgumentException<string>("Invalid texture rank.")
});
builder.Append("As a possible workaround on older devices, consider using a texture type of lower rank, or a linear buffer.");
_ = builder.Append("As a possible workaround on older devices, consider using a texture type of lower rank, or a linear buffer.");
return new(builder.ToString());
}
+1 -1
ファイルの表示
@@ -99,7 +99,7 @@ unsafe partial class GraphicsDevice
device.DeviceLost?.Invoke(device, new DeviceLostEventArgs(reason));
}
ThreadPool.QueueUserWorkItem(static state => RaiseDeviceLostEvent((GraphicsDevice)state!), this);
_ = ThreadPool.QueueUserWorkItem(static state => RaiseDeviceLostEvent((GraphicsDevice)state!), this);
}
/// <summary>
+1 -1
ファイルの表示
@@ -433,7 +433,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject
this.copyCommandListPool.Rent(this.d3D12Device.Get(), null, out d3D12CommandList, out d3D12CommandAllocator);
break;
default:
ThrowHelper.ThrowArgumentException<ComPtr<ID3D12CommandAllocator>>();
_ = ThrowHelper.ThrowArgumentException<ComPtr<ID3D12CommandAllocator>>();
d3D12CommandList = null;
d3D12CommandAllocator = null;
break;
+2 -2
ファイルの表示
@@ -100,11 +100,11 @@ partial class DeviceHelper
defaultDevice = null;
}
DevicesCache.Remove(device.Luid);
_ = DevicesCache.Remove(device.Luid);
if (Configuration.IsDebugOutputEnabled)
{
D3D12InfoQueueMap.Remove(device.Luid, out ComPtr<ID3D12InfoQueue> queue);
_ = D3D12InfoQueueMap.Remove(device.Luid, out ComPtr<ID3D12InfoQueue> queue);
queue.Dispose();
}
+15 -15
ファイルの表示
@@ -47,19 +47,19 @@ partial class DeviceHelper
{
nuint length;
queue->GetMessage(i, null, &length);
_ = queue->GetMessage(i, null, &length);
D3D12_MESSAGE* message = (D3D12_MESSAGE*)NativeMemory.Alloc(length);
try
{
queue->GetMessage(i, message, &length);
_ = queue->GetMessage(i, message, &length);
builder.Clear();
builder.AppendLine($"[D3D12 message #{i} for \"{device}\" (HW: {device.IsHardwareAccelerated}, UMA: {device.IsCacheCoherentUMA})]");
builder.AppendLine($"[Category]: {Enum.GetName(message->Category)}");
builder.AppendLine($"[Severity]: {Enum.GetName(message->Severity)}");
builder.AppendLine($"[ID]: {Enum.GetName(message->ID)}");
_ = builder.Clear();
_ = builder.AppendLine($"[D3D12 message #{i} for \"{device}\" (HW: {device.IsHardwareAccelerated}, UMA: {device.IsCacheCoherentUMA})]");
_ = builder.AppendLine($"[Category]: {Enum.GetName(message->Category)}");
_ = builder.AppendLine($"[Severity]: {Enum.GetName(message->Severity)}");
_ = builder.AppendLine($"[ID]: {Enum.GetName(message->ID)}");
bool isDeviceRemovedMessage = message->ID is D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT or D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT or D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT;
@@ -81,14 +81,14 @@ partial class DeviceHelper
_ => ThrowHelper.ThrowArgumentOutOfRangeException<string>("Invalid GetDeviceRemovedReason HRESULT.")
};
builder.AppendLine($"[Reason]: {deviceRemovalReason}");
_ = builder.AppendLine($"[Reason]: {deviceRemovalReason}");
}
}
// If DRED is enabled, also output the available auto breadcrumbs
if (isDeviceRemovedMessage && Configuration.IsDeviceRemovedExtendedDataEnabled)
{
builder.AppendLine($"[Description]: \"{new string(message->pDescription)}\"");
_ = builder.AppendLine($"[Description]: \"{new string(message->pDescription)}\"");
using ComPtr<ID3D12DeviceRemovedExtendedData1> d3D12DeviceRemovedExtendedData = default;
@@ -112,7 +112,7 @@ partial class DeviceHelper
ThrowHelper.ThrowWin32Exception(hresult);
}
builder.AppendLine("[DRED breadcrumbs START] ===============================");
_ = builder.AppendLine("[DRED breadcrumbs START] ===============================");
int breadcrumbNodeIndex = 0;
@@ -126,7 +126,7 @@ partial class DeviceHelper
// For each auto breadcrumb node, not all recorded breadcrumb have actually been executed. To reduce the verbosity of the
// output and only show the most relevant info, indicate how many breadcrumbs were recorded and how many were actually
// executed, but then only display the executed ones in the code below. This makes it easier to debug hangs for users.
builder.AppendLine($"[NODE #{breadcrumbNodeIndex}]: {d3D12AutoBreadcrumbNode->BreadcrumbCount} total breadcrumb(s), {numberOfExecutedOps} executed breadcrumb(s)");
_ = builder.AppendLine($"[NODE #{breadcrumbNodeIndex}]: {d3D12AutoBreadcrumbNode->BreadcrumbCount} total breadcrumb(s), {numberOfExecutedOps} executed breadcrumb(s)");
uint contextIndex = 0;
@@ -145,20 +145,20 @@ partial class DeviceHelper
{
string context = new((char*)d3D12AutoBreadcrumbNode->pBreadcrumbContexts[contextIndex++].pContextString);
builder.AppendLine($">> [OP #{commandIndex}]: {d3D12AutoBreadcrumbNode->pCommandHistory[commandIndex]}, \"{context}\"");
_ = builder.AppendLine($">> [OP #{commandIndex}]: {d3D12AutoBreadcrumbNode->pCommandHistory[commandIndex]}, \"{context}\"");
}
else
{
builder.AppendLine($">> [OP #{commandIndex}]: {d3D12AutoBreadcrumbNode->pCommandHistory[commandIndex]}");
_ = builder.AppendLine($">> [OP #{commandIndex}]: {d3D12AutoBreadcrumbNode->pCommandHistory[commandIndex]}");
}
}
}
builder.AppendLine("================================= [DRED breadcrumbs END]");
_ = builder.AppendLine("================================= [DRED breadcrumbs END]");
}
else
{
builder.Append($"[Description]: \"{new string(message->pDescription)}\"");
_ = builder.Append($"[Description]: \"{new string(message->pDescription)}\"");
}
if (message->Severity is D3D12_MESSAGE_SEVERITY_ERROR or D3D12_MESSAGE_SEVERITY_CORRUPTION or D3D12_MESSAGE_SEVERITY_WARNING)
+1 -1
ファイルの表示
@@ -206,7 +206,7 @@ partial class DeviceHelper
[UnmanagedCallersOnly]
private static uint Release(IDXGIFactory4As6Backcompat* @this)
{
@this->dxgiFactory4->Release();
_ = @this->dxgiFactory4->Release();
NativeMemory.Free(@this);
+4 -4
ファイルの表示
@@ -115,8 +115,8 @@ internal static partial class DeviceHelper
if (Windows.SUCCEEDED(createDeviceResult) &&
d3D12DeviceCandidate.Get()->IsShaderModelSupported(D3D_SHADER_MODEL_6_0))
{
d3D12DeviceCandidate.CopyTo(d3D12Device);
dxgiAdapter1.CopyTo(dxgiAdapter);
_ = d3D12DeviceCandidate.CopyTo(d3D12Device);
_ = dxgiAdapter1.CopyTo(dxgiAdapter);
return true;
}
@@ -159,8 +159,8 @@ internal static partial class DeviceHelper
// There is no need to check for SM6.0, as it's guaranteed to be supported by Windows
if (Windows.SUCCEEDED(createDeviceResult))
{
d3D12DeviceCandidate.CopyTo(d3D12Device);
dxgiAdapter1.CopyTo(dxgiAdapter);
_ = d3D12DeviceCandidate.CopyTo(d3D12Device);
_ = dxgiAdapter1.CopyTo(dxgiAdapter);
return true;
}
+5 -5
ファイルの表示
@@ -372,7 +372,7 @@ internal sealed unsafe class WICHelper
fixed (char* p = filename)
{
wicStream.Get()->InitializeFromFilename(
_ = wicStream.Get()->InitializeFromFilename(
(ushort*)p,
Windows.GENERIC_WRITE);
}
@@ -409,7 +409,7 @@ internal sealed unsafe class WICHelper
// Create and initialize a stream
this.wicImagingFactory2.Get()->CreateStream(wicStream.GetAddressOf()).Assert();
wicStream.Get()->InitializeFromStream(stream);
_ = wicStream.Get()->InitializeFromStream(stream);
// Initialize the encoder
wicBitmapEncoder.Get()->Initialize(
@@ -443,7 +443,7 @@ internal sealed unsafe class WICHelper
// Create and initialize a stream
this.wicImagingFactory2.Get()->CreateStream(wicStream.GetAddressOf()).Assert();
wicStream.Get()->InitializeFromBufferWriter(writer);
_ = wicStream.Get()->InitializeFromBufferWriter(writer);
// Initialize the encoder
wicBitmapEncoder.Get()->Initialize(
@@ -524,7 +524,7 @@ internal sealed unsafe class WICHelper
pbPixels: (byte*)data).Assert();
}
wicBitmapFrameEncode.Get()->Commit();
wicBitmapEncoder->Commit();
_ = wicBitmapFrameEncode.Get()->Commit();
_ = wicBitmapEncoder->Commit();
}
}
+4 -4
ファイルの表示
@@ -19,7 +19,7 @@ public partial class D2D1PixelShaderTests
Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(bytecode, out MemoryManager<byte>? manager));
Assert.AreEqual("PinnedBufferMemoryManager", manager!.GetType().Name);
D2D1PixelShader.LoadBytecode<ShaderWithNoCompileAttributes>(
_ = D2D1PixelShader.LoadBytecode<ShaderWithNoCompileAttributes>(
shaderProfile: D2D1ShaderProfile.PixelShader41,
options: D2D1CompileOptions.IeeeStrictness | D2D1CompileOptions.OptimizationLevel2 | D2D1CompileOptions.PartialPrecision);
@@ -53,7 +53,7 @@ public partial class D2D1PixelShaderTests
Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(bytecode, out MemoryManager<byte>? manager));
Assert.AreEqual("PinnedBufferMemoryManager", manager!.GetType().Name);
D2D1PixelShader.LoadBytecode<ShaderWithOverriddenProfile>(
_ = D2D1PixelShader.LoadBytecode<ShaderWithOverriddenProfile>(
shaderProfile: D2D1ShaderProfile.PixelShader50,
options: D2D1CompileOptions.IeeeStrictness | D2D1CompileOptions.OptimizationLevel2 | D2D1CompileOptions.PartialPrecision);
@@ -87,7 +87,7 @@ public partial class D2D1PixelShaderTests
Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(bytecode, out MemoryManager<byte>? manager));
Assert.AreEqual("PinnedBufferMemoryManager", manager!.GetType().Name);
D2D1PixelShader.LoadBytecode<ShaderWithOverriddenOptions>(
_ = D2D1PixelShader.LoadBytecode<ShaderWithOverriddenOptions>(
shaderProfile: D2D1ShaderProfile.PixelShader41,
options: D2D1CompileOptions.Debug | D2D1CompileOptions.AvoidFlowControl | D2D1CompileOptions.PartialPrecision);
@@ -121,7 +121,7 @@ public partial class D2D1PixelShaderTests
Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(bytecode, out MemoryManager<byte>? manager));
Assert.AreEqual("PinnedBufferMemoryManager", manager!.GetType().Name);
D2D1PixelShader.LoadBytecode<ShaderWithOverriddenProfileAndOptions>(
_ = D2D1PixelShader.LoadBytecode<ShaderWithOverriddenProfileAndOptions>(
shaderProfile: D2D1ShaderProfile.PixelShader50,
options: D2D1CompileOptions.Debug | D2D1CompileOptions.AvoidFlowControl | D2D1CompileOptions.PartialPrecision);
+1 -1
ファイルの表示
@@ -447,7 +447,7 @@ public sealed partial class BokehBlurEffect
}
else
{
compositeEffect.Get()->SetInputCount((uint)numberOfComponents);
_ = compositeEffect.Get()->SetInputCount((uint)numberOfComponents);
// Aggregate all partial results with the composite effect
for (int i = 0; i < numberOfComponents; i++)
+2 -2
ファイルの表示
@@ -96,7 +96,7 @@ internal static class D2D1Helper
using ComPtr<ID2D1Device> d2D1Device = default;
// Create a D2D1 device
d2D1Factory2->CreateDevice(
_ = d2D1Factory2->CreateDevice(
dxgiDevice: (IDXGIDevice*)dxgiDevice3.Get(),
d2dDevice: d2D1Device.GetAddressOf());
@@ -227,7 +227,7 @@ internal static class D2D1Helper
d2DRectSource.bottom = (uint)d2DSize.Height;
// Copy the image from the target to the readback bitmap
d2D1Bitmap1Buffer.Get()->CopyFromBitmap(
_ = d2D1Bitmap1Buffer.Get()->CopyFromBitmap(
destPoint: &d2DPointDestination,
bitmap: d2D1Bitmap,
srcRect: &d2DRectSource);
+3 -3
ファイルの表示
@@ -40,7 +40,7 @@ public class GetDefaultDeviceTests
device1.Dispose();
// The device is correctly marked as disposed
Assert.ThrowsException<ObjectDisposedException>(() => device1.IsDoublePrecisionSupportAvailable());
_ = Assert.ThrowsException<ObjectDisposedException>(() => device1.IsDoublePrecisionSupportAvailable());
// Now there should just be this one last reference left to the native device
Assert.AreEqual(1u, GraphicsDeviceHelper.GetD3D12DeviceRefCount(in d3D12Device));
@@ -65,7 +65,7 @@ public class GetDefaultDeviceTests
device4.Dispose();
// The device is correctly marked as disposed
Assert.ThrowsException<ObjectDisposedException>(() => device4.IsDoublePrecisionSupportAvailable());
_ = Assert.ThrowsException<ObjectDisposedException>(() => device4.IsDoublePrecisionSupportAvailable());
// Sanity check that this is in fact the only reference keeping the device alive
Assert.AreEqual(1u, GraphicsDeviceHelper.GetD3D12DeviceRefCount(in d3D12Device));
@@ -79,7 +79,7 @@ public class GetDefaultDeviceTests
}
// Calling GraphicsDevice.GetDefault() will now throw, because the native device has not been disposed properly
Assert.ThrowsException<InvalidOperationException>(() => GraphicsDevice.GetDefault());
_ = Assert.ThrowsException<InvalidOperationException>(() => GraphicsDevice.GetDefault());
}
}
+2 -2
ファイルの表示
@@ -68,7 +68,7 @@ internal static class GraphicsDeviceHelper
{
if (d3D12Device is not null)
{
d3D12Device->Release();
_ = d3D12Device->Release();
}
}
}
@@ -92,6 +92,6 @@ internal static class GraphicsDeviceHelper
RemoveDevice(graphicsDevice);
await tcs.Task;
_ = await tcs.Task;
}
}
+5 -5
ファイルの表示
@@ -18,11 +18,11 @@ public class NativeObjectTests
Assert.IsTrue(obj.IsDisposed);
using var _ = obj.TryGetReferenceTrackingLease(out bool leaseTaken);
using var lease0 = obj.TryGetReferenceTrackingLease(out bool leaseTaken);
Assert.IsFalse(leaseTaken);
Assert.ThrowsException<ObjectDisposedException>(() => obj.GetReferenceTrackingLease());
_ = Assert.ThrowsException<ObjectDisposedException>(() => obj.GetReferenceTrackingLease());
}
[TestMethod]
@@ -85,7 +85,7 @@ public class NativeObjectTests
{
DisposableObject obj = new();
Parallel.For(0, 2048, i =>
_ = Parallel.For(0, 2048, i =>
{
for (int j = 0; j < 4; j++)
{
@@ -105,7 +105,7 @@ public class NativeObjectTests
{
DisposableObject obj = new();
Parallel.For(0, 2048, i =>
_ = Parallel.For(0, 2048, i =>
{
bool isDisposed = false;
@@ -137,7 +137,7 @@ public class NativeObjectTests
var outstandingLease = obj.GetReferenceTrackingLease();
Parallel.For(0, 2048, i =>
_ = Parallel.For(0, 2048, i =>
{
bool isDisposed = false;
@@ -119,7 +119,7 @@ public abstract class NativeLibrariesResolverTestsBase
// Furthermore, only publishing in Release mode is tested.
CleanSampleProject(Configuration.Release, RID.Win_x64);
Exec(SampleProjectDirectory, "dotnet", $"publish -c Release -f net6.0 -r win-x64 {ToOption(publishMode)} {ToOption(deploymentMode)} {ToOption(nativeLibsDeploymentMode)} /bl");
_ = Exec(SampleProjectDirectory, "dotnet", $"publish -c Release -f net6.0 -r win-x64 {ToOption(publishMode)} {ToOption(deploymentMode)} {ToOption(nativeLibsDeploymentMode)} /bl");
string pathToAppHost = Path.Combine("bin", $"Release", "net6.0", "win-x64", "publish", $"{SampleProjectName}.exe");
@@ -135,7 +135,7 @@ public abstract class NativeLibrariesResolverTestsBase
/// <param name="rid">The RID for which the output is cleaned.</param>
private void CleanSampleProject(Configuration configuration, RID rid)
{
Exec(SampleProjectDirectory, "dotnet", $"clean -c {configuration} {ToOption(rid)}");
_ = Exec(SampleProjectDirectory, "dotnet", $"clean -c {configuration} {ToOption(rid)}");
}
/// <summary>
@@ -145,7 +145,7 @@ public abstract class NativeLibrariesResolverTestsBase
/// <param name="rid">The RID to use to build the project.</param>
private void BuildSampleProject(Configuration configuration, RID rid)
{
Exec(SampleProjectDirectory, "dotnet", $"build -c {configuration} {ToOption(rid)}");
_ = Exec(SampleProjectDirectory, "dotnet", $"build -c {configuration} {ToOption(rid)}");
}
/// <summary>
+1 -1
ファイルの表示
@@ -97,7 +97,7 @@ public class AutoConstructorGeneratorTests
CSharpGeneratorDriver driver = CSharpGeneratorDriver.Create(generator);
driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray<Diagnostic> diagnostics);
_ = driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray<Diagnostic> diagnostics);
string outputBody = outputCompilation.SyntaxTrees.Skip(index + 1).First().ToString();
+1 -1
ファイルの表示
@@ -1810,7 +1810,7 @@ public class DiagnosticsTests
CSharpGeneratorDriver driver = CSharpGeneratorDriver.Create(generator);
driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray<Diagnostic> diagnostics);
_ = driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray<Diagnostic> diagnostics);
HashSet<string> resultingIds = diagnostics.Select(diagnostic => diagnostic.Id).ToHashSet();
+1 -1
ファイルの表示
@@ -655,7 +655,7 @@ public partial class ComputeContextTests
_ = device.Get();
Parallel.For(0, 64, _ => Test(device));
_ = Parallel.For(0, 64, _ => Test(device));
}
[CombinatorialTestMethod]
+2 -2
ファイルの表示
@@ -24,7 +24,7 @@ public static class TestHelper
try
{
@delegate.Method.GetGenericMethodDefinition().MakeGenericMethod(type).Invoke(null, arguments);
_ = @delegate.Method.GetGenericMethodDefinition().MakeGenericMethod(type).Invoke(null, arguments);
}
catch (TargetInvocationException e) when (e.InnerException is not null)
{
@@ -48,7 +48,7 @@ public static class TestHelper
try
{
@delegate.Method.GetGenericMethodDefinition().MakeGenericMethod(type1, type2).Invoke(null, arguments);
_ = @delegate.Method.GetGenericMethodDefinition().MakeGenericMethod(type1, type2).Invoke(null, arguments);
}
catch (TargetInvocationException e) when (e.InnerException is not null)
{
+3 -3
ファイルの表示
@@ -99,12 +99,12 @@ internal static class TolerantImageComparer
if (normalizedDifference > threshold)
{
StringBuilder builder = new();
builder.AppendLine($"The input images don't match. Normalized delta: {normalizedDifference}%");
builder.AppendLine($"First {differences.Count} pixel deltas:");
_ = builder.AppendLine($"The input images don't match. Normalized delta: {normalizedDifference}%");
_ = builder.AppendLine($"First {differences.Count} pixel deltas:");
foreach (var delta in differences)
{
builder.AppendLine(delta.ToString());
_ = builder.AppendLine(delta.ToString());
}
Assert.Fail(builder.ToString());
+2 -2
ファイルの表示
@@ -171,7 +171,7 @@ public class ShadersTests
var action = new Action<ReadWriteTexture2D<Rgba32, float4>>(RunComputeShader<SwapChain.Shaders.Compute.ColorfulInfinity>);
action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
_ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
}
else
{
@@ -183,7 +183,7 @@ public class ShadersTests
var action = new Action<ReadWriteTexture2D<Rgba32, float4>>(RunPixelShader<ColorfulInfinity>);
action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
_ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
}
_ = image.DangerousTryGetSinglePixelMemory(out Memory<ImageSharpRgba32> memory);