Browse Source

Get rid of ICSharpCode.Decompiler.Generators.Attributes in favour of EmbeddedAttribute

ast-source-generator
Siegfried Pammer 3 days ago
parent
commit
19cac08535
  1. 1
      Directory.Packages.props
  2. 13
      ICSharpCode.Decompiler.Generators.Attributes/DecompilerAstNodeAttribute.cs
  3. 7
      ICSharpCode.Decompiler.Generators.Attributes/ICSharpCode.Decompiler.Generators.Attributes.csproj
  4. 34
      ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs
  5. 8
      ICSharpCode.Decompiler.Generators/GeneratorAttributes.cs
  6. 13
      ICSharpCode.Decompiler.Generators/ICSharpCode.Decompiler.Generators.csproj
  7. 3
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  8. 6
      ILSpy.sln

1
Directory.Packages.props

@ -14,6 +14,7 @@
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageVersion Include="McMaster.Extensions.Hosting.CommandLine" Version="4.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.14.0" />

13
ICSharpCode.Decompiler.Generators.Attributes/DecompilerAstNodeAttribute.cs

@ -1,13 +0,0 @@
using System;
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
public sealed class DecompilerAstNodeAttribute : Attribute
{
public DecompilerAstNodeAttribute(bool hasNullNode = false, bool hasPatternPlaceholder = false) { }
}
public sealed class ExcludeFromMatchAttribute : Attribute
{
}
}

7
ICSharpCode.Decompiler.Generators.Attributes/ICSharpCode.Decompiler.Generators.Attributes.csproj

@ -1,7 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>

34
ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs

@ -2,8 +2,6 @@
using System.Collections.Immutable;
using System.Text;
using ICSharpCode.Decompiler.CSharp.Syntax;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@ -41,7 +39,7 @@ internal class DecompilerSyntaxTreeGenerator : IIncrementalGenerator
{
if (m is not IPropertySymbol property || property.IsIndexer || property.IsOverride)
continue;
if (property.GetAttributes().Any(a => a.AttributeClass?.Name == nameof(ExcludeFromMatchAttribute)))
if (property.GetAttributes().Any(a => a.AttributeClass?.Name == "ExcludeFromMatchAttribute"))
continue;
if (property.Type.MetadataName is "CSharpTokenNode" or "TextLocation")
continue;
@ -264,7 +262,7 @@ internal class DecompilerSyntaxTreeGenerator : IIncrementalGenerator
context.AddSource(source.NodeName + ".g.cs", SourceText.From(builder.ToString(), Encoding.UTF8));
}
private void WriteVisitors(SourceProductionContext context, ImmutableArray<AstNodeAdditions> source)
void WriteVisitors(SourceProductionContext context, ImmutableArray<AstNodeAdditions> source)
{
var builder = new StringBuilder();
@ -318,6 +316,34 @@ internal class DecompilerSyntaxTreeGenerator : IIncrementalGenerator
var visitorMembers = astNodeAdditions.Collect();
context
.RegisterPostInitializationOutput(i => i.AddSource("DecompilerSyntaxTreeGeneratorAttributes.g.cs", @"
using System;
namespace Microsoft.CodeAnalysis
{
internal sealed partial class EmbeddedAttribute : global::System.Attribute
{
}
}
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
sealed class DecompilerAstNodeAttribute : global::System.Attribute
{
public DecompilerAstNodeAttribute(bool hasNullNode = false, bool hasPatternPlaceholder = false) { }
}
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
sealed class ExcludeFromMatchAttribute : global::System.Attribute
{
}
}
"));
context.RegisterSourceOutput(astNodeAdditions, WriteGeneratedMembers);
context.RegisterSourceOutput(visitorMembers, WriteVisitors);
}

8
ICSharpCode.Decompiler.Generators/GeneratorAttributes.cs

@ -1,8 +0,0 @@
using System;
namespace ICSharpCode.Decompiler.CSharp.Syntax;
public class DecompilerAstNodeAttribute(bool hasNullNode) : Attribute
{
public bool HasNullNode { get; } = hasNullNode;
}

13
ICSharpCode.Decompiler.Generators/ICSharpCode.Decompiler.Generators.csproj

@ -8,18 +8,9 @@
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup>
<RoslynVersion>4.8.0</RoslynVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.Decompiler.Generators.Attributes\ICSharpCode.Decompiler.Generators.Attributes.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common" VersionOverride="$(RoslynVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" VersionOverride="$(RoslynVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" VersionOverride="$(RoslynVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>
</Project>

3
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -28,7 +28,7 @@
<GenerateAssemblyInformationalVersionAttribute>False</GenerateAssemblyInformationalVersionAttribute>
<EnableDefaultItems>false</EnableDefaultItems>
<LangVersion>preview</LangVersion>
<LangVersion>13</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>
@ -101,7 +101,6 @@
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.Decompiler.Generators\ICSharpCode.Decompiler.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\ICSharpCode.Decompiler.Generators.Attributes\ICSharpCode.Decompiler.Generators.Attributes.csproj" OutputItemType="Analyzer" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>

6
ILSpy.sln

@ -46,8 +46,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.Generators", "ICSharpCode.Decompiler.Generators\ICSharpCode.Decompiler.Generators.csproj", "{0792B524-622B-4B9D-8027-3531ED6A42EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Decompiler.Generators.Attributes", "ICSharpCode.Decompiler.Generators.Attributes\ICSharpCode.Decompiler.Generators.Attributes.csproj", "{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -110,10 +108,6 @@ Global
{0792B524-622B-4B9D-8027-3531ED6A42EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0792B524-622B-4B9D-8027-3531ED6A42EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0792B524-622B-4B9D-8027-3531ED6A42EB}.Release|Any CPU.Build.0 = Release|Any CPU
{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save