diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputTypes.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputTypes.cs index 8e8be4b3..633fff67 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputTypes.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.InputTypes.cs @@ -39,6 +39,8 @@ partial class D2DPixelShaderDescriptorGenerator int rawInputCount = 0; bool isInputCountPresent = false; + // Note: this logic is shared with InvalidD2DResourceTextureIndexAttributeUseAnalyzer. + // If any changes are made here, they should be reflected in that analyzer as well. inputCount = 0; using ImmutableArrayBuilder inputSimpleIndicesBuilder = new(); diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.ResourceTextureDescriptions.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.ResourceTextureDescriptions.cs index f975e2ee..b5f5a68e 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.ResourceTextureDescriptions.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.ResourceTextureDescriptions.cs @@ -1,13 +1,9 @@ -using System; using System.Collections.Immutable; -using System.Globalization; using ComputeSharp.D2D1.SourceGenerators.Models; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; using ComputeSharp.SourceGeneration.Mappings; -using ComputeSharp.SourceGeneration.Models; using Microsoft.CodeAnalysis; -using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors; namespace ComputeSharp.D2D1.SourceGenerators; @@ -22,23 +18,19 @@ partial class D2DPixelShaderDescriptorGenerator /// /// Extracts the resource texture descriptions for the current shader. /// - /// The collection of produced instances. /// The input instance to process. - /// The number of inputs for the shader. /// The produced resource texture descriptions for the shader. public static void GetInfo( - ImmutableArrayBuilder diagnostics, INamedTypeSymbol structDeclarationSymbol, - int inputCount, out ImmutableArray resourceTextureDescriptions) { - using ImmutableArrayBuilder<(int? Index, int Rank)> resourceTextureInfos = new(); + using ImmutableArrayBuilder builder = new(); - foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType()) + foreach (ISymbol memberSymbol in structDeclarationSymbol.GetMembers().OfType()) { // Only look for fields of a named type symbol (diagnostics is emitted by the HLSL rewriter if it's not the case). // We're only looking for instance fields of unmanaged types in this case (as resource textures are structs). - if (fieldSymbol is not { IsStatic: false, Type: INamedTypeSymbol { IsUnmanagedType: true } typeSymbol }) + if (memberSymbol is not IFieldSymbol { IsStatic: false, Type: INamedTypeSymbol { IsUnmanagedType: true, IsGenericType: true } typeSymbol } fieldSymbol) { continue; } @@ -48,8 +40,10 @@ partial class D2DPixelShaderDescriptorGenerator // Check that the field is a resource texture type (if not, it will be processed by the HLSL rewriter too) if (HlslKnownTypes.IsResourceTextureType(metadataName)) { - // The type name will be ComputeSharp.D2D1.D2D1ResourceTexture1D`1 or the 2D/3D versions - int rank = int.Parse(metadataName.Substring(metadataName.Length - 4, 1), CultureInfo.InvariantCulture); + // The type name will be ComputeSharp.D2D1.D2D1ResourceTexture1D`1 or the 2D/3D versions. + // To avoid the intermediate string and the parsing, we can rely on the fact the metadata + // has already been validated here, so we can get the rank by offsetting the characters. + int rank = metadataName[^4] - '0'; int? index = null; // Get the index from the [D2DResourceTextureIndex] attribute over the field @@ -62,76 +56,12 @@ partial class D2DPixelShaderDescriptorGenerator index = resourceIndex; } } - else - { - // If the attribute is missing, emit a diagnostic - diagnostics.Add(MissingD2DResourceTextureIndexAttribute, fieldSymbol, fieldSymbol.Name, structDeclarationSymbol); - } - resourceTextureInfos.Add((index, rank)); + builder.Add(new ResourceTextureDescription(index ?? 0, rank)); } } - // Extract the resource texture descriptions for the rest of the pipeline - using (ImmutableArrayBuilder resourceTextureDescriptionsBuilder = new()) - { - foreach ((int? index, int rank) in resourceTextureInfos.WrittenSpan) - { - resourceTextureDescriptionsBuilder.Add(new ResourceTextureDescription(index ?? 0, rank)); - } - - resourceTextureDescriptions = resourceTextureDescriptionsBuilder.ToImmutable(); - } - - // If the input count is invalid, do nothing and avoid emitting potentially incorrect - // diagnostics based on the resource texture indices with respect to the input count. - // The GetInputType() generator has already emitted diagnostic for this error, so this - // generator can just wait for users to go back and fix that issue before proceeding. - if (inputCount is not (>= 0 and <= 8)) - { - return; - } - - // Validate that the resource texture indices don't overlap with the shader inputs - foreach ((int? index, _) in resourceTextureInfos.WrittenSpan) - { - if (index < inputCount) - { - diagnostics.Add(ResourceTextureIndexOverlappingWithInputIndex, structDeclarationSymbol, structDeclarationSymbol); - - return; - } - } - - // Validate that no resource texture has an index greater than or equal to 16 - foreach ((int? index, _) in resourceTextureInfos.WrittenSpan) - { - if (index >= 16) - { - diagnostics.Add(OutOfRangeResourceTextureIndex, structDeclarationSymbol, structDeclarationSymbol); - - return; - } - } - - Span selectedResourceTextureIndices = stackalloc bool[16]; - - selectedResourceTextureIndices.Clear(); - - // All input description indices must be unique (also take this path for invalid indices) - foreach ((int? index, _) in resourceTextureInfos.WrittenSpan) - { - ref bool isResourceTextureIndexUsed = ref selectedResourceTextureIndices[index ?? 0]; - - if (isResourceTextureIndexUsed) - { - diagnostics.Add(RepeatedD2DResourceTextureIndices, structDeclarationSymbol, structDeclarationSymbol); - - return; - } - - isResourceTextureIndexUsed = true; - } + resourceTextureDescriptions = builder.ToImmutable(); } } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.cs index 2bf72336..2afaaf07 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.cs @@ -109,9 +109,7 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene // Get the resource texture info for ResourceTextureDescriptions ResourceTextureDescriptions.GetInfo( - diagnostics, typeSymbol, - inputCount, out ImmutableArray resourceTextureDescriptions); token.ThrowIfCancellationRequested(); diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexAttributeLocationAnalyzer.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexAttributeLocationAnalyzer.cs new file mode 100644 index 00000000..09f99388 --- /dev/null +++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexAttributeLocationAnalyzer.cs @@ -0,0 +1,64 @@ +using System.Collections.Immutable; +using System.Linq; +using ComputeSharp.SourceGeneration.Extensions; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors; + +namespace ComputeSharp.D2D1.SourceGenerators; + +/// +/// A diagnostic analyzer that generates an error whenever [D2DResourceTextureIndex] is used incorrectly to annotate a field. +/// +[DiagnosticAnalyzer(LanguageNames.CSharp)] +public sealed class InvalidD2DResourceTextureIndexAttributeLocationAnalyzer : DiagnosticAnalyzer +{ + /// + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(InvalidD2DResourceTextureIndexAttributeLocation); + + /// + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); + context.EnableConcurrentExecution(); + + context.RegisterCompilationStartAction(static context => + { + // Get the [D2DResourceTextureIndex] symbol, and the ones for the D2D resource texture types + if (context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute") is not { } d2DResourceTextureIndexAttributeSymbol || + context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2D1ResourceTexture1D`1") is not { } d2D1ResourceTexture1DSymbol || + context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2D1ResourceTexture2D`1") is not { } d2D1ResourceTexture2DSymbol || + context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2D1ResourceTexture3D`1") is not { } d2D1ResourceTexture3DSymbol) + { + return; + } + + // Inspect all fields to make sure they're not using the attribute incorrectly + context.RegisterSymbolAction(context => + { + IFieldSymbol fieldSymbol = (IFieldSymbol)context.Symbol; + + if (fieldSymbol.HasAttributeWithType(d2DResourceTextureIndexAttributeSymbol)) + { + // If the field is using [D2DResourceTextureIndex], it must be a D2D resource texture. We can first + // just check that the field type is a generic named type (since that's the case if it's indeed of + // a D2D resource texture type). Past that, we just check that it's one of the three possible types. + if (fieldSymbol.Type is not INamedTypeSymbol { IsGenericType: true } typeSymbol || + !(SymbolEqualityComparer.Default.Equals(typeSymbol.ConstructedFrom, d2D1ResourceTexture1DSymbol) || + SymbolEqualityComparer.Default.Equals(typeSymbol.ConstructedFrom, d2D1ResourceTexture2DSymbol) || + SymbolEqualityComparer.Default.Equals(typeSymbol.ConstructedFrom, d2D1ResourceTexture3DSymbol))) + { + Diagnostic diagnostic = Diagnostic.Create( + InvalidD2DResourceTextureIndexAttributeLocation, + fieldSymbol.Locations.First(), + fieldSymbol.Name, + fieldSymbol.ContainingType, + fieldSymbol.Type); + + context.ReportDiagnostic(diagnostic); + } + } + }, SymbolKind.Field); + }); + } +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexAttributeUseAnalyzer.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexAttributeUseAnalyzer.cs new file mode 100644 index 00000000..c2a0d7f3 --- /dev/null +++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexAttributeUseAnalyzer.cs @@ -0,0 +1,191 @@ +using System; +using System.Collections.Immutable; +using System.Linq; +using ComputeSharp.SourceGeneration.Extensions; +using ComputeSharp.SourceGeneration.Helpers; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors; + +namespace ComputeSharp.D2D1.SourceGenerators; + +/// +/// A diagnostic analyzer that generates errors for all invalid uses of the [D2DResourceTextureIndex] attribute. +/// +[DiagnosticAnalyzer(LanguageNames.CSharp)] +public sealed class InvalidD2DResourceTextureIndexAttributeUseAnalyzer : DiagnosticAnalyzer +{ + /// + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create( + MissingD2DResourceTextureIndexAttribute, + ResourceTextureIndexOverlappingWithInputIndex, + OutOfRangeResourceTextureIndex, + RepeatedD2DResourceTextureIndices); + + /// + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); + context.EnableConcurrentExecution(); + + context.RegisterCompilationStartAction(static context => + { + // Get all necessary symbols (we need a whole bunch of them here) + if (context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute") is not { } d2DResourceTextureIndexAttributeSymbol || + context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2D1ResourceTexture1D`1") is not { } d2D1ResourceTexture1DSymbol || + context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2D1ResourceTexture2D`1") is not { } d2D1ResourceTexture2DSymbol || + context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2D1ResourceTexture3D`1") is not { } d2D1ResourceTexture3DSymbol || + context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2DInputCountAttribute") is not { } d2DInputCountAttributeSymbol || + context.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.ID2D1PixelShader") is not { } d2D1PixelShaderSymbol) + { + return; + } + + context.RegisterSymbolAction(context => + { + // We're validating all struct types (since they're the possible shader types) + if (context.Symbol is not INamedTypeSymbol { TypeKind: TypeKind.Struct } typeSymbol) + { + return; + } + + // Only validate fields for shader types (even without a generated descriptor) + if (!typeSymbol.HasInterfaceWithType(d2D1PixelShaderSymbol)) + { + return; + } + + using ImmutableArrayBuilder<(int? Index, int Rank)> resourceTextureInfos = new(); + + foreach (ISymbol memberSymbol in typeSymbol.GetMembers()) + { + // Only look for valid candidate fields (same logic as in D2DPixelShaderDescriptorGenerator.InputTypes) + if (memberSymbol is not IFieldSymbol { IsStatic: false, Type: INamedTypeSymbol { IsUnmanagedType: true } } fieldSymbol) + { + continue; + } + + // Specifically check that the type is generic and grab the source one + if (fieldSymbol.Type is not INamedTypeSymbol { ConstructedFrom: { } nonGenericFieldTypeSymbol }) + { + continue; + } + + // Check that the field is a D2D resource texture and get the rank + int rank = nonGenericFieldTypeSymbol switch + { + _ when SymbolEqualityComparer.Default.Equals(d2D1ResourceTexture1DSymbol, nonGenericFieldTypeSymbol) => 1, + _ when SymbolEqualityComparer.Default.Equals(d2D1ResourceTexture2DSymbol, nonGenericFieldTypeSymbol) => 2, + _ when SymbolEqualityComparer.Default.Equals(d2D1ResourceTexture3DSymbol, nonGenericFieldTypeSymbol) => 3, + _ => 0 + }; + + // The field is not a D2D resource texture, just skip it + if (rank == 0) + { + continue; + } + + int? index = null; + + // Try to get the annotated index for the D2D texture, and track it. This + // logic is also in sync with D2DPixelShaderDescriptorGenerator.InputTypes. + if (fieldSymbol.TryGetAttributeWithType(d2DResourceTextureIndexAttributeSymbol, out AttributeData? textureIndexData)) + { + if (textureIndexData.TryGetConstructorArgument(0, out int resourceIndex)) + { + index = resourceIndex; + } + } + else + { + // If the attribute is missing, emit a diagnostic + context.ReportDiagnostic(Diagnostic.Create( + MissingD2DResourceTextureIndexAttribute, + fieldSymbol.Locations.First(), + fieldSymbol.Name, + typeSymbol)); + } + + resourceTextureInfos.Add((index, rank)); + } + + int inputCount = 0; + + // Same logic as in D2DPixelShaderDescriptorGenerator.InputTypes (see there for reference). + // Keeping this in sync to ensure a consistent behavior (this should be updated if that changes). + if (typeSymbol.TryGetAttributeWithType(d2DInputCountAttributeSymbol, out AttributeData? inputCountData)) + { + inputCount = Math.Max((int)inputCountData.ConstructorArguments[0].Value!, 0); + } + + // If the input count is invalid, do nothing and avoid emitting potentially incorrect diagnostics + // based on the resource texture indices with respect to the input count. The generator for the + // InputType property has already emitted diagnostic for this error, so this analyzer can just + // wait for users to go back and fix that issue before proceeding. + if (inputCount is not (>= 0 and <= 8)) + { + return; + } + + // Validate that the resource texture indices don't overlap with the shader inputs + foreach ((int? index, _) in resourceTextureInfos.WrittenSpan) + { + if (index < inputCount) + { + context.ReportDiagnostic(Diagnostic.Create( + ResourceTextureIndexOverlappingWithInputIndex, + typeSymbol.Locations.First(), + typeSymbol)); + + break; + } + } + + // Validate that no resource texture has an index greater than or equal to 16 + foreach ((int? index, _) in resourceTextureInfos.WrittenSpan) + { + if (index >= 16) + { + context.ReportDiagnostic(Diagnostic.Create( + OutOfRangeResourceTextureIndex, + typeSymbol.Locations.First(), + typeSymbol)); + + break; + } + } + + Span selectedResourceTextureIndices = stackalloc bool[16]; + + selectedResourceTextureIndices.Clear(); + + // All input description indices must be unique + foreach ((int? index, _) in resourceTextureInfos.WrittenSpan) + { + // Skip this path for invalid indices, as those will receive other diagnostics. + // We have to do this to avoid generating false positives for the default value. + // Because indices could be out of range, we also have to skip any of those. + if (index is null or >= 16) + { + continue; + } + + ref bool isResourceTextureIndexUsed = ref selectedResourceTextureIndices[index ?? 0]; + + if (isResourceTextureIndexUsed) + { + context.ReportDiagnostic(Diagnostic.Create( + RepeatedD2DResourceTextureIndices, + typeSymbol.Locations.First(), + typeSymbol)); + + break; + } + + isResourceTextureIndexUsed = true; + } + }, SymbolKind.NamedType); + }); + } +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs deleted file mode 100644 index e78c4591..00000000 --- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/Analyzers/InvalidD2DResourceTextureIndexUseAnalyzer.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Collections.Immutable; -using System.Linq; -using ComputeSharp.SourceGeneration.Extensions; -using ComputeSharp.SourceGeneration.Mappings; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; -using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors; - -namespace ComputeSharp.D2D1.SourceGenerators; - -/// -/// A diagnostic analyzer that generates an error whenever [D2DResourceTextureIndex] is used incorrectly to annotate an invalid field. -/// -[DiagnosticAnalyzer(LanguageNames.CSharp)] -public sealed class InvalidD2DResourceTextureIndexUseAnalyzer : DiagnosticAnalyzer -{ - /// - public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(InvalidD2DResourceTextureIndexAttributeUse); - - /// - public override void Initialize(AnalysisContext context) - { - context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); - context.EnableConcurrentExecution(); - - context.RegisterSymbolAction(static context => - { - IFieldSymbol fieldSymbol = (IFieldSymbol)context.Symbol; - - if (fieldSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute", out _)) - { - string metadataName = fieldSymbol.Type.GetFullyQualifiedMetadataName(); - - if (!HlslKnownTypes.IsResourceTextureType(metadataName)) - { - Diagnostic diagnostic = Diagnostic.Create( - InvalidD2DResourceTextureIndexAttributeUse, - fieldSymbol.Locations.First(), - fieldSymbol.Name, - fieldSymbol.ContainingType, - fieldSymbol.Type); - - context.ReportDiagnostic(diagnostic); - } - } - }, SymbolKind.Field); - } -} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs index aa16d774..1dcd8ca7 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs @@ -654,9 +654,9 @@ partial class DiagnosticDescriptors helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); /// - /// Gets a for a shader with an out of range resource texture index (or more). + /// Gets a for a shader with an overlapping resource texture index (or more). /// - /// Format: "The D2D1 shader of type {0} is using some out of range resource texture indices". + /// Format: "The D2D1 shader of type {0} is using some resource texture indices that overlap with the shader input indices". /// /// public static readonly DiagnosticDescriptor ResourceTextureIndexOverlappingWithInputIndex = new( @@ -702,14 +702,14 @@ partial class DiagnosticDescriptors helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); /// - /// Gets a for an invalid use of [D2DResourceTextureIndex]. + /// Gets a for an invalid location of [D2DResourceTextureIndex]. /// - /// Format: "The field "{0}" (in type {1}) is using [D2DResourceTextureIndex] incorrectly (the attribute can only be used on D2D1 resource texture types, but the field is of type {2})". + /// Format: "The field "{0}" (in type {1}) is using [D2DResourceTextureIndex] on an invalid location (the attribute can only be used on D2D1 resource texture types, but the field is of type {2})". /// /// - public static readonly DiagnosticDescriptor InvalidD2DResourceTextureIndexAttributeUse = new( + public static readonly DiagnosticDescriptor InvalidD2DResourceTextureIndexAttributeLocation = new( id: "CMPSD2D0049", - title: "Invalid [D2DResourceTextureIndex] use", + title: "Invalid [D2DResourceTextureIndex] location", messageFormat: """The field "{0}" (in type {1}) is using [D2DResourceTextureIndex] incorrectly (the attribute can only be used on D2D1 resource texture types, but the field is of type {2})""", category: "ComputeSharp.D2D1.Shaders", defaultSeverity: DiagnosticSeverity.Error, diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs index 24ae776a..506de94b 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs @@ -21,6 +21,19 @@ partial class HlslKnownMethods return name is "ComputeSharp.D2D1.D2D.GetScenePosition" or "ComputeSharp.D2D1.D2D.SampleInputAtPosition"; } + /// + private static partial Dictionary BuildKnownResourceSamplers() + { + return new() + { + [$"ComputeSharp.D2D1.D2D1ResourceTexture1D`1.Sample({typeof(float).FullName})"] = null, + [$"ComputeSharp.D2D1.D2D1ResourceTexture2D`1.Sample({typeof(float).FullName}, {typeof(float).FullName})"] = "float2", + [$"ComputeSharp.D2D1.D2D1ResourceTexture2D`1.Sample({typeof(Float2).FullName})"] = null, + [$"ComputeSharp.D2D1.D2D1ResourceTexture3D`1.Sample({typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName})"] = "float3", + [$"ComputeSharp.D2D1.D2D1ResourceTexture3D`1.Sample({typeof(Float3).FullName})"] = null + }; + } + /// static partial void AddKnownMethods(IDictionary knownMethods) @@ -37,17 +50,4 @@ partial class HlslKnownMethods knownMethods.Add($"{typeof(D2D).FullName}{Type.Delimiter}{method.Name}", hlslName); } } - - /// - private static partial IReadOnlyDictionary BuildKnownResourceSamplers() - { - return new Dictionary - { - [$"ComputeSharp.D2D1.D2D1ResourceTexture1D`1.Sample({typeof(float).FullName})"] = null, - [$"ComputeSharp.D2D1.D2D1ResourceTexture2D`1.Sample({typeof(float).FullName}, {typeof(float).FullName})"] = "float2", - [$"ComputeSharp.D2D1.D2D1ResourceTexture2D`1.Sample({typeof(Float2).FullName})"] = null, - [$"ComputeSharp.D2D1.D2D1ResourceTexture3D`1.Sample({typeof(float).FullName}, {typeof(float).FullName}, {typeof(float).FullName})"] = "float3", - [$"ComputeSharp.D2D1.D2D1ResourceTexture3D`1.Sample({typeof(Float3).FullName})"] = null - }; - } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownProperties.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownProperties.cs index af7c3fb6..2c750be2 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownProperties.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownProperties.cs @@ -6,9 +6,9 @@ namespace ComputeSharp.SourceGeneration.Mappings; partial class HlslKnownProperties { /// - private static partial IReadOnlyDictionary BuildKnownResourceIndexers() + private static partial Dictionary BuildKnownResourceIndexers() { - return new Dictionary + return new() { [$"ComputeSharp.D2D1.D2D1ResourceTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", [$"ComputeSharp.D2D1.D2D1ResourceTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3" @@ -16,9 +16,9 @@ partial class HlslKnownProperties } /// - private static partial IReadOnlyDictionary BuildKnownSizeAccessors() + private static partial Dictionary BuildKnownSizeAccessors() { - return new Dictionary + return new() { ["ComputeSharp.D2D1.D2D1ResourceTexture1D`1.Width"] = (1, 0), ["ComputeSharp.D2D1.D2D1ResourceTexture2D`1.Width"] = (2, 0), diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownFields.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownFields.cs index aabbf373..3e56fdc1 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownFields.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownFields.cs @@ -10,7 +10,7 @@ internal static partial class HlslKnownFields /// /// The mapping of supported known fields to HLSL names. /// - private static readonly IReadOnlyDictionary KnownFields = BuildKnownFieldsMap(); + private static readonly Dictionary KnownFields = BuildKnownFieldsMap(); /// /// Builds the mapping of supported known fields to HLSL names. diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs index 12b6050e..9662e2e3 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs @@ -16,7 +16,7 @@ internal static partial class HlslKnownKeywords /// /// The mapping of known HLSL keywords. /// - private static readonly IReadOnlyCollection KnownKeywords = BuildKnownKeywordsMap(); + private static readonly HashSet KnownKeywords = BuildKnownKeywordsMap(); /// /// Builds the mapping of all known HLSL keywords. diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs index 4e2b14e6..19410359 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs @@ -14,12 +14,17 @@ internal static partial class HlslKnownMethods /// /// The mapping of supported known methods to HLSL names. /// - private static readonly IReadOnlyDictionary KnownMethods = BuildKnownMethodsMap(); + private static readonly Dictionary KnownMethods = BuildKnownMethodsMap(); /// /// The mapping of supported known methods that require parameters mapping to HLSL names. /// - private static readonly IReadOnlyDictionary KnownMethodsParametersMapping = BuildKnownMethodsParametersMappingMap(); + private static readonly Dictionary KnownMethodsParametersMapping = BuildKnownMethodsParametersMappingMap(); + + /// + /// The mapping of supported known samplers to HLSL resource type names. + /// + private static readonly Dictionary KnownResourceSamplers = BuildKnownResourceSamplers(); /// /// Builds the mapping of supported known methods to HLSL names. @@ -94,23 +99,18 @@ internal static partial class HlslKnownMethods return knownMethods; } + /// + /// Builds the mapping of supported known samplers to HLSL resource type names. + /// + /// The mapping of supported known samplers to HLSL resource type names. + private static partial Dictionary BuildKnownResourceSamplers(); + /// /// Adds more known methods to the mapping to use. /// /// The mapping of known methods being built. static partial void AddKnownMethods(IDictionary knownMethods); - /// - /// The mapping of supported known samplers to HLSL resource type names. - /// - private static readonly IReadOnlyDictionary KnownResourceSamplers = BuildKnownResourceSamplers(); - - /// - /// Builds the mapping of supported known samplers to HLSL resource type names. - /// - /// The mapping of supported known samplers to HLSL resource type names. - private static partial IReadOnlyDictionary BuildKnownResourceSamplers(); - /// /// Tries to get the mapped HLSL-compatible sampler resource type name for the input indexer name. /// diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs index 15dd8294..3403bac6 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs @@ -14,7 +14,7 @@ internal static partial class HlslKnownOperators /// /// The mapping of supported known operators to HLSL names. /// - private static readonly IReadOnlyDictionary KnownOperators = BuildKnownOperatorsMap(); + private static readonly Dictionary KnownOperators = BuildKnownOperatorsMap(); /// /// Builds the mapping of supported known operators to HLSL names. diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownProperties.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownProperties.cs index 49583f0f..e91156dd 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownProperties.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownProperties.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; @@ -15,7 +14,27 @@ internal static partial class HlslKnownProperties /// /// The mapping of supported known properties to HLSL names. /// - private static readonly IReadOnlyDictionary KnownProperties = BuildKnownPropertiesMap(); + private static readonly Dictionary KnownProperties = BuildKnownPropertiesMap(); + + /// + /// The mapping of supported known properties to HLSL names. + /// + private static readonly HashSet KnownMatrixIndexers = BuildKnownMatrixIndexers(); + + /// + /// The mapping of supported known members to HLSL names. + /// + private static readonly HashSet KnownMatrixIndices = BuildKnownMatrixIndices(); + + /// + /// The mapping of supported known indexers to HLSL resource type names. + /// + private static readonly Dictionary KnownResourceIndexers = BuildKnownResourceIndexers(); + + /// + /// The mapping of supported known size accessors for HLSL resource types. + /// + private static readonly Dictionary KnownSizeAccessors = BuildKnownSizeAccessors(); /// /// Builds the mapping of supported known properties to HLSL names. @@ -143,23 +162,12 @@ internal static partial class HlslKnownProperties return knownProperties; } - /// - /// Adds more known members to the mapping to use. - /// - /// The mapping of known properties being built. - static partial void AddKnownProperties(IDictionary knownProperties); - - /// - /// The mapping of supported known properties to HLSL names. - /// - private static readonly IReadOnlyCollection KnownMatrixIndexers = BuildKnownMatrixIndexers(); - /// /// Builds the mapping of swizzled matrix indexer properties. /// - private static IReadOnlyCollection BuildKnownMatrixIndexers() + private static HashSet BuildKnownMatrixIndexers() { - return ( + return new( from type in Assembly.GetExecutingAssembly().ExportedTypes where Regex.IsMatch(type.FullName, @"ComputeSharp\.(Bool|Double|Float|Int|UInt)[1-4]x[1-4]") from property in type.GetProperties() @@ -167,45 +175,36 @@ internal static partial class HlslKnownProperties where indices.Length > 0 && indices.All(static index => index.ParameterType == typeof(MatrixIndex)) let metadataName = $"{type.FullName}.this[{string.Join(", ", indices.Select(index => index.ParameterType))}]" - select metadataName).ToImmutableHashSet(); + select metadataName); } - /// - /// The mapping of supported known members to HLSL names. - /// - private static readonly IReadOnlyCollection KnownMatrixIndices = BuildKnownMatrixIndices(); - /// /// Builds the mapping of swizzled matrix indices. /// - private static IReadOnlyCollection BuildKnownMatrixIndices() + private static HashSet BuildKnownMatrixIndices() { - return ( + return new( from name in Enum.GetNames(typeof(MatrixIndex)) - select $"{typeof(MatrixIndex).FullName}.{name}").ToImmutableHashSet(); + select $"{typeof(MatrixIndex).FullName}.{name}"); } - /// - /// The mapping of supported known indexers to HLSL resource type names. - /// - private static readonly IReadOnlyDictionary KnownResourceIndexers = BuildKnownResourceIndexers(); - /// /// Builds the mapping of supported known indexers to HLSL resource type names. /// /// The mapping of supported known indexers to HLSL resource type names. - private static partial IReadOnlyDictionary BuildKnownResourceIndexers(); - - /// - /// The mapping of supported known size accessors for HLSL resource types. - /// - private static readonly IReadOnlyDictionary KnownSizeAccessors = BuildKnownSizeAccessors(); + private static partial Dictionary BuildKnownResourceIndexers(); /// /// Builds the mapping of supported known size accessors for HLSL resource types. /// /// The mapping of supported known size accessors for HLSL resource types. - private static partial IReadOnlyDictionary BuildKnownSizeAccessors(); + private static partial Dictionary BuildKnownSizeAccessors(); + + /// + /// Adds more known members to the mapping to use. + /// + /// The mapping of known properties being built. + static partial void AddKnownProperties(IDictionary knownProperties); /// /// Checks whether or not a given property fullname matches a matrix swizzled indexer. diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownSizes.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownSizes.cs index 45308371..99caf1cc 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownSizes.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownSizes.cs @@ -14,7 +14,7 @@ internal static class HlslKnownSizes /// /// The mapping of supported known sizes to HLSL type names. /// - private static readonly IReadOnlyDictionary KnownSizes = BuildKnownSizesMap(); + private static readonly Dictionary KnownSizes = BuildKnownSizesMap(); /// /// Builds the mapping of known type sizes and alignments. diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs index f3496cf5..4d62654f 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs @@ -57,22 +57,22 @@ internal static partial class HlslKnownTypes /// /// The mapping of supported known vector types to HLSL types. /// - private static readonly IReadOnlyDictionary KnownVectorTypeMetadataNames = BuildKnownVectorTypeMetadataNames(); + private static readonly Dictionary KnownVectorTypeMetadataNames = BuildKnownVectorTypeMetadataNames(); /// /// The mapping of supported known matrix types to HLSL types. /// - private static readonly IReadOnlyDictionary KnownMatrixTypesMetadataNames = BuildKnownMatrixTypeMetadataNames(); + private static readonly Dictionary KnownMatrixTypesMetadataNames = BuildKnownMatrixTypeMetadataNames(); /// /// The mapping of supported known types to HLSL types. /// - private static readonly IReadOnlyDictionary KnownHlslTypeMetadataNames = BuildKnownHlslTypeMetadataNames(); + private static readonly Dictionary KnownHlslTypeMetadataNames = BuildKnownHlslTypeMetadataNames(); /// /// The mapping of type info for all supported known matrix types to HLSL types. /// - private static readonly IReadOnlyDictionary KnownNonLinearMatrixTypeInfo = BuildKnownNonLinearMatrixTypeInfo(); + private static readonly Dictionary KnownNonLinearMatrixTypeInfo = BuildKnownNonLinearMatrixTypeInfo(); /// /// Builds the mapping of known HLSL vector types. diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownMethods.cs index 3f83ba16..d829bf30 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownMethods.cs @@ -6,9 +6,9 @@ namespace ComputeSharp.SourceGeneration.Mappings; partial class HlslKnownMethods { /// - private static partial IReadOnlyDictionary BuildKnownResourceSamplers() + private static partial Dictionary BuildKnownResourceSamplers() { - return new Dictionary + return new() { [$"ComputeSharp.ReadOnlyTexture1D`2.Sample({typeof(float).FullName})"] = null, [$"ComputeSharp.IReadOnlyTexture1D`1.Sample({typeof(float).FullName})"] = null, diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs index 0d85be99..c3ff1ab2 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs @@ -9,9 +9,9 @@ namespace ComputeSharp.SourceGeneration.Mappings; partial class HlslKnownProperties { /// - private static partial IReadOnlyDictionary BuildKnownResourceIndexers() + private static partial Dictionary BuildKnownResourceIndexers() { - return new Dictionary + return new() { [$"ComputeSharp.ReadOnlyTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", [$"ComputeSharp.ReadOnlyTexture2D`2.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2", @@ -33,9 +33,9 @@ partial class HlslKnownProperties } /// - private static partial IReadOnlyDictionary BuildKnownSizeAccessors() + private static partial Dictionary BuildKnownSizeAccessors() { - return new Dictionary + return new() { ["ComputeSharp.Resources.Buffer`1.Length"] = (2, 0), ["ComputeSharp.Resources.Texture1D`1.Width"] = (1, 0), diff --git a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_Analyzers.cs b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_Analyzers.cs index 903e6549..64609156 100644 --- a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_Analyzers.cs +++ b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_Analyzers.cs @@ -415,4 +415,199 @@ public class Test_Analyzers await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); } + + [TestMethod] + public async Task MissingD2DResourceTextureIndexAttribute_WarnsOnlyIfMissing() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [D2DInputCount(0)] + internal partial struct MyType : ID2D1PixelShader + { + public D2D1ResourceTexture1D {|CMPSD2D0050:texture1D|}; + public D2D1ResourceTexture2D {|CMPSD2D0050:texture2D|}; + public D2D1ResourceTexture3D {|CMPSD2D0050:texture3D|}; + + [D2DResourceTextureIndex(0)] + public D2D1ResourceTexture1D texture1D_2; + + [D2DResourceTextureIndex(1)] + public D2D1ResourceTexture2D texture2D_2; + + [D2DResourceTextureIndex(2)] + public D2D1ResourceTexture3D texture3D_2; + + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } + + [TestMethod] + public async Task ResourceTextureIndexOverlappingWithInputIndex_Warns() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [D2DInputCount(2)] + internal partial struct {|CMPSD2D0046:MyType|} : ID2D1PixelShader + { + [D2DResourceTextureIndex(1)] + public D2D1ResourceTexture1D texture; + + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } + + [TestMethod] + public async Task ResourceTextureIndexOverlappingWithInputIndex_WarnsOnlyOnce() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [D2DInputCount(2)] + internal partial struct {|CMPSD2D0046:MyType|} : ID2D1PixelShader + { + [D2DResourceTextureIndex(0)] + public D2D1ResourceTexture1D texture1D; + + [D2DResourceTextureIndex(1)] + public D2D1ResourceTexture2D texture2D; + + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } + + [TestMethod] + public async Task OutOfRangeResourceTextureIndex_Warns() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [D2DInputCount(0)] + internal partial struct {|CMPSD2D0047:MyType|} : ID2D1PixelShader + { + [D2DResourceTextureIndex(16)] + public D2D1ResourceTexture1D texture; + + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } + + [TestMethod] + public async Task OutOfRangeResourceTextureIndex_WarnsOnlyOnce() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [D2DInputCount(0)] + internal partial struct {|CMPSD2D0047:MyType|} : ID2D1PixelShader + { + [D2DResourceTextureIndex(16)] + public D2D1ResourceTexture1D texture1D; + + [D2DResourceTextureIndex(17)] + public D2D1ResourceTexture2D texture2D; + + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } + + [TestMethod] + public async Task RepeatedD2DResourceTextureIndices_Warns() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [D2DInputCount(0)] + internal partial struct {|CMPSD2D0048:MyType|} : ID2D1PixelShader + { + [D2DResourceTextureIndex(0)] + public D2D1ResourceTexture1D texture1; + + [D2DResourceTextureIndex(0)] + public D2D1ResourceTexture1D texture2; + + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } + + [TestMethod] + public async Task InvalidD2DResourceTextureIndices_MultipleErrors_WarnsOncePerDiagnosticId() + { + const string source = """ + using ComputeSharp; + using ComputeSharp.D2D1; + + [D2DInputCount(3)] + internal partial struct {|CMPSD2D0046:{|CMPSD2D0047:{|CMPSD2D0048:MyType|}|}|} : ID2D1PixelShader + { + [D2DResourceTextureIndex(0)] + public D2D1ResourceTexture1D texture1; + + [D2DResourceTextureIndex(1)] + public D2D1ResourceTexture1D texture2; + + [D2DResourceTextureIndex(16)] + public D2D1ResourceTexture1D texture3; + + [D2DResourceTextureIndex(17)] + public D2D1ResourceTexture2D texture4; + + [D2DResourceTextureIndex(2)] + public D2D1ResourceTexture1D texture5; + + [D2DResourceTextureIndex(2)] + public D2D1ResourceTexture1D texture6; + + public Float4 Execute() + { + return 0; + } + } + """; + + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + } } \ No newline at end of file diff --git a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_D2DPixelShaderDescriptorGenerator.cs b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_D2DPixelShaderDescriptorGenerator.cs index e9ce7e4a..8ac64ed0 100644 --- a/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_D2DPixelShaderDescriptorGenerator.cs +++ b/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_D2DPixelShaderDescriptorGenerator.cs @@ -1770,7 +1770,8 @@ public class Test_D2DPixelShaderDescriptorGenerator await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); - await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); + await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source); await CSharpAnalyzerWithLanguageVersionTest.VerifyAnalyzerAsync(source);