From deb9d89409bcced6466938bb164d8e8568ab6ec7 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 27 May 2021 16:14:50 -0700 Subject: [PATCH 1/5] Provide a tooling gesture that suggests values for required component parameters are not specified. --- .../Components/src/DynamicComponent.cs | 1 + .../Components/src/EditorRequiredAttribute.cs | 19 ++ .../Components/src/PublicAPI.Unshipped.txt | 2 + src/Components/Components/src/RouteView.cs | 1 + .../Components/src/Routing/Router.cs | 12 +- .../src/BoundAttributeDescriptor.cs | 5 +- .../src/BoundAttributeDescriptorBuilder.cs | 4 +- .../src/Components/ComponentLoweringPass.cs | 47 +++- .../DefaultBoundAttributeDescriptorBuilder.cs | 5 +- .../src/RazorDiagnosticFactory.cs | 23 ++ .../src/Resources.resx | 6 + .../src/TagHelperDescriptor.cs | 26 ++ .../ComponentCodeGenerationTestBase.cs | 232 ++++++++++++++++++ .../TestComponent.codegen.cs | 37 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 19 ++ .../TestComponent.codegen.cs | 37 +++ .../TestComponent.ir.txt | 27 ++ .../TestComponent.codegen.cs | 37 +++ .../TestComponent.ir.txt | 27 ++ .../TestComponent.codegen.cs | 37 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 19 ++ .../TestComponent.codegen.cs | 37 +++ .../TestComponent.ir.txt | 23 ++ .../TestComponent.codegen.cs | 37 +++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 19 ++ .../TestComponent.codegen.cs | 38 +++ .../TestComponent.ir.txt | 22 ++ .../TestComponent.codegen.cs | 46 ++++ .../TestComponent.ir.txt | 21 ++ .../TestComponent.mappings.txt | 5 + .../TestComponent.codegen.cs | 22 ++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 10 + .../TestComponent.codegen.cs | 26 ++ .../TestComponent.ir.txt | 12 + .../TestComponent.codegen.cs | 26 ++ .../TestComponent.ir.txt | 12 + .../TestComponent.codegen.cs | 24 ++ .../TestComponent.ir.txt | 16 ++ .../TestComponent.codegen.cs | 22 ++ .../TestComponent.ir.txt | 10 + .../TestComponent.codegen.cs | 23 ++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 13 + .../TestComponent.codegen.cs | 23 ++ .../TestComponent.diagnostics.txt | 2 + .../TestComponent.ir.txt | 13 + .../TestComponent.codegen.cs | 22 ++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 10 + .../TestComponent.codegen.cs | 26 ++ .../TestComponent.ir.txt | 12 + .../TestComponent.codegen.cs | 22 ++ .../TestComponent.diagnostics.txt | 1 + .../TestComponent.ir.txt | 10 + .../TestComponent.codegen.cs | 23 ++ .../TestComponent.ir.txt | 13 + .../TestComponent.codegen.cs | 31 +++ .../TestComponent.ir.txt | 12 + .../ComponentTagHelperDescriptorProvider.cs | 9 + ...omponentTagHelperDescriptorProviderTest.cs | 49 ++++ ...ft.AspNetCore.Components.netstandard2.0.cs | 7 + .../TagHelperDescriptorJsonConverter.cs | 15 +- 66 files changed, 1383 insertions(+), 10 deletions(-) create mode 100644 src/Components/Components/src/EditorRequiredAttribute.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_AllValuesSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_AllValuesSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_NoValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_NoValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.diagnostics.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.ir.txt diff --git a/src/Components/Components/src/DynamicComponent.cs b/src/Components/Components/src/DynamicComponent.cs index 3e5e932a8bef..387d98f8fc0b 100644 --- a/src/Components/Components/src/DynamicComponent.cs +++ b/src/Components/Components/src/DynamicComponent.cs @@ -32,6 +32,7 @@ public DynamicComponent() /// [Parameter] [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] + [EditorRequired] public Type Type { get; set; } = default!; /// diff --git a/src/Components/Components/src/EditorRequiredAttribute.cs b/src/Components/Components/src/EditorRequiredAttribute.cs new file mode 100644 index 000000000000..38a23937668b --- /dev/null +++ b/src/Components/Components/src/EditorRequiredAttribute.cs @@ -0,0 +1,19 @@ +// 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; + +namespace Microsoft.AspNetCore.Components +{ + /// + /// Specifies that the component parameter is required to be provided by the user when authoring it in the editor. + /// + /// If a value for this parameter is not provided, editors or build tools may provide warnings indicating the user to + /// specify a value. This attribute is only valid on properties marked with . + /// + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] + public sealed class EditorRequiredAttribute : Attribute + { + } +} diff --git a/src/Components/Components/src/PublicAPI.Unshipped.txt b/src/Components/Components/src/PublicAPI.Unshipped.txt index 4058101d38ad..50c92b7e30c5 100644 --- a/src/Components/Components/src/PublicAPI.Unshipped.txt +++ b/src/Components/Components/src/PublicAPI.Unshipped.txt @@ -9,6 +9,8 @@ Microsoft.AspNetCore.Components.ComponentApplicationState.PersistAsJson( Microsoft.AspNetCore.Components.ComponentApplicationState.PersistState(string! key, byte[]! value) -> void Microsoft.AspNetCore.Components.ComponentApplicationState.TryTakeAsJson(string! key, out TValue? instance) -> bool Microsoft.AspNetCore.Components.ComponentApplicationState.TryTakePersistedState(string! key, out byte[]? value) -> bool +Microsoft.AspNetCore.Components.EditorRequiredAttribute +Microsoft.AspNetCore.Components.EditorRequiredAttribute.EditorRequiredAttribute() -> void Microsoft.AspNetCore.Components.ErrorBoundaryBase Microsoft.AspNetCore.Components.ErrorBoundaryBase.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? Microsoft.AspNetCore.Components.ErrorBoundaryBase.ChildContent.set -> void diff --git a/src/Components/Components/src/RouteView.cs b/src/Components/Components/src/RouteView.cs index d94ca1083384..76f9f47d311e 100644 --- a/src/Components/Components/src/RouteView.cs +++ b/src/Components/Components/src/RouteView.cs @@ -25,6 +25,7 @@ public class RouteView : IComponent /// displayed and the parameter values that will be supplied to the page. /// [Parameter] + [EditorRequired] public RouteData RouteData { get; set; } /// diff --git a/src/Components/Components/src/Routing/Router.cs b/src/Components/Components/src/Routing/Router.cs index bc8bd0b3d6c0..3a05e7589bea 100644 --- a/src/Components/Components/src/Routing/Router.cs +++ b/src/Components/Components/src/Routing/Router.cs @@ -47,7 +47,9 @@ static readonly IReadOnlyDictionary _emptyParametersDictionary /// /// Gets or sets the assembly that should be searched for components matching the URI. /// - [Parameter] public Assembly AppAssembly { get; set; } + [Parameter] + [EditorRequired] + public Assembly AppAssembly { get; set; } /// /// Gets or sets a collection of additional assemblies that should be searched for components @@ -58,12 +60,16 @@ static readonly IReadOnlyDictionary _emptyParametersDictionary /// /// Gets or sets the content to display when no match is found for the requested route. /// - [Parameter] public RenderFragment NotFound { get; set; } + [Parameter] + [EditorRequired] + public RenderFragment NotFound { get; set; } /// /// Gets or sets the content to display when a match is found for the requested route. /// - [Parameter] public RenderFragment Found { get; set; } + [Parameter] + [EditorRequired] + public RenderFragment Found { get; set; } /// /// Get or sets the content to display when asynchronous navigation is in progress. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs index ecfd96105f54..55070b1a12d7 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptor.cs @@ -1,3 +1,4 @@ + // 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. @@ -29,6 +30,8 @@ protected BoundAttributeDescriptor(string kind) public bool IsBooleanProperty { get; protected set; } + internal bool IsEditorRequired { get; set; } + public string Name { get; protected set; } public string IndexerNamePrefix { get; protected set; } @@ -81,4 +84,4 @@ public override int GetHashCode() return BoundAttributeDescriptorComparer.Default.GetHashCode(this); } } -} \ No newline at end of file +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilder.cs index b6fb01d7ad01..051f2655d67b 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilder.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/BoundAttributeDescriptorBuilder.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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; @@ -28,6 +28,8 @@ public abstract class BoundAttributeDescriptorBuilder public abstract RazorDiagnosticCollection Diagnostics { get; } + internal bool IsEditorRequired { get; set; } + public virtual IReadOnlyList BoundAttributeParameters { get; } public virtual void BindAttributeParameter(Action configure) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs index 3a7e3c748e28..fa0c73783502 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentLoweringPass.cs @@ -67,7 +67,7 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentInte } } - private ComponentIntermediateNode RewriteAsComponent(TagHelperIntermediateNode node, TagHelperDescriptor tagHelper) + private static ComponentIntermediateNode RewriteAsComponent(TagHelperIntermediateNode node, TagHelperDescriptor tagHelper) { var component = new ComponentIntermediateNode() { @@ -89,13 +89,54 @@ private ComponentIntermediateNode RewriteAsComponent(TagHelperIntermediateNode n // because we see the nodes in the wrong order. foreach (var childContent in component.ChildContents) { - childContent.ParameterName = childContent.ParameterName ?? component.ChildContentParameterName ?? ComponentMetadata.ChildContent.DefaultParameterName; + childContent.ParameterName ??= component.ChildContentParameterName ?? ComponentMetadata.ChildContent.DefaultParameterName; } + ValidateRequiredAttributes(node, tagHelper, component); + return component; } - private MarkupElementIntermediateNode RewriteAsElement(TagHelperIntermediateNode node) + private static void ValidateRequiredAttributes(TagHelperIntermediateNode node, TagHelperDescriptor tagHelper, ComponentIntermediateNode intermediateNode) + { + if (intermediateNode.Children.Any(c => c is TagHelperDirectiveAttributeIntermediateNode node && (node.TagHelper?.IsSplatTagHelper() ?? false))) + { + // If there are any splat attributes, assume the user may have provided all values. + // This pass runs earlier than ComponentSplatLoweringPass, so we cannot rely on the presence of SplatIntermediateNode to make this check. + return; + } + + foreach (var requiredAttribute in tagHelper.EditorRequiredAttributes) + { + if (!IsPresentAsAttribute(requiredAttribute.Name, intermediateNode)) + { + intermediateNode.Diagnostics.Add( + RazorDiagnosticFactory.CreateComponent_EditorRequiredParameterNotSpecified( + node.Source ?? SourceSpan.Undefined, + intermediateNode.TagName, + requiredAttribute.Name)); + } + } + + static bool IsPresentAsAttribute(string attributeName, ComponentIntermediateNode intermediateNode) + { + foreach (var child in intermediateNode.Children) + { + if (child is ComponentAttributeIntermediateNode attributeNode && attributeName == attributeNode.AttributeName) + { + return true; + } + else if (child is ComponentChildContentIntermediateNode childContent && attributeName == childContent.AttributeName) + { + return true; + } + } + + return false; + } + } + + private static MarkupElementIntermediateNode RewriteAsElement(TagHelperIntermediateNode node) { var result = new MarkupElementIntermediateNode() { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptorBuilder.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptorBuilder.cs index 52f152b33f8d..446bd56b7460 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptorBuilder.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DefaultBoundAttributeDescriptorBuilder.cs @@ -125,7 +125,10 @@ public BoundAttributeDescriptor Build() CaseSensitive, parameters, new Dictionary(Metadata), - diagnostics.ToArray()); + diagnostics.ToArray()) + { + IsEditorRequired = IsEditorRequired, + }; return descriptor; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs index d88879c15960..95f0589e968a 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.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; +using System.Collections.Generic; using Microsoft.AspNetCore.Razor.Language.Legacy; namespace Microsoft.AspNetCore.Razor.Language @@ -588,6 +589,28 @@ public static RazorDiagnostic CreateTagHelper_InconsistentTagStructure(SourceSpa return RazorDiagnostic.Create(TagHelper_InconsistentTagStructure, location, firstDescriptor, secondDescriptor, tagName, nameof(TagMatchingRuleDescriptor.TagStructure)); } + internal static readonly RazorDiagnosticDescriptor Component_EditorRequiredParameterNotSpecified = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2012", + () => Resources.Component_EditorRequiredParameterNotSpecified, + RazorDiagnosticSeverity.Warning); + + public static RazorDiagnostic CreateComponent_EditorRequiredParameterNotSpecified(SourceSpan location, string tagName, string parameterName) + { + return RazorDiagnostic.Create(Component_EditorRequiredParameterNotSpecified, location, tagName, parameterName); + } + + internal static readonly RazorDiagnosticDescriptor Component_EditorRequiredGroupNotSpecified = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}2013", + () => Resources.Component_EditorRequiredGroupNotSpecified, + RazorDiagnosticSeverity.Warning); + + public static RazorDiagnostic CreateComponent_EditorRequiredGroupNotSpecified(SourceSpan location, string tagName, IEnumerable parameterNames) + { + return RazorDiagnostic.Create(Component_EditorRequiredParameterNotSpecified, location, tagName, string.Join(", ", parameterNames)); + } + #endregion #region TagHelper Errors diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx index 8fa60e30c6e6..b2d1b0ca554a 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx @@ -571,4 +571,10 @@ '{0}' is not valid in this position. Valid options are '{1}' + + Component '{0}' expects a value for the parameter '{1}', but a value may not have been provided. + + + Component '{0}' expects a value for the following parameters '{1}' that may not have been provided. + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs index 409e71248359..a3c264137e20 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperDescriptor.cs @@ -10,6 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Language public abstract class TagHelperDescriptor : IEquatable { private IEnumerable _allDiagnostics; + private BoundAttributeDescriptor[] _editorRequiredAttributes; protected TagHelperDescriptor(string kind) { @@ -45,6 +46,14 @@ protected TagHelperDescriptor(string kind) internal bool? IsComponentFullyQualifiedNameMatchCache { get; set; } internal bool? IsChildContentTagHelperCache { get; set; } internal ParsedTypeInformation? ParsedTypeInfo { get; set; } + internal BoundAttributeDescriptor[] EditorRequiredAttributes + { + get + { + _editorRequiredAttributes ??= GetEditorRequiredAttributes(BoundAttributes); + return _editorRequiredAttributes; + } + } public bool HasErrors { @@ -96,6 +105,23 @@ public override int GetHashCode() return _hashCode.Value; } + private static BoundAttributeDescriptor[] GetEditorRequiredAttributes(IReadOnlyList boundAttributeDescriptors) + { + List editorRequiredAttributes = null; + var count = boundAttributeDescriptors.Count; + for (var i = 0; i < count; i++) + { + var attribute = boundAttributeDescriptors[i]; + if (attribute.IsEditorRequired) + { + editorRequiredAttributes ??= new(); + editorRequiredAttributes.Add(attribute); + } + } + + return editorRequiredAttributes?.ToArray() ?? Array.Empty(); + } + internal readonly struct ParsedTypeInformation { public ParsedTypeInformation(bool success, StringSegment @namespace, StringSegment typeName) 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 56e308c0bb12..449d3e189b3d 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -517,6 +517,238 @@ public class ComponentWithNullableRenderFragment : ComponentBase CompileToAssembly(generated); } + [Fact] + public void Component_WithEditorRequiredParameter_NoValueSpecified() + { + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class ComponentWithEditorRequiredParameters : ComponentBase + { + [Parameter] + [EditorRequired] + public string Property1 { get; set; } + } +} +")); + var generated = CompileToCSharp(@" + +"); + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, throwOnFailure: false); + + var diagnostics = Assert.Single(generated.Diagnostics); + Assert.Equal(RazorDiagnosticSeverity.Warning, diagnostics.Severity); + Assert.Equal("RZ2012", diagnostics.Id); + } + + [Fact] + public void Component_WithEditorRequiredParameter_ValueSpecified() + { + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class ComponentWithEditorRequiredParameters : ComponentBase + { + [Parameter] + [EditorRequired] + public string Property1 { get; set; } + } +} +")); + var generated = CompileToCSharp(@" + +"); + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + + Assert.Empty(generated.Diagnostics); + } + + [Fact] + public void Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting() + { + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class ComponentWithEditorRequiredParameters : ComponentBase + { + [Parameter] + [EditorRequired] + public string Property1 { get; set; } + } +} +")); + var generated = CompileToCSharp(@" +())"" /> +"); + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + + Assert.Empty(generated.Diagnostics); + } + + [Fact] + public void Component_WithEditorRequiredChildContent_NoValueSpecified() + { + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class ComponentWithEditorRequiredChildContent : ComponentBase + { + [Parameter] + [EditorRequired] + public RenderFragment ChildContent { get; set; } + } +} +")); + var generated = CompileToCSharp(@" + +"); + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, throwOnFailure: false); + + var diagnostics = Assert.Single(generated.Diagnostics); + Assert.Equal(RazorDiagnosticSeverity.Warning, diagnostics.Severity); + Assert.Equal("RZ2012", diagnostics.Id); + } + + [Fact] + public void Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName() + { + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class ComponentWithEditorRequiredChildContent : ComponentBase + { + [Parameter] + [EditorRequired] + public RenderFragment ChildContent { get; set; } + } +} +")); + var generated = CompileToCSharp(@" + +

