/// <summary> /// Instantiates a new instance of <see cref="TagHelperDirectiveDescriptor"/>. /// </summary> /// <param name="directiveText">A <see cref="string"/> used to understand tag helper /// <see cref="System.Type"/>s.</param> /// <param name="location">The <see cref="SourceLocation"/> of the directive.</param> /// <param name="directiveType">The <see cref="TagHelperDirectiveType"/> of this directive.</param> public TagHelperDirectiveDescriptor([NotNull] string directiveText, SourceLocation location, TagHelperDirectiveType directiveType) { DirectiveText = directiveText; Location = location; DirectiveType = directiveType; }
private static TagHelperDirectiveDescriptor CreateDirectiveDescriptor( string directiveText, TagHelperDirectiveType directiveType) { return(new TagHelperDirectiveDescriptor { DirectiveText = directiveText, Location = SourceLocation.Undefined, DirectiveType = directiveType }); }
private TagHelperDirectiveDescriptor CreateDirective( Span span, string directiveText, TagHelperDirectiveType directiveType, List <RazorDiagnostic> diagnostics) { directiveText = directiveText.Trim(); if (directiveText.Length >= 2 && directiveText.StartsWith("\"", StringComparison.Ordinal) && directiveText.EndsWith("\"", StringComparison.Ordinal)) { directiveText = directiveText.Substring(1, directiveText.Length - 2); } // If this is the "string literal" form of a directive, we'll need to postprocess the location // and content. // // Ex: @addTagHelper "*, Microsoft.AspNetCore.CoolLibrary" // ^ ^ // Start End var directiveStart = span.Start; if (span.Symbols.Count == 1 && (span.Symbols[0] as CSharpSymbol)?.Type == CSharpSymbolType.StringLiteral) { var offset = span.Content.IndexOf(directiveText, StringComparison.Ordinal); // This is safe because inside one of these directives all of the text needs to be on the // same line. var original = span.Start; directiveStart = new SourceLocation( original.FilePath, original.AbsoluteIndex + offset, original.LineIndex, original.CharacterIndex + offset); } var directiveDescriptor = new TagHelperDirectiveDescriptor { DirectiveText = directiveText, Location = directiveStart, DirectiveType = directiveType, Diagnostics = diagnostics, }; return(directiveDescriptor); }
// Internal for testing purposes. internal TagHelperDirectiveDescriptor(string directiveText, TagHelperDirectiveType directiveType) : this(directiveText, SourceLocation.Zero, directiveType) { }
private static TagHelperDirectiveDescriptor CreateDirectiveDescriptor( string directiveText, TagHelperDirectiveType directiveType) { return new TagHelperDirectiveDescriptor(directiveText, SourceLocation.Undefined, directiveType); }
private static TagHelperDirectiveDescriptor CreateDirectiveDescriptor( string directiveText, TagHelperDirectiveType directiveType) { return new TagHelperDirectiveDescriptor { DirectiveText = directiveText, Location = SourceLocation.Undefined, DirectiveType = directiveType }; }