diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs index d88f379542..491a2faaab 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs @@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -101,7 +101,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorProviderTest.cs index 7ddd76d9fc..862b97d715 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/test/ViewComponentTagHelperDescriptorProviderTest.cs @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X provider.Execute(context); // Assert - Assert.Single(context.Results, d => TagHelperDescriptorComparer.CaseSensitive.Equals(d, expectedDescriptor)); + Assert.Single(context.Results, d => TagHelperDescriptorComparer.Default.Equals(d, expectedDescriptor)); } } } diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs index d27fdb3129..bf56cb729f 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorFactoryTest.cs @@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -101,7 +101,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -210,7 +210,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorProviderTest.cs index 6c15d62a1f..d78e7b0a82 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/test/ViewComponentTagHelperDescriptorProviderTest.cs @@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X provider.Execute(context); // Assert - Assert.Single(context.Results, d => TagHelperDescriptorComparer.CaseSensitive.Equals(d, expectedDescriptor)); + Assert.Single(context.Results, d => TagHelperDescriptorComparer.Default.Equals(d, expectedDescriptor)); } } } diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorFactoryTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorFactoryTest.cs index d44f0169a1..8e874ac608 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorFactoryTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorFactoryTest.cs @@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -101,7 +101,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -210,7 +210,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions var descriptor = factory.CreateDescriptor(viewComponent); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorProviderTest.cs index 16fb3096dc..10faadb243 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/test/ViewComponentTagHelperDescriptorProviderTest.cs @@ -1,9 +1,6 @@ // 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.IO; -using System.Linq; -using System.Reflection; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -66,7 +63,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions provider.Execute(context); // Assert - Assert.Single(context.Results, d => TagHelperDescriptorComparer.CaseSensitive.Equals(d, expectedDescriptor)); + Assert.Single(context.Results, d => TagHelperDescriptorComparer.Default.Equals(d, expectedDescriptor)); } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorComparer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorComparer.cs index 37f0a55417..f6b4ea5776 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorComparer.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/AllowedChildTagDescriptorComparer.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language @@ -16,27 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language public static readonly AllowedChildTagDescriptorComparer Default = new AllowedChildTagDescriptorComparer(); - /// - /// A default instance of the that does case-sensitive comparison. - /// - internal static readonly AllowedChildTagDescriptorComparer CaseSensitive = - new AllowedChildTagDescriptorComparer(caseSensitive: true); - - private readonly StringComparer _stringComparer; - private readonly StringComparison _stringComparison; - - private AllowedChildTagDescriptorComparer(bool caseSensitive = false) + private AllowedChildTagDescriptorComparer() { - if (caseSensitive) - { - _stringComparer = StringComparer.Ordinal; - _stringComparison = StringComparison.Ordinal; - } - else - { - _stringComparer = StringComparer.OrdinalIgnoreCase; - _stringComparison = StringComparison.OrdinalIgnoreCase; - } } /// @@ -55,7 +35,7 @@ namespace Microsoft.AspNetCore.Razor.Language } return - string.Equals(descriptorX.Name, descriptorY.Name, _stringComparison) && + string.Equals(descriptorX.Name, descriptorY.Name, StringComparison.Ordinal) && string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal); } @@ -63,7 +43,7 @@ namespace Microsoft.AspNetCore.Razor.Language public virtual int GetHashCode(AllowedChildTagDescriptor descriptor) { var hash = HashCodeCombiner.Start(); - hash.Add(descriptor.Name, _stringComparer); + hash.Add(descriptor.Name, StringComparer.Ordinal); return hash.CombinedHash; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs index 96a0119ad8..ecfd96105f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs @@ -43,6 +43,8 @@ namespace Microsoft.AspNetCore.Razor.Language public string DisplayName { get; protected set; } + public bool CaseSensitive { get; protected set; } + public IReadOnlyList Diagnostics { get; protected set; } public IReadOnlyDictionary Metadata { get; protected set; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorComparer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorComparer.cs index fbf68929eb..54154a7aaa 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorComparer.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorComparer.cs @@ -15,27 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language /// public static readonly BoundAttributeDescriptorComparer Default = new BoundAttributeDescriptorComparer(); - /// - /// A default instance of the that does case-sensitive comparison. - /// - internal static readonly BoundAttributeDescriptorComparer CaseSensitive = - new BoundAttributeDescriptorComparer(caseSensitive: true); - - private readonly StringComparer _stringComparer; - private readonly StringComparison _stringComparison; - - private BoundAttributeDescriptorComparer(bool caseSensitive = false) + private BoundAttributeDescriptorComparer() { - if (caseSensitive) - { - _stringComparer = StringComparer.Ordinal; - _stringComparison = StringComparison.Ordinal; - } - else - { - _stringComparer = StringComparer.OrdinalIgnoreCase; - _stringComparison = StringComparison.OrdinalIgnoreCase; - } } public virtual bool Equals(BoundAttributeDescriptor descriptorX, BoundAttributeDescriptor descriptorY) @@ -55,8 +36,9 @@ namespace Microsoft.AspNetCore.Razor.Language descriptorX.IsIndexerStringProperty == descriptorY.IsIndexerStringProperty && descriptorX.IsEnum == descriptorY.IsEnum && descriptorX.HasIndexer == descriptorY.HasIndexer && - string.Equals(descriptorX.Name, descriptorY.Name, _stringComparison) && - string.Equals(descriptorX.IndexerNamePrefix, descriptorY.IndexerNamePrefix, _stringComparison) && + descriptorX.CaseSensitive == descriptorY.CaseSensitive && + string.Equals(descriptorX.Name, descriptorY.Name, StringComparison.Ordinal) && + string.Equals(descriptorX.IndexerNamePrefix, descriptorY.IndexerNamePrefix, StringComparison.Ordinal) && string.Equals(descriptorX.TypeName, descriptorY.TypeName, StringComparison.Ordinal) && string.Equals(descriptorX.IndexerTypeName, descriptorY.IndexerTypeName, StringComparison.Ordinal) && string.Equals(descriptorX.Documentation, descriptorY.Documentation, StringComparison.Ordinal) && @@ -75,7 +57,7 @@ namespace Microsoft.AspNetCore.Razor.Language var hash = HashCodeCombiner.Start(); hash.Add(descriptor.Kind); - hash.Add(descriptor.Name, _stringComparer); + hash.Add(descriptor.Name, StringComparer.Ordinal); return hash.CombinedHash; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptor.cs index b0c98d8400..904718d730 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptor.cs @@ -30,6 +30,8 @@ namespace Microsoft.AspNetCore.Razor.Language public string DisplayName { get; protected set; } + public bool CaseSensitive { get; protected set; } + public IReadOnlyList Diagnostics { get; protected set; } public IReadOnlyDictionary Metadata { get; protected set; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorComparer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorComparer.cs index 4f183bee01..6cbc01017c 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorComparer.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeParameterDescriptorComparer.cs @@ -15,27 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language /// public static readonly BoundAttributeParameterDescriptorComparer Default = new BoundAttributeParameterDescriptorComparer(); - /// - /// A default instance of the that does case-sensitive comparison. - /// - internal static readonly BoundAttributeParameterDescriptorComparer CaseSensitive = - new BoundAttributeParameterDescriptorComparer(caseSensitive: true); - - private readonly StringComparer _stringComparer; - private readonly StringComparison _stringComparison; - - private BoundAttributeParameterDescriptorComparer(bool caseSensitive = false) + private BoundAttributeParameterDescriptorComparer() { - if (caseSensitive) - { - _stringComparer = StringComparer.Ordinal; - _stringComparison = StringComparison.Ordinal; - } - else - { - _stringComparer = StringComparer.OrdinalIgnoreCase; - _stringComparison = StringComparison.OrdinalIgnoreCase; - } } public virtual bool Equals(BoundAttributeParameterDescriptor descriptorX, BoundAttributeParameterDescriptor descriptorY) @@ -53,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language return string.Equals(descriptorX.Kind, descriptorY.Kind, StringComparison.Ordinal) && descriptorX.IsEnum == descriptorY.IsEnum && - string.Equals(descriptorX.Name, descriptorY.Name, _stringComparison) && + string.Equals(descriptorX.Name, descriptorY.Name, StringComparison.Ordinal) && string.Equals(descriptorX.TypeName, descriptorY.TypeName, StringComparison.Ordinal) && string.Equals(descriptorX.Documentation, descriptorY.Documentation, StringComparison.Ordinal) && string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal) && @@ -71,7 +52,7 @@ namespace Microsoft.AspNetCore.Razor.Language var hash = HashCodeCombiner.Start(); hash.Add(descriptor.Kind); - hash.Add(descriptor.Name, _stringComparer); + hash.Add(descriptor.Name, StringComparer.Ordinal); return hash.CombinedHash; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs index e095499508..0b37c16233 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs @@ -421,5 +421,48 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { return RazorDiagnostic.Create(RefSuppressFieldRequiredForGeneric, source ?? SourceSpan.Undefined); } + + public static readonly RazorDiagnosticDescriptor ComponentNamesCannotStartWithLowerCase = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10013", + () => "Component '{0}' starts with a lowercase character. Component names cannot start with a lowercase character.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ComponentNamesCannotStartWithLowerCase(string componentName, SourceSpan? source = null) + { + return RazorDiagnostic.Create( + ComponentNamesCannotStartWithLowerCase, + source ?? SourceSpan.Undefined, + componentName); + } + + public static readonly RazorDiagnosticDescriptor UnexpectedMarkupElement = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10014", + () => "Found markup element with unexpected name '{0}'. If this is intended to be a component, add a @using directive for its namespace.", + RazorDiagnosticSeverity.Warning); + + public static RazorDiagnostic Create_UnexpectedMarkupElement(string elementName, SourceSpan? source = null) + { + return RazorDiagnostic.Create( + UnexpectedMarkupElement, + source ?? SourceSpan.Undefined, + elementName); + } + + public static readonly RazorDiagnosticDescriptor InconsistentStartAndEndTagName = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10015", + () => "The start tag name '{0}' does not match the end tag name '{1}'. Components must have matching start and end tag names (case-sensitive).", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_InconsistentStartAndEndTagName(string startTagName, string endTagName, SourceSpan? source = null) + { + return RazorDiagnostic.Create( + InconsistentStartAndEndTagName, + source ?? SourceSpan.Undefined, + startTagName, + endTagName); + } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs index 8ff9196e1e..8e2b1970e0 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs @@ -64,6 +64,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Components computedClass = $"AspNetCore_{checksum}"; } + var documentNode = codeDocument.GetDocumentIntermediateNode(); + if (char.IsLower(computedClass, 0)) + { + // We don't allow component names to start with a lowercase character. + documentNode.Diagnostics.Add( + ComponentDiagnosticFactory.Create_ComponentNamesCannotStartWithLowerCase(computedClass, documentNode.Source)); + } + if (MangleClassNames) { computedClass = ComponentMetadata.MangleClassName(computedClass); @@ -91,7 +99,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { @class.BaseType = ComponentsApi.ComponentBase.FullTypeName; - var documentNode = codeDocument.GetDocumentIntermediateNode(); var typeParamReferences = documentNode.FindDirectiveReferences(ComponentTypeParamDirective.Directive); for (var i = 0; i < typeParamReferences.Count; i++) { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptor.cs index bff46f4549..af297496c9 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptor.cs @@ -17,6 +17,7 @@ namespace Microsoft.AspNetCore.Razor.Language string indexerTypeName, string documentation, string displayName, + bool caseSensitive, BoundAttributeParameterDescriptor[] parameterDescriptors, Dictionary metadata, RazorDiagnostic[] diagnostics) @@ -30,6 +31,7 @@ namespace Microsoft.AspNetCore.Razor.Language IndexerTypeName = indexerTypeName; Documentation = documentation; DisplayName = displayName; + CaseSensitive = caseSensitive; BoundAttributeParameters = parameterDescriptors; Metadata = metadata; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptorBuilder.cs index a44c2570db..5c9b8cf90b 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptorBuilder.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptorBuilder.cs @@ -74,6 +74,8 @@ namespace Microsoft.AspNetCore.Razor.Language } } + internal bool CaseSensitive => _parent.CaseSensitive; + public override void BindAttributeParameter(Action configure) { if (configure == null) @@ -101,7 +103,7 @@ namespace Microsoft.AspNetCore.Razor.Language if (_attributeParameterBuilders != null) { // Attribute parameters are case-sensitive. - var parameterset = new HashSet(BoundAttributeParameterDescriptorComparer.CaseSensitive); + var parameterset = new HashSet(BoundAttributeParameterDescriptorComparer.Default); for (var i = 0; i < _attributeParameterBuilders.Count; i++) { parameterset.Add(_attributeParameterBuilders[i].Build()); @@ -120,6 +122,7 @@ namespace Microsoft.AspNetCore.Razor.Language IndexerValueTypeName, Documentation, GetDisplayName(), + CaseSensitive, parameters, new Dictionary(Metadata), diagnostics.ToArray()); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeParameterDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeParameterDescriptor.cs index 349ffb68f8..bbac666f48 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeParameterDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeParameterDescriptor.cs @@ -14,6 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Language bool isEnum, string documentation, string displayName, + bool caseSensitive, Dictionary metadata, RazorDiagnostic[] diagnostics) : base(kind) @@ -23,6 +24,7 @@ namespace Microsoft.AspNetCore.Razor.Language IsEnum = isEnum; Documentation = documentation; DisplayName = displayName; + CaseSensitive = caseSensitive; Metadata = metadata; Diagnostics = diagnostics; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeParameterDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeParameterDescriptorBuilder.cs index d7c62286bc..0b2c30000f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeParameterDescriptorBuilder.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeParameterDescriptorBuilder.cs @@ -1,7 +1,6 @@ // 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; @@ -48,6 +47,8 @@ namespace Microsoft.AspNetCore.Razor.Language } } + internal bool CaseSensitive => _parent.CaseSensitive; + public BoundAttributeParameterDescriptor Build() { var validationDiagnostics = Validate(); @@ -63,6 +64,7 @@ namespace Microsoft.AspNetCore.Razor.Language IsEnum, Documentation, GetDisplayName(), + CaseSensitive, new Dictionary(Metadata), diagnostics.ToArray()); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRazorIntermediateNodeLoweringPhase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRazorIntermediateNodeLoweringPhase.cs index 166a2912a4..f3180eb618 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRazorIntermediateNodeLoweringPhase.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRazorIntermediateNodeLoweringPhase.cs @@ -1162,7 +1162,7 @@ namespace Microsoft.AspNetCore.Razor.Language Source = BuildSourceSpanFromNode(node), // Could be empty while the tag is being typed in. - TagName = node.StartTag?.GetTagNameWithOptionalBang() ?? node.EndTag?.GetTagNameWithOptionalBang() ?? string.Empty, + TagName = node.StartTag?.Name?.Content ?? node.EndTag?.Name?.Content ?? string.Empty, }; if (node.StartTag != null && node.EndTag != null && node.StartTag.IsVoidElement()) @@ -1184,6 +1184,19 @@ namespace Microsoft.AspNetCore.Razor.Language BuildSourceSpanFromNode(node.EndTag), node.EndTag.GetTagNameWithOptionalBang())); } + if (node.StartTag != null && !_document.Options.SuppressPrimaryMethodBody) + { + // We only want this error during the second phase of the two phase compilation. + var startTagName = node.StartTag.GetTagNameWithOptionalBang(); + if (startTagName != null && startTagName.Length > 0 && char.IsUpper(startTagName, 0)) + { + // A markup element that starts with an uppercase character. + // It is most likely intended to be a component. Add a warning. + element.Diagnostics.Add( + ComponentDiagnosticFactory.Create_UnexpectedMarkupElement(startTagName, BuildSourceSpanFromNode(node.StartTag))); + } + } + _builder.Push(element); base.VisitMarkupElement(node); @@ -1640,6 +1653,19 @@ namespace Microsoft.AspNetCore.Razor.Language // We don't want to track attributes from a previous tag helper element. _renderedBoundAttributeNames.Clear(); + + if (node.StartTag != null && node.EndTag != null) + { + var startTagName = node.StartTag.Name?.Content; + var endTagName = node.EndTag.Name?.Content; + if (!string.Equals(startTagName, endTagName, StringComparison.Ordinal)) + { + // This is most likely a case mismatch in start and end tags. Otherwise the parser wouldn't have grouped them together. + // But we can't have case mismatch in start and end tags in components. Add a diagnostic. + tagHelperNode.Diagnostics.Add( + ComponentDiagnosticFactory.Create_InconsistentStartAndEndTagName(startTagName, endTagName, BuildSourceSpanFromNode(node.EndTag))); + } + } } public override void VisitMarkupTagHelperStartTag(MarkupTagHelperStartTagSyntax node) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRequiredAttributeDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRequiredAttributeDescriptor.cs index 13228d130b..29d29881bd 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRequiredAttributeDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRequiredAttributeDescriptor.cs @@ -10,6 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Language public DefaultRequiredAttributeDescriptor( string name, NameComparisonMode nameComparison, + bool caseSensitive, string value, ValueComparisonMode valueComparison, string displayName, @@ -18,6 +19,7 @@ namespace Microsoft.AspNetCore.Razor.Language { Name = name; NameComparison = nameComparison; + CaseSensitive = caseSensitive; Value = value; ValueComparison = valueComparison; DisplayName = displayName; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRequiredAttributeDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRequiredAttributeDescriptorBuilder.cs index a3e7472598..f663da4c3b 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRequiredAttributeDescriptorBuilder.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultRequiredAttributeDescriptorBuilder.cs @@ -9,9 +9,15 @@ namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultRequiredAttributeDescriptorBuilder : RequiredAttributeDescriptorBuilder { + private DefaultTagMatchingRuleDescriptorBuilder _parent; private RazorDiagnosticCollection _diagnostics; private readonly Dictionary _metadata = new Dictionary(); + public DefaultRequiredAttributeDescriptorBuilder(DefaultTagMatchingRuleDescriptorBuilder parent) + { + _parent = parent; + } + public override string Name { get; set; } public override RequiredAttributeDescriptor.NameComparisonMode NameComparisonMode { get; set; } @@ -35,6 +41,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override IDictionary Metadata => _metadata; + internal bool CaseSensitive => _parent.CaseSensitive; + public RequiredAttributeDescriptor Build() { var validationDiagnostics = Validate(); @@ -48,6 +56,7 @@ namespace Microsoft.AspNetCore.Razor.Language var rule = new DefaultRequiredAttributeDescriptor( Name, NameComparisonMode, + CaseSensitive, Value, ValueComparisonMode, displayName, diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagHelperDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagHelperDescriptor.cs index f9da39f401..9ebd3eb90b 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagHelperDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagHelperDescriptor.cs @@ -14,6 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Language string displayName, string documentation, string tagOutputHint, + bool caseSensitive, TagMatchingRuleDescriptor[] tagMatchingRules, BoundAttributeDescriptor[] attributeDescriptors, AllowedChildTagDescriptor[] allowedChildTags, @@ -26,6 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language DisplayName = displayName; Documentation = documentation; TagOutputHint = tagOutputHint; + CaseSensitive = caseSensitive; TagMatchingRules = tagMatchingRules; BoundAttributes = attributeDescriptors; AllowedChildTags = allowedChildTags; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagHelperDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagHelperDescriptorBuilder.cs index 3dcd280a11..e4635d141c 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagHelperDescriptorBuilder.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagHelperDescriptorBuilder.cs @@ -40,6 +40,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override string TagOutputHint { get; set; } + public override bool CaseSensitive { get; set; } + public override string Documentation { get; set; } public override IDictionary Metadata => _metadata; @@ -124,7 +126,7 @@ namespace Microsoft.AspNetCore.Razor.Language EnsureTagMatchingRuleBuilders(); - var builder = new DefaultTagMatchingRuleDescriptorBuilder(); + var builder = new DefaultTagMatchingRuleDescriptorBuilder(this); configure(builder); _tagMatchingRuleBuilders.Add(builder); } @@ -180,6 +182,7 @@ namespace Microsoft.AspNetCore.Razor.Language GetDisplayName(), Documentation, TagOutputHint, + CaseSensitive, tagMatchingRules, attributes, allowedChildTags, diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagMatchingRuleDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagMatchingRuleDescriptor.cs index 78595a9165..dae8151b65 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagMatchingRuleDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagMatchingRuleDescriptor.cs @@ -9,12 +9,14 @@ namespace Microsoft.AspNetCore.Razor.Language string tagName, string parentTag, TagStructure tagStructure, + bool caseSensitive, RequiredAttributeDescriptor[] attributes, RazorDiagnostic[] diagnostics) { TagName = tagName; ParentTag = parentTag; TagStructure = tagStructure; + CaseSensitive = caseSensitive; Attributes = attributes; Diagnostics = diagnostics; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagMatchingRuleDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagMatchingRuleDescriptorBuilder.cs index 7cfb80eebc..4c8524ccb7 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagMatchingRuleDescriptorBuilder.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultTagMatchingRuleDescriptorBuilder.cs @@ -4,17 +4,18 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language { internal class DefaultTagMatchingRuleDescriptorBuilder : TagMatchingRuleDescriptorBuilder { + private DefaultTagHelperDescriptorBuilder _parent; private List _requiredAttributeBuilders; private RazorDiagnosticCollection _diagnostics; - internal DefaultTagMatchingRuleDescriptorBuilder() + internal DefaultTagMatchingRuleDescriptorBuilder(DefaultTagHelperDescriptorBuilder parent) { + _parent = parent; } public override string TagName { get; set; } @@ -23,6 +24,8 @@ namespace Microsoft.AspNetCore.Razor.Language public override TagStructure TagStructure { get; set; } + internal bool CaseSensitive => _parent.CaseSensitive; + public override RazorDiagnosticCollection Diagnostics { get @@ -55,7 +58,7 @@ namespace Microsoft.AspNetCore.Razor.Language EnsureRequiredAttributeBuilders(); - var builder = new DefaultRequiredAttributeDescriptorBuilder(); + var builder = new DefaultRequiredAttributeDescriptorBuilder(this); configure(builder); _requiredAttributeBuilders.Add(builder); } @@ -85,6 +88,7 @@ namespace Microsoft.AspNetCore.Razor.Language TagName, ParentTag, TagStructure, + CaseSensitive, requiredAttributes, diagnostics.ToArray()); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RequiredAttributeDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RequiredAttributeDescriptor.cs index 5f68eea115..ccae80a91e 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RequiredAttributeDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RequiredAttributeDescriptor.cs @@ -13,6 +13,8 @@ namespace Microsoft.AspNetCore.Razor.Language public NameComparisonMode NameComparison { get; protected set; } + public bool CaseSensitive { get; protected set; } + public string Value { get; protected set; } public ValueComparisonMode ValueComparison { get; protected set; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RequiredAttributeDescriptorComparer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RequiredAttributeDescriptorComparer.cs index 149f6a0c3d..2883797e4f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RequiredAttributeDescriptorComparer.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RequiredAttributeDescriptorComparer.cs @@ -19,27 +19,8 @@ namespace Microsoft.AspNetCore.Razor.Language public static readonly RequiredAttributeDescriptorComparer Default = new RequiredAttributeDescriptorComparer(); - /// - /// A default instance of the that does case-sensitive comparison. - /// - internal static readonly RequiredAttributeDescriptorComparer CaseSensitive = - new RequiredAttributeDescriptorComparer(caseSensitive: true); - - private readonly StringComparer _stringComparer; - private readonly StringComparison _stringComparison; - - private RequiredAttributeDescriptorComparer(bool caseSensitive = false) + private RequiredAttributeDescriptorComparer() { - if (caseSensitive) - { - _stringComparer = StringComparer.Ordinal; - _stringComparison = StringComparison.Ordinal; - } - else - { - _stringComparer = StringComparer.OrdinalIgnoreCase; - _stringComparison = StringComparison.OrdinalIgnoreCase; - } } /// @@ -58,9 +39,10 @@ namespace Microsoft.AspNetCore.Razor.Language } return + descriptorX.CaseSensitive == descriptorY.CaseSensitive && descriptorX.NameComparison == descriptorY.NameComparison && descriptorX.ValueComparison == descriptorY.ValueComparison && - string.Equals(descriptorX.Name, descriptorY.Name, _stringComparison) && + string.Equals(descriptorX.Name, descriptorY.Name, StringComparison.Ordinal) && string.Equals(descriptorX.Value, descriptorY.Value, StringComparison.Ordinal) && string.Equals(descriptorX.DisplayName, descriptorY.DisplayName, StringComparison.Ordinal); } @@ -68,8 +50,13 @@ namespace Microsoft.AspNetCore.Razor.Language /// public virtual int GetHashCode(RequiredAttributeDescriptor descriptor) { + if (descriptor == null) + { + throw new ArgumentNullException(nameof(descriptor)); + } + var hash = HashCodeCombiner.Start(); - hash.Add(descriptor.Name, _stringComparer); + hash.Add(descriptor.Name, StringComparer.Ordinal); return hash.CombinedHash; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs index 7c81d5e94f..3b55e486c6 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs @@ -34,6 +34,8 @@ namespace Microsoft.AspNetCore.Razor.Language public string TagOutputHint { get; protected set; } + public bool CaseSensitive { get; protected set; } + public IReadOnlyList Diagnostics { get; protected set; } public IReadOnlyDictionary Metadata { get; protected set; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptorBuilder.cs index 57a75bf50a..1d60d7e023 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptorBuilder.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptorBuilder.cs @@ -52,6 +52,8 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract string TagOutputHint { get; set; } + public virtual bool CaseSensitive { get; set; } + public abstract string Documentation { get; set; } public abstract IDictionary Metadata { get; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptorComparer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptorComparer.cs index 5ca9c0fe91..a078fc0630 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptorComparer.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptorComparer.cs @@ -15,36 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language /// public static readonly TagHelperDescriptorComparer Default = new TagHelperDescriptorComparer(); - /// - /// A default instance of the that does case-sensitive comparison. - /// - internal static readonly TagHelperDescriptorComparer CaseSensitive = - new TagHelperDescriptorComparer(caseSensitive: true); - - private readonly StringComparer _stringComparer; - private readonly StringComparison _stringComparison; - private readonly AllowedChildTagDescriptorComparer _AllowedChildTagDescriptorComparer; - private readonly BoundAttributeDescriptorComparer _boundAttributeComparer; - private readonly TagMatchingRuleDescriptorComparer _tagMatchingRuleComparer; - - private TagHelperDescriptorComparer(bool caseSensitive = false) + private TagHelperDescriptorComparer() { - if (caseSensitive) - { - _stringComparer = StringComparer.Ordinal; - _stringComparison = StringComparison.Ordinal; - _AllowedChildTagDescriptorComparer = AllowedChildTagDescriptorComparer.CaseSensitive; - _boundAttributeComparer = BoundAttributeDescriptorComparer.CaseSensitive; - _tagMatchingRuleComparer = TagMatchingRuleDescriptorComparer.CaseSensitive; - } - else - { - _stringComparer = StringComparer.OrdinalIgnoreCase; - _stringComparison = StringComparison.OrdinalIgnoreCase; - _AllowedChildTagDescriptorComparer = AllowedChildTagDescriptorComparer.Default; - _boundAttributeComparer = BoundAttributeDescriptorComparer.Default; - _tagMatchingRuleComparer = TagMatchingRuleDescriptorComparer.Default; - } } public virtual bool Equals(TagHelperDescriptor descriptorX, TagHelperDescriptor descriptorY) @@ -59,11 +31,6 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - if (descriptorX == null) - { - return false; - } - if (!string.Equals(descriptorX.Kind, descriptorY.Kind, StringComparison.Ordinal)) { return false; @@ -80,17 +47,17 @@ namespace Microsoft.AspNetCore.Razor.Language } if (!Enumerable.SequenceEqual( - descriptorX.BoundAttributes.OrderBy(attribute => attribute.Name, _stringComparer), - descriptorY.BoundAttributes.OrderBy(attribute => attribute.Name, _stringComparer), - _boundAttributeComparer)) + descriptorX.BoundAttributes.OrderBy(attribute => attribute.Name, StringComparer.Ordinal), + descriptorY.BoundAttributes.OrderBy(attribute => attribute.Name, StringComparer.Ordinal), + BoundAttributeDescriptorComparer.Default)) { return false; } if (!Enumerable.SequenceEqual( - descriptorX.TagMatchingRules.OrderBy(rule => rule.TagName, _stringComparer), - descriptorY.TagMatchingRules.OrderBy(rule => rule.TagName, _stringComparer), - _tagMatchingRuleComparer)) + descriptorX.TagMatchingRules.OrderBy(rule => rule.TagName, StringComparer.Ordinal), + descriptorY.TagMatchingRules.OrderBy(rule => rule.TagName, StringComparer.Ordinal), + TagMatchingRuleDescriptorComparer.Default)) { return false; } @@ -99,9 +66,14 @@ namespace Microsoft.AspNetCore.Razor.Language (descriptorX.AllowedChildTags != null && descriptorY.AllowedChildTags != null && Enumerable.SequenceEqual( - descriptorX.AllowedChildTags.OrderBy(childTag => childTag.Name, _stringComparer), - descriptorY.AllowedChildTags.OrderBy(childTag => childTag.Name, _stringComparer), - _AllowedChildTagDescriptorComparer)))) + descriptorX.AllowedChildTags.OrderBy(childTag => childTag.Name, StringComparer.Ordinal), + descriptorY.AllowedChildTags.OrderBy(childTag => childTag.Name, StringComparer.Ordinal), + AllowedChildTagDescriptorComparer.Default)))) + { + return false; + } + + if (descriptorX.CaseSensitive != descriptorY.CaseSensitive) { return false; } @@ -116,7 +88,7 @@ namespace Microsoft.AspNetCore.Razor.Language return false; } - if (!string.Equals(descriptorX.TagOutputHint, descriptorY.TagOutputHint, _stringComparison)) + if (!string.Equals(descriptorX.TagOutputHint, descriptorY.TagOutputHint, StringComparison.Ordinal)) { return false; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperMatchingConventions.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperMatchingConventions.cs index 514acad767..68184d91ca 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperMatchingConventions.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperMatchingConventions.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Security.Cryptography; namespace Microsoft.AspNetCore.Razor.Language { @@ -81,7 +82,7 @@ namespace Microsoft.AspNetCore.Razor.Language if (rule.TagName != ElementCatchAllName && rule.TagName != null && - !string.Equals(tagNameWithoutPrefix, rule.TagName, StringComparison.OrdinalIgnoreCase)) + !string.Equals(tagNameWithoutPrefix, rule.TagName, rule.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase)) { return false; } @@ -96,7 +97,7 @@ namespace Microsoft.AspNetCore.Razor.Language throw new ArgumentNullException(nameof(rule)); } - if (rule.ParentTag != null && !string.Equals(parentTagNameWithoutPrefix, rule.ParentTag, StringComparison.OrdinalIgnoreCase)) + if (rule.ParentTag != null && !string.Equals(parentTagNameWithoutPrefix, rule.ParentTag, rule.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase)) { return false; } @@ -137,7 +138,7 @@ namespace Microsoft.AspNetCore.Razor.Language { return descriptor.IndexerNamePrefix != null && !SatisfiesBoundAttributeName(name, descriptor) && - name.StartsWith(descriptor.IndexerNamePrefix, StringComparison.OrdinalIgnoreCase); + name.StartsWith(descriptor.IndexerNamePrefix, descriptor.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } public static bool SatisfiesBoundAttributeWithParameter(string name, BoundAttributeDescriptor parent, BoundAttributeParameterDescriptor descriptor) @@ -146,7 +147,7 @@ namespace Microsoft.AspNetCore.Razor.Language { var satisfiesBoundAttributeName = SatisfiesBoundAttributeName(attributeName, parent); var satisfiesBoundAttributeIndexer = SatisfiesBoundAttributeIndexer(attributeName, parent); - var matchesParameter = string.Equals(descriptor.Name, parameterName, StringComparison.Ordinal); + var matchesParameter = string.Equals(descriptor.Name, parameterName, descriptor.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); return (satisfiesBoundAttributeName || satisfiesBoundAttributeIndexer) && matchesParameter; } @@ -220,7 +221,7 @@ namespace Microsoft.AspNetCore.Razor.Language private static bool SatisfiesBoundAttributeName(string name, BoundAttributeDescriptor descriptor) { - return string.Equals(descriptor.Name, name, StringComparison.OrdinalIgnoreCase); + return string.Equals(descriptor.Name, name, descriptor.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } // Internal for testing @@ -229,13 +230,13 @@ namespace Microsoft.AspNetCore.Razor.Language var nameMatches = false; if (descriptor.NameComparison == RequiredAttributeDescriptor.NameComparisonMode.FullMatch) { - nameMatches = string.Equals(descriptor.Name, attributeName, StringComparison.OrdinalIgnoreCase); + nameMatches = string.Equals(descriptor.Name, attributeName, descriptor.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } else if (descriptor.NameComparison == RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch) { // attributeName cannot equal the Name if comparing as a PrefixMatch. nameMatches = attributeName.Length != descriptor.Name.Length && - attributeName.StartsWith(descriptor.Name, StringComparison.OrdinalIgnoreCase); + attributeName.StartsWith(descriptor.Name, descriptor.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } else { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs index d4564b88e7..c907f71134 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptor.cs @@ -19,6 +19,8 @@ namespace Microsoft.AspNetCore.Razor.Language public TagStructure TagStructure { get; protected set; } + public bool CaseSensitive { get; protected set; } + public IReadOnlyList Diagnostics { get; protected set; } public bool HasErrors diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptorComparer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptorComparer.cs index 734485b3c3..4ed8805e92 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptorComparer.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagMatchingRuleDescriptorComparer.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.AspNetCore.Razor.Language.Legacy; using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Language @@ -16,30 +15,8 @@ namespace Microsoft.AspNetCore.Razor.Language /// public static readonly TagMatchingRuleDescriptorComparer Default = new TagMatchingRuleDescriptorComparer(); - /// - /// A default instance of the that does case-sensitive comparison. - /// - internal static readonly TagMatchingRuleDescriptorComparer CaseSensitive = - new TagMatchingRuleDescriptorComparer(caseSensitive: true); - - private readonly StringComparer _stringComparer; - private readonly StringComparison _stringComparison; - private readonly RequiredAttributeDescriptorComparer _requiredAttributeComparer; - - private TagMatchingRuleDescriptorComparer(bool caseSensitive = false) + private TagMatchingRuleDescriptorComparer() { - if (caseSensitive) - { - _stringComparer = StringComparer.Ordinal; - _stringComparison = StringComparison.Ordinal; - _requiredAttributeComparer = RequiredAttributeDescriptorComparer.CaseSensitive; - } - else - { - _stringComparer = StringComparer.OrdinalIgnoreCase; - _stringComparison = StringComparison.OrdinalIgnoreCase; - _requiredAttributeComparer = RequiredAttributeDescriptorComparer.Default; - } } public virtual bool Equals(TagMatchingRuleDescriptor ruleX, TagMatchingRuleDescriptor ruleY) @@ -55,10 +32,11 @@ namespace Microsoft.AspNetCore.Razor.Language } return - string.Equals(ruleX.TagName, ruleY.TagName, _stringComparison) && - string.Equals(ruleX.ParentTag, ruleY.ParentTag, _stringComparison) && + string.Equals(ruleX.TagName, ruleY.TagName, StringComparison.Ordinal) && + string.Equals(ruleX.ParentTag, ruleY.ParentTag, StringComparison.Ordinal) && + ruleX.CaseSensitive == ruleY.CaseSensitive && ruleX.TagStructure == ruleY.TagStructure && - Enumerable.SequenceEqual(ruleX.Attributes, ruleY.Attributes, _requiredAttributeComparer); + Enumerable.SequenceEqual(ruleX.Attributes, ruleY.Attributes, RequiredAttributeDescriptorComparer.Default); } public virtual int GetHashCode(TagMatchingRuleDescriptor rule) @@ -69,7 +47,7 @@ namespace Microsoft.AspNetCore.Razor.Language } var hash = HashCodeCombiner.Start(); - hash.Add(rule.TagName, _stringComparer); + hash.Add(rule.TagName, StringComparer.Ordinal); return hash.CombinedHash; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRequiredAttributeDescriptorBuilderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRequiredAttributeDescriptorBuilderTest.cs index f847f6ae3c..7f81d74e66 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRequiredAttributeDescriptorBuilderTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DefaultRequiredAttributeDescriptorBuilderTest.cs @@ -11,7 +11,9 @@ namespace Microsoft.AspNetCore.Razor.Language public void Build_DisplayNameIsName_NameComparisonFullMatch() { // Arrange - var builder = new DefaultRequiredAttributeDescriptorBuilder(); + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var tagMatchingRuleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); + var builder = new DefaultRequiredAttributeDescriptorBuilder(tagMatchingRuleBuilder); builder .Name("asp-action") @@ -28,7 +30,9 @@ namespace Microsoft.AspNetCore.Razor.Language public void Build_DisplayNameIsNameWithDots_NameComparisonPrefixMatch() { // Arrange - var builder = new DefaultRequiredAttributeDescriptorBuilder(); + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var tagMatchingRuleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); + var builder = new DefaultRequiredAttributeDescriptorBuilder(tagMatchingRuleBuilder); builder .Name("asp-route-") diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs index 7321c473cb..104c63c752 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Extensions/DefaultTagHelperOptimizationPassTest.cs @@ -60,16 +60,16 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions var create = Assert.IsType(tagHelper.Children[1]); Assert.Equal("__TestTagHelper", create.FieldName); Assert.Equal("TestTagHelper", create.TypeName); - Assert.Equal(tagHelpers[0], create.TagHelper, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(tagHelpers[0], create.TagHelper, TagHelperDescriptorComparer.Default); var property = Assert.IsType(tagHelper.Children[2]); Assert.Equal("foo", property.AttributeName); Assert.Equal(AttributeStructure.DoubleQuotes, property.AttributeStructure); - Assert.Equal(tagHelpers[0].BoundAttributes[0], property.BoundAttribute, BoundAttributeDescriptorComparer.CaseSensitive); + Assert.Equal(tagHelpers[0].BoundAttributes[0], property.BoundAttribute, BoundAttributeDescriptorComparer.Default); Assert.Equal("__TestTagHelper", property.FieldName); Assert.False(property.IsIndexerNameMatch); Assert.Equal("FooProp", property.PropertyName); - Assert.Equal(tagHelpers[0], property.TagHelper, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(tagHelpers[0], property.TagHelper, TagHelperDescriptorComparer.Default); var htmlAttribute = Assert.IsType(tagHelper.Children[3]); Assert.Equal("attr", htmlAttribute.AttributeName); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs index 15c2d4de9b..3a84f91501 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs @@ -161,8 +161,10 @@ Some Content "); // Assert - var diagnostic = Assert.Single(generated.Diagnostics); - Assert.Same(ComponentDiagnosticFactory.ChildContentMixedWithExplicitChildContent.Id, diagnostic.Id); + Assert.Collection( + generated.Diagnostics, + d => Assert.Equal("RZ10014", d.Id), + d => Assert.Equal("RZ9996", d.Id)); } [Fact] diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index cd2a441163..b65d268ac1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -998,6 +998,24 @@ namespace Test CompileToAssembly(generated); } + [Fact] + public void BuiltIn_BindToInputWithoutType_IsCaseSensitive() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + [Fact] public void BuiltIn_BindToInputText_WithFormat_WritesAttributes() { @@ -1829,12 +1847,12 @@ namespace Test3 @using static Test2.SomeComponent @using Foo = Test3 - "); + ", throwOnFailure: false); // Assert AssertDocumentNodeMatchesBaseline(generated.CodeDocument); AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); - var result = CompileToAssembly(generated); + CompileToAssembly(generated, throwOnFailure: false); } [Fact] @@ -2650,6 +2668,25 @@ namespace Test CompileToAssembly(generated); } + [Fact] + public void EventHandler_AttributeNameIsCaseSensitive() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@code { + void OnClick(UIMouseEventArgs e) { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion #region Generics @@ -3448,6 +3485,24 @@ namespace Test CompileToAssembly(generated); } + [Fact] + public void Element_WithKey_AttributeNameIsCaseSensitive() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + +@code { + private object someObject = new object(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion #region Splat @@ -3616,6 +3671,24 @@ namespace Test var generated = CompileToCSharp(@" +@code { + private Dictionary someAttributes = new Dictionary(); +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Element_WithSplat_AttributeNameIsCaseSensitive() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + @code { private Dictionary someAttributes = new Dictionary(); } @@ -3773,6 +3846,19 @@ namespace Test CompileToAssembly(generated); } + [Fact] + public void Element_WithRef_AttributeNameIsCaseSensitive() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion #region Templates @@ -4430,6 +4516,29 @@ namespace New.Test Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttributeDirective.Id, diagnostic.Id); } + [Fact] + public void DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +
+ +
+@functions { + private string text = ""hi""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttributeDirective.Id, diagnostic.Id); + } + [Fact] public void DuplicateMarkupAttributes_IsAnError_BindOnInput() { @@ -4871,6 +4980,81 @@ namespace Test CompileToAssembly(generated); } + [Fact] + public void Component_MatchingIsCaseSensitive() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public int IntProperty { get; set; } + [Parameter] public bool BoolProperty { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void Component_MultipleComponentsDifferByCase() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public int IntProperty { get; set; } + } + + public class Mycomponent : ComponentBase + { + [Parameter] public int IntProperty { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact] + public void ElementWithUppercaseTagName_CanHideWarningWithBang() + { + // Arrange & Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + #endregion } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs index 5caa98fb92..dc0b1b4cf9 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs @@ -9,6 +9,8 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests { internal override string FileKind => FileKinds.Component; + internal override bool UseTwoPhaseCompilation => true; + [Fact] public void RejectsEndTagWithNoStartTag() { @@ -125,5 +127,79 @@ namespace Test "Component attributes do not support complex content (mixed C# and markup). Attribute: '@key', text: 'Foo @Text'", diagnostic.GetMessage()); } + + [Fact] + public void Component_StartsWithLowerCase_ReportsError() + { + // Arrange & Act + var generated = CompileToCSharp("lowerCase.razor", @" + +@functions { + public string Text { get; set; } = ""text""; +}", throwOnFailure: false); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ10013", diagnostic.Id); + Assert.Equal( + "Component 'lowerCase' starts with a lowercase character. Component names cannot start with a lowercase character.", + diagnostic.GetMessage()); + } + + [Fact] + public void Element_DoesNotStartWithLowerCase_ReportsWarning() + { + // Arrange & Act + var generated = CompileToCSharp(@" + + +@functions { + public string Text { get; set; } = ""text""; +}"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ10014", diagnostic.Id); + Assert.Equal(RazorDiagnosticSeverity.Warning, diagnostic.Severity); + Assert.Equal( + "Found markup element with unexpected name 'PossibleComponent'. If this is intended to be a component, add a @using directive for its namespace.", + diagnostic.GetMessage()); + } + + [Fact] + public void Element_DoesNotStartWithLowerCase_OverrideWithBang_NoWarning() + { + // Arrange & Act + var generated = CompileToCSharp(@" +"); + + // Assert + Assert.Empty(generated.Diagnostics); + } + + [Fact] + public void Component_StartAndEndTagCaseMismatch_ReportsError() + { + // Arrange & Act + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + var generated = CompileToCSharp(@" +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ10015", diagnostic.Id); + Assert.Equal( + "The start tag name 'MyComponent' does not match the end tag name 'mycomponent'. Components must have matching start and end tag names (case-sensitive).", + diagnostic.GetMessage()); + } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTemplateIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTemplateIntegrationTest.cs index 9a73796a2e..93d206b87a 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTemplateIntegrationTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentTemplateIntegrationTest.cs @@ -9,6 +9,8 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests { internal override string FileKind => FileKinds.Component; + internal override bool UseTwoPhaseCompilation => true; + // Razor doesn't parse this as a template, we don't need much special handling for // it because it will just be invalid in general. [Fact] @@ -17,7 +19,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests // Arrange // Act - var generated = CompileToCSharp(@"
"" />"); + var generated = CompileToCSharp(@"
"" />", throwOnFailure: false); // Assert var diagnostic = Assert.Single(generated.Diagnostics); @@ -55,11 +57,13 @@ namespace Test ")); // Act - var generated = CompileToCSharp(@""" />"); + var generated = CompileToCSharp(@""" />", throwOnFailure: false); // Assert - var diagnostic = Assert.Single(generated.Diagnostics); - Assert.Equal("RZ1005", diagnostic.Id); + Assert.Collection( + generated.Diagnostics, + d => Assert.Equal("RZ9986", d.Id), + d => Assert.Equal("RZ1005", d.Id)); } [Fact] diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperParseTreeRewriterTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperParseTreeRewriterTest.cs index ef3603fa90..044f59124d 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperParseTreeRewriterTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperParseTreeRewriterTest.cs @@ -1880,5 +1880,57 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy { RunParseTreeRewriterTest("Foo"); } + + public static TagHelperDescriptor[] CaseSensitive_Descriptors = new TagHelperDescriptor[] + { + TagHelperDescriptorBuilder.Create("pTagHelper", "SomeAssembly") + .SetCaseSensitive() + .BoundAttributeDescriptor(attribute => + attribute + .Name("bound") + .PropertyName("Bound") + .TypeName(typeof(bool).FullName)) + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("p") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .Build(), + TagHelperDescriptorBuilder.Create("catchAllTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => + rule + .RequireTagName("*") + .RequireAttributeDescriptor(attribute => attribute.Name("catchAll"))) + .Build(), + }; + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly1() + { + EvaluateData(CaseSensitive_Descriptors, "

"); + } + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly2() + { + EvaluateData(CaseSensitive_Descriptors, "

"); + } + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly3() + { + EvaluateData(CaseSensitive_Descriptors, "

"); + } + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly4() + { + EvaluateData(CaseSensitive_Descriptors, "

"); + } + + [Fact] + public void HandlesCaseSensitiveTagHelpersCorrectly5() + { + EvaluateData(CaseSensitive_Descriptors, "

"); + } } } \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperBinderTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperBinderTest.cs index 73b40802bb..ab3439b2e9 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperBinderTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperBinderTest.cs @@ -32,12 +32,12 @@ namespace Microsoft.AspNetCore.Razor.Language parentIsTagHelper: false); // Assert - Assert.Equal(expectedDescriptors, bindingResult.Descriptors, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptors, bindingResult.Descriptors, TagHelperDescriptorComparer.Default); Assert.Equal("th:div", bindingResult.TagName); Assert.Equal("body", bindingResult.ParentTagName); Assert.Equal(expectedAttributes, bindingResult.Attributes); Assert.Equal("th:", bindingResult.TagHelperPrefix); - Assert.Equal(divTagHelper.TagMatchingRules, bindingResult.Mappings[divTagHelper], TagMatchingRuleDescriptorComparer.CaseSensitive); + Assert.Equal(divTagHelper.TagMatchingRules, bindingResult.Mappings[divTagHelper], TagMatchingRuleDescriptorComparer.Default); } public static TheoryData RequiredParentData @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Razor.Language parentIsTagHelper: false); // Assert - Assert.Equal((IEnumerable)expectedDescriptors, bindingResult.Descriptors, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal((IEnumerable)expectedDescriptors, bindingResult.Descriptors, TagHelperDescriptorComparer.Default); } public static TheoryData RequiredAttributeData @@ -277,7 +277,7 @@ namespace Microsoft.AspNetCore.Razor.Language var bindingResult = tagHelperBinder.GetBinding(tagName, providedAttributes, parentTagName: "p", parentIsTagHelper: false); // Assert - Assert.Equal((IEnumerable)expectedDescriptors, bindingResult?.Descriptors, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal((IEnumerable)expectedDescriptors, bindingResult?.Descriptors, TagHelperDescriptorComparer.Default); } [Fact] @@ -598,5 +598,59 @@ namespace Microsoft.AspNetCore.Razor.Language // Assert Assert.False(bindingResult.IsAttributeMatch); } + + [Fact] + public void GetBinding_CaseSensitiveRule_CaseMismatch_ReturnsNull() + { + // Arrange + var divTagHelper = TagHelperDescriptorBuilder.Create("DivTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("div")) + .SetCaseSensitive() + .Build(); + var expectedDescriptors = new[] { divTagHelper }; + var expectedAttributes = new[] + { + new KeyValuePair("class", "something") + }; + var tagHelperBinder = new TagHelperBinder("th:", expectedDescriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "th:Div", + attributes: expectedAttributes, + parentTagName: "body", + parentIsTagHelper: false); + + // Assert + Assert.Null(bindingResult); + } + + [Fact] + public void GetBinding_CaseSensitiveRequiredAttribute_CaseMismatch_ReturnsNull() + { + // Arrange + var divTagHelper = TagHelperDescriptorBuilder.Create("DivTagHelper", "SomeAssembly") + .TagMatchingRuleDescriptor(rule => rule + .RequireTagName("div") + .RequireAttributeDescriptor(attribute => attribute.Name("class"))) + .SetCaseSensitive() + .Build(); + var expectedDescriptors = new[] { divTagHelper }; + var expectedAttributes = new[] + { + new KeyValuePair("CLASS", "something") + }; + var tagHelperBinder = new TagHelperBinder(null, expectedDescriptors); + + // Act + var bindingResult = tagHelperBinder.GetBinding( + tagName: "div", + attributes: expectedAttributes, + parentTagName: "body", + parentIsTagHelper: false); + + // Assert + Assert.Null(bindingResult); + } } } \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperMatchingConventionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperMatchingConventionsTest.cs index 7a1fc6c1e3..afda769414 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperMatchingConventionsTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TagHelperMatchingConventionsTest.cs @@ -140,8 +140,10 @@ namespace Microsoft.AspNetCore.Razor.Language bool expectedResult) { // Arrange + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var tagMatchingRuleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); + var builder = new DefaultRequiredAttributeDescriptorBuilder(tagMatchingRuleBuilder); - var builder = new DefaultRequiredAttributeDescriptorBuilder(); configure(builder); var requiredAttibute = builder.Build(); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..da80e7da99 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,44 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + __o = +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ; + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..9a5add6521 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [30] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (6:0,6 [21] x:\dir\subdir\Test\TestComponent.cshtml) - @BIND=" - " + CSharpExpressionAttributeValue - (14:0,14 [12] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (15:0,15 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + HtmlContent - (30:0,30 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (30:0,30 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (39:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (39:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.mappings.txt new file mode 100644 index 0000000000..895df80e01 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (15:0,15 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (878:25,15 [11] ) +|ParentValue| + +Source Location: (39:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1082:35,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..0dcd6ea2b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(4,1): Warning RZ10014: Found markup element with unexpected name 'SomeComponent'. If this is intended to be a component, add a @using directive for its namespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..0e75622023 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,57 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(MyComponent); + +#line default +#line hidden +#nullable disable + __o = ""; + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + true + +#line default +#line hidden +#nullable disable + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(MyComponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..d7543ebcf9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,28 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [15] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + HtmlContent - (15:0,15 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (15:0,15 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (17:1,0 [15] x:\dir\subdir\Test\TestComponent.cshtml) - mycomponent + HtmlContent - (32:1,15 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (32:1,15 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (34:2,0 [51] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - - intproperty - AttributeStructure.SingleQuotes + HtmlContent - (60:2,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (60:2,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 1 + ComponentAttribute - (77:2,43 [4] x:\dir\subdir\Test\TestComponent.cshtml) - BoolProperty - AttributeStructure.SingleQuotes + IntermediateToken - (77:2,43 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.mappings.txt new file mode 100644 index 0000000000..e01a00ec83 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (77:2,43 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|true| +Generated Location: (1301:36,43 [4] ) +|true| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.codegen.cs new file mode 100644 index 0000000000..447d620529 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.codegen.cs @@ -0,0 +1,65 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + 1 + +#line default +#line hidden +#nullable disable + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(MyComponent); + +#line default +#line hidden +#nullable disable + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + 2 + +#line default +#line hidden +#nullable disable + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(Mycomponent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.ir.txt new file mode 100644 index 0000000000..b91de37da2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - IntProperty - AttributeStructure.SingleQuotes + IntermediateToken - (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 1 + HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (33:1,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - Mycomponent + ComponentAttribute - (59:1,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - IntProperty - AttributeStructure.SingleQuotes + IntermediateToken - (59:1,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.mappings.txt new file mode 100644 index 0000000000..f3773885e4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|1| +Generated Location: (960:25,26 [1] ) +|1| + +Source Location: (59:1,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|2| +Generated Location: (1515:44,26 [1] ) +|2| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs new file mode 100644 index 0000000000..6446930de5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs @@ -0,0 +1,45 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + text + +#line default +#line hidden +#nullable disable + ); + __o = Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text); + } + #pragma warning restore 1998 +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private string text = "hi"; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..02b5d2763b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,3): Error RZ10008: The attribute 'Value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'Value' is used by the '@bind' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt new file mode 100644 index 0000000000..99c52ebd52 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt @@ -0,0 +1,44 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [69] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (9:1,2 [52] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (22:1,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (22:1,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - - Value=" - " + HtmlAttributeValue - (35:1,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (35:1,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 + HtmlAttribute - (46:1,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (47:1,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (46:1,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, + IntermediateToken - - CSharp - text + IntermediateToken - - CSharp - ) + HtmlContent - (61:1,54 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (61:1,54 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (69:2,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (69:2,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (119:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (119:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (83:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (83:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private string text = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt new file mode 100644 index 0000000000..2b13abd3aa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (47:1,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|text| +Generated Location: (956:25,40 [4] ) +|text| + +Source Location: (83:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) +| + private string text = "hi"; +| +Generated Location: (1285:36,12 [35] ) +| + private string text = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.codegen.cs new file mode 100644 index 0000000000..3efad2f87c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.codegen.cs @@ -0,0 +1,27 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.ir.txt new file mode 100644 index 0000000000..571cb8412f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.ir.txt @@ -0,0 +1,20 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [18] x:\dir\subdir\Test\TestComponent.cshtml) - NotAComponent + HtmlContent - (18:0,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (18:0,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (20:1,0 [53] x:\dir\subdir\Test\TestComponent.cshtml) - DefinitelyNotAComponent diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..ca056d5b10 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private object someObject = new object(); + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..c644e00e2b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,34 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [84] x:\dir\subdir\Test\TestComponent.cshtml) - elem + HtmlAttribute - (5:0,5 [25] x:\dir\subdir\Test\TestComponent.cshtml) - attributebefore=" - " + HtmlAttributeValue - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - before + HtmlAttribute - (30:0,30 [18] x:\dir\subdir\Test\TestComponent.cshtml) - @KEY=" - " + HtmlAttributeValue - (37:0,37 [10] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (37:0,37 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - someObject + HtmlAttribute - (48:0,48 [23] x:\dir\subdir\Test\TestComponent.cshtml) - attributeafter=" - " + HtmlAttributeValue - (65:0,65 [5] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (65:0,65 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after + HtmlContent - (72:0,72 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:0,72 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlContent - (84:0,84 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (84:0,84 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (145:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (145:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (95:2,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:2,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private object someObject = new object();\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.mappings.txt new file mode 100644 index 0000000000..a8551246fb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (95:2,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) +| + private object someObject = new object(); +| +Generated Location: (899:26,7 [49] ) +| + private object someObject = new object(); +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..3efad2f87c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,27 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..965abd8a50 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,28 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [80] x:\dir\subdir\Test\TestComponent.cshtml) - elem + HtmlAttribute - (5:0,5 [25] x:\dir\subdir\Test\TestComponent.cshtml) - attributebefore=" - " + HtmlAttributeValue - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - before + HtmlAttribute - (30:0,30 [14] x:\dir\subdir\Test\TestComponent.cshtml) - @rEF=" - " + HtmlAttributeValue - (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - myElem + HtmlAttribute - (44:0,44 [23] x:\dir\subdir\Test\TestComponent.cshtml) - attributeafter=" - " + HtmlAttributeValue - (61:0,61 [5] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (61:0,61 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after + HtmlContent - (68:0,68 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (68:0,68 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..79057687db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Dictionary someAttributes = new Dictionary(); + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..6e83da6e4a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,34 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [95] x:\dir\subdir\Test\TestComponent.cshtml) - elem + HtmlAttribute - (5:0,5 [25] x:\dir\subdir\Test\TestComponent.cshtml) - attributebefore=" - " + HtmlAttributeValue - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - before + HtmlAttribute - (30:0,30 [29] x:\dir\subdir\Test\TestComponent.cshtml) - @ATTributes=" - " + HtmlAttributeValue - (44:0,44 [14] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:0,44 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Html - someAttributes + HtmlAttribute - (59:0,59 [23] x:\dir\subdir\Test\TestComponent.cshtml) - attributeafter=" - " + HtmlAttributeValue - (76:0,76 [5] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (76:0,76 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after + HtmlContent - (83:0,83 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (83:0,83 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlContent - (95:0,95 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:0,95 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (200:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (200:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (106:2,7 [93] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (106:2,7 [93] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Dictionary someAttributes = new Dictionary();\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.mappings.txt new file mode 100644 index 0000000000..2715ebcd75 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (106:2,7 [93] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Dictionary someAttributes = new Dictionary(); +| +Generated Location: (899:26,7 [93] ) +| + private Dictionary someAttributes = new Dictionary(); +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..356f4e9ce0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick(UIMouseEventArgs e) { + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..94d094aba5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + CSharpCode - + IntermediateToken - - CSharp - #pragma warning disable 0414 + CSharpCode - + IntermediateToken - - CSharp - private static System.Object __o = null; + CSharpCode - + IntermediateToken - - CSharp - #pragma warning restore 0414 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (6:0,6 [19] x:\dir\subdir\Test\TestComponent.cshtml) - @onCLICK=" - " + HtmlAttributeValue - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - OnClick + HtmlContent - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (37:1,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (37:1,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick(UIMouseEventArgs e) {\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.mappings.txt new file mode 100644 index 0000000000..090024800d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (37:1,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick(UIMouseEventArgs e) { + } +| +Generated Location: (899:26,7 [49] ) +| + void OnClick(UIMouseEventArgs e) { + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..af29d947d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,39 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "@BIND", +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden +#nullable disable + ); + builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..b411813ed9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [30] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (6:0,6 [21] x:\dir\subdir\Test\TestComponent.cshtml) - @BIND=" - " + CSharpExpressionAttributeValue - (14:0,14 [12] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (15:0,15 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + CSharpCode - (39:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (39:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.mappings.txt new file mode 100644 index 0000000000..60cf603474 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_IsCaseSensitive/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (39:1,7 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (925:30,7 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.codegen.cs index 2a467f5166..3f020b8298 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.codegen.cs @@ -29,7 +29,9 @@ using Foo = Test3; { builder.OpenComponent(0); builder.CloseComponent(); - builder.AddMarkupContent(1, "\r\n"); + builder.AddMarkupContent(1, "\r\n"); + builder.OpenElement(2, "SomeComponent"); + builder.CloseElement(); } #pragma warning restore 1998 } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..0dcd6ea2b9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(4,1): Warning RZ10014: Found markup element with unexpected name 'SomeComponent'. If this is intended to be a component, add a @using directive for its namespace. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.ir.txt index 5e6295960a..0588c17fee 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.ir.txt @@ -10,4 +10,6 @@ Document - ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree Component - (55:2,0 [15] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - MarkupBlock - - \n + HtmlContent - (70:2,15 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (70:2,15 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (72:3,0 [17] x:\dir\subdir\Test\TestComponent.cshtml) - SomeComponent diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..84a07e8f37 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.OpenComponent(0); + builder.CloseComponent(); + builder.AddMarkupContent(1, "\r\n\r\n"); + builder.OpenComponent(2); + builder.AddAttribute(3, "intproperty", "1"); + builder.AddAttribute(4, "BoolProperty", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + true + +#line default +#line hidden +#nullable disable + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..bf70025a0b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MatchingIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [15] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + MarkupBlock - - \n\n + Component - (34:2,0 [51] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - - intproperty - AttributeStructure.SingleQuotes + HtmlContent - (60:2,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (60:2,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 1 + ComponentAttribute - (77:2,43 [4] x:\dir\subdir\Test\TestComponent.cshtml) - BoolProperty - AttributeStructure.SingleQuotes + IntermediateToken - (77:2,43 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.codegen.cs new file mode 100644 index 0000000000..bfc17917d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.OpenComponent(0); + builder.AddAttribute(1, "IntProperty", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + 1 + +#line default +#line hidden +#nullable disable + )); + builder.CloseComponent(); + builder.AddMarkupContent(2, "\r\n"); + builder.OpenComponent(3); + builder.AddAttribute(4, "IntProperty", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + 2 + +#line default +#line hidden +#nullable disable + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.ir.txt new file mode 100644 index 0000000000..a58911a312 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_MultipleComponentsDifferByCase/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - IntProperty - AttributeStructure.SingleQuotes + IntermediateToken - (26:0,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 1 + HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + Component - (33:1,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - Mycomponent + ComponentAttribute - (59:1,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - IntProperty - AttributeStructure.SingleQuotes + IntermediateToken - (59:1,26 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 2 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs new file mode 100644 index 0000000000..0b002da471 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.OpenElement(0, "div"); + builder.AddMarkupContent(1, "\r\n "); + builder.OpenElement(2, "input"); + builder.AddAttribute(3, "type", "text"); + builder.AddAttribute(4, "Value", "17"); + builder.AddAttribute(5, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + text + +#line default +#line hidden +#nullable disable + )); + builder.AddAttribute(6, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); + builder.SetUpdatesAttributeName("value"); + builder.CloseElement(); + builder.AddMarkupContent(7, "\r\n"); + builder.CloseElement(); + } + #pragma warning restore 1998 +#nullable restore +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private string text = "hi"; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..02b5d2763b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,3): Error RZ10008: The attribute 'Value' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'Value' is used by the '@bind' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt new file mode 100644 index 0000000000..01d33ffb1a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.ir.txt @@ -0,0 +1,33 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupElement - (0:0,0 [69] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (5:0,5 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (9:1,2 [52] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (22:1,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (22:1,15 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - - Value=" - " + HtmlAttributeValue - (35:1,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (35:1,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - 17 + HtmlAttribute - (46:1,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (47:1,40 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (46:1,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, + IntermediateToken - - CSharp - text + IntermediateToken - - CSharp - ) + HtmlContent - (61:1,54 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (61:1,54 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (83:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (83:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private string text = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt new file mode 100644 index 0000000000..ee9e5de003 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_DifferentCasing_IsAnError_BindValue/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (83:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) +| + private string text = "hi"; +| +Generated Location: (1504:38,12 [35] ) +| + private string text = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.codegen.cs new file mode 100644 index 0000000000..5a0a955b96 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.codegen.cs @@ -0,0 +1,21 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.AddMarkupContent(0, "\r\n"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.ir.txt new file mode 100644 index 0000000000..f3e523b7a0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ElementWithUppercaseTagName_CanHideWarningWithBang/TestComponent.ir.txt @@ -0,0 +1,10 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupBlock - - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..3d8a29f719 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.AddMarkupContent(0, "Hello"); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private object someObject = new object(); + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..554b419774 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupBlock - - Hello + CSharpCode - (95:2,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:2,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private object someObject = new object();\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.mappings.txt new file mode 100644 index 0000000000..8bdee6f4b2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithKey_AttributeNameIsCaseSensitive/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (95:2,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) +| + private object someObject = new object(); +| +Generated Location: (767:20,7 [49] ) +| + private object someObject = new object(); +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..13c4866185 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,21 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.AddMarkupContent(0, "Hello"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..ee469bdbbc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AttributeNameIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,10 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupBlock - - Hello diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..d44918f210 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.AddMarkupContent(0, "Hello"); + } + #pragma warning restore 1998 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Dictionary someAttributes = new Dictionary(); + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..a92e72da17 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupBlock - - Hello + CSharpCode - (106:2,7 [93] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (106:2,7 [93] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Dictionary someAttributes = new Dictionary();\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.mappings.txt new file mode 100644 index 0000000000..520861be0a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithSplat_AttributeNameIsCaseSensitive/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (106:2,7 [93] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Dictionary someAttributes = new Dictionary(); +| +Generated Location: (778:20,7 [93] ) +| + private Dictionary someAttributes = new Dictionary(); +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.codegen.cs new file mode 100644 index 0000000000..575595427d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.codegen.cs @@ -0,0 +1,30 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + builder.AddMarkupContent(0, ""); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick(UIMouseEventArgs e) { + } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.ir.txt new file mode 100644 index 0000000000..33c36944db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupBlock - - + CSharpCode - (37:1,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (37:1,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick(UIMouseEventArgs e) {\n }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.mappings.txt new file mode 100644 index 0000000000..1ab598aff8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_AttributeNameIsCaseSensitive/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (37:1,7 [49] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick(UIMouseEventArgs e) { + } +| +Generated Location: (705:20,7 [49] ) +| + void OnClick(UIMouseEventArgs e) { + } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.cspans.txt new file mode 100644 index 0000000000..9244132d92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.stree.txt new file mode 100644 index 0000000000..efa4cd5f46 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..28)::28 - [

] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - p[StartTagAndEndTag] - pTagHelper - catchAllTagHelper + MarkupTagHelperStartTag - [0..24)::24 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - class - SingleQuotes - Unbound - [ class='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [14..23)::9 - catchAll - Minimized - Unbound - [ catchAll] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..23)::8 - [catchAll] - Gen - SpanEditHandler;Accepts:Any + Text;[catchAll]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [24..28)::4 - [

] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.tspans.txt new file mode 100644 index 0000000000..f9a1aca732 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly1.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - pTagHelper - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.cspans.txt new file mode 100644 index 0000000000..9244132d92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.stree.txt new file mode 100644 index 0000000000..b3397e054d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..28)::28 - [

] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - p[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..24)::24 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupTagHelperAttribute - [2..14)::12 - CLASS - SingleQuotes - Unbound - [ CLASS='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [CLASS] - Gen - SpanEditHandler;Accepts:Any + Text;[CLASS]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [14..23)::9 - CATCHAll - Minimized - Unbound - [ CATCHAll] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..23)::8 - [CATCHAll] - Gen - SpanEditHandler;Accepts:Any + Text;[CATCHAll]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [24..28)::4 - [

] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.tspans.txt new file mode 100644 index 0000000000..2a9461471f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly2.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.cspans.txt new file mode 100644 index 0000000000..9244132d92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.cspans.txt @@ -0,0 +1 @@ +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [28] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.stree.txt new file mode 100644 index 0000000000..abf07adaa8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.stree.txt @@ -0,0 +1,31 @@ +RazorDocument - [0..28)::28 - [

] + MarkupBlock - [0..28)::28 + MarkupTagHelperElement - [0..28)::28 - P[StartTagAndEndTag] - catchAllTagHelper + MarkupTagHelperStartTag - [0..24)::24 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[P]; + MarkupTagHelperAttribute - [2..14)::12 - class - SingleQuotes - Unbound - [ class='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupTagHelperAttributeValue - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + MarkupMinimizedTagHelperAttribute - [14..23)::9 - CATCHAll - Minimized - Unbound - [ CATCHAll] + MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [15..23)::8 - [CATCHAll] - Gen - SpanEditHandler;Accepts:Any + Text;[CATCHAll]; + CloseAngle;[>]; + MarkupTagHelperEndTag - [24..28)::4 - [

] + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[P]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.tspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.tspans.txt new file mode 100644 index 0000000000..2a9461471f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly3.tspans.txt @@ -0,0 +1 @@ +TagHelper span at (0:0,0 [28] ) - catchAllTagHelper diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.cspans.txt new file mode 100644 index 0000000000..34f63d813d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (2:0,2 [8] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (13:0,13 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (15:0,15 [4] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.stree.txt new file mode 100644 index 0000000000..67601f532c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly4.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..19)::19 - [

] + MarkupBlock - [0..19)::19 + MarkupElement - [0..19)::19 + MarkupStartTag - [0..15)::15 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[P]; + MarkupAttributeBlock - [2..14)::12 - [ class='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [class] - Gen - SpanEditHandler;Accepts:Any + Text;[class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [15..19)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[P]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.cspans.txt new file mode 100644 index 0000000000..34f63d813d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.cspans.txt @@ -0,0 +1,6 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (2:0,2 [8] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (10:0,10 [3] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (13:0,13 [1] ) (Accepts:Any) - Parent: Markup block at (2:0,2 [12] ) +Markup span at (14:0,14 [1] ) (Accepts:Any) - Parent: Tag block at (0:0,0 [15] ) +Markup span at (15:0,15 [4] ) (Accepts:Any) - Parent: Tag block at (15:0,15 [4] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.stree.txt new file mode 100644 index 0000000000..94fc32106e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/TagHelperParseTreeRewriterTest/HandlesCaseSensitiveTagHelpersCorrectly5.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..19)::19 - [

] + MarkupBlock - [0..19)::19 + MarkupElement - [0..19)::19 + MarkupStartTag - [0..15)::15 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + Text;[p]; + MarkupAttributeBlock - [2..14)::12 - [ Class='foo'] + MarkupTextLiteral - [2..3)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any + Whitespace;[ ]; + MarkupTextLiteral - [3..8)::5 - [Class] - Gen - SpanEditHandler;Accepts:Any + Text;[Class]; + Equals;[=]; + MarkupTextLiteral - [9..10)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + GenericBlock - [10..13)::3 + MarkupLiteralAttributeValue - [10..13)::3 - [foo] + MarkupTextLiteral - [10..13)::3 - [foo] - Gen - SpanEditHandler;Accepts:Any + Text;[foo]; + MarkupTextLiteral - [13..14)::1 - ['] - Gen - SpanEditHandler;Accepts:Any + SingleQuote;[']; + CloseAngle;[>]; + MarkupEndTag - [15..19)::4 - [

] - Gen - SpanEditHandler;Accepts:Any + OpenAngle;[<]; + ForwardSlash;[/]; + Text;[p]; + CloseAngle;[>]; diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs index 34d70280a2..04512ecb69 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs @@ -125,6 +125,7 @@ namespace Microsoft.CodeAnalysis.Razor private TagHelperDescriptor CreateFallbackBindTagHelper() { var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Bind.TagHelperKind, "Bind", ComponentsApi.AssemblyName); + builder.CaseSensitive = true; builder.Documentation = ComponentResources.BindTagHelper_Fallback_Documentation; builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Bind.TagHelperKind); @@ -292,6 +293,7 @@ namespace Microsoft.CodeAnalysis.Razor var eventName = entry.Suffix == null ? "Event_" + entry.ValueAttribute : "Event_" + entry.Suffix; var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Bind.TagHelperKind, name, ComponentsApi.AssemblyName); + builder.CaseSensitive = true; builder.Documentation = string.Format( ComponentResources.BindTagHelper_Element_Documentation, entry.ValueAttribute, @@ -469,6 +471,7 @@ namespace Microsoft.CodeAnalysis.Razor var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Bind.TagHelperKind, tagHelper.Name, tagHelper.AssemblyName); builder.DisplayName = tagHelper.DisplayName; + builder.CaseSensitive = true; builder.Documentation = string.Format( ComponentResources.BindTagHelper_Component_Documentation, valueAttribute.Name, diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs index 57b64c6abc..17eb8b3918 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs @@ -91,7 +91,10 @@ namespace Microsoft.CodeAnalysis.Razor private TagHelperDescriptor CreateShortNameMatchingDescriptor(ComponentSymbols symbols, INamedTypeSymbol type) { var builder = CreateDescriptorBuilder(symbols, type); - builder.TagMatchingRule(r => r.TagName = type.Name); + builder.TagMatchingRule(r => + { + r.TagName = type.Name; + }); return builder.Build(); } @@ -101,7 +104,10 @@ namespace Microsoft.CodeAnalysis.Razor var builder = CreateDescriptorBuilder(symbols, type); var containingNamespace = type.ContainingNamespace.ToDisplayString(); var fullName = $"{containingNamespace}.{type.Name}"; - builder.TagMatchingRule(r => r.TagName = fullName); + builder.TagMatchingRule(r => + { + r.TagName = fullName; + }); builder.Metadata[ComponentMetadata.Component.NameMatchKey] = ComponentMetadata.Component.FullyQualifiedNameMatch; return builder.Build(); @@ -114,6 +120,7 @@ namespace Microsoft.CodeAnalysis.Razor var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Component.TagHelperKind, typeName, assemblyName); builder.SetTypeName(typeName); + builder.CaseSensitive = true; // This opts out this 'component' tag helper for any processing that's specific to the default // Razor ITagHelper runtime. @@ -264,6 +271,7 @@ namespace Microsoft.CodeAnalysis.Razor var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.ChildContent.TagHelperKind, typeName, assemblyName); builder.SetTypeName(typeName); + builder.CaseSensitive = true; // This opts out this 'component' tag helper for any processing that's specific to the default // Razor ITagHelper runtime. diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs index d8683796a9..9eead66e2e 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs @@ -106,6 +106,7 @@ namespace Microsoft.CodeAnalysis.Razor var eventArgType = entry.EventArgsType.ToDisplayString(); var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.EventHandler.TagHelperKind, entry.Attribute, ComponentsApi.AssemblyName); + builder.CaseSensitive = true; builder.Documentation = string.Format( ComponentResources.EventHandlerTagHelper_Documentation, attributeName, diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/KeyTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/KeyTagHelperDescriptorProvider.cs index ea2830b91b..789abca318 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/KeyTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/KeyTagHelperDescriptorProvider.cs @@ -41,6 +41,7 @@ namespace Microsoft.CodeAnalysis.Razor private TagHelperDescriptor CreateKeyTagHelper() { var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Key.TagHelperKind, "Key", ComponentsApi.AssemblyName); + builder.CaseSensitive = true; builder.Documentation = ComponentResources.KeyTagHelper_Documentation; builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Key.TagHelperKind); diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs index ccc3ee7ad0..7cce7808e6 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs @@ -41,6 +41,7 @@ namespace Microsoft.CodeAnalysis.Razor private TagHelperDescriptor CreateRefTagHelper() { var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Ref.TagHelperKind, "Ref", ComponentsApi.AssemblyName); + builder.CaseSensitive = true; builder.Documentation = ComponentResources.RefTagHelper_Documentation; builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Ref.TagHelperKind); diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/SplatTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/SplatTagHelperDescriptorProvider.cs index 86aa7a78e3..3d64214427 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/SplatTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/SplatTagHelperDescriptorProvider.cs @@ -41,6 +41,7 @@ namespace Microsoft.CodeAnalysis.Razor private TagHelperDescriptor CreateSplatTagHelper() { var builder = TagHelperDescriptorBuilder.Create(ComponentMetadata.Splat.TagHelperKind, "Attributes", ComponentsApi.AssemblyName); + builder.CaseSensitive = true; builder.Documentation = ComponentResources.SplatTagHelper_Documentation; builder.Metadata.Add(ComponentMetadata.SpecialKindKey, ComponentMetadata.Splat.TagHelperKind); diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/BaseTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/BaseTagHelperDescriptorProviderTest.cs index d8fd1bcbeb..117d9c0c34 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/BaseTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/BaseTagHelperDescriptorProviderTest.cs @@ -35,6 +35,7 @@ namespace Microsoft.CodeAnalysis.Razor .Where(c => c.GetTypeName() != "Microsoft.AspNetCore.Components.Bind") .Where(c => c.GetTypeName() != "Microsoft.AspNetCore.Components.BindAttributes") .Where(c => c.GetTypeName() != "Microsoft.AspNetCore.Components.EventHandlers") + .Where(c => !c.GetTypeName().StartsWith("Microsoft.AspNetCore.Components.Routing")) .OrderBy(c => c.Name) .ToArray(); } diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs index 825326d6f8..89b42a0ae3 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/BindTagHelperDescriptorProviderTest.cs @@ -76,6 +76,7 @@ namespace Test Assert.False(bind.IsDefaultKind()); Assert.False(bind.KindUsesDefaultTagHelperRuntime()); Assert.False(bind.IsComponentOrChildContentTagHelper()); + Assert.True(bind.CaseSensitive); Assert.Equal("MyProperty", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); Assert.Equal("MyPropertyChanged", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); @@ -197,6 +198,7 @@ namespace Test Assert.False(bind.IsDefaultKind()); Assert.False(bind.KindUsesDefaultTagHelperRuntime()); Assert.False(bind.IsComponentOrChildContentTagHelper()); + Assert.True(bind.CaseSensitive); Assert.Equal("MyProperty", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); Assert.Equal("MyPropertyChanged", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); @@ -349,6 +351,7 @@ namespace Test Assert.False(bind.IsDefaultKind()); Assert.False(bind.KindUsesDefaultTagHelperRuntime()); Assert.False(bind.IsComponentOrChildContentTagHelper()); + Assert.True(bind.CaseSensitive); Assert.Equal("myprop", bind.Metadata[ComponentMetadata.Bind.ValueAttribute]); Assert.Equal("myevent", bind.Metadata[ComponentMetadata.Bind.ChangeAttribute]); @@ -778,6 +781,7 @@ namespace Test Assert.False(bind.IsDefaultKind()); Assert.False(bind.KindUsesDefaultTagHelperRuntime()); Assert.False(bind.IsComponentOrChildContentTagHelper()); + Assert.True(bind.CaseSensitive); Assert.False(bind.Metadata.ContainsKey(ComponentMetadata.Bind.ValueAttribute)); Assert.False(bind.Metadata.ContainsKey(ComponentMetadata.Bind.ChangeAttribute)); diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs index f5325fdb05..84e92ba30f 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs @@ -65,6 +65,7 @@ namespace Test Assert.False(component.IsDefaultKind()); Assert.False(component.KindUsesDefaultTagHelperRuntime()); Assert.True(component.IsComponentOrChildContentTagHelper()); + Assert.True(component.CaseSensitive); // No documentation in this test Assert.Null(component.Documentation); @@ -108,6 +109,7 @@ namespace Test Assert.Null(attribute.IndexerTypeName); Assert.False(attribute.IsIndexerBooleanProperty); Assert.False(attribute.IsIndexerStringProperty); + Assert.True(component.CaseSensitive); // No documentation in this test Assert.Null(attribute.Documentation); diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorFactoryTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorFactoryTest.cs index 64f092cdb3..7465c6e903 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorFactoryTest.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/DefaultTagHelperDescriptorFactoryTest.cs @@ -200,12 +200,13 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces IEnumerable> configureBuilders) { // Arrange - var ruleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(); + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var ruleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); var expectedRules = new List(); foreach (var configureBuilder in configureBuilders) { - var builder = new DefaultRequiredAttributeDescriptorBuilder(); + var builder = new DefaultRequiredAttributeDescriptorBuilder(ruleBuilder); configureBuilder(builder); expectedRules.Add(builder.Build()); @@ -216,7 +217,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces // Assert var descriptors = ruleBuilder.Build().Attributes; - Assert.Equal(expectedRules, descriptors, RequiredAttributeDescriptorComparer.CaseSensitive); + Assert.Equal(expectedRules, descriptors, RequiredAttributeDescriptorComparer.Default); } public static TheoryData RequiredAttributeParserData @@ -294,12 +295,13 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces IEnumerable> configureBuilders) { // Arrange - var ruleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(); + var tagHelperBuilder = new DefaultTagHelperDescriptorBuilder(TagHelperConventions.DefaultKind, "TestTagHelper", "Test"); + var ruleBuilder = new DefaultTagMatchingRuleDescriptorBuilder(tagHelperBuilder); var expectedRules = new List(); foreach (var configureBuilder in configureBuilders) { - var builder = new DefaultRequiredAttributeDescriptorBuilder(); + var builder = new DefaultRequiredAttributeDescriptorBuilder(ruleBuilder); configureBuilder(builder); expectedRules.Add(builder.Build()); @@ -310,7 +312,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces // Assert var descriptors = ruleBuilder.Build().Attributes; - Assert.Equal(expectedRules, descriptors, RequiredAttributeDescriptorComparer.CaseSensitive); + Assert.Equal(expectedRules, descriptors, RequiredAttributeDescriptorComparer.Default); } public static TheoryData IsEnumData @@ -399,7 +401,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } public static TheoryData RequiredParentData @@ -450,7 +452,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } public static TheoryData RestrictChildrenData @@ -506,7 +508,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } public static TheoryData TagStructureData @@ -566,7 +568,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } public static TheoryData EditorBrowsableData @@ -741,7 +743,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } public static TheoryData AttributeTargetData @@ -938,7 +940,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } public static TheoryData HtmlCaseData @@ -1012,7 +1014,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1046,7 +1048,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1080,7 +1082,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1105,7 +1107,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1131,7 +1133,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1158,7 +1160,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1185,7 +1187,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1210,7 +1212,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1241,7 +1243,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1267,7 +1269,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1291,7 +1293,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] @@ -1310,7 +1312,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } // name, expectedErrorMessages @@ -1763,7 +1765,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } public static TheoryData TagHelperWithPrefixData @@ -2020,7 +2022,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces Assert.Equal( expectedAttributeDescriptors, descriptor.BoundAttributes, - BoundAttributeDescriptorComparer.CaseSensitive); + BoundAttributeDescriptorComparer.Default); Assert.Equal(expectedDiagnostics, descriptor.GetAllDiagnostics()); } @@ -2081,7 +2083,7 @@ namespace Microsoft.CodeAnalysis.Razor.Workspaces var descriptor = factory.CreateDescriptor(typeSymbol); // Assert - Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(expectedDescriptor, descriptor, TagHelperDescriptorComparer.Default); } [Fact] diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/EventHandlerTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/EventHandlerTagHelperDescriptorProviderTest.cs index e2d372f1fe..673ad67050 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/EventHandlerTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/EventHandlerTagHelperDescriptorProviderTest.cs @@ -57,6 +57,7 @@ namespace Test Assert.False(item.IsDefaultKind()); Assert.False(item.KindUsesDefaultTagHelperRuntime()); Assert.False(item.IsComponentOrChildContentTagHelper()); + Assert.True(item.CaseSensitive); Assert.Equal( "Sets the '@onclick' attribute to the provided string or delegate value. " + diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/KeyTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/KeyTagHelperDescriptorProviderTest.cs index b937b62685..3018afea55 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/KeyTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/KeyTagHelperDescriptorProviderTest.cs @@ -36,6 +36,7 @@ namespace Microsoft.CodeAnalysis.Razor Assert.False(item.IsDefaultKind()); Assert.False(item.KindUsesDefaultTagHelperRuntime()); Assert.False(item.IsComponentOrChildContentTagHelper()); + Assert.True(item.CaseSensitive); Assert.Equal( "Ensures that the component or element will be preserved across renders if (and only if) the supplied key value matches.", diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs index ef4a3ed558..5740418f77 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs @@ -36,6 +36,7 @@ namespace Microsoft.CodeAnalysis.Razor Assert.False(item.IsDefaultKind()); Assert.False(item.KindUsesDefaultTagHelperRuntime()); Assert.False(item.IsComponentOrChildContentTagHelper()); + Assert.True(item.CaseSensitive); Assert.Equal( "Generates the specified field, and populates it during rendering with a reference to the element or component.", diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/SplatTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/SplatTagHelperDescriptorProviderTest.cs index c07c95a2aa..7832da05ac 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/SplatTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/SplatTagHelperDescriptorProviderTest.cs @@ -35,6 +35,7 @@ namespace Microsoft.CodeAnalysis.Razor Assert.Equal(ComponentMetadata.Splat.RuntimeName, item.Metadata[TagHelperMetadata.Runtime.Name]); Assert.False(item.IsDefaultKind()); Assert.False(item.KindUsesDefaultTagHelperRuntime()); + Assert.True(item.CaseSensitive); Assert.Equal( "Merges a collection of attributes into the current element or component.", diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Intermediate/IntermediateNodeAssert.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Intermediate/IntermediateNodeAssert.cs index b4fc6f105e..36f7a55414 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Intermediate/IntermediateNodeAssert.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/Intermediate/IntermediateNodeAssert.cs @@ -351,7 +351,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate Assert.Equal(tagName, tagHelperNode.TagName); Assert.Equal(tagMode, tagHelperNode.TagMode); - Assert.Equal(tagHelpers, tagHelperNode.TagHelpers, TagHelperDescriptorComparer.CaseSensitive); + Assert.Equal(tagHelpers, tagHelperNode.TagHelpers, TagHelperDescriptorComparer.Default); } catch (XunitException e) { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestTagHelperDescriptorBuilderExtensions.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestTagHelperDescriptorBuilderExtensions.cs index 5bc81a7792..6590dd3065 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestTagHelperDescriptorBuilderExtensions.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common/Language/TestTagHelperDescriptorBuilderExtensions.cs @@ -55,6 +55,18 @@ namespace Microsoft.AspNetCore.Razor.Language return builder; } + public static TagHelperDescriptorBuilder SetCaseSensitive(this TagHelperDescriptorBuilder builder) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.CaseSensitive = true; + + return builder; + } + public static TagHelperDescriptorBuilder Documentation(this TagHelperDescriptorBuilder builder, string documentation) { if (builder == null) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.Manual.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.Manual.cs index b83fc48298..42a0d20589 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.Manual.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.Manual.cs @@ -45,3 +45,39 @@ namespace Microsoft.AspNetCore.Components.RenderTree public override string ToString() { throw null; } } } + +namespace Microsoft.AspNetCore.Components.Routing +{ + public partial class NavLink : Microsoft.AspNetCore.Components.IComponent, System.IDisposable + { + public NavLink() { } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public string ActiveClass { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + [Microsoft.AspNetCore.Components.ParameterAttribute(CaptureUnmatchedValues = true)] + public System.Collections.Generic.IReadOnlyDictionary AdditionalAttributes { get; private set; } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public RenderFragment ChildContent { get; set; } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public Microsoft.AspNetCore.Components.Routing.NavLinkMatch Match { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + public void Configure(Microsoft.AspNetCore.Components.RenderHandle renderHandle) { } + public void Dispose() { } + public System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; } + } + + public partial class Router : Microsoft.AspNetCore.Components.IComponent, System.IDisposable + { + public Router() { } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public System.Reflection.Assembly AppAssembly { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public Microsoft.AspNetCore.Components.RenderFragment NotFoundContent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public Microsoft.AspNetCore.Components.RenderFragment NotAuthorizedContent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public Microsoft.AspNetCore.Components.RenderFragment AuthorizingContent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + public void Configure(Microsoft.AspNetCore.Components.RenderHandle renderHandle) { } + public void Dispose() { } + protected virtual void Render(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, System.Type handler, System.Collections.Generic.IDictionary parameters) { } + public System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; } + } +} diff --git a/src/Razor/test/testassets/ComponentApp/Components/App.razor b/src/Razor/test/testassets/ComponentApp/Components/App.razor index 03eee81cef..72618a93bd 100644 --- a/src/Razor/test/testassets/ComponentApp/Components/App.razor +++ b/src/Razor/test/testassets/ComponentApp/Components/App.razor @@ -2,4 +2,4 @@ The Router component displays whichever component has a @page directive matching the current URI. *@ - + diff --git a/src/Razor/test/testassets/ComponentApp/Components/_Imports.razor b/src/Razor/test/testassets/ComponentApp/Components/_Imports.razor index 08636e04e8..287317eba6 100644 --- a/src/Razor/test/testassets/ComponentApp/Components/_Imports.razor +++ b/src/Razor/test/testassets/ComponentApp/Components/_Imports.razor @@ -1 +1,2 @@ @using ComponentApp.Components.Shared +@using Microsoft.AspNetCore.Components.Routing