diff --git a/samples/ComputeSharp.ImageProcessing/Primitives/Complex64.cs b/samples/ComputeSharp.ImageProcessing/Primitives/Complex64.cs index 6425a07e..03c2ab44 100644 --- a/samples/ComputeSharp.ImageProcessing/Primitives/Complex64.cs +++ b/samples/ComputeSharp.ImageProcessing/Primitives/Complex64.cs @@ -41,5 +41,5 @@ internal readonly struct Complex64 /// The scalar to use to multiply the value. /// The result. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Complex64 operator *(Complex64 value, float scalar) => new Complex64(value.Real * scalar, value.Imaginary * scalar); + public static Complex64 operator *(Complex64 value, float scalar) => new(value.Real * scalar, value.Imaginary * scalar); } \ No newline at end of file diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs index ce60fc75..f6435bbc 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs @@ -77,7 +77,7 @@ public sealed partial class HlslBokehBlurProcessor : IImageProcessor ThrowHelper.ThrowInvalidOperationException("This processor only supports the RGBA32 pixel format."); } - Implementation processor = new Implementation(this, configuration, Unsafe.As>(source), sourceRectangle); + Implementation processor = new(this, configuration, Unsafe.As>(source), sourceRectangle); return Unsafe.As>(processor); } diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs index 980a4487..68a6bad5 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs @@ -82,7 +82,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor ThrowHelper.ThrowInvalidOperationException("This processor only supports the RGBA32 pixel format."); } - Implementation processor = new Implementation(this, configuration, Unsafe.As>(source), sourceRectangle); + Implementation processor = new(this, configuration, Unsafe.As>(source), sourceRectangle); return Unsafe.As>(processor); } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs index 56410746..b0c2afe9 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -64,7 +64,7 @@ partial class ID2D1ShaderGenerator out ImmutableArray<(string Name, string HlslType, int Index)> resourceTextureFields); // Explore the syntax tree and extract the processed info - SemanticModelProvider semanticModelProvider = new SemanticModelProvider(compilation); + SemanticModelProvider semanticModelProvider = new(compilation); (string entryPoint, ImmutableArray<(string Signature, string Definition)> processedMethods) = GetProcessedMethods(diagnostics, structDeclaration, structDeclarationSymbol, semanticModelProvider, discoveredTypes, staticMethods, instanceMethods, constantDefinitions, out bool methodsNeedD2D1RequiresScenePosition); ImmutableArray<(string Name, string TypeDeclaration, string? Assignment)> staticFields = GetStaticFields(diagnostics, semanticModelProvider, structDeclaration, structDeclarationSymbol, discoveredTypes, constantDefinitions, out bool fieldsNeedD2D1RequiresScenePosition); diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs index c1c1d932..e3d59524 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs @@ -375,8 +375,8 @@ unsafe partial struct D2D1ResourceTextureManagerImpl uint dataCount) { // Either both extents are available, or none is, and the other values must not be null - if (minimumExtents is null && maximimumExtents is not null || - minimumExtents is not null && maximimumExtents is null || + if ((minimumExtents is null && maximimumExtents is not null) || + (minimumExtents is not null && maximimumExtents is null) || (dimensions > 1 && strides is null) || data is null) { diff --git a/src/ComputeSharp.NetStandard/System/Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs b/src/ComputeSharp.NetStandard/System/Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs index d8894769..699a1844 100644 --- a/src/ComputeSharp.NetStandard/System/Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs +++ b/src/ComputeSharp.NetStandard/System/Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs @@ -1,40 +1,39 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -namespace System.Diagnostics.CodeAnalysis +namespace System.Diagnostics.CodeAnalysis; + +/// +/// Indicates that the specified method requires dynamic access to code that is not referenced +/// statically, for example through . +/// +/// +/// This allows tools to understand which methods are unsafe to call when removing unreferenced +/// code from an application. +/// +[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)] +internal sealed class RequiresUnreferencedCodeAttribute : Attribute { /// - /// Indicates that the specified method requires dynamic access to code that is not referenced - /// statically, for example through . + /// Initializes a new instance of the class + /// with the specified message. /// - /// - /// This allows tools to understand which methods are unsafe to call when removing unreferenced - /// code from an application. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)] - internal sealed class RequiresUnreferencedCodeAttribute : Attribute + /// + /// A message that contains information about the usage of unreferenced code. + /// + public RequiresUnreferencedCodeAttribute(string message) { - /// - /// Initializes a new instance of the class - /// with the specified message. - /// - /// - /// A message that contains information about the usage of unreferenced code. - /// - public RequiresUnreferencedCodeAttribute(string message) - { - Message = message; - } - - /// - /// Gets a message that contains information about the usage of unreferenced code. - /// - public string Message { get; } - - /// - /// Gets or sets an optional URL that contains more information about the method, - /// why it requires unreferenced code, and what options a consumer has to deal with it. - /// - public string? Url { get; set; } + Message = message; } + + /// + /// Gets a message that contains information about the usage of unreferenced code. + /// + public string Message { get; } + + /// + /// Gets or sets an optional URL that contains more information about the method, + /// why it requires unreferenced code, and what options a consumer has to deal with it. + /// + public string? Url { get; set; } } \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration/Extensions/ISymbolExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/ISymbolExtensions.cs index c194de7a..15f35756 100644 --- a/src/ComputeSharp.SourceGeneration/Extensions/ISymbolExtensions.cs +++ b/src/ComputeSharp.SourceGeneration/Extensions/ISymbolExtensions.cs @@ -215,6 +215,6 @@ internal static class ISymbolExtensions return accessibility == Accessibility.Public || - accessibility == Accessibility.Internal && symbol.ContainingAssembly.GivesAccessTo(assembly); + (accessibility == Accessibility.Internal && symbol.ContainingAssembly.GivesAccessTo(assembly)); } } \ No newline at end of file diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs index 06d66c8e..aecab263 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -58,7 +58,7 @@ partial class IShaderGenerator } // Explore the syntax tree and extract the processed info - SemanticModelProvider semanticModelProvider = new SemanticModelProvider(compilation); + SemanticModelProvider semanticModelProvider = new(compilation); INamedTypeSymbol? pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IPixelShader) }); bool isComputeShader = pixelShaderSymbol is null; string? implicitTextureType = isComputeShader ? null : HlslKnownTypes.GetMappedNameForPixelShaderType(pixelShaderSymbol!); diff --git a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs index db101d4f..92128a0d 100644 --- a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs @@ -87,7 +87,7 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator Dictionary instanceMethods = new(SymbolEqualityComparer.Default); // Unused in this generator // Explore the syntax tree and extract the processed info - SemanticModelProvider semanticModel = new SemanticModelProvider(compilation); + SemanticModelProvider semanticModel = new(compilation); (string entryPoint, ImmutableArray<(string Signature, string Definition)> dependentMethods) = GetProcessedMethods(builder, methodDeclaration, semanticModel, discoveredTypes, constantDefinitions); ImmutableArray<(string Name, string Definition)> definedTypes = IShaderGenerator.BuildHlslSource.GetDeclaredTypes(builder, methodSymbol, discoveredTypes, instanceMethods); ImmutableArray<(string Name, string Value)> definedConstants = IShaderGenerator.BuildHlslSource.GetDefinedConstants(constantDefinitions); diff --git a/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs b/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs index df76679c..fcbba1ef 100644 --- a/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs +++ b/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs @@ -55,7 +55,7 @@ internal static class TolerantImageComparer float totalDifference = 0F; - List differences = new List(20); + List differences = new(20); Span aBuffer = new ImageSharpRgba32[actual.Width]; Span bBuffer = new ImageSharpRgba32[actual.Width]; @@ -84,7 +84,7 @@ internal static class TolerantImageComparer { if (differences.Count < 20) { - PixelDifference diff = new PixelDifference(new Point(x, y), aBuffer[x], bBuffer[x]); + PixelDifference diff = new(new Point(x, y), aBuffer[x], bBuffer[x]); differences.Add(diff); } diff --git a/tests/ComputeSharp.Tests/ShadersTests.cs b/tests/ComputeSharp.Tests/ShadersTests.cs index 24720ae3..3b0b2b39 100644 --- a/tests/ComputeSharp.Tests/ShadersTests.cs +++ b/tests/ComputeSharp.Tests/ShadersTests.cs @@ -169,7 +169,7 @@ public class ShadersTests texture.GraphicsDevice.For(texture.Width, texture.Height, (T)Activator.CreateInstance(typeof(T), texture, 0f)!); } - Action> action = new Action>(RunComputeShader); + Action> action = new(RunComputeShader); _ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture }); } @@ -181,7 +181,7 @@ public class ShadersTests texture.GraphicsDevice.ForEach(texture, (T)Activator.CreateInstance(typeof(T), 0f)!); } - Action> action = new Action>(RunPixelShader); + Action> action = new(RunPixelShader); _ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture }); }