diff --git a/src/Razor/Razor.Slim.sln b/src/Razor/Razor.Slim.sln index 1bf349d7ad8..7415f02d600 100644 --- a/src/Razor/Razor.Slim.sln +++ b/src/Razor/Razor.Slim.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2036 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28410.60 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C0D6505-79B3-49D0-B4C3-176F0F1836ED}" ProjectSection(SolutionItems) = preProject @@ -80,6 +80,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.RazorAddin", "src\Microsoft.VisualStudio.Mac.RazorAddin\Microsoft.VisualStudio.Mac.RazorAddin.csproj", "{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.ComponentShim", "test\Microsoft.AspNetCore.Razor.Test.ComponentShim\Microsoft.AspNetCore.Razor.Test.ComponentShim.csproj", "{A9FDA40B-0EE4-4B00-8E24-F1C8B62154BE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -222,6 +224,10 @@ Global {A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.Debug|Any CPU.Build.0 = Debug|Any CPU {A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.Release|Any CPU.ActiveCfg = Release|Any CPU {A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.Release|Any CPU.Build.0 = Release|Any CPU + {A9FDA40B-0EE4-4B00-8E24-F1C8B62154BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A9FDA40B-0EE4-4B00-8E24-F1C8B62154BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9FDA40B-0EE4-4B00-8E24-F1C8B62154BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A9FDA40B-0EE4-4B00-8E24-F1C8B62154BE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -261,6 +267,7 @@ Global {495A006C-D2B9-4AD0-9D33-60820BA501D8} = {92463391-81BE-462B-AC3C-78C6C760741F} {D87E5501-B832-46B6-ACD3-EC989E3D14ED} = {92463391-81BE-462B-AC3C-78C6C760741F} {A34CCC12-687B-4D12-AA0E-F5BE800DE19C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} + {A9FDA40B-0EE4-4B00-8E24-F1C8B62154BE} = {92463391-81BE-462B-AC3C-78C6C760741F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0035341D-175A-4D05-95E6-F1C2785A1E26} diff --git a/src/Razor/Razor.sln b/src/Razor/Razor.sln index 36ee01c91a2..fffcbe95946 100644 --- a/src/Razor/Razor.sln +++ b/src/Razor/Razor.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2036 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28410.60 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C0D6505-79B3-49D0-B4C3-176F0F1836ED}" ProjectSection(SolutionItems) = preProject @@ -84,6 +84,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorDeveloperTools", "src\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Mac.RazorAddin", "src\Microsoft.VisualStudio.Mac.RazorAddin\Microsoft.VisualStudio.Mac.RazorAddin.csproj", "{A34CCC12-687B-4D12-AA0E-F5BE800DE19C}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.ComponentShim", "test\Microsoft.AspNetCore.Razor.Test.ComponentShim\Microsoft.AspNetCore.Razor.Test.ComponentShim.csproj", "{5B232E77-F0D3-4298-9A5D-D965788D7A79}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -380,6 +382,14 @@ Global {A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.Release|Any CPU.Build.0 = Release|Any CPU {A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU {A34CCC12-687B-4D12-AA0E-F5BE800DE19C}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU + {5B232E77-F0D3-4298-9A5D-D965788D7A79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5B232E77-F0D3-4298-9A5D-D965788D7A79}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5B232E77-F0D3-4298-9A5D-D965788D7A79}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU + {5B232E77-F0D3-4298-9A5D-D965788D7A79}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU + {5B232E77-F0D3-4298-9A5D-D965788D7A79}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5B232E77-F0D3-4298-9A5D-D965788D7A79}.Release|Any CPU.Build.0 = Release|Any CPU + {5B232E77-F0D3-4298-9A5D-D965788D7A79}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU + {5B232E77-F0D3-4298-9A5D-D965788D7A79}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -421,6 +431,7 @@ Global {BCF712D4-329A-4C7A-8292-9EFC864B2ABA} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} {23424C44-A86D-4DBD-9274-E358B19DDBA1} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} {A34CCC12-687B-4D12-AA0E-F5BE800DE19C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} + {5B232E77-F0D3-4298-9A5D-D965788D7A79} = {92463391-81BE-462B-AC3C-78C6C760741F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0035341D-175A-4D05-95E6-F1C2785A1E26} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentDiagnosticFactory.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentDiagnosticFactory.cs new file mode 100644 index 00000000000..684bcbcec71 --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentDiagnosticFactory.cs @@ -0,0 +1,322 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using Microsoft.AspNetCore.Razor.Language.Intermediate; + +namespace Microsoft.AspNetCore.Razor.Language +{ + internal static class ComponentDiagnosticFactory + { + public static readonly RazorDiagnosticDescriptor CodeBlockInAttribute = + new RazorDiagnosticDescriptor( + "BL9979", + () => + "Code blocks delimited by '@{...}' like '@{{ {0} }}' for attributes are no longer supported " + + "These features have been changed to use attribute syntax. " + + "Use 'attr=\"@(x => {... }\"'.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_CodeBlockInAttribute(SourceSpan? source, string expression) + { + var diagnostic = RazorDiagnostic.Create( + CodeBlockInAttribute, + source ?? SourceSpan.Undefined, + expression); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor UnclosedTag = new RazorDiagnosticDescriptor( + "BL9980", + () => "Unclosed tag '{0}' with no matching end tag.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnclosedTag(SourceSpan? span, string tagName) + { + return RazorDiagnostic.Create(UnclosedTag, span ?? SourceSpan.Undefined, tagName); + } + + public static readonly RazorDiagnosticDescriptor UnexpectedClosingTag = new RazorDiagnosticDescriptor( + "BL9981", + () => "Unexpected closing tag '{0}' with no matching start tag.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnexpectedClosingTag(SourceSpan? span, string tagName) + { + return RazorDiagnostic.Create(UnexpectedClosingTag, span ?? SourceSpan.Undefined, tagName); + } + + public static readonly RazorDiagnosticDescriptor MismatchedClosingTag = new RazorDiagnosticDescriptor( + "BL9982", + () => "Mismatching closing tag. Found '{0}' but expected '{1}'.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_MismatchedClosingTag(SourceSpan? span, string expectedTagName, string tagName) + { + return RazorDiagnostic.Create(MismatchedClosingTag, span ?? SourceSpan.Undefined, expectedTagName, tagName); + } + + public static readonly RazorDiagnosticDescriptor UnexpectedClosingTagForVoidElement = new RazorDiagnosticDescriptor( + "BL9983", + () => "Unexpected closing tag '{0}'. The element '{0}' is a void element, and should be used without a closing tag.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnexpectedClosingTagForVoidElement(SourceSpan? span, string tagName) + { + return RazorDiagnostic.Create(UnexpectedClosingTagForVoidElement, span ?? SourceSpan.Undefined, tagName); + } + + public static readonly RazorDiagnosticDescriptor InvalidHtmlContent = new RazorDiagnosticDescriptor( + "BL9984", + () => "Found invalid HTML content. Text '{0}'", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_InvalidHtmlContent(SourceSpan? span, string text) + { + return RazorDiagnostic.Create(InvalidHtmlContent, span ?? SourceSpan.Undefined, text); + } + + public static readonly RazorDiagnosticDescriptor MultipleComponents = new RazorDiagnosticDescriptor( + "BL9985", + () => "Multiple components use the tag '{0}'. Components: {1}", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_MultipleComponents(SourceSpan? span, string tagName, IEnumerable components) + { + return RazorDiagnostic.Create(MultipleComponents, span ?? SourceSpan.Undefined, tagName, string.Join(", ", components.Select(c => c.DisplayName))); + } + + public static readonly RazorDiagnosticDescriptor UnsupportedComplexContent = new RazorDiagnosticDescriptor( + "BL9986", + () => "Component attributes do not support complex content (mixed C# and markup). Attribute: '{0}', text '{1}'", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_UnsupportedComplexContent(IntermediateNode node, string attributeName) + { + var content = string.Join("", node.FindDescendantNodes().Select(t => t.Content)); + return RazorDiagnostic.Create(UnsupportedComplexContent, node.Source ?? SourceSpan.Undefined, attributeName, content); + } + + public static readonly RazorDiagnosticDescriptor PageDirective_CannotBeImported = + new RazorDiagnosticDescriptor( + "BL9987", + () => ComponentResources.PageDirectiveCannotBeImported, + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreatePageDirective_CannotBeImported(SourceSpan source) + { + var fileName = Path.GetFileName(source.FilePath); + var diagnostic = RazorDiagnostic.Create(PageDirective_CannotBeImported, source, "page", fileName); + + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor PageDirective_MustSpecifyRoute = + new RazorDiagnosticDescriptor( + "BL9988", + () => "The @page directive must specify a route template. The route template must be enclosed in quotes and begin with the '/' character.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreatePageDirective_MustSpecifyRoute(SourceSpan? source) + { + var diagnostic = RazorDiagnostic.Create(PageDirective_MustSpecifyRoute, source ?? SourceSpan.Undefined); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor BindAttribute_Duplicates = + new RazorDiagnosticDescriptor( + "BL9989", + () => "The attribute '{0}' was matched by multiple bind attributes. Duplicates:{1}", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateBindAttribute_Duplicates(SourceSpan? source, string attribute, TagHelperPropertyIntermediateNode[] attributes) + { + var diagnostic = RazorDiagnostic.Create( + BindAttribute_Duplicates, + source ?? SourceSpan.Undefined, + attribute, + Environment.NewLine + string.Join(Environment.NewLine, attributes.Select(p => p.TagHelper.DisplayName))); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor EventHandler_Duplicates = + new RazorDiagnosticDescriptor( + "BL9990", + () => "The attribute '{0}' was matched by multiple event handlers attributes. Duplicates:{1}", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateEventHandler_Duplicates(SourceSpan? source, string attribute, TagHelperPropertyIntermediateNode[] attributes) + { + var diagnostic = RazorDiagnostic.Create( + EventHandler_Duplicates, + source ?? SourceSpan.Undefined, + attribute, + Environment.NewLine + string.Join(Environment.NewLine, attributes.Select(p => p.TagHelper.DisplayName))); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor BindAttribute_InvalidSyntax = + new RazorDiagnosticDescriptor( + "BL9991", + () => "The attribute names could not be inferred from bind attribute '{0}'. Bind attributes should be of the form" + + "'bind', 'bind-value' or 'bind-value-change'", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic CreateBindAttribute_InvalidSyntax(SourceSpan? source, string attribute) + { + var diagnostic = RazorDiagnostic.Create( + BindAttribute_InvalidSyntax, + source ?? SourceSpan.Undefined, + attribute); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor DisallowedScriptTag = new RazorDiagnosticDescriptor( + "BL9992", + () => "Script tags should not be placed inside components because they cannot be updated dynamically. To fix this, move the script tag to the 'index.html' file or another static location. For more information see https://go.microsoft.com/fwlink/?linkid=872131", + RazorDiagnosticSeverity.Error); + + // Reserved: BL9993 Component parameters should not be public + + public static RazorDiagnostic Create_DisallowedScriptTag(SourceSpan? source) + { + var diagnostic = RazorDiagnostic.Create(DisallowedScriptTag, source ?? SourceSpan.Undefined); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor TemplateInvalidLocation = + new RazorDiagnosticDescriptor( + "BL9994", + () => "Razor templates cannot be used in attributes.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_TemplateInvalidLocation(SourceSpan? source) + { + return RazorDiagnostic.Create(TemplateInvalidLocation, source ?? SourceSpan.Undefined); + } + + public static readonly RazorDiagnosticDescriptor ChildContentSetByAttributeAndBody = + new RazorDiagnosticDescriptor( + "BL9995", + () => "The child content property '{0}' is set by both the attribute and the element contents.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ChildContentSetByAttributeAndBody(SourceSpan? source, string attribute) + { + return RazorDiagnostic.Create(ChildContentSetByAttributeAndBody, source ?? SourceSpan.Undefined, attribute); + } + + public static readonly RazorDiagnosticDescriptor ChildContentMixedWithExplicitChildContent = + new RazorDiagnosticDescriptor( + "BL9996", + () => "Unrecognized child content inside component '{0}'. The component '{0}' accepts child content through the " + + "following top-level items: {1}.", + RazorDiagnosticSeverity.Error); + + //public static RazorDiagnostic Create_ChildContentMixedWithExplicitChildContent(SourceSpan? source, ComponentExtensionNode component) + //{ + // var supportedElements = string.Join(", ", component.Component.GetChildContentProperties().Select(p => $"'{p.Name}'")); + // return RazorDiagnostic.Create(ChildContentMixedWithExplicitChildContent, source ?? SourceSpan.Undefined, component.TagName, supportedElements); + //} + + public static readonly RazorDiagnosticDescriptor ChildContentHasInvalidAttribute = + new RazorDiagnosticDescriptor( + "BL9997", + () => "Unrecognized attribute '{0}' on child content element '{1}'.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ChildContentHasInvalidAttribute(SourceSpan? source, string attribute, string element) + { + return RazorDiagnostic.Create(ChildContentHasInvalidAttribute, source ?? SourceSpan.Undefined, attribute, element); + } + + public static readonly RazorDiagnosticDescriptor ChildContentHasInvalidParameter = + new RazorDiagnosticDescriptor( + "BL9998", + () => "Invalid parameter name. The parameter name attribute '{0}' on child content element '{1}' can only include literal text.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ChildContentHasInvalidParameter(SourceSpan? source, string attribute, string element) + { + return RazorDiagnostic.Create(ChildContentHasInvalidParameter, source ?? SourceSpan.Undefined, attribute, element); + } + + public static readonly RazorDiagnosticDescriptor ChildContentRepeatedParameterName = + new RazorDiagnosticDescriptor( + "BL9999", + () => "The child content element '{0}' of component '{1}' uses the same parameter name ('{2}') as enclosing child content " + + "element '{3}' of component '{4}'. Specify the parameter name like: '<{0} Context=\"another_name\"> to resolve the ambiguity", + RazorDiagnosticSeverity.Error); + + //public static RazorDiagnostic Create_ChildContentRepeatedParameterName( + // SourceSpan? source, + // ComponentChildContentIntermediateNode childContent1, + // ComponentExtensionNode component1, + // ComponentChildContentIntermediateNode childContent2, + // ComponentExtensionNode component2) + //{ + // Debug.Assert(childContent1.ParameterName == childContent2.ParameterName); + // Debug.Assert(childContent1.IsParameterized); + // Debug.Assert(childContent2.IsParameterized); + + // return RazorDiagnostic.Create( + // ChildContentRepeatedParameterName, + // source ?? SourceSpan.Undefined, + // childContent1.AttributeName, + // component1.TagName, + // childContent1.ParameterName, + // childContent2.AttributeName, + // component2.TagName); + //} + + public static readonly RazorDiagnosticDescriptor GenericComponentMissingTypeArgument = + new RazorDiagnosticDescriptor( + "BL10000", + () => "The component '{0}' is missing required type arguments. Specify the missing types using the attributes: {1}.", + RazorDiagnosticSeverity.Error); + + //public static RazorDiagnostic Create_GenericComponentMissingTypeArgument( + // SourceSpan? source, + // ComponentExtensionNode component, + // IEnumerable attributes) + //{ + // Debug.Assert(component.Component.IsGenericTypedComponent()); + + // var attributesText = string.Join(", ", attributes.Select(a => $"'{a.Name}'")); + // return RazorDiagnostic.Create(GenericComponentMissingTypeArgument, source ?? SourceSpan.Undefined, component.TagName, attributesText); + //} + + public static readonly RazorDiagnosticDescriptor GenericComponentTypeInferenceUnderspecified = + new RazorDiagnosticDescriptor( + "BL10001", + () => "The type of component '{0}' cannot be inferred based on the values provided. Consider specifying the type arguments " + + "directly using the following attributes: {1}.", + RazorDiagnosticSeverity.Error); + + //public static RazorDiagnostic Create_GenericComponentTypeInferenceUnderspecified( + // SourceSpan? source, + // ComponentExtensionNode component, + // IEnumerable attributes) + //{ + // Debug.Assert(component.Component.IsGenericTypedComponent()); + + // var attributesText = string.Join(", ", attributes.Select(a => $"'{a.Name}'")); + // return RazorDiagnostic.Create(GenericComponentTypeInferenceUnderspecified, source ?? SourceSpan.Undefined, component.TagName, attributesText); + //} + + public static readonly RazorDiagnosticDescriptor ChildContentHasInvalidParameterOnComponent = + new RazorDiagnosticDescriptor( + "BL10002", + () => "Invalid parameter name. The parameter name attribute '{0}' on component '{1}' can only include literal text.", + RazorDiagnosticSeverity.Error); + + //public static RazorDiagnostic Create_ChildContentHasInvalidParameterOnComponent(SourceSpan? source, string attribute, string element) + //{ + // return RazorDiagnostic.Create(ChildContentHasInvalidParameterOnComponent, source ?? SourceSpan.Undefined, attribute, element); + //} + } +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentResources.Designer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentResources.Designer.cs new file mode 100644 index 00000000000..3a7ce3183a5 --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentResources.Designer.cs @@ -0,0 +1,270 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.AspNetCore.Razor.Language { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class ComponentResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ComponentResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNetCore.Razor.Language.ComponentResources", typeof(ComponentResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Binds the provided expression to the '{0}' property and a change event delegate to the '{1}' property of the component.. + /// + internal static string BindTagHelper_Component_Documentation { + get { + return ResourceManager.GetString("BindTagHelper_Component_Documentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Binds the provided expression to the '{0}' attribute and a change event delegate to the '{1}' attribute.. + /// + internal static string BindTagHelper_Element_Documentation { + get { + return ResourceManager.GetString("BindTagHelper_Element_Documentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specifies a format to convert the value specified by the '{0}' attribute. The format string can currently only be used with expressions of type <code>DateTime</code>.. + /// + internal static string BindTagHelper_Element_Format_Documentation { + get { + return ResourceManager.GetString("BindTagHelper_Element_Format_Documentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Binds the provided expression to an attribute and a change event, based on the naming of the bind attribute. For example: <code>bind-value-onchange="..."</code> will assign the current value of the expression to the 'value' attribute, and assign a delegate that attempts to set the value to the 'onchange' attribute.. + /// + internal static string BindTagHelper_Fallback_Documentation { + get { + return ResourceManager.GetString("BindTagHelper_Fallback_Documentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specifies a format to convert the value specified by the corresponding bind attribute. For example: <code>format-value="..."</code> will apply a format string to the value specified in <code>bind-value-...</code>. The format string can currently only be used with expressions of type <code>DateTime</code>.. + /// + internal static string BindTagHelper_Fallback_Format_Documentation { + get { + return ResourceManager.GetString("BindTagHelper_Fallback_Format_Documentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specifies the parameter name for the '{0}' child content expression.. + /// + internal static string ChildContentParameterName_Documentation { + get { + return ResourceManager.GetString("ChildContentParameterName_Documentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specifies the parameter name for all child content expressions.. + /// + internal static string ChildContentParameterName_TopLevelDocumentation { + get { + return ResourceManager.GetString("ChildContentParameterName_TopLevelDocumentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specifies the type of the type parameter {0} for the {1} component.. + /// + internal static string ComponentTypeParameter_Documentation { + get { + return ResourceManager.GetString("ComponentTypeParameter_Documentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets the '{0}' attribute to the provided string or delegate value. A delegate value should be of type '{1}'.. + /// + internal static string EventHandlerTagHelper_Documentation { + get { + return ResourceManager.GetString("EventHandlerTagHelper_Documentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Declares an interface implementation for the current document.. + /// + internal static string ImplementsDirective_Description { + get { + return ResourceManager.GetString("ImplementsDirective_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The interface type implemented by the current document.. + /// + internal static string ImplementsDirective_TypeToken_Description { + get { + return ResourceManager.GetString("ImplementsDirective_TypeToken_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to TypeName. + /// + internal static string ImplementsDirective_TypeToken_Name { + get { + return ResourceManager.GetString("ImplementsDirective_TypeToken_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Declares a layout type for the current document.. + /// + internal static string LayoutDirective_Description { + get { + return ResourceManager.GetString("LayoutDirective_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The interface type implemented by the current document.. + /// + internal static string LayoutDirective_TypeToken_Description { + get { + return ResourceManager.GetString("LayoutDirective_TypeToken_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to TypeName. + /// + internal static string LayoutDirective_TypeToken_Name { + get { + return ResourceManager.GetString("LayoutDirective_TypeToken_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mark the page as a routable component.. + /// + internal static string PageDirective_Description { + get { + return ResourceManager.GetString("PageDirective_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to An optional route template for the component.. + /// + internal static string PageDirective_RouteToken_Description { + get { + return ResourceManager.GetString("PageDirective_RouteToken_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to route template. + /// + internal static string PageDirective_RouteToken_Name { + get { + return ResourceManager.GetString("PageDirective_RouteToken_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The '@{0}' directive specified in {1} file will not be imported. The directive must appear at the top of each Razor cshtml file. + /// + internal static string PageDirectiveCannotBeImported { + get { + return ResourceManager.GetString("PageDirectiveCannotBeImported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Populates the specified field or property with a reference to the element or component.. + /// + internal static string RefTagHelper_Documentation { + get { + return ResourceManager.GetString("RefTagHelper_Documentation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Declares a generic type parameter for the generated component class.. + /// + internal static string TypeParamDirective_Description { + get { + return ResourceManager.GetString("TypeParamDirective_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The name of the type parameter.. + /// + internal static string TypeParamDirective_Token_Description { + get { + return ResourceManager.GetString("TypeParamDirective_Token_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to type parameter. + /// + internal static string TypeParamDirective_Token_Name { + get { + return ResourceManager.GetString("TypeParamDirective_Token_Name", resourceCulture); + } + } + } +} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentResources.resx b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentResources.resx new file mode 100644 index 00000000000..3fe9868ecdc --- /dev/null +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentResources.resx @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Binds the provided expression to the '{0}' property and a change event delegate to the '{1}' property of the component. + + + Binds the provided expression to the '{0}' attribute and a change event delegate to the '{1}' attribute. + + + Specifies a format to convert the value specified by the '{0}' attribute. The format string can currently only be used with expressions of type <code>DateTime</code>. + + + Binds the provided expression to an attribute and a change event, based on the naming of the bind attribute. For example: <code>bind-value-onchange="..."</code> will assign the current value of the expression to the 'value' attribute, and assign a delegate that attempts to set the value to the 'onchange' attribute. + + + Specifies a format to convert the value specified by the corresponding bind attribute. For example: <code>format-value="..."</code> will apply a format string to the value specified in <code>bind-value-...</code>. The format string can currently only be used with expressions of type <code>DateTime</code>. + + + Specifies the parameter name for the '{0}' child content expression. + + + Specifies the parameter name for all child content expressions. + + + Specifies the type of the type parameter {0} for the {1} component. + + + Sets the '{0}' attribute to the provided string or delegate value. A delegate value should be of type '{1}'. + + + Declares an interface implementation for the current document. + + + The interface type implemented by the current document. + + + TypeName + + + Declares a layout type for the current document. + + + The interface type implemented by the current document. + + + TypeName + + + The '@{0}' directive specified in {1} file will not be imported. The directive must appear at the top of each Razor cshtml file + + + Mark the page as a routable component. + + + An optional route template for the component. + + + route template + + + Populates the specified field or property with a reference to the element or component. + + + Declares a generic type parameter for the generated component class. + + + The name of the type parameter. + + + type parameter + + \ No newline at end of file diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/CodeGenerationConstants.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/CodeGenerationConstants.cs index 35c176a6788..43f0cb19099 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/CodeGenerationConstants.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/CodeGenerationConstants.cs @@ -7,9 +7,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Components // Keep these in sync with the actual definitions internal static class CodeGenerationConstants { - public static class RazorComponent + public static class ComponentBase { - public const string FullTypeName = "Microsoft.AspNetCore.Components.Component"; + public const string FullTypeName = "Microsoft.AspNetCore.Components.ComponentBase"; public const string BuildRenderTree = "BuildRenderTree"; public const string BuildRenderTreeParameter = "builder"; } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentDocumentClassifierPass.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentDocumentClassifierPass.cs index 29afa982af1..2e1f24cdb52 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentDocumentClassifierPass.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentDocumentClassifierPass.cs @@ -45,7 +45,7 @@ protected override void OnDocumentStructureCreated(RazorCodeDocument codeDocumen @namespace.Content = computedNamespace; @class.ClassName = computedClass; - @class.BaseType = $"global::{CodeGenerationConstants.RazorComponent.FullTypeName}"; + @class.BaseType = $"global::{CodeGenerationConstants.ComponentBase.FullTypeName}"; var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; if (string.IsNullOrEmpty(filePath)) { @@ -63,7 +63,7 @@ protected override void OnDocumentStructureCreated(RazorCodeDocument codeDocumen @class.Modifiers.Add("public"); @class.Modifiers.Add("sealed"); - method.MethodName = CodeGenerationConstants.RazorComponent.BuildRenderTree; + method.MethodName = CodeGenerationConstants.ComponentBase.BuildRenderTree; method.ReturnType = "void"; method.Modifiers.Clear(); method.Modifiers.Add("public"); @@ -73,7 +73,7 @@ protected override void OnDocumentStructureCreated(RazorCodeDocument codeDocumen method.Parameters.Add(new MethodParameter() { TypeName = CodeGenerationConstants.RenderTreeBuilder.FullTypeName, - ParameterName = CodeGenerationConstants.RazorComponent.BuildRenderTreeParameter, + ParameterName = CodeGenerationConstants.ComponentBase.BuildRenderTreeParameter, }); // We need to call the 'base' method as the first statement. @@ -82,7 +82,7 @@ protected override void OnDocumentStructureCreated(RazorCodeDocument codeDocumen callBase.Children.Add(new IntermediateToken { Kind = TokenKind.CSharp, - Content = $"base.{CodeGenerationConstants.RazorComponent.BuildRenderTree}({CodeGenerationConstants.RazorComponent.BuildRenderTreeParameter});" + Content = $"base.{CodeGenerationConstants.ComponentBase.BuildRenderTree}({CodeGenerationConstants.ComponentBase.BuildRenderTreeParameter});" }); method.Children.Insert(0, callBase); } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Microsoft.AspNetCore.Razor.Language.csproj b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Microsoft.AspNetCore.Razor.Language.csproj index 1fd7aeebf5a..d27b1d8dd6b 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Microsoft.AspNetCore.Razor.Language.csproj +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Microsoft.AspNetCore.Razor.Language.csproj @@ -9,4 +9,19 @@ + + + True + True + ComponentResources.resx + + + + + + ResXFileCodeGenerator + ComponentResources.Designer.cs + + + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/AssertFrame.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/AssertFrame.cs new file mode 100644 index 00000000000..a03c4db92e1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/AssertFrame.cs @@ -0,0 +1,139 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Components.RenderTree; +using Xunit; + +namespace Microsoft.AspNetCore.Components +{ + internal static class AssertFrame + { + public static void Sequence(RenderTreeFrame frame, int? sequence = null) + { + if (sequence.HasValue) + { + Assert.Equal(sequence.Value, frame.Sequence); + } + } + + public static void Text(RenderTreeFrame frame, string textContent, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.Text, frame.FrameType); + Assert.Equal(textContent, frame.TextContent); + Assert.Equal(0, frame.ElementSubtreeLength); + AssertFrame.Sequence(frame, sequence); + } + + internal static void Markup(RenderTreeFrame frame, string markupContent, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.Markup, frame.FrameType); + Assert.Equal(markupContent, frame.MarkupContent); + Assert.Equal(0, frame.ElementSubtreeLength); + AssertFrame.Sequence(frame, sequence); + } + + public static void Element(RenderTreeFrame frame, string elementName, int subtreeLength, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.Element, frame.FrameType); + Assert.Equal(elementName, frame.ElementName); + Assert.Equal(subtreeLength, frame.ElementSubtreeLength); + AssertFrame.Sequence(frame, sequence); + } + + public static void Attribute(RenderTreeFrame frame, string attributeName, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.Attribute, frame.FrameType); + Assert.Equal(attributeName, frame.AttributeName); + AssertFrame.Sequence(frame, sequence); + } + + public static void Attribute(RenderTreeFrame frame, string attributeName, string attributeValue, int? sequence = null) + { + AssertFrame.Attribute(frame, attributeName, sequence); + Assert.Equal(attributeValue, frame.AttributeValue); + } + + public static void Attribute(RenderTreeFrame frame, string attributeName, Action attributeEventHandlerValue, int? sequence = null) + { + AssertFrame.Attribute(frame, attributeName, sequence); + Assert.Equal(attributeEventHandlerValue, frame.AttributeValue); + } + + public static void Attribute(RenderTreeFrame frame, string attributeName, object attributeValue, int? sequence = null) + { + AssertFrame.Attribute(frame, attributeName, sequence); + Assert.Equal(attributeValue, frame.AttributeValue); + } + + public static void Attribute(RenderTreeFrame frame, string attributeName, Type valueType, int? sequence = null) + { + AssertFrame.Attribute(frame, attributeName, sequence); + Assert.IsType(valueType, frame.AttributeValue); + } + + public static void Attribute(RenderTreeFrame frame, string attributeName, Action attributeValidator, int? sequence = null) + { + AssertFrame.Attribute(frame, attributeName, sequence); + attributeValidator(frame.AttributeValue); + } + + public static void Component(RenderTreeFrame frame, int? subtreeLength = null, int? sequence = null) where T : IComponent + { + Component(frame, typeof(T).FullName, subtreeLength, sequence); + } + + public static void Component(RenderTreeFrame frame, string typeName, int? subtreeLength = null, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.Component, frame.FrameType); + Assert.Equal(typeName, frame.ComponentType.FullName); + if (subtreeLength.HasValue) + { + Assert.Equal(subtreeLength.Value, frame.ComponentSubtreeLength); + } + AssertFrame.Sequence(frame, sequence); + } + + public static void ComponentWithInstance(RenderTreeFrame frame, int componentId, int? subtreeLength = null, int? sequence = null) where T : IComponent + { + AssertFrame.Component(frame, subtreeLength, sequence); + Assert.IsType(frame.Component); + Assert.Equal(componentId, frame.ComponentId); + } + + public static void Region(RenderTreeFrame frame, int subtreeLength, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.Region, frame.FrameType); + Assert.Equal(subtreeLength, frame.RegionSubtreeLength); + AssertFrame.Sequence(frame, sequence); + } + + public static void Whitespace(RenderTreeFrame frame, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.Text, frame.FrameType); + AssertFrame.Sequence(frame, sequence); + Assert.True(string.IsNullOrWhiteSpace(frame.TextContent)); + } + + public static void ElementReferenceCapture(RenderTreeFrame frame, Action action, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.ElementReferenceCapture, frame.FrameType); + Assert.Same(action, frame.ElementReferenceCaptureAction); + AssertFrame.Sequence(frame, sequence); + } + + public static void ComponentReferenceCapture(RenderTreeFrame frame, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.ComponentReferenceCapture, frame.FrameType); + Assert.NotNull(frame.ComponentReferenceCaptureAction); + AssertFrame.Sequence(frame, sequence); + } + + public static void ComponentReferenceCapture(RenderTreeFrame frame, Action action, int? sequence = null) + { + Assert.Equal(RenderTreeFrameType.ComponentReferenceCapture, frame.FrameType); + Assert.Same(action, frame.ComponentReferenceCaptureAction); + AssertFrame.Sequence(frame, sequence); + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Components/ComponentDocumentClassifierPassTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Components/ComponentDocumentClassifierPassTest.cs index 3b9ceb447b9..3c0746889cb 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Components/ComponentDocumentClassifierPassTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Components/ComponentDocumentClassifierPassTest.cs @@ -74,7 +74,7 @@ public void ComponentDocumentClassifierPass_SetsClass() visitor.Visit(irDocument); // Assert - Assert.Equal($"global::{CodeGenerationConstants.RazorComponent.FullTypeName}", visitor.Class.BaseType); + Assert.Equal($"global::{CodeGenerationConstants.ComponentBase.FullTypeName}", visitor.Class.BaseType); Assert.Equal(new[] { "public", "sealed" }, visitor.Class.Modifiers); Assert.Equal("Test", visitor.Class.ClassName); } @@ -149,7 +149,7 @@ public void ComponentDocumentClassifierPass_SetsUpMainMethod() visitor.Visit(irDocument); // Assert - Assert.Equal(CodeGenerationConstants.RazorComponent.BuildRenderTree, visitor.Method.MethodName); + Assert.Equal(CodeGenerationConstants.ComponentBase.BuildRenderTree, visitor.Method.MethodName); Assert.Equal("void", visitor.Method.ReturnType); Assert.Equal(new[] { "public", "override" }, visitor.Method.Modifiers); } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentBindIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentBindIntegrationTest.cs new file mode 100644 index 00000000000..5dd9849c863 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentBindIntegrationTest.cs @@ -0,0 +1,537 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Components; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentBindIntegrationTest : RazorIntegrationTestBase + { + internal override bool UseTwoPhaseCompilation => true; + + [Fact(Skip = "Not ready yet.")] + public void Render_BindToComponent_SpecifiesValue_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + int Value { get; set; } + + [Parameter] + Action ValueChanged { get; set; } + } +}")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), + frame => AssertFrame.Attribute(frame, "Value", 42, 1), + frame => AssertFrame.Attribute(frame, "ValueChanged", typeof(Action), 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindToComponent_SpecifiesValue_WithoutMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase, IComponent + { + void IComponent.SetParameters(ParameterCollection parameters) + { + } + } +}")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), + frame => AssertFrame.Attribute(frame, "Value", 42, 1), + frame => AssertFrame.Attribute(frame, "ValueChanged", typeof(Action), 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + int Value { get; set; } + + [Parameter] + Action OnChanged { get; set; } + } +}")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), + frame => AssertFrame.Attribute(frame, "Value", 42, 1), + frame => AssertFrame.Attribute(frame, "OnChanged", typeof(Action), 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase, IComponent + { + void IComponent.SetParameters(ParameterCollection parameters) + { + } + } +}")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), + frame => AssertFrame.Attribute(frame, "Value", 42, 1), + frame => AssertFrame.Attribute(frame, "OnChanged", typeof(Action), 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindToElement_WritesAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +
+@functions { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "div", 3, 0), + frame => AssertFrame.Attribute(frame, "myvalue", "hi", 1), + frame => AssertFrame.Attribute(frame, "myevent", typeof(Action), 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindToElementWithSuffix_WritesAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +
+@functions { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "div", 3, 0), + frame => AssertFrame.Attribute(frame, "myvalue", "hi", 1), + frame => AssertFrame.Attribute(frame, "myevent", typeof(Action), 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindDuplicates_ReportsDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue2"", ""myevent2"")] + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + + // Act + var result = CompileToCSharp(@" +@addTagHelper *, TestAssembly +
+@functions { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + var diagnostic = Assert.Single(result.Diagnostics); + Assert.Equal("BL9989", diagnostic.Id); + Assert.Equal( + "The attribute 'bind-value' was matched by multiple bind attributes. Duplicates:" + Environment.NewLine + + "Test.BindAttributes" + Environment.NewLine + + "Test.BindAttributes", + diagnostic.GetMessage()); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BuiltIn_BindToInputWithoutType_WritesAttributes() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "input", 3, 0), + frame => AssertFrame.Attribute(frame, "value", "42", 1), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BuiltIn_BindToInputText_WithFormat_WritesAttributes() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "input", 4, 0), + frame => AssertFrame.Attribute(frame, "type", "text", 1), + frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 1, 1).ToString("MM/dd/yyyy"), 2), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 3)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + + public string Format { get; set; } = ""MM/dd/yyyy""; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "input", 4, 0), + frame => AssertFrame.Attribute(frame, "type", "text", 1), + frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 1, 1).ToString("MM/dd/yyyy"), 2), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 3)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BuiltIn_BindToInputText_WritesAttributes() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "input", 4, 0), + frame => AssertFrame.Attribute(frame, "type", "text", 1), + frame => AssertFrame.Attribute(frame, "value", "42", 2), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 3)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BuiltIn_BindToInputCheckbox_WritesAttributes() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public bool Enabled { get; set; } +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "input", 3, 0), + frame => AssertFrame.Attribute(frame, "type", "checkbox", 1), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 3)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindToElementFallback_WritesAttributes() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "input", 4, 0), + frame => AssertFrame.Attribute(frame, "type", "text", 1), + frame => AssertFrame.Attribute(frame, "value", "42", 2), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 3)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindToElementFallback_WithFormat_WritesAttributes() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "input", 4, 0), + frame => AssertFrame.Attribute(frame, "type", "text", 1), + frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 1, 1).ToString("MM/dd"), 2), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 3)); + } + + [Fact(Skip = "Not ready yet.")] // Additional coverage of OrphanTagHelperLoweringPass + public void Render_BindToElementFallback_SpecifiesValueAndChangeEvent_WithCSharpAttribute() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "input", 5, 0), + frame => AssertFrame.Attribute(frame, "type", "text", 1), + frame => AssertFrame.Attribute(frame, "visible", 2), + frame => AssertFrame.Attribute(frame, "value", "42", 3), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 4)); + } + + [Fact(Skip = "Not ready yet.")] // See https://github.com/aspnet/Blazor/issues/703 + public void Workaround_703() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + // + // The workaround for 703 is that the value attribute MUST be after the type + // attribute. + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "input", 5, 0), + frame => AssertFrame.Attribute(frame, "type", "text", 1), + frame => AssertFrame.Attribute(frame, "visible", 2), + frame => AssertFrame.Attribute(frame, "value", "42", 3), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 4)); + } + + [Fact(Skip = "Not ready yet.")] // Additional coverage of OrphanTagHelperLoweringPass + public void Render_BindToElementFallback_SpecifiesValueAndChangeEvent_BodyContent() + { + // Arrange + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +
+ @(42.ToString()) +
+@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "div", 7, 0), + frame => AssertFrame.Attribute(frame, "value", "42", 1), + frame => AssertFrame.Attribute(frame, "onchange", typeof(Action), 2), + frame => AssertFrame.Whitespace(frame, 3), + frame => AssertFrame.Element(frame, "span", 2, 4), + frame => AssertFrame.Text(frame, "42", 5), + frame => AssertFrame.Whitespace(frame, 6)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindFallback_InvalidSyntax_TooManyParts() + { + // Arrange & Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public string Text { get; set; } = ""text""; +}"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("BL9991", diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BindFallback_InvalidSyntax_TrailingDash() + { + // Arrange & Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public string Text { get; set; } = ""text""; +}"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("BL9991", diagnostic.Id); + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentChildContentIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentChildContentIntegrationTest.cs new file mode 100644 index 00000000000..49f993bea6f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentChildContentIntegrationTest.cs @@ -0,0 +1,580 @@ +// 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.Linq; +using Microsoft.AspNetCore.Components; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentChildContentIntegrationTest : RazorIntegrationTestBase + { + private readonly CSharpSyntaxTree RenderChildContentComponent = Parse(@" +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.RenderTree; +namespace Test +{ + public class RenderChildContent : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, ChildContent); + } + + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +"); + + private readonly CSharpSyntaxTree RenderChildContentStringComponent = Parse(@" +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.RenderTree; +namespace Test +{ + public class RenderChildContentString : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, ChildContent, Value); + } + + [Parameter] + RenderFragment ChildContent { get; set; } + + [Parameter] + string Value { get; set; } + } +} +"); + + private readonly CSharpSyntaxTree RenderMultipleChildContent = Parse(@" +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.RenderTree; +namespace Test +{ + public class RenderMultipleChildContent : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, Header, Name); + builder.AddContent(1, ChildContent, Value); + builder.AddContent(2, Footer); + } + + [Parameter] + string Name { get; set; } + + [Parameter] + RenderFragment Header { get; set; } + + [Parameter] + RenderFragment ChildContent { get; set; } + + [Parameter] + RenderFragment Footer { get; set; } + + [Parameter] + string Value { get; set; } + } +} +"); + + internal override bool UseTwoPhaseCompilation => true; + + [Fact(Skip = "Not ready yet.")] + public void Render_BodyChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +
+
"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 0), + frame => AssertFrame.Attribute(frame, "ChildContent", 1), + frame => AssertFrame.Markup(frame, "\n
\n", 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BodyChildContent_Generic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +
@context.ToLowerInvariant()
+
"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderChildContentString", 3, 0), + frame => AssertFrame.Attribute(frame, "Value", "HI", 1), + frame => AssertFrame.Attribute(frame, "ChildContent", 2), + frame => AssertFrame.Whitespace(frame, 3), + frame => AssertFrame.Element(frame, "div", 2, 4), + frame => AssertFrame.Text(frame, "hi", 5), + frame => AssertFrame.Whitespace(frame, 6)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ExplicitChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + + +
+
+
"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 0), + frame => AssertFrame.Attribute(frame, "ChildContent", 1), + frame => AssertFrame.Markup(frame, "\n
\n ", 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_BodyChildContent_Recursive() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + + +
+
+
"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 0), + frame => AssertFrame.Attribute(frame, "ChildContent", 1), + frame => AssertFrame.Whitespace(frame, 2), + frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 3), + frame => AssertFrame.Attribute(frame, "ChildContent", 4), + frame => AssertFrame.Whitespace(frame, 6), + frame => AssertFrame.Markup(frame, "\n
\n ", 5)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_AttributeChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +@{ RenderFragment template = (context) => @
@context.ToLowerInvariant()
; } +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 2), + frame => AssertFrame.Attribute(frame, "ChildContent", 3), + frame => AssertFrame.Element(frame, "div", 2, 0), + frame => AssertFrame.Text(frame, "hi", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_AttributeChildContent_RenderFragmentOfString() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +@{ RenderFragment template = (context) => @
@context.ToLowerInvariant()
; } +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderChildContentString", 3, 2), + frame => AssertFrame.Attribute(frame, "ChildContent", 3), + frame => AssertFrame.Attribute(frame, "Value", "HI", 4), + frame => AssertFrame.Element(frame, "div", 2, 0), + frame => AssertFrame.Text(frame, "hi", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_AttributeChildContent_NoArgTemplate() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +@{ RenderFragment template = @
@(""HI"".ToLowerInvariant())
; } +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 2), + frame => AssertFrame.Attribute(frame, "ChildContent", 3), + frame => AssertFrame.Element(frame, "div", 2, 0), + frame => AssertFrame.Text(frame, "hi", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_AttributeChildContent_IgnoresEmptyBody() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +@{ RenderFragment template = (context) => @
@context.ToLowerInvariant()
; } +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 2), + frame => AssertFrame.Attribute(frame, "ChildContent", 3), + frame => AssertFrame.Element(frame, "div", 2, 0), + frame => AssertFrame.Text(frame, "hi", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_AttributeChildContent_IgnoresWhitespaceBody() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +@{ RenderFragment template = (context) => @
@context.ToLowerInvariant()
; } + + +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderChildContent", 2, 2), + frame => AssertFrame.Attribute(frame, "ChildContent", 3), + frame => AssertFrame.Element(frame, "div", 2, 0), + frame => AssertFrame.Text(frame, "hi", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_MultipleChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderMultipleChildContent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +@{ RenderFragment header = context => @
@context.ToLowerInvariant()
; } + + Some @context.ToLowerInvariant() Content +
Bye!
+
"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderMultipleChildContent", 6, 2), + frame => AssertFrame.Attribute(frame, "Name", "billg", 3), + frame => AssertFrame.Attribute(frame, "Header", typeof(RenderFragment), 4), + frame => AssertFrame.Attribute(frame, "Value", "HI", 5), + frame => AssertFrame.Attribute(frame, "ChildContent", typeof(RenderFragment), 6), + frame => AssertFrame.Attribute(frame, "Footer", typeof(RenderFragment), 10), + frame => AssertFrame.Element(frame, "div", 2, 0), + frame => AssertFrame.Text(frame, "billg", 1), + frame => AssertFrame.Text(frame, "Some ", 7), + frame => AssertFrame.Text(frame, "hi", 8), + frame => AssertFrame.Text(frame, " Content", 9), + frame => AssertFrame.Text(frame, "Bye!", 11)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_MultipleChildContent_ContextParameterOnComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderMultipleChildContent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +
@item.ToLowerInvariant()
+ Some @Context.ToLowerInvariant() Content +
Bye!
+
"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderMultipleChildContent", 6, 0), + frame => AssertFrame.Attribute(frame, "Name", "billg", 1), + frame => AssertFrame.Attribute(frame, "Value", "HI", 2), + frame => AssertFrame.Attribute(frame, "Header", typeof(RenderFragment), 3), + frame => AssertFrame.Attribute(frame, "ChildContent", typeof(RenderFragment), 6), + frame => AssertFrame.Attribute(frame, "Footer", typeof(RenderFragment), 10), + frame => AssertFrame.Element(frame, "div", 2, 4), + frame => AssertFrame.Text(frame, "billg", 5), + frame => AssertFrame.Text(frame, "Some ", 7), + frame => AssertFrame.Text(frame, "hi", 8), + frame => AssertFrame.Text(frame, " Content", 9), + frame => AssertFrame.Text(frame, "Bye!", 11)); + } + + // Verifies that our check for reuse of parameter names isn't too aggressive. + [Fact(Skip = "Not ready yet.")] + public void Render_MultipleChildContent_ContextParameterOnComponent_SetsSameName() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderMultipleChildContent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + +
@item.ToLowerInvariant()
+ Some @item.ToLowerInvariant() Content +
Bye!
+
"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.RenderMultipleChildContent", 6, 0), + frame => AssertFrame.Attribute(frame, "Name", "billg", 1), + frame => AssertFrame.Attribute(frame, "Value", "HI", 2), + frame => AssertFrame.Attribute(frame, "Header", typeof(RenderFragment), 3), + frame => AssertFrame.Attribute(frame, "ChildContent", typeof(RenderFragment), 6), + frame => AssertFrame.Attribute(frame, "Footer", typeof(RenderFragment), 10), + frame => AssertFrame.Element(frame, "div", 2, 4), + frame => AssertFrame.Text(frame, "billg", 5), + frame => AssertFrame.Text(frame, "Some ", 7), + frame => AssertFrame.Text(frame, "hi", 8), + frame => AssertFrame.Text(frame, " Content", 9), + frame => AssertFrame.Text(frame, "Bye!", 11)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildContent_AttributeAndBody_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +@{ RenderFragment template = @
@context.ToLowerInvariant()
; } + +Some Content +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentSetByAttributeAndBody.Id, diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildContent_AttributeAndExplicitChildContent_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +@{ RenderFragment template = @
@context.ToLowerInvariant()
; } + + +Some Content + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentSetByAttributeAndBody.Id, diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildContent_ExplicitChildContent_UnrecogizedContent_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + + +@somethingElse +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentMixedWithExplicitChildContent.Id, diagnostic.Id); + Assert.Equal( + "Unrecognized child content inside component 'RenderChildContent'. The component 'RenderChildContent' accepts " + + "child content through the following top-level items: 'ChildContent'.", + diagnostic.GetMessage()); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildContent_ExplicitChildContent_UnrecogizedElement_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + + + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentMixedWithExplicitChildContent.Id, diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildContent_ExplicitChildContent_UnrecogizedAttribute_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentHasInvalidAttribute.Id, diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildContent_ExplicitChildContent_InvalidParameterName_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentHasInvalidParameter.Id, diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildContent_ExplicitChildContent_RepeatedParameterName_GeneratesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + + + + + + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentRepeatedParameterName.Id, diagnostic.Id); + Assert.Equal( + "The child content element 'ChildContent' of component 'RenderChildContentString' uses the same parameter name ('context') as enclosing child content " + + "element 'ChildContent' of component 'RenderChildContentString'. Specify the parameter name like: ' to resolve the ambiguity", + diagnostic.GetMessage()); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildContent_ContextParameterNameOnComponent_Invalid_ProducesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(RenderChildContentStringComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.ChildContentHasInvalidParameterOnComponent.Id, diagnostic.Id); + Assert.Equal( + "Invalid parameter name. The parameter name attribute 'Context' on component 'RenderChildContentString' can only include literal text.", + diagnostic.GetMessage()); + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentCodeGenerationTestBase.cs new file mode 100644 index 00000000000..6600d6c601a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -0,0 +1,2440 @@ +// 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.Linq; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public abstract class ComponentCodeGenerationTestBase : RazorBaselineIntegrationTestBase + { + internal override bool UseTwoPhaseCompilation => true; + + protected ComponentCodeGenerationTestBase() + : base(generateBaselines: false) + { + } + + #region Basics + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_Simple() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithParameters() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SomeType + { + } + + public class MyComponent : ComponentBase + { + [Parameter] int IntProperty { get; set; } + [Parameter] bool BoolProperty { get; set; } + [Parameter] string StringProperty { get; set; } + [Parameter] SomeType ObjectProperty { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ComponentWithTypeParameters() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components; +@typeparam TItem1 +@typeparam TItem2 + +

