private static TagMode GetTagMode( string tagName, Block beginTagBlock, IEnumerable<TagHelperDescriptor> descriptors, ErrorSink errorSink) { var childSpan = beginTagBlock.FindLastDescendentSpan(); // Self-closing tags are always valid despite descriptors[X].TagStructure. if (childSpan?.Content.EndsWith("/>", StringComparison.Ordinal) ?? false) { return TagMode.SelfClosing; } var baseDescriptor = descriptors.FirstOrDefault( descriptor => descriptor.TagStructure != TagStructure.Unspecified); var resolvedTagStructure = baseDescriptor?.TagStructure ?? TagStructure.Unspecified; if (resolvedTagStructure == TagStructure.WithoutEndTag) { return TagMode.StartTagOnly; } return TagMode.StartTagAndEndTag; }
private static bool IsSelfClosing(Block childBlock) { var childSpan = childBlock.FindLastDescendentSpan(); return childSpan?.Content.EndsWith("/>", StringComparison.Ordinal) ?? false; }