From 31cfdd9ecacadfa377dcdea894bcd4f34fef1c31 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 10 Apr 2022 20:59:58 +0200 Subject: [PATCH] Move HLSL extensions to new shared project --- ComputeSharp.sln | 5 + ...eSharp.D2D1Interop.SourceGenerators.csproj | 3 +- .../Extensions/StringExtensions.cs | 18 -- .../Extensions/SyntaxNodeExtensions.cs | 199 ------------------ ...erGenerator.CreateBuildHlslSourceMethod.cs | 3 +- ...rGenerator.CreateLoadDispatchDataMethod.cs | 1 + .../Mappings/HlslKnownMembers.cs | 1 + .../Mappings/HlslKnownTypes.cs | 3 +- .../SyntaxRewriters/HlslSourceRewriter.cs | 3 +- .../SyntaxRewriters/ShaderSourceRewriter.cs | 3 +- .../SyntaxRewriters/StaticFieldRewriter.cs | 1 - ...mputeSharp.SourceGeneration.Hlsl.projitems | 15 ++ .../ComputeSharp.SourceGeneration.Hlsl.shproj | 13 ++ .../Extensions/StringExtensions.cs | 3 +- .../Extensions/SyntaxNodeExtensions.cs | 3 +- .../ComputeSharp.SourceGenerators.csproj | 1 + ...erGenerator.CreateBuildHlslSourceMethod.cs | 1 - .../Mappings/HlslKnownTypes.cs | 1 - .../ShaderMethodSourceGenerator.cs | 1 - .../SyntaxRewriters/HlslSourceRewriter.cs | 1 - .../SyntaxRewriters/ShaderSourceRewriter.cs | 2 - .../SyntaxRewriters/StaticFieldRewriter.cs | 1 - 22 files changed, 44 insertions(+), 238 deletions(-) delete mode 100644 src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/StringExtensions.cs delete mode 100644 src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/SyntaxNodeExtensions.cs create mode 100644 src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.projitems create mode 100644 src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.shproj rename src/{ComputeSharp.SourceGenerators => ComputeSharp.SourceGeneration.Hlsl}/Extensions/StringExtensions.cs (90%) rename src/{ComputeSharp.SourceGenerators => ComputeSharp.SourceGeneration.Hlsl}/Extensions/SyntaxNodeExtensions.cs (98%) diff --git a/ComputeSharp.sln b/ComputeSharp.sln index 31b6be92..51976401 100644 --- a/ComputeSharp.sln +++ b/ComputeSharp.sln @@ -94,6 +94,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.D2D1Interop.So EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ComputeSharp.SourceGeneration", "src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.shproj", "{51D5A422-D3A5-4C4D-8A6D-A048940BF279}" EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ComputeSharp.SourceGeneration.Hlsl", "src\ComputeSharp.SourceGeneration.Hlsl\ComputeSharp.SourceGeneration.Hlsl.shproj", "{9AC496A3-BBF0-4C8F-A50D-A20BF01C5E05}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{0071701e-b9c5-4098-be5f-ef556c4553c6}*SharedItemsImports = 5 @@ -114,6 +116,7 @@ Global src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems*{764bc0f5-0c5e-49ad-abaa-e3874c0f3286}*SharedItemsImports = 5 src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{76c66257-fdaa-47ab-85e7-ef757eab10c0}*SharedItemsImports = 5 samples\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems*{8cefc324-ca6c-4845-9ad9-70b92bd87057}*SharedItemsImports = 13 + src\ComputeSharp.SourceGeneration.Hlsl\ComputeSharp.SourceGeneration.Hlsl.projitems*{9ac496a3-bbf0-4c8f-a50d-a20bf01c5e05}*SharedItemsImports = 13 src\TerraFX.Interop.Windows.D2D1Interop\TerraFX.Interop.Windows.D2D1Interop.projitems*{9da1da9f-f8b2-4b25-be80-c21f773029e3}*SharedItemsImports = 13 src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{a5997814-d8d2-4541-87ac-c3e53caa67c0}*SharedItemsImports = 13 src\ComputeSharp.UI\ComputeSharp.UI.projitems*{afaafdc9-be42-45d4-8c79-0ee8c8edbf52}*SharedItemsImports = 5 @@ -121,12 +124,14 @@ Global src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{bfb003d1-788b-48de-8065-39479c162cb0}*SharedItemsImports = 5 src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5 src\ComputeSharp.D2D1Interop.NetStandard\ComputeSharp.D2D1Interop.NetStandard.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5 + src\ComputeSharp.SourceGeneration.Hlsl\ComputeSharp.SourceGeneration.Hlsl.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5 src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5 src\TerraFX.Interop.Windows.D2D1Interop\TerraFX.Interop.Windows.D2D1Interop.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5 samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{e7c9247d-016b-4819-af9f-0e9b3591e04b}*SharedItemsImports = 5 samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{e91f4d24-922a-4921-a8d7-9c45a143c45d}*SharedItemsImports = 5 src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5 src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5 + src\ComputeSharp.SourceGeneration.Hlsl\ComputeSharp.SourceGeneration.Hlsl.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5 src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5 src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5 src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5 diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/ComputeSharp.D2D1Interop.SourceGenerators.csproj b/src/ComputeSharp.D2D1Interop.SourceGenerators/ComputeSharp.D2D1Interop.SourceGenerators.csproj index 0664cfae..7780e5c1 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/ComputeSharp.D2D1Interop.SourceGenerators.csproj +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/ComputeSharp.D2D1Interop.SourceGenerators.csproj @@ -93,8 +93,9 @@ - + + diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/StringExtensions.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/StringExtensions.cs deleted file mode 100644 index 66a215d7..00000000 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/StringExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ - -namespace ComputeSharp.D2D1Interop.SourceGenerators.Extensions; - -/// -/// Extension methods for types. -/// -internal static class StringExtensions -{ - /// - /// Converts a given instance to a valid HLSL identifier name. - /// - /// The input instance to convert. - /// An valid HLSL identifier name from . - public static string ToHlslIdentifierName(this string text) - { - return text.Replace('.', '_').Replace('+', '_'); - } -} diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/SyntaxNodeExtensions.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/SyntaxNodeExtensions.cs deleted file mode 100644 index 8e8c65f8..00000000 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/SyntaxNodeExtensions.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using ComputeSharp.D2D1Interop.SourceGenerators.Mappings; -using ComputeSharp.SourceGeneration.Extensions; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; - -namespace ComputeSharp.D2D1Interop.SourceGenerators.Extensions; - -/// -/// A with some extension methods for C# syntax nodes. -/// -internal static class SyntaxNodeExtensions -{ - /// - /// Checks a value and replaces the value type to be HLSL compatible, if needed. - /// - /// The type of the input instance. - /// The input to check and modify if needed. - /// The source to use to get type into from . - /// The instance with info on the input tree. - /// The collection of currently discovered types. - /// A instance that represents a type compatible with HLSL. - public static TRoot ReplaceAndTrackType(this TRoot node, SyntaxNode sourceType, SemanticModel semanticModel, ICollection discoveredTypes) - where TRoot : TypeSyntax - { - return node.ReplaceAndTrackType(node, sourceType, semanticModel, discoveredTypes); - } - - /// - /// Checks a value and replaces the value type to be HLSL compatible, if needed. - /// - /// The type of the input instance. - /// The input to check and modify if needed. - /// The target node to replace. - /// The source to use to get type into from . - /// The instance with info on the input tree. - /// The collection of currently discovered types. - /// A instance that represents a type compatible with HLSL. - public static TRoot ReplaceAndTrackType(this TRoot node, TypeSyntax targetType, SyntaxNode sourceType, SemanticModel semanticModel, ICollection discoveredTypes) - where TRoot : SyntaxNode - { - // Skip immediately for function pointers - if (sourceType is FunctionPointerTypeSyntax) - { - return node.ReplaceNode(targetType, ParseTypeName("void*")); - } - - // Handle the various possible type kinds - ITypeSymbol typeSymbol = sourceType switch - { - RefTypeSyntax refType => semanticModel.GetTypeInfo(refType.Type).Type!, - PointerTypeSyntax pointerType => semanticModel.GetTypeInfo(pointerType.ElementType).Type!, - _ => semanticModel.GetTypeInfo(sourceType).Type! - }; - - // Do nothing if the type is just void - if (typeSymbol.SpecialType == SpecialType.System_Void) - { - return node; - } - - string typeName = typeSymbol.GetFullyQualifiedName(); - - discoveredTypes.Add((INamedTypeSymbol)typeSymbol); - - if (HlslKnownTypes.TryGetMappedName(typeName, out string? mappedName)) - { - TypeSyntax newType = ParseTypeName(mappedName!); - - return node.ReplaceNode(targetType, newType); - } - - return node.ReplaceNode(targetType, ParseTypeName(typeName.ToHlslIdentifierName())); - } - - /// - /// Tracks the associated type for a value and returns the HLSL compatible . - /// - /// The input to check. - /// The instance with info on the input tree. - /// The collection of currently discovered types. - /// A instance that represents a type compatible with HLSL. - public static TypeSyntax TrackType(this SyntaxNode node, SemanticModel semanticModel, ICollection discoveredTypes) - { - ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(node).Type!; - string typeName = typeSymbol.GetFullyQualifiedName(); - - discoveredTypes.Add((INamedTypeSymbol)typeSymbol); - - if (HlslKnownTypes.TryGetMappedName(typeName, out string? mappedName)) - { - return ParseTypeName(mappedName!); - } - - return ParseTypeName(typeName.ToHlslIdentifierName()); - } - - /// - /// Returns a with a block body. - /// - /// The input node. - /// A node like the one in input, but always with a block body. - public static MethodDeclarationSyntax WithBlockBody(this MethodDeclarationSyntax node) - { - if (node.ExpressionBody is ArrowExpressionClauseSyntax arrow) - { - StatementSyntax statement = node.ReturnType switch - { - PredefinedTypeSyntax pts when pts.Keyword.IsKind(SyntaxKind.VoidKeyword) => ExpressionStatement(arrow.Expression), - _ => ReturnStatement(arrow.Expression) - }; - - return node - .WithBody(Block(statement)) - .WithExpressionBody(null) - .WithSemicolonToken(MissingToken(SyntaxKind.SemicolonToken)); - } - - return node; - } - - /// - /// Returns a as a method definition. - /// - /// The input node. - /// A node like the one in input, but just as a definition. - public static MethodDeclarationSyntax AsDefinition(this MethodDeclarationSyntax node) - { - if (node.ExpressionBody is ArrowExpressionClauseSyntax) - { - return node.WithExpressionBody(null).WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); - } - - return node.WithBody(null).WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); - } - - /// - /// Returns a with a block body. - /// - /// The input node. - /// A node like the one in input, but always with a block body. - /// - /// This method is the same as , but it is necessary to - /// duplicate the code because the two types don't have a common base type or interface that can be leveraged. - /// - public static LocalFunctionStatementSyntax WithBlockBody(this LocalFunctionStatementSyntax node) - { - if (node.ExpressionBody is ArrowExpressionClauseSyntax arrow) - { - StatementSyntax statement = node.ReturnType switch - { - PredefinedTypeSyntax pts when pts.Keyword.IsKind(SyntaxKind.VoidKeyword) => ExpressionStatement(arrow.Expression), - _ => ReturnStatement(arrow.Expression) - }; - - return node - .WithBody(Block(statement)) - .WithExpressionBody(null) - .WithSemicolonToken(MissingToken(SyntaxKind.SemicolonToken)); - } - - return node; - } - - /// - /// Returns a as a method definition. - /// - /// The input node. - /// A node like the one in input, but just as a definition. - public static LocalFunctionStatementSyntax AsDefinition(this LocalFunctionStatementSyntax node) - { - if (node.ExpressionBody is ArrowExpressionClauseSyntax) - { - return node.WithExpressionBody(null).WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); - } - - return node.WithBody(null).WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); - } - - /// - /// Returns a instance with no accessibility modifiers. - /// - /// The input node. - /// A node just like but with no accessibility modifiers. - public static MethodDeclarationSyntax WithoutAccessibilityModifiers(this MethodDeclarationSyntax node) - { - return node.WithModifiers(TokenList(node.Modifiers.Where(static modifier => modifier.Kind() switch - { - SyntaxKind.PublicKeyword => false, - SyntaxKind.PrivateKeyword => false, - SyntaxKind.ProtectedKeyword => false, - SyntaxKind.InternalKeyword => false, - _ => true - }).ToArray())); - } -} diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs index 37c328e5..2ef9b893 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -4,12 +4,11 @@ using System.Collections.Immutable; using System.Linq; using System.Text; using ComputeSharp.D2D1Interop.SourceGenerators.Diagnostics; -using ComputeSharp.D2D1Interop.SourceGenerators.Extensions; -using ComputeSharp.D2D1Interop.SourceGenerators.Mappings; using ComputeSharp.D2D1Interop.SourceGenerators.SyntaxRewriters; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; using ComputeSharp.SourceGeneration.Mappings; +using ComputeSharp.SourceGenerators.Mappings; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs index 0cbd8865..3b1beac2 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs @@ -8,6 +8,7 @@ using ComputeSharp.D2D1Interop.SourceGenerators.Diagnostics; using ComputeSharp.D2D1Interop.SourceGenerators.Mappings; using ComputeSharp.D2D1Interop.SourceGenerators.Models; using ComputeSharp.SourceGeneration.Extensions; +using ComputeSharp.SourceGenerators.Mappings; using Microsoft.CodeAnalysis; using static ComputeSharp.D2D1Interop.SourceGenerators.Diagnostics.DiagnosticDescriptors; diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Mappings/HlslKnownMembers.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Mappings/HlslKnownMembers.cs index 3800e858..a767134f 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Mappings/HlslKnownMembers.cs +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/Mappings/HlslKnownMembers.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Numerics; using System.Reflection; using System.Text.RegularExpressions; +using ComputeSharp.SourceGenerators.Mappings; namespace ComputeSharp.D2D1Interop.SourceGenerators.Mappings; diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Mappings/HlslKnownTypes.cs index 0dfc52bc..e373817b 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/Mappings/HlslKnownTypes.cs @@ -3,13 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text.RegularExpressions; -using ComputeSharp.D2D1Interop.SourceGenerators.Extensions; using ComputeSharp.SourceGeneration.Extensions; using Microsoft.CodeAnalysis; #pragma warning disable RS1024 -namespace ComputeSharp.D2D1Interop.SourceGenerators.Mappings; +namespace ComputeSharp.SourceGenerators.Mappings; /// /// A that contains and maps known HLSL type names to common .NET types. diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs index 7b48af8b..9930377e 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs @@ -3,12 +3,11 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Globalization; using System.Linq; -using ComputeSharp.D2D1Interop.SourceGenerators.Diagnostics; -using ComputeSharp.D2D1Interop.SourceGenerators.Extensions; using ComputeSharp.D2D1Interop.SourceGenerators.Mappings; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; using ComputeSharp.SourceGeneration.Mappings; +using ComputeSharp.SourceGenerators.Mappings; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs index aeb93baf..6ad3a01d 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs @@ -3,11 +3,10 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Globalization; using System.Linq; -using ComputeSharp.D2D1Interop.SourceGenerators.Diagnostics; -using ComputeSharp.D2D1Interop.SourceGenerators.Extensions; using ComputeSharp.D2D1Interop.SourceGenerators.Mappings; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; +using ComputeSharp.SourceGenerators.Mappings; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs index 82ebba5d..a8d70c45 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Globalization; -using ComputeSharp.D2D1Interop.SourceGenerators.Extensions; using ComputeSharp.D2D1Interop.SourceGenerators.Mappings; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.projitems b/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.projitems new file mode 100644 index 00000000..97280dff --- /dev/null +++ b/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.projitems @@ -0,0 +1,15 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 9ac496a3-bbf0-4c8f-a50d-a20bf01c5e05 + + + ComputeSharp.SourceGeneration.Hlsl + + + + + + \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.shproj b/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.shproj new file mode 100644 index 00000000..4c441b94 --- /dev/null +++ b/src/ComputeSharp.SourceGeneration.Hlsl/ComputeSharp.SourceGeneration.Hlsl.shproj @@ -0,0 +1,13 @@ + + + + 9ac496a3-bbf0-4c8f-a50d-a20bf01c5e05 + 14.0 + + + + + + + + diff --git a/src/ComputeSharp.SourceGenerators/Extensions/StringExtensions.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Extensions/StringExtensions.cs similarity index 90% rename from src/ComputeSharp.SourceGenerators/Extensions/StringExtensions.cs rename to src/ComputeSharp.SourceGeneration.Hlsl/Extensions/StringExtensions.cs index 993450dc..f0847fa0 100644 --- a/src/ComputeSharp.SourceGenerators/Extensions/StringExtensions.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Extensions/StringExtensions.cs @@ -1,5 +1,4 @@ - -namespace ComputeSharp.SourceGenerators.Extensions; +namespace ComputeSharp.SourceGeneration.Extensions; /// /// Extension methods for types. diff --git a/src/ComputeSharp.SourceGenerators/Extensions/SyntaxNodeExtensions.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Extensions/SyntaxNodeExtensions.cs similarity index 98% rename from src/ComputeSharp.SourceGenerators/Extensions/SyntaxNodeExtensions.cs rename to src/ComputeSharp.SourceGeneration.Hlsl/Extensions/SyntaxNodeExtensions.cs index 9d85b1d5..009428ab 100644 --- a/src/ComputeSharp.SourceGenerators/Extensions/SyntaxNodeExtensions.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Extensions/SyntaxNodeExtensions.cs @@ -1,13 +1,12 @@ using System.Collections.Generic; using System.Linq; -using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGenerators.Mappings; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -namespace ComputeSharp.SourceGenerators.Extensions; +namespace ComputeSharp.SourceGeneration.Extensions; /// /// A with some extension methods for C# syntax nodes. diff --git a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj index d7e85278..24881627 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj +++ b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj @@ -100,6 +100,7 @@ + diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs index df772ffb..5eeedb05 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -7,7 +7,6 @@ using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; using ComputeSharp.SourceGeneration.Mappings; using ComputeSharp.SourceGenerators.Diagnostics; -using ComputeSharp.SourceGenerators.Extensions; using ComputeSharp.SourceGenerators.Mappings; using ComputeSharp.SourceGenerators.Models; using ComputeSharp.SourceGenerators.SyntaxRewriters; diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs index 71151d86..76982d56 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Numerics; using System.Text.RegularExpressions; using ComputeSharp.SourceGeneration.Extensions; -using ComputeSharp.SourceGenerators.Extensions; using Microsoft.CodeAnalysis; #pragma warning disable RS1024 diff --git a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs index d4727529..2ba6fd55 100644 --- a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs @@ -5,7 +5,6 @@ using ComputeSharp.__Internals; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; using ComputeSharp.SourceGeneration.Models; -using ComputeSharp.SourceGenerators.Extensions; using ComputeSharp.SourceGenerators.Models; using ComputeSharp.SourceGenerators.SyntaxRewriters; using Microsoft.CodeAnalysis; diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs index 6f31efbb..6de039b6 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs @@ -6,7 +6,6 @@ using System.Linq; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; using ComputeSharp.SourceGeneration.Mappings; -using ComputeSharp.SourceGenerators.Extensions; using ComputeSharp.SourceGenerators.Mappings; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs index 1b10d676..8738951c 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs @@ -5,8 +5,6 @@ using System.Globalization; using System.Linq; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; -using ComputeSharp.SourceGenerators.Diagnostics; -using ComputeSharp.SourceGenerators.Extensions; using ComputeSharp.SourceGenerators.Mappings; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs index d7b75747..36fecebd 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/StaticFieldRewriter.cs @@ -5,7 +5,6 @@ using System.Globalization; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; using ComputeSharp.SourceGenerators.Diagnostics; -using ComputeSharp.SourceGenerators.Extensions; using ComputeSharp.SourceGenerators.Mappings; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp;