From 95bb698c5a5de0444a0e849dbd20e8f815b164e7 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Tue, 21 May 2019 16:37:08 -0700 Subject: [PATCH] Make duplicate attribute names an error (dotnet/aspnetcore-tooling#604) This came up in the context of discussion around aspnet/AspNetCoredotnet/aspnetcore-tooling#5071. Browsers use a 'first attribute wins' rule for evaluating attributes and building the DOM - though duplicate attributes are considered to be a spec violation. Blazor wants to use 'last attribute wins' rules because that's most sensible when you consider evaluation order and splatting. This means that we have to have the markup block pass do the same thing as the Blazor runtime when duplicates appear. However, since this is a spec violation I'm proposing that we just make it an error (like we do for malformed tags). There's no useful purpose for duplicate attributes since browsers ignore it. Since we're not going to allow this for elements. Let's go all of the way and block it for components as well. And while we're here, lets block some of the invalid cases where users try to mix onchange and bind. These don't work today, so we should make them an error. If we decide to add support for this case to the runtime that would require compiler work anyway. \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/0c59ca5f74699efe8e1e046edb316af933eb469a --- .../Components/ComponentBindLoweringPass.cs | 20 ++ .../Components/ComponentDiagnosticFactory.cs | 50 ++- ...mponentDuplicateAttributeDiagnosticPass.cs | 113 +++++++ .../ComponentEventHandlerLoweringPass.cs | 12 +- .../Components/ComponentMarkupBlockPass.cs | 5 +- .../Components/ComponentMarkupEncodingPass.cs | 4 +- .../src/Components/ComponentMetadata.cs | 5 + .../src/RazorProjectEngine.cs | 1 + ...entDuplicateAttributeDiagnosticPassTest.cs | 196 +++++++++++ .../ComponentMarkupBlockPassTest.cs | 27 ++ .../ComponentCodeGenerationTestBase.cs | 303 ++++++++++++++++++ .../test/RazorProjectEngineTest.cs | 1 + .../TestComponent.codegen.cs | 39 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 25 ++ .../TestComponent.codegen.cs | 66 ++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 37 +++ .../TestComponent.mappings.txt | 19 ++ .../TestComponent.codegen.cs | 66 ++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 37 +++ .../TestComponent.mappings.txt | 19 ++ .../TestComponent.codegen.cs | 66 ++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 37 +++ .../TestComponent.mappings.txt | 19 ++ .../TestComponent.codegen.cs | 40 +++ .../TestComponent.diagnostics.txt | 2 + .../TestComponent.ir.txt | 28 ++ .../TestComponent.codegen.cs | 39 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 25 ++ .../TestComponent.codegen.cs | 27 ++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 32 ++ .../TestComponent.codegen.cs | 54 ++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 44 +++ .../TestComponent.mappings.txt | 19 ++ .../TestComponent.codegen.cs | 45 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 42 +++ .../TestComponent.mappings.txt | 14 + .../TestComponent.codegen.cs | 35 ++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 32 ++ .../TestComponent.mappings.txt | 5 + .../TestComponent.codegen.cs | 27 ++ .../TestComponent.diagnostics.txt | 2 + .../TestComponent.ir.txt | 33 ++ .../TestComponent.codegen.cs | 24 ++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 16 + .../TestComponent.codegen.cs | 50 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 26 ++ .../TestComponent.mappings.txt | 9 + .../TestComponent.codegen.cs | 50 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 26 ++ .../TestComponent.mappings.txt | 9 + .../TestComponent.codegen.cs | 50 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 26 ++ .../TestComponent.mappings.txt | 9 + .../TestComponent.codegen.cs | 25 ++ .../TestComponent.diagnostics.txt | 2 + .../TestComponent.ir.txt | 19 ++ .../TestComponent.codegen.cs | 24 ++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 16 + .../TestComponent.codegen.cs | 31 ++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 25 ++ .../TestComponent.codegen.cs | 54 ++++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 33 ++ .../TestComponent.mappings.txt | 9 + .../TestComponent.codegen.cs | 46 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 31 ++ .../TestComponent.mappings.txt | 9 + .../TestComponent.codegen.cs | 38 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 25 ++ .../TestComponent.codegen.cs | 32 ++ .../TestComponent.diagnostics.txt | 2 + .../TestComponent.ir.txt | 26 ++ 89 files changed, 2466 insertions(+), 6 deletions(-) create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDuplicateAttributeDiagnosticPass.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentDuplicateAttributeDiagnosticPassTest.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs index 6873560b1f..a28fac0543 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs @@ -330,6 +330,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { var valueNode = new HtmlAttributeIntermediateNode() { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.AttributeName, + }, AttributeName = valueAttributeName, Source = node.Source, @@ -350,6 +354,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Components var changeNode = new HtmlAttributeIntermediateNode() { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.AttributeName, + }, AttributeName = changeAttributeName, Source = node.Source, @@ -369,6 +377,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { var valueNode = new ComponentAttributeIntermediateNode(node) { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.AttributeName, + }, AttributeName = valueAttributeName, BoundAttribute = valueAttribute, // Might be null if it doesn't match a component attribute PropertyName = valueAttribute?.GetPropertyName(), @@ -385,6 +397,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Components var changeNode = new ComponentAttributeIntermediateNode(node) { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.AttributeName, + }, AttributeName = changeAttributeName, BoundAttribute = changeAttribute, // Might be null if it doesn't match a component attribute PropertyName = changeAttribute?.GetPropertyName(), @@ -406,6 +422,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { expressionNode = new ComponentAttributeIntermediateNode(node) { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.AttributeName, + }, AttributeName = expressionAttributeName, BoundAttribute = expressionAttribute, PropertyName = expressionAttribute.GetPropertyName(), 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 b5eb7395c9..aa416b3da4 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs @@ -364,7 +364,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components public static readonly RazorDiagnosticDescriptor BindAttribute_FormatNode_Unsupported = new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}10005", + $"{DiagnosticPrefix}10006", () => "Specifying format using 'format-...' attributes are no longer supported. Specify it using the 'bind-...:format=...' attribute instead.", RazorDiagnosticSeverity.Warning); @@ -375,5 +375,53 @@ namespace Microsoft.AspNetCore.Razor.Language.Components source ?? SourceSpan.Undefined); return diagnostic; } + + public static readonly RazorDiagnosticDescriptor DuplicateMarkupAttribute = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10007", + () => "The attribute '{0}' is used two or more times for this element. Attributes must be unique (case-insensitive).", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_DuplicateMarkupAttribute(string attributeName, SourceSpan? source = null) + { + return RazorDiagnostic.Create(DuplicateMarkupAttribute, source ?? SourceSpan.Undefined, attributeName); + } + + public static readonly RazorDiagnosticDescriptor DuplicateMarkupAttributeDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10008", + () => + "The attribute '{0}' is used two or more times for this element. Attributes must be unique (case-insensitive). " + + "The attribute '{0}' is used by the '{1}' directive attribute.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_DuplicateMarkupAttributeDirective(string attributeName, string directiveAttributeName, SourceSpan? source = null) + { + return RazorDiagnostic.Create(DuplicateMarkupAttributeDirective, source ?? SourceSpan.Undefined, attributeName, directiveAttributeName); + } + + public static readonly RazorDiagnosticDescriptor DuplicateComponentParameter = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10009", + () => "The component parameter '{0}' is used two or more times for this component. Parameters must be unique (case-insensitive).", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_DuplicateComponentParameter(string attributeName, SourceSpan? source = null) + { + return RazorDiagnostic.Create(DuplicateComponentParameter, source ?? SourceSpan.Undefined, attributeName); + } + + public static readonly RazorDiagnosticDescriptor DuplicateComponentParameterDirective = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}10010", + () => + "The component parameter '{0}' is used two or more times for this component. Parameters must be unique (case-insensitive). " + + "The component parameter '{0}' is generated by the '{1}' directive attribute.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_DuplicateComponentParameterDirective(string attributeName, string directiveAttributeName, SourceSpan? source = null) + { + return RazorDiagnostic.Create(DuplicateComponentParameterDirective, source ?? SourceSpan.Undefined, attributeName, directiveAttributeName); + } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDuplicateAttributeDiagnosticPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDuplicateAttributeDiagnosticPass.cs new file mode 100644 index 0000000000..83936bf28d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDuplicateAttributeDiagnosticPass.cs @@ -0,0 +1,113 @@ +// 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 Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + internal sealed class ComponentMarkupDiagnosticPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass + { + public static readonly int DefaultOrder = 10000; + + public override int Order => DefaultOrder; + + protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) + { + var visitor = new Visitor(); + visitor.Visit(documentNode); + } + + private class Visitor : IntermediateNodeWalker + { + private Dictionary _attributes = new Dictionary(StringComparer.OrdinalIgnoreCase); + + public override void VisitMarkupElement(MarkupElementIntermediateNode node) + { + for (var i = 0; i < node.Children.Count; i++) + { + if (node.Children[i] is HtmlAttributeIntermediateNode attribute && attribute.AttributeName != null) + { + if (_attributes.TryGetValue(attribute.AttributeName, out var other)) + { + // As a special case we want to point it out explicitly where a directive or other construct + // has emitted an attribute that causes a conflict. We're already looking at the lowered version + // of this construct, so it's easy to detect. We just need the original name to report the issue. + // + // Example: `bind-value` will set `value` and `onchange`. + + var originalAttributeName = + attribute.Annotations[ComponentMetadata.Common.OriginalAttributeName] as string ?? + other.node.Annotations[ComponentMetadata.Common.OriginalAttributeName] as string; + if (originalAttributeName != null) + { + other.node.Diagnostics.Add(ComponentDiagnosticFactory.Create_DuplicateMarkupAttributeDirective( + other.name, + originalAttributeName, + other.node.Source ?? node.Source)); + } + else + { + // This is a conflict in the code the user wrote. + other.node.Diagnostics.Add(ComponentDiagnosticFactory.Create_DuplicateMarkupAttribute( + other.name, + other.node.Source ?? node.Source)); + } + } + + // Replace the attribute we were previously tracking. Then if you have three, the two on the left will have + // diagnostics. + _attributes[attribute.AttributeName] = (attribute.AttributeName, attribute); + } + } + + _attributes.Clear(); + base.VisitMarkupElement(node); + } + + public override void VisitComponent(ComponentIntermediateNode node) + { + for (var i = 0; i < node.Children.Count; i++) + { + // Note that we don't handle ChildContent cases here. Those have their own pass for diagnostics. + if (node.Children[i] is ComponentAttributeIntermediateNode attribute && attribute.AttributeName != null) + { + if (_attributes.TryGetValue(attribute.AttributeName, out var other)) + { + // As a special case we want to point it out explicitly where a directive or other construct + // has emitted an attribute that causes a conflict. We're already looking at the lowered version + // of this construct, so it's easy to detect. We just need the original name to report the issue. + // + // Example: `bind-Value` will set `Value` and `ValueChanged`. + var originalAttributeName = + attribute.Annotations[ComponentMetadata.Common.OriginalAttributeName] as string ?? + other.node.Annotations[ComponentMetadata.Common.OriginalAttributeName] as string; + if (originalAttributeName != null) + { + other.node.Diagnostics.Add(ComponentDiagnosticFactory.Create_DuplicateComponentParameterDirective( + other.name, + originalAttributeName, + other.node.Source ?? node.Source)); + } + else + { + // This is a conflict in the code the user wrote. + other.node.Diagnostics.Add(ComponentDiagnosticFactory.Create_DuplicateComponentParameter( + other.name, + other.node.Source ?? node.Source)); + } + } + + // Replace the attribute we were previously tracking. Then if you have three, the two on the left will have + // diagnostics. + _attributes[attribute.AttributeName] = (attribute.AttributeName, attribute); + } + } + + _attributes.Clear(); + base.VisitComponent(node); + } + } + } +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentEventHandlerLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentEventHandlerLoweringPass.cs index aeefbab150..74ceb8c236 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentEventHandlerLoweringPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentEventHandlerLoweringPass.cs @@ -151,6 +151,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { var result = new HtmlAttributeIntermediateNode() { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.AttributeName, + }, AttributeName = node.AttributeName, Source = node.Source, @@ -173,7 +177,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Components } else { - var result = new ComponentAttributeIntermediateNode(node); + var result = new ComponentAttributeIntermediateNode(node) + { + Annotations = + { + [ComponentMetadata.Common.OriginalAttributeName] = node.AttributeName, + }, + }; result.Children.Clear(); result.Children.Add(new CSharpExpressionIntermediateNode()); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupBlockPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupBlockPass.cs index 4d467d6203..8578b6993e 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupBlockPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupBlockPass.cs @@ -17,7 +17,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Components internal class ComponentMarkupBlockPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass { // Runs LATE because we want to destroy structure. - public override int Order => 10000; + // + // We also need to run after ComponentMarkupDiagnosticPass to avoid destroying diagnostics + // added in that pass. + public override int Order => ComponentMarkupDiagnosticPass.DefaultOrder + 10; protected override void ExecuteCore( RazorCodeDocument codeDocument, diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupEncodingPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupEncodingPass.cs index b35824c45d..186743e5b9 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupEncodingPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMarkupEncodingPass.cs @@ -3,9 +3,7 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; -using System.Text; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Microsoft.AspNetCore.Razor.Language.Legacy; @@ -14,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components internal class ComponentMarkupEncodingPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass { // Runs after ComponentMarkupBlockPass - public override int Order => 10010; + public override int Order => ComponentMarkupDiagnosticPass.DefaultOrder + 20; protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs index f57daad348..dc620c8f4f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentMetadata.cs @@ -47,6 +47,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Components return className.StartsWith(MangledClassNamePrefix, StringComparison.Ordinal); } + public static class Common + { + public static readonly string OriginalAttributeName = "Common.OriginalAttributeName"; + } + public static class Bind { public static readonly string RuntimeName = "Components.None"; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs index 32d2b68874..9ae6652fe7 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs @@ -235,6 +235,7 @@ namespace Microsoft.AspNetCore.Razor.Language builder.Features.Add(new ComponentTemplateDiagnosticPass()); builder.Features.Add(new ComponentGenericTypePass()); builder.Features.Add(new ComponentChildContentDiagnosticPass()); + builder.Features.Add(new ComponentMarkupDiagnosticPass()); builder.Features.Add(new ComponentMarkupBlockPass()); builder.Features.Add(new ComponentMarkupEncodingPass()); } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentDuplicateAttributeDiagnosticPassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentDuplicateAttributeDiagnosticPassTest.cs new file mode 100644 index 0000000000..fa6132337b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentDuplicateAttributeDiagnosticPassTest.cs @@ -0,0 +1,196 @@ +// 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; +using Microsoft.AspNetCore.Razor.Language.Intermediate; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.Components +{ + // These tests are really basic and cover a few different structures. The components part of this + // pass is hard to unit test, so component cases are covered by integration tests. + public class ComponentDuplicateAttributeDiagnosticPassTest + { + public ComponentDuplicateAttributeDiagnosticPassTest() + { + Pass = new ComponentMarkupDiagnosticPass(); + ProjectEngine = (DefaultRazorProjectEngine)RazorProjectEngine.Create( + RazorConfiguration.Default, + RazorProjectFileSystem.Create(Environment.CurrentDirectory), + b => + { + // Don't run the markup mutating passes. + b.Features.Remove(b.Features.OfType().Single()); + b.Features.Remove(b.Features.OfType().Single()); + b.Features.Remove(b.Features.OfType().Single()); + }); + Engine = ProjectEngine.Engine; + + Pass.Engine = Engine; + } + + private DefaultRazorProjectEngine ProjectEngine { get; } + + private RazorEngine Engine { get; } + + private ComponentMarkupDiagnosticPass Pass { get; } + + [Fact] + public void Execute_NoDuplicates() + { + // Arrange + var document = CreateDocument(@" + + +
+
    +
  • +
+ +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + Assert.Empty(documentNode.GetAllDiagnostics()); + } + + [Fact] + public void Execute_FindDuplicate() + { + // Arrange + var document = CreateDocument(@" + + +
+
    +
  • +
+ +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var diagnostic = Assert.Single(documentNode.GetAllDiagnostics()); + Assert.Equal(ComponentDiagnosticFactory.DuplicateMarkupAttribute.Id, diagnostic.Id); + + var node = documentNode.FindDescendantNodes().Where(n => n.HasDiagnostics).Single(); + Assert.Equal("a", node.AttributeName); + Assert.Equal(node.Source, diagnostic.Span); + } + + [Fact] + public void Execute_FindDuplicate_CaseInsensitive() + { + // Arrange + var document = CreateDocument(@" + + +
+
    +
  • +
+ +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var diagnostic = Assert.Single(documentNode.GetAllDiagnostics()); + Assert.Equal(ComponentDiagnosticFactory.DuplicateMarkupAttribute.Id, diagnostic.Id); + + var node = documentNode.FindDescendantNodes().Where(n => n.HasDiagnostics).Single(); + Assert.Equal("attr", node.AttributeName); + Assert.Equal(node.Source, diagnostic.Span); + } + + [Fact] + public void Execute_FindDuplicate_Multiple() + { + // Arrange + var document = CreateDocument(@" + + +
+
    +
  • +
+ +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var diagnostics = documentNode.GetAllDiagnostics(); + var nodes = documentNode.FindDescendantNodes().Where(n => n.HasDiagnostics).ToArray(); + + Assert.Equal(2, diagnostics.Count); + Assert.Equal(2, nodes.Length); + + for (var i = 0; i < 2; i++) + { + var diagnostic = diagnostics[i]; + var node = nodes[i]; + + Assert.Equal(ComponentDiagnosticFactory.DuplicateMarkupAttribute.Id, diagnostic.Id); + Assert.Equal("attr", node.AttributeName); + Assert.Equal(node.Source, diagnostic.Span); + } + } + + private RazorCodeDocument CreateDocument(string content) + { + // Normalize newlines since we are testing lengths of things. + content = content.Replace("\r", ""); + content = content.Replace("\n", "\r\n"); + + var source = RazorSourceDocument.Create(content, "test.cshtml"); + return ProjectEngine.CreateCodeDocumentCore(source, FileKinds.Component); + } + + private DocumentIntermediateNode Lower(RazorCodeDocument codeDocument) + { + for (var i = 0; i < Engine.Phases.Count; i++) + { + var phase = Engine.Phases[i]; + if (phase is IRazorCSharpLoweringPhase) + { + break; + } + + phase.Execute(codeDocument); + } + + var document = codeDocument.GetDocumentIntermediateNode(); + Engine.Features.OfType().Single().Execute(codeDocument, document); + return document; + } + + private class StaticTagHelperFeature : ITagHelperFeature + { + public RazorEngine Engine { get; set; } + + public List TagHelpers { get; set; } + + public IReadOnlyList GetDescriptors() + { + return TagHelpers; + } + } + } +} \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupBlockPassTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupBlockPassTest.cs index b823d72ef8..75c32a7878 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupBlockPassTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Components/ComponentMarkupBlockPassTest.cs @@ -325,6 +325,32 @@ namespace Microsoft.AspNetCore.Razor.Language.Components Assert.Empty(documentNode.FindDescendantNodes()); } + // We want duplicate attributes to result in an error and prevent rewriting. + // + // This is because Blazor de-duplicates attributes differently from browsers, so we don't + // want to allow any markup blocks to exist with duplicate attributes or else they will have + // the browser's behavior. + [Fact] + public void Execute_CannotRewriteHtml_DuplicateAttribute() + { + // Arrange + var document = CreateDocument(@" + + +"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + Assert.Empty(documentNode.FindDescendantNodes()); + + var diagnostic = Assert.Single(documentNode.GetAllDiagnostics()); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttribute.Id, diagnostic.Id); + } + [Fact] public void Execute_RewritesHtml_MismatchedClosingTag() { @@ -385,6 +411,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components var document = codeDocument.GetDocumentIntermediateNode(); Engine.Features.OfType().Single().Execute(codeDocument, document); + Engine.Features.OfType().Single().Execute(codeDocument, document); return document; } 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 9be0e8e632..d9fcc74ccc 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Components; using Xunit; namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests @@ -3795,6 +3796,308 @@ namespace New.Test CompileToAssembly(generated); } + [Fact] + public void DuplicateMarkupAttributes_IsAnError() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttribute.Id, diagnostic.Id); + } + + // Right now this is almost indistinguishable from the previous case, but when we add the @ for directive attributes + // it won't be. This is a placeholder to be updated when that change goes in. + [Fact] + public void DuplicateMarkupAttributes_IsAnError_EventHandler() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttributeDirective.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateMarkupAttributes_Multiple_IsAnError() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + Assert.All(generated.Diagnostics, d => + { + Assert.Same(ComponentDiagnosticFactory.DuplicateMarkupAttribute.Id, d.Id); + }); + } + + [Fact] + public void DuplicateMarkupAttributes_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() + { + // 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 DuplicateComponentParameters_IsAnError() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; private set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameter.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_Multiple() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; private set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + Assert.All(generated.Diagnostics, d => + { + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameter.Id, d.Id); + }); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_WeaklyTyped() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; private set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameter.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_BindMessage() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; private set; } + [Parameter] public EventCallback MessageChanged { get; private set; } + [Parameter] public Expression> MessageExpression { get; private set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + +@functions { + string message = ""hi""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameterDirective.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_BindMessageChanged() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; private set; } + [Parameter] public EventCallback MessageChanged { get; private set; } + [Parameter] public Expression> MessageExpression { get; private set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + {})"" bind-Message=""@message"" /> +@functions { + string message = ""hi""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameterDirective.Id, diagnostic.Id); + } + + [Fact] + public void DuplicateComponentParameters_IsAnError_BindMessageExpression() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using System.Linq.Expressions; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] public string Message { get; private set; } + [Parameter] public EventCallback MessageChanged { get; private set; } + [Parameter] public Expression> MessageExpression { get; private set; } + } +} +")); + // Act + var generated = CompileToCSharp(@" + {})"" /> +@functions { + string message = ""hi""; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.DuplicateComponentParameterDirective.Id, diagnostic.Id); + } + [Fact] public void ScriptTag_WithErrorSuppressed() { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineTest.cs index 76e7686fa1..8a7ac84c04 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorProjectEngineTest.cs @@ -57,6 +57,7 @@ namespace Microsoft.AspNetCore.Razor.Language feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), + feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), feature => Assert.IsType(feature), diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.codegen.cs new file mode 100644 index 0000000000..f0a2c9b5a7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/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 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 = ""; + __o = ""; + 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 + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..90b182e690 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10009: The component parameter 'Message' is used two or more times for this component. Parameters must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.ir.txt new file mode 100644 index 0000000000..6e788003a9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.ir.txt @@ -0,0 +1,25 @@ +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 [45] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + HtmlContent - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + ComponentAttribute - - mESSAGE - AttributeStructure.DoubleQuotes + HtmlContent - (37:0,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (37:0,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + HtmlContent - (45:0,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (45:0,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs new file mode 100644 index 0000000000..906412e12e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs @@ -0,0 +1,66 @@ +// +#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" + message + +#line default +#line hidden +#nullable disable + ); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + message + +#line default +#line hidden +#nullable disable + )); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>(Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message))); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>>(() => message); + 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 + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + string message = "hi"; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..4b0c476087 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10010: The component parameter 'Message' is used two or more times for this component. Parameters must be unique (case-insensitive). The component parameter 'Message' is generated by the 'bind-Message' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt new file mode 100644 index 0000000000..6f3fd83e49 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt @@ -0,0 +1,37 @@ +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 [58] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (22:0,22 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + CSharpExpression - (23:0,23 [7] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (23:0,23 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message + ComponentAttribute - (46:0,46 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (47:0,47 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message + IntermediateToken - - CSharp - ) + ComponentAttribute - (46:0,46 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message) + ComponentAttribute - (46:0,46 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => message + HtmlContent - (58:0,58 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:0,58 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (103:3,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (103:3,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (72:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string message = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt new file mode 100644 index 0000000000..e8219984c8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (23:0,23 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|message| +Generated Location: (958:25,23 [7] ) +|message| + +Source Location: (47:0,47 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|message| +Generated Location: (1295:34,47 [7] ) +|message| + +Source Location: (72:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) +| + string message = "hi"; +| +Generated Location: (2310:57,12 [30] ) +| + string message = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs new file mode 100644 index 0000000000..3880f38fad --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs @@ -0,0 +1,66 @@ +// +#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>(Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + (s) => {} + +#line default +#line hidden +#nullable disable + )); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + message + +#line default +#line hidden +#nullable disable + )); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>(Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message))); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>>(() => message); + 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 + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + string message = "hi"; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..823665c916 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,30): Error RZ10010: The component parameter 'MessageChanged' is used two or more times for this component. Parameters must be unique (case-insensitive). The component parameter 'MessageChanged' is generated by the 'bind-Message' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt new file mode 100644 index 0000000000..6022fdbfaa --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt @@ -0,0 +1,37 @@ +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 [69] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (29:0,29 [12] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - AttributeStructure.DoubleQuotes + CSharpExpression - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:0,31 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - (s) => {} + ComponentAttribute - (57:0,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (58:0,58 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message + IntermediateToken - - CSharp - ) + ComponentAttribute - (57:0,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message) + ComponentAttribute - (57:0,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => message + HtmlContent - (69:0,69 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (69:0,69 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (114:3,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (114:3,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (83:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (83:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string message = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt new file mode 100644 index 0000000000..87119a46ef --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (31:0,31 [9] x:\dir\subdir\Test\TestComponent.cshtml) +|(s) => {}| +Generated Location: (1095:25,31 [9] ) +|(s) => {}| + +Source Location: (58:0,58 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|message| +Generated Location: (1446:34,58 [7] ) +|message| + +Source Location: (83:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) +| + string message = "hi"; +| +Generated Location: (2461:57,12 [30] ) +| + string message = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs new file mode 100644 index 0000000000..5410554f92 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs @@ -0,0 +1,66 @@ +// +#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" + (s) => {} + +#line default +#line hidden +#nullable disable + ); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + message + +#line default +#line hidden +#nullable disable + )); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>(Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message))); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>>(() => message); + 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 + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + string message = "hi"; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..1586878f86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,57): Error RZ10010: The component parameter 'MessageExpression' is used two or more times for this component. Parameters must be unique (case-insensitive). The component parameter 'MessageExpression' is generated by the 'bind-Message' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt new file mode 100644 index 0000000000..13d7481d85 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt @@ -0,0 +1,37 @@ +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 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (56:0,56 [12] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - AttributeStructure.DoubleQuotes + CSharpExpression - (57:0,57 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:0,58 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - (s) => {} + ComponentAttribute - (27:0,27 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (28:0,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message + IntermediateToken - - CSharp - ) + ComponentAttribute - (27:0,27 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message) + ComponentAttribute - (27:0,27 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => message + HtmlContent - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:0,72 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (117:3,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (117:3,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (86:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string message = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt new file mode 100644 index 0000000000..aa37e5ed58 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (58:0,58 [9] x:\dir\subdir\Test\TestComponent.cshtml) +|(s) => {}| +Generated Location: (1044:25,58 [9] ) +|(s) => {}| + +Source Location: (28:0,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|message| +Generated Location: (1364:34,28 [7] ) +|message| + +Source Location: (86:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) +| + string message = "hi"; +| +Generated Location: (2379:57,12 [30] ) +| + string message = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.codegen.cs new file mode 100644 index 0000000000..590af79a44 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#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 = ""; + __o = ""; + __o = ""; + 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 + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..a7c8a30322 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Error RZ10009: The component parameter 'mESSAGE' is used two or more times for this component. Parameters must be unique (case-insensitive). +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10009: The component parameter 'Message' is used two or more times for this component. Parameters must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.ir.txt new file mode 100644 index 0000000000..55906fb718 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/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 [66] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + HtmlContent - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + ComponentAttribute - - mESSAGE - AttributeStructure.DoubleQuotes + HtmlContent - (37:0,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (37:0,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + ComponentAttribute - - Message - AttributeStructure.DoubleQuotes + HtmlContent - (52:0,52 [10] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:0,52 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - anotherone + HtmlContent - (66:0,66 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (66:0,66 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.codegen.cs new file mode 100644 index 0000000000..f0a2c9b5a7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/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 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 = ""; + __o = ""; + 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 + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..572de363b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Error RZ10009: The component parameter 'Foo' is used two or more times for this component. Parameters must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.ir.txt new file mode 100644 index 0000000000..4a74314e02 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.ir.txt @@ -0,0 +1,25 @@ +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 [37] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - - Foo - AttributeStructure.DoubleQuotes + HtmlContent - (18:0,18 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (18:0,18 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + ComponentAttribute - - foo - AttributeStructure.DoubleQuotes + HtmlContent - (29:0,29 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + HtmlContent - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (37:0,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs new file mode 100644 index 0000000000..3efad2f87c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/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/DuplicateMarkupAttributes_IsAnError/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..99896ebbff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,5): Error RZ10007: The attribute 'href' is used two or more times for this element. Attributes must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt new file mode 100644 index 0000000000..c57b44be65 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt @@ -0,0 +1,32 @@ +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 [140] 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 [123] x:\dir\subdir\Test\TestComponent.cshtml) - a + HtmlAttribute - (11:1,4 [17] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " + HtmlAttributeValue - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - /cool-url + HtmlAttribute - (28:1,21 [9] x:\dir\subdir\Test\TestComponent.cshtml) - style=" - " + HtmlAttribute - (37:1,30 [9] x:\dir\subdir\Test\TestComponent.cshtml) - disabled - + HtmlAttribute - (46:1,39 [24] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " + HtmlAttributeValue - (53:1,46 [16] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (53:1,46 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Html - /even-cooler-url + HtmlContent - (71:1,64 [57] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:1,64 [57] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Learn the ten cool tricks your compiler author will hate! + HtmlContent - (132:1,125 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (132:1,125 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs new file mode 100644 index 0000000000..0345b2ac34 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs @@ -0,0 +1,54 @@ +// +#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.EventCallback.Factory.Create(this, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + () => {} + +#line default +#line hidden +#nullable disable + ); + __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_IsAnError_BindOnInput/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..27f6955b38 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,77): Error RZ10008: The attribute 'oninput' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'oninput' is used by the 'bind-value' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt new file mode 100644 index 0000000000..8f716b1294 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/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 [112] 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 [95] 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 - (83:1,76 [11] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + IntermediateToken - (85:1,78 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => {} + IntermediateToken - - CSharp - ) + HtmlAttribute - (40:1,33 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (41:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (40:1,33 [5] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text) + HtmlContent - (104:1,97 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (104:1,97 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (112:2,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (112:2,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (162:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (162:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (126:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (126: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_IsAnError_BindOnInput/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt new file mode 100644 index 0000000000..631248be06 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (85:1,78 [8] x:\dir\subdir\Test\TestComponent.cshtml) +|() => {}| +Generated Location: (1059:25,78 [8] ) +|() => {}| + +Source Location: (41:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|text| +Generated Location: (1312:34,34 [4] ) +|text| + +Source Location: (126:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) +| + private string text = "hi"; +| +Generated Location: (1641:45,12 [35] ) +| + private string text = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs new file mode 100644 index 0000000000..ff40e87e8e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_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_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..3277ed84c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_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_IsAnError_BindValue/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt new file mode 100644 index 0000000000..e78c1493a7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt @@ -0,0 +1,42 @@ +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 [68] 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 [51] 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 - (45:1,38 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (46:1,39 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (45:1,38 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text) + HtmlContent - (60:1,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (60:1,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (68:2,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (68:2,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (118:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (118:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (82:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (82: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_IsAnError_BindValue/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt new file mode 100644 index 0000000000..d0fd00e6ee --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt @@ -0,0 +1,14 @@ +Source Location: (46:1,39 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|text| +Generated Location: (955:25,39 [4] ) +|text| + +Source Location: (82:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) +| + private string text = "hi"; +| +Generated Location: (1284:36,12 [35] ) +| + private string text = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs new file mode 100644 index 0000000000..92dd6b9fa8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/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) + { + __o = Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, "test()"); +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = () => {}; + +#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/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..e1149b3381 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,15): Error RZ10008: The attribute 'onclick' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'onclick' is used by the 'onclick' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt new file mode 100644 index 0000000000..ebf1b99d33 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt @@ -0,0 +1,32 @@ +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 [120] 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 [103] x:\dir\subdir\Test\TestComponent.cshtml) - a + HtmlContent - (51:1,44 [57] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (51:1,44 [57] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Learn the ten cool tricks your compiler author will hate! + HtmlAttribute - (21:1,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + IntermediateToken - - CSharp - "test()" + IntermediateToken - - CSharp - ) + HtmlAttribute - - onclick=" - " + CSharpExpression - (40:1,33 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (40:1,33 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => {} + HtmlContent - (112:1,105 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (112:1,105 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.mappings.txt new file mode 100644 index 0000000000..e169bb2a5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (40:1,33 [8] x:\dir\subdir\Test\TestComponent.cshtml) +|() => {}| +Generated Location: (1023:25,33 [8] ) +|() => {}| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs new file mode 100644 index 0000000000..3efad2f87c --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/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/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..4261b59805 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,5): Error RZ10007: The attribute 'href' is used two or more times for this element. Attributes must be unique (case-insensitive). +x:\dir\subdir\Test\TestComponent.cshtml(2,40): Error RZ10007: The attribute 'href' is used two or more times for this element. Attributes must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt new file mode 100644 index 0000000000..f5084c8f15 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt @@ -0,0 +1,33 @@ +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 [145] 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 [128] x:\dir\subdir\Test\TestComponent.cshtml) - a + HtmlAttribute - (11:1,4 [17] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " + HtmlAttributeValue - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - /cool-url + HtmlAttribute - (28:1,21 [9] x:\dir\subdir\Test\TestComponent.cshtml) - style=" - " + HtmlAttribute - (37:1,30 [9] x:\dir\subdir\Test\TestComponent.cshtml) - disabled - + HtmlAttribute - (46:1,39 [24] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " + HtmlAttributeValue - (53:1,46 [16] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (53:1,46 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Html - /even-cooler-url + HtmlAttribute - (70:1,63 [5] x:\dir\subdir\Test\TestComponent.cshtml) - href - + HtmlContent - (76:1,69 [57] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (76:1,69 [57] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Learn the ten cool tricks your compiler author will hate! + HtmlContent - (137:1,130 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (137:1,130 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.codegen.cs new file mode 100644 index 0000000000..e2c489ad50 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#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, "Message", "test"); + builder.AddAttribute(2, "mESSAGE", "test"); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..90b182e690 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10009: The component parameter 'Message' is used two or more times for this component. Parameters must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.ir.txt new file mode 100644 index 0000000000..5b3a5785b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError/TestComponent.ir.txt @@ -0,0 +1,16 @@ +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 [45] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + HtmlContent - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + ComponentAttribute - - mESSAGE - AttributeStructure.DoubleQuotes + HtmlContent - (37:0,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (37:0,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs new file mode 100644 index 0000000000..2e7578f435 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#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, "Message", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + message + +#line default +#line hidden +#nullable disable + )); + builder.AddAttribute(2, "Message", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + message + +#line default +#line hidden +#nullable disable + ))); + builder.AddAttribute(3, "MessageChanged", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>(Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message)))); + builder.AddAttribute(4, "MessageExpression", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>>(() => message)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + string message = "hi"; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..4b0c476087 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10010: The component parameter 'Message' is used two or more times for this component. Parameters must be unique (case-insensitive). The component parameter 'Message' is generated by the 'bind-Message' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt new file mode 100644 index 0000000000..3eef2491d8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.ir.txt @@ -0,0 +1,26 @@ +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 [58] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (22:0,22 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + CSharpExpression - (23:0,23 [7] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (23:0,23 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message + ComponentAttribute - (46:0,46 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (47:0,47 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message + IntermediateToken - - CSharp - ) + ComponentAttribute - (46:0,46 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message) + ComponentAttribute - (46:0,46 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => message + CSharpCode - (72:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string message = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt new file mode 100644 index 0000000000..17a28168d6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessage/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (72:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) +| + string message = "hi"; +| +Generated Location: (1962:41,12 [30] ) +| + string message = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs new file mode 100644 index 0000000000..d003d6c272 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#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, "MessageChanged", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>(Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + (s) => {} + +#line default +#line hidden +#nullable disable + ))); + builder.AddAttribute(2, "Message", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + message + +#line default +#line hidden +#nullable disable + ))); + builder.AddAttribute(3, "MessageChanged", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>(Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message)))); + builder.AddAttribute(4, "MessageExpression", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>>(() => message)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + string message = "hi"; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..823665c916 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,30): Error RZ10010: The component parameter 'MessageChanged' is used two or more times for this component. Parameters must be unique (case-insensitive). The component parameter 'MessageChanged' is generated by the 'bind-Message' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt new file mode 100644 index 0000000000..6263cb0767 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.ir.txt @@ -0,0 +1,26 @@ +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 [69] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (29:0,29 [12] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - AttributeStructure.DoubleQuotes + CSharpExpression - (30:0,30 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:0,31 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - (s) => {} + ComponentAttribute - (57:0,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (58:0,58 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message + IntermediateToken - - CSharp - ) + ComponentAttribute - (57:0,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message) + ComponentAttribute - (57:0,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => message + CSharpCode - (83:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (83:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string message = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt new file mode 100644 index 0000000000..0a4efd9127 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageChanged/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (83:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) +| + string message = "hi"; +| +Generated Location: (2120:41,12 [30] ) +| + string message = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs new file mode 100644 index 0000000000..0e59d9b397 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#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, "MessageExpression", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>>( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + (s) => {} + +#line default +#line hidden +#nullable disable + )); + builder.AddAttribute(2, "Message", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + message + +#line default +#line hidden +#nullable disable + ))); + builder.AddAttribute(3, "MessageChanged", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>(Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message)))); + builder.AddAttribute(4, "MessageExpression", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck>>(() => message)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + string message = "hi"; + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..1586878f86 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,57): Error RZ10010: The component parameter 'MessageExpression' is used two or more times for this component. Parameters must be unique (case-insensitive). The component parameter 'MessageExpression' is generated by the 'bind-Message' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt new file mode 100644 index 0000000000..f8be13be38 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.ir.txt @@ -0,0 +1,26 @@ +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 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (56:0,56 [12] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - AttributeStructure.DoubleQuotes + CSharpExpression - (57:0,57 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:0,58 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - (s) => {} + ComponentAttribute - (27:0,27 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (28:0,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - message + IntermediateToken - - CSharp - ) + ComponentAttribute - (27:0,27 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageChanged - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateInferred(this, __value => message = __value, message) + ComponentAttribute - (27:0,27 [8] x:\dir\subdir\Test\TestComponent.cshtml) - MessageExpression - AttributeStructure.DoubleQuotes + CSharpExpression - + IntermediateToken - - CSharp - () => message + CSharpCode - (86:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string message = "hi";\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt new file mode 100644 index 0000000000..2ad7965435 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_BindMessageExpression/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (86:1,12 [30] x:\dir\subdir\Test\TestComponent.cshtml) +| + string message = "hi"; +| +Generated Location: (2041:41,12 [30] ) +| + string message = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.codegen.cs new file mode 100644 index 0000000000..679ce1999a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.codegen.cs @@ -0,0 +1,25 @@ +// +#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, "Message", "test"); + builder.AddAttribute(2, "mESSAGE", "test"); + builder.AddAttribute(3, "Message", "anotherone"); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..a7c8a30322 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Error RZ10009: The component parameter 'mESSAGE' is used two or more times for this component. Parameters must be unique (case-insensitive). +x:\dir\subdir\Test\TestComponent.cshtml(1,23): Error RZ10009: The component parameter 'Message' is used two or more times for this component. Parameters must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.ir.txt new file mode 100644 index 0000000000..cf083f5ca4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_Multiple/TestComponent.ir.txt @@ -0,0 +1,19 @@ +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 [66] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Message - AttributeStructure.DoubleQuotes + HtmlContent - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (22:0,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + ComponentAttribute - - mESSAGE - AttributeStructure.DoubleQuotes + HtmlContent - (37:0,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (37:0,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + ComponentAttribute - - Message - AttributeStructure.DoubleQuotes + HtmlContent - (52:0,52 [10] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:0,52 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - anotherone diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.codegen.cs new file mode 100644 index 0000000000..7732ae8afc --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#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, "Foo", "test"); + builder.AddAttribute(2, "foo", "test"); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..572de363b4 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Error RZ10009: The component parameter 'Foo' is used two or more times for this component. Parameters must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.ir.txt new file mode 100644 index 0000000000..e434a9fce7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateComponentParameters_IsAnError_WeaklyTyped/TestComponent.ir.txt @@ -0,0 +1,16 @@ +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 [37] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent + ComponentAttribute - - Foo - AttributeStructure.DoubleQuotes + HtmlContent - (18:0,18 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (18:0,18 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test + ComponentAttribute - - foo - AttributeStructure.DoubleQuotes + HtmlContent - (29:0,29 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - test diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs new file mode 100644 index 0000000000..0d4a171ca1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#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, "a"); + builder.AddAttribute(3, "href", "/cool-url"); + builder.AddAttribute(4, "style", true); + builder.AddAttribute(5, "disabled", true); + builder.AddAttribute(6, "href", "/even-cooler-url"); + builder.AddContent(7, "Learn the ten cool tricks your compiler author will hate!"); + builder.CloseElement(); + builder.AddMarkupContent(8, "\r\n"); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..99896ebbff --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,5): Error RZ10007: The attribute 'href' is used two or more times for this element. Attributes must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt new file mode 100644 index 0000000000..1620f5850d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError/TestComponent.ir.txt @@ -0,0 +1,25 @@ +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 [140] 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 [123] x:\dir\subdir\Test\TestComponent.cshtml) - a + HtmlAttribute - (11:1,4 [17] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " + HtmlAttributeValue - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - /cool-url + HtmlAttribute - (28:1,21 [9] x:\dir\subdir\Test\TestComponent.cshtml) - style=" - " + HtmlAttribute - (37:1,30 [9] x:\dir\subdir\Test\TestComponent.cshtml) - disabled - + HtmlAttribute - (46:1,39 [24] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " + HtmlAttributeValue - (53:1,46 [16] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (53:1,46 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Html - /even-cooler-url + HtmlContent - (71:1,64 [57] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:1,64 [57] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Learn the ten cool tricks your compiler author will hate! + HtmlContent - (132:1,125 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (132:1,125 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs new file mode 100644 index 0000000000..3e4fd96a12 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.codegen.cs @@ -0,0 +1,54 @@ +// +#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, "oninput", Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + () => {} + +#line default +#line hidden +#nullable disable + )); + 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, "oninput", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text)); + 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_IsAnError_BindOnInput/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..27f6955b38 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,77): Error RZ10008: The attribute 'oninput' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'oninput' is used by the 'bind-value' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.ir.txt new file mode 100644 index 0000000000..843e83ea74 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/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 [112] 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 [95] 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 - (83:1,76 [11] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + IntermediateToken - (85:1,78 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => {} + IntermediateToken - - CSharp - ) + HtmlAttribute - (40:1,33 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (41:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (40:1,33 [5] x:\dir\subdir\Test\TestComponent.cshtml) - oninput=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text) + HtmlContent - (104:1,97 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (104:1,97 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (126:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (126: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_IsAnError_BindOnInput/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt new file mode 100644 index 0000000000..2bcebb8c5b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindOnInput/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (126:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) +| + private string text = "hi"; +| +Generated Location: (1781:45,12 [35] ) +| + private string text = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs new file mode 100644 index 0000000000..7b128cc38b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.codegen.cs @@ -0,0 +1,46 @@ +// +#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.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_IsAnError_BindValue/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..3277ed84c6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_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_IsAnError_BindValue/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt new file mode 100644 index 0000000000..5c99860360 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.ir.txt @@ -0,0 +1,31 @@ +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 [68] 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 [51] 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 - (45:1,38 [5] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (46:1,39 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - text + IntermediateToken - - CSharp - ) + HtmlAttribute - (45:1,38 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => text = __value, text) + HtmlContent - (60:1,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (60:1,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (82:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (82: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_IsAnError_BindValue/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt new file mode 100644 index 0000000000..2429a1c991 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_BindValue/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (82:3,12 [35] x:\dir\subdir\Test\TestComponent.cshtml) +| + private string text = "hi"; +| +Generated Location: (1448:37,12 [35] ) +| + private string text = "hi"; +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs new file mode 100644 index 0000000000..0e55646fd2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.codegen.cs @@ -0,0 +1,38 @@ +// +#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, "a"); + builder.AddAttribute(3, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, "test()")); + builder.AddContent(4, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + () => {} + +#line default +#line hidden +#nullable disable + ); + builder.AddAttribute(5, "onclick", true); + builder.AddContent(6, "Learn the ten cool tricks your compiler author will hate!"); + builder.CloseElement(); + builder.AddMarkupContent(7, "\r\n"); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..e1149b3381 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,15): Error RZ10008: The attribute 'onclick' is used two or more times for this element. Attributes must be unique (case-insensitive). The attribute 'onclick' is used by the 'onclick' directive attribute. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt new file mode 100644 index 0000000000..9b44eab2dd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_IsAnError_EventHandler/TestComponent.ir.txt @@ -0,0 +1,25 @@ +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 [120] 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 [103] x:\dir\subdir\Test\TestComponent.cshtml) - a + HtmlContent - (51:1,44 [57] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (51:1,44 [57] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Learn the ten cool tricks your compiler author will hate! + HtmlAttribute - (21:1,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + IntermediateToken - - CSharp - "test()" + IntermediateToken - - CSharp - ) + HtmlAttribute - - onclick=" - " + CSharpExpression - (40:1,33 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (40:1,33 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => {} + HtmlContent - (112:1,105 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (112:1,105 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs new file mode 100644 index 0000000000..525d7ca849 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#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, "a"); + builder.AddAttribute(3, "href", "/cool-url"); + builder.AddAttribute(4, "style", true); + builder.AddAttribute(5, "disabled", true); + builder.AddAttribute(6, "href", "/even-cooler-url"); + builder.AddAttribute(7, "href", true); + builder.AddContent(8, "Learn the ten cool tricks your compiler author will hate!"); + builder.CloseElement(); + builder.AddMarkupContent(9, "\r\n"); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.diagnostics.txt new file mode 100644 index 0000000000..4261b59805 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.cshtml(2,5): Error RZ10007: The attribute 'href' is used two or more times for this element. Attributes must be unique (case-insensitive). +x:\dir\subdir\Test\TestComponent.cshtml(2,40): Error RZ10007: The attribute 'href' is used two or more times for this element. Attributes must be unique (case-insensitive). diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt new file mode 100644 index 0000000000..bc80339ed7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/DuplicateMarkupAttributes_Multiple_IsAnError/TestComponent.ir.txt @@ -0,0 +1,26 @@ +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 [145] 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 [128] x:\dir\subdir\Test\TestComponent.cshtml) - a + HtmlAttribute - (11:1,4 [17] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " + HtmlAttributeValue - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (18:1,11 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - /cool-url + HtmlAttribute - (28:1,21 [9] x:\dir\subdir\Test\TestComponent.cshtml) - style=" - " + HtmlAttribute - (37:1,30 [9] x:\dir\subdir\Test\TestComponent.cshtml) - disabled - + HtmlAttribute - (46:1,39 [24] x:\dir\subdir\Test\TestComponent.cshtml) - href=" - " + HtmlAttributeValue - (53:1,46 [16] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (53:1,46 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Html - /even-cooler-url + HtmlAttribute - (70:1,63 [5] x:\dir\subdir\Test\TestComponent.cshtml) - href - + HtmlContent - (76:1,69 [57] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (76:1,69 [57] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Learn the ten cool tricks your compiler author will hate! + HtmlContent - (137:1,130 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (137:1,130 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n