From 746f132182ae18d7009c312da3645bcaac89878c Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 15 Oct 2022 13:08:15 +0200 Subject: [PATCH] Adjust field visibility, fix naming violations in non test projects --- .editorconfig | 8 +- .../Blas/BlasHelpers.cs | 14 +-- .../Dispatching/DispatchingBenchmark.cs | 2 +- .../HlslBokehBlurProcessor{TPixel}.cs | 106 +++++++++--------- .../Processors/HlslGaussianBlurProcessor.cs | 5 +- .../HlslGaussianBlurProcessor{TPixel}.cs | 28 ++--- .../MultiplyByTwo.cs | 2 +- samples/ComputeSharp.Sample/Program.cs | 2 +- .../ColorfulInfinity.cs | 2 +- .../ContouredLayers.cs | 4 +- .../ExtrudedTruchetPattern.cs | 2 +- .../FourColorGradient.cs | 14 +-- .../FractalTiling.cs | 2 +- .../HelloWorld.cs | 2 +- .../MengerJourney.cs | 6 +- .../Octagrams.cs | 2 +- .../ProteanClouds.cs | 6 +- .../PyramidPattern.cs | 2 +- .../TriangleGridContouring.cs | 11 +- .../TwoTiledTruchet.cs | 2 +- ...TryWriteFormatInterpolatedStringHandler.cs | 4 +- src/ComputeSharp.Core/Primitives/Bool/Bool.cs | 14 +-- ...nerator.CreateLoadBytecodeMethod.Syntax.cs | 6 +- .../Shaders/Translation/ShaderCompiler.cs | 28 ++--- .../Helpers/HashCode.cs | 2 +- .../Helpers/ImmutableArrayBuilder{T}.cs | 4 +- ...nerator.CreateLoadBytecodeMethod.Syntax.cs | 6 +- .../IWICStreamExtensions.IBufferWriter.cs | 8 +- .../Interop/IWICStreamExtensions.Stream.cs | 8 +- .../Graphics/Helpers/DeviceHelper.Factory.cs | 2 +- .../Helpers/DeviceHelper.IDXGIFactory6.cs | 8 +- .../Interop/__Internals/ResourceDescriptor.cs | 2 +- src/ComputeSharp/Shaders/Models/ShaderKey.cs | 26 ++--- tests/.editorconfig | 2 + 34 files changed, 171 insertions(+), 171 deletions(-) create mode 100644 tests/.editorconfig diff --git a/.editorconfig b/.editorconfig index a5b1e9f2..d15bf821 100644 --- a/.editorconfig +++ b/.editorconfig @@ -219,8 +219,8 @@ dotnet_naming_style.prefix_interface_interface_with_i.required_prefix # Naming Rules -# Async -dotnet_naming_rule.async_methods_end_in_async.severity = warning +# Async methods should have the "Async" suffix (disabled because it can't currently exclude async void methods) +dotnet_naming_rule.async_methods_end_in_async.severity = none dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods dotnet_naming_rule.async_methods_end_in_async.style = end_in_async @@ -251,8 +251,8 @@ dotnet_naming_rule.non_private_fields_must_be_pascal_case.style dotnet_naming_rule.public_symbols_must_be_capitalized.severity = warning dotnet_naming_rule.public_symbols_must_be_capitalized.symbols = public_symbols dotnet_naming_rule.public_symbols_must_be_capitalized.style = pascal_case -# Parameters must be camelCase -dotnet_naming_rule.parameters_must_be_camel_case.severity = warning +# Parameters must be camelCase (ignored because some use PascalCase to match Win32 parameter names) +dotnet_naming_rule.parameters_must_be_camel_case.severity = none dotnet_naming_rule.parameters_must_be_camel_case.symbols = parameters dotnet_naming_rule.parameters_must_be_camel_case.style = camel_case # Interfaces must be PascalCase and start with an 'I' diff --git a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs index 8f789cc9..e95ba25f 100644 --- a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs +++ b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs @@ -83,13 +83,13 @@ internal static partial class BlasHelpers [AutoConstructor] public readonly partial struct FullyConnectedForwardKernel : IComputeShader { - public readonly int n; - public readonly int m; - public readonly int p; - public readonly ReadOnlyBuffer x; - public readonly ReadOnlyBuffer w; - public readonly ReadOnlyBuffer b; - public readonly ReadWriteBuffer y; + private readonly int n; + private readonly int m; + private readonly int p; + private readonly ReadOnlyBuffer x; + private readonly ReadOnlyBuffer w; + private readonly ReadOnlyBuffer b; + private readonly ReadWriteBuffer y; /// public void Execute() diff --git a/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs b/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs index 4fa7a91e..a3ec85a8 100644 --- a/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs +++ b/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs @@ -111,7 +111,7 @@ public partial class DispatchingBenchmark : IDisposable [AutoConstructor] internal readonly partial struct TestShader : IComputeShader { - public readonly ReadWriteBuffer buffer; + private readonly ReadWriteBuffer buffer; /// public void Execute() diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs index d5577809..a6f41d0e 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs @@ -23,37 +23,37 @@ public sealed partial class HlslBokehBlurProcessor /// /// The instance in use. /// - private readonly GraphicsDevice GraphicsDevice; + private readonly GraphicsDevice graphicsDevice; /// /// The kernel radius. /// - private readonly int Radius; + private readonly int radius; /// /// The maximum size of the kernel in either direction. /// - private readonly int KernelSize; + private readonly int kernelSize; /// /// The number of components to use when applying the bokeh blur. /// - private readonly int ComponentsCount; + private readonly int componentsCount; /// /// The kernel parameters to use for the current instance (a: X, b: Y, A: Z, B: W) /// - private readonly Vector4[] KernelParameters; + private readonly Vector4[] kernelParameters; /// /// The kernel components for the current instance. /// - private readonly Complex64[][] Kernels; + private readonly Complex64[][] kernels; /// /// The scaling factor for kernel values. /// - private readonly float KernelsScale; + private readonly float kernelsScale; /// /// The mapping of initialized complex kernels and parameters, to speed up the initialization of new instances. @@ -70,29 +70,29 @@ public sealed partial class HlslBokehBlurProcessor public Implementation(HlslBokehBlurProcessor definition, Configuration configuration, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) { - GraphicsDevice = definition.GraphicsDevice; - Radius = definition.Radius; - KernelSize = Radius * 2 + 1; - ComponentsCount = definition.Components; + graphicsDevice = definition.GraphicsDevice; + radius = definition.Radius; + kernelSize = radius * 2 + 1; + componentsCount = definition.Components; // Reuse the initialized values from the cache, if possible - var parameters = (Radius, ComponentsCount); + var parameters = (radius, componentsCount); if (Cache.TryGetValue(parameters, out var info)) { - KernelParameters = info.Parameters; - KernelsScale = info.Scale; - Kernels = info.Kernels; + kernelParameters = info.Parameters; + kernelsScale = info.Scale; + kernels = info.Kernels; } else { // Initialize the complex kernels and parameters with the current arguments - (KernelParameters, KernelsScale) = GetParameters(); - Kernels = CreateComplexKernels(); + (kernelParameters, kernelsScale) = GetParameters(); + kernels = CreateComplexKernels(); NormalizeKernels(); // Store them in the cache for future use - Cache.TryAdd(parameters, (KernelParameters, KernelsScale, Kernels)); + Cache.TryAdd(parameters, (kernelParameters, kernelsScale, kernels)); } } @@ -161,7 +161,7 @@ public sealed partial class HlslBokehBlurProcessor private (Vector4[] Parameters, float Scale) GetParameters() { // Prepare the kernel components - int index = Math.Max(0, Math.Min(ComponentsCount - 1, KernelComponents.Count)); + int index = Math.Max(0, Math.Min(componentsCount - 1, KernelComponents.Count)); return (KernelComponents[index], KernelScales[index]); } @@ -171,10 +171,10 @@ public sealed partial class HlslBokehBlurProcessor /// private Complex64[][] CreateComplexKernels() { - var kernels = new Complex64[KernelParameters.Length][]; - ref Vector4 baseRef = ref MemoryMarshal.GetReference(KernelParameters.AsSpan()); + var kernels = new Complex64[kernelParameters.Length][]; + ref Vector4 baseRef = ref MemoryMarshal.GetReference(kernelParameters.AsSpan()); - for (int i = 0; i < KernelParameters.Length; i++) + for (int i = 0; i < kernelParameters.Length; i++) { ref Vector4 paramsRef = ref Unsafe.Add(ref baseRef, i); @@ -191,15 +191,15 @@ public sealed partial class HlslBokehBlurProcessor /// The angle component for each complex component. private Complex64[] CreateComplex1DKernel(float a, float b) { - var kernel = new Complex64[KernelSize]; + var kernel = new Complex64[kernelSize]; ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel.AsSpan()); - int r = Radius; + int r = radius; int n = -r; - for (int i = 0; i < KernelSize; i++, n++) + for (int i = 0; i < kernelSize; i++, n++) { // Incrementally compute the range values - float value = n * KernelsScale * (1f / r); + float value = n * kernelsScale * (1f / r); value *= value; @@ -219,11 +219,11 @@ public sealed partial class HlslBokehBlurProcessor { // Calculate the complex weighted sum float total = 0; - Span kernelsSpan = Kernels.AsSpan(); + Span kernelsSpan = kernels.AsSpan(); ref Complex64[] baseKernelsRef = ref MemoryMarshal.GetReference(kernelsSpan); - ref Vector4 baseParamsRef = ref MemoryMarshal.GetReference(KernelParameters.AsSpan()); + ref Vector4 baseParamsRef = ref MemoryMarshal.GetReference(kernelParameters.AsSpan()); - for (int i = 0; i < KernelParameters.Length; i++) + for (int i = 0; i < kernelParameters.Length; i++) { ref Complex64[] kernelRef = ref Unsafe.Add(ref baseKernelsRef, i); int length = kernelRef.Length; @@ -270,23 +270,23 @@ public sealed partial class HlslBokehBlurProcessor Span span = MemoryMarshal.Cast(pixelMemory.Span); - using ReadWriteTexture2D texture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height); - using ReadWriteTexture2D temporary = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height, AllocationMode.Clear); - using ReadWriteTexture2D reals = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); - using ReadWriteTexture2D imaginaries = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); - using ReadOnlyBuffer kernel = GraphicsDevice.AllocateReadOnlyBuffer(KernelSize); + using ReadWriteTexture2D texture = graphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height); + using ReadWriteTexture2D temporary = graphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height, AllocationMode.Clear); + using ReadWriteTexture2D reals = graphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); + using ReadWriteTexture2D imaginaries = graphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); + using ReadOnlyBuffer kernel = graphicsDevice.AllocateReadOnlyBuffer(kernelSize); // Preliminary gamma highlight pass - GraphicsDevice.For(source.Height, new(texture)); + graphicsDevice.For(source.Height, new(texture)); // Perform two 1D convolutions for each component in the current instance - for (int j = 0; j < Kernels.Length; j++) + for (int j = 0; j < kernels.Length; j++) { - Vector4 parameters = KernelParameters[j]; + Vector4 parameters = kernelParameters[j]; - kernel.CopyFrom(Kernels[j]); + kernel.CopyFrom(kernels[j]); - using var context = GraphicsDevice.CreateComputeContext(); + using var context = graphicsDevice.CreateComputeContext(); context.For( source.Width, @@ -303,7 +303,7 @@ public sealed partial class HlslBokehBlurProcessor } // Apply the inverse gamma exposure pass - GraphicsDevice.For(source.Height, new(temporary, texture)); + graphicsDevice.For(source.Height, new(temporary, texture)); // Write the final pixel data texture.CopyTo(span); @@ -315,10 +315,10 @@ public sealed partial class HlslBokehBlurProcessor [AutoConstructor] internal partial struct VerticalConvolutionProcessor : IComputeShader { - public IReadWriteNormalizedTexture2D source; - public ReadWriteTexture2D reals; - public ReadWriteTexture2D imaginaries; - public ReadOnlyBuffer kernel; + private IReadWriteNormalizedTexture2D source; + private ReadWriteTexture2D reals; + private ReadWriteTexture2D imaginaries; + private ReadOnlyBuffer kernel; /// public void Execute() @@ -352,13 +352,13 @@ public sealed partial class HlslBokehBlurProcessor [AutoConstructor] internal partial struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader { - public float z; - public float w; + private float z; + private float w; - public ReadWriteTexture2D reals; - public ReadWriteTexture2D imaginaries; - public ReadWriteTexture2D target; - public ReadOnlyBuffer kernel; + private ReadWriteTexture2D reals; + private ReadWriteTexture2D imaginaries; + private ReadWriteTexture2D target; + private ReadOnlyBuffer kernel; /// public void Execute() @@ -391,7 +391,7 @@ public sealed partial class HlslBokehBlurProcessor [AutoConstructor] internal readonly partial struct GammaHighlightProcessor : IComputeShader { - public readonly IReadWriteNormalizedTexture2D source; + private readonly IReadWriteNormalizedTexture2D source; /// public void Execute() @@ -415,8 +415,8 @@ public sealed partial class HlslBokehBlurProcessor [AutoConstructor] internal readonly partial struct InverseGammaHighlightProcessor : IComputeShader { - public readonly ReadWriteTexture2D source; - public readonly IReadWriteNormalizedTexture2D target; + private readonly ReadWriteTexture2D source; + private readonly IReadWriteNormalizedTexture2D target; /// public void Execute() diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs index a677568b..0e54255a 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs @@ -52,7 +52,8 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor /// The radius value representing the size of the area to sample (this should be at least twice the sigma value) public HlslGaussianBlurProcessor(GraphicsDevice device, float sigma, int radius) { - GraphicsDevice = device; + graphicsDevice = device; + Sigma = sigma; Radius = radius; } @@ -60,7 +61,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor /// /// The instance in use. /// - private readonly GraphicsDevice GraphicsDevice; + private readonly GraphicsDevice graphicsDevice; /// /// Gets the sigma value representing the weight of the blur. diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs index 725a1c41..3b2ce50e 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs @@ -19,12 +19,12 @@ public sealed partial class HlslGaussianBlurProcessor /// /// The instance in use. /// - private readonly GraphicsDevice GraphicsDevice; + private readonly GraphicsDevice graphicsDevice; /// /// The 1D kernel to apply. /// - private readonly float[] Kernel; + private readonly float[] kernel; /// /// Initializes a new instance of the class. @@ -38,8 +38,8 @@ public sealed partial class HlslGaussianBlurProcessor { int kernelSize = definition.Radius * 2 + 1; - GraphicsDevice = definition.GraphicsDevice; - Kernel = CreateGaussianBlurKernel(kernelSize, definition.Sigma); + graphicsDevice = definition.graphicsDevice; + kernel = CreateGaussianBlurKernel(kernelSize, definition.Sigma); } /// @@ -100,11 +100,11 @@ public sealed partial class HlslGaussianBlurProcessor Span span = MemoryMarshal.Cast(pixelMemory.Span); - using ReadWriteTexture2D sourceTexture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height); - using ReadWriteTexture2D firstPassTexture = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); - using ReadOnlyBuffer kernelBuffer = GraphicsDevice.AllocateReadOnlyBuffer(Kernel); + using ReadWriteTexture2D sourceTexture = graphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height); + using ReadWriteTexture2D firstPassTexture = graphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); + using ReadOnlyBuffer kernelBuffer = graphicsDevice.AllocateReadOnlyBuffer(kernel); - using (var context = GraphicsDevice.CreateComputeContext()) + using (var context = graphicsDevice.CreateComputeContext()) { context.For(source.Width, source.Height, new(sourceTexture, firstPassTexture, kernelBuffer)); context.Barrier(firstPassTexture); @@ -120,9 +120,9 @@ public sealed partial class HlslGaussianBlurProcessor [AutoConstructor] internal readonly partial struct VerticalConvolutionProcessor : IComputeShader { - public readonly IReadWriteNormalizedTexture2D source; - public readonly IReadWriteNormalizedTexture2D target; - public readonly ReadOnlyBuffer kernel; + private readonly IReadWriteNormalizedTexture2D source; + private readonly IReadWriteNormalizedTexture2D target; + private readonly ReadOnlyBuffer kernel; /// public void Execute() @@ -152,9 +152,9 @@ public sealed partial class HlslGaussianBlurProcessor [AutoConstructor] internal readonly partial struct HorizontalConvolutionProcessor : IComputeShader { - public readonly IReadWriteNormalizedTexture2D source; - public readonly IReadWriteNormalizedTexture2D target; - public readonly ReadOnlyBuffer kernel; + private readonly IReadWriteNormalizedTexture2D source; + private readonly IReadWriteNormalizedTexture2D target; + private readonly ReadOnlyBuffer kernel; /// public void Execute() diff --git a/samples/ComputeSharp.Sample.FSharp.Shaders/MultiplyByTwo.cs b/samples/ComputeSharp.Sample.FSharp.Shaders/MultiplyByTwo.cs index dc935c28..75298a2d 100644 --- a/samples/ComputeSharp.Sample.FSharp.Shaders/MultiplyByTwo.cs +++ b/samples/ComputeSharp.Sample.FSharp.Shaders/MultiplyByTwo.cs @@ -6,7 +6,7 @@ namespace ComputeSharp.Sample.FSharp.Shaders; [AutoConstructor] public readonly partial struct MultiplyByTwo : IComputeShader { - public readonly ReadWriteBuffer buffer; + private readonly ReadWriteBuffer buffer; /// public void Execute() diff --git a/samples/ComputeSharp.Sample/Program.cs b/samples/ComputeSharp.Sample/Program.cs index 1ccc2b9e..ec27ab04 100644 --- a/samples/ComputeSharp.Sample/Program.cs +++ b/samples/ComputeSharp.Sample/Program.cs @@ -26,7 +26,7 @@ Formatting.PrintMatrix(array, 10, 10, "AFTER"); [AutoConstructor] internal readonly partial struct MultiplyByTwo : IComputeShader { - public readonly ReadWriteBuffer buffer; + private readonly ReadWriteBuffer buffer; /// public void Execute() diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs index 22d6f40d..e8fa6ca3 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ColorfulInfinity.cs @@ -15,7 +15,7 @@ internal readonly partial struct ColorfulInfinity : IPixelShader /// /// The current time since the start of the application. /// - public readonly float time; + private readonly float time; /// /// The total number of layers for the final animation. diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs index 7093a284..db95adc0 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs @@ -14,12 +14,12 @@ internal readonly partial struct ContouredLayers : IPixelShader /// /// The current time Hlsl.Since the start of the application. /// - public readonly float time; + private readonly float time; /// /// The background texture to sample. /// - public readonly IReadOnlyNormalizedTexture2D texture; + private readonly IReadOnlyNormalizedTexture2D texture; // float3 to float hash. private static float Hash21(float2 p) diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs index d6ae933d..4caa2fbf 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs @@ -14,7 +14,7 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader /// /// The current time since the start of the application. /// - public readonly float time; + private readonly float time; /// /// Curve shape - Round: 0, Semi-round: 1, Octagonal: 2, Superellipse: 3, Straight: 4. diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs index 86bcccf9..03d1abf1 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs @@ -15,13 +15,13 @@ internal readonly partial struct FourColorGradient : IPixelShader /// /// The current time since the start of the application. /// - public readonly float time; + private readonly float time; // Colors to blend together - private static readonly float3 colorOne = new(0.999f, 0.999f, 0.999f); - private static readonly float3 colorTwo = new(0.999f, 0f, 0f); - private static readonly float3 colorThree = new(0f, 0.999f, 0f); - private static readonly float3 colorFour = new(0f, 0f, 0.999f); + private static readonly float3 ColorOne = new(0.999f, 0.999f, 0.999f); + private static readonly float3 ColorTwo = new(0.999f, 0f, 0f); + private static readonly float3 ColorThree = new(0f, 0.999f, 0f); + private static readonly float3 ColorFour = new(0f, 0f, 0.999f); /// /// Standard 2D rotation formula. @@ -99,8 +99,8 @@ internal readonly partial struct FourColorGradient : IPixelShader tuv.Y += Hlsl.Sin(tuv.X * frequency * 1.5f + speed) / (amplitude * 0.5f); // Draw the image - float3 layer1 = Hlsl.Lerp(colorOne, colorTwo, Hlsl.SmoothStep(-0.3f, 0.2f, Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(-5.0f))).X)); - float3 layer2 = Hlsl.Lerp(colorThree, colorFour, Hlsl.SmoothStep(-0.3f, 0.2f, Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(-5.0f))).X)); + float3 layer1 = Hlsl.Lerp(ColorOne, ColorTwo, Hlsl.SmoothStep(-0.3f, 0.2f, Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(-5.0f))).X)); + float3 layer2 = Hlsl.Lerp(ColorThree, ColorFour, Hlsl.SmoothStep(-0.3f, 0.2f, Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians(-5.0f))).X)); float3 col = Hlsl.Lerp(layer1, layer2, Hlsl.SmoothStep(0.5f, -0.3f, tuv.Y)); return new(col, 1.0f); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs index 44e06949..b63b4698 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/FractalTiling.cs @@ -15,7 +15,7 @@ internal readonly partial struct FractalTiling : IPixelShader /// /// The current time since the start of the application. /// - public readonly float time; + private readonly float time; /// public float4 Execute() diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs index b26396fd..4680e460 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/HelloWorld.cs @@ -13,7 +13,7 @@ internal readonly partial struct HelloWorld : IPixelShader /// /// The current time since the start of the application. /// - public readonly float time; + private readonly float time; /// public float4 Execute() diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs index fe38fc7f..262329b1 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs @@ -14,7 +14,7 @@ internal readonly partial struct MengerJourney : IPixelShader /// /// The current time since the start of the application. /// - public readonly float time; + private readonly float time; private const int MaxSteps = 30; private const float MinimumDistance = 0.0009f; @@ -100,7 +100,7 @@ internal readonly partial struct MengerJourney : IPixelShader /// /// Calculates the finite difference normal at a given position. /// - private float3 getNormal(in float3 pos) + private float3 GetNormal(in float3 pos) { float3 e = new(0.0f, NormalDistance, 0.0f); @@ -141,7 +141,7 @@ internal readonly partial struct MengerJourney : IPixelShader float smoothStep = steps + distance / MinimumDistance; float ao = 1.1f - smoothStep / MaxSteps; - float3 normal = getNormal(pos - dir * NormalDistance * 3.0f); + float3 normal = GetNormal(pos - dir * NormalDistance * 3.0f); float3 color = 1.0f; float3 light = GetLight(color, normal); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs index f29287e2..472d4851 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/Octagrams.cs @@ -14,7 +14,7 @@ internal readonly partial struct Octagrams : IPixelShader /// /// The current time since the start of the application. /// - public readonly float time; + private readonly float time; private static float2x2 Rotate(float a) { diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs index eb98e798..cf29d2d9 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs @@ -15,9 +15,9 @@ internal readonly partial struct ProteanClouds : IPixelShader /// /// The current time Hlsl.Since the start of the application. /// - public readonly float time; + private readonly float time; - private static readonly float3x3 m3 = new float3x3(0.33338f, 0.56034f, -0.71817f, -0.87887f, 0.32651f, -0.15323f, 0.15162f, 0.69596f, 0.61339f) * 1.93f; + private static readonly float3x3 M3 = new float3x3(0.33338f, 0.56034f, -0.71817f, -0.87887f, 0.32651f, -0.15323f, 0.15162f, 0.69596f, 0.61339f) * 1.93f; private static float2x2 Rotate(in float a) { @@ -60,7 +60,7 @@ internal readonly partial struct ProteanClouds : IPixelShader z *= 0.57f; trk *= 1.4f; - p = Hlsl.Mul(p, m3); + p = Hlsl.Mul(p, M3); } d = Hlsl.Abs(d + prm1 * 3.0f) + prm1 * 0.3f - 2.5f + bsMo.Y; diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs index e7fee5db..a72a0dda 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs @@ -15,7 +15,7 @@ internal readonly partial struct PyramidPattern : IPixelShader /// /// The current time Hlsl.Since the start of the application. /// - public readonly float time; + private readonly float time; // Standard 2D rotation formula. private static float2x2 Rotate2x2(in float a) diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs index 134552d8..06ccdfd2 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs @@ -14,7 +14,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader /// /// The current time Hlsl.Since the start of the application. /// - public readonly float time; + private readonly float time; // Standard 2D rotation formula. private static float2x2 Rotate2x2(in float a) @@ -60,7 +60,6 @@ internal readonly partial struct TriangleGridContouring : IPixelShader return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y); } - // The isofunction. Just a Hlsl.Single noise function, but it can be more elaborate. private float IsoFunction(in float2 p) { @@ -78,7 +77,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader } // Based on IQ's signed distance to the segment joining "a" and "b". - private static float distEdge(float2 a, float2 b) + private static float DistEdge(float2 a, float2 b) { return Hlsl.Dot((a + b) * 0.5f, Hlsl.Normalize((b - a).YX * new float2(-1, 1))); } @@ -188,7 +187,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader float2 p1 = default; int iTh = IsoLine(n3, ip0, ip1, ip2, isovalue, i, ref p0, ref p1); - d = Hlsl.Min(d, distEdge(p - p0, p - p1)); + d = Hlsl.Min(d, DistEdge(p - p0, p - p1)); if (iTh == 7) { @@ -206,9 +205,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader int iTh2 = IsoLine(n3, ip0, ip1, ip2, isovalue, i, ref p0, ref p1); - d2 = Hlsl.Min(d2, distEdge(p - p0, p - p1)); - - float oldD2 = d2; + d2 = Hlsl.Min(d2, DistEdge(p - p0, p - p1)); if (iTh2 == 7) d2 = 0.0f; if (iTh == 7) d2 = 1e5f; diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs index 6096f4bb..ca025a1c 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TwoTiledTruchet.cs @@ -14,7 +14,7 @@ internal readonly partial struct TwoTiledTruchet : IPixelShader /// /// The current time since the start of the application. /// - public readonly float time; + private readonly float time; /// /// Calculates the Truchet distance field. diff --git a/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs b/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs index 18e5a14a..62a898ca 100644 --- a/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs +++ b/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs @@ -34,12 +34,12 @@ internal ref struct TryWriteFormatInterpolatedStringHandler /// /// The number of characters written to . /// - internal int position; + private int position; /// /// Indicates whether all formatting operations have succeeded. /// - internal bool success; + private bool success; /// /// Whether provides an . diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs index 231f3a17..f00c9855 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs @@ -13,7 +13,7 @@ public readonly struct Bool /// The wrapped value for the current instance. /// [FieldOffset(0)] - private readonly int Value; + private readonly int value; /// /// Creates a new instance for a given value. @@ -21,19 +21,19 @@ public readonly struct Bool /// . private Bool(bool value) { - Value = value ? 1 : 0; + this.value = value ? 1 : 0; } /// public override bool Equals(object? obj) { - return obj is Bool x && Value == x.Value; + return obj is Bool x && value == x.value; } /// public override int GetHashCode() { - return Value.GetHashCode(); + return value.GetHashCode(); } /// @@ -94,20 +94,20 @@ public readonly struct Bool /// /// The left instance. /// The right instance. - public static bool operator ==(Bool left, Bool right) => left.Value == right.Value; + public static bool operator ==(Bool left, Bool right) => left.value == right.value; /// /// Checks whether or not two instances represent a different value. /// /// The left instance. /// The right instance. - public static bool operator !=(Bool left, Bool right) => left.Value != right.Value; + public static bool operator !=(Bool left, Bool right) => left.value != right.value; /// /// Converts a given instance to its corresponding value. /// /// The input instance. - public static implicit operator bool(Bool x) => x.Value != 0; + public static implicit operator bool(Bool x) => x.value != 0; /// /// Converts a value to a corresponding instance. diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs index e623a8d2..ab8d460b 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs @@ -189,7 +189,7 @@ partial class ID2D1ShaderGenerator /// /// A mapping of precomputed literals for all values. /// - private static readonly string[] formattedBytes = + private static readonly string[] FormattedBytes = { "0x00", "0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x0A", "0x0B", "0x0C", "0x0D", "0x0E", "0x0F", "0x10", "0x11", "0x12", "0x13", "0x14", "0x15", "0x16", "0x17", "0x18", "0x19", "0x1A", "0x1B", "0x1C", "0x1D", "0x1E", "0x1F", @@ -218,12 +218,12 @@ partial class ID2D1ShaderGenerator { using ImmutableArrayBuilder builder = ImmutableArrayBuilder.Rent(); - builder.AddRange(formattedBytes[bytecode[0]].AsSpan()); + builder.AddRange(FormattedBytes[bytecode[0]].AsSpan()); foreach (byte b in bytecode.Slice(1)) { builder.AddRange(", ".AsSpan()); - builder.AddRange(formattedBytes[b].AsSpan()); + builder.AddRange(FormattedBytes[b].AsSpan()); } return builder.ToString(); diff --git a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs index 97249809..68ba0487 100644 --- a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs +++ b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs @@ -26,17 +26,17 @@ internal sealed unsafe partial class ShaderCompiler /// /// The instance to use to create the bytecode for HLSL sources. /// - private readonly ComPtr DxcCompiler; + private readonly ComPtr dxcCompiler; /// - /// The instance to use to work with . + /// The instance to use to work with . /// - private readonly ComPtr DxcLibrary; + private readonly ComPtr dxcLibrary; /// - /// The instance used to compile shaders with . + /// The instance used to compile shaders with . /// - private readonly ComPtr DxcIncludeHandler; + private readonly ComPtr dxcIncludeHandler; /// /// Creates a new instance. @@ -59,9 +59,9 @@ internal sealed unsafe partial class ShaderCompiler dxcLibrary.Get()->CreateIncludeHandler(dxcIncludeHandler.GetAddressOf()).Assert(); - DxcCompiler = dxcCompiler.Move(); - DxcLibrary = dxcLibrary.Move(); - DxcIncludeHandler = dxcIncludeHandler.Move(); + this.dxcCompiler = dxcCompiler.Move(); + this.dxcLibrary = dxcLibrary.Move(); + this.dxcIncludeHandler = dxcIncludeHandler.Move(); } /// @@ -69,9 +69,9 @@ internal sealed unsafe partial class ShaderCompiler /// ~ShaderCompiler() { - DxcCompiler.Dispose(); - DxcLibrary.Dispose(); - DxcIncludeHandler.Dispose(); + dxcCompiler.Dispose(); + dxcLibrary.Dispose(); + dxcIncludeHandler.Dispose(); } /// @@ -93,7 +93,7 @@ internal sealed unsafe partial class ShaderCompiler // Get the encoded blob from the source code fixed (char* p = source) { - DxcLibrary.Get()->CreateBlobWithEncodingOnHeapCopy( + dxcLibrary.Get()->CreateBlobWithEncodingOnHeapCopy( p, (uint)source.Length * 2, 1200, @@ -110,7 +110,7 @@ internal sealed unsafe partial class ShaderCompiler { char** arguments = stackalloc char*[3] { optimization, rowMajor, warningsAsErrors }; - DxcCompiler.Get()->Compile( + dxcCompiler.Get()->Compile( (IDxcBlob*)dxcBlobEncoding.Get(), (ushort*)shaderName, (ushort*)entryPoint, @@ -119,7 +119,7 @@ internal sealed unsafe partial class ShaderCompiler 3, null, 0, - DxcIncludeHandler.Get(), + dxcIncludeHandler.Get(), dxcOperationResult.GetAddressOf()).Assert(); } diff --git a/src/ComputeSharp.SourceGeneration/Helpers/HashCode.cs b/src/ComputeSharp.SourceGeneration/Helpers/HashCode.cs index 9c9b2763..ebf8433a 100644 --- a/src/ComputeSharp.SourceGeneration/Helpers/HashCode.cs +++ b/src/ComputeSharp.SourceGeneration/Helpers/HashCode.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security.Cryptography; -#pragma warning disable CS0809 +#pragma warning disable CS0809, IDE0009, IDE1006 namespace System; diff --git a/src/ComputeSharp.SourceGeneration/Helpers/ImmutableArrayBuilder{T}.cs b/src/ComputeSharp.SourceGeneration/Helpers/ImmutableArrayBuilder{T}.cs index 40eae510..1dfbc2d6 100644 --- a/src/ComputeSharp.SourceGeneration/Helpers/ImmutableArrayBuilder{T}.cs +++ b/src/ComputeSharp.SourceGeneration/Helpers/ImmutableArrayBuilder{T}.cs @@ -17,7 +17,7 @@ internal struct ImmutableArrayBuilder : IDisposable /// /// The shared instance to share objects. /// - private static readonly ObjectPool sharedObjectPool = new(static () => new Writer()); + private static readonly ObjectPool SharedObjectPool = new(static () => new Writer()); /// /// The owner instance. @@ -35,7 +35,7 @@ internal struct ImmutableArrayBuilder : IDisposable /// A instance to write data to. public static ImmutableArrayBuilder Rent() { - return new(sharedObjectPool, sharedObjectPool.Allocate()); + return new(SharedObjectPool, SharedObjectPool.Allocate()); } /// diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs index 14d68890..799c5edb 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs @@ -211,7 +211,7 @@ partial class IShaderGenerator /// /// A mapping of precomputed literals for all values. /// - private static readonly string[] formattedBytes = + private static readonly string[] FormattedBytes = { "0x00", "0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x0A", "0x0B", "0x0C", "0x0D", "0x0E", "0x0F", "0x10", "0x11", "0x12", "0x13", "0x14", "0x15", "0x16", "0x17", "0x18", "0x19", "0x1A", "0x1B", "0x1C", "0x1D", "0x1E", "0x1F", @@ -240,12 +240,12 @@ partial class IShaderGenerator { using ImmutableArrayBuilder builder = ImmutableArrayBuilder.Rent(); - builder.AddRange(formattedBytes[bytecode[0]].AsSpan()); + builder.AddRange(FormattedBytes[bytecode[0]].AsSpan()); foreach (byte b in bytecode.Slice(1)) { builder.AddRange(", ".AsSpan()); - builder.AddRange(formattedBytes[b].AsSpan()); + builder.AddRange(FormattedBytes[b].AsSpan()); } return builder.ToString(); diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs index cb36ca81..e81fdaea 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs @@ -41,7 +41,7 @@ unsafe partial class IWICStreamExtensions /// /// A manual CCW implementation for an object wrapping an instance. /// - internal unsafe partial struct IBufferWriterWrapper + private unsafe partial struct IBufferWriterWrapper #if NET6_0_OR_GREATER : IUnknown.Interface #endif @@ -225,17 +225,17 @@ unsafe partial class IWICStreamExtensions /// /// The vtable pointer for the current instance. /// - public void** lpVtbl; + private void** lpVtbl; /// /// The current reference count for the object (from IUnknown). /// - public volatile int referenceCount; + private volatile int referenceCount; /// /// The to the captured . /// - public GCHandle writerHandle; + private GCHandle writerHandle; /// /// Creates and initializes a new instance. diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs index 5d0c062b..df4564ef 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs @@ -44,7 +44,7 @@ internal static unsafe partial class IWICStreamExtensions /// /// A manual CCW implementation for an object wrapping a instance. /// - internal unsafe partial struct IStreamWrapper + private unsafe partial struct IStreamWrapper #if NET6_0_OR_GREATER : IUnknown.Interface #endif @@ -228,17 +228,17 @@ internal static unsafe partial class IWICStreamExtensions /// /// The vtable pointer for the current instance. /// - public void** lpVtbl; + private void** lpVtbl; /// /// The current reference count for the object (from IUnknown). /// - public volatile int referenceCount; + private volatile int referenceCount; /// /// The to the captured . /// - public GCHandle streamHandle; + private GCHandle streamHandle; /// /// Creates and initializes a new instance. diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs index 6861635a..78f13df4 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs @@ -22,7 +22,7 @@ partial class DeviceHelper /// /// The cached default instance, if any. /// - internal static GraphicsDevice? defaultDevice; + private static GraphicsDevice? defaultDevice; /// /// Gets the cached instance or creates and caches a new one. diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs index 1384e735..b4666593 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs @@ -204,7 +204,7 @@ partial class DeviceHelper /// [UnmanagedCallersOnly] - public static uint Release(IDXGIFactory4As6Backcompat* @this) + private static uint Release(IDXGIFactory4As6Backcompat* @this) { @this->dxgiFactory4->Release(); @@ -215,21 +215,21 @@ partial class DeviceHelper /// [UnmanagedCallersOnly] - public static int EnumAdapters(IDXGIFactory4As6Backcompat* @this, uint Adapter, IDXGIAdapter** ppAdapter) + private static int EnumAdapters(IDXGIFactory4As6Backcompat* @this, uint Adapter, IDXGIAdapter** ppAdapter) { return @this->dxgiFactory4->EnumAdapters(Adapter, ppAdapter); } /// [UnmanagedCallersOnly] - public static int EnumWarpAdapter(IDXGIFactory4As6Backcompat* @this, Guid* riid, void** ppvAdapter) + private static int EnumWarpAdapter(IDXGIFactory4As6Backcompat* @this, Guid* riid, void** ppvAdapter) { return @this->dxgiFactory4->EnumWarpAdapter(riid, ppvAdapter); } /// [UnmanagedCallersOnly] - public static int EnumAdapterByGpuPreference(IDXGIFactory4As6Backcompat* @this, uint Adapter, DXGI_GPU_PREFERENCE GpuPreference, Guid* riid, void** ppvAdapter) + private static int EnumAdapterByGpuPreference(IDXGIFactory4As6Backcompat* @this, uint Adapter, DXGI_GPU_PREFERENCE GpuPreference, Guid* riid, void** ppvAdapter) { return @this->dxgiFactory4->EnumAdapters1(Adapter, (IDXGIAdapter1**)ppvAdapter); } diff --git a/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs b/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs index 051ea106..803ef761 100644 --- a/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs +++ b/src/ComputeSharp/Graphics/Resources/Interop/__Internals/ResourceDescriptor.cs @@ -3,7 +3,7 @@ using System.ComponentModel; using TerraFX.Interop.DirectX; using static TerraFX.Interop.DirectX.D3D12_DESCRIPTOR_RANGE_FLAGS; -#pragma warning disable IDE0052, CS0414 +#pragma warning disable IDE0052, IDE1006, CS0414 namespace ComputeSharp.__Internals; diff --git a/src/ComputeSharp/Shaders/Models/ShaderKey.cs b/src/ComputeSharp/Shaders/Models/ShaderKey.cs index aba1acf4..d805f4d0 100644 --- a/src/ComputeSharp/Shaders/Models/ShaderKey.cs +++ b/src/ComputeSharp/Shaders/Models/ShaderKey.cs @@ -11,22 +11,22 @@ internal readonly struct ShaderKey : IEquatable /// /// The hashcode of the current shader type. /// - private readonly int Id; + private readonly int id; /// /// The number of iterations to run on the X axis. /// - private readonly int ThreadsX; + private readonly int threadsX; /// /// The number of iterations to run on the Y axis. /// - private readonly int ThreadsY; + private readonly int threadsY; /// /// The number of iterations to run on the Z axis. /// - private readonly int ThreadsZ; + private readonly int threadsZ; /// /// Creates a new instance with the specified parameters. @@ -38,10 +38,10 @@ internal readonly struct ShaderKey : IEquatable [MethodImpl(MethodImplOptions.AggressiveInlining)] public ShaderKey(int id, int threadsX, int threadsY, int threadsZ) { - Id = id; - ThreadsX = threadsX; - ThreadsY = threadsY; - ThreadsZ = threadsZ; + this.id = id; + this.threadsX = threadsX; + this.threadsY = threadsY; + this.threadsZ = threadsZ; } /// @@ -49,10 +49,10 @@ internal readonly struct ShaderKey : IEquatable public bool Equals(ShaderKey other) { return - Id == other.Id && - ThreadsX == other.ThreadsX && - ThreadsY == other.ThreadsY && - ThreadsZ == other.ThreadsZ; + id == other.id && + threadsX == other.threadsX && + threadsY == other.threadsY && + threadsZ == other.threadsZ; } /// @@ -65,6 +65,6 @@ internal readonly struct ShaderKey : IEquatable [MethodImpl(MethodImplOptions.AggressiveInlining)] public override int GetHashCode() { - return HashCode.Combine(Id, ThreadsX, ThreadsY, ThreadsZ); + return HashCode.Combine(id, threadsX, threadsY, threadsZ); } } \ No newline at end of file diff --git a/tests/.editorconfig b/tests/.editorconfig new file mode 100644 index 00000000..e0feda6f --- /dev/null +++ b/tests/.editorconfig @@ -0,0 +1,2 @@ +# Disable naming rule violation warnings just for unit tests +dotnet_diagnostic.IDE1006.severity = none \ No newline at end of file