Hello World

+
+ +"); + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + + Assert.Empty(generated.Diagnostics); + } + + [Fact] + public void Component_WithEditorRequiredChildContent_ValueSpecified() + { + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class ComponentWithEditorRequiredChildContent : ComponentBase + { + [Parameter] + [EditorRequired] + public RenderFragment ChildContent { get; set; } + } +} +")); + var generated = CompileToCSharp(@" + + +

Hello World

+
+
+ +"); + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + + Assert.Empty(generated.Diagnostics); + } + + [Fact] + public void Component_WithEditorRequiredNamedChildContent_NoValueSpecified() + { + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class ComponentWithEditorRequiredChildContent : ComponentBase + { + [Parameter] + [EditorRequired] + public RenderFragment Found { get; set; } + + [Parameter] + public RenderFragment NotFound { get; set; } + } +} +")); + var generated = CompileToCSharp(@" + + + +"); + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated, throwOnFailure: false); + + var diagnostics = Assert.Single(generated.Diagnostics); + Assert.Equal(RazorDiagnosticSeverity.Warning, diagnostics.Severity); + Assert.Equal("RZ2012", diagnostics.Id); + } + + [Fact] + public void Component_WithEditorRequiredNamedChildContent_ValueSpecified() + { + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class ComponentWithEditorRequiredChildContent : ComponentBase + { + [Parameter] + [EditorRequired] + public RenderFragment Found { get; set; } + + [Parameter] + public RenderFragment NotFound { get; set; } + } +} +")); + var generated = CompileToCSharp(@" + +

