diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentDiagnosticFactory.cs new file mode 100644 index 0000000000..684bcbcec7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/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/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.Designer.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.Designer.cs new file mode 100644 index 0000000000..3a7ce3183a --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/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/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx new file mode 100644 index 0000000000..3fe9868ecd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/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/Microsoft.AspNetCore.Razor.Language/src/Components/CodeGenerationConstants.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/CodeGenerationConstants.cs index 35c176a678..43f0cb1909 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/CodeGenerationConstants.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/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/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs index 29afa982af..2e1f24cdb5 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components @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 @@ namespace Microsoft.AspNetCore.Razor.Language.Components @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 @@ namespace Microsoft.AspNetCore.Razor.Language.Components 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 @@ namespace Microsoft.AspNetCore.Razor.Language.Components 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/Microsoft.AspNetCore.Razor.Language/src/Microsoft.AspNetCore.Razor.Language.csproj b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Microsoft.AspNetCore.Razor.Language.csproj index 1fd7aeebf5..d27b1d8dd6 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Microsoft.AspNetCore.Razor.Language.csproj +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/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.Test.ComponentShim/LayoutAttribute.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.ComponentShim/LayoutAttribute.cs new file mode 100644 index 0000000000..63f6d64e4a --- /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 87301deb92..208b3aad25 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 @@ using Microsoft.AspNetCore.Components.RenderTree; 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 0000000000..06d6c9d370 --- /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 c2fe5924da..0f909c5d71 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 0000000000..3490c456ce --- /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 0000000000..5351c619fb --- /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 0000000000..f055fa6e9b --- /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 0000000000..b0034b801f --- /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 0000000000..953300d8a9 --- /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 0000000000..756371e76d --- /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 0000000000..01c9e70b1a --- /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 ec9b435178..bbfde1da9b 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 bd2e0104cc..10bebabe02 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/testassets/AppWithP2PReference/AppWithP2PReference.csproj b/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj index 550e8fa2d7..f299f64e13 100644 --- a/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj +++ b/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj @@ -26,6 +26,7 @@ + diff --git a/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj b/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj index 9b38b6b7f6..37172bc6b7 100644 --- a/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj +++ b/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj @@ -29,6 +29,7 @@ + diff --git a/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj b/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj index b13a9c8071..4d4cd2f2a3 100644 --- a/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj +++ b/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj @@ -28,6 +28,7 @@ + diff --git a/src/Razor/test/testassets/LargeProject/LargeProject.csproj b/src/Razor/test/testassets/LargeProject/LargeProject.csproj index a4b035712a..69cada3019 100644 --- a/src/Razor/test/testassets/LargeProject/LargeProject.csproj +++ b/src/Razor/test/testassets/LargeProject/LargeProject.csproj @@ -20,6 +20,7 @@ + diff --git a/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj b/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj index 23d69bef39..b9fd86c876 100644 --- a/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj +++ b/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj @@ -20,6 +20,7 @@ + diff --git a/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj b/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj index 275ae61610..276589868f 100644 --- a/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj +++ b/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj @@ -20,6 +20,7 @@ + diff --git a/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj b/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj index 5264c82b76..c32a88baa1 100644 --- a/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj +++ b/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj @@ -25,6 +25,7 @@ + diff --git a/src/Razor/test/testassets/SimplePages/SimplePages.csproj b/src/Razor/test/testassets/SimplePages/SimplePages.csproj index d131016beb..362406340c 100644 --- a/src/Razor/test/testassets/SimplePages/SimplePages.csproj +++ b/src/Razor/test/testassets/SimplePages/SimplePages.csproj @@ -20,6 +20,7 @@ +