diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs b/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs index 3707b0c4b..75a1d5e94 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs @@ -43,45 +43,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax // the Root role must be available when creating the null nodes, so we can't put it in the Roles class internal static readonly Role RootRole = new Role("Root", null); - #region Null - public static readonly AstNode Null = new NullAstNode(); - - sealed class NullAstNode : AstNode - { - public override NodeType NodeType { - get { - return NodeType.Unknown; - } - } - - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode? other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - #region PatternPlaceholder public static implicit operator AstNode?(PatternMatching.Pattern? pattern) { diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs b/ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs index 7734bc98d..7447c8710 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/AstType.cs @@ -31,44 +31,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public abstract partial class AstType : AstNode { - #region Null - public new static readonly AstType Null = new NullAstType(); - - sealed class NullAstType : AstType - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - - public override ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider) - { - return SpecialType.UnknownType; - } - } - #endregion - #region PatternPlaceholder public static implicit operator AstType(PatternMatching.Pattern pattern) { diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs b/ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs index e12b2ce4c..19f5ef080 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs @@ -37,40 +37,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public partial class CSharpTokenNode : AstNode { - public static new readonly CSharpTokenNode Null = new NullCSharpTokenNode(); - class NullCSharpTokenNode : CSharpTokenNode - { - public override bool IsNull { - get { - return true; - } - } - - public NullCSharpTokenNode() : base(TextLocation.Empty, null) - { - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - public override NodeType NodeType { get { return NodeType.Token; diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs index 0765cbabd..0bf14651c 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/ArrayInitializerExpression.cs @@ -60,39 +60,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax this.Elements.AddRange(elements); } - #region Null - public new static readonly ArrayInitializerExpression Null = new NullArrayInitializerExpression(); - - sealed class NullArrayInitializerExpression : ArrayInitializerExpression - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - public CSharpTokenNode LBraceToken { get { return GetChildByRole(Roles.LBrace); } } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs index d48092512..f8f3cf139 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/Expression.cs @@ -17,7 +17,6 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Collections.Generic; namespace ICSharpCode.Decompiler.CSharp.Syntax { @@ -31,39 +30,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public abstract partial class Expression : AstNode { - #region Null - public new static readonly Expression Null = new NullExpression(); - - sealed class NullExpression : Expression - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - #region PatternPlaceholder public static implicit operator Expression(PatternMatching.Pattern pattern) { diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs index 96f3c987b..621faccb7 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; using ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching; @@ -51,39 +49,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public abstract partial class InterpolatedStringContent : AstNode { - #region Null - public new static readonly InterpolatedStringContent Null = new NullInterpolatedStringContent(); - - sealed class NullInterpolatedStringContent : InterpolatedStringContent - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - public new static readonly Role Role = new Role("InterpolatedStringContent", Syntax.InterpolatedStringContent.Null); public override NodeType NodeType => NodeType.Unknown; diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs index 1c9ba8f5a..e3708a69f 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/QueryExpression.cs @@ -23,39 +23,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax { public static readonly Role ClauseRole = new Role("Clause", null); - #region Null - public new static readonly QueryExpression Null = new NullQueryExpression(); - - sealed class NullQueryExpression : QueryExpression - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - public AstNodeCollection Clauses { get { return GetChildrenByRole(ClauseRole); } } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs index e4f1cc784..887a1ca42 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Identifier.cs @@ -31,36 +31,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public partial class Identifier : AstNode { - public new static readonly Identifier Null = new NullIdentifier(); - sealed class NullIdentifier : Identifier - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - public override NodeType NodeType { get { return NodeType.Token; diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/SimpleType.cs b/ICSharpCode.Decompiler/CSharp/Syntax/SimpleType.cs index 0f655465f..6b8ac0c0b 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/SimpleType.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/SimpleType.cs @@ -35,44 +35,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public partial class SimpleType : AstType { - #region Null - public new static readonly SimpleType Null = new NullSimpleType(); - - sealed class NullSimpleType : SimpleType - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - - public override ITypeReference ToTypeReference(NameLookupMode lookupMode, InterningProvider interningProvider) - { - return SpecialType.UnknownType; - } - } - #endregion - public SimpleType() { } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/BlockStatement.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/BlockStatement.cs index 5ec485397..98b8cfbc3 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/BlockStatement.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/BlockStatement.cs @@ -36,38 +36,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax { public static readonly Role StatementRole = new Role("Statement", Statement.Null); - #region Null - public static readonly new BlockStatement Null = new NullBlockStatement(); - sealed class NullBlockStatement : BlockStatement - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - #region PatternPlaceholder public static implicit operator BlockStatement(PatternMatching.Pattern pattern) { diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs index 17910c1e8..8bc13c65f 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs @@ -30,39 +30,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public abstract partial class Statement : AstNode { - #region Null - public new static readonly Statement Null = new NullStatement(); - - sealed class NullStatement : Statement - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - #region PatternPlaceholder public static implicit operator Statement(PatternMatching.Pattern pattern) { diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs index 2d985057f..534d2de11 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs @@ -95,39 +95,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax public static readonly TokenRole CondLPar = new TokenRole("("); public static readonly TokenRole CondRPar = new TokenRole(")"); - #region Null - public new static readonly CatchClause Null = new NullCatchClause(); - - sealed class NullCatchClause : CatchClause - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - #region PatternPlaceholder public static implicit operator CatchClause(PatternMatching.Pattern pattern) { diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TupleAstType.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TupleAstType.cs index 2221d2ecf..73fcb8e8d 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TupleAstType.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TupleAstType.cs @@ -66,39 +66,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public partial class TupleTypeElement : AstNode { - #region Null - public new static readonly TupleTypeElement Null = new TupleTypeElement(); - - sealed class NullTupleTypeElement : TupleTypeElement - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - public AstType Type { get { return GetChildByRole(Roles.Type); } set { SetChildByRole(Roles.Type, value); } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs index 12eeb08af..2d76d17a2 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs @@ -34,36 +34,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public partial class Accessor : EntityDeclaration { - public static readonly new Accessor Null = new NullAccessor(); - sealed class NullAccessor : Accessor - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - public override NodeType NodeType { get { return NodeType.Unknown; } } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs index a95a66cbb..7456972cb 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/ConstructorDeclaration.cs @@ -99,42 +99,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax public static readonly TokenRole BaseKeywordRole = new TokenRole("base"); public static readonly TokenRole ThisKeywordRole = new TokenRole("this"); - public static readonly new ConstructorInitializer Null = new NullConstructorInitializer(); - class NullConstructorInitializer : ConstructorInitializer - { - public override NodeType NodeType { - get { - return NodeType.Unknown; - } - } - - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - public override NodeType NodeType { get { return NodeType.Unknown; diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/VariableInitializer.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/VariableInitializer.cs index 2b547c1de..626c4c03d 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/VariableInitializer.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/VariableInitializer.cs @@ -30,39 +30,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [DecompilerAstNode(true)] public partial class VariableInitializer : AstNode { - #region Null - public new static readonly VariableInitializer Null = new NullVariableInitializer(); - - sealed class NullVariableInitializer : VariableInitializer - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - #region PatternPlaceholder public static implicit operator VariableInitializer(PatternMatching.Pattern pattern) { diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/VariableDesignation.cs b/ICSharpCode.Decompiler/CSharp/Syntax/VariableDesignation.cs index 9cef6f308..2292a6094 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/VariableDesignation.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/VariableDesignation.cs @@ -24,40 +24,6 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax public abstract partial class VariableDesignation : AstNode { public override NodeType NodeType => NodeType.Unknown; - - #region Null - public new static readonly VariableDesignation Null = new NullVariableDesignation(); - - sealed class NullVariableDesignation : VariableDesignation - { - public override bool IsNull { - get { - return true; - } - } - - public override void AcceptVisitor(IAstVisitor visitor) - { - visitor.VisitNullNode(this); - } - - public override T AcceptVisitor(IAstVisitor visitor) - { - return visitor.VisitNullNode(this); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNullNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - } ///