Merge pull request #378 from Sergio0694/dev/roslyn-430
Bump Roslyn to 4.4 and use ForAttributeWithMetadataName
このコミットが含まれているのは:
13ファイル変更
+35
-41
検索条件に一致するファイルはありません
@@ -21,17 +21,16 @@ public sealed class AutoConstructorGenerator : IIncrementalGenerator
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
{
|
||||
// Get all declared struct symbols with the [AutoConstructor] attribute
|
||||
IncrementalValuesProvider<INamedTypeSymbol> structDeclarations =
|
||||
IncrementalValuesProvider<INamedTypeSymbol> structSymbols =
|
||||
context.SyntaxProvider
|
||||
.CreateSyntaxProvider(
|
||||
.ForAttributeWithMetadataName(
|
||||
typeof(AutoConstructorAttribute).FullName,
|
||||
static (node, token) => node is StructDeclarationSyntax structDeclaration,
|
||||
static (context, token) => (INamedTypeSymbol?)context.SemanticModel.GetDeclaredSymbol(context.Node, token))
|
||||
.Where(static symbol => symbol is not null &&
|
||||
symbol.GetAttributes().Any(static a => a.AttributeClass?.ToDisplayString() == typeof(AutoConstructorAttribute).FullName))!;
|
||||
static (context, token) => (INamedTypeSymbol)context.TargetSymbol);
|
||||
|
||||
// Get the type hierarchy and fields info
|
||||
IncrementalValuesProvider<(HierarchyInfo Left, ConstructorInfo Right)> constructorInfo =
|
||||
structDeclarations
|
||||
structSymbols
|
||||
.Select(static (item, token) => (Hierarchy: HierarchyInfo.From(item), Info: Ctor.GetData(item)))
|
||||
.Where(static item => !item.Info.Parameters.IsEmpty)
|
||||
.WithComparers(HierarchyInfo.Comparer.Default, ConstructorInfo.Comparer.Default);
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" PrivateAssets="all" Pack="false" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0-1.final" PrivateAssets="all" Pack="false" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!-- Remove the analyzer if using Roslyn < 4.2 (ComputeSharp.Core's generators require Roslyn 4.2) -->
|
||||
<!-- Remove the analyzer if using Roslyn < 4.4 (ComputeSharp.Core's generators require Roslyn 4.4) -->
|
||||
<Target Name="_ComputeSharpCoreRemoveAnalyzersForRoslyn3"
|
||||
Condition="'$(CSharpCoreTargetsPath)' != ''"
|
||||
AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"
|
||||
@@ -27,10 +27,10 @@
|
||||
<ComputeSharpCoreCurrentCompilerVersion>@(ComputeSharpCoreCurrentCompilerAssemblyIdentity->'%(Version)')</ComputeSharpCoreCurrentCompilerVersion>
|
||||
|
||||
<!-- The CurrentCompilerVersionIsNotNewEnough property can now be defined based on the Roslyn assembly version -->
|
||||
<ComputeSharpCoreCurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(ComputeSharpCoreCurrentCompilerVersion), 4.2))">true</ComputeSharpCoreCurrentCompilerVersionIsNotNewEnough>
|
||||
<ComputeSharpCoreCurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(ComputeSharpCoreCurrentCompilerVersion), 4.4))">true</ComputeSharpCoreCurrentCompilerVersionIsNotNewEnough>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- If the Roslyn version is < 4.2, disable the source generators -->
|
||||
<!-- If the Roslyn version is < 4.4, disable the source generators -->
|
||||
<ItemGroup Condition ="'$(ComputeSharpCoreCurrentCompilerVersionIsNotNewEnough)' == 'true'">
|
||||
<Analyzer Remove="@(_ComputeSharpCoreAnalyzer)"/>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" PrivateAssets="all" Pack="false" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0-1.final" PrivateAssets="all" Pack="false" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -21,18 +21,16 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
{
|
||||
// Get all method declarations with the [D2DPixelShaderSource] attribute
|
||||
IncrementalValuesProvider<(MethodDeclarationSyntax Syntax, IMethodSymbol Symbol)> methodSymbols =
|
||||
IncrementalValuesProvider<(MethodDeclarationSyntax Syntax, IMethodSymbol Symbol)> methodDeclarationsAndSymbols =
|
||||
context.SyntaxProvider
|
||||
.CreateSyntaxProvider(
|
||||
static (node, _) => node is MethodDeclarationSyntax { Parent: ClassDeclarationSyntax, AttributeLists.Count: > 0 },
|
||||
static (context, _) => (
|
||||
(MethodDeclarationSyntax)context.Node,
|
||||
Symbol: (IMethodSymbol)context.SemanticModel.GetDeclaredSymbol(context.Node)!))
|
||||
.Where(static pair => pair.Symbol.HasAttributeWithFullyQualifiedName("ComputeSharp.D2D1.D2DPixelShaderSourceAttribute"));
|
||||
.ForAttributeWithMetadataName(
|
||||
typeof(D2DPixelShaderSourceAttribute).FullName,
|
||||
static (node, token) => node is MethodDeclarationSyntax,
|
||||
static (context, token) => ((MethodDeclarationSyntax)context.TargetNode, (IMethodSymbol)context.TargetSymbol));
|
||||
|
||||
// Gather info for all annotated methods
|
||||
IncrementalValuesProvider<(HierarchyInfo Hierarchy, HlslShaderMethodSourceInfo Source, ImmutableArray<Diagnostic> Diagnostics)> shaderInfoWithErrors =
|
||||
methodSymbols
|
||||
methodDeclarationsAndSymbols
|
||||
.Select(static (item, _) =>
|
||||
{
|
||||
ImmutableArray<Diagnostic>.Builder diagnostics = ImmutableArray.CreateBuilder<Diagnostic>();
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
|
||||
#pragma warning disable CS0618, RS1024
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!-- Remove the analyzer if using Roslyn < 4.2 (ComputeSharp.D2D1's generators require Roslyn 4.2) -->
|
||||
<!-- Remove the analyzer if using Roslyn < 4.4 (ComputeSharp.D2D1's generators require Roslyn 4.4) -->
|
||||
<Target Name="_ComputeSharpD2D1RemoveAnalyzersForRoslyn3"
|
||||
Condition="'$(CSharpCoreTargetsPath)' != ''"
|
||||
AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"
|
||||
@@ -27,10 +27,10 @@
|
||||
<ComputeSharpD2D1CurrentCompilerVersion>@(ComputeSharpD2D1CurrentCompilerAssemblyIdentity->'%(Version)')</ComputeSharpD2D1CurrentCompilerVersion>
|
||||
|
||||
<!-- The CurrentCompilerVersionIsNotNewEnough property can now be defined based on the Roslyn assembly version -->
|
||||
<ComputeSharpD2D1CurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(ComputeSharpD2D1CurrentCompilerVersion), 4.2))">true</ComputeSharpD2D1CurrentCompilerVersionIsNotNewEnough>
|
||||
<ComputeSharpD2D1CurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(ComputeSharpD2D1CurrentCompilerVersion), 4.4))">true</ComputeSharpD2D1CurrentCompilerVersionIsNotNewEnough>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- If the Roslyn version is < 4.2, disable the source generators -->
|
||||
<!-- If the Roslyn version is < 4.4, disable the source generators -->
|
||||
<ItemGroup Condition ="'$(ComputeSharpD2D1CurrentCompilerVersionIsNotNewEnough)' == 'true'">
|
||||
<Analyzer Remove="@(_ComputeSharpD2D1Analyzer)"/>
|
||||
</ItemGroup>
|
||||
@@ -38,7 +38,7 @@
|
||||
<!-- If the source generators are disabled, also emit an error. This would've been produced by MSBuild itself as well, but
|
||||
emitting this manually lets us customize the message to inform developers as to why exactly the generators have been
|
||||
disabled, and that ComputeSharp will not work at all unless a more up to date IDE or compiler version are used. -->
|
||||
<Error Condition ="'$(ComputeSharpD2D1CurrentCompilerVersionIsNotNewEnough)' == 'true'" Text="The ComputeSharp.D2D1 source generators have been disabled on the current configuration, as they need Roslyn 4.2 in order to work. ComputeSharp.D2D1 requires the source generators to run in order to process shaders, so the library cannot be used without a more up to date IDE (eg. VS2022) or .NET SDK version."/>
|
||||
<Error Condition ="'$(ComputeSharpD2D1CurrentCompilerVersionIsNotNewEnough)' == 'true'" Text="The ComputeSharp.D2D1 source generators have been disabled on the current configuration, as they need Roslyn 4.4 in order to work. ComputeSharp.D2D1 requires the source generators to run in order to process shaders, so the library cannot be used without a more up to date IDE (eg. VS2022) or .NET SDK version."/>
|
||||
</Target>
|
||||
|
||||
<!-- Remove the analyzer if Roslyn is missing -->
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" PrivateAssets="all" Pack="false" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0-1.final" PrivateAssets="all" Pack="false" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
|
||||
#pragma warning disable CS0618, RS1024
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
|
||||
#pragma warning disable CS0618, RS1024
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using static ComputeSharp.SourceGenerators.Helpers.SyntaxFactoryHelper;
|
||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
|
||||
#pragma warning disable CS0618, RS1024
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
@@ -29,19 +29,16 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
{
|
||||
// Get all declared methods (including global function declarations) with the [ShaderMethod] attribute
|
||||
IncrementalValuesProvider<(CSharpSyntaxNode Syntax, IMethodSymbol Symbol)> structDeclarations =
|
||||
IncrementalValuesProvider<(MethodDeclarationSyntax Syntax, IMethodSymbol Symbol)> methodDeclarationsAndSymbols =
|
||||
context.SyntaxProvider
|
||||
.CreateSyntaxProvider(
|
||||
.ForAttributeWithMetadataName(
|
||||
typeof(ShaderMethodAttribute).FullName,
|
||||
static (node, token) => node is MethodDeclarationSyntax { AttributeLists.Count: > 0 } or LocalFunctionStatementSyntax { Parent: GlobalStatementSyntax { Parent: CompilationUnitSyntax }, AttributeLists.Count: > 0 },
|
||||
static (context, token) => (
|
||||
Syntax: (CSharpSyntaxNode)context.Node,
|
||||
Symbol: (IMethodSymbol?)context.SemanticModel.GetDeclaredSymbol(context.Node, token)))
|
||||
.Where(static item => item.Symbol is not null &&
|
||||
item.Symbol.GetAttributes().Any(static a => a.AttributeClass?.ToDisplayString() == typeof(ShaderMethodAttribute).FullName))!;
|
||||
static (context, token) => ((MethodDeclarationSyntax)context.TargetNode, (IMethodSymbol)context.TargetSymbol));
|
||||
|
||||
// Get the source info for each method
|
||||
IncrementalValuesProvider<Result<HlslMethodSourceInfo>> methodSourceInfoWithErrors =
|
||||
structDeclarations
|
||||
methodDeclarationsAndSymbols
|
||||
.Combine(context.CompilationProvider)
|
||||
.Select(static (item, token) =>
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!-- Remove the analyzer if using Roslyn < 4.2 (ComputeSharp's generators require Roslyn 4.2) -->
|
||||
<!-- Remove the analyzer if using Roslyn < 4.4 (ComputeSharp's generators require Roslyn 4.4) -->
|
||||
<Target Name="_ComputeSharpRemoveAnalyzersForRoslyn3"
|
||||
Condition="'$(CSharpCoreTargetsPath)' != ''"
|
||||
AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"
|
||||
@@ -27,10 +27,10 @@
|
||||
<ComputeSharpCurrentCompilerVersion>@(ComputeSharpCurrentCompilerAssemblyIdentity->'%(Version)')</ComputeSharpCurrentCompilerVersion>
|
||||
|
||||
<!-- The CurrentCompilerVersionIsNotNewEnough property can now be defined based on the Roslyn assembly version -->
|
||||
<ComputeSharpCurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(ComputeSharpCurrentCompilerVersion), 4.2))">true</ComputeSharpCurrentCompilerVersionIsNotNewEnough>
|
||||
<ComputeSharpCurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(ComputeSharpCurrentCompilerVersion), 4.4))">true</ComputeSharpCurrentCompilerVersionIsNotNewEnough>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- If the Roslyn version is < 4.2, disable the source generators -->
|
||||
<!-- If the Roslyn version is < 4.4, disable the source generators -->
|
||||
<ItemGroup Condition ="'$(ComputeSharpCurrentCompilerVersionIsNotNewEnough)' == 'true'">
|
||||
<Analyzer Remove="@(_ComputeSharpAnalyzer)"/>
|
||||
</ItemGroup>
|
||||
@@ -38,7 +38,7 @@
|
||||
<!-- If the source generators are disabled, also emit an error. This would've been produced by MSBuild itself as well, but
|
||||
emitting this manually lets us customize the message to inform developers as to why exactly the generators have been
|
||||
disabled, and that ComputeSharp will not work at all unless a more up to date IDE or compiler version are used. -->
|
||||
<Error Condition ="'$(ComputeSharpCurrentCompilerVersionIsNotNewEnough)' == 'true'" Text="The ComputeSharp source generators have been disabled on the current configuration, as they need Roslyn 4.2 in order to work. ComputeSharp requires the source generators to run in order to process shaders, so the library cannot be used without a more up to date IDE (eg. VS2022) or .NET SDK version."/>
|
||||
<Error Condition ="'$(ComputeSharpCurrentCompilerVersionIsNotNewEnough)' == 'true'" Text="The ComputeSharp source generators have been disabled on the current configuration, as they need Roslyn 4.4 in order to work. ComputeSharp requires the source generators to run in order to process shaders, so the library cannot be used without a more up to date IDE (eg. VS2022) or .NET SDK version."/>
|
||||
</Target>
|
||||
|
||||
<!-- Remove the analyzer if Roslyn is missing -->
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0-1.final" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする