Streamline collections
Makes our collections sealed instead of abstract. Only the IntermediateNodeCollection needs to have a read only variant.
This commit is contained in:
parent
d36838ed88
commit
8dfba25d59
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
|
||||
public string MemberName { get; set; }
|
||||
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
_documentNode = documentNode;
|
||||
Options = options;
|
||||
|
||||
Diagnostics = new DefaultRazorDiagnosticCollection();
|
||||
Items = new DefaultItemCollection();
|
||||
Diagnostics = new RazorDiagnosticCollection();
|
||||
Items = new ItemCollection();
|
||||
LineMappings = new List<LineMapping>();
|
||||
|
||||
TagHelperRenderingContext = new TagHelperRenderingContext();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
internal class DefaultAllowedChildTagDescriptorBuilder : AllowedChildTagDescriptorBuilder
|
||||
{
|
||||
private readonly DefaultTagHelperDescriptorBuilder _parent;
|
||||
private DefaultRazorDiagnosticCollection _diagnostics;
|
||||
private RazorDiagnosticCollection _diagnostics;
|
||||
|
||||
public DefaultAllowedChildTagDescriptorBuilder(DefaultTagHelperDescriptorBuilder parent)
|
||||
{
|
||||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
if (_diagnostics == null)
|
||||
{
|
||||
_diagnostics = new DefaultRazorDiagnosticCollection();
|
||||
_diagnostics = new RazorDiagnosticCollection();
|
||||
}
|
||||
|
||||
return _diagnostics;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
private readonly string _kind;
|
||||
private readonly Dictionary<string, string> _metadata;
|
||||
|
||||
private DefaultRazorDiagnosticCollection _diagnostics;
|
||||
private RazorDiagnosticCollection _diagnostics;
|
||||
|
||||
public DefaultBoundAttributeDescriptorBuilder(DefaultTagHelperDescriptorBuilder parent, string kind)
|
||||
{
|
||||
|
|
@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
if (_diagnostics == null)
|
||||
{
|
||||
_diagnostics = new DefaultRazorDiagnosticCollection();
|
||||
_diagnostics = new RazorDiagnosticCollection();
|
||||
}
|
||||
|
||||
return _diagnostics;
|
||||
|
|
|
|||
|
|
@ -1,116 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// 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
|
||||
{
|
||||
internal class DefaultItemCollection : ItemCollection
|
||||
{
|
||||
private readonly Dictionary<object, object> _items;
|
||||
|
||||
public DefaultItemCollection()
|
||||
{
|
||||
_items = new Dictionary<object, object>();
|
||||
}
|
||||
|
||||
public override object this[object key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
object value;
|
||||
_items.TryGetValue(key, out value);
|
||||
return value;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
_items[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Count => _items.Count;
|
||||
|
||||
public override bool IsReadOnly => false;
|
||||
|
||||
public override void Add(object key, object value)
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
_items.Add(key, value);
|
||||
}
|
||||
|
||||
public override void Add(KeyValuePair<object, object> item)
|
||||
{
|
||||
if (item.Key == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.KeyMustNotBeNull, nameof(item));
|
||||
}
|
||||
|
||||
((ICollection<KeyValuePair<object, object>>)_items).Add(item);
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
_items.Clear();
|
||||
}
|
||||
|
||||
public override bool Contains(KeyValuePair<object, object> item)
|
||||
{
|
||||
if (item.Key == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.KeyMustNotBeNull, nameof(item));
|
||||
}
|
||||
|
||||
return ((ICollection<KeyValuePair<object, object>>)_items).Contains(item);
|
||||
}
|
||||
|
||||
public override void CopyTo(KeyValuePair<object, object>[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
else if (array.Length - arrayIndex < Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
|
||||
((ICollection<KeyValuePair<object, object>>)_items).CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public override IEnumerator<KeyValuePair<object, object>> GetEnumerator()
|
||||
{
|
||||
return _items.GetEnumerator();
|
||||
}
|
||||
|
||||
public override bool Remove(KeyValuePair<object, object> item)
|
||||
{
|
||||
if (item.Key == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.KeyMustNotBeNull, nameof(item));
|
||||
}
|
||||
|
||||
return ((ICollection<KeyValuePair<object, object>>)_items).Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
Source = source;
|
||||
Imports = imports?.ToArray() ?? RazorSourceDocument.EmptyArray;
|
||||
|
||||
Items = new DefaultItemCollection();
|
||||
Items = new ItemCollection();
|
||||
}
|
||||
|
||||
public override IReadOnlyList<RazorSourceDocument> Imports { get; }
|
||||
|
|
|
|||
|
|
@ -1,128 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// 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
|
||||
{
|
||||
public sealed class DefaultRazorDiagnosticCollection : RazorDiagnosticCollection
|
||||
{
|
||||
private readonly List<RazorDiagnostic> _inner = new List<RazorDiagnostic>();
|
||||
|
||||
public override RazorDiagnostic this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
return _inner[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
_inner[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Count => _inner.Count;
|
||||
|
||||
public override bool IsReadOnly => false;
|
||||
|
||||
public override void Add(RazorDiagnostic item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
_inner.Add(item);
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
_inner.Clear();
|
||||
}
|
||||
|
||||
public override bool Contains(RazorDiagnostic item)
|
||||
{
|
||||
return _inner.Contains(item);
|
||||
}
|
||||
|
||||
public override void CopyTo(RazorDiagnostic[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
else if (array.Length - arrayIndex < Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
|
||||
_inner.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public override IEnumerator<RazorDiagnostic> GetEnumerator()
|
||||
{
|
||||
return _inner.GetEnumerator();
|
||||
}
|
||||
|
||||
public override int IndexOf(RazorDiagnostic item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return _inner.IndexOf(item);
|
||||
}
|
||||
|
||||
public override void Insert(int index, RazorDiagnostic item)
|
||||
{
|
||||
if (index < 0 || index > Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
_inner.Insert(index, item);
|
||||
}
|
||||
|
||||
public override bool Remove(RazorDiagnostic item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return _inner.Remove(item);
|
||||
}
|
||||
|
||||
public override void RemoveAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
_inner.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
internal class DefaultRequiredAttributeDescriptorBuilder : RequiredAttributeDescriptorBuilder
|
||||
{
|
||||
private DefaultRazorDiagnosticCollection _diagnostics;
|
||||
private RazorDiagnosticCollection _diagnostics;
|
||||
|
||||
public override string Name { get; set; }
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
if (_diagnostics == null)
|
||||
{
|
||||
_diagnostics = new DefaultRazorDiagnosticCollection();
|
||||
_diagnostics = new RazorDiagnosticCollection();
|
||||
}
|
||||
|
||||
return _diagnostics;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
private List<DefaultAllowedChildTagDescriptorBuilder> _allowedChildTags;
|
||||
private List<DefaultBoundAttributeDescriptorBuilder> _attributeBuilders;
|
||||
private List<DefaultTagMatchingRuleDescriptorBuilder> _tagMatchingRuleBuilders;
|
||||
private DefaultRazorDiagnosticCollection _diagnostics;
|
||||
private RazorDiagnosticCollection _diagnostics;
|
||||
|
||||
public DefaultTagHelperDescriptorBuilder(string kind, string name, string assemblyName)
|
||||
{
|
||||
|
|
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
if (_diagnostics == null)
|
||||
{
|
||||
_diagnostics = new DefaultRazorDiagnosticCollection();
|
||||
_diagnostics = new RazorDiagnosticCollection();
|
||||
}
|
||||
|
||||
return _diagnostics;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
internal class DefaultTagMatchingRuleDescriptorBuilder : TagMatchingRuleDescriptorBuilder
|
||||
{
|
||||
private List<DefaultRequiredAttributeDescriptorBuilder> _requiredAttributeBuilders;
|
||||
private DefaultRazorDiagnosticCollection _diagnostics;
|
||||
private RazorDiagnosticCollection _diagnostics;
|
||||
|
||||
internal DefaultTagMatchingRuleDescriptorBuilder()
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
if (_diagnostics == null)
|
||||
{
|
||||
_diagnostics = new DefaultRazorDiagnosticCollection();
|
||||
_diagnostics = new RazorDiagnosticCollection();
|
||||
}
|
||||
|
||||
return _diagnostics;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public TagMode TagMode { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
{
|
||||
public sealed class DefaultTagHelperCreateIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children { get; } = IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public string Field { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
{
|
||||
public sealed class DefaultTagHelperExecuteIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children { get; } = IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
|
||||
public AttributeStructure AttributeStructure { get; set; }
|
||||
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string AttributeName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
{
|
||||
public sealed class DefaultTagHelperRuntimeIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
{
|
||||
internal sealed class DesignTimeDirectiveIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
{
|
||||
internal sealed class PreallocatedTagHelperHtmlAttributeIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public string VariableName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public string VariableName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
TagHelper = propertyNode.TagHelper;
|
||||
}
|
||||
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public string AttributeName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
{
|
||||
internal sealed class PreallocatedTagHelperPropertyValueIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public string VariableName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
{
|
||||
public sealed class SectionIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
|||
{
|
||||
public sealed class TemplateIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class CSharpCodeAttributeValueIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string Prefix { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class CSharpCodeIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class CSharpExpressionAttributeValueIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string Prefix { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class CSharpExpressionIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class ClassDeclarationIntermediateNode : MemberDeclarationIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public IList<string> Modifiers { get; } = new List<string>();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,128 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// 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 DefaultIntermediateNodeCollection : IntermediateNodeCollection
|
||||
{
|
||||
private readonly List<IntermediateNode> _inner = new List<IntermediateNode>();
|
||||
|
||||
public override IntermediateNode this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
return _inner[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
_inner[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Count => _inner.Count;
|
||||
|
||||
public override bool IsReadOnly => false;
|
||||
|
||||
public override void Add(IntermediateNode item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
_inner.Add(item);
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
_inner.Clear();
|
||||
}
|
||||
|
||||
public override bool Contains(IntermediateNode item)
|
||||
{
|
||||
return _inner.Contains(item);
|
||||
}
|
||||
|
||||
public override void CopyTo(IntermediateNode[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
else if (array.Length - arrayIndex < Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
|
||||
_inner.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public override IEnumerator<IntermediateNode> GetEnumerator()
|
||||
{
|
||||
return _inner.GetEnumerator();
|
||||
}
|
||||
|
||||
public override int IndexOf(IntermediateNode item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return _inner.IndexOf(item);
|
||||
}
|
||||
|
||||
public override void Insert(int index, IntermediateNode item)
|
||||
{
|
||||
if (index < 0 || index > Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
_inner.Insert(index, item);
|
||||
}
|
||||
|
||||
public override bool Remove(IntermediateNode item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return _inner.Remove(item);
|
||||
}
|
||||
|
||||
public override void RemoveAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
_inner.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class DirectiveIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class DirectiveTokenIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public string Content { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class DocumentIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string DocumentKind { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class FieldDeclarationIntermediateNode : MemberDeclarationIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public IList<string> Modifiers { get; } = new List<string>();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class HtmlAttributeIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string AttributeName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class HtmlAttributeValueIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string Prefix { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class HtmlContentIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
if (_annotations == null)
|
||||
{
|
||||
_annotations = new DefaultItemCollection();
|
||||
_annotations = new ItemCollection();
|
||||
}
|
||||
|
||||
return _annotations;
|
||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
if (_diagnostics == null)
|
||||
{
|
||||
_diagnostics = new DefaultRazorDiagnosticCollection();
|
||||
_diagnostics = new RazorDiagnosticCollection();
|
||||
}
|
||||
|
||||
return _diagnostics;
|
||||
|
|
|
|||
|
|
@ -1,40 +1,198 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public abstract class IntermediateNodeCollection : IList<IntermediateNode>
|
||||
public sealed class IntermediateNodeCollection : IList<IntermediateNode>
|
||||
{
|
||||
public abstract IntermediateNode this[int index] { get; set; }
|
||||
public static readonly IntermediateNodeCollection ReadOnly = new IntermediateNodeCollection(new List<IntermediateNode>().AsReadOnly());
|
||||
|
||||
public abstract int Count { get; }
|
||||
private readonly IList<IntermediateNode> _inner;
|
||||
|
||||
public abstract bool IsReadOnly { get; }
|
||||
public IntermediateNodeCollection()
|
||||
: this(new List<IntermediateNode>())
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void Add(IntermediateNode item);
|
||||
private IntermediateNodeCollection(IList<IntermediateNode> inner)
|
||||
{
|
||||
_inner = inner;
|
||||
}
|
||||
|
||||
public abstract void Clear();
|
||||
public IntermediateNode this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
public abstract bool Contains(IntermediateNode item);
|
||||
return _inner[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
public abstract void CopyTo(IntermediateNode[] array, int arrayIndex);
|
||||
_inner[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract IEnumerator<IntermediateNode> GetEnumerator();
|
||||
public int Count => _inner.Count;
|
||||
|
||||
public abstract int IndexOf(IntermediateNode item);
|
||||
public bool IsReadOnly => _inner.IsReadOnly;
|
||||
|
||||
public abstract void Insert(int index, IntermediateNode item);
|
||||
public void Add(IntermediateNode item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
public abstract bool Remove(IntermediateNode item);
|
||||
_inner.Add(item);
|
||||
}
|
||||
|
||||
public abstract void RemoveAt(int index);
|
||||
public void Clear()
|
||||
{
|
||||
_inner.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(IntermediateNode item)
|
||||
{
|
||||
return _inner.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(IntermediateNode[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
else if (array.Length - arrayIndex < Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
|
||||
_inner.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return new Enumerator(this);
|
||||
}
|
||||
|
||||
IEnumerator<IntermediateNode> IEnumerable<IntermediateNode>.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public int IndexOf(IntermediateNode item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return _inner.IndexOf(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, IntermediateNode item)
|
||||
{
|
||||
if (index < 0 || index > Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
_inner.Insert(index, item);
|
||||
}
|
||||
|
||||
public bool Remove(IntermediateNode item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return _inner.Remove(item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
_inner.RemoveAt(index);
|
||||
}
|
||||
|
||||
public struct Enumerator : IEnumerator<IntermediateNode>
|
||||
{
|
||||
private readonly IList<IntermediateNode> _items;
|
||||
private int _index;
|
||||
|
||||
public Enumerator(IntermediateNodeCollection collection)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(collection));
|
||||
}
|
||||
|
||||
_items = collection._inner;
|
||||
_index = -1;
|
||||
}
|
||||
|
||||
public IntermediateNode Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_index < 0 || _index >= _items.Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _items[_index];
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
_index++;
|
||||
return _index < _items.Count;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_index = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class IntermediateToken : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public string Content { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class MalformedDirectiveIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class MethodDeclarationIntermediateNode : MemberDeclarationIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public IList<string> Modifiers { get; } = new List<string>();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class NamespaceDeclarationIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string Content { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class PropertyDeclarationIntermediateNode : MemberDeclarationIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public IList<string> Modifiers { get; } = new List<string>();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,133 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
||||
{
|
||||
public sealed class ReadOnlyIntermediateNodeCollection : IntermediateNodeCollection
|
||||
{
|
||||
public static readonly ReadOnlyIntermediateNodeCollection Instance = new ReadOnlyIntermediateNodeCollection();
|
||||
|
||||
private ReadOnlyIntermediateNodeCollection()
|
||||
{
|
||||
}
|
||||
|
||||
public override IntermediateNode this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
throw null; // Unreachable
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
throw null; // Unreachable
|
||||
}
|
||||
}
|
||||
|
||||
public override int Count => 0;
|
||||
|
||||
public override bool IsReadOnly => true;
|
||||
|
||||
public override void Add(IntermediateNode item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override bool Contains(IntermediateNode item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void CopyTo(IntermediateNode[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
else if (array.Length - arrayIndex < Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override IEnumerator<IntermediateNode> GetEnumerator()
|
||||
{
|
||||
return Enumerable.Empty<IntermediateNode>().GetEnumerator();
|
||||
}
|
||||
|
||||
public override int IndexOf(IntermediateNode item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override void Insert(int index, IntermediateNode item)
|
||||
{
|
||||
if (index < 0 || index > Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override bool Remove(IntermediateNode item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void RemoveAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class TagHelperBodyIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class TagHelperHtmlAttributeIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string AttributeName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class TagHelperIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public TagMode TagMode { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class TagHelperPropertyIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public string AttributeName { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
{
|
||||
public sealed class UsingDirectiveIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public string Content { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +1,124 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language
|
||||
{
|
||||
public abstract class ItemCollection : ICollection<KeyValuePair<object, object>>
|
||||
public sealed class ItemCollection : ICollection<KeyValuePair<object, object>>
|
||||
{
|
||||
public abstract object this[object key] { get; set; }
|
||||
private readonly Dictionary<object, object> _inner;
|
||||
|
||||
public abstract int Count { get; }
|
||||
public ItemCollection()
|
||||
{
|
||||
_inner = new Dictionary<object, object>();
|
||||
}
|
||||
|
||||
public abstract bool IsReadOnly { get; }
|
||||
public object this[object key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
_inner.TryGetValue(key, out var value);
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
public abstract void Add(object key, object value);
|
||||
_inner[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Add(KeyValuePair<object, object> item);
|
||||
public int Count => _inner.Count;
|
||||
|
||||
public abstract void Clear();
|
||||
public bool IsReadOnly => _inner != null;
|
||||
|
||||
public abstract bool Contains(KeyValuePair<object, object> item);
|
||||
int ICollection<KeyValuePair<object, object>>.Count => throw new NotImplementedException();
|
||||
|
||||
public abstract void CopyTo(KeyValuePair<object, object>[] array, int arrayIndex);
|
||||
bool ICollection<KeyValuePair<object, object>>.IsReadOnly => throw new NotImplementedException();
|
||||
|
||||
public abstract IEnumerator<KeyValuePair<object, object>> GetEnumerator();
|
||||
public void Add(KeyValuePair<object, object> item)
|
||||
{
|
||||
if (item.Key == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.KeyMustNotBeNull, nameof(item));
|
||||
}
|
||||
|
||||
public abstract bool Remove(KeyValuePair<object, object> item);
|
||||
((ICollection<KeyValuePair<object, object>>)_inner).Add(item);
|
||||
}
|
||||
|
||||
public void Add(object key, object value)
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
_inner.Add(key, value);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_inner.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<object, object> item)
|
||||
{
|
||||
if (item.Key == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.KeyMustNotBeNull, nameof(item));
|
||||
}
|
||||
|
||||
return ((ICollection<KeyValuePair<object, object>>)_inner).Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<object, object>[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
else if (array.Length - arrayIndex < Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
|
||||
((ICollection<KeyValuePair<object, object>>)_inner).CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<object, object>> GetEnumerator()
|
||||
{
|
||||
return _inner.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public bool Remove(KeyValuePair<object, object> item)
|
||||
{
|
||||
if (item.Key == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.KeyMustNotBeNull, nameof(item));
|
||||
}
|
||||
|
||||
return ((ICollection<KeyValuePair<object, object>>)_inner).Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,191 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language
|
||||
{
|
||||
public abstract class RazorDiagnosticCollection : IList<RazorDiagnostic>
|
||||
public sealed class RazorDiagnosticCollection : IList<RazorDiagnostic>
|
||||
{
|
||||
public abstract RazorDiagnostic this[int index] { get; set; }
|
||||
private readonly List<RazorDiagnostic> _inner;
|
||||
|
||||
public abstract int Count { get; }
|
||||
public RazorDiagnosticCollection()
|
||||
{
|
||||
_inner = new List<RazorDiagnostic>();
|
||||
}
|
||||
|
||||
public abstract bool IsReadOnly { get; }
|
||||
public RazorDiagnostic this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
public abstract void Add(RazorDiagnostic item);
|
||||
return _inner[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
public abstract void Clear();
|
||||
_inner[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract bool Contains(RazorDiagnostic item);
|
||||
public int Count => _inner.Count;
|
||||
|
||||
public abstract void CopyTo(RazorDiagnostic[] array, int arrayIndex);
|
||||
public bool IsReadOnly => _inner != null;
|
||||
|
||||
public abstract IEnumerator<RazorDiagnostic> GetEnumerator();
|
||||
public void Add(RazorDiagnostic item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
public abstract int IndexOf(RazorDiagnostic item);
|
||||
_inner.Add(item);
|
||||
}
|
||||
|
||||
public abstract void Insert(int index, RazorDiagnostic item);
|
||||
public void Clear()
|
||||
{
|
||||
_inner.Clear();
|
||||
}
|
||||
|
||||
public abstract bool Remove(RazorDiagnostic item);
|
||||
public bool Contains(RazorDiagnostic item)
|
||||
{
|
||||
return _inner.Contains(item);
|
||||
}
|
||||
|
||||
public abstract void RemoveAt(int index);
|
||||
public void CopyTo(RazorDiagnostic[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
else if (array.Length - arrayIndex < Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
|
||||
_inner.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return new Enumerator(this);
|
||||
}
|
||||
|
||||
IEnumerator<RazorDiagnostic> IEnumerable<RazorDiagnostic>.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public int IndexOf(RazorDiagnostic item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return _inner.IndexOf(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, RazorDiagnostic item)
|
||||
{
|
||||
if (index < 0 || index > Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
_inner.Insert(index, item);
|
||||
}
|
||||
|
||||
public bool Remove(RazorDiagnostic item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return _inner.Remove(item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
_inner.RemoveAt(index);
|
||||
}
|
||||
|
||||
public struct Enumerator : IEnumerator<RazorDiagnostic>
|
||||
{
|
||||
private readonly IList<RazorDiagnostic> _items;
|
||||
private int _index;
|
||||
|
||||
public Enumerator(RazorDiagnosticCollection collection)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(collection));
|
||||
}
|
||||
|
||||
_items = collection._inner;
|
||||
_index = -1;
|
||||
}
|
||||
|
||||
public RazorDiagnostic Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_index < 0 || _index >= _items.Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _items[_index];
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
_index++;
|
||||
return _index < _items.Count;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_index = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,133 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language
|
||||
{
|
||||
public sealed class ReadOnlyDiagnosticCollection : RazorDiagnosticCollection
|
||||
{
|
||||
public static readonly ReadOnlyDiagnosticCollection Instance = new ReadOnlyDiagnosticCollection();
|
||||
|
||||
private ReadOnlyDiagnosticCollection()
|
||||
{
|
||||
}
|
||||
|
||||
public override RazorDiagnostic this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
throw null; // Unreachable
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
throw null; // Unreachable
|
||||
}
|
||||
}
|
||||
|
||||
public override int Count => 0;
|
||||
|
||||
public override bool IsReadOnly => true;
|
||||
|
||||
public override void Add(RazorDiagnostic item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override bool Contains(RazorDiagnostic item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void CopyTo(RazorDiagnostic[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
else if (array.Length - arrayIndex < Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override IEnumerator<RazorDiagnostic> GetEnumerator()
|
||||
{
|
||||
return Enumerable.Empty<RazorDiagnostic>().GetEnumerator();
|
||||
}
|
||||
|
||||
public override int IndexOf(RazorDiagnostic item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override void Insert(int index, RazorDiagnostic item)
|
||||
{
|
||||
if (index < 0 || index > Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override bool Remove(RazorDiagnostic item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void RemoveAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language
|
||||
{
|
||||
internal class ReadOnlyItemCollection : ItemCollection
|
||||
{
|
||||
public static readonly ItemCollection Empty = new ReadOnlyItemCollection();
|
||||
|
||||
public override object this[object key]
|
||||
{
|
||||
get => null;
|
||||
set => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override int Count => 0;
|
||||
|
||||
public override bool IsReadOnly => true;
|
||||
|
||||
public override void Add(object key, object value)
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Add(KeyValuePair<object, object> item)
|
||||
{
|
||||
if (item.Key == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.KeyMustNotBeNull, nameof(item));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override bool Contains(KeyValuePair<object, object> item)
|
||||
{
|
||||
if (item.Key == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.KeyMustNotBeNull, nameof(item));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void CopyTo(KeyValuePair<object, object>[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
}
|
||||
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
else if (array.Length - arrayIndex < Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
}
|
||||
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public override IEnumerator<KeyValuePair<object, object>> GetEnumerator()
|
||||
{
|
||||
return Enumerable.Empty<KeyValuePair<object, object>>().GetEnumerator();
|
||||
}
|
||||
|
||||
public override bool Remove(KeyValuePair<object, object> item)
|
||||
{
|
||||
if (item.Key == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.KeyMustNotBeNull, nameof(item));
|
||||
}
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
Results = results;
|
||||
|
||||
Items = new DefaultItemCollection();
|
||||
Items = new ItemCollection();
|
||||
}
|
||||
|
||||
public override ItemCollection Items { get; }
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ Render Children
|
|||
|
||||
private class MyExtensionIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -583,7 +583,7 @@ WriteAttributeValue("" "", 27, false, 28, 6, false);
|
|||
|
||||
private class MyExtensionIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language
|
||||
{
|
||||
public class DefaultItemCollectionTest
|
||||
public class ItemCollectionTest
|
||||
{
|
||||
[Fact]
|
||||
public void Get_MissingValueReturnsNull()
|
||||
{
|
||||
// Arrange
|
||||
var items = new DefaultItemCollection();
|
||||
var items = new ItemCollection();
|
||||
|
||||
// Act
|
||||
var value = items["foo"];
|
||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
public void GetAndSet_ReturnsValue()
|
||||
{
|
||||
// Arrange
|
||||
var items = new DefaultItemCollection();
|
||||
var items = new ItemCollection();
|
||||
|
||||
var expected = "bar";
|
||||
items["foo"] = expected;
|
||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
public void Set_CanSetValueToNull()
|
||||
{
|
||||
// Arrange
|
||||
var items = new DefaultItemCollection();
|
||||
var items = new ItemCollection();
|
||||
|
||||
items["foo"] = "bar";
|
||||
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
|
||||
private class BasicIntermediateNode : IntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
|
||||
private class TestExtensionIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children => ReadOnlyIntermediateNodeCollection.Instance;
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
public void InsertAfter_SingleNode_ThrowsForReadOnlyCollection()
|
||||
{
|
||||
// Arrange
|
||||
var parent = new BasicIntermediateNode("Parent", ReadOnlyIntermediateNodeCollection.Instance);
|
||||
var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly);
|
||||
|
||||
var node1 = new BasicIntermediateNode("Node1");
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
public void InsertAfter_MulipleNodes_ThrowsForReadOnlyCollection()
|
||||
{
|
||||
// Arrange
|
||||
var parent = new BasicIntermediateNode("Parent", ReadOnlyIntermediateNodeCollection.Instance);
|
||||
var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly);
|
||||
|
||||
var node1 = new BasicIntermediateNode("Node1");
|
||||
|
||||
|
|
@ -335,7 +335,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
public void InsertBefore_SingleNode_ThrowsForReadOnlyCollection()
|
||||
{
|
||||
// Arrange
|
||||
var parent = new BasicIntermediateNode("Parent", ReadOnlyIntermediateNodeCollection.Instance);
|
||||
var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly);
|
||||
|
||||
var node1 = new BasicIntermediateNode("Node1");
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
public void InsertBefore_MulipleNodes_ThrowsForReadOnlyCollection()
|
||||
{
|
||||
// Arrange
|
||||
var parent = new BasicIntermediateNode("Parent", ReadOnlyIntermediateNodeCollection.Instance);
|
||||
var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly);
|
||||
|
||||
var node1 = new BasicIntermediateNode("Node1");
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
public void Remove_ThrowsForReadOnlyCollection()
|
||||
{
|
||||
// Arrange
|
||||
var parent = new BasicIntermediateNode("Parent", ReadOnlyIntermediateNodeCollection.Instance);
|
||||
var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly);
|
||||
|
||||
var node1 = new BasicIntermediateNode("Node1");
|
||||
|
||||
|
|
@ -380,7 +380,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
public void Replace_ThrowsForReadOnlyCollection()
|
||||
{
|
||||
// Arrange
|
||||
var parent = new BasicIntermediateNode("Parent", ReadOnlyIntermediateNodeCollection.Instance);
|
||||
var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly);
|
||||
|
||||
var node1 = new BasicIntermediateNode("Node1");
|
||||
|
||||
|
|
@ -484,7 +484,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
private class BasicIntermediateNode : IntermediateNode
|
||||
{
|
||||
public BasicIntermediateNode(string name)
|
||||
: this(name, new DefaultIntermediateNodeCollection())
|
||||
: this(name, new IntermediateNodeCollection())
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
|
||||
public string Name { get; }
|
||||
|
||||
public override IntermediateNodeCollection Children { get; } = new DefaultIntermediateNodeCollection();
|
||||
public override IntermediateNodeCollection Children { get; } = new IntermediateNodeCollection();
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue