Browse Source

Add the AST source generator for the C# syntax tree

Introduce a Roslyn source generator that emits the visitor boilerplate for
the C# AST from [DecompilerAstNode]-tagged node declarations: the
IAstVisitor interface, the AcceptVisitor overloads, the pattern-placeholder
nodes, and the initial DoMatch support. AccessorKind lets an accessor's
keyword be chosen independently of its role, an early step toward shedding
the NRefactory role model.
pull/3807/head
Siegfried Pammer 1 year ago committed by Siegfried Pammer
parent
commit
c174e4d6b1
  1. 1
      Directory.Packages.props
  2. 383
      ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs
  3. 21
      ICSharpCode.Decompiler.Generators/ICSharpCode.Decompiler.Generators.csproj
  4. 3
      ICSharpCode.Decompiler.Generators/IsExternalInit.cs
  5. 17
      ICSharpCode.Decompiler.Generators/NuGet.config
  6. 32
      ICSharpCode.Decompiler.Generators/RoslynHelpers.cs
  7. 125
      ICSharpCode.Decompiler.Generators/TreeTraversal.cs
  8. 120
      ICSharpCode.Decompiler.Generators/packages.lock.json
  9. 17
      ICSharpCode.Decompiler.Tests/packages.lock.json
  10. 1
      ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs
  11. 3
      ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs
  12. 3
      ICSharpCode.Decompiler/CSharp/Syntax/CSharpModifierToken.cs
  13. 3
      ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs
  14. 6
      ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs
  15. 3
      ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs
  16. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs
  17. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousTypeCreateExpression.cs
  18. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayCreateExpression.cs
  19. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs
  20. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AsExpression.cs
  21. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs
  22. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BaseReferenceExpression.cs
  23. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs
  24. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CastExpression.cs
  25. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CheckedExpression.cs
  26. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ConditionalExpression.cs
  27. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DeclarationExpression.cs
  28. 30
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DecompilerAstNodeAttribute.cs
  29. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DefaultValueExpression.cs
  30. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs
  31. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ErrorExpression.cs
  32. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs
  33. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IdentifierExpression.cs
  34. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IndexerExpression.cs
  35. 12
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs
  36. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InvocationExpression.cs
  37. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IsExpression.cs
  38. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs
  39. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/MemberReferenceExpression.cs
  40. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedArgumentExpression.cs
  41. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedExpression.cs
  42. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NullReferenceExpression.cs
  43. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ObjectCreateExpression.cs
  44. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/OutVarDeclarationExpression.cs
  45. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ParenthesizedExpression.cs
  46. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PointerReferenceExpression.cs
  47. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs
  48. 30
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs
  49. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/RecursivePatternExpression.cs
  50. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/SizeOfExpression.cs
  51. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/StackAllocExpression.cs
  52. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/SwitchExpression.cs
  53. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ThisReferenceExpression.cs
  54. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ThrowExpression.cs
  55. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TupleExpression.cs
  56. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TypeOfExpression.cs
  57. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TypeReferenceExpression.cs
  58. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs
  59. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UncheckedExpression.cs
  60. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UndocumentedExpression.cs
  61. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/WithInitializerExpression.cs
  62. 3
      ICSharpCode.Decompiler/CSharp/Syntax/FunctionPointerAstType.cs
  63. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Attribute.cs
  64. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/AttributeSection.cs
  65. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Comment.cs
  66. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Constraint.cs
  67. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/DelegateDeclaration.cs
  68. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/ExternAliasDeclaration.cs
  69. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/NamespaceDeclaration.cs
  70. 9
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/PreProcessorDirective.cs
  71. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs
  72. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs
  73. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/UsingAliasDeclaration.cs
  74. 3
      ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/UsingDeclaration.cs
  75. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs
  76. 3
      ICSharpCode.Decompiler/CSharp/Syntax/InvocationAstType.cs
  77. 3
      ICSharpCode.Decompiler/CSharp/Syntax/MemberType.cs
  78. 3
      ICSharpCode.Decompiler/CSharp/Syntax/PrimitiveType.cs
  79. 3
      ICSharpCode.Decompiler/CSharp/Syntax/SimpleType.cs
  80. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/BlockStatement.cs
  81. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/BreakStatement.cs
  82. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/CheckedStatement.cs
  83. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ContinueStatement.cs
  84. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/DoWhileStatement.cs
  85. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/EmptyStatement.cs
  86. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ExpressionStatement.cs
  87. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/FixedStatement.cs
  88. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ForStatement.cs
  89. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ForeachStatement.cs
  90. 9
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/GotoStatement.cs
  91. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/IfElseStatement.cs
  92. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/LabelStatement.cs
  93. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/LocalFunctionDeclarationStatement.cs
  94. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/LockStatement.cs
  95. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ReturnStatement.cs
  96. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs
  97. 9
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/SwitchStatement.cs
  98. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/ThrowStatement.cs
  99. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs
  100. 3
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/UncheckedStatement.cs
  101. Some files were not shown because too many files have changed in this diff Show More

1
Directory.Packages.props