Here's Johnny!

+
+ +"); + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + + Assert.Empty(generated.Diagnostics); + } #endregion #region Bind diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..a48dac4649f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 partial 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.Rendering.RenderTreeBuilder __builder) + { + __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(ComponentWithEditorRequiredChildContent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.diagnostics.txt new file mode 100644 index 000000000000..20d0a0227048 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Warning RZ2012: Component 'ComponentWithEditorRequiredChildContent' expects a value for the parameter 'ChildContent', but a value may not have been provided. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..52b25c291c98 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.ir.txt @@ -0,0 +1,19 @@ +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 partial - 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 [43] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent + HtmlContent - (43:0,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (43:0,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..a48dac4649f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 partial 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.Rendering.RenderTreeBuilder __builder) + { + __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(ComponentWithEditorRequiredChildContent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..5c77e7f32345 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 partial - 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 [156] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent + ComponentChildContent - (47:1,4 [65] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent - context + HtmlContent - (61:1,18 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (61:1,18 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (71:2,8 [20] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (75:2,12 [11] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (75:2,12 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello World + HtmlContent - (91:2,28 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (91:2,28 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (156:4,42 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (156:4,42 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.codegen.cs new file mode 100644 index 000000000000..a48dac4649f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 partial 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.Rendering.RenderTreeBuilder __builder) + { + __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(ComponentWithEditorRequiredChildContent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.ir.txt new file mode 100644 index 000000000000..4a95e0c7fe87 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.ir.txt @@ -0,0 +1,27 @@ +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 partial - 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 [111] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent + ComponentChildContent - - ChildContent - context + HtmlContent - (41:0,41 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (41:0,41 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (47:1,4 [20] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (51:1,8 [11] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (51:1,8 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello World + HtmlContent - (67:1,24 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (67:1,24 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (111:2,42 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (111:2,42 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..a48dac4649f6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 partial 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.Rendering.RenderTreeBuilder __builder) + { + __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(ComponentWithEditorRequiredChildContent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.diagnostics.txt new file mode 100644 index 000000000000..ae41788d3a55 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Warning RZ2012: Component 'ComponentWithEditorRequiredChildContent' expects a value for the parameter 'Found', but a value may not have been provided. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..ce3eae7ba232 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.ir.txt @@ -0,0 +1,19 @@ +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 partial - 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 [85] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent + HtmlContent - (85:1,42 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (85:1,42 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..cba1ffd9ba18 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 partial 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.Rendering.RenderTreeBuilder __builder) + { + __builder.AddAttribute(-1, "Found", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(ComponentWithEditorRequiredChildContent); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..1d72e953e354 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.ir.txt @@ -0,0 +1,23 @@ +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 partial - 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 [129] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent + ComponentChildContent - (47:1,4 [38] x:\dir\subdir\Test\TestComponent.cshtml) - Found - context + MarkupElement - (54:1,11 [23] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (58:1,15 [14] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (58:1,15 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Here's Johnny! + HtmlContent - (129:2,42 [4] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (129:2,42 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..f73731f994af --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,37 @@ +// +#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 partial 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.Rendering.RenderTreeBuilder __builder) + { + __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(ComponentWithEditorRequiredParameters); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.diagnostics.txt new file mode 100644 index 000000000000..bfd22f324ad5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Warning RZ2012: Component 'ComponentWithEditorRequiredParameters' expects a value for the parameter 'Property1', but a value may not have been provided. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..b35279a1e279 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.ir.txt @@ -0,0 +1,19 @@ +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 partial - 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 [41] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredParameters + HtmlContent - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (41:0,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..0e7c5b81b960 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/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 partial 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.Rendering.RenderTreeBuilder __builder) + { + __o = ""; + __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(ComponentWithEditorRequiredParameters); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..b9b2f6ce0216 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.ir.txt @@ -0,0 +1,22 @@ +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 partial - 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 [64] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredParameters + ComponentAttribute - (50:0,50 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Property1 - Property1 - AttributeStructure.DoubleQuotes + HtmlContent - (50:0,50 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:0,50 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Some Value + HtmlContent - (64:0,64 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (64:0,64 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.codegen.cs new file mode 100644 index 000000000000..26dd4369cce9 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/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 partial 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.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMultipleAttributes(-1, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + new Dictionary() + +#line default +#line hidden +#nullable disable + )); + __builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + } + )); +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = typeof(ComponentWithEditorRequiredParameters); + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.ir.txt new file mode 100644 index 000000000000..5f2978118677 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.ir.txt @@ -0,0 +1,21 @@ +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 partial - 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 [91] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredParameters + Splat - (52:0,52 [35] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (54:0,54 [32] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - new Dictionary() + HtmlContent - (91:0,91 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (91:0,91 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.mappings.txt new file mode 100644 index 000000000000..7cebbba6a3fb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (54:0,54 [32] x:\dir\subdir\Test\TestComponent.cshtml) +|new Dictionary()| +Generated Location: (1151:25,54 [32] ) +|new Dictionary()| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..14a24d17d315 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,22 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.diagnostics.txt new file mode 100644 index 000000000000..20d0a0227048 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Warning RZ2012: Component 'ComponentWithEditorRequiredChildContent' expects a value for the parameter 'ChildContent', but a value may not have been provided. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..eeaeb098263a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_NoValueSpecified/TestComponent.ir.txt @@ -0,0 +1,10 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..7d98722251bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,26 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + __builder2.AddMarkupContent(2, "

