From 59cd5a9ce3f0ccb99f2277ed6b3341fd74f2aa47 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 3 Apr 2022 17:03:09 +0200 Subject: [PATCH] Move generators to ComputeSharp.Core.SourceGenerators --- ComputeSharp.sln | 15 ++++ .../AnalyzerReleases.Shipped.md | 9 ++ .../AnalyzerReleases.Unshipped.md | 2 + .../AutoConstructorGenerator.cs | 4 +- .../ComputeSharp.Core.SourceGenerators.csproj | 80 +++++++++++++++++ .../GlobalUsingDirectives.cs | 0 .../Extensions/HashCodeExtensions.cs | 40 +++++++++ .../Extensions/IEqualityComparerExtensions.cs | 59 ++++++++++++ .../Extensions/ISymbolExtensions.cs | 46 ++++++++++ .../Extensions/ImmutableArrayExtensions.cs | 50 +++++++++++ .../IncrementalValuesProviderExtensions.cs | 71 +++++++++++++++ .../GlobalUsingDirectivesGenerator.cs | 0 .../Helpers/HashCode.cs | 0 .../Models/HierarchyInfo.cs | 90 +++++++++++++++++++ .../Models/ParameterInfo.cs | 8 ++ .../IsExternalInit.cs | 12 +++ .../ComputeSharp.SourceGenerators.csproj | 13 +-- .../AutoConstructorGeneratorTests.cs | 2 +- 18 files changed, 489 insertions(+), 12 deletions(-) create mode 100644 src/ComputeSharp.Core.SourceGenerators/AnalyzerReleases.Shipped.md create mode 100644 src/ComputeSharp.Core.SourceGenerators/AnalyzerReleases.Unshipped.md rename src/{ComputeSharp.SourceGenerators => ComputeSharp.Core.SourceGenerators}/AutoConstructorGenerator.cs (98%) create mode 100644 src/ComputeSharp.Core.SourceGenerators/ComputeSharp.Core.SourceGenerators.csproj rename src/{ComputeSharp.SourceGenerators => ComputeSharp.Core.SourceGenerators}/EmbeddedResources/GlobalUsingDirectives.cs (100%) create mode 100644 src/ComputeSharp.Core.SourceGenerators/Extensions/HashCodeExtensions.cs create mode 100644 src/ComputeSharp.Core.SourceGenerators/Extensions/IEqualityComparerExtensions.cs create mode 100644 src/ComputeSharp.Core.SourceGenerators/Extensions/ISymbolExtensions.cs create mode 100644 src/ComputeSharp.Core.SourceGenerators/Extensions/ImmutableArrayExtensions.cs create mode 100644 src/ComputeSharp.Core.SourceGenerators/Extensions/IncrementalValuesProviderExtensions.cs rename src/{ComputeSharp.SourceGenerators => ComputeSharp.Core.SourceGenerators}/GlobalUsingDirectivesGenerator.cs (100%) rename src/{ComputeSharp.SourceGenerators => ComputeSharp.Core.SourceGenerators}/Helpers/HashCode.cs (100%) create mode 100644 src/ComputeSharp.Core.SourceGenerators/Models/HierarchyInfo.cs create mode 100644 src/ComputeSharp.Core.SourceGenerators/Models/ParameterInfo.cs create mode 100644 src/ComputeSharp.Core.SourceGenerators/System.Runtime.CompilerServices/IsExternalInit.cs diff --git a/ComputeSharp.sln b/ComputeSharp.sln index ab302913..68f242f5 100644 --- a/ComputeSharp.sln +++ b/ComputeSharp.sln @@ -85,6 +85,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Core", "src\Co EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ComputeSharp.Core.NetStandard", "src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.shproj", "{3ACACF03-6B20-40BA-B8EC-11AC1624D2C9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputeSharp.Core.SourceGenerators", "src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj", "{BFB003D1-788B-48DE-8065-39479C162CB0}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{0071701e-b9c5-4098-be5f-ef556c4553c6}*SharedItemsImports = 5 @@ -107,6 +109,7 @@ Global 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 + src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems*{bfb003d1-788b-48de-8065-39479c162cb0}*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 @@ -378,6 +381,18 @@ Global {764BC0F5-0C5E-49AD-ABAA-E3874C0F3286}.Release|ARM64.Build.0 = Release|Any CPU {764BC0F5-0C5E-49AD-ABAA-E3874C0F3286}.Release|x64.ActiveCfg = Release|Any CPU {764BC0F5-0C5E-49AD-ABAA-E3874C0F3286}.Release|x64.Build.0 = Release|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Debug|ARM64.Build.0 = Debug|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Debug|x64.ActiveCfg = Debug|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Debug|x64.Build.0 = Debug|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Release|Any CPU.Build.0 = Release|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Release|ARM64.ActiveCfg = Release|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Release|ARM64.Build.0 = Release|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Release|x64.ActiveCfg = Release|Any CPU + {BFB003D1-788B-48DE-8065-39479C162CB0}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/ComputeSharp.Core.SourceGenerators/AnalyzerReleases.Shipped.md b/src/ComputeSharp.Core.SourceGenerators/AnalyzerReleases.Shipped.md new file mode 100644 index 00000000..cc5f50e7 --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/AnalyzerReleases.Shipped.md @@ -0,0 +1,9 @@ +; Shipped analyzer releases +; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md + +## Release 1.0 + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- diff --git a/src/ComputeSharp.Core.SourceGenerators/AnalyzerReleases.Unshipped.md b/src/ComputeSharp.Core.SourceGenerators/AnalyzerReleases.Unshipped.md new file mode 100644 index 00000000..6a6dd08d --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/AnalyzerReleases.Unshipped.md @@ -0,0 +1,2 @@ +; Unshipped analyzer release +; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md diff --git a/src/ComputeSharp.SourceGenerators/AutoConstructorGenerator.cs b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs similarity index 98% rename from src/ComputeSharp.SourceGenerators/AutoConstructorGenerator.cs rename to src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs index b6afffe2..dc38178b 100644 --- a/src/ComputeSharp.SourceGenerators/AutoConstructorGenerator.cs +++ b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; -using ComputeSharp.SourceGenerators.Extensions; -using ComputeSharp.SourceGenerators.Models; +using ComputeSharp.Core.SourceGenerators.Extensions; +using ComputeSharp.Core.SourceGenerators.Models; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/ComputeSharp.Core.SourceGenerators/ComputeSharp.Core.SourceGenerators.csproj b/src/ComputeSharp.Core.SourceGenerators/ComputeSharp.Core.SourceGenerators.csproj new file mode 100644 index 00000000..c9647076 --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/ComputeSharp.Core.SourceGenerators.csproj @@ -0,0 +1,80 @@ + + + + netstandard2.0 + false + ComputeSharp.SourceGenerators + $(NoWarn);CS1591;CS0649;CS1574 + + + + $(DefineConstants);SOURCE_GENERATOR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ComputeSharp.SourceGenerators/EmbeddedResources/GlobalUsingDirectives.cs b/src/ComputeSharp.Core.SourceGenerators/EmbeddedResources/GlobalUsingDirectives.cs similarity index 100% rename from src/ComputeSharp.SourceGenerators/EmbeddedResources/GlobalUsingDirectives.cs rename to src/ComputeSharp.Core.SourceGenerators/EmbeddedResources/GlobalUsingDirectives.cs diff --git a/src/ComputeSharp.Core.SourceGenerators/Extensions/HashCodeExtensions.cs b/src/ComputeSharp.Core.SourceGenerators/Extensions/HashCodeExtensions.cs new file mode 100644 index 00000000..8c219c45 --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/Extensions/HashCodeExtensions.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; + +namespace ComputeSharp.Core.SourceGenerators.Extensions; + +/// +/// Extension methods for . +/// +internal static class HashCodeExtensions +{ + /// + /// Adds all items from a given instance to an hashcode. + /// + /// The type of items to hash. + /// The target instance. + /// The input items to hash. + public static void AddRange(this ref HashCode hashCode, ImmutableArray items) + { + foreach (T item in items) + { + hashCode.Add(item); + } + } + + /// + /// Adds all items from a given instance to an hashcode. + /// + /// The type of items to hash. + /// The target instance. + /// A comparer to get hashcodes for items. + /// The input items to hash. + public static void AddRange(this ref HashCode hashCode, ImmutableArray items, IEqualityComparer comparer) + { + foreach (T item in items) + { + hashCode.Add(item, comparer); + } + } +} diff --git a/src/ComputeSharp.Core.SourceGenerators/Extensions/IEqualityComparerExtensions.cs b/src/ComputeSharp.Core.SourceGenerators/Extensions/IEqualityComparerExtensions.cs new file mode 100644 index 00000000..48ac4beb --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/Extensions/IEqualityComparerExtensions.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; + +namespace ComputeSharp.Core.SourceGenerators.Extensions; + +/// +/// Extension methods for . +/// +internal static class IEqualityComparerExtensions +{ + /// + /// Gets an for an sequence. + /// + /// The type of items to compare. + /// The compare for individual items. + public static IEqualityComparer> ForImmutableArray(this IEqualityComparer comparer) + { + return new Comparer(comparer); + } + + /// + /// An implementation for an value. + /// + public sealed class Comparer : IEqualityComparer> + { + /// + /// The comparer. + /// + private readonly IEqualityComparer comparer; + + /// + /// Creates a new instance with the specified parameters. + /// + /// The comparer. + public Comparer(IEqualityComparer comparer) + { + this.comparer = comparer; + } + + /// + public bool Equals(ImmutableArray x, ImmutableArray y) + { + return + x == y || + x.SequenceEqual(y, this.comparer); + } + + /// + public int GetHashCode(ImmutableArray obj) + { + HashCode hashCode = default; + + hashCode.AddRange(obj, this.comparer); + + return hashCode.ToHashCode(); + } + } +} diff --git a/src/ComputeSharp.Core.SourceGenerators/Extensions/ISymbolExtensions.cs b/src/ComputeSharp.Core.SourceGenerators/Extensions/ISymbolExtensions.cs new file mode 100644 index 00000000..4853e2ee --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/Extensions/ISymbolExtensions.cs @@ -0,0 +1,46 @@ +using System.Text; +using Microsoft.CodeAnalysis; + +namespace ComputeSharp.Core.SourceGenerators.Extensions; + +/// +/// Extension methods for types. +/// +internal static class ISymbolExtensions +{ + /// + /// Gets a valid filename for a target symbol and generator type. + /// + /// The symbol being processed. + /// A filename in the form "<SYMBOL_FULLNAME>" + public static string GetGeneratedFileName(this INamedTypeSymbol symbol) + { + return symbol.GetFullMetadataName().Replace('`', '-').Replace('+', '.'); + } + + /// + /// Gets the full metadata name for a given instance. + /// + /// The input instance. + /// The full metadata name for . + private static string GetFullMetadataName(this ITypeSymbol symbol) + { + static StringBuilder BuildFrom(ISymbol? symbol, StringBuilder builder) + { + return symbol switch + { + INamespaceSymbol ns when ns.IsGlobalNamespace => builder, + INamespaceSymbol ns when ns.ContainingNamespace is { IsGlobalNamespace: false } + => BuildFrom(ns.ContainingNamespace, builder.Insert(0, $".{ns.MetadataName}")), + ITypeSymbol ts when ts.ContainingType is ISymbol containingType + => BuildFrom(containingType, builder.Insert(0, $"+{ts.MetadataName}")), + ITypeSymbol ts when ts.ContainingNamespace is ISymbol containingNamespace and not INamespaceSymbol { IsGlobalNamespace: true } + => BuildFrom(containingNamespace, builder.Insert(0, $".{ts.MetadataName}")), + ISymbol => BuildFrom(symbol.ContainingSymbol, builder.Insert(0, symbol.MetadataName)), + _ => builder + }; + } + + return BuildFrom(symbol, new StringBuilder(256)).ToString(); + } +} diff --git a/src/ComputeSharp.Core.SourceGenerators/Extensions/ImmutableArrayExtensions.cs b/src/ComputeSharp.Core.SourceGenerators/Extensions/ImmutableArrayExtensions.cs new file mode 100644 index 00000000..b9b03491 --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/Extensions/ImmutableArrayExtensions.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; + +namespace ComputeSharp.Core.SourceGenerators.Extensions; + +/// +/// Extension methods for . +/// +internal static class ImmutableArrayExtensions +{ + /// + /// Compares two sequences for equality. + /// + /// The items to compare. + /// The left sequence of items. + /// The right sequence of items. + /// Whether or not equals . + public static bool SequenceEqual(this ImmutableArray left, ImmutableArray right) + where T : IEquatable + { + return left.AsSpan().SequenceEqual(right.AsSpan()); + } + + /// + /// Compares two sequences for equality. + /// + /// The items to compare. + /// The left sequence of items. + /// The right sequence of items. + /// The instance used to compare items. + /// Whether or not equals . + public static bool SequenceEqual(this ImmutableArray left, ImmutableArray right, IEqualityComparer comparer) + { + if (left.Length != right.Length) + { + return false; + } + + for (int i = 0; i < left.Length; i++) + { + if (!comparer.Equals(left[i], right[i])) + { + return false; + } + } + + return true; + } +} diff --git a/src/ComputeSharp.Core.SourceGenerators/Extensions/IncrementalValuesProviderExtensions.cs b/src/ComputeSharp.Core.SourceGenerators/Extensions/IncrementalValuesProviderExtensions.cs new file mode 100644 index 00000000..95d0326b --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/Extensions/IncrementalValuesProviderExtensions.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using Microsoft.CodeAnalysis; + +namespace ComputeSharp.Core.SourceGenerators.Extensions; + +/// +/// Extension methods for . +/// +internal static class IncrementalValuesProviderExtensions +{ + /// + /// Creates a new instance with a gven pair of comparers. + /// + /// The type of left items in each tuple. + /// The type of right items in each tuple. + /// The input instance. + /// An instance for items. + /// An instance for items. + /// An with the specified comparers applied to each item. + public static IncrementalValuesProvider<(TLeft Left, TRight Right)> WithComparers( + this IncrementalValuesProvider<(TLeft Left, TRight Right)> source, + IEqualityComparer comparerLeft, + IEqualityComparer comparerRight) + { + return source.WithComparer(new Comparer(comparerLeft, comparerRight)); + } + + /// + /// An implementation for a value tuple. + /// + public sealed class Comparer : IEqualityComparer<(TLeft Left, TRight Right)> + { + /// + /// The comparer. + /// + private readonly IEqualityComparer comparerLeft; + + /// + /// The comparer. + /// + private readonly IEqualityComparer comparerRight; + + /// + /// Creates a new instance with the specified parameters. + /// + /// The comparer. + /// The comparer. + public Comparer(IEqualityComparer comparerLeft, IEqualityComparer comparerRight) + { + this.comparerLeft = comparerLeft; + this.comparerRight = comparerRight; + } + + /// + public bool Equals((TLeft Left, TRight Right) x, (TLeft Left, TRight Right) y) + { + return + this.comparerLeft.Equals(x.Left, y.Left) && + this.comparerRight.Equals(x.Right, y.Right); + } + + /// + public int GetHashCode((TLeft Left, TRight Right) obj) + { + return HashCode.Combine( + this.comparerLeft.GetHashCode(obj.Left), + this.comparerRight.GetHashCode(obj.Right)); + } + } +} diff --git a/src/ComputeSharp.SourceGenerators/GlobalUsingDirectivesGenerator.cs b/src/ComputeSharp.Core.SourceGenerators/GlobalUsingDirectivesGenerator.cs similarity index 100% rename from src/ComputeSharp.SourceGenerators/GlobalUsingDirectivesGenerator.cs rename to src/ComputeSharp.Core.SourceGenerators/GlobalUsingDirectivesGenerator.cs diff --git a/src/ComputeSharp.SourceGenerators/Helpers/HashCode.cs b/src/ComputeSharp.Core.SourceGenerators/Helpers/HashCode.cs similarity index 100% rename from src/ComputeSharp.SourceGenerators/Helpers/HashCode.cs rename to src/ComputeSharp.Core.SourceGenerators/Helpers/HashCode.cs diff --git a/src/ComputeSharp.Core.SourceGenerators/Models/HierarchyInfo.cs b/src/ComputeSharp.Core.SourceGenerators/Models/HierarchyInfo.cs new file mode 100644 index 00000000..9afbe270 --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/Models/HierarchyInfo.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using ComputeSharp.Core.SourceGenerators.Extensions; +using Microsoft.CodeAnalysis; +using static Microsoft.CodeAnalysis.SymbolDisplayTypeQualificationStyle; + +namespace ComputeSharp.Core.SourceGenerators.Models; + +/// +/// A model describing the hierarchy info for a specific type. +/// +/// The filename hint for the current type. +/// The metadata name for the current type. +/// Gets the namespace for the current type. +/// Gets the sequence of type definitions containing the current type. +internal sealed record HierarchyInfo(string FilenameHint, string MetadataName, string Namespace, ImmutableArray Names) +{ + /// + /// Creates a new instance from a given . + /// + /// The input instance to gather info for. + /// A instance describing . + public static HierarchyInfo From(INamedTypeSymbol typeSymbol) + { + ImmutableArray.Builder names = ImmutableArray.CreateBuilder(); + + for (INamedTypeSymbol? parent = typeSymbol; + parent is not null; + parent = parent.ContainingType) + { + names.Add(parent.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat)); + } + + return new( + typeSymbol.GetGeneratedFileName(), + typeSymbol.MetadataName, + typeSymbol.ContainingNamespace.ToDisplayString(new(typeQualificationStyle: NameAndContainingTypesAndNamespaces)), + names.ToImmutable()); + } + + /// + /// An implementation for . + /// + public sealed class Comparer : IEqualityComparer + { + /// + /// The singleton instance. + /// + public static Comparer Default { get; } = new(); + + /// + public bool Equals(HierarchyInfo? x, HierarchyInfo? y) + { + if (x is null && y is null) + { + return true; + } + + if (x is null || y is null) + { + return false; + } + + if (ReferenceEquals(x, y)) + { + return true; + } + + return + x.FilenameHint == y.FilenameHint && + x.MetadataName == y.MetadataName && + x.Namespace == y.Namespace && + x.Names.SequenceEqual(y.Names); + } + + /// + public int GetHashCode(HierarchyInfo obj) + { + HashCode hashCode = default; + + hashCode.Add(obj.FilenameHint); + hashCode.Add(obj.MetadataName); + hashCode.Add(obj.Namespace); + hashCode.AddRange(obj.Names); + + return hashCode.ToHashCode(); + } + } +} diff --git a/src/ComputeSharp.Core.SourceGenerators/Models/ParameterInfo.cs b/src/ComputeSharp.Core.SourceGenerators/Models/ParameterInfo.cs new file mode 100644 index 00000000..ff276e79 --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/Models/ParameterInfo.cs @@ -0,0 +1,8 @@ +namespace ComputeSharp.Core.SourceGenerators.Models; + +/// +/// A model describing info on a constructor parameter. +/// +/// The fully qualified type name. +/// The parameter name. +internal sealed record ParameterInfo(string Type, string Name); diff --git a/src/ComputeSharp.Core.SourceGenerators/System.Runtime.CompilerServices/IsExternalInit.cs b/src/ComputeSharp.Core.SourceGenerators/System.Runtime.CompilerServices/IsExternalInit.cs new file mode 100644 index 00000000..a914bf06 --- /dev/null +++ b/src/ComputeSharp.Core.SourceGenerators/System.Runtime.CompilerServices/IsExternalInit.cs @@ -0,0 +1,12 @@ +using System.ComponentModel; + +namespace System.Runtime.CompilerServices; + +/// +/// Reserved to be used by the compiler for tracking metadata. +/// This class should not be used by developers in source code. +/// +[EditorBrowsable(EditorBrowsableState.Never)] +internal static class IsExternalInit +{ +} diff --git a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj index e6dea1b0..1b5683bb 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj +++ b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj @@ -11,11 +11,12 @@ $(DefineConstants);SOURCE_GENERATOR - + + + + @@ -91,12 +92,6 @@ - - - - - - diff --git a/tests/ComputeSharp.Tests.SourceGenerators/AutoConstructorGeneratorTests.cs b/tests/ComputeSharp.Tests.SourceGenerators/AutoConstructorGeneratorTests.cs index db4eb6c6..016d565d 100644 --- a/tests/ComputeSharp.Tests.SourceGenerators/AutoConstructorGeneratorTests.cs +++ b/tests/ComputeSharp.Tests.SourceGenerators/AutoConstructorGeneratorTests.cs @@ -53,7 +53,7 @@ public class AutoConstructorGeneratorTests {{ partial struct Test {{ - [global::System.CodeDom.Compiler.GeneratedCode(""ComputeSharp.SourceGenerators.AutoConstructorGenerator"", ""{typeof(AutoConstructorGenerator).Assembly.GetName().Version}"")] + [global::System.CodeDom.Compiler.GeneratedCode(""ComputeSharp.Core.SourceGenerators.AutoConstructorGenerator"", ""{typeof(AutoConstructorGenerator).Assembly.GetName().Version}"")] [global::System.Diagnostics.DebuggerNonUserCode] [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public Test(float a, global::System.Numerics.Vector2 b, global::ComputeSharp.ReadWriteBuffer c, global::ComputeSharp.ReadWriteBuffer d)