@ -40,6 +40,7 @@
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" /> <PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="5.1.0" /> <PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="5.1.0" />
<PackageVersion Include="McMaster.Extensions.Hosting.CommandLine" Version="5.1.0" /> <PackageVersion Include="McMaster.Extensions.Hosting.CommandLine" Version="5.1.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="$(RoslynVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(RoslynVersion)" /> <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(RoslynVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="$(RoslynVersion)" /> <PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="$(RoslynVersion)" />
<PackageVersion Include="Microsoft.DiaSymReader.Converter.Xml" Version="1.1.0-beta2-22171-02" /> <PackageVersion Include="Microsoft.DiaSymReader.Converter.Xml" Version="1.1.0-beta2-22171-02" />

383
ICSharpCode.Decompiler.Generators/DecompilerSyntaxTreeGenerator.cs

@ -0,0 +1,383 @@
// Copyright (c) 2026 Siegfried Pammer
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections;
using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace ICSharpCode.Decompiler.Generators;
[Generator]
internal class DecompilerSyntaxTreeGenerator : IIncrementalGenerator
{
record AstNodeAdditions(string NodeName, bool NeedsAcceptImpls, bool NeedsVisitor, bool NeedsNullNode, bool NeedsPatternPlaceholder, int NullNodeBaseCtorParamCount, bool IsTypeNode, string VisitMethodName, string VisitMethodParamType, EquatableArray<(string Member, string TypeName, bool RecursiveMatch, bool MatchAny)>? MembersToMatch);
AstNodeAdditions GetAstNodeAdditions(GeneratorAttributeSyntaxContext context, CancellationToken ct)
{
var targetSymbol = (INamedTypeSymbol)context.TargetSymbol;
var attribute = context.Attributes.SingleOrDefault(ad => ad.AttributeClass?.Name == "DecompilerAstNodeAttribute")!;
var (visitMethodName, paramTypeName) = targetSymbol.Name switch {
"ErrorExpression" => ("ErrorNode", "AstNode"),
string s when s.Contains("AstType") => (s.Replace("AstType", "Type"), s),
_ => (targetSymbol.Name, targetSymbol.Name),
};
List<(string Member, string TypeName, bool RecursiveMatch, bool MatchAny)>? membersToMatch = null;
if (!targetSymbol.MemberNames.Contains("DoMatch"))
{
membersToMatch = new();
var astNodeType = (INamedTypeSymbol)context.SemanticModel.GetSpeculativeSymbolInfo(context.TargetNode.Span.Start, SyntaxFactory.ParseTypeName("AstNode"), SpeculativeBindingOption.BindAsTypeOrNamespace).Symbol!;
if (targetSymbol.BaseType!.MemberNames.Contains("MatchAttributesAndModifiers"))
membersToMatch.Add(("MatchAttributesAndModifiers", null!, false, false));
foreach (var m in targetSymbol.GetMembers())
{
if (m is not IPropertySymbol property || property.IsIndexer || property.IsOverride)
continue;
if (property.GetAttributes().Any(a => a.AttributeClass?.Name == "ExcludeFromMatchAttribute"))
continue;
if (property.Type.MetadataName is "CSharpTokenNode" or "TextLocation")
continue;
switch (property.Type)
{
case INamedTypeSymbol named when named.IsDerivedFrom(astNodeType) || named.MetadataName == "AstNodeCollection`1":
membersToMatch.Add((property.Name, named.Name, true, false));
break;
case INamedTypeSymbol { TypeKind: TypeKind.Enum } named when named.GetMembers().Any(_ => _.Name == "Any"):
membersToMatch.Add((property.Name, named.Name, false, true));
break;
default:
membersToMatch.Add((property.Name, property.Type.Name, false, false));
break;
}
}
}
return new(targetSymbol.Name, !targetSymbol.MemberNames.Contains("AcceptVisitor"),
NeedsVisitor: !targetSymbol.IsAbstract && targetSymbol.BaseType!.IsAbstract,
NeedsNullNode: (bool)attribute.ConstructorArguments[0].Value!,
NeedsPatternPlaceholder: (bool)attribute.ConstructorArguments[1].Value!,
NullNodeBaseCtorParamCount: targetSymbol.InstanceConstructors.Min(m => m.Parameters.Length),
IsTypeNode: targetSymbol.Name == "AstType" || targetSymbol.BaseType?.Name == "AstType",
visitMethodName, paramTypeName, membersToMatch?.ToEquatableArray());
}
void WriteGeneratedMembers(SourceProductionContext context, AstNodeAdditions source)
{
var builder = new StringBuilder();
builder.AppendLine("namespace ICSharpCode.Decompiler.CSharp.Syntax;");
builder.AppendLine();
if (source.NeedsPatternPlaceholder)
{
builder.AppendLine("using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;");
}
builder.AppendLine();
builder.AppendLine("#nullable enable");
builder.AppendLine();
builder.AppendLine($"partial class {source.NodeName}");
builder.AppendLine("{");
if (source.NeedsNullNode)
{
bool needsNew = source.NodeName != "AstNode";
builder.AppendLine($" {(needsNew ? "new " : "")}public static readonly {source.NodeName} Null = new Null{source.NodeName}();");
builder.AppendLine($@"
sealed class Null{source.NodeName} : {source.NodeName}
{{
public override NodeType NodeType => NodeType.Unknown;
public override bool IsNull => true;
public override void AcceptVisitor(IAstVisitor visitor)
{{
visitor.VisitNullNode(this);
}}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{{
return visitor.VisitNullNode(this);
}}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{{
return visitor.VisitNullNode(this, data);
}}
protected internal override bool DoMatch(AstNode? other, PatternMatching.Match match)
{{
return other == null || other.IsNull;
}}");
if (source.NullNodeBaseCtorParamCount > 0)
{
builder.AppendLine($@"
public Null{source.NodeName}() : base({string.Join(", ", Enumerable.Repeat("default", source.NullNodeBaseCtorParamCount))}) {{ }}");
}
builder.AppendLine($@"
}}
");
}
if (source.NeedsPatternPlaceholder)
{
builder.Append(
$@" public static implicit operator {source.NodeName}?(PatternMatching.Pattern? pattern)
{{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}}
sealed class PatternPlaceholder : {source.NodeName}, INode
{{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{{
this.child = child;
}}
public override NodeType NodeType {{
get {{ return NodeType.Pattern; }}
}}
public override void AcceptVisitor(IAstVisitor visitor)
{{
visitor.VisitPatternPlaceholder(this, child);
}}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{{
return visitor.VisitPatternPlaceholder(this, child);
}}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{{
return visitor.VisitPatternPlaceholder(this, child, data);
}}
protected internal override bool DoMatch(AstNode? other, PatternMatching.Match match)
{{
return child.DoMatch(other, match);
}}
bool PatternMatching.INode.DoMatchCollection(Role? role, PatternMatching.INode? pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}}
}}
"
);
}
if (source.NeedsAcceptImpls && source.NeedsVisitor)
{
builder.Append($@" public override void AcceptVisitor(IAstVisitor visitor)
{{
visitor.Visit{source.VisitMethodName}(this);
}}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{{
return visitor.Visit{source.VisitMethodName}(this);
}}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{{
return visitor.Visit{source.VisitMethodName}(this, data);
}}
");
}
if (source.MembersToMatch != null)
{
builder.Append($@" protected internal override bool DoMatch(AstNode? other, PatternMatching.Match match)
{{
return other is {source.NodeName} o && !o.IsNull");
foreach (var (member, typeName, recursive, hasAny) in source.MembersToMatch)
{
if (member == "MatchAttributesAndModifiers")
{
builder.Append($"\r\n\t\t\t&& this.MatchAttributesAndModifiers(o, match)");
}
else if (recursive)
{
builder.Append($"\r\n\t\t\t&& this.{member}.DoMatch(o.{member}, match)");
}
else if (hasAny)
{
builder.Append($"\r\n\t\t\t&& (this.{member} == {typeName}.Any || this.{member} == o.{member})");
}
else if (typeName == "String")
{
builder.Append($"\r\n\t\t\t&& MatchString(this.{member}, o.{member})");
}
else
{
builder.Append($"\r\n\t\t\t&& this.{member} == o.{member}");
}
}
builder.Append(@";
}
");
}
builder.AppendLine("}");
context.AddSource(source.NodeName + ".g.cs", SourceText.From(builder.ToString(), Encoding.UTF8));
}
void WriteVisitors(SourceProductionContext context, ImmutableArray<AstNodeAdditions> source)
{
var builder = new StringBuilder();
builder.AppendLine("namespace ICSharpCode.Decompiler.CSharp.Syntax;");
source = source
.Concat([new("NullNode", false, true, false, false, 0, false, "NullNode", "AstNode", null), new("PatternPlaceholder", false, true, false, false, 0, false, "PatternPlaceholder", "AstNode", null)])
.ToImmutableArray();
WriteInterface("IAstVisitor", "void", "");
WriteInterface("IAstVisitor<out S>", "S", "");
WriteInterface("IAstVisitor<in T, out S>", "S", ", T data");
context.AddSource("IAstVisitor.g.cs", SourceText.From(builder.ToString(), Encoding.UTF8));
void WriteInterface(string name, string ret, string param)
{
builder.AppendLine($"public interface {name}");
builder.AppendLine("{");
foreach (var type in source.OrderBy(t => t.VisitMethodName))
{
if (!type.NeedsVisitor)
continue;
string extParams, paramName;
if (type.VisitMethodName == "PatternPlaceholder")
{
paramName = "placeholder";
extParams = ", PatternMatching.Pattern pattern" + param;
}
else
{
paramName = char.ToLowerInvariant(type.VisitMethodName[0]) + type.VisitMethodName.Substring(1);
extParams = param;
}
builder.AppendLine($"\t{ret} Visit{type.VisitMethodName}({type.VisitMethodParamType} {paramName}{extParams});");
}
builder.AppendLine("}");
}
}
public void Initialize(IncrementalGeneratorInitializationContext context)
{
var astNodeAdditions = context.SyntaxProvider.ForAttributeWithMetadataName(
"ICSharpCode.Decompiler.CSharp.Syntax.DecompilerAstNodeAttribute",
(n, ct) => n is ClassDeclarationSyntax,
GetAstNodeAdditions);
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);
}
}
readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IEnumerable<T>
where T : IEquatable<T>
{
readonly T[] array;
public EquatableArray(T[] array)
{
this.array = array ?? throw new ArgumentNullException(nameof(array));
}
public bool Equals(EquatableArray<T> other)
{
return other.array.AsSpan().SequenceEqual(this.array);
}
public IEnumerator<T> GetEnumerator()
{
return ((IEnumerable<T>)array).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return array.GetEnumerator();
}
}
static class EquatableArrayExtensions
{
public static EquatableArray<T> ToEquatableArray<T>(this List<T> array) where T : IEquatable<T>
{
return new EquatableArray<T>(array.ToArray());
}
}

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

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<LangVersion>12</LangVersion>
<!-- Opt out of the repo's central package management for this project: a source generator must
reference a Roslyn no newer than the running compiler, but the repo's $(RoslynVersion) tracks
the (newer) preview SDK compiler. Pin to a stable lower version any supported host can load.
The stable package lives on nuget.org; the local NuGet.config reaches it past the repo-root
source mapping that otherwise routes Microsoft.CodeAnalysis.* to the dotnet-tools feed. -->
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
</ItemGroup>
</Project>

3
ICSharpCode.Decompiler.Generators/IsExternalInit.cs

@ -0,0 +1,3 @@
namespace System.Runtime.CompilerServices;
class IsExternalInit { }

17
ICSharpCode.Decompiler.Generators/NuGet.config

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- The repo-root NuGet.config maps Microsoft.CodeAnalysis.* exclusively to the dotnet-tools feed,
which carries only prerelease Roslyn builds. This source generator deliberately references a
stable Roslyn (see the csproj), which lives on nuget.org. Clearing the inherited sources and
mapping here lets this project restore that stable package; it has no other dependencies. -->
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceMapping>
<clear />
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>

32
ICSharpCode.Decompiler.Generators/RoslynHelpers.cs

@ -0,0 +1,32 @@
using Microsoft.CodeAnalysis;
namespace ICSharpCode.Decompiler.Generators;
public static class RoslynHelpers
{
public static IEnumerable<INamedTypeSymbol> GetTopLevelTypes(this IAssemblySymbol assembly)
{
foreach (var ns in TreeTraversal.PreOrder(assembly.GlobalNamespace, ns => ns.GetNamespaceMembers()))
{
foreach (var t in ns.GetTypeMembers())
{
yield return t;
}
}
}
public static bool IsDerivedFrom(this INamedTypeSymbol type, INamedTypeSymbol baseType)
{
INamedTypeSymbol? t = type;
while (t != null)
{
if (SymbolEqualityComparer.Default.Equals(t, baseType))
return true;
t = t.BaseType;
}
return false;
}
}

125
ICSharpCode.Decompiler.Generators/TreeTraversal.cs

@ -0,0 +1,125 @@
#nullable enable
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace ICSharpCode.Decompiler.Generators;
/// <summary>
/// Static helper methods for traversing trees.
/// </summary>
internal static class TreeTraversal
{
/// <summary>
/// Converts a tree data structure into a flat list by traversing it in pre-order.
/// </summary>
/// <param name="root">The root element of the tree.</param>
/// <param name="recursion">The function that gets the children of an element.</param>
/// <returns>Iterator that enumerates the tree structure in pre-order.</returns>
public static IEnumerable<T> PreOrder<T>(T root, Func<T, IEnumerable<T>?> recursion)
{
return PreOrder(new T[] { root }, recursion);
}
/// <summary>
/// Converts a tree data structure into a flat list by traversing it in pre-order.
/// </summary>
/// <param name="input">The root elements of the forest.</param>
/// <param name="recursion">The function that gets the children of an element.</param>
/// <returns>Iterator that enumerates the tree structure in pre-order.</returns>
public static IEnumerable<T> PreOrder<T>(IEnumerable<T> input, Func<T, IEnumerable<T>?> recursion)
{
Stack<IEnumerator<T>> stack = new Stack<IEnumerator<T>>();
try
{
stack.Push(input.GetEnumerator());
while (stack.Count > 0)
{
while (stack.Peek().MoveNext())
{
T element = stack.Peek().Current;
yield return element;
IEnumerable<T>? children = recursion(element);
if (children != null)
{
stack.Push(children.GetEnumerator());
}
}
stack.Pop().Dispose();
}
}
finally
{
while (stack.Count > 0)
{
stack.Pop().Dispose();
}
}
}
/// <summary>
/// Converts a tree data structure into a flat list by traversing it in post-order.
/// </summary>
/// <param name="root">The root element of the tree.</param>
/// <param name="recursion">The function that gets the children of an element.</param>
/// <returns>Iterator that enumerates the tree structure in post-order.</returns>
public static IEnumerable<T> PostOrder<T>(T root, Func<T, IEnumerable<T>?> recursion)
{
return PostOrder(new T[] { root }, recursion);
}
/// <summary>
/// Converts a tree data structure into a flat list by traversing it in post-order.
/// </summary>
/// <param name="input">The root elements of the forest.</param>
/// <param name="recursion">The function that gets the children of an element.</param>
/// <returns>Iterator that enumerates the tree structure in post-order.</returns>
public static IEnumerable<T> PostOrder<T>(IEnumerable<T> input, Func<T, IEnumerable<T>?> recursion)
{
Stack<IEnumerator<T>> stack = new Stack<IEnumerator<T>>();
try
{
stack.Push(input.GetEnumerator());
while (stack.Count > 0)
{
while (stack.Peek().MoveNext())
{
T element = stack.Peek().Current;
IEnumerable<T>? children = recursion(element);
if (children != null)
{
stack.Push(children.GetEnumerator());
}
else
{
yield return element;
}
}
stack.Pop().Dispose();
if (stack.Count > 0)
yield return stack.Peek().Current;
}
}
finally
{
while (stack.Count > 0)
{
stack.Pop().Dispose();
}
}
}
}

120
ICSharpCode.Decompiler.Generators/packages.lock.json

@ -0,0 +1,120 @@
{
"version": 1,
"dependencies": {
".NETStandard,Version=v2.0": {
"Microsoft.CodeAnalysis.CSharp": {
"type": "Direct",
"requested": "[5.0.0, )",
"resolved": "5.0.0",
"contentHash": "5DSyJ9bk+ATuDy7fp2Zt0mJStDVKbBoiz1DyfAwSa+k4H4IwykAUcV3URelw5b8/iVbfSaOwkwmPUZH6opZKCw==",
"dependencies": {
"Microsoft.CodeAnalysis.Analyzers": "3.11.0",
"Microsoft.CodeAnalysis.Common": "[5.0.0]",
"System.Buffers": "4.6.0",
"System.Collections.Immutable": "9.0.0",
"System.Memory": "4.6.0",
"System.Numerics.Vectors": "4.6.0",
"System.Reflection.Metadata": "9.0.0",
"System.Runtime.CompilerServices.Unsafe": "6.1.0",
"System.Text.Encoding.CodePages": "8.0.0",
"System.Threading.Tasks.Extensions": "4.6.0"
}
},
"NETStandard.Library": {
"type": "Direct",
"requested": "[2.0.3, )",
"resolved": "2.0.3",
"contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"Microsoft.CodeAnalysis.Analyzers": {
"type": "Transitive",
"resolved": "3.11.0",
"contentHash": "v/EW3UE8/lbEYHoC2Qq7AR/DnmvpgdtAMndfQNmpuIMx/Mto8L5JnuCfdBYtgvalQOtfNCnxFejxuRrryvUTsg=="
},
"Microsoft.CodeAnalysis.Common": {
"type": "Transitive",
"resolved": "5.0.0",
"contentHash": "ZXRAdvH6GiDeHRyd3q/km8Z44RoM6FBWHd+gen/la81mVnAdHTEsEkO5J0TCNXBymAcx5UYKt5TvgKBhaLJEow==",
"dependencies": {
"Microsoft.CodeAnalysis.Analyzers": "3.11.0",
"System.Buffers": "4.6.0",
"System.Collections.Immutable": "9.0.0",
"System.Memory": "4.6.0",
"System.Numerics.Vectors": "4.6.0",
"System.Reflection.Metadata": "9.0.0",
"System.Runtime.CompilerServices.Unsafe": "6.1.0",
"System.Text.Encoding.CodePages": "8.0.0",
"System.Threading.Tasks.Extensions": "4.6.0"
}
},
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
"resolved": "1.1.0",
"contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A=="
},
"System.Buffers": {
"type": "Transitive",
"resolved": "4.6.0",
"contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
},
"System.Collections.Immutable": {
"type": "Transitive",
"resolved": "9.0.0",
"contentHash": "QhkXUl2gNrQtvPmtBTQHb0YsUrDiDQ2QS09YbtTTiSjGcf7NBqtYbrG/BE06zcBPCKEwQGzIv13IVdXNOSub2w==",
"dependencies": {
"System.Memory": "4.5.5",
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"System.Memory": {
"type": "Transitive",
"resolved": "4.6.0",
"contentHash": "OEkbBQoklHngJ8UD8ez2AERSk2g+/qpAaSWWCBFbpH727HxDq5ydVkuncBaKcKfwRqXGWx64dS6G1SUScMsitg==",
"dependencies": {
"System.Buffers": "4.6.0",
"System.Numerics.Vectors": "4.6.0",
"System.Runtime.CompilerServices.Unsafe": "6.1.0"
}
},
"System.Numerics.Vectors": {
"type": "Transitive",
"resolved": "4.6.0",
"contentHash": "t+SoieZsRuEyiw/J+qXUbolyO219tKQQI0+2/YI+Qv7YdGValA6WiuokrNKqjrTNsy5ABWU11bdKOzUdheteXg=="
},
"System.Reflection.Metadata": {
"type": "Transitive",
"resolved": "9.0.0",
"contentHash": "ANiqLu3DxW9kol/hMmTWbt3414t9ftdIuiIU7j80okq2YzAueo120M442xk1kDJWtmZTqWQn7wHDvMRipVOEOQ==",
"dependencies": {
"System.Collections.Immutable": "9.0.0",
"System.Memory": "4.5.5"
}
},
"System.Runtime.CompilerServices.Unsafe": {
"type": "Transitive",
"resolved": "6.1.0",
"contentHash": "5o/HZxx6RVqYlhKSq8/zronDkALJZUT2Vz0hx43f0gwe8mwlM0y2nYlqdBwLMzr262Bwvpikeb/yEwkAa5PADg=="
},
"System.Text.Encoding.CodePages": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "OZIsVplFGaVY90G2SbpgU7EnCoOO5pw1t4ic21dBF3/1omrJFpAGoNAVpPyMVOC90/hvgkGG3VFqR13YgZMQfg==",
"dependencies": {
"System.Memory": "4.5.5",
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"System.Threading.Tasks.Extensions": {
"type": "Transitive",
"resolved": "4.6.0",
"contentHash": "I5G6Y8jb0xRtGUC9Lahy7FUvlYlnGMMkbuKAQBy8Jb7Y6Yn8OlBEiUOY0PqZ0hy6Ua8poVA1ui1tAIiXNxGdsg==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.1.0"
}
}
}
}
}

17
ICSharpCode.Decompiler.Tests/packages.lock.json

@ -214,14 +214,6 @@
"resolved": "5.6.0-2.26172.2", "resolved": "5.6.0-2.26172.2",
"contentHash": "xRPIwva1u2UuX46lfccAl8+86YnjzXjoCD83KanidOq/qHXHt4UdhWj4oPGtAcVnYWiiQPnYwi16wD6SSuLZUw==" "contentHash": "xRPIwva1u2UuX46lfccAl8+86YnjzXjoCD83KanidOq/qHXHt4UdhWj4oPGtAcVnYWiiQPnYwi16wD6SSuLZUw=="
}, },
"Microsoft.CodeAnalysis.Common": {
"type": "Transitive",
"resolved": "5.8.0-1.26302.115",
"contentHash": "GVNztynnvtpOh19LGlhwQTNOBKoSsaJ+Q+fA80AMKJNDXw25mCTJLM4TEJfyTolJj6DesIK78Xlu3iG7y8sIMg==",
"dependencies": {
"Microsoft.CodeAnalysis.Analyzers": "5.6.0-2.26172.2"
}
},
"Microsoft.DiaSymReader.PortablePdb": { "Microsoft.DiaSymReader.PortablePdb": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.7.0-beta-21525-03", "resolved": "1.7.0-beta-21525-03",
@ -1254,6 +1246,15 @@
"resolved": "1.3.8", "resolved": "1.3.8",
"contentHash": "LhwlPa7c1zs1OV2XadMtAWdImjLIsqFJPoRcIWAadSRn0Ri1DepK65UbWLPmt4riLqx2d40xjXRk0ogpqNtK7g==" "contentHash": "LhwlPa7c1zs1OV2XadMtAWdImjLIsqFJPoRcIWAadSRn0Ri1DepK65UbWLPmt4riLqx2d40xjXRk0ogpqNtK7g=="
}, },
"Microsoft.CodeAnalysis.Common": {
"type": "CentralTransitive",
"requested": "[5.8.0-1.26302.115, )",
"resolved": "5.8.0-1.26302.115",
"contentHash": "GVNztynnvtpOh19LGlhwQTNOBKoSsaJ+Q+fA80AMKJNDXw25mCTJLM4TEJfyTolJj6DesIK78Xlu3iG7y8sIMg==",
"dependencies": {
"Microsoft.CodeAnalysis.Analyzers": "5.6.0-2.26172.2"
}
},
"Microsoft.Extensions.DependencyInjection.Abstractions": { "Microsoft.Extensions.DependencyInjection.Abstractions": {
"type": "CentralTransitive", "type": "CentralTransitive",
"requested": "[10.0.9, )", "requested": "[10.0.9, )",

1
ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs

@ -37,6 +37,7 @@ using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
[DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public abstract partial class AstNode : AbstractAnnotatable, INode, ICloneable public abstract partial class AstNode : AbstractAnnotatable, INode, ICloneable
{ {
// the Root role must be available when creating the null nodes, so we can't put it in the Roles class // the Root role must be available when creating the null nodes, so we can't put it in the Roles class

3
ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs

@ -26,7 +26,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// A type reference in the C# AST. /// A type reference in the C# AST.
/// </summary> /// </summary>
public abstract class AstType : AstNode [DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public abstract partial class AstType : AstNode
{ {
#region Null #region Null
public new static readonly AstType Null = new NullAstType(); public new static readonly AstType Null = new NullAstType();

3
ICSharpCode.Decompiler/CSharp/Syntax/CSharpModifierToken.cs

@ -31,7 +31,8 @@ using ICSharpCode.Decompiler.CSharp.OutputVisitor;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class CSharpModifierToken : CSharpTokenNode [DecompilerAstNode(hasNullNode: false)]
public partial class CSharpModifierToken : CSharpTokenNode
{ {
Modifiers modifier; Modifiers modifier;

3
ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs

@ -34,7 +34,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <remarks> /// <remarks>
/// In all non null c# token nodes the Role of a CSharpToken must be a TokenRole. /// In all non null c# token nodes the Role of a CSharpToken must be a TokenRole.
/// </remarks> /// </remarks>
public class CSharpTokenNode : AstNode [DecompilerAstNode(hasNullNode: true)]
public partial class CSharpTokenNode : AstNode
{ {
public static new readonly CSharpTokenNode Null = new NullCSharpTokenNode(); public static new readonly CSharpTokenNode Null = new NullCSharpTokenNode();
class NullCSharpTokenNode : CSharpTokenNode class NullCSharpTokenNode : CSharpTokenNode

6
ICSharpCode.Decompiler/CSharp/Syntax/ComposedType.cs

@ -32,7 +32,8 @@ using ICSharpCode.Decompiler.CSharp.OutputVisitor;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class ComposedType : AstType [DecompilerAstNode(hasNullNode: false)]
public partial class ComposedType : AstType
{ {
public static readonly Role<AttributeSection> AttributeRole = EntityDeclaration.AttributeRole; public static readonly Role<AttributeSection> AttributeRole = EntityDeclaration.AttributeRole;
public static readonly TokenRole RefRole = new TokenRole("ref"); public static readonly TokenRole RefRole = new TokenRole("ref");
@ -203,7 +204,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// [,,,] /// [,,,]
/// </summary> /// </summary>
public class ArraySpecifier : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class ArraySpecifier : AstNode
{ {
public override NodeType NodeType { public override NodeType NodeType {
get { get {

3
ICSharpCode.Decompiler/CSharp/Syntax/DocumentationReference.cs

@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Represents a 'cref' reference in XML documentation. /// Represents a 'cref' reference in XML documentation.
/// </summary> /// </summary>
public class DocumentationReference : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class DocumentationReference : AstNode
{ {
public static readonly Role<AstType> DeclaringTypeRole = new Role<AstType>("DeclaringType", AstType.Null); public static readonly Role<AstType> DeclaringTypeRole = new Role<AstType>("DeclaringType", AstType.Null);
public static readonly Role<AstType> ConversionOperatorReturnTypeRole = new Role<AstType>("ConversionOperatorReturnType", AstType.Null); public static readonly Role<AstType> ConversionOperatorReturnTypeRole = new Role<AstType>("ConversionOperatorReturnType", AstType.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousMethodExpression.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// [async] delegate(Parameters) {Body} /// [async] delegate(Parameters) {Body}
/// </summary> /// </summary>
public class AnonymousMethodExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class AnonymousMethodExpression : Expression
{ {
public readonly static TokenRole DelegateKeywordRole = new TokenRole("delegate"); public readonly static TokenRole DelegateKeywordRole = new TokenRole("delegate");
public readonly static TokenRole AsyncModifierRole = LambdaExpression.AsyncModifierRole; public readonly static TokenRole AsyncModifierRole = LambdaExpression.AsyncModifierRole;

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AnonymousTypeCreateExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// new { [ExpressionList] } /// new { [ExpressionList] }
/// </summary> /// </summary>
public class AnonymousTypeCreateExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class AnonymousTypeCreateExpression : Expression
{ {
public readonly static TokenRole NewKeywordRole = new TokenRole("new"); public readonly static TokenRole NewKeywordRole = new TokenRole("new");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayCreateExpression.cs

@ -21,7 +21,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// new Type[Dimensions] /// new Type[Dimensions]
/// </summary> /// </summary>
public class ArrayCreateExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class ArrayCreateExpression : Expression
{ {
public readonly static TokenRole NewKeywordRole = new TokenRole("new"); public readonly static TokenRole NewKeywordRole = new TokenRole("new");
public readonly static Role<ArraySpecifier> AdditionalArraySpecifierRole = new Role<ArraySpecifier>("AdditionalArraySpecifier", null); public readonly static Role<ArraySpecifier> AdditionalArraySpecifierRole = new Role<ArraySpecifier>("AdditionalArraySpecifier", null);

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// { Elements } /// { Elements }
/// </summary> /// </summary>
public class ArrayInitializerExpression : Expression [DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public partial class ArrayInitializerExpression : Expression
{ {
/// <summary> /// <summary>
/// For ease of use purposes in the resolver the ast representation /// For ease of use purposes in the resolver the ast representation

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AsExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Expression as TypeReference /// Expression as TypeReference
/// </summary> /// </summary>
public class AsExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class AsExpression : Expression
{ {
public readonly static TokenRole AsKeywordRole = new TokenRole("as"); public readonly static TokenRole AsKeywordRole = new TokenRole("as");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/AssignmentExpression.cs

@ -33,7 +33,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Left Operator= Right /// Left Operator= Right
/// </summary> /// </summary>
public class AssignmentExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class AssignmentExpression : Expression
{ {
// reuse roles from BinaryOperatorExpression // reuse roles from BinaryOperatorExpression
public readonly static Role<Expression> LeftRole = BinaryOperatorExpression.LeftRole; public readonly static Role<Expression> LeftRole = BinaryOperatorExpression.LeftRole;

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BaseReferenceExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// base /// base
/// </summary> /// </summary>
public class BaseReferenceExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class BaseReferenceExpression : Expression
{ {
public TextLocation Location { public TextLocation Location {
get; get;

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/BinaryOperatorExpression.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Left Operator Right /// Left Operator Right
/// </summary> /// </summary>
public class BinaryOperatorExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class BinaryOperatorExpression : Expression
{ {
public readonly static TokenRole BitwiseAndRole = new TokenRole("&"); public readonly static TokenRole BitwiseAndRole = new TokenRole("&");
public readonly static TokenRole BitwiseOrRole = new TokenRole("|"); public readonly static TokenRole BitwiseOrRole = new TokenRole("|");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CastExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// (CastTo)Expression /// (CastTo)Expression
/// </summary> /// </summary>
public class CastExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class CastExpression : Expression
{ {
public CSharpTokenNode LParToken { public CSharpTokenNode LParToken {
get { return GetChildByRole(Roles.LPar); } get { return GetChildByRole(Roles.LPar); }

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/CheckedExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// checked(Expression) /// checked(Expression)
/// </summary> /// </summary>
public class CheckedExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class CheckedExpression : Expression
{ {
public readonly static TokenRole CheckedKeywordRole = new TokenRole("checked"); public readonly static TokenRole CheckedKeywordRole = new TokenRole("checked");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ConditionalExpression.cs

@ -30,7 +30,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Condition ? TrueExpression : FalseExpression /// Condition ? TrueExpression : FalseExpression
/// </summary> /// </summary>
public class ConditionalExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class ConditionalExpression : Expression
{ {
public readonly static Role<Expression> ConditionRole = Roles.Condition; public readonly static Role<Expression> ConditionRole = Roles.Condition;
public readonly static TokenRole QuestionMarkRole = new TokenRole("?"); public readonly static TokenRole QuestionMarkRole = new TokenRole("?");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DeclarationExpression.cs

@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// TypeName VariableDesignation /// TypeName VariableDesignation
/// </summary> /// </summary>
public class DeclarationExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class DeclarationExpression : Expression
{ {
public AstType Type { public AstType Type {
get { return GetChildByRole(Roles.Type); } get { return GetChildByRole(Roles.Type); }

30
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DecompilerAstNodeAttribute.cs

@ -0,0 +1,30 @@
// Copyright (c) 2017 Siegfried Pammer
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace ICSharpCode.Decompiler.CSharp.Syntax
{
class DecompilerAstNodeAttribute : System.Attribute
{
}
}

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DefaultValueExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// default(Type) /// default(Type)
/// </summary> /// </summary>
public class DefaultValueExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class DefaultValueExpression : Expression
{ {
public readonly static TokenRole DefaultKeywordRole = new TokenRole("default"); public readonly static TokenRole DefaultKeywordRole = new TokenRole("default");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/DirectionExpression.cs

@ -37,7 +37,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// ref Expression /// ref Expression
/// </summary> /// </summary>
public class DirectionExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class DirectionExpression : Expression
{ {
public readonly static TokenRole RefKeywordRole = new TokenRole("ref"); public readonly static TokenRole RefKeywordRole = new TokenRole("ref");
public readonly static TokenRole OutKeywordRole = new TokenRole("out"); public readonly static TokenRole OutKeywordRole = new TokenRole("out");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ErrorExpression.cs

@ -27,7 +27,8 @@ using System;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class ErrorExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class ErrorExpression : Expression
{ {
public TextLocation Location { get; set; } public TextLocation Location { get; set; }

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs

@ -28,7 +28,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// This class is useful even though it doesn't provide any additional functionality: /// This class is useful even though it doesn't provide any additional functionality:
/// It can be used to communicate more information in APIs, e.g. "this subnode will always be an expression" /// It can be used to communicate more information in APIs, e.g. "this subnode will always be an expression"
/// </remarks> /// </remarks>
public abstract class Expression : AstNode [DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public abstract partial class Expression : AstNode
{ {
#region Null #region Null
public new static readonly Expression Null = new NullExpression(); public new static readonly Expression Null = new NullExpression();

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IdentifierExpression.cs

@ -26,7 +26,8 @@
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class IdentifierExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class IdentifierExpression : Expression
{ {
public IdentifierExpression() public IdentifierExpression()
{ {

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IndexerExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Target[Arguments] /// Target[Arguments]
/// </summary> /// </summary>
public class IndexerExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class IndexerExpression : Expression
{ {
public Expression Target { public Expression Target {
get { return GetChildByRole(Roles.TargetExpression); } get { return GetChildByRole(Roles.TargetExpression); }

12
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs

@ -6,7 +6,8 @@ using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class InterpolatedStringExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class InterpolatedStringExpression : Expression
{ {
public static readonly TokenRole OpenQuote = new TokenRole("$\""); public static readonly TokenRole OpenQuote = new TokenRole("$\"");
public static readonly TokenRole CloseQuote = new TokenRole("\""); public static readonly TokenRole CloseQuote = new TokenRole("\"");
@ -47,7 +48,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public abstract class InterpolatedStringContent : AstNode [DecompilerAstNode(hasNullNode: true)]
public abstract partial class InterpolatedStringContent : AstNode
{ {
#region Null #region Null
public new static readonly InterpolatedStringContent Null = new NullInterpolatedStringContent(); public new static readonly InterpolatedStringContent Null = new NullInterpolatedStringContent();
@ -90,7 +92,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// { Expression , Alignment : Suffix } /// { Expression , Alignment : Suffix }
/// </summary> /// </summary>
public class Interpolation : InterpolatedStringContent [DecompilerAstNode(hasNullNode: false)]
public partial class Interpolation : InterpolatedStringContent
{ {
public static readonly TokenRole LBrace = new TokenRole("{"); public static readonly TokenRole LBrace = new TokenRole("{");
public static readonly TokenRole RBrace = new TokenRole("}"); public static readonly TokenRole RBrace = new TokenRole("}");
@ -146,7 +149,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class InterpolatedStringText : InterpolatedStringContent [DecompilerAstNode(hasNullNode: false)]
public partial class InterpolatedStringText : InterpolatedStringContent
{ {
public string Text { get; set; } public string Text { get; set; }

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InvocationExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Target(Arguments) /// Target(Arguments)
/// </summary> /// </summary>
public class InvocationExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class InvocationExpression : Expression
{ {
public Expression Target { public Expression Target {
get { return GetChildByRole(Roles.TargetExpression); } get { return GetChildByRole(Roles.TargetExpression); }

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IsExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Expression is Type /// Expression is Type
/// </summary> /// </summary>
public class IsExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class IsExpression : Expression
{ {
public readonly static TokenRole IsKeywordRole = new TokenRole("is"); public readonly static TokenRole IsKeywordRole = new TokenRole("is");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/LambdaExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// [async] Parameters => Body /// [async] Parameters => Body
/// </summary> /// </summary>
public class LambdaExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class LambdaExpression : Expression
{ {
public static readonly Role<AttributeSection> AttributeRole = new Role<AttributeSection>("Attribute", null); public static readonly Role<AttributeSection> AttributeRole = new Role<AttributeSection>("Attribute", null);
public readonly static TokenRole AsyncModifierRole = new TokenRole("async"); public readonly static TokenRole AsyncModifierRole = new TokenRole("async");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/MemberReferenceExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Target.MemberName /// Target.MemberName
/// </summary> /// </summary>
public class MemberReferenceExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class MemberReferenceExpression : Expression
{ {
public Expression Target { public Expression Target {
get { get {

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedArgumentExpression.cs

@ -22,7 +22,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Represents a named argument passed to a method or attribute. /// Represents a named argument passed to a method or attribute.
/// name: expression /// name: expression
/// </summary> /// </summary>
public class NamedArgumentExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class NamedArgumentExpression : Expression
{ {
public NamedArgumentExpression() public NamedArgumentExpression()
{ {

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NamedExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// This isn't the same as 'assign' even though it has the same syntax. /// This isn't the same as 'assign' even though it has the same syntax.
/// This expression is used in object initializers and for named attribute arguments [Attr(FieldName = value)]. /// This expression is used in object initializers and for named attribute arguments [Attr(FieldName = value)].
/// </summary> /// </summary>
public class NamedExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class NamedExpression : Expression
{ {
public NamedExpression() public NamedExpression()
{ {

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/NullReferenceExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// null /// null
/// </summary> /// </summary>
public class NullReferenceExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class NullReferenceExpression : Expression
{ {
TextLocation location; TextLocation location;
public override TextLocation StartLocation { public override TextLocation StartLocation {

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ObjectCreateExpression.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// new Type(Arguments) { Initializer } /// new Type(Arguments) { Initializer }
/// </summary> /// </summary>
public class ObjectCreateExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class ObjectCreateExpression : Expression
{ {
public readonly static TokenRole NewKeywordRole = new TokenRole("new"); public readonly static TokenRole NewKeywordRole = new TokenRole("new");
public readonly static Role<ArrayInitializerExpression> InitializerRole = ArrayCreateExpression.InitializerRole; public readonly static Role<ArrayInitializerExpression> InitializerRole = ArrayCreateExpression.InitializerRole;

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/OutVarDeclarationExpression.cs

@ -21,7 +21,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// out type expression /// out type expression
/// </summary> /// </summary>
public class OutVarDeclarationExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class OutVarDeclarationExpression : Expression
{ {
public readonly static TokenRole OutKeywordRole = DirectionExpression.OutKeywordRole; public readonly static TokenRole OutKeywordRole = DirectionExpression.OutKeywordRole;

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ParenthesizedExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// ( Expression ) /// ( Expression )
/// </summary> /// </summary>
public class ParenthesizedExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class ParenthesizedExpression : Expression
{ {
public CSharpTokenNode LParToken { public CSharpTokenNode LParToken {
get { return GetChildByRole(Roles.LPar); } get { return GetChildByRole(Roles.LPar); }

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PointerReferenceExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Target->MemberName /// Target->MemberName
/// </summary> /// </summary>
public class PointerReferenceExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class PointerReferenceExpression : Expression
{ {
public readonly static TokenRole ArrowRole = new TokenRole("->"); public readonly static TokenRole ArrowRole = new TokenRole("->");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/PrimitiveExpression.cs

@ -46,7 +46,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Represents a literal value. /// Represents a literal value.
/// </summary> /// </summary>
public class PrimitiveExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class PrimitiveExpression : Expression
{ {
public static readonly object AnyValue = new object(); public static readonly object AnyValue = new object();

30
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs

@ -18,7 +18,8 @@
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class QueryExpression : Expression [DecompilerAstNode(hasNullNode: true)]
public partial class QueryExpression : Expression
{ {
public static readonly Role<QueryClause> ClauseRole = new Role<QueryClause>("Clause", null); public static readonly Role<QueryClause> ClauseRole = new Role<QueryClause>("Clause", null);
@ -106,7 +107,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// new QuerySelectClause(e) /// new QuerySelectClause(e)
/// } /// }
/// </summary> /// </summary>
public class QueryContinuationClause : QueryClause [DecompilerAstNode(hasNullNode: false)]
public partial class QueryContinuationClause : QueryClause
{ {
public static readonly Role<QueryExpression> PrecedingQueryRole = new Role<QueryExpression>("PrecedingQuery", QueryExpression.Null); public static readonly Role<QueryExpression> PrecedingQueryRole = new Role<QueryExpression>("PrecedingQuery", QueryExpression.Null);
public static readonly TokenRole IntoKeywordRole = new TokenRole("into"); public static readonly TokenRole IntoKeywordRole = new TokenRole("into");
@ -155,7 +157,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class QueryFromClause : QueryClause [DecompilerAstNode(hasNullNode: false)]
public partial class QueryFromClause : QueryClause
{ {
public static readonly TokenRole FromKeywordRole = new TokenRole("from"); public static readonly TokenRole FromKeywordRole = new TokenRole("from");
public static readonly TokenRole InKeywordRole = new TokenRole("in"); public static readonly TokenRole InKeywordRole = new TokenRole("in");
@ -214,7 +217,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class QueryLetClause : QueryClause [DecompilerAstNode(hasNullNode: false)]
public partial class QueryLetClause : QueryClause
{ {
public readonly static TokenRole LetKeywordRole = new TokenRole("let"); public readonly static TokenRole LetKeywordRole = new TokenRole("let");
@ -266,7 +270,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class QueryWhereClause : QueryClause [DecompilerAstNode(hasNullNode: false)]
public partial class QueryWhereClause : QueryClause
{ {
public readonly static TokenRole WhereKeywordRole = new TokenRole("where"); public readonly static TokenRole WhereKeywordRole = new TokenRole("where");
@ -304,7 +309,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Represents a join or group join clause. /// Represents a join or group join clause.
/// </summary> /// </summary>
public class QueryJoinClause : QueryClause [DecompilerAstNode(hasNullNode: false)]
public partial class QueryJoinClause : QueryClause
{ {
public static readonly TokenRole JoinKeywordRole = new TokenRole("join"); public static readonly TokenRole JoinKeywordRole = new TokenRole("join");
public static readonly Role<AstType> TypeRole = Roles.Type; public static readonly Role<AstType> TypeRole = Roles.Type;
@ -414,7 +420,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class QueryOrderClause : QueryClause [DecompilerAstNode(hasNullNode: false)]
public partial class QueryOrderClause : QueryClause
{ {
public static readonly TokenRole OrderbyKeywordRole = new TokenRole("orderby"); public static readonly TokenRole OrderbyKeywordRole = new TokenRole("orderby");
public static readonly Role<QueryOrdering> OrderingRole = new Role<QueryOrdering>("Ordering", null); public static readonly Role<QueryOrdering> OrderingRole = new Role<QueryOrdering>("Ordering", null);
@ -449,7 +456,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class QueryOrdering : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class QueryOrdering : AstNode
{ {
public readonly static TokenRole AscendingKeywordRole = new TokenRole("ascending"); public readonly static TokenRole AscendingKeywordRole = new TokenRole("ascending");
public readonly static TokenRole DescendingKeywordRole = new TokenRole("descending"); public readonly static TokenRole DescendingKeywordRole = new TokenRole("descending");
@ -501,7 +509,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Descending Descending
} }
public class QuerySelectClause : QueryClause [DecompilerAstNode(hasNullNode: false)]
public partial class QuerySelectClause : QueryClause
{ {
public readonly static TokenRole SelectKeywordRole = new TokenRole("select"); public readonly static TokenRole SelectKeywordRole = new TokenRole("select");
@ -536,7 +545,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class QueryGroupClause : QueryClause [DecompilerAstNode(hasNullNode: false)]
public partial class QueryGroupClause : QueryClause
{ {
public static readonly TokenRole GroupKeywordRole = new TokenRole("group"); public static readonly TokenRole GroupKeywordRole = new TokenRole("group");
public static readonly Role<Expression> ProjectionRole = new Role<Expression>("Projection", Expression.Null); public static readonly Role<Expression> ProjectionRole = new Role<Expression>("Projection", Expression.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/RecursivePatternExpression.cs

@ -20,7 +20,8 @@ using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class RecursivePatternExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class RecursivePatternExpression : Expression
{ {
public static readonly Role<Expression> SubPatternRole = new Role<Expression>("SubPattern", Syntax.Expression.Null); public static readonly Role<Expression> SubPatternRole = new Role<Expression>("SubPattern", Syntax.Expression.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/SizeOfExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// sizeof(Type) /// sizeof(Type)
/// </summary> /// </summary>
public class SizeOfExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class SizeOfExpression : Expression
{ {
public readonly static TokenRole SizeofKeywordRole = new TokenRole("sizeof"); public readonly static TokenRole SizeofKeywordRole = new TokenRole("sizeof");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/StackAllocExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// stackalloc Type[Count] /// stackalloc Type[Count]
/// </summary> /// </summary>
public class StackAllocExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class StackAllocExpression : Expression
{ {
public readonly static TokenRole StackallocKeywordRole = new TokenRole("stackalloc"); public readonly static TokenRole StackallocKeywordRole = new TokenRole("stackalloc");
public readonly static Role<ArrayInitializerExpression> InitializerRole = new Role<ArrayInitializerExpression>("Initializer", ArrayInitializerExpression.Null); public readonly static Role<ArrayInitializerExpression> InitializerRole = new Role<ArrayInitializerExpression>("Initializer", ArrayInitializerExpression.Null);

6
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/SwitchExpression.cs

@ -21,7 +21,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Expression switch { SwitchSections } /// Expression switch { SwitchSections }
/// </summary> /// </summary>
public class SwitchExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class SwitchExpression : Expression
{ {
public static readonly TokenRole SwitchKeywordRole = new TokenRole("switch"); public static readonly TokenRole SwitchKeywordRole = new TokenRole("switch");
public static readonly Role<SwitchExpressionSection> SwitchSectionRole = new Role<SwitchExpressionSection>("SwitchSection", null); public static readonly Role<SwitchExpressionSection> SwitchSectionRole = new Role<SwitchExpressionSection>("SwitchSection", null);
@ -72,7 +73,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Pattern => Expression /// Pattern => Expression
/// </summary> /// </summary>
public class SwitchExpressionSection : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class SwitchExpressionSection : AstNode
{ {
public static readonly Role<Expression> PatternRole = new Role<Expression>("Pattern", Expression.Null); public static readonly Role<Expression> PatternRole = new Role<Expression>("Pattern", Expression.Null);
public static readonly Role<Expression> BodyRole = new Role<Expression>("Body", Expression.Null); public static readonly Role<Expression> BodyRole = new Role<Expression>("Body", Expression.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ThisReferenceExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// this /// this
/// </summary> /// </summary>
public class ThisReferenceExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class ThisReferenceExpression : Expression
{ {
public TextLocation Location { public TextLocation Location {
get; get;

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ThrowExpression.cs

@ -21,7 +21,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// throw Expression /// throw Expression
/// </summary> /// </summary>
public class ThrowExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class ThrowExpression : Expression
{ {
public static readonly TokenRole ThrowKeywordRole = ThrowStatement.ThrowKeywordRole; public static readonly TokenRole ThrowKeywordRole = ThrowStatement.ThrowKeywordRole;

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TupleExpression.cs

@ -22,7 +22,8 @@ using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class TupleExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class TupleExpression : Expression
{ {
public AstNodeCollection<Expression> Elements { public AstNodeCollection<Expression> Elements {
get { return GetChildrenByRole(Roles.Expression); } get { return GetChildrenByRole(Roles.Expression); }

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TypeOfExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// typeof(Type) /// typeof(Type)
/// </summary> /// </summary>
public class TypeOfExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class TypeOfExpression : Expression
{ {
public readonly static TokenRole TypeofKeywordRole = new TokenRole("typeof"); public readonly static TokenRole TypeofKeywordRole = new TokenRole("typeof");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/TypeReferenceExpression.cs

@ -22,7 +22,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Represents an AstType as an expression. /// Represents an AstType as an expression.
/// This is used when calling a method on a primitive type: "int.Parse()" /// This is used when calling a method on a primitive type: "int.Parse()"
/// </summary> /// </summary>
public class TypeReferenceExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class TypeReferenceExpression : Expression
{ {
public AstType Type { public AstType Type {
get { return GetChildByRole(Roles.Type); } get { return GetChildByRole(Roles.Type); }

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Operator Expression /// Operator Expression
/// </summary> /// </summary>
public class UnaryOperatorExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class UnaryOperatorExpression : Expression
{ {
public readonly static TokenRole NotRole = new TokenRole("!"); public readonly static TokenRole NotRole = new TokenRole("!");
public readonly static TokenRole BitNotRole = new TokenRole("~"); public readonly static TokenRole BitNotRole = new TokenRole("~");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UncheckedExpression.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// unchecked(Expression) /// unchecked(Expression)
/// </summary> /// </summary>
public class UncheckedExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class UncheckedExpression : Expression
{ {
public readonly static TokenRole UncheckedKeywordRole = new TokenRole("unchecked"); public readonly static TokenRole UncheckedKeywordRole = new TokenRole("unchecked");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UndocumentedExpression.cs

@ -38,7 +38,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Represents undocumented expressions. /// Represents undocumented expressions.
/// </summary> /// </summary>
public class UndocumentedExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class UndocumentedExpression : Expression
{ {
public readonly static TokenRole ArglistKeywordRole = new TokenRole("__arglist"); public readonly static TokenRole ArglistKeywordRole = new TokenRole("__arglist");
public readonly static TokenRole RefvalueKeywordRole = new TokenRole("__refvalue"); public readonly static TokenRole RefvalueKeywordRole = new TokenRole("__refvalue");

3
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/WithInitializerExpression.cs

@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Expression with Initializer /// Expression with Initializer
/// </summary> /// </summary>
public class WithInitializerExpression : Expression [DecompilerAstNode(hasNullNode: false)]
public partial class WithInitializerExpression : Expression
{ {
public readonly static TokenRole WithKeywordRole = new TokenRole("with"); public readonly static TokenRole WithKeywordRole = new TokenRole("with");
public readonly static Role<ArrayInitializerExpression> InitializerRole = ArrayCreateExpression.InitializerRole; public readonly static Role<ArrayInitializerExpression> InitializerRole = ArrayCreateExpression.InitializerRole;

3
ICSharpCode.Decompiler/CSharp/Syntax/FunctionPointerAstType.cs

@ -26,7 +26,8 @@
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class FunctionPointerAstType : AstType [DecompilerAstNode(hasNullNode: false)]
public partial class FunctionPointerAstType : AstType
{ {
public static readonly TokenRole PointerRole = new TokenRole("*"); public static readonly TokenRole PointerRole = new TokenRole("*");
public static readonly Role<AstType> CallingConventionRole = new Role<AstType>("CallConv", AstType.Null); public static readonly Role<AstType> CallingConventionRole = new Role<AstType>("CallConv", AstType.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Attribute.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Attribute(Arguments) /// Attribute(Arguments)
/// </summary> /// </summary>
public class Attribute : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class Attribute : AstNode
{ {
public override NodeType NodeType { public override NodeType NodeType {
get { get {

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/AttributeSection.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// [AttributeTarget: Attributes] /// [AttributeTarget: Attributes]
/// </summary> /// </summary>
public class AttributeSection : AstNode [DecompilerAstNode(hasNullNode: false, hasPatternPlaceholder: true)]
public partial class AttributeSection : AstNode
{ {
#region PatternPlaceholder #region PatternPlaceholder
public static implicit operator AttributeSection(PatternMatching.Pattern pattern) public static implicit operator AttributeSection(PatternMatching.Pattern pattern)

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Comment.cs

@ -50,7 +50,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
MultiLineDocumentation MultiLineDocumentation
} }
public class Comment : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class Comment : AstNode
{ {
public override NodeType NodeType { public override NodeType NodeType {
get { get {

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/Constraint.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <remarks> /// <remarks>
/// new(), struct and class constraints are represented using a PrimitiveType "new", "struct" or "class" /// new(), struct and class constraints are represented using a PrimitiveType "new", "struct" or "class"
/// </remarks> /// </remarks>
public class Constraint : AstNode [DecompilerAstNode(hasNullNode: true)]
public partial class Constraint : AstNode
{ {
public override NodeType NodeType { public override NodeType NodeType {
get { return NodeType.Unknown; } get { return NodeType.Unknown; }

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/DelegateDeclaration.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// delegate ReturnType Name&lt;TypeParameters&gt;(Parameters) where Constraints; /// delegate ReturnType Name&lt;TypeParameters&gt;(Parameters) where Constraints;
/// </summary> /// </summary>
public class DelegateDeclaration : EntityDeclaration [DecompilerAstNode(hasNullNode: false)]
public partial class DelegateDeclaration : EntityDeclaration
{ {
public override NodeType NodeType { public override NodeType NodeType {
get { return NodeType.TypeDeclaration; } get { return NodeType.TypeDeclaration; }

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/ExternAliasDeclaration.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// extern alias IDENTIFIER; /// extern alias IDENTIFIER;
/// </summary> /// </summary>
public class ExternAliasDeclaration : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class ExternAliasDeclaration : AstNode
{ {
public override NodeType NodeType { public override NodeType NodeType {
get { get {

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/NamespaceDeclaration.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// namespace Name { Members } /// namespace Name { Members }
/// </summary> /// </summary>
public class NamespaceDeclaration : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class NamespaceDeclaration : AstNode
{ {
public static readonly Role<AstNode> MemberRole = SyntaxTree.MemberRole; public static readonly Role<AstNode> MemberRole = SyntaxTree.MemberRole;
public static readonly Role<AstType> NamespaceNameRole = new Role<AstType>("NamespaceName", AstType.Null); public static readonly Role<AstType> NamespaceNameRole = new Role<AstType>("NamespaceName", AstType.Null);

9
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/PreProcessorDirective.cs

@ -46,7 +46,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
Line = 12 Line = 12
} }
public class LinePreprocessorDirective : PreProcessorDirective [DecompilerAstNode(hasNullNode: false)]
public partial class LinePreprocessorDirective : PreProcessorDirective
{ {
public int LineNumber { public int LineNumber {
get; get;
@ -67,7 +68,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class PragmaWarningPreprocessorDirective : PreProcessorDirective [DecompilerAstNode(hasNullNode: false)]
public partial class PragmaWarningPreprocessorDirective : PreProcessorDirective
{ {
public static readonly Role<PrimitiveExpression> WarningRole = new Role<PrimitiveExpression>("Warning", null); public static readonly Role<PrimitiveExpression> WarningRole = new Role<PrimitiveExpression>("Warning", null);
@ -125,7 +127,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class PreProcessorDirective : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class PreProcessorDirective : AstNode
{ {
public override NodeType NodeType { public override NodeType NodeType {
get { get {

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs

@ -47,7 +47,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// class Name&lt;TypeParameters&gt; : BaseTypes where Constraints; /// class Name&lt;TypeParameters&gt; : BaseTypes where Constraints;
/// </summary> /// </summary>
public class TypeDeclaration : EntityDeclaration [DecompilerAstNode(hasNullNode: false)]
public partial class TypeDeclaration : EntityDeclaration
{ {
public override NodeType NodeType { public override NodeType NodeType {
get { return NodeType.TypeDeclaration; } get { return NodeType.TypeDeclaration; }

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeParameterDeclaration.cs

@ -27,7 +27,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Note: mirroring the C# syntax, constraints are not part of the type parameter declaration, but belong /// Note: mirroring the C# syntax, constraints are not part of the type parameter declaration, but belong
/// to the parent type or method. /// to the parent type or method.
/// </summary> /// </summary>
public class TypeParameterDeclaration : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class TypeParameterDeclaration : AstNode
{ {
public static readonly Role<AttributeSection> AttributeRole = EntityDeclaration.AttributeRole; public static readonly Role<AttributeSection> AttributeRole = EntityDeclaration.AttributeRole;
public static readonly TokenRole OutVarianceKeywordRole = new TokenRole("out"); public static readonly TokenRole OutVarianceKeywordRole = new TokenRole("out");

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/UsingAliasDeclaration.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// using Alias = Import; /// using Alias = Import;
/// </summary> /// </summary>
public class UsingAliasDeclaration : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class UsingAliasDeclaration : AstNode
{ {
public static readonly TokenRole UsingKeywordRole = new TokenRole("using"); public static readonly TokenRole UsingKeywordRole = new TokenRole("using");
public static readonly Role<Identifier> AliasRole = new Role<Identifier>("Alias", Identifier.Null); public static readonly Role<Identifier> AliasRole = new Role<Identifier>("Alias", Identifier.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/UsingDeclaration.cs

@ -32,7 +32,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// using Import; /// using Import;
/// </summary> /// </summary>
public class UsingDeclaration : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class UsingDeclaration : AstNode
{ {
public static readonly TokenRole UsingKeywordRole = new TokenRole("using"); public static readonly TokenRole UsingKeywordRole = new TokenRole("using");
public static readonly Role<AstType> ImportRole = new Role<AstType>("Import", AstType.Null); public static readonly Role<AstType> ImportRole = new Role<AstType>("Import", AstType.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs

@ -28,7 +28,8 @@ using System;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class Identifier : AstNode [DecompilerAstNode(hasNullNode: true)]
public partial class Identifier : AstNode
{ {
public new static readonly Identifier Null = new NullIdentifier(); public new static readonly Identifier Null = new NullIdentifier();
sealed class NullIdentifier : Identifier sealed class NullIdentifier : Identifier

3
ICSharpCode.Decompiler/CSharp/Syntax/InvocationAstType.cs

@ -23,7 +23,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// BaseType "(" Argument { "," Argument } ")" /// BaseType "(" Argument { "," Argument } ")"
/// </summary> /// </summary>
public class InvocationAstType : AstType [DecompilerAstNode(hasNullNode: false)]
public partial class InvocationAstType : AstType
{ {
public AstNodeCollection<Expression> Arguments { public AstNodeCollection<Expression> Arguments {
get { return GetChildrenByRole(Roles.Expression); } get { return GetChildrenByRole(Roles.Expression); }

3
ICSharpCode.Decompiler/CSharp/Syntax/MemberType.cs

@ -28,7 +28,8 @@ using System.Collections.Generic;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class MemberType : AstType [DecompilerAstNode(hasNullNode: false)]
public partial class MemberType : AstType
{ {
public static readonly Role<AstType> TargetRole = new Role<AstType>("Target", AstType.Null); public static readonly Role<AstType> TargetRole = new Role<AstType>("Target", AstType.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/PrimitiveType.cs

@ -31,7 +31,8 @@ using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class PrimitiveType : AstType [DecompilerAstNode(hasNullNode: false)]
public partial class PrimitiveType : AstType
{ {
TextLocation location; TextLocation location;
string keyword = string.Empty; string keyword = string.Empty;

3
ICSharpCode.Decompiler/CSharp/Syntax/SimpleType.cs

@ -28,7 +28,8 @@ using System.Collections.Generic;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class SimpleType : AstType [DecompilerAstNode(hasNullNode: true)]
public partial class SimpleType : AstType
{ {
#region Null #region Null
public new static readonly SimpleType Null = new NullSimpleType(); public new static readonly SimpleType Null = new NullSimpleType();

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/BlockStatement.cs

@ -31,7 +31,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// { Statements } /// { Statements }
/// </summary> /// </summary>
public class BlockStatement : Statement, IEnumerable<Statement> [DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public partial class BlockStatement : Statement, IEnumerable<Statement>
{ {
public static readonly Role<Statement> StatementRole = new Role<Statement>("Statement", Statement.Null); public static readonly Role<Statement> StatementRole = new Role<Statement>("Statement", Statement.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/BreakStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// break; /// break;
/// </summary> /// </summary>
public class BreakStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class BreakStatement : Statement
{ {
public static readonly TokenRole BreakKeywordRole = new TokenRole("break"); public static readonly TokenRole BreakKeywordRole = new TokenRole("break");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/CheckedStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// checked BodyBlock /// checked BodyBlock
/// </summary> /// </summary>
public class CheckedStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class CheckedStatement : Statement
{ {
public static readonly TokenRole CheckedKeywordRole = new TokenRole("checked"); public static readonly TokenRole CheckedKeywordRole = new TokenRole("checked");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ContinueStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// continue; /// continue;
/// </summary> /// </summary>
public class ContinueStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class ContinueStatement : Statement
{ {
public static readonly TokenRole ContinueKeywordRole = new TokenRole("continue"); public static readonly TokenRole ContinueKeywordRole = new TokenRole("continue");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/DoWhileStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// "do EmbeddedStatement while(Condition);" /// "do EmbeddedStatement while(Condition);"
/// </summary> /// </summary>
public class DoWhileStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class DoWhileStatement : Statement
{ {
public static readonly TokenRole DoKeywordRole = new TokenRole("do"); public static readonly TokenRole DoKeywordRole = new TokenRole("do");
public static readonly TokenRole WhileKeywordRole = new TokenRole("while"); public static readonly TokenRole WhileKeywordRole = new TokenRole("while");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/EmptyStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// ; /// ;
/// </summary> /// </summary>
public class EmptyStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class EmptyStatement : Statement
{ {
public TextLocation Location { public TextLocation Location {
get; get;

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ExpressionStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Expression; /// Expression;
/// </summary> /// </summary>
public class ExpressionStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class ExpressionStatement : Statement
{ {
public Expression Expression { public Expression Expression {
get { return GetChildByRole(Roles.Expression); } get { return GetChildByRole(Roles.Expression); }

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/FixedStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// fixed (Type Variables) EmbeddedStatement /// fixed (Type Variables) EmbeddedStatement
/// </summary> /// </summary>
public class FixedStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class FixedStatement : Statement
{ {
public static readonly TokenRole FixedKeywordRole = new TokenRole("fixed"); public static readonly TokenRole FixedKeywordRole = new TokenRole("fixed");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ForStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// for (Initializers; Condition; Iterators) EmbeddedStatement /// for (Initializers; Condition; Iterators) EmbeddedStatement
/// </summary> /// </summary>
public class ForStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class ForStatement : Statement
{ {
public static readonly TokenRole ForKeywordRole = new TokenRole("for"); public static readonly TokenRole ForKeywordRole = new TokenRole("for");
public readonly static Role<Statement> InitializerRole = new Role<Statement>("Initializer", Statement.Null); public readonly static Role<Statement> InitializerRole = new Role<Statement>("Initializer", Statement.Null);

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ForeachStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// foreach (Type VariableName in InExpression) EmbeddedStatement /// foreach (Type VariableName in InExpression) EmbeddedStatement
/// </summary> /// </summary>
public class ForeachStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class ForeachStatement : Statement
{ {
public static readonly TokenRole AwaitRole = UnaryOperatorExpression.AwaitRole; public static readonly TokenRole AwaitRole = UnaryOperatorExpression.AwaitRole;
public static readonly TokenRole ForeachKeywordRole = new TokenRole("foreach"); public static readonly TokenRole ForeachKeywordRole = new TokenRole("foreach");

9
ICSharpCode.Decompiler/CSharp/Syntax/Statements/GotoStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// "goto Label;" /// "goto Label;"
/// </summary> /// </summary>
public class GotoStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class GotoStatement : Statement
{ {
public static readonly TokenRole GotoKeywordRole = new TokenRole("goto"); public static readonly TokenRole GotoKeywordRole = new TokenRole("goto");
@ -87,7 +88,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// or "goto case LabelExpression;" /// or "goto case LabelExpression;"
/// </summary> /// </summary>
public class GotoCaseStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class GotoCaseStatement : Statement
{ {
public static readonly TokenRole GotoKeywordRole = new TokenRole("goto"); public static readonly TokenRole GotoKeywordRole = new TokenRole("goto");
public static readonly TokenRole CaseKeywordRole = new TokenRole("case"); public static readonly TokenRole CaseKeywordRole = new TokenRole("case");
@ -137,7 +139,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// or "goto default;" /// or "goto default;"
/// </summary> /// </summary>
public class GotoDefaultStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class GotoDefaultStatement : Statement
{ {
public static readonly TokenRole GotoKeywordRole = new TokenRole("goto"); public static readonly TokenRole GotoKeywordRole = new TokenRole("goto");
public static readonly TokenRole DefaultKeywordRole = new TokenRole("default"); public static readonly TokenRole DefaultKeywordRole = new TokenRole("default");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/IfElseStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// if (Condition) TrueStatement else FalseStatement /// if (Condition) TrueStatement else FalseStatement
/// </summary> /// </summary>
public class IfElseStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class IfElseStatement : Statement
{ {
public readonly static TokenRole IfKeywordRole = new TokenRole("if"); public readonly static TokenRole IfKeywordRole = new TokenRole("if");
public readonly static Role<Expression> ConditionRole = Roles.Condition; public readonly static Role<Expression> ConditionRole = Roles.Condition;

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/LabelStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Label: /// Label:
/// </summary> /// </summary>
public class LabelStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class LabelStatement : Statement
{ {
public string Label { public string Label {
get { get {

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/LocalFunctionDeclarationStatement.cs

@ -20,7 +20,8 @@ using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching;
namespace ICSharpCode.Decompiler.CSharp.Syntax namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
public class LocalFunctionDeclarationStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class LocalFunctionDeclarationStatement : Statement
{ {
public static readonly Role<MethodDeclaration> MethodDeclarationRole = new Role<MethodDeclaration>("Method", null); public static readonly Role<MethodDeclaration> MethodDeclarationRole = new Role<MethodDeclaration>("Method", null);

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/LockStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// lock (Expression) EmbeddedStatement; /// lock (Expression) EmbeddedStatement;
/// </summary> /// </summary>
public class LockStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class LockStatement : Statement
{ {
public static readonly TokenRole LockKeywordRole = new TokenRole("lock"); public static readonly TokenRole LockKeywordRole = new TokenRole("lock");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ReturnStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// return Expression; /// return Expression;
/// </summary> /// </summary>
public class ReturnStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class ReturnStatement : Statement
{ {
public static readonly TokenRole ReturnKeywordRole = new TokenRole("return"); public static readonly TokenRole ReturnKeywordRole = new TokenRole("return");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs

@ -27,7 +27,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// This class is useful even though it doesn't provide any additional functionality: /// This class is useful even though it doesn't provide any additional functionality:
/// It can be used to communicate more information in APIs, e.g. "this subnode will always be a statement" /// It can be used to communicate more information in APIs, e.g. "this subnode will always be a statement"
/// </remarks> /// </remarks>
public abstract class Statement : AstNode [DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public abstract partial class Statement : AstNode
{ {
#region Null #region Null
public new static readonly Statement Null = new NullStatement(); public new static readonly Statement Null = new NullStatement();

9
ICSharpCode.Decompiler/CSharp/Syntax/Statements/SwitchStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// switch (Expression) { SwitchSections } /// switch (Expression) { SwitchSections }
/// </summary> /// </summary>
public class SwitchStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class SwitchStatement : Statement
{ {
public static readonly TokenRole SwitchKeywordRole = new TokenRole("switch"); public static readonly TokenRole SwitchKeywordRole = new TokenRole("switch");
public static readonly Role<SwitchSection> SwitchSectionRole = new Role<SwitchSection>("SwitchSection", null); public static readonly Role<SwitchSection> SwitchSectionRole = new Role<SwitchSection>("SwitchSection", null);
@ -85,7 +86,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class SwitchSection : AstNode [DecompilerAstNode(hasNullNode: false, hasPatternPlaceholder: true)]
public partial class SwitchSection : AstNode
{ {
#region PatternPlaceholder #region PatternPlaceholder
public static implicit operator SwitchSection(PatternMatching.Pattern pattern) public static implicit operator SwitchSection(PatternMatching.Pattern pattern)
@ -171,7 +173,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public class CaseLabel : AstNode [DecompilerAstNode(hasNullNode: false)]
public partial class CaseLabel : AstNode
{ {
public static readonly TokenRole CaseKeywordRole = new TokenRole("case"); public static readonly TokenRole CaseKeywordRole = new TokenRole("case");
public static readonly TokenRole DefaultKeywordRole = new TokenRole("default"); public static readonly TokenRole DefaultKeywordRole = new TokenRole("default");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/ThrowStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// throw Expression; /// throw Expression;
/// </summary> /// </summary>
public class ThrowStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class ThrowStatement : Statement
{ {
public static readonly TokenRole ThrowKeywordRole = new TokenRole("throw"); public static readonly TokenRole ThrowKeywordRole = new TokenRole("throw");

6
ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// try TryBlock CatchClauses finally FinallyBlock /// try TryBlock CatchClauses finally FinallyBlock
/// </summary> /// </summary>
public class TryCatchStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class TryCatchStatement : Statement
{ {
public static readonly TokenRole TryKeywordRole = new TokenRole("try"); public static readonly TokenRole TryKeywordRole = new TokenRole("try");
public static readonly Role<BlockStatement> TryBlockRole = new Role<BlockStatement>("TryBlock", BlockStatement.Null); public static readonly Role<BlockStatement> TryBlockRole = new Role<BlockStatement>("TryBlock", BlockStatement.Null);
@ -84,7 +85,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// catch (Type VariableName) { Body } /// catch (Type VariableName) { Body }
/// </summary> /// </summary>
public class CatchClause : AstNode [DecompilerAstNode(hasNullNode: true, hasPatternPlaceholder: true)]
public partial class CatchClause : AstNode
{ {
public static readonly TokenRole CatchKeywordRole = new TokenRole("catch"); public static readonly TokenRole CatchKeywordRole = new TokenRole("catch");
public static readonly TokenRole WhenKeywordRole = new TokenRole("when"); public static readonly TokenRole WhenKeywordRole = new TokenRole("when");

3
ICSharpCode.Decompiler/CSharp/Syntax/Statements/UncheckedStatement.cs

@ -29,7 +29,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// unchecked BodyBlock /// unchecked BodyBlock
/// </summary> /// </summary>
public class UncheckedStatement : Statement [DecompilerAstNode(hasNullNode: false)]
public partial class UncheckedStatement : Statement
{ {
public static readonly TokenRole UncheckedKeywordRole = new TokenRole("unchecked"); public static readonly TokenRole UncheckedKeywordRole = new TokenRole("unchecked");

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save