示例#1
0
        private ComponentExtensionNode RewriteAsComponent(TagHelperIntermediateNode node, TagHelperDescriptor tagHelper)
        {
            var component = new ComponentExtensionNode()
            {
                Component = tagHelper,
                Source    = node.Source,
                TagName   = node.TagName,
                TypeName  = tagHelper.GetTypeName(),
            };

            for (var i = 0; i < node.Diagnostics.Count; i++)
            {
                component.Diagnostics.Add(node.Diagnostics[i]);
            }

            var visitor = new ComponentRewriteVisitor(component);

            visitor.Visit(node);

            // Fixup the parameter names of child content elements. We can't do this during the rewrite
            // because we see the nodes in the wrong order.
            foreach (var childContent in component.ChildContents)
            {
                childContent.ParameterName = childContent.ParameterName ?? component.ChildContentParameterName ?? BlazorMetadata.ChildContent.DefaultParameterName;
            }

            return(component);
        }
示例#2
0
        public static RazorDiagnostic Create_GenericComponentTypeInferenceUnderspecified(
            SourceSpan?source,
            ComponentExtensionNode component,
            IEnumerable <BoundAttributeDescriptor> 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));
        }
示例#3
0
        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));
        }
示例#4
0
        private ComponentExtensionNode RewriteAsComponent(TagHelperIntermediateNode node, TagHelperDescriptor tagHelper)
        {
            var component = new ComponentExtensionNode()
            {
                Component = tagHelper,
                Source    = node.Source,
                TagName   = node.TagName,
            };

            for (var i = 0; i < node.Diagnostics.Count; i++)
            {
                component.Diagnostics.Add(node.Diagnostics[i]);
            }

            var visitor = new ComponentRewriteVisitor(component);

            visitor.Visit(node);

            return(component);
        }
示例#5
0
 public abstract void WriteComponent(CodeRenderingContext context, ComponentExtensionNode node);
示例#6
0
 public ComponentRewriteVisitor(ComponentExtensionNode component)
 {
     _component = component;
     _children  = component.Children;
 }
示例#7
0
        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));
        }