From 9343ac7f7b522eecbabadd1231a29793081000fb Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 15 Oct 2022 15:01:48 +0200 Subject: [PATCH] Add explicit discards to all value returning expressions --- .../Blas/BlasHelpers.cs | 2 +- .../HlslBokehBlurProcessor{TPixel}.cs | 2 +- .../Services/DebugAnalyticsService.cs | 12 ++++---- .../Views/MainView.xaml.cs | 4 +-- .../Views/MainWindow.xaml.cs | 4 +-- .../Backend/SwapChainApplication{T}.cs | 24 +++++++-------- .../Backend/Win32ApplicationRunner.cs | 4 +-- samples/ComputeSharp.SwapChain/Program.cs | 2 +- ...erGenerator.CreateBuildHlslSourceMethod.cs | 6 ++-- .../Exceptions/FxcCompilationException.cs | 12 ++++---- .../Interop/D2D1ResourceTextureManager.cs | 2 +- .../Effects/PixelShaderEffect.Properties.cs | 4 +-- ...mpl.ID2D1ResourceTextureManagerInternal.cs | 6 ++-- .../Loaders/D2D1DrawInfoDispatchDataLoader.cs | 2 +- .../Exceptions/DxcCompilationException.cs | 12 ++++---- .../Mappings/HlslKnownKeywords.cs | 4 +-- .../Mappings/HlslKnownTypes.cs | 4 +-- ...ator.CreateBuildHlslSourceMethod.Syntax.cs | 8 ++--- ...erGenerator.CreateBuildHlslSourceMethod.cs | 14 ++++----- ...haderGenerator.CreateLoadBytecodeMethod.cs | 2 +- .../Extensions/SemaphoreSlimExtensions.cs | 2 +- .../Helpers/SwapChainManager.Rendering.cs | 2 +- .../Helpers/SwapChainManager.cs | 2 +- .../Commands/Interop/ID3D12CommandListPool.cs | 8 ++--- .../GraphicsDeviceMismatchException.cs | 10 +++---- .../UnsupportedDoubleOperationsException.cs | 8 ++--- .../UnsupportedTextureTypeException.cs | 8 ++--- .../Graphics/GraphicsDevice.DeviceLost.cs | 2 +- src/ComputeSharp/Graphics/GraphicsDevice.cs | 2 +- .../Graphics/Helpers/DeviceHelper.Factory.cs | 4 +-- .../Helpers/DeviceHelper.ID3D12InfoQueue.cs | 30 +++++++++---------- .../Helpers/DeviceHelper.IDXGIFactory6.cs | 2 +- .../Graphics/Helpers/DeviceHelper.cs | 8 ++--- .../Graphics/Helpers/WICHelper.cs | 10 +++---- .../D2D1PixelShaderTests.cs | 8 ++--- .../Effects/BokehBlurEffect.cs | 2 +- .../Helpers/D2D1Helper.cs | 4 +-- .../GetDefaultDeviceTests.cs | 6 ++-- .../Helpers/GraphicsDeviceHelper.cs | 4 +-- .../NativeObjectTests.cs | 10 +++---- .../NativeLibrariesResolverTestsBase.cs | 6 ++-- .../AutoConstructorGeneratorTests.cs | 2 +- .../DiagnosticsTests.cs | 2 +- .../ComputeSharp.Tests/ComputeContextTests.cs | 2 +- .../ComputeSharp.Tests/Helpers/TestHelper.cs | 4 +-- .../Helpers/TolerantImageComparer.cs | 6 ++-- tests/ComputeSharp.Tests/ShadersTests.cs | 4 +-- 47 files changed, 144 insertions(+), 144 deletions(-) diff --git a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs index e95ba25f..0d68fc03 100644 --- a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs +++ b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs @@ -47,7 +47,7 @@ internal static partial class BlasHelpers } } - Parallel.For(0, c, Kernel); + _ = Parallel.For(0, c, Kernel); } /// diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs index a6f41d0e..ae9c1dc8 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs @@ -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)); } } diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs index 1ce14814..97550c59 100644 --- a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs +++ b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs @@ -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 ?? ""}\""); + _ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\""); } } @@ -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 ?? ""}\""); + _ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\""); } } diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs index 4528f462..f249acd9 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs +++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs @@ -31,7 +31,7 @@ public sealed partial class MainView : UserControl { Ioc.Default.GetRequiredService().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().Log(Event.CloseShaderSelectionPanel); - Root.Children.Remove(ShaderSelectionPanel); + _ = Root.Children.Remove(ShaderSelectionPanel); } // Updates the size of the shaders list panel diff --git a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs index 37076f21..fa900fea 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs +++ b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs @@ -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 diff --git a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs index e0146e4c..83e84f0d 100644 --- a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs +++ b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs @@ -147,7 +147,7 @@ internal sealed class SwapChainApplication : 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(), (void**)d3D12CommandAllocator); @@ -156,7 +156,7 @@ internal sealed class SwapChainApplication : 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 : Win32Application } // Close the command list to prepare it for future use - this.d3D12GraphicsCommandList.Get()->Close(); + _ = this.d3D12GraphicsCommandList.Get()->Close(); } /// @@ -180,10 +180,10 @@ internal sealed class SwapChainApplication : Win32Application /// 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 : 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 dxgiSwapChain3 = default) @@ -249,8 +249,8 @@ internal sealed class SwapChainApplication : 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 : 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++; diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs index 43d8c818..bc3b9f6b 100644 --- a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs +++ b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs @@ -196,11 +196,11 @@ internal unsafe static class Win32ApplicationRunner if (isPaused) { - Windows.SetCapture(hwnd); + _ = Windows.SetCapture(hwnd); } else { - Windows.ReleaseCapture(); + _ = Windows.ReleaseCapture(); } isPaused = !isPaused; diff --git a/samples/ComputeSharp.SwapChain/Program.cs b/samples/ComputeSharp.SwapChain/Program.cs index a94a3b16..d1606b2a 100644 --- a/samples/ComputeSharp.SwapChain/Program.cs +++ b/samples/ComputeSharp.SwapChain/Program.cs @@ -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); diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs index e7bfa22b..5ccebec3 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -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 diff --git a/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs b/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs index 35f43f46..c7b2b7f3 100644 --- a/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs +++ b/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs @@ -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(); } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureManager.cs index cdb769aa..3c1234ce 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureManager.cs @@ -342,7 +342,7 @@ public sealed unsafe class D2D1ResourceTextureManager : ICustomQueryInterface { if (this.d2D1ResourceManagerImpl is not null) { - this.d2D1ResourceManagerImpl->Release(); + _ = this.d2D1ResourceManagerImpl->Release(); } } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs index bf19ed26..c3c128ac 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs @@ -178,7 +178,7 @@ unsafe partial struct PixelShaderEffect using ComPtr 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 diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs index 6d16384c..fefe89cf 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs @@ -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); diff --git a/src/ComputeSharp.D2D1/Shaders/Loaders/D2D1DrawInfoDispatchDataLoader.cs b/src/ComputeSharp.D2D1/Shaders/Loaders/D2D1DrawInfoDispatchDataLoader.cs index e6d1e1f4..0f302f4b 100644 --- a/src/ComputeSharp.D2D1/Shaders/Loaders/D2D1DrawInfoDispatchDataLoader.cs +++ b/src/ComputeSharp.D2D1/Shaders/Loaders/D2D1DrawInfoDispatchDataLoader.cs @@ -31,7 +31,7 @@ internal readonly unsafe struct D2D1DrawInfoDispatchDataLoader : ID2D1DispatchDa /// void ID2D1DispatchDataLoader.LoadConstantBuffer(ReadOnlySpan data) { - this.d2D1DrawInfo->SetPixelShaderConstantBuffer( + _ = this.d2D1DrawInfo->SetPixelShaderConstantBuffer( buffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)), bufferCount: (uint)data.Length); } diff --git a/src/ComputeSharp.Dynamic/Shaders/Exceptions/DxcCompilationException.cs b/src/ComputeSharp.Dynamic/Shaders/Exceptions/DxcCompilationException.cs index 418d8fd5..634b84dd 100644 --- a/src/ComputeSharp.Dynamic/Shaders/Exceptions/DxcCompilationException.cs +++ b/src/ComputeSharp.Dynamic/Shaders/Exceptions/DxcCompilationException.cs @@ -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(); } diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs index 9becbce8..1175f6ee 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs @@ -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()?.Name ?? method.Name; - knownKeywords.Add(name); + _ = knownKeywords.Add(name); } // Let other types inject additional keywords diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs index ef98563f..1120d5a5 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs @@ -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; } diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs index 3bfc1043..c408de07 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs @@ -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(); } } diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs index 544ee08b..7bf082b7 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -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; } diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs index f27e9a7f..4c432101 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs @@ -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); diff --git a/src/ComputeSharp.UI/Extensions/SemaphoreSlimExtensions.cs b/src/ComputeSharp.UI/Extensions/SemaphoreSlimExtensions.cs index c8e9d134..750e637d 100644 --- a/src/ComputeSharp.UI/Extensions/SemaphoreSlimExtensions.cs +++ b/src/ComputeSharp.UI/Extensions/SemaphoreSlimExtensions.cs @@ -50,7 +50,7 @@ internal static class SemaphoreSlimExtensions /// public void Dispose() { - this.semaphore.Release(); + _ = this.semaphore.Release(); } } } \ No newline at end of file diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs index d59738bc..de92d10d 100644 --- a/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs +++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs @@ -210,7 +210,7 @@ partial class SwapChainManager } finally { - this.renderSemaphore.Release(); + _ = this.renderSemaphore.Release(); } } diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs index 996c25f0..4be41123 100644 --- a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs +++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs @@ -531,7 +531,7 @@ internal sealed unsafe partial class SwapChainManager : NativeObject @this.swapChainPanelNative.Get()->SetSwapChain(null).Assert(); @this.swapChainPanelNative.Dispose(); - ThreadPool.UnsafeQueueUserWorkItem(static state => + _ = ThreadPool.UnsafeQueueUserWorkItem(static state => { SwapChainManager @this = (SwapChainManager)state!; diff --git a/src/ComputeSharp/Graphics/Commands/Interop/ID3D12CommandListPool.cs b/src/ComputeSharp/Graphics/Commands/Interop/ID3D12CommandListPool.cs index 1f6e835e..7588057e 100644 --- a/src/ComputeSharp/Graphics/Commands/Interop/ID3D12CommandListPool.cs +++ b/src/ComputeSharp/Graphics/Commands/Interop/ID3D12CommandListPool.cs @@ -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); } } diff --git a/src/ComputeSharp/Graphics/Exceptions/GraphicsDeviceMismatchException.cs b/src/ComputeSharp/Graphics/Exceptions/GraphicsDeviceMismatchException.cs index d434713a..e953fb2d 100644 --- a/src/ComputeSharp/Graphics/Exceptions/GraphicsDeviceMismatchException.cs +++ b/src/ComputeSharp/Graphics/Exceptions/GraphicsDeviceMismatchException.cs @@ -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()); } diff --git a/src/ComputeSharp/Graphics/Exceptions/UnsupportedDoubleOperationsException.cs b/src/ComputeSharp/Graphics/Exceptions/UnsupportedDoubleOperationsException.cs index fd1dd913..0c4b8fdb 100644 --- a/src/ComputeSharp/Graphics/Exceptions/UnsupportedDoubleOperationsException.cs +++ b/src/ComputeSharp/Graphics/Exceptions/UnsupportedDoubleOperationsException.cs @@ -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()); } diff --git a/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs b/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs index 6e77879b..4d4c5863 100644 --- a/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs +++ b/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs @@ -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)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture1DSupportedForType)}().", 2 => $"{nameof(GraphicsDevice.IsReadOnlyTexture2DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture2DSupportedForType)}().", @@ -39,7 +39,7 @@ public sealed class UnsupportedTextureTypeException : NotSupportedException _ => ThrowHelper.ThrowArgumentException("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()); } diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs b/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs index fd106449..e0f6c8e1 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs @@ -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); } /// diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.cs b/src/ComputeSharp/Graphics/GraphicsDevice.cs index 48f354d4..460e8325 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.cs @@ -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>(); + _ = ThrowHelper.ThrowArgumentException>(); d3D12CommandList = null; d3D12CommandAllocator = null; break; diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs index 78f13df4..d964ffab 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs @@ -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 queue); + _ = D3D12InfoQueueMap.Remove(device.Luid, out ComPtr queue); queue.Dispose(); } diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs index b9c0a2b8..a10cb845 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs @@ -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("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 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) diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs index b4666593..dad22eed 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs @@ -206,7 +206,7 @@ partial class DeviceHelper [UnmanagedCallersOnly] private static uint Release(IDXGIFactory4As6Backcompat* @this) { - @this->dxgiFactory4->Release(); + _ = @this->dxgiFactory4->Release(); NativeMemory.Free(@this); diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs index 2743edc6..f5506087 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs @@ -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; } diff --git a/src/ComputeSharp/Graphics/Helpers/WICHelper.cs b/src/ComputeSharp/Graphics/Helpers/WICHelper.cs index 6d072396..791fd01f 100644 --- a/src/ComputeSharp/Graphics/Helpers/WICHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/WICHelper.cs @@ -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(); } } \ No newline at end of file diff --git a/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/D2D1PixelShaderTests.cs b/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/D2D1PixelShaderTests.cs index cf350586..4a26be0f 100644 --- a/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/D2D1PixelShaderTests.cs +++ b/tests/ComputeSharp.D2D1.Tests.AssemblyLevelAttributes/D2D1PixelShaderTests.cs @@ -19,7 +19,7 @@ public partial class D2D1PixelShaderTests Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(bytecode, out MemoryManager? manager)); Assert.AreEqual("PinnedBufferMemoryManager", manager!.GetType().Name); - D2D1PixelShader.LoadBytecode( + _ = D2D1PixelShader.LoadBytecode( 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? manager)); Assert.AreEqual("PinnedBufferMemoryManager", manager!.GetType().Name); - D2D1PixelShader.LoadBytecode( + _ = D2D1PixelShader.LoadBytecode( 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? manager)); Assert.AreEqual("PinnedBufferMemoryManager", manager!.GetType().Name); - D2D1PixelShader.LoadBytecode( + _ = D2D1PixelShader.LoadBytecode( 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? manager)); Assert.AreEqual("PinnedBufferMemoryManager", manager!.GetType().Name); - D2D1PixelShader.LoadBytecode( + _ = D2D1PixelShader.LoadBytecode( shaderProfile: D2D1ShaderProfile.PixelShader50, options: D2D1CompileOptions.Debug | D2D1CompileOptions.AvoidFlowControl | D2D1CompileOptions.PartialPrecision); diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs index e759cbbf..eae44adb 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs @@ -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++) diff --git a/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1Helper.cs b/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1Helper.cs index e0d9e554..199de1ce 100644 --- a/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1Helper.cs +++ b/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1Helper.cs @@ -96,7 +96,7 @@ internal static class D2D1Helper using ComPtr 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); diff --git a/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs b/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs index f4de275a..1b719435 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs @@ -40,7 +40,7 @@ public class GetDefaultDeviceTests device1.Dispose(); // The device is correctly marked as disposed - Assert.ThrowsException(() => device1.IsDoublePrecisionSupportAvailable()); + _ = Assert.ThrowsException(() => 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(() => device4.IsDoublePrecisionSupportAvailable()); + _ = Assert.ThrowsException(() => 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(() => GraphicsDevice.GetDefault()); + _ = Assert.ThrowsException(() => GraphicsDevice.GetDefault()); } } diff --git a/tests/ComputeSharp.Tests.DeviceLost/Helpers/GraphicsDeviceHelper.cs b/tests/ComputeSharp.Tests.DeviceLost/Helpers/GraphicsDeviceHelper.cs index a96569ff..de319cdf 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/Helpers/GraphicsDeviceHelper.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/Helpers/GraphicsDeviceHelper.cs @@ -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; } } \ No newline at end of file diff --git a/tests/ComputeSharp.Tests.Internals/NativeObjectTests.cs b/tests/ComputeSharp.Tests.Internals/NativeObjectTests.cs index aa87080d..c43fc31a 100644 --- a/tests/ComputeSharp.Tests.Internals/NativeObjectTests.cs +++ b/tests/ComputeSharp.Tests.Internals/NativeObjectTests.cs @@ -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(() => obj.GetReferenceTrackingLease()); + _ = Assert.ThrowsException(() => 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; diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs b/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs index 37bdfba5..2a10561b 100644 --- a/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs +++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs @@ -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 /// The RID for which the output is cleaned. private void CleanSampleProject(Configuration configuration, RID rid) { - Exec(SampleProjectDirectory, "dotnet", $"clean -c {configuration} {ToOption(rid)}"); + _ = Exec(SampleProjectDirectory, "dotnet", $"clean -c {configuration} {ToOption(rid)}"); } /// @@ -145,7 +145,7 @@ public abstract class NativeLibrariesResolverTestsBase /// The RID to use to build the project. private void BuildSampleProject(Configuration configuration, RID rid) { - Exec(SampleProjectDirectory, "dotnet", $"build -c {configuration} {ToOption(rid)}"); + _ = Exec(SampleProjectDirectory, "dotnet", $"build -c {configuration} {ToOption(rid)}"); } /// diff --git a/tests/ComputeSharp.Tests.SourceGenerators/AutoConstructorGeneratorTests.cs b/tests/ComputeSharp.Tests.SourceGenerators/AutoConstructorGeneratorTests.cs index f7df6388..7d897463 100644 --- a/tests/ComputeSharp.Tests.SourceGenerators/AutoConstructorGeneratorTests.cs +++ b/tests/ComputeSharp.Tests.SourceGenerators/AutoConstructorGeneratorTests.cs @@ -97,7 +97,7 @@ public class AutoConstructorGeneratorTests CSharpGeneratorDriver driver = CSharpGeneratorDriver.Create(generator); - driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray diagnostics); + _ = driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray diagnostics); string outputBody = outputCompilation.SyntaxTrees.Skip(index + 1).First().ToString(); diff --git a/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs b/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs index 291180b4..b7d90664 100644 --- a/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs +++ b/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs @@ -1810,7 +1810,7 @@ public class DiagnosticsTests CSharpGeneratorDriver driver = CSharpGeneratorDriver.Create(generator); - driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray diagnostics); + _ = driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray diagnostics); HashSet resultingIds = diagnostics.Select(diagnostic => diagnostic.Id).ToHashSet(); diff --git a/tests/ComputeSharp.Tests/ComputeContextTests.cs b/tests/ComputeSharp.Tests/ComputeContextTests.cs index b1b549fe..11e535fd 100644 --- a/tests/ComputeSharp.Tests/ComputeContextTests.cs +++ b/tests/ComputeSharp.Tests/ComputeContextTests.cs @@ -655,7 +655,7 @@ public partial class ComputeContextTests _ = device.Get(); - Parallel.For(0, 64, _ => Test(device)); + _ = Parallel.For(0, 64, _ => Test(device)); } [CombinatorialTestMethod] diff --git a/tests/ComputeSharp.Tests/Helpers/TestHelper.cs b/tests/ComputeSharp.Tests/Helpers/TestHelper.cs index 08ac4eca..992c4276 100644 --- a/tests/ComputeSharp.Tests/Helpers/TestHelper.cs +++ b/tests/ComputeSharp.Tests/Helpers/TestHelper.cs @@ -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) { diff --git a/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs b/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs index 43894ff2..21327df0 100644 --- a/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs +++ b/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs @@ -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()); diff --git a/tests/ComputeSharp.Tests/ShadersTests.cs b/tests/ComputeSharp.Tests/ShadersTests.cs index a1b3d772..2432060f 100644 --- a/tests/ComputeSharp.Tests/ShadersTests.cs +++ b/tests/ComputeSharp.Tests/ShadersTests.cs @@ -171,7 +171,7 @@ public class ShadersTests var action = new Action>(RunComputeShader); - 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>(RunPixelShader); - action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture }); + _ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture }); } _ = image.DangerousTryGetSinglePixelMemory(out Memory memory);