Skip to content

Commit 19cac08

Browse files
Get rid of ICSharpCode.Decompiler.Generators.Attributes in favour of EmbeddedAttribute
1 parent 0541e53 commit 19cac08

File tree

8 files changed

+34
-51
lines changed

8 files changed

+34
-51
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
1515
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
1616
<PackageVersion Include="McMaster.Extensions.Hosting.CommandLine" Version="4.1.1" />
17+
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.14.0" />
1718
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />
1819
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
1920
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.14.0" />

ICSharpCode.Decompiler.Generators.Attributes/DecompilerAstNodeAttribute.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

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

Lines changed: 0 additions & 7 deletions
This file was deleted.

ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using System.Collections.Immutable;
33
using System.Text;
44

5-
using ICSharpCode.Decompiler.CSharp.Syntax;
6-
75
using Microsoft.CodeAnalysis;
86
using Microsoft.CodeAnalysis.CSharp;
97
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -41,7 +39,7 @@ string s when s.Contains("AstType") => (s.Replace("AstType", "Type"), s),
4139
{
4240
if (m is not IPropertySymbol property || property.IsIndexer || property.IsOverride)
4341
continue;
44-
if (property.GetAttributes().Any(a => a.AttributeClass?.Name == nameof(ExcludeFromMatchAttribute)))
42+
if (property.GetAttributes().Any(a => a.AttributeClass?.Name == "ExcludeFromMatchAttribute"))
4543
continue;
4644
if (property.Type.MetadataName is "CSharpTokenNode" or "TextLocation")
4745
continue;
@@ -264,7 +262,7 @@ public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
264262
context.AddSource(source.NodeName + ".g.cs", SourceText.From(builder.ToString(), Encoding.UTF8));
265263
}
266264

267-
private void WriteVisitors(SourceProductionContext context, ImmutableArray<AstNodeAdditions> source)
265+
void WriteVisitors(SourceProductionContext context, ImmutableArray<AstNodeAdditions> source)
268266
{
269267
var builder = new StringBuilder();
270268

@@ -318,6 +316,34 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
318316

319317
var visitorMembers = astNodeAdditions.Collect();
320318

319+
context
320+
.RegisterPostInitializationOutput(i => i.AddSource("DecompilerSyntaxTreeGeneratorAttributes.g.cs", @"
321+
322+
using System;
323+
324+
namespace Microsoft.CodeAnalysis
325+
{
326+
internal sealed partial class EmbeddedAttribute : global::System.Attribute
327+
{
328+
}
329+
}
330+
331+
namespace ICSharpCode.Decompiler.CSharp.Syntax
332+
{
333+
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
334+
sealed class DecompilerAstNodeAttribute : global::System.Attribute
335+
{
336+
public DecompilerAstNodeAttribute(bool hasNullNode = false, bool hasPatternPlaceholder = false) { }
337+
}
338+
339+
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
340+
sealed class ExcludeFromMatchAttribute : global::System.Attribute
341+
{
342+
}
343+
}
344+
345+
"));
346+
321347
context.RegisterSourceOutput(astNodeAdditions, WriteGeneratedMembers);
322348
context.RegisterSourceOutput(visitorMembers, WriteVisitors);
323349
}

ICSharpCode.Decompiler.Generators/GeneratorAttributes.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,9 @@
88
<LangVersion>12</LangVersion>
99
</PropertyGroup>
1010

11-
<PropertyGroup>
12-
<RoslynVersion>4.8.0</RoslynVersion>
13-
</PropertyGroup>
14-
15-
<ItemGroup>
16-
<ProjectReference Include="..\ICSharpCode.Decompiler.Generators.Attributes\ICSharpCode.Decompiler.Generators.Attributes.csproj" />
17-
</ItemGroup>
18-
1911
<ItemGroup>
20-
<PackageReference Include="Microsoft.CodeAnalysis.Common" VersionOverride="$(RoslynVersion)" />
21-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" VersionOverride="$(RoslynVersion)" />
22-
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" VersionOverride="$(RoslynVersion)" />
12+
<PackageReference Include="Microsoft.CodeAnalysis" />
13+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
2314
</ItemGroup>
2415

2516
</Project>

ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<GenerateAssemblyInformationalVersionAttribute>False</GenerateAssemblyInformationalVersionAttribute>
2929

3030
<EnableDefaultItems>false</EnableDefaultItems>
31-
<LangVersion>preview</LangVersion>
31+
<LangVersion>13</LangVersion>
3232
<GenerateDocumentationFile>true</GenerateDocumentationFile>
3333
<SignAssembly>True</SignAssembly>
3434
<AssemblyOriginatorKeyFile>ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>
@@ -101,7 +101,6 @@
101101

102102
<ItemGroup>
103103
<ProjectReference Include="..\ICSharpCode.Decompiler.Generators\ICSharpCode.Decompiler.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
104-
<ProjectReference Include="..\ICSharpCode.Decompiler.Generators.Attributes\ICSharpCode.Decompiler.Generators.Attributes.csproj" OutputItemType="Analyzer" PrivateAssets="all" />
105104
</ItemGroup>
106105

107106
<ItemGroup>

ILSpy.sln

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
4646
EndProject
4747
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.Generators", "ICSharpCode.Decompiler.Generators\ICSharpCode.Decompiler.Generators.csproj", "{0792B524-622B-4B9D-8027-3531ED6A42EB}"
4848
EndProject
49-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Decompiler.Generators.Attributes", "ICSharpCode.Decompiler.Generators.Attributes\ICSharpCode.Decompiler.Generators.Attributes.csproj", "{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}"
50-
EndProject
5149
Global
5250
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5351
Debug|Any CPU = Debug|Any CPU
@@ -110,10 +108,6 @@ Global
110108
{0792B524-622B-4B9D-8027-3531ED6A42EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
111109
{0792B524-622B-4B9D-8027-3531ED6A42EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
112110
{0792B524-622B-4B9D-8027-3531ED6A42EB}.Release|Any CPU.Build.0 = Release|Any CPU
113-
{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
114-
{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
115-
{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
116-
{02FE14EC-EEA7-4902-BCBF-0F95FB90C9B3}.Release|Any CPU.Build.0 = Release|Any CPU
117111
EndGlobalSection
118112
GlobalSection(SolutionProperties) = preSolution
119113
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)