Item1

+@foreach (var item2 in Items2) +{ +

+ @ChildContent(item2); +

+} +@functions { + [Parameter] TItem1 Item1 { get; set; } + [Parameter] List Items2 { get; set; } + [Parameter] RenderFragment ChildContent { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithExplicitStringParameter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + string StringProperty { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithNonPropertyAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ComponentParameter_TypeMismatch_ReportsDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class CoolnessMeter : ComponentBase + { + [Parameter] private int Coolness { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var assembly = CompileToAssembly(generated, throwOnFailure: false); + // This has some errors + Assert.Collection( + assembly.Diagnostics.OrderBy(d => d.Id), + d => Assert.Equal("CS1503", d.Id)); + } + + #endregion + + #region Bind + + [Fact(Skip = "Not ready yet.")] + public void BindToComponent_SpecifiesValue_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + int Value { get; set; } + + [Parameter] + Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BindToComponent_TypeChecked_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + int Value { get; set; } + + [Parameter] + Action ValueChanged { get; set; } + } +}")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public string ParentValue { get; set; } = ""42""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + + var assembly = CompileToAssembly(generated, throwOnFailure: false); + // This has some errors + Assert.Collection( + assembly.Diagnostics.OrderBy(d => d.Id), + d => Assert.Equal("CS0029", d.Id), + d => Assert.Equal("CS1503", d.Id)); + } + + [Fact(Skip = "Not ready yet.")] + public void BindToComponent_SpecifiesValue_WithoutMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase, IComponent + { + void IComponent.SetParameters(ParameterCollection parameters) + { + } + } +}")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + int Value { get; set; } + + [Parameter] + Action OnChanged { get; set; } + } +}")); + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase, IComponent + { + void IComponent.SetParameters(ParameterCollection parameters) + { + } + } +}")); + + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BindToElement_WritesAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", null, ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +
+@functions { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BindToElementWithSuffix_WritesAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + [BindElement(""div"", ""value"", ""myvalue"", ""myevent"")] + public static class BindAttributes + { + } +}")); + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +
+@functions { + public string ParentValue { get; set; } = ""hi""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BuiltIn_BindToInputWithoutType_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BuiltIn_BindToInputText_WithFormat_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + + public string Format { get; set; } = ""MM/dd/yyyy""; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BuiltIn_BindToInputText_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BuiltIn_BindToInputCheckbox_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public bool Enabled { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BindToElementFallback_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public int ParentValue { get; set; } = 42; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BindToElementFallback_WithFormat_WritesAttributes() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Child Content + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + string MyAttr { get; set; } + + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +Some textNested text"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithGenericChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + string MyAttr { get; set; } + + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +Some text@context.ToLowerInvariant()"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithGenericChildContent_SetsParameterName() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + string MyAttr { get; set; } + + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + + Some text@item.ToLowerInvariant() + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + string MyAttr { get; set; } + + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + + Some text@item.ToLowerInvariant() + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithElementOnlyChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +hello"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithExplicitChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +hello"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithExplicitGenericChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +@context"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void MultipleExplictChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + RenderFragment Header { get; set; } + + [Parameter] + RenderFragment Footer { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +
Hi!
+
@(""bye!"")
+
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BodyAndAttributeChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + RenderFragment Header { get; set; } + + RenderFragment ChildContent { get; set; } + + [Parameter] + RenderFragment Footer { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +@{ RenderFragment header = (context) => @
@context.ToLowerInvariant()
; } + + Some Content +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void BodyAndExplicitChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + RenderFragment Header { get; set; } + + [Parameter] + RenderFragment ChildContent { get; set; } + + [Parameter] + RenderFragment Footer { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +@{ RenderFragment header = (context) => @
@context.ToLowerInvariant()
; } + + Some Content +
Bye!
+
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Directives + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithPageDirective() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +@page ""/MyPage"" +@page ""/AnotherRoute/{id}"" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Event Handlers + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithLambdaEventHandler() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + Action OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + { Increment(); })""/> + +@functions { + private int counter; + private void Increment() { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + // Regression test for #954 - we need to allow arbitrary event handler + // attributes with weak typing. + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithWeaklyTypeEventHandler() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class DynamicElement : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + +@functions { + private Action OnClick { get; set; } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_WithExplicitEventHandler() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + Action OnClick { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + +@functions { + private int counter; + private void Increment(UIEventArgs e) { + counter++; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void EventHandler_OnElement_WithString() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void EventHandler_OnElement_WithNoArgsLambdaDelegate() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + { })"" />"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void EventHandler_OnElement_WithEventArgsLambdaDelegate() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + { })"" />"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void EventHandler_OnElement_WithNoArgMethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@functions { + void OnClick() { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void EventHandler_OnElement_WithEventArgsMethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@functions { + void OnClick(UIMouseEventArgs e) { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@functions { + void OnClick(UIEventArgs e) { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void AsyncEventHandler_OnElement_Action_MethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using System.Threading.Tasks + +@functions { + Task OnClick() + { + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using System.Threading.Tasks + +@functions { + Task OnClick(UIMouseEventArgs e) + { + return Task.CompletedTask; + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void AsyncEventHandler_OnElement_Action_Lambda() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using System.Threading.Tasks + await Task.Delay(10)"" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void AsyncEventHandler_OnElement_ActionEventArgs_Lambda() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using System.Threading.Tasks + await Task.Delay(10)"" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void EventHandler_OnElement_WithLambdaDelegate() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + { })"" />"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void EventHandler_OnElement_WithDelegate() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@functions { + void OnClick(UIMouseEventArgs e) { + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Generics + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_Generic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_Generic_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_Generic_TypeInference_Multiple() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_GenericWeaklyTypedAttribute() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_GenericWeaklyTypedAttribute_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_GenericBind() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + TItem Item { get; set; } + + [Parameter] + Action ItemChanged { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + string Value; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_GenericBind_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + TItem Item { get; set; } + + [Parameter] + Action ItemChanged { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + string Value; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_GenericBindWeaklyTyped() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + string Value; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_GenericBindWeaklyTyped_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Value { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + string Value; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_GenericChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Item { get; set; } + + [Parameter] RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +
@context.ToLower()
+
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_GenericChildContent_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Item { get; set; } + + [Parameter] RenderFragment ChildContent { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +
@context.ToLower()
+
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_MultipleGenerics() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem1 Item { get; set; } + + [Parameter] RenderFragment ChildContent { get; set; } + + [Parameter] RenderFragment AnotherChildContent { get; set; } + + public class Context + { + public TItem2 Item { get; set; } + } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +
@context.ToLower()
+ + @System.Math.Max(0, item.Item); + +
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ChildComponent_MultipleGenerics_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System.Collections.Generic; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem1 Item { get; set; } + + [Parameter] List Items { get; set; } + + [Parameter] RenderFragment ChildContent { get; set; } + + [Parameter] RenderFragment AnotherChildContent { get; set; } + + public class Context + { + public TItem2 Item { get; set; } + } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +())> +
@context.ToLower()
+ + @System.Math.Max(0, item.Item); + +
"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void GenericComponent_WithComponentRef() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + +@functions { + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void GenericComponent_WithComponentRef_TypeInference() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] TItem Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + +@functions { + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Ref + + [Fact(Skip = "Not ready yet.")] + public void Element_WithRef() + { + // Arrange/Act + var generated = CompileToCSharp(@" +Hello + +@functions { + private Microsoft.AspNetCore.Components.ElementRef myElem; + public void Foo() { System.GC.KeepAlive(myElem); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void Component_WithRef() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + +@functions { + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void Component_WithRef_WithChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Arrange/Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + Some further content + + +@functions { + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Templates + + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_InCodeBlock() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@{ + RenderFragment p = (person) => @
@person.Name
; +} +@functions { + class Person + { + public string Name { get; set; } + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_InExplicitExpression() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@(RenderPerson((person) => @
@person.Name
)) +@functions { + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_NonGeneric_InImplicitExpression() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@RenderPerson(@
HI
) +@functions { + object RenderPerson(RenderFragment p) => null; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_Generic_InImplicitExpression() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@RenderPerson((person) => @
@person.Name
) +@functions { + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_ContainsComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] string Name { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper ""*, TestAssembly"" +@{ + RenderFragment p = (person) => @
; +} +@functions { + class Person + { + public string Name { get; set; } + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + // Targeted at the logic that assigns 'builder' names + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_FollowedByComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] string Name { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper ""*, TestAssembly"" +@{ + RenderFragment p = (person) => @
; +} + +@(""hello, world!"") + + +@functions { + class Person + { + public string Name { get; set; } + } +}"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_NonGeneric_AsComponentParameter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] RenderFragment Template { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper ""*, TestAssembly"" +@{ RenderFragment template = @
Joey
; } + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_Generic_AsComponentParameter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] RenderFragment PersonTemplate { get; set; } + } + + public class Person + { + public string Name { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper ""*, TestAssembly"" +@{ RenderFragment template = (person) => @
@person.Name
; } + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_AsComponentParameter_MixedContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] RenderFragment Template { get; set; } + } + + public class Context + { + public int Index { get; set; } + public string Item { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper ""*, TestAssembly"" +@{ RenderFragment template = (context) => @
  • #@context.Index - @context.Item.ToLower()
  • ; } + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Whitespace + + [Fact(Skip = "Not ready yet.")] + public void LeadingWhiteSpace_WithDirective() + { + // Arrange/Act + var generated = CompileToCSharp(@" + +@using System + +

    Hello

    "); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void LeadingWhiteSpace_WithCSharpExpression() + { + // Arrange/Act + var generated = CompileToCSharp(@" + +@(""My value"") + +

    Hello

    "); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void LeadingWhiteSpace_WithComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SomeOtherComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + + +

    Hello

    "); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void TrailingWhiteSpace_WithDirective() + { + // Arrange/Act + var generated = CompileToCSharp(@" +

    Hello

    + +@page ""/my/url"" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void TrailingWhiteSpace_WithCSharpExpression() + { + // Arrange/Act + var generated = CompileToCSharp(@" +

    Hello

    + +@(""My value"") + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void TrailingWhiteSpace_WithComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SomeOtherComponent : ComponentBase + { + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +

    Hello

    + + + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + + #region Misc + + [Fact(Skip = "Not ready yet.")] // We don't process - we just skip them + public void Component_WithDocType() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +
    +
    "); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void ScriptTag_WithErrorSuppressed() + { + // Arrange/Act + var generated = CompileToCSharp(@" +
    + +
    +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] // https://github.com/aspnet/Blazor/issues/597 + public void Regression_597() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class Counter : ComponentBase + { + public int Count { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + +@functions { + string y = null; +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void Regression_609() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class User : ComponentBase + { + public string Name { get; set; } + public Action NameChanged { get; set; } + public bool IsActive { get; set; } + public Action IsActiveChanged { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly + + +@functions { + public string UserName { get; set; } + public bool UserIsActive { get; set; } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] // https://github.com/aspnet/Blazor/issues/772 + public void Regression_772() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SurveyPrompt : ComponentBase + { + [Parameter] private string Title { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +@page ""/"" + +

    Hello, world!

    + +Welcome to your new app. + + d.Id), + d => Assert.Equal("RZ1034", d.Id), + d => Assert.Equal("RZ1035", d.Id)); + } + + [Fact(Skip = "Not ready yet.")] // https://github.com/aspnet/Blazor/issues/773 + public void Regression_773() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SurveyPrompt : ComponentBase + { + [Parameter] private string Title { get; set; } + } +} +")); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +@page ""/"" + +

    Hello, world!

    + +Welcome to your new app. + +Test!
    "" /> +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void Regression_784() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +

    +@functions { + public string ParentBgColor { get; set; } = ""#FFFFFF""; + + public void OnComponentHover(UIMouseEventArgs e) + { + } +} +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + [Fact(Skip = "Not ready yet.")] + public void EventHandlerTagHelper_EscapeQuotes() + { + // Act + var generated = CompileToCSharp(@" + +"); + + // Assert + AssertDocumentNodeMatchesBaseline(generated.CodeDocument); + AssertCSharpDocumentMatchesBaseline(generated.CodeDocument); + CompileToAssembly(generated); + } + + #endregion + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDeclarationIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDeclarationIntegrationTest.cs new file mode 100644 index 00000000000..ae9ff2339e4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDeclarationIntegrationTest.cs @@ -0,0 +1,171 @@ +// 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.Reflection; +using System.Text; +using Microsoft.AspNetCore.Components; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentDeclarationRazorIntegrationTest : RazorIntegrationTestBase + { + [Fact(Skip = "Not ready yet.")] + public void DeclarationConfiguration_IncludesFunctions() + { + // Arrange & Act + var component = CompileToComponent(@" +@functions { + public string Value { get; set; } +}"); + + // Assert + var property = component.GetType().GetProperty("Value"); + Assert.NotNull(property); + Assert.Same(typeof(string), property.PropertyType); + } + + [Fact(Skip = "Not ready yet.")] + public void DeclarationConfiguration_IncludesInject() + { + // Arrange & Act + var component = CompileToComponent(@" +@inject string Value +"); + + // Assert + var property = component.GetType().GetProperty("Value", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(property); + Assert.Same(typeof(string), property.PropertyType); + } + + [Fact(Skip = "Not ready yet.")] + public void DeclarationConfiguration_IncludesUsings() + { + // Arrange & Act + var component = CompileToComponent(@" +@using System.Text +@inject StringBuilder Value +"); + + // Assert + var property = component.GetType().GetProperty("Value", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(property); + Assert.Same(typeof(StringBuilder), property.PropertyType); + } + + [Fact(Skip = "Not ready yet.")] + public void DeclarationConfiguration_IncludesInherits() + { + // Arrange & Act + var component = CompileToComponent($@" +@inherits {FullTypeName()} +"); + + // Assert + Assert.Same(typeof(BaseClass), component.GetType().BaseType); + } + + [Fact(Skip = "Not ready yet.")] + public void DeclarationConfiguration_IncludesImplements() + { + // Arrange & Act + var component = CompileToComponent($@" +@implements {FullTypeName()} +"); + + // Assert + var type = component.GetType(); + Assert.Contains(typeof(IDoCoolThings), component.GetType().GetInterfaces()); + } + + [Fact(Skip = "Not ready yet.")] + public void DeclarationConfiguration_RenderMethodIsEmpty() + { + // Arrange & Act + var component = CompileToComponent(@" + +@{ var message = ""hi""; } +@message + +"); + + var frames = GetRenderTree(component); + + // Assert + Assert.Empty(frames); + } + + [Fact(Skip = "Not ready yet.")] // Regression test for https://github.com/aspnet/Blazor/issues/453 + public void DeclarationConfiguration_FunctionsBlockHasLineMappings_MappingsApplyToError() + { + // Arrange & Act 1 + var generated = CompileToCSharp(@" +@functions { + public StringBuilder Builder { get; set; } +} +"); + + // Assert 1 + AssertSourceEquals(@" +// +#pragma warning disable 1591 +#pragma warning disable 0414 +#pragma warning disable 0649 +#pragma warning disable 0169 + +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + } + #pragma warning restore 1998 +#line 1 ""x:\dir\subdir\Test\TestComponent.cshtml"" + + public StringBuilder Builder { get; set; } + +#line default +#line hidden + } +} +#pragma warning restore 1591 +", generated); + + // Act 2 + var assembly = CompileToAssembly(generated, throwOnFailure: false); + + // Assert 2 + var diagnostic = Assert.Single(assembly.Diagnostics); + + // This error should map to line 2 of the generated file, the test + // says 1 because Roslyn's line/column data structures are 0-based. + var position = diagnostic.Location.GetMappedLineSpan(); + Assert.EndsWith(".cshtml", position.Path); + Assert.Equal(1, position.StartLinePosition.Line); + } + + public class BaseClass : IComponent + { + public void Init(RenderHandle renderHandle) + { + } + + public void SetParameters(ParameterCollection parameters) + { + } + } + + public interface IDoCoolThings + { + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDesignTimeCodeGenerationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDesignTimeCodeGenerationTest.cs new file mode 100644 index 00000000000..f86a7d8d239 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDesignTimeCodeGenerationTest.cs @@ -0,0 +1,10 @@ +// 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. + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentDesignTimeCodeGenerationTest : ComponentCodeGenerationTestBase + { + internal override bool DesignTime => true; + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs new file mode 100644 index 00000000000..a42caa042a3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs @@ -0,0 +1,65 @@ +// 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 Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentDiagnosticRazorIntegrationTest : RazorIntegrationTestBase + { + [Fact(Skip = "Not ready yet.")] + public void RejectsEndTagWithNoStartTag() + { + // Arrange/Act + var result = CompileToCSharp( + "Line1\nLine2\nLine3"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("BL9981", item.Id); + Assert.Equal("Unexpected closing tag 'mytag' with no matching start tag.", item.GetMessage()); + }); + } + + // This used to be a sugar syntax for lambdas, but we don't support that anymore + [Fact(Skip = "Not ready yet.")] + public void OldCodeBlockAttributeSyntax_ReportsError() + { + // Arrange/Act + var generated = CompileToCSharp(@" + +@functions { + public bool DidInvokeCode { get; set; } = false; +}"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("BL9979", diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void RejectsScriptTag() + { + // Arrange/Act + var result = CompileToCSharp(@"Hello +

    + +
    +Goodbye"); + + // Assert + Assert.Collection(result.Diagnostics, + item => + { + Assert.Equal("BL9992", item.Id); + Assert.Equal("Script tags should not be placed inside components because they cannot be updated dynamically. To fix this, move the script tag to the 'index.html' file or another static location. For more information see https://go.microsoft.com/fwlink/?linkid=872131", item.GetMessage()); + Assert.Equal(2, item.Span.LineIndex); + Assert.Equal(4, item.Span.CharacterIndex); + }); + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDirectiveIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDirectiveIntegrationTest.cs new file mode 100644 index 00000000000..f289635ef7e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDirectiveIntegrationTest.cs @@ -0,0 +1,150 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Reflection; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Layouts; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + // Integration tests for component directives + public class ComponentDirectiveIntegrationTest : RazorIntegrationTestBase + { + [Fact(Skip = "Not ready yet.")] + public void ComponentsDoNotHaveLayoutAttributeByDefault() + { + // Arrange/Act + var component = CompileToComponent($"Hello"); + + // Assert + Assert.Null(component.GetType().GetCustomAttribute()); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsLayoutDeclarations() + { + // Arrange/Act + var testComponentTypeName = FullTypeName(); + var component = CompileToComponent( + $"@layout {testComponentTypeName}\n" + + $"Hello"); + var frames = GetRenderTree(component); + + // Assert + var layoutAttribute = component.GetType().GetCustomAttribute(); + Assert.NotNull(layoutAttribute); + Assert.Equal(typeof(TestLayout), layoutAttribute.LayoutType); + Assert.Collection(frames, + frame => AssertFrame.Text(frame, "Hello")); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsImplementsDeclarations() + { + // Arrange/Act + var testInterfaceTypeName = FullTypeName(); + var component = CompileToComponent( + $"@implements {testInterfaceTypeName}\n" + + $"Hello"); + var frames = GetRenderTree(component); + + // Assert + Assert.IsAssignableFrom(component); + Assert.Collection(frames, + frame => AssertFrame.Text(frame, "Hello")); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsMultipleImplementsDeclarations() + { + // Arrange/Act + var testInterfaceTypeName = FullTypeName(); + var testInterfaceTypeName2 = FullTypeName(); + var component = CompileToComponent( + $"@implements {testInterfaceTypeName}\n" + + $"@implements {testInterfaceTypeName2}\n" + + $"Hello"); + var frames = GetRenderTree(component); + + // Assert + Assert.IsAssignableFrom(component); + Assert.IsAssignableFrom(component); + Assert.Collection(frames, + frame => AssertFrame.Text(frame, "Hello")); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsInheritsDirective() + { + // Arrange/Act + var testBaseClassTypeName = FullTypeName(); + var component = CompileToComponent( + $"@inherits {testBaseClassTypeName}" + Environment.NewLine + + $"Hello"); + var frames = GetRenderTree(component); + + // Assert + Assert.IsAssignableFrom(component); + Assert.Collection(frames, + frame => AssertFrame.Text(frame, "Hello")); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsInjectDirective() + { + // Arrange/Act 1: Compilation + var componentType = CompileToComponent( + $"@inject {FullTypeName()} MyService1\n" + + $"@inject {FullTypeName()} MyService2\n" + + $"Hello from @MyService1 and @MyService2").GetType(); + + // Assert 1: Compiled type has correct properties + var propertyFlags = BindingFlags.Instance | BindingFlags.NonPublic; + var injectableProperties = componentType.GetProperties(propertyFlags) + .Where(p => p.GetCustomAttribute() != null); + Assert.Collection(injectableProperties.OrderBy(p => p.Name), + property => + { + Assert.Equal("MyService1", property.Name); + Assert.Equal(typeof(IMyService1), property.PropertyType); + Assert.False(property.GetMethod.IsPublic); + Assert.False(property.SetMethod.IsPublic); + }, + property => + { + Assert.Equal("MyService2", property.Name); + Assert.Equal(typeof(IMyService2), property.PropertyType); + Assert.False(property.GetMethod.IsPublic); + Assert.False(property.SetMethod.IsPublic); + }); + } + + public class TestLayout : IComponent + { + [Parameter] + RenderFragment Body { get; set; } + + public void Init(RenderHandle renderHandle) + { + } + + public void SetParameters(ParameterCollection parameters) + { + } + } + + public interface ITestInterface { } + + public interface ITestInterface2 { } + + public class TestBaseClass : ComponentBase { } + + public interface IMyService1 { } + public interface IMyService2 { } + public class MyService1Impl : IMyService1 { } + public class MyService2Impl : IMyService2 { } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs new file mode 100644 index 00000000000..c84ebdf7786 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentDiscoveryIntegrationTest.cs @@ -0,0 +1,126 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Text; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentDiscoveryIntegrationTest : RazorIntegrationTestBase + { + internal override bool UseTwoPhaseCompilation => true; + + [Fact(Skip = "Not ready yet.")] + public void ComponentDiscovery_CanFindComponent_DefinedinCSharp() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var result = CompileToCSharp("@addTagHelper *, TestAssembly"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Single(bindings.TagHelpers, t => t.Name == "Test.MyComponent"); + } + + [Fact(Skip = "Not ready yet.")] + public void ComponentDiscovery_CanFindComponent_WithNamespace_DefinedinCSharp() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test.AnotherNamespace +{ + public class MyComponent : ComponentBase + { + } +} +")); + + // Act + var result = CompileToCSharp("@addTagHelper *, TestAssembly"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Single(bindings.TagHelpers, t => t.Name == "Test.AnotherNamespace.MyComponent"); + } + + [Fact(Skip = "Not ready yet.")] + public void ComponentDiscovery_CanFindComponent_DefinedinCshtml() + { + // Arrange + + // Act + var result = CompileToCSharp("UniqueName.cshtml", "@addTagHelper *, TestAssembly"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Single(bindings.TagHelpers, t => t.Name == "Test.UniqueName"); + } + + [Fact(Skip = "Not ready yet.")] + public void ComponentDiscovery_CanFindComponent_BuiltIn() + { + // Arrange + + // Act + var result = CompileToCSharp("@addTagHelper *, Microsoft.AspNetCore.Components"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Single(bindings.TagHelpers, t => t.Name == "Microsoft.AspNetCore.Components.Routing.NavLink"); + } + + [Fact(Skip = "Not ready yet.")] + public void ComponentDiscovery_CanFindComponent_WithTypeParameter() + { + // Arrange + + // Act + var result = CompileToCSharp("UniqueName.cshtml", @" +@addTagHelper *, TestAssembly +@typeparam TItem +@functions { + [Parameter] TItem Item { get; set; } +}"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Single(bindings.TagHelpers, t => t.Name == "Test.UniqueName"); + } + + [Fact(Skip = "Not ready yet.")] + public void ComponentDiscovery_CanFindComponent_WithMultipleTypeParameters() + { + // Arrange + + // Act + var result = CompileToCSharp("UniqueName.cshtml", @" +@addTagHelper *, TestAssembly +@typeparam TItem1 +@typeparam TItem2 +@typeparam TItem3 +@functions { + [Parameter] TItem1 Item { get; set; } +}"); + + // Assert + var bindings = result.CodeDocument.GetTagHelperContext(); + Assert.Single(bindings.TagHelpers, t => t.Name == "Test.UniqueName"); + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentFilePathIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentFilePathIntegrationTest.cs new file mode 100644 index 00000000000..ba7df85c006 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentFilePathIntegrationTest.cs @@ -0,0 +1,48 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + // Integration tests focused on file path handling for class/namespace names + public class ComponentFilePathIntegrationTest : RazorIntegrationTestBase + { + [Fact(Skip = "Not ready yet.")] + public void FileNameIsInvalidClassName_SanitizesInvalidClassName() + { + // Arrange + + // Act + var result = CompileToAssembly("Filename with spaces.cshtml", ""); + + // Assert + Assert.Empty(result.Diagnostics); + + var type = Assert.Single(result.Assembly.GetTypes()); + Assert.Equal(DefaultBaseNamespace, type.Namespace); + Assert.Equal("Filename_with_spaces", type.Name); + } + + [Theory(Skip = "Not ready yet.")] + [InlineData("ItemAtRoot.cs", "Test", "ItemAtRoot")] + [InlineData("Dir1\\MyFile.cs", "Test.Dir1", "MyFile")] + [InlineData("Dir1\\Dir2\\MyFile.cs", "Test.Dir1.Dir2", "MyFile")] + public void CreatesClassWithCorrectNameAndNamespace(string relativePath, string expectedNamespace, string expectedClassName) + { + // Arrange + relativePath = relativePath.Replace('\\', Path.DirectorySeparatorChar); + + // Act + var result = CompileToAssembly(relativePath, ""); + + // Assert + Assert.Empty(result.Diagnostics); + + var type = Assert.Single(result.Assembly.GetTypes()); + Assert.Equal(expectedNamespace, type.Namespace); + Assert.Equal(expectedClassName, type.Name); + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentGenericTypeIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentGenericTypeIntegrationTest.cs new file mode 100644 index 00000000000..fd2d30b3575 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentGenericTypeIntegrationTest.cs @@ -0,0 +1,355 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.RenderTree; +using Microsoft.CodeAnalysis.CSharp; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentGenericTypeIntegrationTest : RazorIntegrationTestBase + { + private readonly CSharpSyntaxTree GenericContextComponent = Parse(@" +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.RenderTree; +namespace Test +{ + public class GenericContext : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + var items = (IReadOnlyList)Items ?? Array.Empty(); + for (var i = 0; i < items.Count; i++) + { + if (ChildContent == null) + { + builder.AddContent(i, Items[i]); + } + else + { + builder.AddContent(i, ChildContent, new Context() { Index = i, Item = items[i], }); + } + } + } + + [Parameter] + List Items { get; set; } + + [Parameter] + RenderFragment ChildContent { get; set; } + + public class Context + { + public int Index { get; set; } + public TItem Item { get; set; } + } + } +} +"); + + private readonly CSharpSyntaxTree MultipleGenericParameterComponent = Parse(@" +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.RenderTree; +namespace Test +{ + public class MultipleGenericParameter : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, Item1); + builder.AddContent(1, Item2); + builder.AddContent(2, Item3); + } + + [Parameter] + TItem1 Item1 { get; set; } + + [Parameter] + TItem2 Item2 { get; set; } + + [Parameter] + TItem3 Item3 { get; set; } + } +} +"); + + internal override bool UseTwoPhaseCompilation => true; + + [Fact(Skip = "Not ready yet.")] + public void Render_GenericComponent_WithoutChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(GenericContextComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +() { 1, 2, })"" />"); + + // Act + var frames = GetRenderTree(component); + + // Assert + var genericComponentType = component.GetType().Assembly.DefinedTypes + .Where(t => t.Name == "GenericContext`1") + .Single() + .MakeGenericType(typeof(int)); + + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, genericComponentType.FullName, 2, 0), + frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), + frame => AssertFrame.Text(frame, "1", 0), + frame => AssertFrame.Text(frame, "2", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_GenericComponent_WithRef() + { + // Arrange + AdditionalSyntaxTrees.Add(GenericContextComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +() { 1, 2, })"" ref=""_my"" /> + +@functions { + GenericContext _my; + void Foo() { GC.KeepAlive(_my); } +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + var genericComponentType = component.GetType().Assembly.DefinedTypes + .Where(t => t.Name == "GenericContext`1") + .Single() + .MakeGenericType(typeof(int)); + + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0), + frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), + frame => AssertFrame.ComponentReferenceCapture(frame, 2), + frame => AssertFrame.Text(frame, "1", 0), + frame => AssertFrame.Text(frame, "2", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_GenericComponent_WithChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(GenericContextComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +() { 1, 2, })""> +
    @(context.Item * context.Index)
    +
    "); + + // Act + var frames = GetRenderTree(component); + + // Assert + var genericComponentType = component.GetType().Assembly.DefinedTypes + .Where(t => t.Name == "GenericContext`1") + .Single() + .MakeGenericType(typeof(int)); + + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0), + frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), + frame => AssertFrame.Attribute(frame, "ChildContent", 2), + frame => AssertFrame.Whitespace(frame, 3), + frame => AssertFrame.Element(frame, "div", 2, 4), + frame => AssertFrame.Text(frame, "0", 5), + frame => AssertFrame.Whitespace(frame, 6), + frame => AssertFrame.Whitespace(frame, 3), + frame => AssertFrame.Element(frame, "div", 2, 4), + frame => AssertFrame.Text(frame, "2", 5), + frame => AssertFrame.Whitespace(frame, 6)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_GenericComponent_TypeInference_WithRef() + { + // Arrange + AdditionalSyntaxTrees.Add(GenericContextComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +() { 1, 2, })"" ref=""_my"" /> + +@functions { + GenericContext _my; + void Foo() { GC.KeepAlive(_my); } +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + var genericComponentType = component.GetType().Assembly.DefinedTypes + .Where(t => t.Name == "GenericContext`1") + .Single() + .MakeGenericType(typeof(int)); + + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0), + frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), + frame => AssertFrame.ComponentReferenceCapture(frame, 2), + frame => AssertFrame.Text(frame, "1", 0), + frame => AssertFrame.Text(frame, "2", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_GenericComponent_TypeInference_WithRef_Recursive() + { + // Arrange + AdditionalSyntaxTrees.Add(GenericContextComponent); + + var assembly = CompileToAssembly("Test.cshtml", @" +@addTagHelper *, TestAssembly +@typeparam TItem + + +@functions { + [Parameter] List MyItems { get; set; } + GenericContext _my; + void Foo() { GC.KeepAlive(_my); } +}"); + + var componentType = assembly.Assembly.DefinedTypes + .Where(t => t.Name == "Test`1") + .Single() + .MakeGenericType(typeof(int)); + var component = (IComponent)Activator.CreateInstance(componentType); + + // Act + var frames = GetRenderTree(component); + + // Assert + var genericComponentType = assembly.Assembly.DefinedTypes + .Where(t => t.Name == "GenericContext`1") + .Single() + .MakeGenericType(typeof(int)); + + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, genericComponentType.FullName, 3, 0), + frame => AssertFrame.Attribute(frame, "Items", 1), + frame => AssertFrame.ComponentReferenceCapture(frame, 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_GenericComponent_TypeInference_WithoutChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(GenericContextComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +() { 1, 2, })"" />"); + + // Act + var frames = GetRenderTree(component); + + // Assert + var genericComponentType = component.GetType().Assembly.DefinedTypes + .Where(t => t.Name == "GenericContext`1") + .Single() + .MakeGenericType(typeof(int)); + + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, genericComponentType.FullName, 2, 0), + frame => AssertFrame.Attribute(frame, "Items", typeof(List), 1), + frame => AssertFrame.Text(frame, "1", 0), + frame => AssertFrame.Text(frame, "2", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_GenericComponent_MultipleParameters_WithChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(MultipleGenericParameterComponent); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + var genericComponentType = component.GetType().Assembly.DefinedTypes + .Where(t => t.Name == "MultipleGenericParameter`3") + .Single() + .MakeGenericType(typeof(int), typeof(string), typeof(long)); + + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, genericComponentType.FullName, 4, 0), + frame => AssertFrame.Attribute(frame, "Item1", 3, 1), + frame => AssertFrame.Attribute(frame, "Item2", "FOO", 2), + frame => AssertFrame.Attribute(frame, "Item3", 39L, 3), + frame => AssertFrame.Text(frame, "3", 0), + frame => AssertFrame.Text(frame, "FOO", 1), + frame => AssertFrame.Text(frame, "39", 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void GenericComponent_WithoutAnyTypeParameters_TriggersDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(GenericContextComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.GenericComponentTypeInferenceUnderspecified.Id, diagnostic.Id); + Assert.Equal( + "The type of component 'GenericContext' cannot be inferred based on the values provided. Consider " + + "specifying the type arguments directly using the following attributes: 'TItem'.", + diagnostic.GetMessage()); + } + + [Fact(Skip = "Not ready yet.")] + public void GenericComponent_WithMissingTypeParameters_TriggersDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(MultipleGenericParameterComponent); + + // Act + var generated = CompileToCSharp(@" +@addTagHelper *, TestAssembly +"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Same(ComponentDiagnosticFactory.GenericComponentMissingTypeArgument.Id, diagnostic.Id); + Assert.Equal( + "The component 'MultipleGenericParameter' is missing required type arguments. " + + "Specify the missing types using the attributes: 'TItem2', 'TItem3'.", + diagnostic.GetMessage()); + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentRenderingIntegrationTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentRenderingIntegrationTest.cs new file mode 100644 index 00000000000..d5bf71424c8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentRenderingIntegrationTest.cs @@ -0,0 +1,1319 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.RenderTree; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class ComponentRenderingIntegrationTest : RazorIntegrationTestBase + { + internal override bool UseTwoPhaseCompilation => true; + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildComponent_Simple() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 1, 0)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildComponent_WithParameters() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SomeType + { + } + + public class MyComponent : ComponentBase + { + [Parameter] int IntProperty { get; set; } + [Parameter] bool BoolProperty { get; set; } + [Parameter] string StringProperty { get; set; } + [Parameter] SomeType ObjectProperty { get; set; } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 5, 0), + frame => AssertFrame.Attribute(frame, "IntProperty", 123, 1), + frame => AssertFrame.Attribute(frame, "BoolProperty", true, 2), + frame => AssertFrame.Attribute(frame, "StringProperty", "My string", 3), + frame => + { + AssertFrame.Attribute(frame, "ObjectProperty", 4); + Assert.Equal("Test.SomeType", frame.AttributeValue.GetType().FullName); + }); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildComponent_TriesToSetNonParamter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + public int IntProperty { get; set; } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +"); + + // Act + var ex = Assert.Throws(() => GetRenderTree(component)); + + // Assert + Assert.Equal( + "Object of type 'Test.MyComponent' has a property matching the name 'IntProperty', " + + "but it does not have [ParameterAttribute] or [CascadingParameterAttribute] applied.", + ex.Message); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildComponent_WithExplicitStringParameter() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + string StringProperty { get; set; } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), + frame => AssertFrame.Attribute(frame, "StringProperty", "42", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildComponent_WithNonPropertyAttributes() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase, IComponent + { + void IComponent.SetParameters(ParameterCollection parameters) + { + } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), + frame => AssertFrame.Attribute(frame, "some-attribute", "foo", 1), + frame => AssertFrame.Attribute(frame, "another-attribute", "42", 2)); + } + + + [Theory(Skip = "Not ready yet.")] + [InlineData("e => Increment(e)")] + [InlineData("(e) => Increment(e)")] + [InlineData("@(e => Increment(e))")] + [InlineData("@(e => { Increment(e); })")] + [InlineData("Increment")] + [InlineData("@Increment")] + [InlineData("@(Increment)")] + public void Render_ChildComponent_WithEventHandler(string expression) + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + Action OnClick { get; set; } + } +} +")); + + var component = CompileToComponent($@" +@addTagHelper *, TestAssembly + + +@functions {{ + private int counter; + private void Increment(UIMouseEventArgs e) {{ + counter++; + }} +}}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), + frame => + { + AssertFrame.Attribute(frame, "OnClick", 1); + + // The handler will have been assigned to a lambda + var handler = Assert.IsType>(frame.AttributeValue); + Assert.Equal("Test.TestComponent", handler.Target.GetType().FullName); + }); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildComponent_WithExplicitEventHandler() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + Action OnClick { get; set; } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + + +@functions { + private int counter; + private void Increment(UIEventArgs e) { + counter++; + } +}"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), + frame => + { + AssertFrame.Attribute(frame, "OnClick", 1); + + // The handler will have been assigned to a lambda + var handler = Assert.IsType>(frame.AttributeValue); + Assert.Equal("Test.TestComponent", handler.Target.GetType().FullName); + Assert.Equal("Increment", handler.Method.Name); + }); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildComponent_WithMinimizedBoolAttribute() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + bool BoolProperty { get; set; } + } +}")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), + frame => AssertFrame.Attribute(frame, "BoolProperty", true, 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildComponent_WithChildContent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + string MyAttr { get; set; } + + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +Some textNested text @(""Hello"")"); + + // Act + var frames = GetRenderTree(component); + + // Assert: component frames are correct + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 3, 0), + frame => AssertFrame.Attribute(frame, "MyAttr", "abc", 1), + frame => AssertFrame.Attribute(frame, "ChildContent", 2)); + + // Assert: Captured ChildContent frames are correct + var childFrames = GetFrames((RenderFragment)frames[2].AttributeValue); + Assert.Collection( + childFrames, + frame => AssertFrame.Text(frame, "Some text", 3), + frame => AssertFrame.Element(frame, "some-child", 4, 4), + frame => AssertFrame.Attribute(frame, "a", "1", 5), + frame => AssertFrame.Text(frame, "Nested text ", 6), + frame => AssertFrame.Text(frame, "Hello", 7)); + } + + [Fact(Skip = "Not ready yet.")] + public void Render_ChildComponent_Nested() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +Some text"); + + // Act + var frames = GetRenderTree(component); + + // Assert: outer component frames are correct + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 0), + frame => AssertFrame.Attribute(frame, "ChildContent", 1)); + + // Assert: first level of ChildContent is correct + // Note that we don't really need the sequence numbers to continue on from the + // sequence numbers at the parent level. All that really matters is that they are + // correct relative to each other (i.e., incrementing) within the nesting level. + // As an implementation detail, it happens that they do follow on from the parent + // level, but we could change that part of the implementation if we wanted. + var innerFrames = GetFrames((RenderFragment)frames[1].AttributeValue).ToArray(); + Assert.Collection( + innerFrames, + frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 2), + frame => AssertFrame.Attribute(frame, "ChildContent", 3)); + + // Assert: second level of ChildContent is correct + Assert.Collection( + GetFrames((RenderFragment)innerFrames[1].AttributeValue), + frame => AssertFrame.Text(frame, "Some text", 4)); + } + + [Fact(Skip = "Not ready yet.")] // https://github.com/aspnet/Blazor/issues/773 + public void Regression_773() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class SurveyPrompt : ComponentBase + { + [Parameter] private string Title { get; set; } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly +@page ""/"" + +Test!
    "" /> +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.SurveyPrompt", 2, 0), + frame => AssertFrame.Attribute(frame, "Title", "
    Test!
    ", 1)); + } + + + [Fact(Skip = "Not ready yet.")] + public void Regression_784() + { + // Arrange + + // Act + var component = CompileToComponent(@" +

    +@functions { + public string ParentBgColor { get; set; } = ""#FFFFFF""; + + public void OnComponentHover(UIMouseEventArgs e) + { + } +} +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "p", 3, 0), + frame => AssertFrame.Attribute(frame, "onmouseover", 1), + frame => AssertFrame.Attribute(frame, "style", "background: #FFFFFF;", 2)); + } + + // Text nodes decode HTML entities + [Fact(Skip = "Not ready yet.")] + public void Render_Component_HtmlEncoded() + { + // Arrange + var component = CompileToComponent(@"<span>Hi</span>"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Text(frame, "Hi")); + } + + // Integration test for HTML block rewriting + [Fact(Skip = "Not ready yet.")] + public void Render_HtmlBlock_Integration() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] + RenderFragment ChildContent { get; set; } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper *, TestAssembly + + + + + +

    +
    @(""hi"")
    +
    +
    +
    @(""hi"")
    +
    +
    + +"); + + // Act + var frames = GetRenderTree(component); + + // Assert: component frames are correct + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "html", 9, 0), + frame => AssertFrame.Whitespace(frame, 1), + frame => AssertFrame.Markup(frame, "\n ", 2), + frame => AssertFrame.Element(frame, "body", 5, 3), + frame => AssertFrame.Whitespace(frame, 4), + frame => AssertFrame.Component(frame, "Test.MyComponent", 2, 5), + frame => AssertFrame.Attribute(frame, "ChildContent", 6), + frame => AssertFrame.Whitespace(frame, 16), + frame => AssertFrame.Whitespace(frame, 17)); + + // Assert: Captured ChildContent frames are correct + var childFrames = GetFrames((RenderFragment)frames[6].AttributeValue); + Assert.Collection( + childFrames, + frame => AssertFrame.Whitespace(frame, 7), + frame => AssertFrame.Markup(frame, "
    \n ", 8), + frame => AssertFrame.Element(frame, "div", 2, 9), + frame => AssertFrame.Text(frame, "hi", 10), + frame => AssertFrame.Whitespace(frame, 11), + frame => AssertFrame.Markup(frame, "
    \n
    \n ", 12), + frame => AssertFrame.Element(frame, "div", 2, 13), + frame => AssertFrame.Text(frame, "hi", 14), + frame => AssertFrame.Markup(frame, "\n
    \n ", 15)); + } + + [Fact(Skip = "Not ready yet.")] + public void RazorTemplate_CanBeUsedFromComponent() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.RenderTree; + +namespace Test +{ + public class Repeater : ComponentBase + { + [Parameter] int Count { get; set; } + [Parameter] RenderFragment Template { get; set; } + [Parameter] string Value { get; set; } + + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + for (var i = 0; i < Count; i++) + { + builder.AddContent(i, Template, Value); + } + } + } +} +")); + + var component = CompileToComponent(@" +@addTagHelper ""*, TestAssembly"" +@{ RenderFragment template = (context) => @
    @context.ToLower()
    ; } + +"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Component(frame, "Test.Repeater", 4, 2), + frame => AssertFrame.Attribute(frame, "Count", typeof(int), 3), + frame => AssertFrame.Attribute(frame, "Value", typeof(string), 4), + frame => AssertFrame.Attribute(frame, "Template", typeof(RenderFragment), 5), + frame => AssertFrame.Element(frame, "div", 2, 0), + frame => AssertFrame.Text(frame, "hello, world!", 1), + frame => AssertFrame.Element(frame, "div", 2, 0), + frame => AssertFrame.Text(frame, "hello, world!", 1), + frame => AssertFrame.Element(frame, "div", 2, 0), + frame => AssertFrame.Text(frame, "hello, world!", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsPlainText() + { + // Arrange/Act + var component = CompileToComponent("Some plain text"); + var frames = GetRenderTree(component); + + // Assert + Assert.Collection(frames, + frame => AssertFrame.Text(frame, "Some plain text", 0)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsCSharpExpressions() + { + // Arrange/Act + var component = CompileToComponent(@" + @(""Hello"") + @((object)null) + @(123) + @(new object()) + "); + + // Assert + var frames = GetRenderTree(component); + Assert.Collection(frames, + frame => AssertFrame.Text(frame, "Hello", 0), + frame => AssertFrame.Whitespace(frame, 1), + frame => AssertFrame.Whitespace(frame, 2), // @((object)null) + frame => AssertFrame.Whitespace(frame, 3), + frame => AssertFrame.Text(frame, "123", 4), + frame => AssertFrame.Whitespace(frame, 5), + frame => AssertFrame.Text(frame, new object().ToString(), 6)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsCSharpFunctionsBlock() + { + // Arrange/Act + var component = CompileToComponent(@" + @foreach(var item in items) { + @item + } + @functions { + string[] items = new[] { ""First"", ""Second"", ""Third"" }; + } + "); + + // Assert + var frames = GetRenderTree(component); + Assert.Collection(frames, + frame => AssertFrame.Text(frame, "First", 0), + frame => AssertFrame.Text(frame, "Second", 0), + frame => AssertFrame.Text(frame, "Third", 0)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsElementsWithDynamicContent() + { + // Arrange/Act + var component = CompileToComponent("Hello @(\"there\")"); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "myelem", 3, 0), + frame => AssertFrame.Text(frame, "Hello ", 1), + frame => AssertFrame.Text(frame, "there", 2)); + } + + [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + public void SupportsElementsAsStaticBlock() + { + // Arrange/Act + var component = CompileToComponent("Hello"); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Markup(frame, "Hello", 0)); + } + + [Fact(Skip = "Not ready yet.")] + public void CreatesSeparateMarkupFrameForEachTopLevelStaticElement() + { + // The JavaScript-side rendering code does not rely on this behavior. It supports + // inserting markup frames with arbitrary markup (e.g., multiple top-level elements + // or none). This test exists only as an observation of the current behavior rather + // than a promise that we never want to change it. + + // Arrange/Act + var component = CompileToComponent( + "@(\"Hi\") a b "); + + // Assert + var frames = GetRenderTree(component); + Assert.Collection( + frames, + frame => AssertFrame.Element(frame, "root", 5, 0), + frame => AssertFrame.Text(frame, "Hi", 1), + frame => AssertFrame.Text(frame, " ", 2), + frame => AssertFrame.Markup(frame, "a ", 3), + frame => AssertFrame.Markup(frame, "b ", 4)); + } + + [Fact(Skip = "Not ready yet.")] + public void RendersMarkupStringAsMarkupFrame() + { + // Arrange/Act + var component = CompileToComponent( + "@{ var someMarkup = new MarkupString(\"
    Hello
    \"); }" + + "

    @someMarkup

    "); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "p", 2, 0), + frame => AssertFrame.Markup(frame, "
    Hello
    ", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsSelfClosingElementsWithDynamicContent() + { + // Arrange/Act + var component = CompileToComponent("Some text so elem isn't at position 0 "); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Text(frame, "Some text so elem isn't at position 0 ", 0), + frame => AssertFrame.Element(frame, "myelem", 2, 1), + frame => AssertFrame.Attribute(frame, "myattr", "val", 2)); + } + + [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + public void SupportsSelfClosingElementsAsStaticBlock() + { + // Arrange/Act + var component = CompileToComponent("Some text so elem isn't at position 0 "); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Text(frame, "Some text so elem isn't at position 0 ", 0), + frame => AssertFrame.Markup(frame, "", 1)); + } + + [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + public void SupportsVoidHtmlElements() + { + // Arrange/Act + var component = CompileToComponent("Some text so elem isn't at position 0 "); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Text(frame, "Some text so elem isn't at position 0 ", 0), + frame => AssertFrame.Markup(frame, "", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsComments() + { + // Arrange/Act + var component = CompileToComponent("StartEnd"); + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Markup(frame, "StartEnd", 0)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsAttributesWithLiteralValues() + { + // Arrange/Act + var component = CompileToComponent("@(\"Hello\")"); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "elem", 4, 0), + frame => AssertFrame.Attribute(frame, "attrib-one", "Value 1", 1), + frame => AssertFrame.Attribute(frame, "a2", "v2", 2), + frame => AssertFrame.Text(frame, "Hello", 3)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsAttributesWithStringExpressionValues() + { + // Arrange/Act + var component = CompileToComponent( + "@{ var myValue = \"My string\"; }" + + ""); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "elem", 2, 0), + frame => AssertFrame.Attribute(frame, "attr", "My string", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsAttributesWithNonStringExpressionValues() + { + // Arrange/Act + var component = CompileToComponent( + "@{ var myValue = 123; }" + + ""); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "elem", 2, 0), + frame => AssertFrame.Attribute(frame, "attr", "123", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsAttributesWithInterpolatedStringExpressionValues() + { + // Arrange/Act + var component = CompileToComponent( + "@{ var myValue = \"world\"; var myNum=123; }" + + ""); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "elem", 2, 0), + frame => AssertFrame.Attribute(frame, "attr", "Hello, WORLD with number 246!", 1)); + } + + // This test exercises the case where two IntermediateTokens are part of the same expression. + // In these case they are split by a comment. + [Fact(Skip = "Not ready yet.")] + public void SupportsAttributesWithInterpolatedStringExpressionValues_SplitByComment() + { + // Arrange/Act + var component = CompileToComponent( + "@{ var myValue = \"world\"; var myNum=123; }" + + ""); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "elem", 2, 0), + frame => AssertFrame.Attribute(frame, "attr", "Hello, WORLD with number 246!", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsAttributesWithInterpolatedTernaryExpressionValues() + { + // Arrange/Act + var component = CompileToComponent( + "@{ var myValue = \"world\"; }" + + ""); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "elem", 2, 0), + frame => AssertFrame.Attribute(frame, "attr", "Hello, world!", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsHyphenedAttributesWithCSharpExpressionValues() + { + // Arrange/Act + var component = CompileToComponent( + "@{ var myValue = \"My string\"; }" + + ""); + + // Assert + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "elem", 2, 0), + frame => AssertFrame.Attribute(frame, "abc-def", "My string", 1)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsDataDashAttributes() + { + // Arrange/Act + var component = CompileToComponent(@" +@{ + var myValue = ""Expression value""; +} +"); + + // Assert + Assert.Collection( + GetRenderTree(component), + frame => AssertFrame.Element(frame, "elem", 3, 0), + frame => AssertFrame.Attribute(frame, "data-abc", "Literal value", 1), + frame => AssertFrame.Attribute(frame, "data-def", "Expression value", 2)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsAttributesWithEventHandlerValues() + { + // Arrange/Act + var component = CompileToComponent( + @" + @functions { + public bool HandlerWasCalled { get; set; } = false; + + void MyHandleEvent(Microsoft.AspNetCore.Components.UIEventArgs eventArgs) + { + HandlerWasCalled = true; + } + }"); + var handlerWasCalledProperty = component.GetType().GetProperty("HandlerWasCalled"); + + // Assert + Assert.False((bool)handlerWasCalledProperty.GetValue(component)); + Assert.Collection(GetRenderTree(component), + frame => AssertFrame.Element(frame, "elem", 2, 0), + frame => + { + Assert.Equal(RenderTreeFrameType.Attribute, frame.FrameType); + Assert.Equal(1, frame.Sequence); + Assert.NotNull(frame.AttributeValue); + + ((Action)frame.AttributeValue)(null); + Assert.True((bool)handlerWasCalledProperty.GetValue(component)); + }); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsUsingStatements() + { + // Arrange/Act + var component = CompileToComponent( + @"@using System.Collections.Generic + @(typeof(List).FullName)"); + var frames = GetRenderTree(component); + + // Assert + Assert.Collection(frames, + frame => AssertFrame.Text(frame, typeof(List).FullName, 0)); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsTwoWayBindingForTextboxes() + { + // Arrange/Act + var component = CompileToComponent( + @" + @functions { + public string MyValue { get; set; } = ""Initial value""; + }"); + var myValueProperty = component.GetType().GetProperty("MyValue"); + + // Assert + var frames = GetRenderTree(component); + Assert.Collection(frames, + frame => AssertFrame.Element(frame, "input", 3, 0), + frame => AssertFrame.Attribute(frame, "value", "Initial value", 1), + frame => + { + AssertFrame.Attribute(frame, "onchange", 2); + + // Trigger the change event to show it updates the property + ((Action)frame.AttributeValue)(new UIChangeEventArgs + { + Value = "Modified value" + }); + Assert.Equal("Modified value", myValueProperty.GetValue(component)); + }); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsTwoWayBindingForTextareas() + { + // Arrange/Act + var component = CompileToComponent( + @" + @functions { + public string MyValue { get; set; } = ""Initial value""; + }"); + var myValueProperty = component.GetType().GetProperty("MyValue"); + + // Assert + var frames = GetRenderTree(component); + Assert.Collection(frames, + frame => AssertFrame.Element(frame, "textarea", 3, 0), + frame => AssertFrame.Attribute(frame, "value", "Initial value", 1), + frame => + { + AssertFrame.Attribute(frame, "onchange", 2); + + // Trigger the change event to show it updates the property + ((Action)frame.AttributeValue)(new UIChangeEventArgs + { + Value = "Modified value" + }); + Assert.Equal("Modified value", myValueProperty.GetValue(component)); + }); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsTwoWayBindingForDateValues() + { + // Arrange/Act + var component = CompileToComponent( + @" + @functions { + public DateTime MyDate { get; set; } = new DateTime(2018, 3, 4, 1, 2, 3); + }"); + var myDateProperty = component.GetType().GetProperty("MyDate"); + + // Assert + var frames = GetRenderTree(component); + Assert.Collection(frames, + frame => AssertFrame.Element(frame, "input", 3, 0), + frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 3, 4, 1, 2, 3).ToString(), 1), + frame => + { + AssertFrame.Attribute(frame, "onchange", 2); + + // Trigger the change event to show it updates the property + var newDateValue = new DateTime(2018, 3, 5, 4, 5, 6); + ((Action)frame.AttributeValue)(new UIChangeEventArgs + { + Value = newDateValue.ToString() + }); + Assert.Equal(newDateValue, myDateProperty.GetValue(component)); + }); + } + + [Fact(Skip = "Not ready yet.")] + public void SupportsTwoWayBindingForDateValuesWithFormatString() + { + // Arrange/Act + var testDateFormat = "ddd yyyy-MM-dd"; + var component = CompileToComponent( + $@" + @functions {{ + public DateTime MyDate {{ get; set; }} = new DateTime(2018, 3, 4); + }}"); + var myDateProperty = component.GetType().GetProperty("MyDate"); + + // Assert + var frames = GetRenderTree(component); + Assert.Collection(frames, + frame => AssertFrame.Element(frame, "input", 3, 0), + frame => AssertFrame.Attribute(frame, "value", new DateTime(2018, 3, 4).ToString(testDateFormat), 1), + frame => + { + AssertFrame.Attribute(frame, "onchange", 2); + + // Trigger the change event to show it updates the property + ((Action)frame.AttributeValue)(new UIChangeEventArgs + { + Value = new DateTime(2018, 3, 5).ToString(testDateFormat) + }); + Assert.Equal(new DateTime(2018, 3, 5), myDateProperty.GetValue(component)); + }); + } + + [Fact(Skip = "Not ready yet.")] // In this case, onclick is just a normal HTML attribute + public void SupportsEventHandlerWithString() + { + // Arrange + var component = CompileToComponent(@" +
    "" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("RZ1005", diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void Template_ExplicitExpressionInComponentAttribute_CreatesDiagnostic() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + } +} +")); + // Act + var generated = CompileToCSharp(@"
    )"" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("BL9994", diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void Template_ExplicitExpressionInRef_CreatesDiagnostic() + { + // Arrange + + // Act + var generated = CompileToCSharp(@"
    )"" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("BL9994", diagnostic.Id); + } + + + [Fact(Skip = "Not ready yet.")] + public void Template_ExplicitExpressionInBind_CreatesDiagnostic() + { + // Arrange + + // Act + var generated = CompileToCSharp(@"
    )"" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("BL9994", diagnostic.Id); + } + + [Fact(Skip = "Not ready yet.")] + public void Template_ExplicitExpressionInEventHandler_CreatesDiagnostic() + { + // Arrange + + // Act + var generated = CompileToCSharp(@")"" />"); + + // Assert + var diagnostic = Assert.Single(generated.Diagnostics); + Assert.Equal("BL9994", diagnostic.Id); + } + } +} \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentTypingTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentTypingTest.cs new file mode 100644 index 00000000000..af28dd09a84 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentTypingTest.cs @@ -0,0 +1,94 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using Xunit; +using Xunit.Sdk; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + // Similar to design time code generation tests, but goes a character at a time. + // Don't add many of these since they are slow - instead add features to existing + // tests here, and use these as smoke tests, not for detailed regression testing. + public class ComponentTypingTest : RazorIntegrationTestBase + { + internal override bool DesignTime => true; + + internal override bool UseTwoPhaseCompilation => false; + + [Fact(Skip = "Not ready yet.")] + public void DoSomeTyping() + { + // Arrange + AdditionalSyntaxTrees.Add(Parse(@" +using System; +using Microsoft.AspNetCore.Components; + +namespace Test +{ + public class MyComponent : ComponentBase + { + [Parameter] int Value { get; set; } + [Parameter] Action ValueChanged { get; set; } + [Parameter] string AnotherValue { get; set; } + } + + public class ModelState + { + public Action Bind(Func func) => throw null; + } +} +")); + var text = @" +@addTagHelper *, TestAssembly +
    + + x)"" /> + +
    + +@functions { + Test.ModelState ModelState { get; set; } +}"; + + for (var i = 0; i <= text.Length; i++) + { + try + { + CompileToCSharp(text.Substring(0, i)); + } + catch (Exception ex) + { + throw new XunitException($@" +Code generation failed on iteration {i} with source text: +{text.Substring(0, i)} + +Exception: +{ex} +"); + } + } + } + + [Fact(Skip = "Not ready yet.")] // Regression test for #1068 + public void Regression_1068() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" + +@functions { + Test.ModelState ModelState { get; set; } +} +"); + + // Assert + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorBaselineIntegrationTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorBaselineIntegrationTestBase.cs new file mode 100644 index 00000000000..3b4b3223230 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorBaselineIntegrationTestBase.cs @@ -0,0 +1,209 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Linq; +using System.Threading; +using Xunit; +using Xunit.Sdk; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + [IntializeTestFile] + public abstract class RazorBaselineIntegrationTestBase : RazorIntegrationTestBase + { + private static readonly AsyncLocal _directoryPath = new AsyncLocal(); + + protected RazorBaselineIntegrationTestBase(bool? generateBaselines = null) + { + TestProjectRoot = TestProject.GetProjectDirectory(GetType()); + + if (generateBaselines.HasValue) + { + GenerateBaselines = generateBaselines.Value; + } + } + + // Used by the test framework to set the directory for test files. + public static string DirectoryPath + { + get { return _directoryPath.Value; } + set { _directoryPath.Value = value; } + } + +#if GENERATE_BASELINES + protected bool GenerateBaselines { get; } = true; +#else + protected bool GenerateBaselines { get; } = false; +#endif + + protected string TestProjectRoot { get; } + + // For consistent line endings because the character counts are going to be recorded in files. + internal override string LineEnding => "\r\n"; + + internal override bool NormalizeSourceLineEndings => true; + + internal override string PathSeparator => "\\"; + + // Force consistent paths since they are going to be recorded in files. + internal override string WorkingDirectory => ArbitraryWindowsPath; + + [Fact] + public void GenerateBaselinesMustBeFalse() + { + Assert.False(GenerateBaselines, "GenerateBaselines should be set back to false before you check in!"); + } + + protected void AssertDocumentNodeMatchesBaseline(RazorCodeDocument codeDocument) + { + var document = codeDocument.GetDocumentIntermediateNode(); + var baselineFilePath = GetBaselineFilePath(codeDocument, ".ir.txt"); + + if (GenerateBaselines) + { + var baselineFullPath = Path.Combine(TestProjectRoot, baselineFilePath); + Directory.CreateDirectory(Path.GetDirectoryName(baselineFullPath)); + WriteBaseline(IntermediateNodeSerializer.Serialize(document), baselineFullPath); + + return; + } + + var irFile = TestFile.Create(baselineFilePath, GetType().Assembly); + if (!irFile.Exists()) + { + throw new XunitException($"The resource {baselineFilePath} was not found."); + } + + // Normalize newlines by splitting into an array. + var baseline = irFile.ReadAllText().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + IntermediateNodeVerifier.Verify(document, baseline); + } + + protected void AssertCSharpDocumentMatchesBaseline(RazorCodeDocument codeDocument) + { + var document = codeDocument.GetCSharpDocument(); + + // Normalize newlines to match those in the baseline. + var actualCode = document.GeneratedCode.Replace("\r", "").Replace("\n", "\r\n"); + + var baselineFilePath = GetBaselineFilePath(codeDocument, ".codegen.cs"); + var baselineDiagnosticsFilePath = GetBaselineFilePath(codeDocument, ".diagnostics.txt"); + var baselineMappingsFilePath = GetBaselineFilePath(codeDocument, ".mappings.txt"); + + var serializedMappings = SourceMappingsSerializer.Serialize(document, codeDocument.Source); + + if (GenerateBaselines) + { + var baselineFullPath = Path.Combine(TestProjectRoot, baselineFilePath); + Directory.CreateDirectory(Path.GetDirectoryName(baselineFullPath)); + WriteBaseline(actualCode, baselineFullPath); + + var baselineDiagnosticsFullPath = Path.Combine(TestProjectRoot, baselineDiagnosticsFilePath); + var lines = document.Diagnostics.Select(RazorDiagnosticSerializer.Serialize).ToArray(); + if (lines.Any()) + { + WriteBaseline(lines, baselineDiagnosticsFullPath); + } + else if (File.Exists(baselineDiagnosticsFullPath)) + { + File.Delete(baselineDiagnosticsFullPath); + } + + var baselineMappingsFullPath = Path.Combine(TestProjectRoot, baselineMappingsFilePath); + var text = SourceMappingsSerializer.Serialize(document, codeDocument.Source); + if (!string.IsNullOrEmpty(text)) + { + WriteBaseline(text, baselineMappingsFullPath); + } + else if (File.Exists(baselineMappingsFullPath)) + { + File.Delete(baselineMappingsFullPath); + } + + return; + } + + var codegenFile = TestFile.Create(baselineFilePath, GetType().Assembly); + if (!codegenFile.Exists()) + { + throw new XunitException($"The resource {baselineFilePath} was not found."); + } + + var baseline = codegenFile.ReadAllText(); + Assert.Equal(baseline, actualCode); + + var baselineDiagnostics = string.Empty; + var diagnosticsFile = TestFile.Create(baselineDiagnosticsFilePath, GetType().Assembly); + if (diagnosticsFile.Exists()) + { + baselineDiagnostics = diagnosticsFile.ReadAllText(); + } + + var actualDiagnostics = string.Concat(document.Diagnostics.Select(d => RazorDiagnosticSerializer.Serialize(d) + "\r\n")); + Assert.Equal(baselineDiagnostics, actualDiagnostics); + + var baselineMappings = string.Empty; + var mappingsFile = TestFile.Create(baselineMappingsFilePath, GetType().Assembly); + if (mappingsFile.Exists()) + { + baselineMappings = mappingsFile.ReadAllText(); + } + + var actualMappings = SourceMappingsSerializer.Serialize(document, codeDocument.Source); + actualMappings = actualMappings.Replace("\r", "").Replace("\n", "\r\n"); + Assert.Equal(baselineMappings, actualMappings); + } + + private string GetBaselineFilePath(RazorCodeDocument codeDocument, string extension) + { + if (codeDocument == null) + { + throw new ArgumentNullException(nameof(codeDocument)); + } + + if (extension == null) + { + throw new ArgumentNullException(nameof(extension)); + } + + var lastSlash = codeDocument.Source.FilePath.LastIndexOfAny(new []{ '/', '\\' }); + var fileName = lastSlash == -1 ? null : codeDocument.Source.FilePath.Substring(lastSlash + 1); + if (string.IsNullOrEmpty(fileName)) + { + var message = "Integration tests require a filename"; + throw new InvalidOperationException(message); + } + + if (DirectoryPath == null) + { + var message = $"{nameof(AssertDocumentNodeMatchesBaseline)} should only be called from an integration test.."; + throw new InvalidOperationException(message); + } + + return Path.Combine(DirectoryPath, Path.ChangeExtension(fileName, extension)); + } + + private static void WriteBaseline(string text, string filePath) + { + var lines = text.Replace("\r", "").Replace("\n", "\r\n"); + File.WriteAllText(filePath, text); + } + + private static void WriteBaseline(string[] lines, string filePath) + { + using (var writer = new StreamWriter(File.Open(filePath, FileMode.Create))) + { + // Force windows-style line endings so that we're consistent. This isn't + // required for correctness, but will prevent churn when developing on OSX. + writer.NewLine = "\r\n"; + + for (var i = 0; i < lines.Length; i++) + { + writer.WriteLine(lines[i]); + } + } + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorIntegrationTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorIntegrationTestBase.cs new file mode 100644 index 00000000000..431db5881d6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorIntegrationTestBase.cs @@ -0,0 +1,428 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.RenderTree; +using Microsoft.AspNetCore.Razor.Language.CodeGeneration; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Razor; +using Xunit; +using Xunit.Sdk; + +namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +{ + public class RazorIntegrationTestBase + { + internal const string ArbitraryWindowsPath = "x:\\dir\\subdir\\Test"; + internal const string ArbitraryMacLinuxPath = "/dir/subdir/Test"; + + // Creating the initial compilation + reading references is on the order of 250ms without caching + // so making sure it doesn't happen for each test. + private static readonly CSharpCompilation BaseCompilation; + + private static CSharpParseOptions CSharpParseOptions { get; } + + static RazorIntegrationTestBase() + { + var referenceAssemblyRoots = new[] + { + typeof(System.Runtime.AssemblyTargetedPatchBandAttribute).Assembly, // System.Runtime + typeof(ComponentBase).Assembly, + typeof(RazorIntegrationTestBase).Assembly, // Reference this assembly, so that we can refer to test component types + }; + + var referenceAssemblies = referenceAssemblyRoots + .SelectMany(assembly => assembly.GetReferencedAssemblies().Concat(new[] { assembly.GetName() })) + .Distinct() + .Select(Assembly.Load) + .Select(assembly => MetadataReference.CreateFromFile(assembly.Location)) + .ToList(); + BaseCompilation = CSharpCompilation.Create( + "TestAssembly", + Array.Empty(), + referenceAssemblies, + new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); + + CSharpParseOptions = new CSharpParseOptions(LanguageVersion.CSharp7_3); + } + + public RazorIntegrationTestBase() + { + AdditionalSyntaxTrees = new List(); + AdditionalRazorItems = new List(); + + + Configuration = RazorConfiguration.Default; + FileSystem = new VirtualRazorProjectFileSystem(); + PathSeparator = Path.DirectorySeparatorChar.ToString(); + WorkingDirectory = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ArbitraryWindowsPath : ArbitraryMacLinuxPath; + + DefaultBaseNamespace = "Test"; // Matches the default working directory + DefaultFileName = "TestComponent.cshtml"; + } + + internal List AdditionalRazorItems { get; } + + internal List AdditionalSyntaxTrees { get; } + + internal virtual RazorConfiguration Configuration { get; } + + internal virtual string DefaultBaseNamespace { get; } + + internal virtual string DefaultFileName { get; } + + internal virtual bool DesignTime { get; } + + internal virtual VirtualRazorProjectFileSystem FileSystem { get; } + + // Used to force a specific style of line-endings for testing. This matters + // for the baseline tests that exercise line mappings. Even though we normalize + // newlines for testing, the difference between platforms affects the data through + // the *count* of characters written. + internal virtual string LineEnding { get; } + + internal virtual string PathSeparator { get; } + + internal virtual bool NormalizeSourceLineEndings { get; } + + internal virtual bool UseTwoPhaseCompilation { get; } + + internal virtual string WorkingDirectory { get; } + + internal RazorProjectEngine CreateProjectEngine(RazorConfiguration configuration, MetadataReference[] references) + { + return RazorProjectEngine.Create(configuration, FileSystem, b => + { + // Turn off checksums, we're testing code generation. + b.Features.Add(new SuppressChecksum()); + + if (LineEnding != null) + { + b.Phases.Insert(0, new ForceLineEndingPhase(LineEnding)); + } + + b.Features.Add(new CompilationTagHelperFeature()); + b.Features.Add(new DefaultMetadataReferenceFeature() + { + References = references, + }); + }); + } + + internal RazorProjectItem CreateProjectItem(string cshtmlRelativePath, string cshtmlContent) + { + var fullPath = WorkingDirectory + PathSeparator + cshtmlRelativePath; + + // FilePaths in Razor are **always** are of the form '/a/b/c.cshtml' + var filePath = cshtmlRelativePath.Replace('\\', '/'); + if (!filePath.StartsWith("/")) + { + filePath = '/' + filePath; + } + + if (NormalizeSourceLineEndings) + { + cshtmlContent = cshtmlContent.Replace("\r", "").Replace("\n", LineEnding); + } + + return new TestRazorProjectItem( + filePath: filePath, + physicalPath: fullPath, + relativePhysicalPath: cshtmlRelativePath, + basePath: WorkingDirectory) + { + Content = cshtmlContent.TrimStart(), + }; + } + + protected CompileToCSharpResult CompileToCSharp(string cshtmlContent) + { + return CompileToCSharp(DefaultFileName, cshtmlContent); + } + + protected CompileToCSharpResult CompileToCSharp(string cshtmlRelativePath, string cshtmlContent) + { + if (UseTwoPhaseCompilation) + { + // The first phase won't include any metadata references for component discovery. This mirrors + // what the build does. + var projectEngine = CreateProjectEngine(RazorConfiguration.Default, Array.Empty()); + + RazorCodeDocument codeDocument; + foreach (var item in AdditionalRazorItems) + { + // Result of generating declarations + codeDocument = projectEngine.Process(item); + Assert.Empty(codeDocument.GetCSharpDocument().Diagnostics); + + var syntaxTree = Parse(codeDocument.GetCSharpDocument().GeneratedCode, path: item.FilePath); + AdditionalSyntaxTrees.Add(syntaxTree); + } + + // Result of generating declarations + var projectItem = CreateProjectItem(cshtmlRelativePath, cshtmlContent); + codeDocument = projectEngine.Process(projectItem); + var declaration = new CompileToCSharpResult + { + BaseCompilation = BaseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), + CodeDocument = codeDocument, + Code = codeDocument.GetCSharpDocument().GeneratedCode, + Diagnostics = codeDocument.GetCSharpDocument().Diagnostics, + }; + + // Result of doing 'temp' compilation + var tempAssembly = CompileToAssembly(declaration); + + // Add the 'temp' compilation as a metadata reference + var references = BaseCompilation.References.Concat(new[] { tempAssembly.Compilation.ToMetadataReference() }).ToArray(); + projectEngine = CreateProjectEngine(RazorConfiguration.Default, references); + + // Now update the any additional files + foreach (var item in AdditionalRazorItems) + { + // Result of generating declarations + codeDocument = projectEngine.Process(item); + Assert.Empty(codeDocument.GetCSharpDocument().Diagnostics); + + // Replace the 'declaration' syntax tree + var syntaxTree = Parse(codeDocument.GetCSharpDocument().GeneratedCode, path: item.FilePath); + AdditionalSyntaxTrees.RemoveAll(st => st.FilePath == item.FilePath); + AdditionalSyntaxTrees.Add(syntaxTree); + } + + // Result of real code generation for the document under test + codeDocument = DesignTime ? projectEngine.ProcessDesignTime(projectItem) : projectEngine.Process(projectItem); + return new CompileToCSharpResult + { + BaseCompilation = BaseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), + CodeDocument = codeDocument, + Code = codeDocument.GetCSharpDocument().GeneratedCode, + Diagnostics = codeDocument.GetCSharpDocument().Diagnostics, + }; + } + else + { + // For single phase compilation tests just use the base compilation's references. + // This will include the built-in Blazor components. + var projectEngine = CreateProjectEngine(Configuration, BaseCompilation.References.ToArray()); + + var projectItem = CreateProjectItem(cshtmlRelativePath, cshtmlContent); + var codeDocument = DesignTime ? projectEngine.ProcessDesignTime(projectItem) : projectEngine.Process(projectItem); + return new CompileToCSharpResult + { + BaseCompilation = BaseCompilation.AddSyntaxTrees(AdditionalSyntaxTrees), + CodeDocument = codeDocument, + Code = codeDocument.GetCSharpDocument().GeneratedCode, + Diagnostics = codeDocument.GetCSharpDocument().Diagnostics, + }; + } + } + + protected CompileToAssemblyResult CompileToAssembly(string cshtmlRelativePath, string cshtmlContent) + { + var cSharpResult = CompileToCSharp(cshtmlRelativePath, cshtmlContent); + return CompileToAssembly(cSharpResult); + } + + protected CompileToAssemblyResult CompileToAssembly(CompileToCSharpResult cSharpResult, bool throwOnFailure = true) + { + if (cSharpResult.Diagnostics.Any()) + { + var diagnosticsLog = string.Join(Environment.NewLine, cSharpResult.Diagnostics.Select(d => d.ToString()).ToArray()); + throw new InvalidOperationException($"Aborting compilation to assembly because RazorCompiler returned nonempty diagnostics: {diagnosticsLog}"); + } + + var syntaxTrees = new[] + { + Parse(cSharpResult.Code), + }; + + var compilation = cSharpResult.BaseCompilation.AddSyntaxTrees(syntaxTrees); + + var diagnostics = compilation + .GetDiagnostics() + .Where(d => d.Severity != DiagnosticSeverity.Hidden); + + if (diagnostics.Any() && throwOnFailure) + { + throw new CompilationFailedException(compilation); + } + else if (diagnostics.Any()) + { + return new CompileToAssemblyResult + { + Compilation = compilation, + Diagnostics = diagnostics, + }; + } + + using (var peStream = new MemoryStream()) + { + compilation.Emit(peStream); + + return new CompileToAssemblyResult + { + Compilation = compilation, + Diagnostics = diagnostics, + Assembly = diagnostics.Any() ? null : Assembly.Load(peStream.ToArray()) + }; + } + } + + protected IComponent CompileToComponent(string cshtmlSource) + { + var assemblyResult = CompileToAssembly(DefaultFileName, cshtmlSource); + + var componentFullTypeName = $"{DefaultBaseNamespace}.{Path.GetFileNameWithoutExtension(DefaultFileName)}"; + return CompileToComponent(assemblyResult, componentFullTypeName); + } + + protected IComponent CompileToComponent(CompileToCSharpResult cSharpResult, string fullTypeName) + { + return CompileToComponent(CompileToAssembly(cSharpResult), fullTypeName); + } + + protected IComponent CompileToComponent(CompileToAssemblyResult assemblyResult, string fullTypeName) + { + var componentType = assemblyResult.Assembly.GetType(fullTypeName); + if (componentType == null) + { + throw new XunitException( + $"Failed to find component type '{fullTypeName}'. Found types:" + Environment.NewLine + + string.Join(Environment.NewLine, assemblyResult.Assembly.ExportedTypes.Select(t => t.FullName))); + } + + return (IComponent)Activator.CreateInstance(componentType); + } + + protected static CSharpSyntaxTree Parse(string text, string path = null) + { + return (CSharpSyntaxTree)CSharpSyntaxTree.ParseText(text, CSharpParseOptions, path: path); + } + + protected static string FullTypeName() => typeof(T).FullName.Replace('+', '.'); + + protected RenderTreeFrame[] GetRenderTree(IComponent component) + { + throw null; + } + + protected RenderTreeFrame[] GetFrames(RenderFragment fragment) + { + throw null; + } + + protected static void AssertSourceEquals(string expected, CompileToCSharpResult generated) + { + // Normalize the paths inside the expected result to match the OS paths + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + var windowsPath = Path.Combine(ArbitraryWindowsPath, generated.CodeDocument.Source.RelativePath).Replace('/', '\\'); + expected = expected.Replace(windowsPath, generated.CodeDocument.Source.FilePath); + } + + expected = expected.Trim(); + Assert.Equal(expected, generated.Code.Trim(), ignoreLineEndingDifferences: true); + } + + protected class CompileToCSharpResult + { + // A compilation that can be used *with* this code to compile an assembly + public Compilation BaseCompilation { get; set; } + public RazorCodeDocument CodeDocument { get; set; } + public string Code { get; set; } + public IEnumerable Diagnostics { get; set; } + } + + protected class CompileToAssemblyResult + { + public Assembly Assembly { get; set; } + public Compilation Compilation { get; set; } + public string VerboseLog { get; set; } + public IEnumerable Diagnostics { get; set; } + } + + private class CompilationFailedException : XunitException + { + public CompilationFailedException(Compilation compilation) + { + Compilation = compilation; + } + + public Compilation Compilation { get; } + + public override string Message + { + get + { + var builder = new StringBuilder(); + builder.AppendLine("Compilation failed: "); + + var diagnostics = Compilation.GetDiagnostics(); + var syntaxTreesWithErrors = new HashSet(); + foreach (var diagnostic in diagnostics) + { + builder.AppendLine(diagnostic.ToString()); + + if (diagnostic.Location.IsInSource) + { + syntaxTreesWithErrors.Add(diagnostic.Location.SourceTree); + } + } + + if (syntaxTreesWithErrors.Any()) + { + builder.AppendLine(); + builder.AppendLine(); + + foreach (var syntaxTree in syntaxTreesWithErrors) + { + builder.AppendLine($"File {syntaxTree.FilePath ?? "unknown"}:"); + builder.AppendLine(syntaxTree.GetText().ToString()); + } + } + + return builder.ToString(); + } + } + } + + private class SuppressChecksum : IConfigureRazorCodeGenerationOptionsFeature + { + public int Order => 0; + + public RazorEngine Engine { get; set; } + + public void Configure(RazorCodeGenerationOptionsBuilder options) + { + options.SuppressChecksum = true; + } + } + + private class ForceLineEndingPhase : RazorEnginePhaseBase + { + public ForceLineEndingPhase(string lineEnding) + { + LineEnding = lineEnding; + } + + public string LineEnding { get; } + + protected override void ExecuteCore(RazorCodeDocument codeDocument) + { + var field = typeof(CodeRenderingContext).GetField("NewLineString", BindingFlags.Static | BindingFlags.NonPublic); + var key = field.GetValue(null); + codeDocument.Items[key] = LineEnding; + } + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj index 00c537d5f0e..4430c2e13b6 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/Microsoft.AspNetCore.Razor.Language.Test.csproj @@ -14,6 +14,7 @@ + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RenderTreeFrame.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RenderTreeFrame.cs new file mode 100644 index 00000000000..4441c06c9b7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RenderTreeFrame.cs @@ -0,0 +1,344 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace Microsoft.AspNetCore.Components.RenderTree +{ + /// + /// Represents an entry in a tree of user interface (UI) items. + /// + [StructLayout(LayoutKind.Explicit)] + public readonly struct RenderTreeFrame + { + // Note that the struct layout has to be valid in both 32-bit and 64-bit runtime platforms, + // which means that all reference-type fields need to take up 8 bytes (except for the last + // one, which will be sized as either 4 or 8 bytes depending on the runtime platform). + // This is not optimal for the Mono-WebAssembly case because that's always 32-bit so the + // reference-type fields could be reduced to 4 bytes each. We could use ifdefs to have + // different fields offsets for the 32 and 64 bit compile targets, but then we'd have the + // complexity of needing different binaries when loaded into Mono-WASM vs desktop. + // Eventually we might stop using this shared memory interop altogether (and would have to + // if running as a web worker) so for now to keep things simple, treat reference types as + // 8 bytes here. + + // -------------------------------------------------------------------------------- + // Common + // -------------------------------------------------------------------------------- + + /// + /// Gets the sequence number of the frame. Sequence numbers indicate the relative source + /// positions of the instructions that inserted the frames. Sequence numbers are only + /// comparable within the same sequence (typically, the same source method). + /// + [FieldOffset(0)] public readonly int Sequence; + + /// + /// Describes the type of this frame. + /// + [FieldOffset(4)] public readonly RenderTreeFrameType FrameType; + + // -------------------------------------------------------------------------------- + // RenderTreeFrameType.Element + // -------------------------------------------------------------------------------- + + /// + /// If the property equals + /// gets the number of frames in the subtree for which this frame is the root. + /// The value is zero if the frame has not yet been closed. + /// + [FieldOffset(8)] public readonly int ElementSubtreeLength; + + /// + /// If the property equals , + /// gets a name representing the type of the element. Otherwise, the value is undefined. + /// + [FieldOffset(16)] public readonly string ElementName; + + // -------------------------------------------------------------------------------- + // RenderTreeFrameType.Text + // -------------------------------------------------------------------------------- + + /// + /// If the property equals , + /// gets the content of the text frame. Otherwise, the value is undefined. + /// + [FieldOffset(16)] public readonly string TextContent; + + // -------------------------------------------------------------------------------- + // RenderTreeFrameType.Attribute + // -------------------------------------------------------------------------------- + + /// + /// If the property equals + /// gets the ID of the corresponding event handler, if any. + /// + [FieldOffset(8)] public readonly int AttributeEventHandlerId; + + /// + /// If the property equals , + /// gets the attribute name. Otherwise, the value is undefined. + /// + [FieldOffset(16)] public readonly string AttributeName; + + /// + /// If the property equals , + /// gets the attribute value. Otherwise, the value is undefined. + /// + [FieldOffset(24)] public readonly object AttributeValue; + + // -------------------------------------------------------------------------------- + // RenderTreeFrameType.Component + // -------------------------------------------------------------------------------- + + /// + /// If the property equals + /// gets the number of frames in the subtree for which this frame is the root. + /// The value is zero if the frame has not yet been closed. + /// + [FieldOffset(8)] public readonly int ComponentSubtreeLength; + + /// + /// If the property equals , + /// gets the child component instance identifier. + /// + [FieldOffset(12)] public readonly int ComponentId; + + /// + /// If the property equals , + /// gets the type of the child component. + /// + [FieldOffset(16)] public readonly Type ComponentType; + + /// + /// If the property equals , + /// gets the child component instance. Otherwise, the value is undefined. + /// + public IComponent Component => null; + + // -------------------------------------------------------------------------------- + // RenderTreeFrameType.Region + // -------------------------------------------------------------------------------- + + /// + /// If the property equals + /// gets the number of frames in the subtree for which this frame is the root. + /// The value is zero if the frame has not yet been closed. + /// + [FieldOffset(8)] public readonly int RegionSubtreeLength; + + // -------------------------------------------------------------------------------- + // RenderTreeFrameType.ElementReferenceCapture + // -------------------------------------------------------------------------------- + + /// + /// If the property equals , + /// gets the ID of the reference capture. Otherwise, the value is undefined. + /// + [FieldOffset(16)] public readonly string ElementReferenceCaptureId; + + /// + /// If the property equals , + /// gets the action that writes the reference to its target. Otherwise, the value is undefined. + /// + [FieldOffset(24)] public readonly Action ElementReferenceCaptureAction; + + // -------------------------------------------------------------------------------- + // RenderTreeFrameType.ComponentReferenceCapture + // -------------------------------------------------------------------------------- + + /// + /// If the property equals , + /// gets the index of the parent frame representing the component being captured. Otherwise, the value is undefined. + /// WARNING: This index can only be used in the context of the frame's original render tree. If the frame is + /// copied elsewhere, such as to the ReferenceFrames buffer of a RenderTreeDiff, then the index will + /// not relate to entries in that other buffer. + /// Currently there's no scenario where this matters, but if there was, we could change all of the subtree + /// initialization logic in RenderTreeDiffBuilder to walk the frames hierarchically, then it would know + /// the parent index at the point where it wants to initialize the ComponentReferenceCapture frame. + /// + [FieldOffset(8)] public readonly int ComponentReferenceCaptureParentFrameIndex; + + /// + /// If the property equals , + /// gets the action that writes the reference to its target. Otherwise, the value is undefined. + /// + [FieldOffset(16)] public readonly Action ComponentReferenceCaptureAction; + + // -------------------------------------------------------------------------------- + // RenderTreeFrameType.Markup + // -------------------------------------------------------------------------------- + + /// + /// If the property equals , + /// gets the content of the markup frame. Otherwise, the value is undefined. + /// + [FieldOffset(16)] public readonly string MarkupContent; + + private RenderTreeFrame(int sequence, string elementName, int elementSubtreeLength) + : this() + { + FrameType = RenderTreeFrameType.Element; + Sequence = sequence; + ElementName = elementName; + ElementSubtreeLength = elementSubtreeLength; + } + + private RenderTreeFrame(int sequence, Type componentType, int componentSubtreeLength) + : this() + { + FrameType = RenderTreeFrameType.Component; + Sequence = sequence; + ComponentType = componentType; + ComponentSubtreeLength = componentSubtreeLength; + } + + private RenderTreeFrame(int sequence, string textContent) + : this() + { + FrameType = RenderTreeFrameType.Text; + Sequence = sequence; + TextContent = textContent; + } + + private RenderTreeFrame(int sequence, string attributeName, object attributeValue) + : this() + { + FrameType = RenderTreeFrameType.Attribute; + Sequence = sequence; + AttributeName = attributeName; + AttributeValue = attributeValue; + } + + private RenderTreeFrame(int sequence, string attributeName, object attributeValue, int eventHandlerId) + : this() + { + FrameType = RenderTreeFrameType.Attribute; + Sequence = sequence; + AttributeName = attributeName; + AttributeValue = attributeValue; + AttributeEventHandlerId = eventHandlerId; + } + + private RenderTreeFrame(int sequence, int regionSubtreeLength) + : this() + { + FrameType = RenderTreeFrameType.Region; + Sequence = sequence; + RegionSubtreeLength = regionSubtreeLength; + } + + private RenderTreeFrame(int sequence, Action elementReferenceCaptureAction, string elementReferenceCaptureId) + : this() + { + FrameType = RenderTreeFrameType.ElementReferenceCapture; + Sequence = sequence; + ElementReferenceCaptureAction = elementReferenceCaptureAction; + ElementReferenceCaptureId = elementReferenceCaptureId; + } + + private RenderTreeFrame(int sequence, Action componentReferenceCaptureAction, int parentFrameIndex) + : this() + { + FrameType = RenderTreeFrameType.ComponentReferenceCapture; + Sequence = sequence; + ComponentReferenceCaptureAction = componentReferenceCaptureAction; + ComponentReferenceCaptureParentFrameIndex = parentFrameIndex; + } + + // If we need further constructors whose signatures clash with the patterns above, + // we can add extra args to this general-purpose one. + private RenderTreeFrame(int sequence, RenderTreeFrameType frameType, string markupContent) + : this() + { + FrameType = frameType; + Sequence = sequence; + MarkupContent = markupContent; + } + + internal static RenderTreeFrame Element(int sequence, string elementName) + => new RenderTreeFrame(sequence, elementName: elementName, elementSubtreeLength: 0); + + internal static RenderTreeFrame Text(int sequence, string textContent) + => new RenderTreeFrame(sequence, textContent: textContent); + + internal static RenderTreeFrame Markup(int sequence, string markupContent) + => new RenderTreeFrame(sequence, RenderTreeFrameType.Markup, markupContent); + + internal static RenderTreeFrame Attribute(int sequence, string name, MulticastDelegate value) + => new RenderTreeFrame(sequence, attributeName: name, attributeValue: value); + + internal static RenderTreeFrame Attribute(int sequence, string name, object value) + => new RenderTreeFrame(sequence, attributeName: name, attributeValue: value); + + internal static RenderTreeFrame ChildComponent(int sequence, Type componentType) + => new RenderTreeFrame(sequence, componentType, 0); + + internal static RenderTreeFrame PlaceholderChildComponentWithSubtreeLength(int subtreeLength) + => new RenderTreeFrame(0, typeof(IComponent), subtreeLength); + + internal static RenderTreeFrame Region(int sequence) + => new RenderTreeFrame(sequence, regionSubtreeLength: 0); + + internal static RenderTreeFrame ElementReferenceCapture(int sequence, Action elementReferenceCaptureAction) + => new RenderTreeFrame(sequence, elementReferenceCaptureAction: elementReferenceCaptureAction, elementReferenceCaptureId: null); + + internal static RenderTreeFrame ComponentReferenceCapture(int sequence, Action componentReferenceCaptureAction, int parentFrameIndex) + => new RenderTreeFrame(sequence, componentReferenceCaptureAction: componentReferenceCaptureAction, parentFrameIndex: parentFrameIndex); + + internal RenderTreeFrame WithElementSubtreeLength(int elementSubtreeLength) + => new RenderTreeFrame(Sequence, elementName: ElementName, elementSubtreeLength: elementSubtreeLength); + + internal RenderTreeFrame WithComponentSubtreeLength(int componentSubtreeLength) + => new RenderTreeFrame(Sequence, componentType: ComponentType, componentSubtreeLength: componentSubtreeLength); + + internal RenderTreeFrame WithAttributeSequence(int sequence) + => new RenderTreeFrame(sequence, attributeName: AttributeName, attributeValue: AttributeValue); + + internal RenderTreeFrame WithAttributeEventHandlerId(int eventHandlerId) + => new RenderTreeFrame(Sequence, AttributeName, AttributeValue, eventHandlerId); + + internal RenderTreeFrame WithRegionSubtreeLength(int regionSubtreeLength) + => new RenderTreeFrame(Sequence, regionSubtreeLength: regionSubtreeLength); + + internal RenderTreeFrame WithElementReferenceCaptureId(string elementReferenceCaptureId) + => new RenderTreeFrame(Sequence, ElementReferenceCaptureAction, elementReferenceCaptureId); + + /// + // Just to be nice for debugging and unit tests. + public override string ToString() + { + switch (FrameType) + { + case RenderTreeFrameType.Attribute: + return $"Attribute: (seq={Sequence}, id={AttributeEventHandlerId}) '{AttributeName}'='{AttributeValue}'"; + + case RenderTreeFrameType.Component: + return $"Component: (seq={Sequence}, len={ComponentSubtreeLength}) {ComponentType}"; + + case RenderTreeFrameType.Element: + return $"Element: (seq={Sequence}, len={ElementSubtreeLength}) {ElementName}"; + + case RenderTreeFrameType.Region: + return $"Region: (seq={Sequence}, len={RegionSubtreeLength})"; + + case RenderTreeFrameType.Text: + return $"Text: (seq={Sequence}, len=n/a) {EscapeNewlines(TextContent)}"; + + case RenderTreeFrameType.Markup: + return $"Markup: (seq={Sequence}, len=n/a) {EscapeNewlines(TextContent)}"; + + case RenderTreeFrameType.ElementReferenceCapture: + return $"ElementReferenceCapture: (seq={Sequence}, len=n/a) {ElementReferenceCaptureAction}"; + } + + return base.ToString(); + } + + private static string EscapeNewlines(string text) + { + return text.Replace("\n", "\\n").Replace("\r\n", "\\r\\n"); + } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RenderTreeFrameType.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RenderTreeFrameType.cs new file mode 100644 index 00000000000..5a64846ae94 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/RenderTreeFrameType.cs @@ -0,0 +1,54 @@ +// 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. + +namespace Microsoft.AspNetCore.Components.RenderTree +{ + /// + /// Describes the type of a . + /// + public enum RenderTreeFrameType : int + { + /// + /// Represents a container for other frames. + /// + Element = 1, + + /// + /// Represents text content. + /// + Text = 2, + + /// + /// Represents a key-value pair associated with another . + /// + Attribute = 3, + + /// + /// Represents a child component. + /// + Component = 4, + + /// + /// Defines the boundary around range of sibling frames that should be treated as an + /// unsplittable group for the purposes of diffing. This is typically used when appending + /// a tree fragment generated by external code, because the sequence numbers in that tree + /// fragment are not comparable to sequence numbers outside it. + /// + Region = 5, + + /// + /// Represents an instruction to capture or update a reference to the parent element. + /// + ElementReferenceCapture = 6, + + /// + /// Represents an instruction to capture or update a reference to the parent component. + /// + ComponentReferenceCapture = 7, + + /// + /// Represents a block of markup content. + /// + Markup = 8, + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.codegen.cs new file mode 100644 index 00000000000..6de3cb730f0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using Microsoft.AspNetCore.Components; +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using System.Threading.Tasks; + +#line default +#line hidden + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue("async (e) => await Task.Delay(10)"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.ir.txt new file mode 100644 index 00000000000..cc858bd23bf --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.ir.txt @@ -0,0 +1,30 @@ +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 - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [28] x:\dir\subdir\Test\TestComponent.cshtml) - System.Threading.Tasks + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [53] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (47:1,16 [33] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - - CSharp - "async (e) => await Task.Delay(10)" + IntermediateToken - - CSharp - ) + HtmlContent - (84:1,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (84:1,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.mappings.txt new file mode 100644 index 00000000000..b97e7aa5a7d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (1:0,1 [28] x:\dir\subdir\Test\TestComponent.cshtml) +|using System.Threading.Tasks| +Generated Location: (266:10,0 [28] ) +|using System.Threading.Tasks| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..d9db12dcf0b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using Microsoft.AspNetCore.Components; +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using System.Threading.Tasks; + +#line default +#line hidden + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + Task OnClick(UIMouseEventArgs e) + { + return Task.CompletedTask; + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..feb915aee20 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.ir.txt @@ -0,0 +1,32 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [28] x:\dir\subdir\Test\TestComponent.cshtml) - System.Threading.Tasks + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (47:1,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (48:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + HtmlContent - (59:1,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (59:1,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (73:2,12 [91] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (73:2,12 [91] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n Task OnClick(UIMouseEventArgs e) \n {\n return Task.CompletedTask;\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..8e3a9e0d994 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (1:0,1 [28] x:\dir\subdir\Test\TestComponent.cshtml) +|using System.Threading.Tasks| +Generated Location: (266:10,0 [28] ) +|using System.Threading.Tasks| + +Source Location: (48:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|OnClick| +Generated Location: (1028:27,133 [7] ) +|OnClick| + +Source Location: (73:2,12 [91] x:\dir\subdir\Test\TestComponent.cshtml) +| + Task OnClick(UIMouseEventArgs e) + { + return Task.CompletedTask; + } +| +Generated Location: (1151:31,12 [91] ) +| + Task OnClick(UIMouseEventArgs e) + { + return Task.CompletedTask; + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.codegen.cs new file mode 100644 index 00000000000..6de3cb730f0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using Microsoft.AspNetCore.Components; +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using System.Threading.Tasks; + +#line default +#line hidden + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue("async (e) => await Task.Delay(10)"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.ir.txt new file mode 100644 index 00000000000..cc858bd23bf --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.ir.txt @@ -0,0 +1,30 @@ +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 - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [28] x:\dir\subdir\Test\TestComponent.cshtml) - System.Threading.Tasks + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [53] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (47:1,16 [33] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - - CSharp - "async (e) => await Task.Delay(10)" + IntermediateToken - - CSharp - ) + HtmlContent - (84:1,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (84:1,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.mappings.txt new file mode 100644 index 00000000000..b97e7aa5a7d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (1:0,1 [28] x:\dir\subdir\Test\TestComponent.cshtml) +|using System.Threading.Tasks| +Generated Location: (266:10,0 [28] ) +|using System.Threading.Tasks| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..606261cf30a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using Microsoft.AspNetCore.Components; +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using System.Threading.Tasks; + +#line default +#line hidden + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + Task OnClick() + { + return Task.CompletedTask; + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..0da76c0893f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.ir.txt @@ -0,0 +1,32 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [28] x:\dir\subdir\Test\TestComponent.cshtml) - System.Threading.Tasks + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (47:1,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (48:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + HtmlContent - (59:1,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (59:1,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (73:2,12 [73] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (73:2,12 [73] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n Task OnClick() \n {\n return Task.CompletedTask;\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..b20efd8550f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (1:0,1 [28] x:\dir\subdir\Test\TestComponent.cshtml) +|using System.Threading.Tasks| +Generated Location: (266:10,0 [28] ) +|using System.Threading.Tasks| + +Source Location: (48:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|OnClick| +Generated Location: (1028:27,133 [7] ) +|OnClick| + +Source Location: (73:2,12 [73] x:\dir\subdir\Test\TestComponent.cshtml) +| + Task OnClick() + { + return Task.CompletedTask; + } +| +Generated Location: (1151:31,12 [73] ) +| + Task OnClick() + { + return Task.CompletedTask; + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..d0abedafafd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden + )); + __o = new System.Action( + __value => ParentValue = __value); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..7295ad37a42 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [50] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - OnChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + HtmlContent - (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..ebd53f042bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1164:29,35 [11] ) +|ParentValue| + +Source Location: (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1588:42,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..5a8ecbc709d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,49 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..68aa44af9fe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [50] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + HtmlContent - (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..eb3e730a54c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1093:29,35 [11] ) +|ParentValue| + +Source Location: (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1543:41,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..aa91ac79865 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden + )); + __o = new System.Action( + __value => ParentValue = __value); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..c75da4700b4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [40] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + HtmlContent - (71:1,40 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:1,40 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..bf42d527eee --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1154:29,25 [11] ) +|ParentValue| + +Source Location: (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1578:42,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..611acf6ce46 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,49 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..b933602feab --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [40] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + HtmlContent - (71:1,40 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:1,40 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..ed41ba9eac7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1083:29,25 [11] ) +|ParentValue| + +Source Location: (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1533:41,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..f028961ecb1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ParentValue + +#line default +#line hidden + )); + __o = new System.Action( + __value => ParentValue = __value); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "42"; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..8a43c85cbe9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [40] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + HtmlContent - (71:1,40 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:1,40 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (85:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (85:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "42";\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..a3e10bc4efc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1154:29,25 [11] ) +|ParentValue| + +Source Location: (85:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "42"; +| +Generated Location: (1578:42,12 [55] ) +| + public string ParentValue { get; set; } = "42"; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..96562a892cc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(CurrentDate, "MM/dd"); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, "MM/dd"); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..45daf14a11f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,41 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (71:1,40 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (72:1,41 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - "MM/dd" + IntermediateToken - - CSharp - ) + HtmlAttribute - (71:1,40 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, "MM/dd") + HtmlContent - (108:1,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (108:1,77 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (122:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (122:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..87ca7a8ac5e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (72:1,41 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|CurrentDate| +Generated Location: (1005:27,71 [11] ) +|CurrentDate| + +Source Location: (122:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +| +Generated Location: (1277:32,12 [77] ) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..684f352a031 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..dadfe0591b6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,39 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [56] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (71:1,40 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (72:1,41 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (71:1,40 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + HtmlContent - (87:1,56 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (87:1,56 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (101:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (101:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..e629286e380 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (72:1,41 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1005:27,71 [11] ) +|ParentValue| + +Source Location: (101:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1259:32,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..e768b0f0cf1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..8621ce9bc96 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [33] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (48:1,17 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (49:1,18 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (48:1,17 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + HtmlContent - (64:1,33 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (64:1,33 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (78:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (78:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..2e15f746253 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (49:1,18 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1005:27,71 [11] ) +|ParentValue| + +Source Location: (78:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; +| +Generated Location: (1259:32,12 [55] ) +| + public string ParentValue { get; set; } = "hi"; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..e768b0f0cf1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..6bf6c30c87a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [27] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (42:1,11 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (43:1,12 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (42:1,11 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + HtmlContent - (58:1,27 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:1,27 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (72:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..cd366f6243f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (43:1,12 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1005:27,71 [11] ) +|ParentValue| + +Source Location: (72:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; +| +Generated Location: (1259:32,12 [55] ) +| + public string ParentValue { get; set; } = "hi"; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..4b556e6406c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs @@ -0,0 +1,59 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment header = (context) => + +#line default +#line hidden + (builder2) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context.ToLowerInvariant(); + +#line default +#line hidden + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + __o = new Microsoft.AspNetCore.Components.RenderFragment( +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + header + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..2da9c6fd7c0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.ir.txt @@ -0,0 +1,38 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment header = (context) => + Template - (80:1,49 [37] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (80:1,49 [38] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLowerInvariant() + CSharpCode - (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (123:2,0 [62] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (151:2,28 [20] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (151:2,28 [20] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n Some Content\n + ComponentAttributeExtensionNode - (143:2,20 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Header - Header + CSharpExpression - (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - header diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..325cb343a04 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment header = (context) => | +Generated Location: (987:28,2 [46] ) +| RenderFragment header = (context) => | + +Source Location: (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) +|context.ToLowerInvariant()| +Generated Location: (1201:34,55 [26] ) +|context.ToLowerInvariant()| + +Source Location: (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (1414:40,87 [2] ) +|; | + +Source Location: (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|header| +Generated Location: (1607:46,21 [6] ) +|header| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..d2554d64da3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs @@ -0,0 +1,62 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment header = (context) => + +#line default +#line hidden + (builder2) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context.ToLowerInvariant(); + +#line default +#line hidden + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + __o = new Microsoft.AspNetCore.Components.RenderFragment( +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + header + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + builder.AddAttribute(-1, "Footer", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..53a2f512d88 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.ir.txt @@ -0,0 +1,41 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment header = (context) => + Template - (80:1,49 [37] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (80:1,49 [38] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLowerInvariant() + CSharpCode - (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (123:2,0 [114] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (155:3,2 [41] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlContent - (169:3,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (169:3,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Some Content + ComponentChildContent - (200:4,2 [21] x:\dir\subdir\Test\TestComponent.cshtml) - Footer + HtmlContent - (208:4,10 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (208:4,10 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Bye! + ComponentAttributeExtensionNode - (143:2,20 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Header - Header + CSharpExpression - (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - header diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..325cb343a04 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment header = (context) => | +Generated Location: (987:28,2 [46] ) +| RenderFragment header = (context) => | + +Source Location: (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) +|context.ToLowerInvariant()| +Generated Location: (1201:34,55 [26] ) +|context.ToLowerInvariant()| + +Source Location: (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (1414:40,87 [2] ) +|; | + +Source Location: (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|header| +Generated Location: (1607:46,21 [6] ) +|header| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..72169e0d95d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(Enabled); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Enabled = __value, Enabled); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public bool Enabled { get; set; } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..5349927f270 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,39 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [8] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - checkbox + HtmlAttribute - (60:1,29 [8] x:\dir\subdir\Test\TestComponent.cshtml) - checked=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (61:1,30 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Enabled + IntermediateToken - - CSharp - ) + HtmlAttribute - (60:1,29 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Enabled = __value, Enabled) + HtmlContent - (72:1,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:1,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (86:2,12 [41] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:2,12 [41] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public bool Enabled { get; set; }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..4535b9812be --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (61:1,30 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|Enabled| +Generated Location: (1005:27,71 [7] ) +|Enabled| + +Source Location: (86:2,12 [41] x:\dir\subdir\Test\TestComponent.cshtml) +| + public bool Enabled { get; set; } +| +Generated Location: (1247:32,12 [41] ) +| + public bool Enabled { get; set; } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..7d61f92d2ae --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(CurrentDate, Format); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, Format); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + + public string Format { get; set; } = "MM/dd/yyyy"; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..bdd5856a218 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,41 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [63] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (57:1,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate + IntermediateToken - - CSharp - , + IntermediateToken - (85:1,54 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Format + IntermediateToken - - CSharp - ) + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, Format) + HtmlContent - (94:1,63 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (94:1,63 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (108:2,12 [135] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (108:2,12 [135] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n\n public string Format { get; set; } = "MM/dd/yyyy";\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..466721d41ac --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,28 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (57:1,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|CurrentDate| +Generated Location: (1005:27,71 [11] ) +|CurrentDate| + +Source Location: (85:1,54 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|Format| +Generated Location: (1018:27,84 [6] ) +|Format| + +Source Location: (108:2,12 [135] x:\dir\subdir\Test\TestComponent.cshtml) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + + public string Format { get; set; } = "MM/dd/yyyy"; +| +Generated Location: (1275:32,12 [135] ) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + + public string Format { get; set; } = "MM/dd/yyyy"; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..f9fb164b2f8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(CurrentDate, "MM/dd/yyyy"); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, "MM/dd/yyyy"); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..72fc1f0f075 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,41 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [66] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (57:1,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - "MM/dd/yyyy" + IntermediateToken - - CSharp - ) + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, "MM/dd/yyyy") + HtmlContent - (97:1,66 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (97:1,66 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (111:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (111:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..7170fa644c7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (57:1,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|CurrentDate| +Generated Location: (1005:27,71 [11] ) +|CurrentDate| + +Source Location: (111:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +| +Generated Location: (1287:32,12 [77] ) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..684f352a031 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..2813471425b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,39 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (57:1,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + HtmlContent - (72:1,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:1,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (86:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..d2b22b616a3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (57:1,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1005:27,71 [11] ) +|ParentValue| + +Source Location: (86:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1259:32,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..684f352a031 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..b791080153e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (44:1,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (45:1,14 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (44:1,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + HtmlContent - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (74:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (74:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..08dab60ebfe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (45:1,14 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentValue| +Generated Location: (1005:27,71 [11] ) +|ParentValue| + +Source Location: (74:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1259:32,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic/TestComponent.codegen.cs new file mode 100644 index 00000000000..ea8dc2f9260 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic/TestComponent.codegen.cs @@ -0,0 +1,49 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = typeof( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + string + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "hi" + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic/TestComponent.ir.txt new file mode 100644 index 00000000000..6d9d0292e44 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic/TestComponent.ir.txt @@ -0,0 +1,29 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (63:1,32 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (64:1,33 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic/TestComponent.mappings.txt new file mode 100644 index 00000000000..c8cfdec15ad --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|string| +Generated Location: (1031:29,19 [6] ) +|string| + +Source Location: (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|"hi"| +Generated Location: (1256:36,34 [4] ) +|"hi"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.codegen.cs new file mode 100644 index 00000000000..9564c397354 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.codegen.cs @@ -0,0 +1,57 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = typeof( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + string + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + Value + +#line default +#line hidden + )); + __o = new System.Action( + __value => Value = __value); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string Value; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.ir.txt new file mode 100644 index 00000000000..0028e0a5d08 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.ir.txt @@ -0,0 +1,38 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - ItemChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => Value = __value + HtmlContent - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.mappings.txt new file mode 100644 index 00000000000..07633fc4bbe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.mappings.txt @@ -0,0 +1,24 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|string| +Generated Location: (1031:29,19 [6] ) +|string| + +Source Location: (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) +|Value| +Generated Location: (1311:36,36 [5] ) +|Value| + +Source Location: (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) +| + string Value; +| +Generated Location: (1717:49,12 [21] ) +| + string Value; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.codegen.cs new file mode 100644 index 00000000000..03f32dcebf5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = typeof( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + string + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + Value + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Value = __value, Value); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string Value; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt new file mode 100644 index 00000000000..eead159f4f5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt @@ -0,0 +1,38 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Value = __value, Value) + HtmlContent - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.mappings.txt new file mode 100644 index 00000000000..10234758f3e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.mappings.txt @@ -0,0 +1,24 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|string| +Generated Location: (1031:29,19 [6] ) +|string| + +Source Location: (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) +|Value| +Generated Location: (1246:36,36 [5] ) +|Value| + +Source Location: (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) +| + string Value; +| +Generated Location: (1678:48,12 [21] ) +| + string Value; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..d1412ef37bd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,66 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1, +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + 18 + +#line default +#line hidden + , -1, Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + Value + +#line default +#line hidden + ), -1, Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Value = __value, Value)); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string Value; + +#line default +#line hidden + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, System.Object __arg1, int __seq2, System.Object __arg2) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Value", __arg0); + builder.AddAttribute(__seq1, "Item", __arg1); + builder.AddAttribute(__seq2, "ItemChanged", __arg2); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..3ce37a7df2b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt @@ -0,0 +1,42 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (66:1,35 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value + CSharpExpression - (67:1,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 18 + ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Value = __value, Value) + HtmlContent - (73:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (73:1,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..23f5de23fc1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,24 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|18| +Generated Location: (1115:29,37 [2] ) +|18| + +Source Location: (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) +|Value| +Generated Location: (1297:35,23 [5] ) +|Value| + +Source Location: (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) +| + string Value; +| +Generated Location: (1564:43,12 [21] ) +| + string Value; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..a50ae877af4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,60 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1, Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + Value + +#line default +#line hidden + ), -1, + __value => Value = __value); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string Value; + +#line default +#line hidden + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "ItemChanged", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..8da25b3d5e1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.ir.txt @@ -0,0 +1,39 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [30] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - ItemChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => Value = __value + HtmlContent - (61:1,30 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (61:1,30 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..566c12bfe74 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) +|Value| +Generated Location: (1154:29,23 [5] ) +|Value| + +Source Location: (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) +| + string Value; +| +Generated Location: (1367:38,12 [21] ) +| + string Value; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..84bb22d4ae2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = typeof( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + string + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "hi" + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((context) => (builder2) => { +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context.ToLower(); + +#line default +#line hidden + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..5b20b6f6c4b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt @@ -0,0 +1,37 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [90] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (72:1,41 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:1,41 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (76:2,2 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (82:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (82:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() + HtmlContent - (105:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (105:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (63:1,32 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (64:1,33 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..62f2c6c68e0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|string| +Generated Location: (1031:29,19 [6] ) +|string| + +Source Location: (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|"hi"| +Generated Location: (1256:36,34 [4] ) +|"hi"| + +Source Location: (82:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|context.ToLower()| +Generated Location: (1508:43,8 [17] ) +|context.ToLower()| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..3952832c1b5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,60 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1, +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "hi" + +#line default +#line hidden + , -1, (context) => (builder2) => { +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context.ToLower(); + +#line default +#line hidden + } + ); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.RenderFragment __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "ChildContent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..0c8dec9c50a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt @@ -0,0 +1,38 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (59:1,28 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (59:1,28 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (63:2,2 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() + HtmlContent - (92:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (92:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..d966dab3c22 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|"hi"| +Generated Location: (1099:29,21 [4] ) +|"hi"| + +Source Location: (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|context.ToLower()| +Generated Location: (1243:35,8 [17] ) +|context.ToLower()| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.codegen.cs new file mode 100644 index 00000000000..e3f7ea641aa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = typeof( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + string + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "hi" + +#line default +#line hidden + ); + __o = +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + 17 + +#line default +#line hidden + ; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.ir.txt new file mode 100644 index 00000000000..18d0da6b2bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.ir.txt @@ -0,0 +1,32 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [56] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (63:1,32 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (64:1,33 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + ComponentAttributeExtensionNode - - Other - + CSharpExpression - (79:1,48 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 17 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.mappings.txt new file mode 100644 index 00000000000..3fe96bdbc71 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|string| +Generated Location: (1031:29,19 [6] ) +|string| + +Source Location: (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|"hi"| +Generated Location: (1256:36,34 [4] ) +|"hi"| + +Source Location: (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|17| +Generated Location: (1430:43,50 [2] ) +|17| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..959b2015b60 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,59 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1, +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "hi" + +#line default +#line hidden + , -1, +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + 17 + +#line default +#line hidden + ); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, System.Object __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "Other", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..fffdaf96ad6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.ir.txt @@ -0,0 +1,33 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + ComponentAttributeExtensionNode - - Other - + CSharpExpression - (66:1,35 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 17 + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..565d3538059 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|"hi"| +Generated Location: (1099:29,21 [4] ) +|"hi"| + +Source Location: (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|17| +Generated Location: (1244:35,37 [2] ) +|17| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..d77ffc4e7a7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,52 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1, +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "hi" + +#line default +#line hidden + ); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..ffc822ec866 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..ae90183a66c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|"hi"| +Generated Location: (1099:29,21 [4] ) +|"hi"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.codegen.cs new file mode 100644 index 00000000000..ee03dbe3e89 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.codegen.cs @@ -0,0 +1,78 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1, +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "hi" + +#line default +#line hidden + ); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_1(builder, -1, -1, +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + "how are you?" + +#line default +#line hidden + ); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_2(builder, -1, -1, +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + "bye!" + +#line default +#line hidden + ); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.CloseComponent(); + } + public static void CreateMyComponent_1(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.CloseComponent(); + } + public static void CreateMyComponent_2(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.ir.txt new file mode 100644 index 00000000000..4c54493797e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.ir.txt @@ -0,0 +1,44 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + HtmlContent - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (62:2,0 [39] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (81:2,19 [17] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (82:2,20 [16] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (83:2,21 [14] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "how are you?" + HtmlContent - (101:2,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (101:2,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (103:3,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (122:3,19 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (123:3,20 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (124:3,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "bye!" + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_1 + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_2 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.mappings.txt new file mode 100644 index 00000000000..cde7b926aef --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|"hi"| +Generated Location: (1099:29,21 [4] ) +|"hi"| + +Source Location: (83:2,21 [14] x:\dir\subdir\Test\TestComponent.cshtml) +|"how are you?"| +Generated Location: (1317:36,21 [14] ) +|"how are you?"| + +Source Location: (124:3,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|"bye!"| +Generated Location: (1545:43,21 [6] ) +|"bye!"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs new file mode 100644 index 00000000000..1ed68c5bc91 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs @@ -0,0 +1,69 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = typeof( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + string + +#line default +#line hidden + ); + __o = typeof( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + int + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "hi" + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((context) => (builder2) => { +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context.ToLower(); + +#line default +#line hidden + } + )); + builder.AddAttribute(-1, "AnotherChildContent", (Microsoft.AspNetCore.Components.RenderFragment.Context>)((item) => (builder2) => { +#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = System.Math.Max(0, item.Item); + +#line default +#line hidden + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt new file mode 100644 index 00000000000..099d94fbcfe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt @@ -0,0 +1,42 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [228] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (88:2,2 [58] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlElement - (102:2,16 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (108:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (108:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() + ComponentChildContent - (148:3,0 [95] x:\dir\subdir\Test\TestComponent.cshtml) - AnotherChildContent + HtmlContent - (184:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (184:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (189:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (189:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - System.Math.Max(0, item.Item) + HtmlContent - (218:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (218:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + ComponentTypeArgumentExtensionNode - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem1 + IntermediateToken - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentTypeArgumentExtensionNode - (65:1,34 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TItem2 + IntermediateToken - (65:1,34 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int + ComponentAttributeExtensionNode - (75:1,44 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (76:1,45 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (77:1,46 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.mappings.txt new file mode 100644 index 00000000000..d0914a96e81 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.mappings.txt @@ -0,0 +1,30 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|string| +Generated Location: (1032:29,20 [6] ) +|string| + +Source Location: (65:1,34 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|int| +Generated Location: (1199:36,34 [3] ) +|int| + +Source Location: (77:1,46 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|"hi"| +Generated Location: (1433:43,46 [4] ) +|"hi"| + +Source Location: (108:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|context.ToLower()| +Generated Location: (1699:50,22 [17] ) +|context.ToLower()| + +Source Location: (189:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) +|System.Math.Max(0, item.Item)| +Generated Location: (2014:58,6 [29] ) +|System.Math.Max(0, item.Item)| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..3933f941a74 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,75 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1, +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "hi" + +#line default +#line hidden + , -1, +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + new List() + +#line default +#line hidden + , -1, (context) => (builder2) => { +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context.ToLower(); + +#line default +#line hidden + } + , -1, (item) => (builder2) => { +#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = System.Math.Max(0, item.Item); + +#line default +#line hidden + } + ); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem1 __arg0, int __seq1, global::System.Collections.Generic.List __arg1, int __seq2, global::Microsoft.AspNetCore.Components.RenderFragment __arg2, int __seq3, global::Microsoft.AspNetCore.Components.RenderFragment.Context> __arg3) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "Items", __arg1); + builder.AddAttribute(__seq2, "ChildContent", __arg2); + builder.AddAttribute(__seq3, "AnotherChildContent", __arg3); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..a388f982278 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt @@ -0,0 +1,44 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [229] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentChildContent - (89:2,2 [58] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlElement - (103:2,16 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() + ComponentChildContent - (149:3,0 [95] x:\dir\subdir\Test\TestComponent.cshtml) - AnotherChildContent + HtmlContent - (185:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (185:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - System.Math.Max(0, item.Item) + HtmlContent - (219:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (219:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + ComponentAttributeExtensionNode - (65:1,34 [19] x:\dir\subdir\Test\TestComponent.cshtml) - Items - Items + CSharpExpression - (66:1,35 [18] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (67:1,36 [16] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - new List() + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..3e4078529db --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|"hi"| +Generated Location: (1099:29,21 [4] ) +|"hi"| + +Source Location: (67:1,36 [16] x:\dir\subdir\Test\TestComponent.cshtml) +|new List()| +Generated Location: (1243:35,36 [16] ) +|new List()| + +Source Location: (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|context.ToLower()| +Generated Location: (1413:41,22 [17] ) +|context.ToLower()| + +Source Location: (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) +|System.Math.Max(0, item.Item)| +Generated Location: (1581:48,6 [29] ) +|System.Math.Max(0, item.Item)| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Simple/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Simple/TestComponent.codegen.cs new file mode 100644 index 00000000000..3c8fef10742 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Simple/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Simple/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Simple/TestComponent.ir.txt new file mode 100644 index 00000000000..04bb07c5f8a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Simple/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [15] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Simple/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Simple/TestComponent.mappings.txt new file mode 100644 index 00000000000..3917573adf7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_Simple/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..288be779ed3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = ""; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..f32a0f1d276 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [91] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Some text + HtmlElement - (66:1,35 [42] x:\dir\subdir\Test\TestComponent.cshtml) - some-child + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - 1 + HtmlContent - (84:1,53 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (84:1,53 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Nested text + ComponentAttributeExtensionNode - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr + HtmlContent - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..3917573adf7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..3c8fef10742 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..f08cf8b7476 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt @@ -0,0 +1,28 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [47] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlElement - (44:1,13 [20] x:\dir\subdir\Test\TestComponent.cshtml) - child + HtmlContent - (51:1,20 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (51:1,20 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - hello diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..3917573adf7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..3c8fef10742 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..48021f51a04 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/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 - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [61] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (44:1,13 [34] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlContent - (58:1,27 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:1,27 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - hello diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..3917573adf7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs new file mode 100644 index 00000000000..61d34f78125 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs @@ -0,0 +1,51 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = new System.Action( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + Increment + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private int counter; + private void Increment(UIEventArgs e) { + counter++; + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.ir.txt new file mode 100644 index 00000000000..ae39bbd0336 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.ir.txt @@ -0,0 +1,31 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (53:1,22 [10] x:\dir\subdir\Test\TestComponent.cshtml) - OnClick - OnClick + CSharpExpression - (54:1,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (54:1,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Increment + HtmlContent - (66:1,35 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (66:1,35 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (82:3,12 [100] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (82:3,12 [100] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private int counter;\n private void Increment(UIEventArgs e) {\n counter++;\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt new file mode 100644 index 00000000000..c6405d7c546 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (54:1,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) +|Increment| +Generated Location: (1091:29,23 [9] ) +|Increment| + +Source Location: (82:3,12 [100] x:\dir\subdir\Test\TestComponent.cshtml) +| + private int counter; + private void Increment(UIEventArgs e) { + counter++; + } +| +Generated Location: (1412:40,12 [100] ) +| + private int counter; + private void Increment(UIEventArgs e) { + counter++; + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..a2c066546a6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((context) => (builder2) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context; + +#line default +#line hidden + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..26e2f26f43b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/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 - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (44:1,13 [37] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + CSharpExpression - (59:1,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (59:1,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..ca548bcd187 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (59:1,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|context| +Generated Location: (1160:29,28 [7] ) +|context| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.codegen.cs new file mode 100644 index 00000000000..ef63483411c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + 42.ToString() + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.ir.txt new file mode 100644 index 00000000000..a1f995fc262 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/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 - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [49] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (60:1,29 [16] x:\dir\subdir\Test\TestComponent.cshtml) - StringProperty - StringProperty + CSharpExpression - (62:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (62:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 42.ToString() diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.mappings.txt new file mode 100644 index 00000000000..81e7979f418 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (62:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml) +|42.ToString()| +Generated Location: (1108:29,31 [13] ) +|42.ToString()| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..5b51e73b4e5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = ""; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((context) => (builder2) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context.ToLowerInvariant(); + +#line default +#line hidden + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..5ac1905184b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [107] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Some text + HtmlElement - (66:1,35 [58] x:\dir\subdir\Test\TestComponent.cshtml) - some-child + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - 1 + CSharpExpression - (85:1,54 [26] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (85:1,54 [26] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLowerInvariant() + ComponentAttributeExtensionNode - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr + HtmlContent - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..81a696b3b93 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (85:1,54 [26] x:\dir\subdir\Test\TestComponent.cshtml) +|context.ToLowerInvariant()| +Generated Location: (1209:30,54 [26] ) +|context.ToLowerInvariant()| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs new file mode 100644 index 00000000000..b7253041bf6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = ""; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((item) => (builder2) => { +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = item.ToLowerInvariant(); + +#line default +#line hidden + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt new file mode 100644 index 00000000000..af1d17208c6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt @@ -0,0 +1,38 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [164] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (61:2,2 [118] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlContent - (90:2,31 [15] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (90:2,31 [15] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n Some text + HtmlElement - (105:3,13 [55] x:\dir\subdir\Test\TestComponent.cshtml) - some-child + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - 1 + CSharpExpression - (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item.ToLowerInvariant() + HtmlContent - (160:3,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (160:3,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentAttributeExtensionNode - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr + HtmlContent - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt new file mode 100644 index 00000000000..5031c58513a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) +|item.ToLowerInvariant()| +Generated Location: (1184:30,32 [23] ) +|item.ToLowerInvariant()| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..b7253041bf6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = ""; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((item) => (builder2) => { +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = item.ToLowerInvariant(); + +#line default +#line hidden + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..abe035020ba --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt @@ -0,0 +1,38 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [164] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (76:2,2 [103] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlContent - (90:2,16 [15] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (90:2,16 [15] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n Some text + HtmlElement - (105:3,13 [55] x:\dir\subdir\Test\TestComponent.cshtml) - some-child + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - 1 + CSharpExpression - (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item.ToLowerInvariant() + HtmlContent - (160:3,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (160:3,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentAttributeExtensionNode - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr + HtmlContent - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt new file mode 100644 index 00000000000..5031c58513a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) +|item.ToLowerInvariant()| +Generated Location: (1184:30,32 [23] ) +|item.ToLowerInvariant()| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs new file mode 100644 index 00000000000..e40582d4efa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs @@ -0,0 +1,51 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = new System.Action( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + e => { Increment(); } + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private int counter; + private void Increment() { + counter++; + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.ir.txt new file mode 100644 index 00000000000..4bc5d5e640a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.ir.txt @@ -0,0 +1,31 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [49] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (53:1,22 [24] x:\dir\subdir\Test\TestComponent.cshtml) - OnClick - OnClick + CSharpExpression - (54:1,23 [23] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (55:1,24 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - e => { Increment(); } + HtmlContent - (80:1,49 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (80:1,49 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (96:3,12 [87] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (96:3,12 [87] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private int counter;\n private void Increment() {\n counter++;\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt new file mode 100644 index 00000000000..52bd5077730 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (55:1,24 [21] x:\dir\subdir\Test\TestComponent.cshtml) +|e => { Increment(); }| +Generated Location: (1092:29,24 [21] ) +|e => { Increment(); }| + +Source Location: (96:3,12 [87] x:\dir\subdir\Test\TestComponent.cshtml) +| + private int counter; + private void Increment() { + counter++; + } +| +Generated Location: (1425:40,12 [87] ) +| + private int counter; + private void Increment() { + counter++; + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..eb6a81956e6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = ""; + __o = +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + 43.ToString() + +#line default +#line hidden + ; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..7a7abec5123 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - - some-attribute - + HtmlContent - (60:1,29 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (60:1,29 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - foo + ComponentAttributeExtensionNode - - another-attribute - + CSharpExpression - (84:1,53 [16] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:1,55 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 43.ToString() diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..e441ce9d712 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (86:1,55 [13] x:\dir\subdir\Test\TestComponent.cshtml) +|43.ToString()| +Generated Location: (1083:30,55 [13] ) +|43.ToString()| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.codegen.cs new file mode 100644 index 00000000000..264122c83e8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.codegen.cs @@ -0,0 +1,45 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + [Microsoft.AspNetCore.Components.RouteAttribute("/MyPage")] + [Microsoft.AspNetCore.Components.RouteAttribute("/AnotherRoute/{id}")] + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + ((System.Action)(() => { +global::System.Object __typeHelper = "/MyPage"; + } + ))(); + ((System.Action)(() => { +global::System.Object __typeHelper = "/AnotherRoute/{id}"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.ir.txt new file mode 100644 index 00000000000..bfbbf79448f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.ir.txt @@ -0,0 +1,28 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + RouteAttributeExtensionNode - - /MyPage + RouteAttributeExtensionNode - - /AnotherRoute/{id} + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + DirectiveToken - (37:1,6 [9] x:\dir\subdir\Test\TestComponent.cshtml) - "/MyPage" + DirectiveToken - (54:2,6 [20] x:\dir\subdir\Test\TestComponent.cshtml) - "/AnotherRoute/{id}" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (76:3,0 [15] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.mappings.txt new file mode 100644 index 00000000000..201fe3fccc9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (644:17,38 [15] ) +|*, TestAssembly| + +Source Location: (37:1,6 [9] x:\dir\subdir\Test\TestComponent.cshtml) +|"/MyPage"| +Generated Location: (760:21,37 [9] ) +|"/MyPage"| + +Source Location: (54:2,6 [20] x:\dir\subdir\Test\TestComponent.cshtml) +|"/AnotherRoute/{id}"| +Generated Location: (869:25,37 [20] ) +|"/AnotherRoute/{id}"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.codegen.cs new file mode 100644 index 00000000000..14f9c64fda1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.codegen.cs @@ -0,0 +1,57 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + 123 + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + true + +#line default +#line hidden + ); + __o = ""; + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + new SomeType() + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.ir.txt new file mode 100644 index 00000000000..75f100aadcb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.ir.txt @@ -0,0 +1,33 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [132] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (63:2,17 [3] x:\dir\subdir\Test\TestComponent.cshtml) - IntProperty - IntProperty + IntermediateToken - (63:2,17 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 123 + ComponentAttributeExtensionNode - (87:3,18 [4] x:\dir\subdir\Test\TestComponent.cshtml) - BoolProperty - BoolProperty + IntermediateToken - (87:3,18 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true + ComponentAttributeExtensionNode - (114:4,20 [9] x:\dir\subdir\Test\TestComponent.cshtml) - StringProperty - StringProperty + HtmlContent - (114:4,20 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (114:4,20 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - My string + ComponentAttributeExtensionNode - (146:5,20 [14] x:\dir\subdir\Test\TestComponent.cshtml) - ObjectProperty - ObjectProperty + IntermediateToken - (146:5,20 [14] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - new SomeType() diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.mappings.txt new file mode 100644 index 00000000000..c8b0c010013 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (63:2,17 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|123| +Generated Location: (1093:29,17 [3] ) +|123| + +Source Location: (87:3,18 [4] x:\dir\subdir\Test\TestComponent.cshtml) +|true| +Generated Location: (1307:36,18 [4] ) +|true| + +Source Location: (146:5,20 [14] x:\dir\subdir\Test\TestComponent.cshtml) +|new SomeType()| +Generated Location: (1546:44,20 [14] ) +|new SomeType()| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.codegen.cs new file mode 100644 index 00000000000..d6a9b8149c0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + OnClick + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Action OnClick { get; set; } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.ir.txt new file mode 100644 index 00000000000..c745f2e3200 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.ir.txt @@ -0,0 +1,33 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - DynamicElement - Test.DynamicElement + ComponentAttributeExtensionNode - (56:1,25 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (57:1,26 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + HtmlContent - (68:1,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (68:1,37 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (84:3,12 [62] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (84:3,12 [62] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Action OnClick { get; set; }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.mappings.txt new file mode 100644 index 00000000000..4902958cc5b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (57:1,26 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|OnClick| +Generated Location: (1146:29,26 [7] ) +|OnClick| + +Source Location: (84:3,12 [62] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Action OnClick { get; set; } +| +Generated Location: (1465:40,12 [62] ) +| + private Action OnClick { get; set; } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.codegen.cs new file mode 100644 index 00000000000..2aa30acccf1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + "very-cool" + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.ir.txt new file mode 100644 index 00000000000..0068449567f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.ir.txt @@ -0,0 +1,29 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - CoolnessMeter - Test.CoolnessMeter + ComponentAttributeExtensionNode - (56:1,25 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Coolness - Coolness + CSharpExpression - (57:1,26 [13] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:1,27 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "very-cool" + HtmlContent - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (74:1,43 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.mappings.txt new file mode 100644 index 00000000000..2e5b8954288 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (58:1,27 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|"very-cool"| +Generated Location: (1103:29,27 [11] ) +|"very-cool"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs new file mode 100644 index 00000000000..b7cb3a157a2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs @@ -0,0 +1,66 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using Microsoft.AspNetCore.Components; + +#line default +#line hidden + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object TItem1 = null; + } + ))(); + ((System.Action)(() => { +global::System.Object TItem2 = null; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item2 in Items2) +{ + + +#line default +#line hidden +#line 9 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = ChildContent(item2); + +#line default +#line hidden +#line 10 "x:\dir\subdir\Test\TestComponent.cshtml" + +} + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 12 "x:\dir\subdir\Test\TestComponent.cshtml" + + [Parameter] TItem1 Item1 { get; set; } + [Parameter] List Items2 { get; set; } + [Parameter] RenderFragment ChildContent { get; set; } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt new file mode 100644 index 00000000000..e7daa631fa4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt @@ -0,0 +1,46 @@ +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 - (1:0,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (52:1,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem1 + DirectiveToken - (71:2,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem2 + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (39:0,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (39:0,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (79:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (79:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (81:4,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (85:4,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (85:4,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Item1 + HtmlContent - (95:4,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:4,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (98:5,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (98:5,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item2 in Items2)\n{\n + HtmlElement - (136:7,4 [40] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlContent - (139:7,7 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (139:7,7 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (146:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (146:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ChildContent(item2) + HtmlContent - (165:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (165:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + CSharpCode - (176:9,8 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (176:9,8 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n} + HtmlContent - (179:10,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (179:10,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (193:11,12 [164] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (193:11,12 [164] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] TItem1 Item1 { get; set; }\n [Parameter] List Items2 { get; set; }\n [Parameter] RenderFragment ChildContent { get; set; }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt new file mode 100644 index 00000000000..d2ba18a0b05 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt @@ -0,0 +1,49 @@ +Source Location: (1:0,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) +|using Microsoft.AspNetCore.Components;| +Generated Location: (257:10,0 [38] ) +|using Microsoft.AspNetCore.Components;| + +Source Location: (52:1,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TItem1| +Generated Location: (581:19,22 [6] ) +|TItem1| + +Source Location: (71:2,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TItem2| +Generated Location: (679:23,22 [6] ) +|TItem2| + +Source Location: (98:5,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) +|foreach (var item2 in Items2) +{ + | +Generated Location: (1159:36,1 [38] ) +|foreach (var item2 in Items2) +{ + | + +Source Location: (146:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) +|ChildContent(item2)| +Generated Location: (1287:43,6 [19] ) +|ChildContent(item2)| + +Source Location: (176:9,8 [3] x:\dir\subdir\Test\TestComponent.cshtml) +| +}| +Generated Location: (1400:48,8 [3] ) +| +}| + +Source Location: (193:11,12 [164] x:\dir\subdir\Test\TestComponent.cshtml) +| + [Parameter] TItem1 Item1 { get; set; } + [Parameter] List Items2 { get; set; } + [Parameter] RenderFragment ChildContent { get; set; } +| +Generated Location: (1549:56,12 [164] ) +| + [Parameter] TItem1 Item1 { get; set; } + [Parameter] List Items2 { get; set; } + [Parameter] RenderFragment ChildContent { get; set; } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs new file mode 100644 index 00000000000..919a59d52ad --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs @@ -0,0 +1,28 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt new file mode 100644 index 00000000000..bd6aceb1343 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt @@ -0,0 +1,25 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (15:0,15 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (15:0,15 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (17:1,0 [13] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (22:1,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (22:1,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs new file mode 100644 index 00000000000..633fcbe59d7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs @@ -0,0 +1,49 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = ""; + __o = ""; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + myInstance = default(Test.MyComponent); + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt new file mode 100644 index 00000000000..938a29719da --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt @@ -0,0 +1,37 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - - ParamBefore - + HtmlContent - (57:1,26 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (57:1,26 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - before + RefExtensionNode - (70:1,39 [10] x:\dir\subdir\Test\TestComponent.cshtml) - myInstance - Test.MyComponent + ComponentAttributeExtensionNode - - ParamAfter - + HtmlContent - (94:1,63 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (94:1,63 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after + HtmlContent - (103:1,72 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (103:1,72 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (224:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (224:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (119:3,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (119:3,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Test.MyComponent myInstance;\n public void Foo() { System.GC.KeepAlive(myInstance); }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt new file mode 100644 index 00000000000..8a41bd417e2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (70:1,39 [10] x:\dir\subdir\Test\TestComponent.cshtml) +|myInstance| +Generated Location: (1221:33,39 [10] ) +|myInstance| + +Source Location: (119:3,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +| +Generated Location: (1405:40,12 [104] ) +| + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..4622f728a74 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = ""; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + myInstance = default(Test.MyComponent); + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..7817dcfea3e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt @@ -0,0 +1,42 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [96] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (76:1,45 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (76:1,45 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n Some + HtmlElement - (87:2,9 [16] x:\dir\subdir\Test\TestComponent.cshtml) - el + HtmlContent - (91:2,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (91:2,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - further + HtmlContent - (103:2,25 [10] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (103:2,25 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - content\n + RefExtensionNode - (49:1,18 [10] x:\dir\subdir\Test\TestComponent.cshtml) - myInstance - Test.MyComponent + ComponentAttributeExtensionNode - - SomeProp - + HtmlContent - (71:1,40 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:1,40 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - val + HtmlContent - (127:3,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (127:3,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (248:8,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (248:8,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (143:5,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (143:5,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Test.MyComponent myInstance;\n public void Foo() { System.GC.KeepAlive(myInstance); }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..3d1c3b4c7b0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt @@ -0,0 +1,21 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (49:1,18 [10] x:\dir\subdir\Test\TestComponent.cshtml) +|myInstance| +Generated Location: (1177:32,18 [10] ) +|myInstance| + +Source Location: (143:5,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +| +Generated Location: (1361:39,12 [104] ) +| + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs new file mode 100644 index 00000000000..652f5243713 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + myElem = default(Microsoft.AspNetCore.Components.ElementRef); + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Microsoft.AspNetCore.Components.ElementRef myElem; + public void Foo() { System.GC.KeepAlive(myElem); } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt new file mode 100644 index 00000000000..a073fd2d4af --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [79] x:\dir\subdir\Test\TestComponent.cshtml) - elem + HtmlContent - (67:0,67 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (67:0,67 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlAttribute - - attributebefore=" - " + HtmlAttributeValue - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - before + RefExtensionNode - (36:0,36 [6] x:\dir\subdir\Test\TestComponent.cshtml) - myElem - Element + HtmlAttribute - - attributeafter=" - " + HtmlAttributeValue - (60:0,60 [5] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (60:0,60 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after + HtmlContent - (79:0,79 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (79:0,79 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (218:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (218:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (95:2,12 [122] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:2,12 [122] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Microsoft.AspNetCore.Components.ElementRef myElem;\n public void Foo() { System.GC.KeepAlive(myElem); }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt new file mode 100644 index 00000000000..595c999d6fd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (36:0,36 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|myElem| +Generated Location: (904:24,36 [6] ) +|myElem| + +Source Location: (95:2,12 [122] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Microsoft.AspNetCore.Components.ElementRef myElem; + public void Foo() { System.GC.KeepAlive(myElem); } +| +Generated Location: (1110:31,12 [122] ) +| + private Microsoft.AspNetCore.Components.ElementRef myElem; + public void Foo() { System.GC.KeepAlive(myElem); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.codegen.cs new file mode 100644 index 00000000000..b4a0c15da5e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue("alert(\"Test\");"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.ir.txt new file mode 100644 index 00000000000..adc6fd4a10e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.ir.txt @@ -0,0 +1,28 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [34] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [14] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - - CSharp - "alert(\"Test\");" + IntermediateToken - - CSharp - ) + HtmlContent - (34:0,34 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (34:0,34 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..1232e09d7ab --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick(UIEventArgs e) { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..694f284ee00 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + HtmlContent - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (42:1,12 [44] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:1,12 [44] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick(UIEventArgs e) {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..965fd7554ac --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|OnClick| +Generated Location: (950:23,133 [7] ) +|OnClick| + +Source Location: (42:1,12 [44] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick(UIEventArgs e) { + } +| +Generated Location: (1073:27,12 [44] ) +| + void OnClick(UIEventArgs e) { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.codegen.cs new file mode 100644 index 00000000000..6dc4a0750a6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick(UIMouseEventArgs e) { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.ir.txt new file mode 100644 index 00000000000..a29f78db656 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + HtmlContent - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick(UIMouseEventArgs e) {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.mappings.txt new file mode 100644 index 00000000000..0a370a2d5fd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|OnClick| +Generated Location: (950:23,133 [7] ) +|OnClick| + +Source Location: (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick(UIMouseEventArgs e) { + } +| +Generated Location: (1073:27,12 [49] ) +| + void OnClick(UIMouseEventArgs e) { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.codegen.cs new file mode 100644 index 00000000000..c49c3e267f9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(x => { }); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.ir.txt new file mode 100644 index 00000000000..43fa8cb7578 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.ir.txt @@ -0,0 +1,26 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [11] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (18:0,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => { } + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.mappings.txt new file mode 100644 index 00000000000..610f3730a86 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (18:0,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) +|x => { }| +Generated Location: (950:23,133 [8] ) +|x => { }| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..6dc4a0750a6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick(UIMouseEventArgs e) { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..a29f78db656 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + HtmlContent - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick(UIMouseEventArgs e) {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..0a370a2d5fd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|OnClick| +Generated Location: (950:23,133 [7] ) +|OnClick| + +Source Location: (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick(UIMouseEventArgs e) { + } +| +Generated Location: (1073:27,12 [49] ) +| + void OnClick(UIMouseEventArgs e) { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.codegen.cs new file mode 100644 index 00000000000..c49c3e267f9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(x => { }); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.ir.txt new file mode 100644 index 00000000000..43fa8cb7578 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.ir.txt @@ -0,0 +1,26 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [11] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (18:0,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => { } + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.mappings.txt new file mode 100644 index 00000000000..610f3730a86 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (18:0,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) +|x => { }| +Generated Location: (950:23,133 [8] ) +|x => { }| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..b339a6b857f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick() { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..ce1ec8f7592 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + HtmlContent - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (28:0,28 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (42:1,12 [31] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:1,12 [31] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick() {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..f95192d92ed --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) +|OnClick| +Generated Location: (950:23,133 [7] ) +|OnClick| + +Source Location: (42:1,12 [31] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick() { + } +| +Generated Location: (1073:27,12 [31] ) +| + void OnClick() { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.codegen.cs new file mode 100644 index 00000000000..2479d0a29a3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(() => { }); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.ir.txt new file mode 100644 index 00000000000..95e52fa87fb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.ir.txt @@ -0,0 +1,26 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [32] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (18:0,18 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => { } + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.mappings.txt new file mode 100644 index 00000000000..5d5d60fe4c9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (18:0,18 [9] x:\dir\subdir\Test\TestComponent.cshtml) +|() => { }| +Generated Location: (950:23,133 [9] ) +|() => { }| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.codegen.cs new file mode 100644 index 00000000000..87a6b631f7b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue("foo"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.ir.txt new file mode 100644 index 00000000000..4cd6780e073 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.ir.txt @@ -0,0 +1,26 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [23] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - - CSharp - "foo" + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs new file mode 100644 index 00000000000..b545b347136 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs @@ -0,0 +1,61 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = typeof( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + int + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + 3 + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + _my = default(Test.MyComponent); + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt new file mode 100644 index 00000000000..af3f05c9cbf --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt @@ -0,0 +1,35 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [44] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int + ComponentAttributeExtensionNode - (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + IntermediateToken - (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3 + RefExtensionNode - (68:1,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my - Test.MyComponent + HtmlContent - (75:1,44 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (75:1,44 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (182:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (182:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt new file mode 100644 index 00000000000..0a61d8b69bc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt @@ -0,0 +1,31 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|int| +Generated Location: (1031:29,19 [3] ) +|int| + +Source Location: (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|3| +Generated Location: (1245:36,29 [1] ) +|3| + +Source Location: (68:1,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|_my| +Generated Location: (1534:45,37 [3] ) +|_my| + +Source Location: (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) +| + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +| +Generated Location: (1716:52,12 [90] ) +| + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..eba8acca987 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,67 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, -1, -1, +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + 3 + +#line default +#line hidden + , -1, (__value) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + _my = __value; + +#line default +#line hidden + } + ); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } + +#line default +#line hidden + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action> __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent)__value); }); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..6cd775d303f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [34] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + IntermediateToken - (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3 + RefExtensionNode - (58:1,27 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my - global::Test.MyComponent + HtmlContent - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (172:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (172:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..870211d4c5e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,26 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|3| +Generated Location: (1097:29,19 [1] ) +|3| + +Source Location: (58:1,27 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|_my| +Generated Location: (1243:35,27 [3] ) +|_my| + +Source Location: (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) +| + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +| +Generated Location: (1433:44,12 [90] ) +| + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..06575bce03b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = "My value"; + +#line default +#line hidden + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..1e3e6ce8938 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/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 - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpExpression - (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "My value" + HtmlContent - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlElement - (17:2,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt new file mode 100644 index 00000000000..e4acf4e91b6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) +|"My value"| +Generated Location: (874:24,6 [10] ) +|"My value"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..3c8fef10742 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..b0631390092 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt @@ -0,0 +1,29 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [7] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n \n + ComponentExtensionNode - (36:2,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent - Test.SomeOtherComponent + HtmlContent - (58:2,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:2,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlElement - (62:4,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (66:4,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (66:4,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt new file mode 100644 index 00000000000..3917573adf7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs new file mode 100644 index 00000000000..d23ff3765d3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using System; + +#line default +#line hidden + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt new file mode 100644 index 00000000000..c2f340ba5b2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt @@ -0,0 +1,25 @@ +Document - + NamespaceDeclaration - - Test + 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 + UsingDirective - (1:0,1 [12] x:\dir\subdir\Test\TestComponent.cshtml) - System + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlElement - (17:2,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.mappings.txt new file mode 100644 index 00000000000..ae847626d3e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (1:0,1 [12] x:\dir\subdir\Test\TestComponent.cshtml) +|using System| +Generated Location: (282:10,0 [12] ) +|using System| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..69a65f5ce1d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddAttribute(-1, "Header", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + builder.AddAttribute(-1, "Footer", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = "bye!"; + +#line default +#line hidden + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..9cc23593bb0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [87] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (50:2,4 [20] x:\dir\subdir\Test\TestComponent.cshtml) - Header + HtmlContent - (58:2,12 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:2,12 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hi! + ComponentChildContent - (76:3,4 [26] x:\dir\subdir\Test\TestComponent.cshtml) - Footer + CSharpExpression - (86:3,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:3,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "bye!" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..cedac6119b7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (86:3,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|"bye!"| +Generated Location: (1257:32,14 [6] ) +|"bye!"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..a95a14e77e2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs @@ -0,0 +1,64 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment template = (context) => + +#line default +#line hidden + (builder2) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context.Index; + +#line default +#line hidden +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = context.Item.ToLower(); + +#line default +#line hidden + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + __o = new Microsoft.AspNetCore.Components.RenderFragment( +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + template + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.ir.txt new file mode 100644 index 00000000000..5c76c02ce5d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.ir.txt @@ -0,0 +1,43 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) - "*, TestAssembly" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (35:1,2 [54] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [54] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment template = (context) => + Template - (90:1,57 [48] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (90:1,57 [50] x:\dir\subdir\Test\TestComponent.cshtml) - li + HtmlContent - (94:1,61 [1] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (94:1,61 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - # + CSharpExpression - (96:1,63 [13] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (96:1,63 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Index + HtmlContent - (109:1,76 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (109:1,76 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \- + CSharpExpression - (113:1,80 [22] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (113:1,80 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Item.ToLower() + CSharpCode - (140:1,107 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (140:1,107 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (145:2,0 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (168:2,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Template - Template + CSharpExpression - (169:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (169:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template + HtmlContent - (180:2,35 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (180:2,35 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..b518bb32e86 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt @@ -0,0 +1,30 @@ +Source Location: (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|"*, TestAssembly"| +Generated Location: (502:15,37 [17] ) +|"*, TestAssembly"| + +Source Location: (35:1,2 [54] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment template = (context) => | +Generated Location: (987:28,2 [54] ) +| RenderFragment template = (context) => | + +Source Location: (96:1,63 [13] x:\dir\subdir\Test\TestComponent.cshtml) +|context.Index| +Generated Location: (1217:34,63 [13] ) +|context.Index| + +Source Location: (113:1,80 [22] x:\dir\subdir\Test\TestComponent.cshtml) +|context.Item.ToLower()| +Generated Location: (1395:39,80 [22] ) +|context.Item.ToLower()| + +Source Location: (140:1,107 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (1624:45,107 [2] ) +|; | + +Source Location: (169:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml) +|template| +Generated Location: (1819:51,24 [8] ) +|template| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..64b2cd0629b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.codegen.cs @@ -0,0 +1,64 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + RenderFragment p = (person) => + +#line default +#line hidden + (builder2) => { + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + person.Name + +#line default +#line hidden + ); + builder2.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder3) => { + } + )); + } +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..6618985236a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.ir.txt @@ -0,0 +1,35 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) - "*, TestAssembly" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment p = (person) => + Template - (81:2,44 [45] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (81:2,44 [45] x:\dir\subdir\Test\TestComponent.cshtml) - div + ComponentExtensionNode - (86:2,49 [34] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (105:2,68 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Name - Name + CSharpExpression - (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + CSharpCode - (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n + CSharpCode - (144:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (144:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.mappings.txt new file mode 100644 index 00000000000..2617c56e676 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.mappings.txt @@ -0,0 +1,39 @@ +Source Location: (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|"*, TestAssembly"| +Generated Location: (502:15,37 [17] ) +|"*, TestAssembly"| + +Source Location: (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) +| + RenderFragment p = (person) => | +Generated Location: (987:28,2 [45] ) +| + RenderFragment p = (person) => | + +Source Location: (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|person.Name| +Generated Location: (1310:36,69 [11] ) +|person.Name| + +Source Location: (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|; +| +Generated Location: (1693:46,89 [3] ) +|; +| + +Source Location: (144:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } +| +Generated Location: (1839:53,12 [76] ) +| + class Person + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..dbbb8065b5b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs @@ -0,0 +1,72 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + RenderFragment p = (person) => + +#line default +#line hidden + (builder2) => { + __o = Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck( +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + person.Name + +#line default +#line hidden + ); + builder2.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder3) => { + } + )); + } +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = "hello, world!"; + +#line default +#line hidden + } + )); + } + #pragma warning restore 1998 +#line 9 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..4674bf0e0e4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt @@ -0,0 +1,45 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) - "*, TestAssembly" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment p = (person) => + Template - (81:2,44 [45] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (81:2,44 [45] x:\dir\subdir\Test\TestComponent.cshtml) - div + ComponentExtensionNode - (86:2,49 [34] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (105:2,68 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Name - Name + CSharpExpression - (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + CSharpCode - (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n + ComponentExtensionNode - (132:4,0 [49] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (145:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (145:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (149:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (149:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hello, world!" + HtmlContent - (165:5,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (165:5,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (181:6,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (181:6,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpCode - (197:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (197:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt new file mode 100644 index 00000000000..dea3d8428f0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt @@ -0,0 +1,44 @@ +Source Location: (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|"*, TestAssembly"| +Generated Location: (502:15,37 [17] ) +|"*, TestAssembly"| + +Source Location: (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) +| + RenderFragment p = (person) => | +Generated Location: (987:28,2 [45] ) +| + RenderFragment p = (person) => | + +Source Location: (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|person.Name| +Generated Location: (1310:36,69 [11] ) +|person.Name| + +Source Location: (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|; +| +Generated Location: (1693:46,89 [3] ) +|; +| + +Source Location: (149:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|"hello, world!"| +Generated Location: (1903:52,6 [15] ) +|"hello, world!"| + +Source Location: (197:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } +| +Generated Location: (2096:61,12 [76] ) +| + class Person + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs new file mode 100644 index 00000000000..1c2e655a88d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs @@ -0,0 +1,59 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment template = (person) => + +#line default +#line hidden + (builder2) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = person.Name; + +#line default +#line hidden + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + __o = new Microsoft.AspNetCore.Components.RenderFragment( +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + template + +#line default +#line hidden + ); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.ir.txt new file mode 100644 index 00000000000..0b2d2a7eef3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.ir.txt @@ -0,0 +1,37 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) - "*, TestAssembly" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (35:1,2 [47] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [47] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment template = (person) => + Template - (83:1,50 [22] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (83:1,50 [23] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (89:1,56 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (89:1,56 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + CSharpCode - (106:1,73 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (106:1,73 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (111:2,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (140:2,29 [9] x:\dir\subdir\Test\TestComponent.cshtml) - PersonTemplate - PersonTemplate + CSharpExpression - (141:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (141:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template + HtmlContent - (152:2,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (152:2,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt new file mode 100644 index 00000000000..83d796d9831 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt @@ -0,0 +1,25 @@ +Source Location: (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|"*, TestAssembly"| +Generated Location: (502:15,37 [17] ) +|"*, TestAssembly"| + +Source Location: (35:1,2 [47] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment template = (person) => | +Generated Location: (987:28,2 [47] ) +| RenderFragment template = (person) => | + +Source Location: (89:1,56 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|person.Name| +Generated Location: (1203:34,56 [11] ) +|person.Name| + +Source Location: (106:1,73 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (1387:40,73 [2] ) +|; | + +Source Location: (141:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml) +|template| +Generated Location: (1587:46,30 [8] ) +|template| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..fe3b5a38c93 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.codegen.cs @@ -0,0 +1,51 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = RenderPerson((person) => (builder2) => { +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = person.Name; + +#line default +#line hidden +} +); + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..04ddbdf5e32 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.ir.txt @@ -0,0 +1,31 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpExpression - (1:0,1 [48] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (1:0,1 [25] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson((person) => + Template - (27:0,27 [22] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (27:0,27 [23] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (33:0,33 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (33:0,33 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + IntermediateToken - (50:0,50 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ) + HtmlContent - (51:0,51 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (51:0,51 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (65:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (65:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n\n object RenderPerson(RenderFragment p) => null;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.mappings.txt new file mode 100644 index 00000000000..b37981c1a80 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.mappings.txt @@ -0,0 +1,34 @@ +Source Location: (1:0,1 [25] x:\dir\subdir\Test\TestComponent.cshtml) +|RenderPerson((person) => | +Generated Location: (874:24,6 [25] ) +|RenderPerson((person) => | + +Source Location: (33:0,33 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|person.Name| +Generated Location: (1000:26,33 [11] ) +|person.Name| + +Source Location: (50:0,50 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|)| +Generated Location: (1048:31,0 [1] ) +|)| + +Source Location: (65:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +| +Generated Location: (1195:38,12 [138] ) +| + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.codegen.cs new file mode 100644 index 00000000000..1a513d9bfee --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.codegen.cs @@ -0,0 +1,55 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + + RenderFragment p = (person) => + +#line default +#line hidden + (builder2) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = person.Name; + +#line default +#line hidden + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.ir.txt new file mode 100644 index 00000000000..d04fb1ffca0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpCode - (2:0,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (2:0,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment p = (person) => + Template - (48:1,44 [22] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (48:1,44 [23] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (54:1,50 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (54:1,50 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + CSharpCode - (71:1,67 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:1,67 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n + CSharpCode - (89:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (89:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.mappings.txt new file mode 100644 index 00000000000..b9045e5bb75 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.mappings.txt @@ -0,0 +1,34 @@ +Source Location: (2:0,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) +| + RenderFragment p = (person) => | +Generated Location: (870:24,2 [45] ) +| + RenderFragment p = (person) => | + +Source Location: (54:1,50 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|person.Name| +Generated Location: (1078:31,50 [11] ) +|person.Name| + +Source Location: (71:1,67 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|; +| +Generated Location: (1256:37,67 [3] ) +|; +| + +Source Location: (89:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } +| +Generated Location: (1402:44,12 [76] ) +| + class Person + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..0da3a367fff --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.codegen.cs @@ -0,0 +1,51 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = RenderPerson((person) => (builder2) => { +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = person.Name; + +#line default +#line hidden +} +); + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..abc67e57153 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.ir.txt @@ -0,0 +1,31 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpExpression - (2:0,2 [48] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (2:0,2 [25] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson((person) => + Template - (28:0,28 [22] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (28:0,28 [23] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (34:0,34 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (34:0,34 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + IntermediateToken - (51:0,51 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ) + HtmlContent - (53:0,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (53:0,53 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (67:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (67:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n\n object RenderPerson(RenderFragment p) => null;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.mappings.txt new file mode 100644 index 00000000000..c11ce14a082 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.mappings.txt @@ -0,0 +1,34 @@ +Source Location: (2:0,2 [25] x:\dir\subdir\Test\TestComponent.cshtml) +|RenderPerson((person) => | +Generated Location: (874:24,6 [25] ) +|RenderPerson((person) => | + +Source Location: (34:0,34 [11] x:\dir\subdir\Test\TestComponent.cshtml) +|person.Name| +Generated Location: (1001:26,34 [11] ) +|person.Name| + +Source Location: (51:0,51 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|)| +Generated Location: (1049:31,0 [1] ) +|)| + +Source Location: (67:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +| +Generated Location: (1196:38,12 [138] ) +| + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.codegen.cs new file mode 100644 index 00000000000..a9dfa2f0644 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.codegen.cs @@ -0,0 +1,54 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment template = + +#line default +#line hidden + (builder2) => { + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + __o = +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + template + +#line default +#line hidden + ; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.ir.txt new file mode 100644 index 00000000000..ce6182b349f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.ir.txt @@ -0,0 +1,37 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) - "*, TestAssembly" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:0,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (35:1,2 [27] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [27] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment template = + Template - (63:1,30 [15] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (63:1,30 [15] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (68:1,35 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (68:1,35 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Joey + CSharpCode - (78:1,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (78:1,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (83:2,0 [33] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - - Person - + CSharpExpression - (104:2,21 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (105:2,22 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template + HtmlContent - (116:2,33 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (116:2,33 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.mappings.txt new file mode 100644 index 00000000000..4d643995838 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.mappings.txt @@ -0,0 +1,20 @@ +Source Location: (14:0,14 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|"*, TestAssembly"| +Generated Location: (502:15,37 [17] ) +|"*, TestAssembly"| + +Source Location: (35:1,2 [27] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment template = | +Generated Location: (987:28,2 [27] ) +| RenderFragment template = | + +Source Location: (78:1,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (1187:35,45 [2] ) +|; | + +Source Location: (105:2,22 [8] x:\dir\subdir\Test\TestComponent.cshtml) +|template| +Generated Location: (1315:41,22 [8] ) +|template| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..aef14271303 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = RenderPerson((builder2) => { +} +); + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + object RenderPerson(RenderFragment p) => null; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..99a41a79498 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.ir.txt @@ -0,0 +1,31 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpExpression - (1:0,1 [27] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (1:0,1 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson( + Template - (15:0,15 [13] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (15:0,15 [13] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (20:0,20 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (20:0,20 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - HI + IntermediateToken - (28:0,28 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ) + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (43:1,12 [54] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (43:1,12 [54] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n object RenderPerson(RenderFragment p) => null;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.mappings.txt new file mode 100644 index 00000000000..53fef3eae5f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (1:0,1 [13] x:\dir\subdir\Test\TestComponent.cshtml) +|RenderPerson(| +Generated Location: (874:24,6 [13] ) +|RenderPerson(| + +Source Location: (28:0,28 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|)| +Generated Location: (907:26,0 [1] ) +|)| + +Source Location: (43:1,12 [54] x:\dir\subdir\Test\TestComponent.cshtml) +| + object RenderPerson(RenderFragment p) => null; +| +Generated Location: (1054:33,12 [54] ) +| + object RenderPerson(RenderFragment p) => null; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.codegen.cs new file mode 100644 index 00000000000..866e1f96c67 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.codegen.cs @@ -0,0 +1,49 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + y + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => y = __value, y); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string y = null; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.ir.txt new file mode 100644 index 00000000000..bd039a21c96 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.ir.txt @@ -0,0 +1,38 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - Counter - Test.Counter + ComponentAttributeExtensionNode - (48:1,17 [1] x:\dir\subdir\Test\TestComponent.cshtml) - v - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (48:1,17 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - y + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (48:1,17 [1] x:\dir\subdir\Test\TestComponent.cshtml) - vChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => y = __value, y) + HtmlContent - (53:1,22 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (53:1,22 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (92:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (92:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (67:2,12 [24] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (67:2,12 [24] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string y = null;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.mappings.txt new file mode 100644 index 00000000000..b04372471af --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_597/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (48:1,17 [1] x:\dir\subdir\Test\TestComponent.cshtml) +|y| +Generated Location: (1075:29,17 [1] ) +|y| + +Source Location: (67:2,12 [24] x:\dir\subdir\Test\TestComponent.cshtml) +| + string y = null; +| +Generated Location: (1495:41,12 [24] ) +| + string y = null; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.codegen.cs new file mode 100644 index 00000000000..825aae87ed1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.codegen.cs @@ -0,0 +1,58 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + UserName + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => UserName = __value, UserName); + __o = Microsoft.AspNetCore.Components.BindMethods.GetValue( +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + UserIsActive + +#line default +#line hidden + ); + __o = Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => UserIsActive = __value, UserIsActive); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string UserName { get; set; } + public bool UserIsActive { get; set; } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.ir.txt new file mode 100644 index 00000000000..762f8737ea5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.ir.txt @@ -0,0 +1,46 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (31:1,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - User - Test.User + ComponentAttributeExtensionNode - (48:1,17 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Name - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (49:1,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserName + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (48:1,17 [9] x:\dir\subdir\Test\TestComponent.cshtml) - NameChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => UserName = __value, UserName) + ComponentAttributeExtensionNode - (74:1,43 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActive - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (75:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserIsActive + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (74:1,43 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActiveChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => UserIsActive = __value, UserIsActive) + HtmlContent - (91:1,60 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (91:1,60 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (196:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (196:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string UserName { get; set; }\n public bool UserIsActive { get; set; }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.mappings.txt new file mode 100644 index 00000000000..d01e84b9086 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_609/TestComponent.mappings.txt @@ -0,0 +1,26 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + +Source Location: (49:1,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) +|UserName| +Generated Location: (1076:29,18 [8] ) +|UserName| + +Source Location: (75:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml) +|UserIsActive| +Generated Location: (1422:37,44 [12] ) +|UserIsActive| + +Source Location: (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string UserName { get; set; } + public bool UserIsActive { get; set; } +| +Generated Location: (1875:49,12 [88] ) +| + public string UserName { get; set; } + public bool UserIsActive { get; set; } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.codegen.cs new file mode 100644 index 00000000000..4f3db087b45 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#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; + [Microsoft.AspNetCore.Components.RouteAttribute("/")] + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + ((System.Action)(() => { +global::System.Object __typeHelper = "/"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = ""; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.diagnostics.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..57b2bc79491 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.cshtml(8,2): Error RZ1035: Missing close angle for tag helper 'SurveyPrompt'. +x:\dir\subdir\Test\TestComponent.cshtml(8,2): Error RZ1034: Found a malformed 'SurveyPrompt' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.ir.txt new file mode 100644 index 00000000000..37b5fb19ada --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.ir.txt @@ -0,0 +1,36 @@ +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 + RouteAttributeExtensionNode - - / + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + DirectiveToken - (37:1,6 [3] x:\dir\subdir\Test\TestComponent.cshtml) - "/" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (42:2,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:2,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (44:3,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (48:3,4 [13] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (48:3,4 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello, world! + HtmlContent - (66:3,22 [32] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (66:3,22 [32] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\nWelcome to your new app.\n\n + ComponentExtensionNode - (98:7,0 [23] x:\dir\subdir\Test\TestComponent.cshtml) - SurveyPrompt - Test.SurveyPrompt + ComponentAttributeExtensionNode - (119:7,21 [0] x:\dir\subdir\Test\TestComponent.cshtml) - Title - Title + HtmlContent - (119:7,21 [0] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (119:7,21 [0] x:\dir\subdir\Test\TestComponent.cshtml) - Html - diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.mappings.txt new file mode 100644 index 00000000000..a9b5edf72a8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_772/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (562:16,38 [15] ) +|*, TestAssembly| + +Source Location: (37:1,6 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|"/"| +Generated Location: (678:20,37 [3] ) +|"/"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_773/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_773/TestComponent.codegen.cs new file mode 100644 index 00000000000..4f3db087b45 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_773/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#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; + [Microsoft.AspNetCore.Components.RouteAttribute("/")] + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + ((System.Action)(() => { +global::System.Object __typeHelper = "/"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = ""; + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_773/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_773/TestComponent.ir.txt new file mode 100644 index 00000000000..8e11bee99ae --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_773/TestComponent.ir.txt @@ -0,0 +1,38 @@ +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 + RouteAttributeExtensionNode - - / + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + DirectiveToken - (37:1,6 [3] x:\dir\subdir\Test\TestComponent.cshtml) - "/" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (42:2,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:2,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (44:3,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (48:3,4 [13] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (48:3,4 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello, world! + HtmlContent - (66:3,22 [32] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (66:3,22 [32] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\nWelcome to your new app.\n\n + ComponentExtensionNode - (98:7,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - SurveyPrompt - Test.SurveyPrompt + ComponentAttributeExtensionNode - (119:7,21 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Title - Title + HtmlContent - (119:7,21 [16] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (119:7,21 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Html -
    Test!
    + HtmlContent - (139:7,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (139:7,41 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_773/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_773/TestComponent.mappings.txt new file mode 100644 index 00000000000..a9b5edf72a8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_773/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (562:16,38 [15] ) +|*, TestAssembly| + +Source Location: (37:1,6 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|"/"| +Generated Location: (678:20,37 [3] ) +|"/"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_784/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_784/TestComponent.codegen.cs new file mode 100644 index 00000000000..e27aca9ed6b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_784/TestComponent.codegen.cs @@ -0,0 +1,44 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __o = Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnComponentHover); +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + __o = ParentBgColor; + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentBgColor { get; set; } = "#FFFFFF"; + + public void OnComponentHover(UIMouseEventArgs e) + { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_784/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_784/TestComponent.ir.txt new file mode 100644 index 00000000000..f05985b010f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_784/TestComponent.ir.txt @@ -0,0 +1,39 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [73] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlAttribute - (16:0,16 [17] x:\dir\subdir\Test\TestComponent.cshtml) - onmouseover=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [16] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnComponentHover + IntermediateToken - - CSharp - ) + HtmlAttribute - - style=" - " + HtmlAttributeValue - (42:0,42 [11] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (42:0,42 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - background: + CSharpExpressionAttributeValue - (53:0,53 [15] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (55:0,55 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentBgColor + HtmlAttributeValue - (68:0,68 [1] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (68:0,68 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ; + HtmlContent - (73:0,73 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (73:0,73 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (220:7,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (220:7,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (87:1,12 [132] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (87:1,12 [132] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentBgColor { get; set; } = "#FFFFFF";\n\n public void OnComponentHover(UIMouseEventArgs e)\n {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_784/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_784/TestComponent.mappings.txt new file mode 100644 index 00000000000..dfe4ea339ca --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Regression_784/TestComponent.mappings.txt @@ -0,0 +1,27 @@ +Source Location: (17:0,17 [16] x:\dir\subdir\Test\TestComponent.cshtml) +|OnComponentHover| +Generated Location: (950:23,133 [16] ) +|OnComponentHover| + +Source Location: (55:0,55 [13] x:\dir\subdir\Test\TestComponent.cshtml) +|ParentBgColor| +Generated Location: (1076:25,55 [13] ) +|ParentBgColor| + +Source Location: (87:1,12 [132] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentBgColor { get; set; } = "#FFFFFF"; + + public void OnComponentHover(UIMouseEventArgs e) + { + } +| +Generated Location: (1235:32,12 [132] ) +| + public string ParentBgColor { get; set; } = "#FFFFFF"; + + public void OnComponentHover(UIMouseEventArgs e) + { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs new file mode 100644 index 00000000000..919a59d52ad --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs @@ -0,0 +1,28 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt new file mode 100644 index 00000000000..50d67b6e070 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt @@ -0,0 +1,36 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [144] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (5:0,5 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (5:0,5 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (11:1,4 [125] x:\dir\subdir\Test\TestComponent.cshtml) - script + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - some/url.js + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - + HtmlContent - (78:1,71 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (78:1,71 [49] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n some text\n some more text\n + HtmlContent - (136:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (136:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (144:5,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (144:5,6 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..a041c175f6b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = "My value"; + +#line default +#line hidden + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..e35b51185fd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt @@ -0,0 +1,29 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlContent - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + CSharpExpression - (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "My value" + HtmlContent - (31:2,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (31:2,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt new file mode 100644 index 00000000000..1184d613a7e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) +|"My value"| +Generated Location: (874:24,6 [10] ) +|"My value"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..3c8fef10742 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "*, TestAssembly"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + } + )); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..f837db0a997 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.ir.txt @@ -0,0 +1,31 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (31:1,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (35:1,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlContent - (45:1,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (45:1,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + ComponentExtensionNode - (49:3,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent - Test.SomeOtherComponent + HtmlContent - (71:3,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:3,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.mappings.txt new file mode 100644 index 00000000000..3917573adf7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) +|*, TestAssembly| +Generated Location: (503:15,38 [15] ) +|*, TestAssembly| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs new file mode 100644 index 00000000000..138dcf99f75 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#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; + [Microsoft.AspNetCore.Components.RouteAttribute("/my/url")] + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +global::System.Object __typeHelper = "/my/url"; + } + ))(); + } + #pragma warning restore 219 + #pragma warning disable 0414 + private static System.Object __o = null; + #pragma warning restore 0414 + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.ir.txt new file mode 100644 index 00000000000..d220046235f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 + RouteAttributeExtensionNode - - /my/url + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + DesignTimeDirective - + DirectiveToken - (14:0,14 [36] ) - "*, Microsoft.AspNetCore.Components" + DirectiveToken - (14:0,14 [9] ) - "*, Test" + DirectiveToken - (24:2,6 [9] x:\dir\subdir\Test\TestComponent.cshtml) - "/my/url" + 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 + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlContent - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlContent - (35:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.mappings.txt new file mode 100644 index 00000000000..1b7602da300 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.mappings.txt @@ -0,0 +1,5 @@ +Source Location: (24:2,6 [9] x:\dir\subdir\Test\TestComponent.cshtml) +|"/my/url"| +Generated Location: (567:16,37 [9] ) +|"/my/url"| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentIntegrationTest/BasicTest.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentIntegrationTest/BasicTest.codegen.cs index 5bb5e8d04de..44f3f21a659 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentIntegrationTest/BasicTest.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentIntegrationTest/BasicTest.codegen.cs @@ -6,7 +6,7 @@ namespace AspNetCore { #line hidden [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"47f616cdc7ec75674c74246619b0e6118ef227e4", @"/TestFiles/IntegrationTests/ComponentIntegrationTest/BasicTest.razor")] - public sealed class BasicTest : global::Microsoft.AspNetCore.Components.Component + public sealed class BasicTest : global::Microsoft.AspNetCore.Components.ComponentBase { #pragma warning disable 1998 public override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentIntegrationTest/BasicTest.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentIntegrationTest/BasicTest.ir.txt index 772f3c1327f..41611b36bb3 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentIntegrationTest/BasicTest.ir.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentIntegrationTest/BasicTest.ir.txt @@ -2,7 +2,7 @@ Document - RazorCompiledItemAttribute - NamespaceDeclaration - - AspNetCore RazorSourceChecksumAttribute - - ClassDeclaration - - public sealed - BasicTest - global::Microsoft.AspNetCore.Components.Component - + ClassDeclaration - - public sealed - BasicTest - global::Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - public override - void - BuildRenderTree CSharpCode - IntermediateToken - - CSharp - base.BuildRenderTree(builder); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.codegen.cs new file mode 100644 index 00000000000..73343054077 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/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 Microsoft.AspNetCore.Components; + using System.Threading.Tasks; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue("async (e) => await Task.Delay(10)")); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.ir.txt new file mode 100644 index 00000000000..98688cef847 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_Lambda/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [30] x:\dir\subdir\Test\TestComponent.cshtml) - System.Threading.Tasks + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [53] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (47:1,16 [33] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - - CSharp - "async (e) => await Task.Delay(10)" + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..ee72b453c75 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using Microsoft.AspNetCore.Components; + using System.Threading.Tasks; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + Task OnClick(UIMouseEventArgs e) + { + return Task.CompletedTask; + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..b24c7a572d8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [30] x:\dir\subdir\Test\TestComponent.cshtml) - System.Threading.Tasks + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (47:1,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (48:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + CSharpCode - (73:2,12 [91] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (73:2,12 [91] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n Task OnClick(UIMouseEventArgs e) \n {\n return Task.CompletedTask;\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..5bada6842b8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (73:2,12 [91] x:\dir\subdir\Test\TestComponent.cshtml) +| + Task OnClick(UIMouseEventArgs e) + { + return Task.CompletedTask; + } +| +Generated Location: (918:22,12 [91] ) +| + Task OnClick(UIMouseEventArgs e) + { + return Task.CompletedTask; + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.codegen.cs new file mode 100644 index 00000000000..73343054077 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/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 Microsoft.AspNetCore.Components; + using System.Threading.Tasks; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue("async (e) => await Task.Delay(10)")); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.ir.txt new file mode 100644 index 00000000000..98688cef847 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_Lambda/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [30] x:\dir\subdir\Test\TestComponent.cshtml) - System.Threading.Tasks + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [53] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (47:1,16 [33] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - - CSharp - "async (e) => await Task.Delay(10)" + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..66065b377c9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using Microsoft.AspNetCore.Components; + using System.Threading.Tasks; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + Task OnClick() + { + return Task.CompletedTask; + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..b1f0a37924e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + UsingDirective - (1:0,1 [30] x:\dir\subdir\Test\TestComponent.cshtml) - System.Threading.Tasks + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (47:1,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (48:1,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + CSharpCode - (73:2,12 [73] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (73:2,12 [73] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n Task OnClick() \n {\n return Task.CompletedTask;\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..f459f65370d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/AsyncEventHandler_OnElement_Action_MethodGroup/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (73:2,12 [73] x:\dir\subdir\Test\TestComponent.cshtml) +| + Task OnClick() + { + return Task.CompletedTask; + } +| +Generated Location: (918:22,12 [73] ) +| + Task OnClick() + { + return Task.CompletedTask; + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..1024358967b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "Value", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue))); + builder.AddAttribute(2, "OnChanged", new System.Action(__value => ParentValue = __value)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..828e856cc5d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [50] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - OnChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + CSharpCode - (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..39e53751760 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1061:23,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..e7807b0bac2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "Value", Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue)); + builder.AddAttribute(2, "OnChanged", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..8381d3fa927 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [50] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (66:1,35 [11] x:\dir\subdir\Test\TestComponent.cshtml) - OnChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + CSharpCode - (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..33a43a37f39 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (95:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1030:23,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..5a8c21bf6de --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "Value", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue))); + builder.AddAttribute(2, "ValueChanged", new System.Action(__value => ParentValue = __value)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..fe38f2c035d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [40] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + CSharpCode - (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..ab302becd2b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1064:23,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..c444fed0d02 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "Value", Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue)); + builder.AddAttribute(2, "ValueChanged", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..27e972b7bfe --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [40] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + CSharpCode - (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..791d24c7dc5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_SpecifiesValue_WithoutMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (85:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1033:23,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs new file mode 100644 index 00000000000..bb98cf18899 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "Value", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue))); + builder.AddAttribute(2, "ValueChanged", new System.Action(__value => ParentValue = __value)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "42"; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.ir.txt new file mode 100644 index 00000000000..c1dbbf46351 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [40] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (56:1,25 [11] x:\dir\subdir\Test\TestComponent.cshtml) - ValueChanged - ValueChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => ParentValue = __value + CSharpCode - (85:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (85:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "42";\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt new file mode 100644 index 00000000000..2504e46ac70 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToComponent_TypeChecked_WithMatchingProperties/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (85:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "42"; +| +Generated Location: (1064:23,12 [55] ) +| + public string ParentValue { get; set; } = "42"; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..f12516fd5ee --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "type", "text"); + builder.AddAttribute(2, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue(CurrentDate, "MM/dd")); + builder.AddAttribute(3, "onchange", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, "MM/dd")); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..6db3eedcb54 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,27 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (71:1,40 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (72:1,41 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - "MM/dd" + IntermediateToken - - CSharp - ) + HtmlAttribute - (71:1,40 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, "MM/dd") + CSharpCode - (122:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (122:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..d1cbd5da554 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WithFormat_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (122:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +| +Generated Location: (1088:24,12 [77] ) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..c46a006cef5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "type", "text"); + builder.AddAttribute(2, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue)); + builder.AddAttribute(3, "onchange", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..d2f4a5ac3de --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,25 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [56] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (71:1,40 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (72:1,41 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (71:1,40 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + CSharpCode - (101:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (101:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..2aff49febce --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementFallback_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (101:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1070:24,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..29f0c99c5d7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "myvalue", Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue)); + builder.AddAttribute(2, "myevent", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..55cbf4c344b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [33] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (48:1,17 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (49:1,18 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (48:1,17 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + CSharpCode - (78:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (78:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..babd720e357 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElementWithSuffix_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (78:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; +| +Generated Location: (1015:23,12 [55] ) +| + public string ParentValue { get; set; } = "hi"; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..29f0c99c5d7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "myvalue", Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue)); + builder.AddAttribute(2, "myevent", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentValue { get; set; } = "hi"; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..22ff3383df2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [27] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlAttribute - (42:1,11 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myvalue=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (43:1,12 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (42:1,11 [12] x:\dir\subdir\Test\TestComponent.cshtml) - myevent=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + CSharpCode - (72:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentValue { get; set; } = "hi";\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..c8ff92005e8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BindToElement_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (72:2,12 [55] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentValue { get; set; } = "hi"; +| +Generated Location: (1015:23,12 [55] ) +| + public string ParentValue { get; set; } = "hi"; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..0213a46786b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment header = (context) => + +#line default +#line hidden + (builder2) => { + builder2.OpenElement(0, "div"); + builder2.AddContent(1, context.ToLowerInvariant()); + builder2.CloseElement(); + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + builder.OpenComponent(2); + builder.AddAttribute(3, "Header", new Microsoft.AspNetCore.Components.RenderFragment(header)); + builder.AddAttribute(4, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddContent(5, "\n Some Content\n"); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..15c209e72c8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.ir.txt @@ -0,0 +1,26 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpCode - (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment header = (context) => + Template - (80:1,49 [37] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (80:1,49 [38] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLowerInvariant() + CSharpCode - (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (123:2,0 [62] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (151:2,28 [20] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (151:2,28 [20] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n Some Content\n + ComponentAttributeExtensionNode - (143:2,20 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Header - Header + CSharpExpression - (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - header diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..5e6eb01dfa7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndAttributeChildContent/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment header = (context) => | +Generated Location: (602:17,2 [46] ) +| RenderFragment header = (context) => | + +Source Location: (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (1023:27,87 [2] ) +|; | + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..0de09fc2a28 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.codegen.cs @@ -0,0 +1,47 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment header = (context) => + +#line default +#line hidden + (builder2) => { + builder2.OpenElement(0, "div"); + builder2.AddContent(1, context.ToLowerInvariant()); + builder2.CloseElement(); + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + builder.OpenComponent(2); + builder.AddAttribute(3, "Header", new Microsoft.AspNetCore.Components.RenderFragment(header)); + builder.AddAttribute(4, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddContent(5, "Some Content"); + } + )); + builder.AddAttribute(6, "Footer", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddContent(7, "Bye!"); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..dd0662b6824 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.ir.txt @@ -0,0 +1,29 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpCode - (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment header = (context) => + Template - (80:1,49 [37] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (80:1,49 [38] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:1,55 [26] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLowerInvariant() + CSharpCode - (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (123:2,0 [114] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (155:3,2 [41] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlContent - (169:3,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (169:3,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Some Content + ComponentChildContent - (200:4,2 [21] x:\dir\subdir\Test\TestComponent.cshtml) - Footer + HtmlContent - (208:4,10 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (208:4,10 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Bye! + ComponentAttributeExtensionNode - (143:2,20 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Header - Header + CSharpExpression - (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (144:2,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - header diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..5e6eb01dfa7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BodyAndExplicitChildContent/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (33:1,2 [46] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment header = (context) => | +Generated Location: (602:17,2 [46] ) +| RenderFragment header = (context) => | + +Source Location: (118:1,87 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (1023:27,87 [2] ) +|; | + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..0b3d4b01150 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "type", "checkbox"); + builder.AddAttribute(2, "checked", Microsoft.AspNetCore.Components.BindMethods.GetValue(Enabled)); + builder.AddAttribute(3, "onchange", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Enabled = __value, Enabled)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public bool Enabled { get; set; } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..2b48165ac52 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,25 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [8] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - checkbox + HtmlAttribute - (60:1,29 [8] x:\dir\subdir\Test\TestComponent.cshtml) - checked=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (61:1,30 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Enabled + IntermediateToken - - CSharp - ) + HtmlAttribute - (60:1,29 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Enabled = __value, Enabled) + CSharpCode - (86:2,12 [41] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:2,12 [41] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public bool Enabled { get; set; }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..dcc4eef3a26 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputCheckbox_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (86:2,12 [41] x:\dir\subdir\Test\TestComponent.cshtml) +| + public bool Enabled { get; set; } +| +Generated Location: (1064:24,12 [41] ) +| + public bool Enabled { get; set; } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..d347475c38a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,34 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "type", "text"); + builder.AddAttribute(2, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue(CurrentDate, Format)); + builder.AddAttribute(3, "onchange", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, Format)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + + public string Format { get; set; } = "MM/dd/yyyy"; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..5540459507e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,27 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [63] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (57:1,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate + IntermediateToken - - CSharp - , + IntermediateToken - (85:1,54 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Format + IntermediateToken - - CSharp - ) + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, Format) + CSharpCode - (108:2,12 [135] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (108:2,12 [135] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n\n public string Format { get; set; } = "MM/dd/yyyy";\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..40918f657fa --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,13 @@ +Source Location: (108:2,12 [135] x:\dir\subdir\Test\TestComponent.cshtml) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + + public string Format { get; set; } = "MM/dd/yyyy"; +| +Generated Location: (1086:24,12 [135] ) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + + public string Format { get; set; } = "MM/dd/yyyy"; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..415e7664c94 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "type", "text"); + builder.AddAttribute(2, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue(CurrentDate, "MM/dd/yyyy")); + builder.AddAttribute(3, "onchange", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, "MM/dd/yyyy")); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..dc862daa4b6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,27 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [66] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (57:1,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate + IntermediateToken - - CSharp - , + IntermediateToken - - CSharp - "MM/dd/yyyy" + IntermediateToken - - CSharp - ) + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => CurrentDate = __value, CurrentDate, "MM/dd/yyyy") + CSharpCode - (111:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (111:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..1096d43fa19 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WithFormat_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (111:2,12 [77] x:\dir\subdir\Test\TestComponent.cshtml) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +| +Generated Location: (1098:24,12 [77] ) +| + public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1); +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..c46a006cef5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "type", "text"); + builder.AddAttribute(2, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue)); + builder.AddAttribute(3, "onchange", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..c935b42bd5e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,25 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - - type=" - " + HtmlAttributeValue - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (44:1,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (57:1,26 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (56:1,25 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + CSharpCode - (86:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..aa078259ce5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputText_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (86:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1070:24,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..28468ad17af --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue(ParentValue)); + builder.AddAttribute(2, "onchange", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + public int ParentValue { get; set; } = 42; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..5ffdd8b1d74 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (44:1,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (45:1,14 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentValue + IntermediateToken - - CSharp - ) + HtmlAttribute - (44:1,13 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => ParentValue = __value, ParentValue) + CSharpCode - (74:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (74:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public int ParentValue { get; set; } = 42;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.mappings.txt new file mode 100644 index 00000000000..f3ac3c42904 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithoutType_WritesAttributes/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (74:2,12 [50] x:\dir\subdir\Test\TestComponent.cshtml) +| + public int ParentValue { get; set; } = 42; +| +Generated Location: (1016:23,12 [50] ) +| + public int ParentValue { get; set; } = 42; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic/TestComponent.codegen.cs new file mode 100644 index 00000000000..847cb43fac0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent>(0); + builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck("hi")); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic/TestComponent.ir.txt new file mode 100644 index 00000000000..9fba5ff2bf1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (63:1,32 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (64:1,33 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.codegen.cs new file mode 100644 index 00000000000..164ee4e0ef2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent>(0); + builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(Microsoft.AspNetCore.Components.BindMethods.GetValue(Value))); + builder.AddAttribute(2, "ItemChanged", new System.Action(__value => Value = __value)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string Value; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.ir.txt new file mode 100644 index 00000000000..a0bade6d00b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - ItemChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => Value = __value + CSharpCode - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.mappings.txt new file mode 100644 index 00000000000..a8c3e765dad --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) +| + string Value; +| +Generated Location: (1046:23,12 [21] ) +| + string Value; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.codegen.cs new file mode 100644 index 00000000000..faa5f80265d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent>(0); + builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.BindMethods.GetValue(Value)); + builder.AddAttribute(2, "ItemChanged", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Value = __value, Value)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string Value; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt new file mode 100644 index 00000000000..a95252463ee --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (67:1,36 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Value = __value, Value) + CSharpCode - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.mappings.txt new file mode 100644 index 00000000000..2cc63bc14b8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (88:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) +| + string Value; +| +Generated Location: (1021:23,12 [21] ) +| + string Value; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..e6f6d19f053 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, 18, 2, Microsoft.AspNetCore.Components.BindMethods.GetValue(Value), 3, Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Value = __value, Value)); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string Value; + +#line default +#line hidden + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, System.Object __arg1, int __seq2, System.Object __arg2) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Value", __arg0); + builder.AddAttribute(__seq1, "Item", __arg1); + builder.AddAttribute(__seq2, "ItemChanged", __arg2); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..7b2b87cdfa7 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.ir.txt @@ -0,0 +1,28 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [42] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (66:1,35 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Value - Value + CSharpExpression - (67:1,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 18 + ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => Value = __value, Value) + CSharpCode - (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..38ff236a02c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBindWeaklyTyped_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (87:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) +| + string Value; +| +Generated Location: (919:20,12 [21] ) +| + string Value; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..c2808ab0c6c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, Microsoft.AspNetCore.Components.BindMethods.GetValue(Value), 2, __value => Value = __value); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string Value; + +#line default +#line hidden + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "ItemChanged", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..a90c5928087 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.ir.txt @@ -0,0 +1,25 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [30] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Value + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (54:1,23 [5] x:\dir\subdir\Test\TestComponent.cshtml) - ItemChanged - ItemChanged + CSharpExpression - + IntermediateToken - - CSharp - __value => Value = __value + CSharpCode - (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string Value;\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..fe2d718f6b9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericBind_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (75:2,12 [21] x:\dir\subdir\Test\TestComponent.cshtml) +| + string Value; +| +Generated Location: (844:20,12 [21] ) +| + string Value; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..8d7563e2aef --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent>(0); + builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck("hi")); + builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((context) => (builder2) => { + builder2.AddContent(3, "\n "); + builder2.OpenElement(4, "div"); + builder2.AddContent(5, context.ToLower()); + builder2.CloseElement(); + builder2.AddContent(6, "\n"); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..ec6dc1c5251 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent/TestComponent.ir.txt @@ -0,0 +1,25 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [90] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (72:1,41 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (72:1,41 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (76:2,2 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (82:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (82:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() + HtmlContent - (105:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (105:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (63:1,32 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (64:1,33 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..e9fc0b231e9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,43 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi", 2, (context) => (builder2) => { + builder2.AddContent(3, "\n "); + builder2.OpenElement(4, "div"); + builder2.AddContent(5, context.ToLower()); + builder2.CloseElement(); + builder2.AddContent(6, "\n"); + } + ); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::Microsoft.AspNetCore.Components.RenderFragment __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "ChildContent", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..265a73f242f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericChildContent_TypeInference/TestComponent.ir.txt @@ -0,0 +1,26 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [77] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (59:1,28 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (59:1,28 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (63:2,2 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (69:2,8 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() + HtmlContent - (92:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (92:2,31 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.codegen.cs new file mode 100644 index 00000000000..c50be2453fc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.codegen.cs @@ -0,0 +1,25 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent>(0); + builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck("hi")); + builder.AddAttribute(2, "Other", 17); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.ir.txt new file mode 100644 index 00000000000..9910509f0a2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute/TestComponent.ir.txt @@ -0,0 +1,20 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [56] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentAttributeExtensionNode - (63:1,32 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (64:1,33 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (65:1,34 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + ComponentAttributeExtensionNode - - Other - + CSharpExpression - (79:1,48 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (81:1,50 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 17 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..49e4bd2ea6a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi", 2, 17); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, System.Object __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "Other", __arg1); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..39aba3881e0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_GenericWeaklyTypedAttribute_TypeInference/TestComponent.ir.txt @@ -0,0 +1,21 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + ComponentAttributeExtensionNode - - Other - + CSharpExpression - (66:1,35 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (68:1,37 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 17 + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..a4e81007875 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi"); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..1f3f11272db --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference/TestComponent.ir.txt @@ -0,0 +1,18 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.codegen.cs new file mode 100644 index 00000000000..7d1d0e91020 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.codegen.cs @@ -0,0 +1,51 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi"); + builder.AddContent(2, "\n"); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_1(builder, 3, 4, "how are you?"); + builder.AddContent(5, "\n"); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_2(builder, 6, 7, "bye!"); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.CloseComponent(); + } + public static void CreateMyComponent_1(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.CloseComponent(); + } + public static void CreateMyComponent_2(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.ir.txt new file mode 100644 index 00000000000..d8e96e6b7bb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Generic_TypeInference_Multiple/TestComponent.ir.txt @@ -0,0 +1,32 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [29] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + HtmlContent - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (60:1,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (62:2,0 [39] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (81:2,19 [17] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (82:2,20 [16] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (83:2,21 [14] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "how are you?" + HtmlContent - (101:2,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (101:2,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentExtensionNode - (103:3,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (122:3,19 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (123:3,20 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (124:3,21 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "bye!" + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_1 + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_2 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs new file mode 100644 index 00000000000..688b77b076d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.codegen.cs @@ -0,0 +1,36 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent>(0); + builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck("hi")); + builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((context) => (builder2) => { + builder2.OpenElement(3, "div"); + builder2.AddContent(4, context.ToLower()); + builder2.CloseElement(); + } + )); + builder.AddAttribute(5, "AnotherChildContent", (Microsoft.AspNetCore.Components.RenderFragment.Context>)((item) => (builder2) => { + builder2.AddContent(6, "\n "); + builder2.AddContent(7, System.Math.Max(0, item.Item)); + builder2.AddContent(8, ";\n"); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt new file mode 100644 index 00000000000..6a69c8b163d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [228] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (88:2,2 [58] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlElement - (102:2,16 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (108:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (108:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() + ComponentChildContent - (148:3,0 [95] x:\dir\subdir\Test\TestComponent.cshtml) - AnotherChildContent + HtmlContent - (184:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (184:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (189:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (189:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - System.Math.Max(0, item.Item) + HtmlContent - (218:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (218:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + ComponentTypeArgumentExtensionNode - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem1 + IntermediateToken - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - string + ComponentTypeArgumentExtensionNode - (65:1,34 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TItem2 + IntermediateToken - (65:1,34 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int + ComponentAttributeExtensionNode - (75:1,44 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (76:1,45 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (77:1,46 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..93d075fcb89 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, "hi", 2, new List(), 3, (context) => (builder2) => { + builder2.OpenElement(4, "div"); + builder2.AddContent(5, context.ToLower()); + builder2.CloseElement(); + } + , 6, (item) => (builder2) => { + builder2.AddContent(7, "\n "); + builder2.AddContent(8, System.Math.Max(0, item.Item)); + builder2.AddContent(9, ";\n"); + } + ); + } + #pragma warning restore 1998 + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem1 __arg0, int __seq1, global::System.Collections.Generic.List __arg1, int __seq2, global::Microsoft.AspNetCore.Components.RenderFragment __arg2, int __seq3, global::Microsoft.AspNetCore.Components.RenderFragment.Context> __arg3) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddAttribute(__seq1, "Items", __arg1); + builder.AddAttribute(__seq2, "ChildContent", __arg2); + builder.AddAttribute(__seq3, "AnotherChildContent", __arg3); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..0f2f0df4675 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_MultipleGenerics_TypeInference/TestComponent.ir.txt @@ -0,0 +1,32 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [229] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentChildContent - (89:2,2 [58] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlElement - (103:2,16 [29] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (109:2,22 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLower() + ComponentChildContent - (149:3,0 [95] x:\dir\subdir\Test\TestComponent.cshtml) - AnotherChildContent + HtmlContent - (185:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (185:3,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (190:4,3 [29] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - System.Math.Max(0, item.Item) + HtmlContent - (219:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (219:4,32 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + ComponentAttributeExtensionNode - (50:1,19 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + CSharpExpression - (51:1,20 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hi" + ComponentAttributeExtensionNode - (65:1,34 [19] x:\dir\subdir\Test\TestComponent.cshtml) - Items - Items + CSharpExpression - (66:1,35 [18] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (67:1,36 [16] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - new List() + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Simple/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Simple/TestComponent.codegen.cs new file mode 100644 index 00000000000..531a8574162 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Simple/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 class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Simple/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Simple/TestComponent.ir.txt new file mode 100644 index 00000000000..51b5023e8a4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_Simple/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [15] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..0d97d51a824 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "MyAttr", "abc"); + builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddContent(3, "Some text"); + builder2.AddMarkupContent(4, "Nested text"); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..2c493db0323 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [91] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Some text + HtmlBlock - - Nested text + ComponentAttributeExtensionNode - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr + HtmlContent - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..81c9ffdeda6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs @@ -0,0 +1,27 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddMarkupContent(2, "hello"); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..ab646023945 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt @@ -0,0 +1,14 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [47] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlBlock - - hello diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..9dada263555 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.codegen.cs @@ -0,0 +1,27 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddContent(2, "hello"); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..06b0cceb115 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitChildContent/TestComponent.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [61] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (44:1,13 [34] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlContent - (58:1,27 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:1,27 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - hello diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs new file mode 100644 index 00000000000..9116082d4b1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "OnClick", new System.Action(Increment)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private int counter; + private void Increment(UIEventArgs e) { + counter++; + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.ir.txt new file mode 100644 index 00000000000..f3057c657e2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (53:1,22 [10] x:\dir\subdir\Test\TestComponent.cshtml) - OnClick - OnClick + CSharpExpression - (54:1,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (54:1,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Increment + CSharpCode - (82:3,12 [100] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (82:3,12 [100] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private int counter;\n private void Increment(UIEventArgs e) {\n counter++;\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt new file mode 100644 index 00000000000..6eea8437b06 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitEventHandler/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (82:3,12 [100] x:\dir\subdir\Test\TestComponent.cshtml) +| + private int counter; + private void Increment(UIEventArgs e) { + counter++; + } +| +Generated Location: (881:22,12 [100] ) +| + private int counter; + private void Increment(UIEventArgs e) { + counter++; + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..42ddaad1f12 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.codegen.cs @@ -0,0 +1,27 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((context) => (builder2) => { + builder2.AddContent(2, context); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..d10b873fb59 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitGenericChildContent/TestComponent.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (44:1,13 [37] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + CSharpExpression - (59:1,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (59:1,28 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.codegen.cs new file mode 100644 index 00000000000..6f9059be256 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "StringProperty", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(42.ToString())); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.ir.txt new file mode 100644 index 00000000000..4f55ddf2147 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithExplicitStringParameter/TestComponent.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [49] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (60:1,29 [16] x:\dir\subdir\Test\TestComponent.cshtml) - StringProperty - StringProperty + CSharpExpression - (62:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (62:1,31 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 42.ToString() diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..cac7b047297 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.codegen.cs @@ -0,0 +1,32 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "MyAttr", "abc"); + builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((context) => (builder2) => { + builder2.AddContent(3, "Some text"); + builder2.OpenElement(4, "some-child"); + builder2.AddAttribute(5, "a", "1"); + builder2.AddContent(6, context.ToLowerInvariant()); + builder2.CloseElement(); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..fea8c42816f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent/TestComponent.ir.txt @@ -0,0 +1,24 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [107] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Some text + HtmlElement - (66:1,35 [58] x:\dir\subdir\Test\TestComponent.cshtml) - some-child + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - 1 + CSharpExpression - (85:1,54 [26] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (85:1,54 [26] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.ToLowerInvariant() + ComponentAttributeExtensionNode - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr + HtmlContent - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs new file mode 100644 index 00000000000..b80253027c8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "MyAttr", "abc"); + builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((item) => (builder2) => { + builder2.AddContent(3, "\n Some text"); + builder2.OpenElement(4, "some-child"); + builder2.AddAttribute(5, "a", "1"); + builder2.AddContent(6, item.ToLowerInvariant()); + builder2.CloseElement(); + builder2.AddContent(7, "\n "); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt new file mode 100644 index 00000000000..c08d7061cad --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterName/TestComponent.ir.txt @@ -0,0 +1,26 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [164] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (61:2,2 [118] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlContent - (90:2,31 [15] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (90:2,31 [15] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n Some text + HtmlElement - (105:3,13 [55] x:\dir\subdir\Test\TestComponent.cshtml) - some-child + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - 1 + CSharpExpression - (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item.ToLowerInvariant() + HtmlContent - (160:3,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (160:3,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentAttributeExtensionNode - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr + HtmlContent - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..b80253027c8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "MyAttr", "abc"); + builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((item) => (builder2) => { + builder2.AddContent(3, "\n Some text"); + builder2.OpenElement(4, "some-child"); + builder2.AddAttribute(5, "a", "1"); + builder2.AddContent(6, item.ToLowerInvariant()); + builder2.CloseElement(); + builder2.AddContent(7, "\n "); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..f5d06e567f0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithGenericChildContent_SetsParameterNameOnComponent/TestComponent.ir.txt @@ -0,0 +1,26 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [164] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (76:2,2 [103] x:\dir\subdir\Test\TestComponent.cshtml) - ChildContent + HtmlContent - (90:2,16 [15] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (90:2,16 [15] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n Some text + HtmlElement - (105:3,13 [55] x:\dir\subdir\Test\TestComponent.cshtml) - some-child + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - 1 + CSharpExpression - (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (124:3,32 [23] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - item.ToLowerInvariant() + HtmlContent - (160:3,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (160:3,68 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + ComponentAttributeExtensionNode - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr + HtmlContent - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs new file mode 100644 index 00000000000..6d455d9ef97 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.codegen.cs @@ -0,0 +1,33 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "OnClick", new System.Action(e => { Increment(); })); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private int counter; + private void Increment() { + counter++; + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.ir.txt new file mode 100644 index 00000000000..650e237e282 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [49] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (53:1,22 [24] x:\dir\subdir\Test\TestComponent.cshtml) - OnClick - OnClick + CSharpExpression - (54:1,23 [23] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (55:1,24 [21] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - e => { Increment(); } + CSharpCode - (96:3,12 [87] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (96:3,12 [87] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private int counter;\n private void Increment() {\n counter++;\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt new file mode 100644 index 00000000000..1e331a5dcbc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithLambdaEventHandler/TestComponent.mappings.txt @@ -0,0 +1,15 @@ +Source Location: (96:3,12 [87] x:\dir\subdir\Test\TestComponent.cshtml) +| + private int counter; + private void Increment() { + counter++; + } +| +Generated Location: (893:22,12 [87] ) +| + private int counter; + private void Increment() { + counter++; + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.codegen.cs new file mode 100644 index 00000000000..2e994509568 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.codegen.cs @@ -0,0 +1,25 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "some-attribute", "foo"); + builder.AddAttribute(2, "another-attribute", 43.ToString()); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.ir.txt new file mode 100644 index 00000000000..81e15493f95 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithNonPropertyAttributes/TestComponent.ir.txt @@ -0,0 +1,18 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - - some-attribute - + HtmlContent - (60:1,29 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (60:1,29 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - foo + ComponentAttributeExtensionNode - - another-attribute - + CSharpExpression - (84:1,53 [16] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:1,55 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 43.ToString() diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.codegen.cs new file mode 100644 index 00000000000..d3956e6d2e2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.codegen.cs @@ -0,0 +1,25 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + [Microsoft.AspNetCore.Components.RouteAttribute("/MyPage")] + [Microsoft.AspNetCore.Components.RouteAttribute("/AnotherRoute/{id}")] + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.ir.txt new file mode 100644 index 00000000000..5ed1562534e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithPageDirective/TestComponent.ir.txt @@ -0,0 +1,14 @@ +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 + RouteAttributeExtensionNode - - /MyPage + RouteAttributeExtensionNode - - /AnotherRoute/{id} + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (76:3,0 [15] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.codegen.cs new file mode 100644 index 00000000000..5fd12339b27 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.codegen.cs @@ -0,0 +1,27 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "IntProperty", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(123)); + builder.AddAttribute(2, "BoolProperty", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(true)); + builder.AddAttribute(3, "StringProperty", "My string"); + builder.AddAttribute(4, "ObjectProperty", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(new SomeType())); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.ir.txt new file mode 100644 index 00000000000..e56cec3e92e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithParameters/TestComponent.ir.txt @@ -0,0 +1,21 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [132] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (63:2,17 [3] x:\dir\subdir\Test\TestComponent.cshtml) - IntProperty - IntProperty + IntermediateToken - (63:2,17 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 123 + ComponentAttributeExtensionNode - (87:3,18 [4] x:\dir\subdir\Test\TestComponent.cshtml) - BoolProperty - BoolProperty + IntermediateToken - (87:3,18 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true + ComponentAttributeExtensionNode - (114:4,20 [9] x:\dir\subdir\Test\TestComponent.cshtml) - StringProperty - StringProperty + HtmlContent - (114:4,20 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (114:4,20 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - My string + ComponentAttributeExtensionNode - (146:5,20 [14] x:\dir\subdir\Test\TestComponent.cshtml) - ObjectProperty - ObjectProperty + IntermediateToken - (146:5,20 [14] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - new SomeType() diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.codegen.cs new file mode 100644 index 00000000000..4bf707b825b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.codegen.cs @@ -0,0 +1,30 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Action OnClick { get; set; } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.ir.txt new file mode 100644 index 00000000000..85be32648dc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [37] x:\dir\subdir\Test\TestComponent.cshtml) - DynamicElement - Test.DynamicElement + ComponentAttributeExtensionNode - (56:1,25 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - onclick + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (57:1,26 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + CSharpCode - (84:3,12 [62] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (84:3,12 [62] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Action OnClick { get; set; }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.mappings.txt new file mode 100644 index 00000000000..9ddaeafa678 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ChildComponent_WithWeaklyTypeEventHandler/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (84:3,12 [62] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Action OnClick { get; set; } +| +Generated Location: (934:22,12 [62] ) +| + private Action OnClick { get; set; } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.codegen.cs new file mode 100644 index 00000000000..adcb35739c5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "Coolness", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck("very-cool")); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.ir.txt new file mode 100644 index 00000000000..511caa57b35 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentParameter_TypeMismatch_ReportsDiagnostic/TestComponent.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [43] x:\dir\subdir\Test\TestComponent.cshtml) - CoolnessMeter - Test.CoolnessMeter + ComponentAttributeExtensionNode - (56:1,25 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Coolness - Coolness + CSharpExpression - (57:1,26 [13] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:1,27 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "very-cool" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs new file mode 100644 index 00000000000..743a1d25355 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddMarkupContent(0, "

    Item1

    \n"); +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item2 in Items2) +{ + +#line default +#line hidden + builder.AddContent(1, " "); + builder.OpenElement(2, "p"); + builder.AddContent(3, "\n "); + builder.AddContent(4, ChildContent(item2)); + builder.AddContent(5, ";\n "); + builder.CloseElement(); + builder.AddContent(6, "\n"); +#line 11 "x:\dir\subdir\Test\TestComponent.cshtml" +} + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 12 "x:\dir\subdir\Test\TestComponent.cshtml" + + [Parameter] TItem1 Item1 { get; set; } + [Parameter] List Items2 { get; set; } + [Parameter] RenderFragment ChildContent { get; set; } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt new file mode 100644 index 00000000000..19ae93068de --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.ir.txt @@ -0,0 +1,29 @@ +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 - (1:0,1 [40] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlBlock - -

    Item1

    \n + CSharpCode - (98:5,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (98:5,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item2 in Items2)\n{\n + HtmlContent - (132:7,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (132:7,0 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - + HtmlElement - (136:7,4 [40] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlContent - (139:7,7 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (139:7,7 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (146:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (146:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ChildContent(item2) + HtmlContent - (165:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (165:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + HtmlContent - (176:9,8 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (176:9,8 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (178:10,0 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (178:10,0 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n + CSharpCode - (193:11,12 [164] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (193:11,12 [164] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] TItem1 Item1 { get; set; }\n [Parameter] List Items2 { get; set; }\n [Parameter] RenderFragment ChildContent { get; set; }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt new file mode 100644 index 00000000000..ce3eb9c9b5b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithTypeParameters/TestComponent.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (98:5,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) +|foreach (var item2 in Items2) +{ +| +Generated Location: (679:19,1 [34] ) +|foreach (var item2 in Items2) +{ +| + +Source Location: (178:10,0 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|} +| +Generated Location: (1111:33,0 [3] ) +|} +| + +Source Location: (193:11,12 [164] x:\dir\subdir\Test\TestComponent.cshtml) +| + [Parameter] TItem1 Item1 { get; set; } + [Parameter] List Items2 { get; set; } + [Parameter] RenderFragment ChildContent { get; set; } +| +Generated Location: (1258:40,12 [164] ) +| + [Parameter] TItem1 Item1 { get; set; } + [Parameter] List Items2 { get; set; } + [Parameter] RenderFragment ChildContent { get; set; } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs new file mode 100644 index 00000000000..1a8e86cab44 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/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 class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddMarkupContent(0, "
    \n
    "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt new file mode 100644 index 00000000000..52917e45c3f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlBlock - -
    \n
    diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs new file mode 100644 index 00000000000..d3fc981a869 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs @@ -0,0 +1,40 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "ParamBefore", "before"); + builder.AddAttribute(2, "ParamAfter", "after"); + builder.AddComponentReferenceCapture(3, (__value) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + myInstance = (Test.MyComponent)__value; + +#line default +#line hidden + } + ); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt new file mode 100644 index 00000000000..c79c0afd236 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt @@ -0,0 +1,21 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [72] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - - ParamBefore - + HtmlContent - (57:1,26 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (57:1,26 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - before + RefExtensionNode - (70:1,39 [10] x:\dir\subdir\Test\TestComponent.cshtml) - myInstance - Test.MyComponent + ComponentAttributeExtensionNode - - ParamAfter - + HtmlContent - (94:1,63 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (94:1,63 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after + CSharpCode - (119:3,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (119:3,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Test.MyComponent myInstance;\n public void Foo() { System.GC.KeepAlive(myInstance); }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt new file mode 100644 index 00000000000..ea8d5c68531 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (70:1,39 [10] x:\dir\subdir\Test\TestComponent.cshtml) +|myInstance| +Generated Location: (888:21,39 [10] ) +|myInstance| + +Source Location: (119:3,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +| +Generated Location: (1142:31,12 [104] ) +| + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..60c7ebc3350 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs @@ -0,0 +1,44 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "SomeProp", "val"); + builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddContent(3, "\n Some "); + builder2.AddMarkupContent(4, "further content\n"); + } + )); + builder.AddComponentReferenceCapture(5, (__value) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + myInstance = (Test.MyComponent)__value; + +#line default +#line hidden + } + ); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..8407ec83785 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [96] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (76:1,45 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (76:1,45 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n Some + HtmlBlock - - further content\n + RefExtensionNode - (49:1,18 [10] x:\dir\subdir\Test\TestComponent.cshtml) - myInstance - Test.MyComponent + ComponentAttributeExtensionNode - - SomeProp - + HtmlContent - (71:1,40 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:1,40 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - val + CSharpCode - (143:5,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (143:5,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Test.MyComponent myInstance;\n public void Foo() { System.GC.KeepAlive(myInstance); }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..9dbf41a99dd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (49:1,18 [10] x:\dir\subdir\Test\TestComponent.cshtml) +|myInstance| +Generated Location: (1083:26,18 [10] ) +|myInstance| + +Source Location: (143:5,12 [104] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +| +Generated Location: (1337:36,12 [104] ) +| + private Test.MyComponent myInstance; + public void Foo() { System.GC.KeepAlive(myInstance); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs new file mode 100644 index 00000000000..076c2445097 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs @@ -0,0 +1,41 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "elem"); + builder.AddAttribute(1, "attributebefore", "before"); + builder.AddAttribute(2, "attributeafter", "after"); + builder.AddElementReferenceCapture(3, (__value) => { +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + myElem = __value; + +#line default +#line hidden + } + ); + builder.AddContent(4, "Hello"); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + private Microsoft.AspNetCore.Components.ElementRef myElem; + public void Foo() { System.GC.KeepAlive(myElem); } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt new file mode 100644 index 00000000000..3becd3940c0 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt @@ -0,0 +1,23 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [79] x:\dir\subdir\Test\TestComponent.cshtml) - elem + HtmlContent - (67:0,67 [5] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (67:0,67 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlAttribute - - attributebefore=" - " + HtmlAttributeValue - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (23:0,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - before + RefExtensionNode - (36:0,36 [6] x:\dir\subdir\Test\TestComponent.cshtml) - myElem - Element + HtmlAttribute - - attributeafter=" - " + HtmlAttributeValue - (60:0,60 [5] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (60:0,60 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after + CSharpCode - (95:2,12 [122] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (95:2,12 [122] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Microsoft.AspNetCore.Components.ElementRef myElem;\n public void Foo() { System.GC.KeepAlive(myElem); }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt new file mode 100644 index 00000000000..71cbebbe5ef --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (36:0,36 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|myElem| +Generated Location: (879:21,36 [6] ) +|myElem| + +Source Location: (95:2,12 [122] x:\dir\subdir\Test\TestComponent.cshtml) +| + private Microsoft.AspNetCore.Components.ElementRef myElem; + public void Foo() { System.GC.KeepAlive(myElem); } +| +Generated Location: (1154:32,12 [122] ) +| + private Microsoft.AspNetCore.Components.ElementRef myElem; + public void Foo() { System.GC.KeepAlive(myElem); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.codegen.cs new file mode 100644 index 00000000000..daf7ed1d8e3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onfocus", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue("alert(\"Test\");")); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.ir.txt new file mode 100644 index 00000000000..3d504c06f91 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandlerTagHelper_EscapeQuotes/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [34] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [14] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - - CSharp - "alert(\"Test\");" + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..8d291c9a049 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick(UIEventArgs e) { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..db06c4f0ea1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + CSharpCode - (42:1,12 [44] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:1,12 [44] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick(UIEventArgs e) {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..35125aed421 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (42:1,12 [44] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick(UIEventArgs e) { + } +| +Generated Location: (918:22,12 [44] ) +| + void OnClick(UIEventArgs e) { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.codegen.cs new file mode 100644 index 00000000000..0848a804f7c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick(UIMouseEventArgs e) { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.ir.txt new file mode 100644 index 00000000000..1d316a8f814 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + CSharpCode - (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick(UIMouseEventArgs e) {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.mappings.txt new file mode 100644 index 00000000000..165e27a7015 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithDelegate/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick(UIMouseEventArgs e) { + } +| +Generated Location: (918:22,12 [49] ) +| + void OnClick(UIMouseEventArgs e) { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.codegen.cs new file mode 100644 index 00000000000..53546b82922 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(x => { })); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.ir.txt new file mode 100644 index 00000000000..6330618edad --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsLambdaDelegate/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [11] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (18:0,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => { } + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..0848a804f7c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick(UIMouseEventArgs e) { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..1d316a8f814 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + CSharpCode - (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick(UIMouseEventArgs e) {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..165e27a7015 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithEventArgsMethodGroup/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (42:1,12 [49] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick(UIMouseEventArgs e) { + } +| +Generated Location: (918:22,12 [49] ) +| + void OnClick(UIMouseEventArgs e) { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.codegen.cs new file mode 100644 index 00000000000..53546b82922 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(x => { })); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.ir.txt new file mode 100644 index 00000000000..6330618edad --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithLambdaDelegate/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [31] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [11] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (18:0,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - x => { } + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.codegen.cs new file mode 100644 index 00000000000..83bd39591f1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnClick)); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + void OnClick() { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.ir.txt new file mode 100644 index 00000000000..cac45e62970 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [28] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [8] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnClick + IntermediateToken - - CSharp - ) + CSharpCode - (42:1,12 [31] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (42:1,12 [31] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n void OnClick() {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.mappings.txt new file mode 100644 index 00000000000..c009c34e8c8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgMethodGroup/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (42:1,12 [31] x:\dir\subdir\Test\TestComponent.cshtml) +| + void OnClick() { + } +| +Generated Location: (918:22,12 [31] ) +| + void OnClick() { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.codegen.cs new file mode 100644 index 00000000000..160ee3f2770 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(() => { })); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.ir.txt new file mode 100644 index 00000000000..64b75207236 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithNoArgsLambdaDelegate/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [32] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (18:0,18 [9] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => { } + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.codegen.cs new file mode 100644 index 00000000000..b548a04645c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "input"); + builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue("foo")); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.ir.txt new file mode 100644 index 00000000000..dfdc050a287 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_OnElement_WithString/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [23] x:\dir\subdir\Test\TestComponent.cshtml) - input + HtmlAttribute - (16:0,16 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - - CSharp - "foo" + IntermediateToken - - CSharp - ) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs new file mode 100644 index 00000000000..006b008784f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs @@ -0,0 +1,39 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent>(0); + builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(3)); + builder.AddComponentReferenceCapture(2, (__value) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + _my = (Test.MyComponent)__value; + +#line default +#line hidden + } + ); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt new file mode 100644 index 00000000000..32c963b7f47 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt @@ -0,0 +1,19 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [44] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentTypeArgumentExtensionNode - (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TItem + IntermediateToken - (50:1,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int + ComponentAttributeExtensionNode - (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + IntermediateToken - (60:1,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3 + RefExtensionNode - (68:1,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my - Test.MyComponent + CSharpCode - (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt new file mode 100644 index 00000000000..527982b014c --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (68:1,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|_my| +Generated Location: (879:20,37 [3] ) +|_my| + +Source Location: (91:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) +| + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +| +Generated Location: (1131:30,12 [90] ) +| + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs new file mode 100644 index 00000000000..c299061cdbd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs @@ -0,0 +1,50 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1, 3, 2, (__value) => { +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + _my = __value; + +#line default +#line hidden + } + ); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } + +#line default +#line hidden + } +} +namespace __Blazor.Test.TestComponent +{ + #line hidden + internal static class TypeInference + { + public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action> __arg1) + { + builder.OpenComponent>(seq); + builder.AddAttribute(__seq0, "Item", __arg0); + builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent)__value); }); + builder.CloseComponent(); + } + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt new file mode 100644 index 00000000000..ec12816d5c3 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt @@ -0,0 +1,20 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [34] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - global::Test.MyComponent + ComponentAttributeExtensionNode - (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - Item + IntermediateToken - (50:1,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3 + RefExtensionNode - (58:1,27 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my - global::Test.MyComponent + CSharpCode - (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n + NamespaceDeclaration - - __Blazor.Test.TestComponent + ClassDeclaration - - internal static - TypeInference - - + ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt new file mode 100644 index 00000000000..5803b4379dd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt @@ -0,0 +1,16 @@ +Source Location: (58:1,27 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|_my| +Generated Location: (738:18,27 [3] ) +|_my| + +Source Location: (81:3,12 [90] x:\dir\subdir\Test\TestComponent.cshtml) +| + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +| +Generated Location: (928:27,12 [90] ) +| + private MyComponent _my; + public void Foo() { System.GC.KeepAlive(_my); } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..7dfa3b30216 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddContent(0, "My value"); + builder.AddContent(1, "\n\n"); + builder.AddMarkupContent(2, "

    Hello

    "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..7b9697cfba6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt @@ -0,0 +1,16 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpExpression - (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "My value" + HtmlContent - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlBlock - -

    Hello

    diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..4df487e6d7d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs @@ -0,0 +1,25 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.CloseComponent(); + builder.AddContent(1, "\n\n"); + builder.AddMarkupContent(2, "

    Hello

    "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..6f9090488c5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt @@ -0,0 +1,15 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (36:2,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent - Test.SomeOtherComponent + HtmlContent - (58:2,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:2,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n + HtmlBlock - -

    Hello

    diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs new file mode 100644 index 00000000000..02d3036e76b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs @@ -0,0 +1,22 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + using System; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddMarkupContent(0, "

    Hello

    "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt new file mode 100644 index 00000000000..210b13ae3ff --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt @@ -0,0 +1,12 @@ +Document - + NamespaceDeclaration - - Test + 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 + UsingDirective - (1:0,1 [14] x:\dir\subdir\Test\TestComponent.cshtml) - System + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlBlock - -

    Hello

    diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..6032dbfa1e1 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "Header", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddContent(2, "Hi!"); + } + )); + builder.AddAttribute(3, "Footer", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddContent(4, "bye!"); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.ir.txt new file mode 100644 index 00000000000..ad902f45bf9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/MultipleExplictChildContent/TestComponent.ir.txt @@ -0,0 +1,18 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [87] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - (50:2,4 [20] x:\dir\subdir\Test\TestComponent.cshtml) - Header + HtmlContent - (58:2,12 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (58:2,12 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hi! + ComponentChildContent - (76:3,4 [26] x:\dir\subdir\Test\TestComponent.cshtml) - Footer + CSharpExpression - (86:3,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (86:3,14 [6] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "bye!" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs new file mode 100644 index 00000000000..8068fdf5de2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.codegen.cs @@ -0,0 +1,42 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment template = (context) => + +#line default +#line hidden + (builder2) => { + builder2.OpenElement(0, "li"); + builder2.AddContent(1, "#"); + builder2.AddContent(2, context.Index); + builder2.AddContent(3, " - "); + builder2.AddContent(4, context.Item.ToLower()); + builder2.CloseElement(); + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + builder.OpenComponent(5); + builder.AddAttribute(6, "Template", new Microsoft.AspNetCore.Components.RenderFragment(template)); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.ir.txt new file mode 100644 index 00000000000..e7d96bc27c2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.ir.txt @@ -0,0 +1,29 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpCode - (35:1,2 [54] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [54] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment template = (context) => + Template - (90:1,57 [48] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (90:1,57 [50] x:\dir\subdir\Test\TestComponent.cshtml) - li + HtmlContent - (94:1,61 [1] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (94:1,61 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - # + CSharpExpression - (96:1,63 [13] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (96:1,63 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Index + HtmlContent - (109:1,76 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (109:1,76 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \- + CSharpExpression - (113:1,80 [22] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (113:1,80 [22] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - context.Item.ToLower() + CSharpCode - (140:1,107 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (140:1,107 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (145:2,0 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (168:2,23 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Template - Template + CSharpExpression - (169:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (169:2,24 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt new file mode 100644 index 00000000000..1963f1cf2cd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_AsComponentParameter_MixedContent/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (35:1,2 [54] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment template = (context) => | +Generated Location: (602:17,2 [54] ) +| RenderFragment template = (context) => | + +Source Location: (140:1,107 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (1196:30,107 [2] ) +|; | + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..cbf409e5858 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.codegen.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + RenderFragment p = (person) => + +#line default +#line hidden + (builder2) => { + builder2.OpenElement(0, "div"); + builder2.OpenComponent(1); + builder2.AddAttribute(2, "Name", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(person.Name)); + builder2.CloseComponent(); + builder2.CloseElement(); + } +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 5 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..c7f75745ba8 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.ir.txt @@ -0,0 +1,23 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpCode - (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment p = (person) => + Template - (81:2,44 [45] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (81:2,44 [45] x:\dir\subdir\Test\TestComponent.cshtml) - div + ComponentExtensionNode - (86:2,49 [34] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (105:2,68 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Name - Name + CSharpExpression - (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + CSharpCode - (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n + CSharpCode - (144:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (144:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.mappings.txt new file mode 100644 index 00000000000..acde1a8af7d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_ContainsComponent/TestComponent.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) +| + RenderFragment p = (person) => | +Generated Location: (602:17,2 [45] ) +| + RenderFragment p = (person) => | + +Source Location: (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|; +| +Generated Location: (1198:30,89 [3] ) +|; +| + +Source Location: (144:4,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } +| +Generated Location: (1344:37,12 [76] ) +| + class Person + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..75cf31b314a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.codegen.cs @@ -0,0 +1,56 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + RenderFragment p = (person) => + +#line default +#line hidden + (builder2) => { + builder2.OpenElement(0, "div"); + builder2.OpenComponent(1); + builder2.AddAttribute(2, "Name", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(person.Name)); + builder2.CloseComponent(); + builder2.CloseElement(); + } +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + builder.OpenComponent(3); + builder.AddAttribute(4, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => { + builder2.AddContent(5, "\n"); + builder2.AddContent(6, "hello, world!"); + builder2.AddContent(7, "\n"); + } + )); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 9 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..0ec2d91086b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.ir.txt @@ -0,0 +1,31 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpCode - (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment p = (person) => + Template - (81:2,44 [45] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (81:2,44 [45] x:\dir\subdir\Test\TestComponent.cshtml) - div + ComponentExtensionNode - (86:2,49 [34] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (105:2,68 [12] x:\dir\subdir\Test\TestComponent.cshtml) - Name - Name + CSharpExpression - (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (106:2,69 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + CSharpCode - (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n + ComponentExtensionNode - (132:4,0 [49] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentChildContent - - ChildContent + HtmlContent - (145:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (145:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (149:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (149:5,2 [15] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "hello, world!" + HtmlContent - (165:5,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (165:5,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (197:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (197:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt new file mode 100644 index 00000000000..c0db477d8a6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_FollowedByComponent/TestComponent.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (35:1,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) +| + RenderFragment p = (person) => | +Generated Location: (602:17,2 [45] ) +| + RenderFragment p = (person) => | + +Source Location: (126:2,89 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|; +| +Generated Location: (1198:30,89 [3] ) +|; +| + +Source Location: (197:8,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } +| +Generated Location: (1742:45,12 [76] ) +| + class Person + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs new file mode 100644 index 00000000000..dcb427879ac --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.codegen.cs @@ -0,0 +1,39 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment template = (person) => + +#line default +#line hidden + (builder2) => { + builder2.OpenElement(0, "div"); + builder2.AddContent(1, person.Name); + builder2.CloseElement(); + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + builder.OpenComponent(2); + builder.AddAttribute(3, "PersonTemplate", new Microsoft.AspNetCore.Components.RenderFragment(template)); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.ir.txt new file mode 100644 index 00000000000..0d9aff443ee --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.ir.txt @@ -0,0 +1,23 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpCode - (35:1,2 [47] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [47] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment template = (person) => + Template - (83:1,50 [22] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (83:1,50 [23] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (89:1,56 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (89:1,56 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + CSharpCode - (106:1,73 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (106:1,73 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (111:2,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - (140:2,29 [9] x:\dir\subdir\Test\TestComponent.cshtml) - PersonTemplate - PersonTemplate + CSharpExpression - (141:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (141:2,30 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt new file mode 100644 index 00000000000..ef5720700b4 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_AsComponentParameter/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (35:1,2 [47] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment template = (person) => | +Generated Location: (602:17,2 [47] ) +| RenderFragment template = (person) => | + +Source Location: (106:1,73 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (995:27,73 [2] ) +|; | + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..a0fa8858ce6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.codegen.cs @@ -0,0 +1,38 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddContent(0, RenderPerson((person) => (builder2) => { + builder2.OpenElement(1, "div"); + builder2.AddContent(2, person.Name); + builder2.CloseElement(); + } + )); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..37914cc7326 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.ir.txt @@ -0,0 +1,20 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpExpression - (1:0,1 [48] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (1:0,1 [25] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson((person) => + Template - (27:0,27 [22] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (27:0,27 [23] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (33:0,33 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (33:0,33 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + IntermediateToken - (50:0,50 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ) + CSharpCode - (65:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (65:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n\n object RenderPerson(RenderFragment p) => null;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.mappings.txt new file mode 100644 index 00000000000..998fa7c231a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_Generic_InImplicitExpression/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (65:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +| +Generated Location: (914:25,12 [138] ) +| + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.codegen.cs new file mode 100644 index 00000000000..333bd6f5d5f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.codegen.cs @@ -0,0 +1,46 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" + + RenderFragment p = (person) => + +#line default +#line hidden + (builder2) => { + builder2.OpenElement(0, "div"); + builder2.AddContent(1, person.Name); + builder2.CloseElement(); + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.ir.txt new file mode 100644 index 00000000000..5a22540dc73 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.ir.txt @@ -0,0 +1,21 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpCode - (2:0,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (2:0,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n RenderFragment p = (person) => + Template - (48:1,44 [22] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (48:1,44 [23] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (54:1,50 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (54:1,50 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + CSharpCode - (71:1,67 [3] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (71:1,67 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ;\n + CSharpCode - (89:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (89:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.mappings.txt new file mode 100644 index 00000000000..fa40ec8015b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InCodeBlock/TestComponent.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (2:0,2 [45] x:\dir\subdir\Test\TestComponent.cshtml) +| + RenderFragment p = (person) => | +Generated Location: (602:17,2 [45] ) +| + RenderFragment p = (person) => | + +Source Location: (71:1,67 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|; +| +Generated Location: (987:28,67 [3] ) +|; +| + +Source Location: (89:3,12 [76] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } +| +Generated Location: (1133:35,12 [76] ) +| + class Person + { + public string Name { get; set; } + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..a0fa8858ce6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.codegen.cs @@ -0,0 +1,38 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddContent(0, RenderPerson((person) => (builder2) => { + builder2.OpenElement(1, "div"); + builder2.AddContent(2, person.Name); + builder2.CloseElement(); + } + )); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..8273aafc575 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.ir.txt @@ -0,0 +1,20 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpExpression - (2:0,2 [48] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (2:0,2 [25] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson((person) => + Template - (28:0,28 [22] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlElement - (28:0,28 [23] x:\dir\subdir\Test\TestComponent.cshtml) - div + CSharpExpression - (34:0,34 [11] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (34:0,34 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - person.Name + IntermediateToken - (51:0,51 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ) + CSharpCode - (67:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (67:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n class Person\n {\n public string Name { get; set; }\n }\n\n object RenderPerson(RenderFragment p) => null;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.mappings.txt new file mode 100644 index 00000000000..fd453a55c69 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_InExplicitExpression/TestComponent.mappings.txt @@ -0,0 +1,19 @@ +Source Location: (67:1,12 [138] x:\dir\subdir\Test\TestComponent.cshtml) +| + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +| +Generated Location: (914:25,12 [138] ) +| + class Person + { + public string Name { get; set; } + } + + object RenderPerson(RenderFragment p) => null; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.codegen.cs new file mode 100644 index 00000000000..714746db4e6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/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 class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + RenderFragment template = + +#line default +#line hidden + (builder2) => { + builder2.AddMarkupContent(0, "
    Joey
    "); + } +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + ; + +#line default +#line hidden + builder.OpenComponent(1); + builder.AddAttribute(2, "Person", template); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.ir.txt new file mode 100644 index 00000000000..bce4cf0b184 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.ir.txt @@ -0,0 +1,21 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpCode - (35:1,2 [27] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (35:1,2 [27] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderFragment template = + Template - (63:1,30 [15] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlBlock - -
    Joey
    + CSharpCode - (78:1,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (78:1,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ; + ComponentExtensionNode - (83:2,0 [33] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent + ComponentAttributeExtensionNode - - Person - + CSharpExpression - (104:2,21 [9] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (105:2,22 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - template diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.mappings.txt new file mode 100644 index 00000000000..768ce896f09 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_AsComponentParameter/TestComponent.mappings.txt @@ -0,0 +1,10 @@ +Source Location: (35:1,2 [27] x:\dir\subdir\Test\TestComponent.cshtml) +| RenderFragment template = | +Generated Location: (602:17,2 [27] ) +| RenderFragment template = | + +Source Location: (78:1,45 [2] x:\dir\subdir\Test\TestComponent.cshtml) +|; | +Generated Location: (868:25,45 [2] ) +|; | + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..19de0ad213d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddContent(0, RenderPerson((builder2) => { + builder2.AddMarkupContent(1, "
    HI
    "); + } + )); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + object RenderPerson(RenderFragment p) => null; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..0c92c8d3332 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.ir.txt @@ -0,0 +1,18 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + CSharpExpression - (1:0,1 [27] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (1:0,1 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - RenderPerson( + Template - (15:0,15 [13] x:\dir\subdir\Test\TestComponent.cshtml) + HtmlBlock - -
    HI
    + IntermediateToken - (28:0,28 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ) + CSharpCode - (43:1,12 [54] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (43:1,12 [54] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n object RenderPerson(RenderFragment p) => null;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.mappings.txt new file mode 100644 index 00000000000..75ad368ca86 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/RazorTemplate_NonGeneric_InImplicitExpression/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (43:1,12 [54] x:\dir\subdir\Test\TestComponent.cshtml) +| + object RenderPerson(RenderFragment p) => null; +| +Generated Location: (821:23,12 [54] ) +| + object RenderPerson(RenderFragment p) => null; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.codegen.cs new file mode 100644 index 00000000000..de8ea8d3535 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.codegen.cs @@ -0,0 +1,31 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "v", Microsoft.AspNetCore.Components.BindMethods.GetValue(y)); + builder.AddAttribute(2, "vChanged", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => y = __value, y)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" + + string y = null; + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.ir.txt new file mode 100644 index 00000000000..3d826705551 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.ir.txt @@ -0,0 +1,22 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - Counter - Test.Counter + ComponentAttributeExtensionNode - (48:1,17 [1] x:\dir\subdir\Test\TestComponent.cshtml) - v - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (48:1,17 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - y + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (48:1,17 [1] x:\dir\subdir\Test\TestComponent.cshtml) - vChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => y = __value, y) + CSharpCode - (67:2,12 [24] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (67:2,12 [24] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n string y = null;\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.mappings.txt new file mode 100644 index 00000000000..727b6af35fd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_597/TestComponent.mappings.txt @@ -0,0 +1,9 @@ +Source Location: (67:2,12 [24] x:\dir\subdir\Test\TestComponent.cshtml) +| + string y = null; +| +Generated Location: (991:23,12 [24] ) +| + string y = null; +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.codegen.cs new file mode 100644 index 00000000000..8c117e539fb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.codegen.cs @@ -0,0 +1,34 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenComponent(0); + builder.AddAttribute(1, "Name", Microsoft.AspNetCore.Components.BindMethods.GetValue(UserName)); + builder.AddAttribute(2, "NameChanged", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => UserName = __value, UserName)); + builder.AddAttribute(3, "IsActive", Microsoft.AspNetCore.Components.BindMethods.GetValue(UserIsActive)); + builder.AddAttribute(4, "IsActiveChanged", Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => UserIsActive = __value, UserIsActive)); + builder.CloseComponent(); + } + #pragma warning restore 1998 +#line 4 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string UserName { get; set; } + public bool UserIsActive { get; set; } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.ir.txt new file mode 100644 index 00000000000..7723e3e5656 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.ir.txt @@ -0,0 +1,30 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + ComponentExtensionNode - (31:1,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - User - Test.User + ComponentAttributeExtensionNode - (48:1,17 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Name - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (49:1,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserName + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (48:1,17 [9] x:\dir\subdir\Test\TestComponent.cshtml) - NameChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => UserName = __value, UserName) + ComponentAttributeExtensionNode - (74:1,43 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActive - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue( + IntermediateToken - (75:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserIsActive + IntermediateToken - - CSharp - ) + ComponentAttributeExtensionNode - (74:1,43 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActiveChanged - + CSharpExpression - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.SetValueHandler(__value => UserIsActive = __value, UserIsActive) + CSharpCode - (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string UserName { get; set; }\n public bool UserIsActive { get; set; }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.mappings.txt new file mode 100644 index 00000000000..77ef4f484c6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_609/TestComponent.mappings.txt @@ -0,0 +1,11 @@ +Source Location: (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string UserName { get; set; } + public bool UserIsActive { get; set; } +| +Generated Location: (1300:25,12 [88] ) +| + public string UserName { get; set; } + public bool UserIsActive { get; set; } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_772/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_772/TestComponent.codegen.cs new file mode 100644 index 00000000000..2ce16627be6 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_772/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; + [Microsoft.AspNetCore.Components.RouteAttribute("/")] + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddMarkupContent(0, "

    Hello, world!

    \n\nWelcome to your new app.\n\n"); + builder.OpenComponent(1); + builder.AddAttribute(2, "Title", ""); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_772/TestComponent.diagnostics.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_772/TestComponent.diagnostics.txt new file mode 100644 index 00000000000..57b2bc79491 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_772/TestComponent.diagnostics.txt @@ -0,0 +1,2 @@ +x:\dir\subdir\Test\TestComponent.cshtml(8,2): Error RZ1035: Missing close angle for tag helper 'SurveyPrompt'. +x:\dir\subdir\Test\TestComponent.cshtml(8,2): Error RZ1034: Found a malformed 'SurveyPrompt' tag helper. Tag helpers must have a start and end tag or be self closing. diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_772/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_772/TestComponent.ir.txt new file mode 100644 index 00000000000..b127a13de4f --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_772/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + RouteAttributeExtensionNode - - / + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlBlock - -

    Hello, world!

    \n\nWelcome to your new app.\n\n + ComponentExtensionNode - (98:7,0 [23] x:\dir\subdir\Test\TestComponent.cshtml) - SurveyPrompt - Test.SurveyPrompt + ComponentAttributeExtensionNode - (119:7,21 [0] x:\dir\subdir\Test\TestComponent.cshtml) - Title - Title + HtmlContent - (119:7,21 [0] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (119:7,21 [0] x:\dir\subdir\Test\TestComponent.cshtml) - Html - diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_773/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_773/TestComponent.codegen.cs new file mode 100644 index 00000000000..a75a64a1e64 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_773/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; + [Microsoft.AspNetCore.Components.RouteAttribute("/")] + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddMarkupContent(0, "

    Hello, world!

    \n\nWelcome to your new app.\n\n"); + builder.OpenComponent(1); + builder.AddAttribute(2, "Title", "
    Test!
    "); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_773/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_773/TestComponent.ir.txt new file mode 100644 index 00000000000..1fb9a8886ba --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_773/TestComponent.ir.txt @@ -0,0 +1,17 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + RouteAttributeExtensionNode - - / + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlBlock - -

    Hello, world!

    \n\nWelcome to your new app.\n\n + ComponentExtensionNode - (98:7,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - SurveyPrompt - Test.SurveyPrompt + ComponentAttributeExtensionNode - (119:7,21 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Title - Title + HtmlContent - (119:7,21 [16] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (119:7,21 [16] x:\dir\subdir\Test\TestComponent.cshtml) - Html -
    Test!
    diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_784/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_784/TestComponent.codegen.cs new file mode 100644 index 00000000000..1132f451458 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_784/TestComponent.codegen.cs @@ -0,0 +1,35 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "p"); + builder.AddAttribute(1, "onmouseover", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue(OnComponentHover)); + builder.AddAttribute(2, "style", "background:" + " " + (ParentBgColor) + ";"); + builder.CloseElement(); + } + #pragma warning restore 1998 +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + + public string ParentBgColor { get; set; } = "#FFFFFF"; + + public void OnComponentHover(UIMouseEventArgs e) + { + } + +#line default +#line hidden + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_784/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_784/TestComponent.ir.txt new file mode 100644 index 00000000000..4a5b1e1c630 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_784/TestComponent.ir.txt @@ -0,0 +1,26 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [73] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlAttribute - (16:0,16 [17] x:\dir\subdir\Test\TestComponent.cshtml) - onmouseover=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue( + IntermediateToken - (17:0,17 [16] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - OnComponentHover + IntermediateToken - - CSharp - ) + HtmlAttribute - - style=" - " + HtmlAttributeValue - (42:0,42 [11] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (42:0,42 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - background: + CSharpExpressionAttributeValue - (53:0,53 [15] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (55:0,55 [13] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ParentBgColor + HtmlAttributeValue - (68:0,68 [1] x:\dir\subdir\Test\TestComponent.cshtml) - + IntermediateToken - (68:0,68 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ; + CSharpCode - (87:1,12 [132] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (87:1,12 [132] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string ParentBgColor { get; set; } = "#FFFFFF";\n\n public void OnComponentHover(UIMouseEventArgs e)\n {\n }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_784/TestComponent.mappings.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_784/TestComponent.mappings.txt new file mode 100644 index 00000000000..c9f709e2c1a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Regression_784/TestComponent.mappings.txt @@ -0,0 +1,17 @@ +Source Location: (87:1,12 [132] x:\dir\subdir\Test\TestComponent.cshtml) +| + public string ParentBgColor { get; set; } = "#FFFFFF"; + + public void OnComponentHover(UIMouseEventArgs e) + { + } +| +Generated Location: (1019:23,12 [132] ) +| + public string ParentBgColor { get; set; } = "#FFFFFF"; + + public void OnComponentHover(UIMouseEventArgs e) + { + } +| + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs new file mode 100644 index 00000000000..4a3c1c62254 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.codegen.cs @@ -0,0 +1,30 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.OpenElement(0, "div"); + builder.AddContent(1, "\n "); + builder.OpenElement(2, "script"); + builder.AddAttribute(3, "src", "some/url.js"); + builder.AddAttribute(4, "anotherattribute", ""); + builder.AddContent(5, "\n some text\n some more text\n "); + builder.CloseElement(); + builder.AddContent(6, "\n"); + builder.CloseElement(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt new file mode 100644 index 00000000000..e96a9b8477d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ScriptTag_WithErrorSuppressed/TestComponent.ir.txt @@ -0,0 +1,25 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlElement - (0:0,0 [144] x:\dir\subdir\Test\TestComponent.cshtml) - div + HtmlContent - (5:0,5 [6] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (5:0,5 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlElement - (11:1,4 [125] x:\dir\subdir\Test\TestComponent.cshtml) - script + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - some/url.js + HtmlAttribute - - - + HtmlAttributeValue - - + IntermediateToken - - Html - + HtmlContent - (78:1,71 [49] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (78:1,71 [49] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n some text\n some more text\n + HtmlContent - (136:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (136:4,13 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs new file mode 100644 index 00000000000..9b8920ec7cb --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/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 class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddMarkupContent(0, "

    Hello

    \n\n"); + builder.AddContent(1, "My value"); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt new file mode 100644 index 00000000000..e11585d5f6b --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt @@ -0,0 +1,14 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlBlock - -

    Hello

    \n\n + CSharpExpression - (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "My value" diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs new file mode 100644 index 00000000000..3f04a5e7e6a --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs @@ -0,0 +1,24 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Components; + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddMarkupContent(0, "

    Hello

    \n\n"); + builder.OpenComponent(1); + builder.CloseComponent(); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.ir.txt new file mode 100644 index 00000000000..9c3a0c453fc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/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 - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlBlock - -

    Hello

    \n\n + ComponentExtensionNode - (49:3,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent - Test.SomeOtherComponent diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs new file mode 100644 index 00000000000..9c401bc7038 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/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; + [Microsoft.AspNetCore.Components.RouteAttribute("/my/url")] + public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) + { + base.BuildRenderTree(builder); + builder.AddMarkupContent(0, "

    Hello

    "); + } + #pragma warning restore 1998 + } +} +#pragma warning restore 1591 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.ir.txt new file mode 100644 index 00000000000..01e9d759a7d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/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 + RouteAttributeExtensionNode - - /my/url + ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - + MethodDeclaration - - protected override - void - BuildRenderTree + CSharpCode - + IntermediateToken - - CSharp - base.BuildRenderTree(builder); + HtmlBlock - -

    Hello

    diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/SuppressPrimaryMethodBodyIntegrationTest/BasicTest.codegen.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/SuppressPrimaryMethodBodyIntegrationTest/BasicTest.codegen.cs index 5133c6e91cb..b197be13a85 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/SuppressPrimaryMethodBodyIntegrationTest/BasicTest.codegen.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/SuppressPrimaryMethodBodyIntegrationTest/BasicTest.codegen.cs @@ -10,7 +10,7 @@ namespace AspNetCore { #line hidden [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"47f616cdc7ec75674c74246619b0e6118ef227e4", @"/TestFiles/IntegrationTests/SuppressPrimaryMethodBodyIntegrationTest/BasicTest.razor")] - public sealed class BasicTest : global::Microsoft.AspNetCore.Components.Component + public sealed class BasicTest : global::Microsoft.AspNetCore.Components.ComponentBase { #pragma warning disable 1998 public override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/SuppressPrimaryMethodBodyIntegrationTest/BasicTest.ir.txt b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/SuppressPrimaryMethodBodyIntegrationTest/BasicTest.ir.txt index d1f61990386..ba5d3860035 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/SuppressPrimaryMethodBodyIntegrationTest/BasicTest.ir.txt +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/SuppressPrimaryMethodBodyIntegrationTest/BasicTest.ir.txt @@ -6,7 +6,7 @@ Document - IntermediateToken - - CSharp - #pragma warning disable 0169\n NamespaceDeclaration - - AspNetCore RazorSourceChecksumAttribute - - ClassDeclaration - - public sealed - BasicTest - global::Microsoft.AspNetCore.Components.Component - + ClassDeclaration - - public sealed - BasicTest - global::Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - public override - void - BuildRenderTree CSharpCode - (58:3,12 [41] BasicTest.razor) IntermediateToken - (58:3,12 [41] BasicTest.razor) - CSharp - \n string SomeProperty { get; set; }\n diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/LayoutAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/LayoutAttribute.cs new file mode 100644 index 00000000000..63f6d64e4a9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/LayoutAttribute.cs @@ -0,0 +1,21 @@ +// 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.Layouts +{ + /// + /// Indicates that the associated component type uses a specified layout. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] + public class LayoutAttribute : Attribute + { + public LayoutAttribute(Type layoutType) + { + LayoutType = layoutType ?? throw new ArgumentNullException(nameof(layoutType)); + } + + public Type LayoutType { get; } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Components/Component.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ComponentBase.cs similarity index 65% rename from src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Components/Component.cs rename to src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ComponentBase.cs index 87301deb92f..208b3aad253 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Components/Component.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ComponentBase.cs @@ -5,12 +5,20 @@ namespace Microsoft.AspNetCore.Components { - public abstract class Component : IComponent + public abstract class ComponentBase : IComponent { public virtual void BuildRenderTree(RenderTreeBuilder builder) { } + public virtual void SetParameters(ParameterCollection parameters) + { + } + + void IComponent.Init(RenderHandle renderHandle) + { + } + protected void WriteLiteral(string literal) { } } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ElementRef.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ElementRef.cs new file mode 100644 index 00000000000..06d6c9d370d --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ElementRef.cs @@ -0,0 +1,12 @@ +// 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. + +namespace Microsoft.AspNetCore.Components +{ + /// + /// Represents a reference to a rendered element. + /// + public struct ElementRef + { + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Components/IComponent.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/IComponent.cs similarity index 70% rename from src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Components/IComponent.cs rename to src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/IComponent.cs index c2fe5924dae..0f909c5d717 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Components/IComponent.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/IComponent.cs @@ -5,5 +5,9 @@ namespace Microsoft.AspNetCore.Components { public interface IComponent { + void Init(RenderHandle renderHandle); + + + void SetParameters(ParameterCollection parameters); } } \ No newline at end of file diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/InjectAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/InjectAttribute.cs new file mode 100644 index 00000000000..3490c456ce2 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/InjectAttribute.cs @@ -0,0 +1,16 @@ +// 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 +{ + /// + /// Indicates that the associated property should have a value injected from the + /// service provider during initialization. + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] + public class InjectAttribute : Attribute + { + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ParameterAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ParameterAttribute.cs new file mode 100644 index 00000000000..5351c619fb5 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ParameterAttribute.cs @@ -0,0 +1,15 @@ +// 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 +{ + /// + /// Denotes the target member as a component parameter. + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public sealed class ParameterAttribute : Attribute + { + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ParameterCollection.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ParameterCollection.cs new file mode 100644 index 00000000000..f055fa6e9bd --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/ParameterCollection.cs @@ -0,0 +1,13 @@ +// 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. + +namespace Microsoft.AspNetCore.Components +{ + /// + /// Represents a collection of parameters supplied to an + /// by its parent in the render tree. + /// + public struct ParameterCollection + { + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/RenderHandle.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/RenderHandle.cs new file mode 100644 index 00000000000..b0034b801fc --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/RenderHandle.cs @@ -0,0 +1,12 @@ +// 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. + +namespace Microsoft.AspNetCore.Components +{ + /// + /// Allows a component to notify the renderer that it should be rendered. + /// + public struct RenderHandle + { + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Components/RenderTree/RenderTreeBuilder.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/RenderTree/RenderTreeBuilder.cs similarity index 100% rename from src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Components/RenderTree/RenderTreeBuilder.cs rename to src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/RenderTree/RenderTreeBuilder.cs diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/UIEventArgs.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/UIEventArgs.cs new file mode 100644 index 00000000000..953300d8a9e --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Components/UIEventArgs.cs @@ -0,0 +1,518 @@ +// 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. + +namespace Microsoft.AspNetCore.Components +{ + /// + /// Supplies information about an event that is being raised. + /// + public class UIEventArgs + { + /// + /// Gets or sets the type of the event. + /// + public string Type { get; set; } + } + + /// + /// Supplies information about an input change event that is being raised. + /// + public class UIChangeEventArgs : UIEventArgs + { + /// + /// Gets or sets the new value of the input. This may be a + /// or a . + /// + public object Value { get; set; } + } + + /// + /// Supplies information about an clipboard event that is being raised. + /// + public class UIClipboardEventArgs : UIEventArgs + { + } + + /// + /// Supplies information about an drag event that is being raised. + /// + public class UIDragEventArgs : UIEventArgs + { + /// + /// A count of consecutive clicks that happened in a short amount of time, incremented by one. + /// + public long Detail { get; set; } + + /// + /// The data that underlies a drag-and-drop operation, known as the drag data store. + /// See . + /// + public DataTransfer DataTransfer { get; set; } + + /// + /// The X coordinate of the mouse pointer in global (screen) coordinates. + /// + public long ScreenX { get; set; } + + /// + /// The Y coordinate of the mouse pointer in global (screen) coordinates. + /// + public long ScreenY { get; set; } + + /// + /// The X coordinate of the mouse pointer in local (DOM content) coordinates. + /// + public long ClientX { get; set; } + + /// + /// The Y coordinate of the mouse pointer in local (DOM content) coordinates. + /// + public long ClientY { get; set; } + + /// + /// The button number that was pressed when the mouse event was fired: + /// Left button=0, + /// middle button=1 (if present), + /// right button=2. + /// For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left. + /// + public long Button { get; set; } + + /// + /// The buttons being pressed when the mouse event was fired: + /// Left button=1, + /// Right button=2, + /// Middle (wheel) button=4, + /// 4th button (typically, "Browser Back" button)=8, + /// 5th button (typically, "Browser Forward" button)=16. + /// If two or more buttons are pressed, returns the logical sum of the values. + /// E.g., if Left button and Right button are pressed, returns 3 (=1 | 2). + /// + public long Buttons { get; set; } + + /// + /// true if the control key was down when the event was fired. false otherwise. + /// + public bool CtrlKey { get; set; } + + /// + /// true if the shift key was down when the event was fired. false otherwise. + /// + public bool ShiftKey { get; set; } + + /// + /// true if the alt key was down when the event was fired. false otherwise. + /// + public bool AltKey { get; set; } + + /// + /// true if the meta key was down when the event was fired. false otherwise. + /// + public bool MetaKey { get; set; } + } + + /// + /// The object is used to hold the data that is being dragged during a drag and drop operation. + /// It may hold one or more , each of one or more data types. + /// For more information about drag and drop, see HTML Drag and Drop API. + /// + public class DataTransfer + { + /// + /// Gets the type of drag-and-drop operation currently selected or sets the operation to a new type. + /// The value must be none, copy, link or move. + /// + public string DropEffect { get; set; } + + /// + /// Provides all of the types of operations that are possible. + /// Must be one of none, copy, copyLink, copyMove, link, linkMove, move, all or uninitialized. + /// + public string EffectAllowed { get; set; } + + /// + /// Contains a list of all the local files available on the data transfer. + /// If the drag operation doesn't involve dragging files, this property is an empty list. + /// + public string[] Files { get; set; } + + /// + /// Gives a array which is a list of all of the drag data. + /// + public UIDataTransferItem[] Items { get; set; } + + /// + /// An array of giving the formats that were set in the dragstart event. + /// + public string[] Types { get; set; } + } + + /// + /// The object represents one drag data item. + /// During a drag operation, each drag event has a dataTransfer property which contains a list of drag data items. + /// Each item in the list is a object. + /// + public class UIDataTransferItem + { + /// + /// The kind of drag data item, string or file + /// + public string Kind { get; set; } + + /// + /// The drag data item's type, typically a MIME type + /// + public string Type { get; set; } + } + + /// + /// Supplies information about an error event that is being raised. + /// + public class UIErrorEventArgs : UIEventArgs + { + /// + /// Gets a a human-readable error message describing the problem. + /// + public string Message { get; set; } + + /// + /// Gets the name of the script file in which the error occurred. + /// + public string Filename { get; set; } + + /// + /// Gets the line number of the script file on which the error occurred. + /// + public int Lineno { get; set; } + + /// + /// Gets the column number of the script file on which the error occurred. + /// + public int Colno { get; set; } + } + + /// + /// Supplies information about a focus event that is being raised. + /// + public class UIFocusEventArgs : UIEventArgs + { + // Not including support for 'relatedTarget' since we don't have a good way to represent it. + // see: https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent + } + + /// + /// Supplies information about a keyboard event that is being raised. + /// + public class UIKeyboardEventArgs : UIEventArgs + { + /// + /// The key value of the key represented by the event. + /// If the value has a printed representation, this attribute's value is the same as the char attribute. + /// Otherwise, it's one of the key value strings specified in 'Key values'. + /// If the key can't be identified, this is the string "Unidentified" + /// + public string Key { get; set; } + + /// + /// Holds a string that identifies the physical key being pressed. + /// The value is not affected by the current keyboard layout or modifier state, so a particular key will always return the same value. + /// + public string Code { get; set; } + + /// + /// The location of the key on the device. + /// + public float Location { get; set; } + + /// + /// true if a key has been depressed long enough to trigger key repetition, otherwise false. + /// + public bool Repeat { get; set; } + + /// + /// true if the control key was down when the event was fired. false otherwise. + /// + public bool CtrlKey { get; set; } + + /// + /// true if the shift key was down when the event was fired. false otherwise. + /// + public bool ShiftKey { get; set; } + + /// + /// true if the alt key was down when the event was fired. false otherwise. + /// + public bool AltKey { get; set; } + + /// + /// true if the meta key was down when the event was fired. false otherwise. + /// + public bool MetaKey { get; set; } + } + + /// + /// Supplies information about a mouse event that is being raised. + /// + public class UIMouseEventArgs : UIEventArgs + { + /// + /// A count of consecutive clicks that happened in a short amount of time, incremented by one. + /// + public long Detail { get; set; } + + /// + /// The X coordinate of the mouse pointer in global (screen) coordinates. + /// + public long ScreenX { get; set; } + + /// + /// The Y coordinate of the mouse pointer in global (screen) coordinates. + /// + public long ScreenY { get; set; } + + /// + /// The X coordinate of the mouse pointer in local (DOM content) coordinates. + /// + public long ClientX { get; set; } + + /// + /// The Y coordinate of the mouse pointer in local (DOM content) coordinates. + /// + public long ClientY { get; set; } + + /// + /// The button number that was pressed when the mouse event was fired: + /// Left button=0, + /// middle button=1 (if present), + /// right button=2. + /// For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left. + /// + public long Button { get; set; } + + /// + /// The buttons being pressed when the mouse event was fired: + /// Left button=1, + /// Right button=2, + /// Middle (wheel) button=4, + /// 4th button (typically, "Browser Back" button)=8, + /// 5th button (typically, "Browser Forward" button)=16. + /// If two or more buttons are pressed, returns the logical sum of the values. + /// E.g., if Left button and Right button are pressed, returns 3 (=1 | 2). + /// + public long Buttons { get; set; } + + /// + /// true if the control key was down when the event was fired. false otherwise. + /// + public bool CtrlKey { get; set; } + + /// + /// true if the shift key was down when the event was fired. false otherwise. + /// + public bool ShiftKey { get; set; } + + /// + /// true if the alt key was down when the event was fired. false otherwise. + /// + public bool AltKey { get; set; } + + /// + /// true if the meta key was down when the event was fired. false otherwise. + /// + public bool MetaKey { get; set; } + } + + /// + /// Supplies information about a mouse event that is being raised. + /// + public class UIPointerEventArgs : UIMouseEventArgs + { + /// + /// A unique identifier for the pointer causing the event. + /// + public string PointerId { get; set; } + + /// + /// The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. + /// + public float Width { get; set; } + + /// + /// The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. + /// + public float Height { get; set; } + + /// + /// The normalized pressure of the pointer input in the range of 0 to 1, + /// where 0 and 1 represent the minimum and maximum pressure the hardware is capable of detecting, respectively. + /// + public float Pressure { get; set; } + + /// + /// The plane angle (in degrees, in the range of -90 to 90) between the Y-Z plane + /// and the plane containing both the transducer (e.g. pen stylus) axis and the Y axis. + /// + public float TiltX { get; set; } + + /// + /// The plane angle (in degrees, in the range of -90 to 90) between the X-Z plane + /// and the plane containing both the transducer (e.g. pen stylus) axis and the X axis. + /// + public float TiltY { get; set; } + + /// + /// Indicates the device type that caused the event. + /// Must be one of the strings mouse, pen or touch, or an empty string. + /// + public string PointerType { get; set; } + + /// + /// Indicates if the pointer represents the primary pointer of this pointer type. + /// + public bool IsPrimary { get; set; } + } + + /// + /// Supplies information about a progress event that is being raised. + /// + public class UIProgressEventArgs : UIEventArgs + { + /// + /// Whether or not the total size of the transfer is known. + /// + public bool LengthComputable { get; set; } + + /// + /// The number of bytes transferred since the beginning of the operation. + /// This doesn't include headers and other overhead, but only the content itself. + /// + public long Loaded { get; set; } + + /// + /// The total number of bytes of content that will be transferred during the operation. + /// If the total size is unknown, this value is zero. + /// + public long Total { get; set; } + } + + /// + /// Supplies information about a touch event that is being raised. + /// + public class UITouchEventArgs : UIEventArgs + { + /// + /// A count of consecutive clicks that happened in a short amount of time, incremented by one. + /// + public long Detail { get; set; } + + /// + /// A list of for every point of contact currently touching the surface. + /// + public UITouchPoint[] Touches { get; set; } + + /// + /// A list of for every point of contact that is touching the surface and started on the element that is the target of the current event. + /// + public UITouchPoint[] TargetTouches { get; set; } + + /// + /// A list of Touches for every point of contact which contributed to the event. + /// For the touchstart event this must be a list of the touch points that just became active with the current event. + /// For the touchmove event this must be a list of the touch points that have moved since the last event. + /// For the touchend and touchcancel events this must be a list of the touch points that have just been removed from the surface. + /// + public UITouchPoint[] ChangedTouches { get; set; } + + /// + /// true if the control key was down when the event was fired. false otherwise. + /// + public bool CtrlKey { get; set; } + + /// + /// true if the shift key was down when the event was fired. false otherwise. + /// + public bool ShiftKey { get; set; } + + /// + /// true if the alt key was down when the event was fired. false otherwise. + /// + public bool AltKey { get; set; } + + /// + /// true if the meta key was down when the event was fired. false otherwise. + /// + public bool MetaKey { get; set; } + } + + /// + /// Represents a single contact point on a touch-sensitive device. + /// The contact point is commonly a finger or stylus and the device may be a touchscreen or trackpad. + /// + public class UITouchPoint + { + /// + /// A unique identifier for this Touch object. + /// A given touch point (say, by a finger) will have the same identifier for the duration of its movement around the surface. + /// This lets you ensure that you're tracking the same touch all the time. + /// + public long Identifier { get; set; } + + /// + /// The X coordinate of the touch point relative to the left edge of the screen. + /// + public long ScreenX { get; set; } + + /// + /// The Y coordinate of the touch point relative to the top edge of the screen. + /// + public long ScreenY { get; set; } + + /// + /// The X coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset. + /// + public long ClientX { get; set; } + + /// + /// The Y coordinate of the touch point relative to the top edge of the browser viewport, not including any scroll offset. + /// + public long ClientY { get; set; } + + /// + /// The X coordinate of the touch point relative to the left edge of the document. + /// Unlike , this value includes the horizontal scroll offset, if any. + /// + public long PageX { get; set; } + + /// + /// The Y coordinate of the touch point relative to the top of the document. + /// Unlike , this value includes the vertical scroll offset, if any. + /// + public long PageY { get; set; } + } + + /// + /// Supplies information about a mouse wheel event that is being raised. + /// + public class UIWheelEventArgs : UIMouseEventArgs + { + /// + /// The horizontal scroll amount. + /// + public double DeltaX { get; set; } + + /// + /// The vertical scroll amount. + /// + public double DeltaY { get; set; } + + /// + /// The scroll amount for the z-axis. + /// + public double DeltaZ { get; set; } + + /// + /// The unit of the delta values scroll amount. + /// + public long DeltaMode { get; set; } + } +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Razor.Test.ComponentShim.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Razor.Test.ComponentShim.csproj new file mode 100644 index 00000000000..756371e76db --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/Microsoft.AspNetCore.Razor.Test.ComponentShim.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0;net461 + + + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/RenderFrame.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/RenderFrame.cs new file mode 100644 index 00000000000..01c9e70b1a9 --- /dev/null +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/RenderFrame.cs @@ -0,0 +1,22 @@ +// 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 Microsoft.AspNetCore.Components.RenderTree; + +namespace Microsoft.AspNetCore.Components +{ + /// + /// Represents a segment of UI content, implemented as a delegate that + /// writes the content to a . + /// + /// The to which the content should be written. + public delegate void RenderFragment(RenderTreeBuilder builder); + + /// + /// Represents a segment of UI content for an object of type , implemented as + /// a function that returns a . + /// + /// The type of object. + /// The value used to build the content. + public delegate RenderFragment RenderFragment(T value); +} diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj index ec9b4351784..bbfde1da9bd 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib/Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj @@ -7,6 +7,8 @@ + + diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj index bd2e0104cc3..10bebabe02f 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.MvcShim/Microsoft.AspNetCore.Razor.Test.MvcShim.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.0;net461 @@ -8,6 +8,8 @@ + + diff --git a/src/Razor/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj b/src/Razor/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj index 550e8fa2d7a..f299f64e134 100644 --- a/src/Razor/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj +++ b/src/Razor/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj @@ -26,6 +26,7 @@ + diff --git a/src/Razor/test/testapps/ClassLibrary/ClassLibrary.csproj b/src/Razor/test/testapps/ClassLibrary/ClassLibrary.csproj index 9b38b6b7f64..37172bc6b71 100644 --- a/src/Razor/test/testapps/ClassLibrary/ClassLibrary.csproj +++ b/src/Razor/test/testapps/ClassLibrary/ClassLibrary.csproj @@ -29,6 +29,7 @@ + diff --git a/src/Razor/test/testapps/ClassLibrary2/ClassLibrary2.csproj b/src/Razor/test/testapps/ClassLibrary2/ClassLibrary2.csproj index b13a9c80717..4d4cd2f2a3c 100644 --- a/src/Razor/test/testapps/ClassLibrary2/ClassLibrary2.csproj +++ b/src/Razor/test/testapps/ClassLibrary2/ClassLibrary2.csproj @@ -28,6 +28,7 @@ + diff --git a/src/Razor/test/testapps/LargeProject/LargeProject.csproj b/src/Razor/test/testapps/LargeProject/LargeProject.csproj index a4b035712a4..69cada30198 100644 --- a/src/Razor/test/testapps/LargeProject/LargeProject.csproj +++ b/src/Razor/test/testapps/LargeProject/LargeProject.csproj @@ -20,6 +20,7 @@ + diff --git a/src/Razor/test/testapps/MvcWithComponents/MvcWithComponents.csproj b/src/Razor/test/testapps/MvcWithComponents/MvcWithComponents.csproj index 23d69bef39e..b9fd86c876f 100644 --- a/src/Razor/test/testapps/MvcWithComponents/MvcWithComponents.csproj +++ b/src/Razor/test/testapps/MvcWithComponents/MvcWithComponents.csproj @@ -20,6 +20,7 @@ + diff --git a/src/Razor/test/testapps/SimpleMvc/SimpleMvc.csproj b/src/Razor/test/testapps/SimpleMvc/SimpleMvc.csproj index 275ae61610a..276589868f7 100644 --- a/src/Razor/test/testapps/SimpleMvc/SimpleMvc.csproj +++ b/src/Razor/test/testapps/SimpleMvc/SimpleMvc.csproj @@ -20,6 +20,7 @@ + diff --git a/src/Razor/test/testapps/SimpleMvcFSharp/SimpleMvcFSharp.fsproj b/src/Razor/test/testapps/SimpleMvcFSharp/SimpleMvcFSharp.fsproj index 5264c82b76f..c32a88baa1a 100644 --- a/src/Razor/test/testapps/SimpleMvcFSharp/SimpleMvcFSharp.fsproj +++ b/src/Razor/test/testapps/SimpleMvcFSharp/SimpleMvcFSharp.fsproj @@ -25,6 +25,7 @@ + diff --git a/src/Razor/test/testapps/SimplePages/SimplePages.csproj b/src/Razor/test/testapps/SimplePages/SimplePages.csproj index d131016beb6..362406340cb 100644 --- a/src/Razor/test/testapps/SimplePages/SimplePages.csproj +++ b/src/Razor/test/testapps/SimplePages/SimplePages.csproj @@ -20,6 +20,7 @@ +