Hello World

"); + } + )); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..ccbcd91f0074 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [156] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent + ComponentChildContent - (47:1,4 [65] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent - context + MarkupBlock - -

Hello World

diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.codegen.cs new file mode 100644 index 000000000000..7d98722251bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.codegen.cs @@ -0,0 +1,26 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + __builder2.AddMarkupContent(2, "

Hello World

"); + } + )); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.ir.txt new file mode 100644 index 000000000000..c27b5fa23bb1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredChildContent_ValueSpecified_WithoutName/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [111] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent + ComponentChildContent - - ChildContent - context + MarkupBlock - -

Hello World

diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_AllValuesSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_AllValuesSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..0226ac52987a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_AllValuesSpecified/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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Property1", "SomeValue"); + __builder.AddAttribute(2, "Property2", "DifferentValue"); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_AllValuesSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_AllValuesSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..8bf4f01394db --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_AllValuesSpecified/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 partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [79] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithRequiredGroup + ComponentAttribute - (39:0,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Property1 - Property1 - AttributeStructure.DoubleQuotes + HtmlContent - (39:0,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - SomeValue + ComponentAttribute - (61:0,61 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Property2 - Property2 - AttributeStructure.DoubleQuotes + HtmlContent - (61:0,61 [14] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (61:0,61 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Html - DifferentValue diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_NoValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_NoValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..3f6fa0c913ca --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_NoValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,22 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_NoValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_NoValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..f2e89a110fe2 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_NoValueSpecified/TestComponent.ir.txt @@ -0,0 +1,10 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [30] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithRequiredGroup diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..f9b09964364e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,23 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Property1", "SomeValue"); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.diagnostics.txt new file mode 100644 index 000000000000..0da7dd5be3c1 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Warning RZ2012: Component 'ComponentWithRequiredGroup' expects a value for the parameter 'Property2', but a value may not have been provided. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..f0708c0f9af6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified/TestComponent.ir.txt @@ -0,0 +1,13 @@ +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 partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [52] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithRequiredGroup + ComponentAttribute - (39:0,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Property1 - Property1 - AttributeStructure.DoubleQuotes + HtmlContent - (39:0,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - SomeValue diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.codegen.cs new file mode 100644 index 000000000000..f9b09964364e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.codegen.cs @@ -0,0 +1,23 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Property1", "SomeValue"); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.diagnostics.txt new file mode 100644 index 000000000000..69517a6b6721 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Warning RZ2012: Component 'ComponentWithRequiredGroup' expects a value for the parameter 'Property2', but a value may not have been provided. +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Warning RZ2012: Component 'ComponentWithRequiredGroup' expects a value for the parameter 'Property3', but a value may not have been provided. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.ir.txt new file mode 100644 index 000000000000..f0708c0f9af6 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredGroup_SomeValueSpecified_MultipleGroups/TestComponent.ir.txt @@ -0,0 +1,13 @@ +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 partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [52] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithRequiredGroup + ComponentAttribute - (39:0,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Property1 - Property1 - AttributeStructure.DoubleQuotes + HtmlContent - (39:0,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - SomeValue diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..14a24d17d315 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,22 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.diagnostics.txt new file mode 100644 index 000000000000..ae41788d3a55 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Warning RZ2012: Component 'ComponentWithEditorRequiredChildContent' expects a value for the parameter 'Found', but a value may not have been provided. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..2b0cf719804f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_NoValueSpecified/TestComponent.ir.txt @@ -0,0 +1,10 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [85] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..689b78d662eb --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,26 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Found", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { + __builder2.AddMarkupContent(2, "

Here\'s Johnny!

"); + } + )); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..5ad404eddf0b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredNamedChildContent_ValueSpecified/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [129] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredChildContent + ComponentChildContent - (47:1,4 [38] x:\dir\subdir\Test\TestComponent.cshtml) - Found - context + MarkupBlock - -

Here's Johnny!

diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..1c8d727f1c5d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,22 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.diagnostics.txt new file mode 100644 index 000000000000..bfd22f324ad5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.diagnostics.txt @@ -0,0 +1 @@ +x:\dir\subdir\Test\TestComponent.cshtml(1,1): Warning RZ2012: Component 'ComponentWithEditorRequiredParameters' expects a value for the parameter 'Property1', but a value may not have been provided. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..2fb846577adf --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_NoValueSpecified/TestComponent.ir.txt @@ -0,0 +1,10 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredParameters diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.codegen.cs new file mode 100644 index 000000000000..f28daeec9e39 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.codegen.cs @@ -0,0 +1,23 @@ +// +#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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddAttribute(1, "Property1", "Some Value"); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.ir.txt new file mode 100644 index 000000000000..8593a60ae1cd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValueSpecified/TestComponent.ir.txt @@ -0,0 +1,13 @@ +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 partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredParameters + ComponentAttribute - (50:0,50 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Property1 - Property1 - AttributeStructure.DoubleQuotes + HtmlContent - (50:0,50 [10] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (50:0,50 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Some Value diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.codegen.cs new file mode 100644 index 000000000000..31592fae8192 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/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 partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.OpenComponent(0); + __builder.AddMultipleAttributes(1, global::Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck>>( +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + new Dictionary() + +#line default +#line hidden +#nullable disable + )); + __builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.ir.txt new file mode 100644 index 000000000000..cff4f423c5fe --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithEditorRequiredParameter_ValuesSpecifiedUsingSplatting/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + Component - (0:0,0 [91] x:\dir\subdir\Test\TestComponent.cshtml) - ComponentWithEditorRequiredParameters + Splat - (52:0,52 [35] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (54:0,54 [32] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - new Dictionary() diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs index 195f29e89dcc..678f10945ca5 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs @@ -172,6 +172,15 @@ private void CreateProperty(TagHelperDescriptorBuilder builder, IPropertySymbol pb.Name = property.Name; pb.TypeName = property.Type.ToDisplayString(FullNameTypeDisplayFormat); pb.SetPropertyName(property.Name); + var editorRequired = property.GetAttributes().FirstOrDefault(a => a.AttributeClass.ToDisplayString() == "Microsoft.AspNetCore.Components.EditorRequiredAttribute"); + if (editorRequired != null) + { + pb.IsEditorRequired = true; + if (editorRequired.ConstructorArguments.Length > 0) + { + pb.EditorRequiredGroupNames = editorRequired.ConstructorArguments[0].Values.Select(v => (string)v.Value).ToArray(); + } + } if (kind == PropertyKind.Enum) { diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs index 4a0e2c676d2d..e854b6c9bc7c 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/ComponentTagHelperDescriptorProviderTest.cs @@ -426,6 +426,55 @@ public class MyComponent : ComponentBase Assert.False(attribute.IsStringProperty); } + [Fact] // editor-required parameters + public void Execute_EditorRequiredProperty_CreatesDescriptor() + { + // Arrange + + var compilation = BaseCompilation.AddSyntaxTrees(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + [EditorRequired] + public string MyProperty { get; set; } + } +} + +")); + + Assert.Empty(compilation.GetDiagnostics()); + + var context = TagHelperDescriptorProviderContext.Create(); + context.SetCompilation(compilation); + + var provider = new ComponentTagHelperDescriptorProvider(); + + // Act + provider.Execute(context); + + // Assert + var components = ExcludeBuiltInComponents(context); + components = AssertAndExcludeFullyQualifiedNameMatchComponents(components, expectedCount: 1); + var component = Assert.Single(components); + + Assert.Equal("TestAssembly", component.AssemblyName); + Assert.Equal("Test.MyComponent", component.Name); + + var attribute = Assert.Single(component.BoundAttributes); + Assert.Equal("MyProperty", attribute.Name); + Assert.Equal("System.String", attribute.TypeName); + + Assert.False(attribute.HasIndexer); + Assert.False(attribute.IsBooleanProperty); + Assert.False(attribute.IsEnum); + Assert.True(attribute.IsStringProperty); + Assert.True(attribute.IsEditorRequired); + } + [Fact] public void Execute_GenericProperty_CreatesDescriptor() { diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs index 6b51474c3c8d..7e807c0f675a 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components.netstandard2.0.cs @@ -1,6 +1,8 @@ // 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; + namespace Microsoft.AspNetCore.Components { public static partial class BindConverter @@ -375,6 +377,11 @@ public void Attach(Microsoft.AspNetCore.Components.RenderHandle renderHandle) { protected virtual void Render(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder) { } public System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView parameters) { throw null; } } + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] + public partial class EditorRequiredAttribute : Attribute + { + public EditorRequiredAttribute() { } + } } namespace Microsoft.AspNetCore.Components.CompilerServices { diff --git a/src/Shared/RazorShared/TagHelperDescriptorJsonConverter.cs b/src/Shared/RazorShared/TagHelperDescriptorJsonConverter.cs index 85763bf559d6..9148390be4e7 100644 --- a/src/Shared/RazorShared/TagHelperDescriptorJsonConverter.cs +++ b/src/Shared/RazorShared/TagHelperDescriptorJsonConverter.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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; @@ -189,6 +189,12 @@ private static void WriteBoundAttribute(JsonWriter writer, BoundAttributeDescrip writer.WriteValue(boundAttribute.IndexerNamePrefix); } + if (boundAttribute.IsEditorRequired) + { + writer.WritePropertyName(nameof(BoundAttributeDescriptor.IsEditorRequired)); + writer.WriteValue(boundAttribute.IsEditorRequired); + } + if (boundAttribute.IndexerTypeName != null) { writer.WritePropertyName(nameof(BoundAttributeDescriptor.IndexerTypeName)); @@ -434,6 +440,13 @@ private static void ReadBoundAttribute(JsonReader reader, TagHelperDescriptorBui attribute.IsEnum = isEnum; } break; + case nameof(BoundAttributeDescriptor.IsEditorRequired): + if (reader.Read()) + { + var value = (bool)reader.Value; + attribute.IsEditorRequired = value; + } + break; case nameof(BoundAttributeDescriptor.BoundAttributeParameters): ReadBoundAttributeParameters(reader, attribute); break; From 26ae54b8c23993e72649241b337afe4ef96aeed5 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 8 Jun 2021 15:14:29 -0700 Subject: [PATCH 2/5] Clean up code --- .../src/ComponentTagHelperDescriptorProvider.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs index 678f10945ca5..ed16a2e07529 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs @@ -172,15 +172,7 @@ private void CreateProperty(TagHelperDescriptorBuilder builder, IPropertySymbol pb.Name = property.Name; pb.TypeName = property.Type.ToDisplayString(FullNameTypeDisplayFormat); pb.SetPropertyName(property.Name); - var editorRequired = property.GetAttributes().FirstOrDefault(a => a.AttributeClass.ToDisplayString() == "Microsoft.AspNetCore.Components.EditorRequiredAttribute"); - if (editorRequired != null) - { - pb.IsEditorRequired = true; - if (editorRequired.ConstructorArguments.Length > 0) - { - pb.EditorRequiredGroupNames = editorRequired.ConstructorArguments[0].Values.Select(v => (string)v.Value).ToArray(); - } - } + pb.IsEditorRequired = property.GetAttributes().Any(a => a.AttributeClass.ToDisplayString() == "Microsoft.AspNetCore.Components.EditorRequiredAttribute"); if (kind == PropertyKind.Enum) { From 1bdd51d86790eadfb8204bbdb15882ff1c6b2d81 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 8 Jun 2021 15:23:43 -0700 Subject: [PATCH 3/5] Delete more code --- .../src/RazorDiagnosticFactory.cs | 11 ----------- .../src/Resources.resx | 7 ++----- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs index 95f0589e968a..2e3c31b4eadf 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs @@ -600,17 +600,6 @@ public static RazorDiagnostic CreateComponent_EditorRequiredParameterNotSpecifie return RazorDiagnostic.Create(Component_EditorRequiredParameterNotSpecified, location, tagName, parameterName); } - internal static readonly RazorDiagnosticDescriptor Component_EditorRequiredGroupNotSpecified = - new RazorDiagnosticDescriptor( - $"{DiagnosticPrefix}2013", - () => Resources.Component_EditorRequiredGroupNotSpecified, - RazorDiagnosticSeverity.Warning); - - public static RazorDiagnostic CreateComponent_EditorRequiredGroupNotSpecified(SourceSpan location, string tagName, IEnumerable parameterNames) - { - return RazorDiagnostic.Create(Component_EditorRequiredParameterNotSpecified, location, tagName, string.Join(", ", parameterNames)); - } - #endregion #region TagHelper Errors diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx index b2d1b0ca554a..6d541a509f83 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx @@ -1,4 +1,4 @@ - +