diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeIntermediateNode.cs index fc848e872b..d786e8eb26 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeIntermediateNode.cs @@ -9,12 +9,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions { internal sealed class PreallocatedTagHelperHtmlAttributeIntermediateNode : ExtensionIntermediateNode { - public override RazorDiagnosticCollection Diagnostics { get; } = ReadOnlyDiagnosticCollection.Instance; - public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; - public override bool HasDiagnostics => false; - public string VariableName { get; set; } public override void Accept(IntermediateNodeVisitor visitor) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeValueIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeValueIntermediateNode.cs index 8fdac24c98..80eb93b27f 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeValueIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperHtmlAttributeValueIntermediateNode.cs @@ -33,12 +33,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions } } - public override RazorDiagnosticCollection Diagnostics { get; } = ReadOnlyDiagnosticCollection.Instance; - public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; - public override bool HasDiagnostics => false; - public string VariableName { get; set; } public string AttributeName { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyIntermediateNode.cs index 080c5e8210..2fff1cc874 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyIntermediateNode.cs @@ -30,12 +30,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions TagHelper = propertyNode.TagHelper; } - public override RazorDiagnosticCollection Diagnostics => ReadOnlyDiagnosticCollection.Instance; - public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; - public override bool HasDiagnostics => false; - public string AttributeName { get; set; } public AttributeStructure AttributeStructure { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyValueIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyValueIntermediateNode.cs index a7f677609d..067f13fda1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyValueIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Extensions/PreallocatedTagHelperPropertyValueIntermediateNode.cs @@ -9,12 +9,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions { internal sealed class PreallocatedTagHelperPropertyValueIntermediateNode : ExtensionIntermediateNode { - public override RazorDiagnosticCollection Diagnostics { get; } = ReadOnlyDiagnosticCollection.Instance; - public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; - public override bool HasDiagnostics => false; - public string VariableName { get; set; } public string AttributeName { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeAttributeValueIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeAttributeValueIntermediateNode.cs index 7a6a1a0b4e..cb2fe554c2 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeAttributeValueIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeAttributeValueIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class CSharpCodeAttributeValueIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string Prefix { get; set; } public override void Accept(IntermediateNodeVisitor visitor) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeIntermediateNode.cs index f02fc81ebe..74577572aa 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpCodeIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class CSharpCodeIntermediateNode : IntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public override void Accept(IntermediateNodeVisitor visitor) { if (visitor == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionAttributeValueIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionAttributeValueIntermediateNode.cs index b9a6d0e1ab..413ab8ed25 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionAttributeValueIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionAttributeValueIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class CSharpExpressionAttributeValueIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string Prefix { get; set; } public override void Accept(IntermediateNodeVisitor visitor) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionIntermediateNode.cs index 6793badc71..889bc6f134 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/CSharpExpressionIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class CSharpExpressionIntermediateNode : IntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public override void Accept(IntermediateNodeVisitor visitor) { if (visitor == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ClassDeclarationIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ClassDeclarationIntermediateNode.cs index 4bf3626ed7..14be3bf113 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ClassDeclarationIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ClassDeclarationIntermediateNode.cs @@ -8,41 +8,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class ClassDeclarationIntermediateNode : MemberDeclarationIntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public IList Modifiers { get; } = new List(); public string Name { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveIntermediateNode.cs index 059321b02c..de92bcba27 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveIntermediateNode.cs @@ -8,41 +8,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class DirectiveIntermediateNode : IntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string Name { get; set; } public IEnumerable Tokens => Children.OfType(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIntermediateNode.cs index 5682f7c762..1187a4fb75 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DirectiveTokenIntermediateNode.cs @@ -5,41 +5,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class DirectiveTokenIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string Content { get; set; } public DirectiveTokenDescriptor Descriptor { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DocumentIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DocumentIntermediateNode.cs index c4dfdbe261..7564cbb03c 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DocumentIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/DocumentIntermediateNode.cs @@ -8,45 +8,12 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class DocumentIntermediateNode : IntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); public string DocumentKind { get; set; } public RazorCodeGenerationOptions Options { get; set; } - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public CodeTarget Target { get; set; } public override void Accept(IntermediateNodeVisitor visitor) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ExtensionIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ExtensionIntermediateNode.cs index f744337486..2b909da7ae 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ExtensionIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ExtensionIntermediateNode.cs @@ -8,39 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public abstract class ExtensionIntermediateNode : IntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public abstract void WriteNode(CodeTarget target, CodeRenderingContext context); protected static void AcceptExtensionNode(TNode node, IntermediateNodeVisitor visitor) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/FieldDeclarationIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/FieldDeclarationIntermediateNode.cs index 28c40c47ff..d93e4ef06e 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/FieldDeclarationIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/FieldDeclarationIntermediateNode.cs @@ -8,41 +8,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class FieldDeclarationIntermediateNode : MemberDeclarationIntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public IList Modifiers { get; } = new List(); public string Name { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeIntermediateNode.cs index 8233f937c1..e8861673b5 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class HtmlAttributeIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string AttributeName { get; set; } public string Prefix { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeValueIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeValueIntermediateNode.cs index b491758233..dc85dea404 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeValueIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlAttributeValueIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class HtmlAttributeValueIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string Prefix { get; set; } public override void Accept(IntermediateNodeVisitor visitor) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlContentIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlContentIntermediateNode.cs index 3a058a4e8d..acf0f6d064 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlContentIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/HtmlContentIntermediateNode.cs @@ -2,47 +2,13 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class HtmlContentIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public override void Accept(IntermediateNodeVisitor visitor) { if (visitor == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNode.cs index e7ae9847db..96f55a3de1 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateNode.cs @@ -5,16 +5,41 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public abstract class IntermediateNode { - public abstract ItemCollection Annotations { get; } + private ItemCollection _annotations; + private RazorDiagnosticCollection _diagnostics; + + public ItemCollection Annotations + { + get + { + if (_annotations == null) + { + _annotations = new DefaultItemCollection(); + } + + return _annotations; + } + } - public abstract RazorDiagnosticCollection Diagnostics { get; } - public abstract IntermediateNodeCollection Children { get; } - public abstract SourceSpan? Source { get; set; } + public RazorDiagnosticCollection Diagnostics + { + get + { + if (_diagnostics == null) + { + _diagnostics = new DefaultRazorDiagnosticCollection(); + } - public abstract bool HasDiagnostics { get; } + return _diagnostics; + } + } + public bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; + + public SourceSpan? Source { get; set; } + public abstract void Accept(IntermediateNodeVisitor visitor); } } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateToken.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateToken.cs index 72059d96c0..440f2d8747 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateToken.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/IntermediateToken.cs @@ -7,35 +7,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class IntermediateToken : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; public string Content { get; set; } @@ -46,10 +17,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate public TokenKind Kind { get; set; } = TokenKind.Unknown; - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public override void Accept(IntermediateNodeVisitor visitor) { if (visitor == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MalformedDirectiveIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MalformedDirectiveIntermediateNode.cs index 3dd07c2e7a..5d87ec48da 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MalformedDirectiveIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MalformedDirectiveIntermediateNode.cs @@ -8,29 +8,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class MalformedDirectiveIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations { get; } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string Name { get; set; } public IEnumerable Tokens => Children.OfType(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MethodDeclarationIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MethodDeclarationIntermediateNode.cs index 6d1250d27b..04e77d2d78 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MethodDeclarationIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MethodDeclarationIntermediateNode.cs @@ -8,41 +8,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class MethodDeclarationIntermediateNode : MemberDeclarationIntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public IList Modifiers { get; } = new List(); public string Name { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/NamespaceDeclarationIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/NamespaceDeclarationIntermediateNode.cs index 080431a4d7..55585a78f0 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/NamespaceDeclarationIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/NamespaceDeclarationIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class NamespaceDeclarationIntermediateNode : IntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string Content { get; set; } public override void Accept(IntermediateNodeVisitor visitor) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/PropertyDeclarationIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/PropertyDeclarationIntermediateNode.cs index 56ba2d48f4..175fdfab47 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/PropertyDeclarationIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/PropertyDeclarationIntermediateNode.cs @@ -8,40 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class PropertyDeclarationIntermediateNode : MemberDeclarationIntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; - - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; public IList Modifiers { get; } = new List(); diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperBodyIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperBodyIntermediateNode.cs index 557b4a66b1..376098a757 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperBodyIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperBodyIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class TagHelperBodyIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public override void Accept(IntermediateNodeVisitor visitor) { if (visitor == null) diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperHtmlAttributeIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperHtmlAttributeIntermediateNode.cs index 3c3040f155..27c283e854 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperHtmlAttributeIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperHtmlAttributeIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class TagHelperHtmlAttributeIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string AttributeName { get; set; } public AttributeStructure AttributeStructure { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperIntermediateNode.cs index 654d0d540f..971cffff12 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperIntermediateNode.cs @@ -9,41 +9,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class TagHelperIntermediateNode : IntermediateNode { - private ItemCollection _annotations; - private RazorDiagnosticCollection _diagnostics; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string TagName { get; set; } public TagMode TagMode { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperPropertyIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperPropertyIntermediateNode.cs index 148a4b4f81..99b9df22ab 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperPropertyIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/TagHelperPropertyIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class TagHelperPropertyIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string AttributeName { get; set; } public AttributeStructure AttributeStructure { get; set; } diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/UsingDirectiveIntermediateNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/UsingDirectiveIntermediateNode.cs index a82cab5da1..9da19e4560 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/UsingDirectiveIntermediateNode.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/UsingDirectiveIntermediateNode.cs @@ -7,41 +7,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate { public sealed class UsingDirectiveIntermediateNode : IntermediateNode { - private RazorDiagnosticCollection _diagnostics; - private ItemCollection _annotations; - - public override ItemCollection Annotations - { - get - { - if (_annotations == null) - { - _annotations = new DefaultItemCollection(); - } - - return _annotations; - } - } - - public override RazorDiagnosticCollection Diagnostics - { - get - { - if (_diagnostics == null) - { - _diagnostics = new DefaultRazorDiagnosticCollection(); - } - - return _diagnostics; - } - } - public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => _diagnostics != null && _diagnostics.Count > 0; - public string Content { get; set; } public override void Accept(IntermediateNodeVisitor visitor) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeNodeWriterTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeNodeWriterTest.cs index eaccb542a4..3cd7915d4e 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeNodeWriterTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/CodeGeneration/RuntimeNodeWriterTest.cs @@ -609,8 +609,6 @@ WriteAttributeValue("" "", 27, false, 28, 6, false); { public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance; - public override SourceSpan? Source { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public override void Accept(IntermediateNodeVisitor visitor) { throw new NotImplementedException(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/DefaultRazorIntermediateNodeBuilderTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/DefaultRazorIntermediateNodeBuilderTest.cs index 63b5346f63..affdfdeab0 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/DefaultRazorIntermediateNodeBuilderTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/DefaultRazorIntermediateNodeBuilderTest.cs @@ -206,16 +206,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate private class BasicIntermediateNode : IntermediateNode { - public override ItemCollection Annotations { get; } = new DefaultItemCollection(); - - public override RazorDiagnosticCollection Diagnostics { get; } = new DefaultRazorDiagnosticCollection(); - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => Diagnostics.Count > 0; - public override void Accept(IntermediateNodeVisitor visitor) { throw new NotImplementedException(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/IntermediateNodeReferenceTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/IntermediateNodeReferenceTest.cs index 9835466576..ea8f1286f4 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/IntermediateNodeReferenceTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/IntermediateNodeReferenceTest.cs @@ -497,16 +497,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate public string Name { get; } - public override ItemCollection Annotations { get; } = new DefaultItemCollection(); - - public override RazorDiagnosticCollection Diagnostics => new DefaultRazorDiagnosticCollection(); - public override IntermediateNodeCollection Children { get; } - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => Diagnostics.Count > 0; - public override void Accept(IntermediateNodeVisitor visitor) { throw new System.NotImplementedException(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/IntermediateNodeWalkerTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/IntermediateNodeWalkerTest.cs index bee4440eb3..70207317f3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/IntermediateNodeWalkerTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/IntermediateNodeWalkerTest.cs @@ -124,16 +124,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate public string Name { get; } - public override ItemCollection Annotations { get; } = new DefaultItemCollection(); - - public override RazorDiagnosticCollection Diagnostics { get; } = new DefaultRazorDiagnosticCollection(); - public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection(); - public override SourceSpan? Source { get; set; } - - public override bool HasDiagnostics => Diagnostics.Count > 0; - public override void Accept(IntermediateNodeVisitor visitor) { ((DerivedIntermediateNodeWalker)visitor).VisitBasic(this);