Language\CodeGeneration\CodeRenderingContextExtensions.cs (8)
13this CodeRenderingContext context, SourceSpan? span, bool suppressLineDefaultAndHidden = false)
18return span is SourceSpan spanValue && !spanValue.FilePath.IsNullOrEmpty()
24this CodeRenderingContext context, SourceSpan? span, int characterOffset = 0, bool suppressLineDefaultAndHidden = false)
27return span is SourceSpan spanValue && !spanValue.FilePath.IsNullOrEmpty()
35private readonly SourceSpan _span;
42SourceSpan span,
56public static LinePragmaScope Standard(CodeRenderingContext context, SourceSpan span, bool suppressLineDefaultAndHidden)
68public static LinePragmaScope Enhanced(CodeRenderingContext context, SourceSpan span, int characterOffset, bool suppressLineDefaultAndHidden)
Language\CodeGeneration\CodeWriterExtensions.cs (10)
80public static CodeWriter WritePadding(this CodeWriter writer, int offset, SourceSpan? span, CodeRenderingContext context)
303public static CodeWriter WriteEnhancedLineNumberDirective(this CodeWriter writer, SourceSpan span, int characterOffset, bool ensurePathBackslashes)
325public static CodeWriter WriteLineNumberDirective(this CodeWriter writer, SourceSpan span, bool ensurePathBackslashes)
526SourceSpan? typeSpan = null,
527SourceSpan? nameSpan = null,
556SourceSpan? typeSpan,
557SourceSpan? nameSpan,
566static void WriteToken(CodeWriter writer, string content, SourceSpan? span, CodeRenderingContext context)
658public static CSharpCodeWritingScope BuildNamespace(this CodeWriter writer, string? name, SourceSpan? span, CodeRenderingContext context)
796static void WriteWithPragma(string content, CodeRenderingContext context, SourceSpan source)
Language\Components\ComponentDiagnosticFactory.cs (42)
23public static RazorDiagnostic Create_UnsupportedTagHelperDirective(SourceSpan? source)
33public static RazorDiagnostic Create_CodeBlockInAttribute(SourceSpan? source, string expression)
41public static RazorDiagnostic Create_UnclosedTag(SourceSpan? span, string tagName)
49public static RazorDiagnostic Create_UnexpectedClosingTag(SourceSpan? span, string tagName)
57public static RazorDiagnostic Create_UnexpectedClosingTagForVoidElement(SourceSpan? span, string tagName)
65public static RazorDiagnostic Create_InvalidHtmlContent(SourceSpan? span, string text)
73public static RazorDiagnostic Create_MultipleComponents(SourceSpan? span, string tagName, IEnumerable<TagHelperDescriptor> components)
86public static RazorDiagnostic Create_AmbiguousComponentSelection(SourceSpan? span, string tagName, TagHelperDescriptor genericComponent, TagHelperDescriptor nonGenericComponent)
108public static RazorDiagnostic CreatePageDirective_CannotBeImported(SourceSpan source)
120public static RazorDiagnostic CreatePageDirective_MustSpecifyRoute(SourceSpan? source)
129SourceSpan? source, string attribute, IEnumerable<TagHelperDirectiveAttributeIntermediateNode> attributes)
141public static RazorDiagnostic CreateEventHandler_Duplicates(SourceSpan? source, string attribute, TagHelperDirectiveAttributeIntermediateNode[] attributes)
154public static RazorDiagnostic CreateBindAttribute_InvalidSyntax(SourceSpan? source, string attribute)
164public static RazorDiagnostic Create_DisallowedScriptTag(SourceSpan? source)
172public static RazorDiagnostic Create_TemplateInvalidLocation(SourceSpan? source)
180public static RazorDiagnostic Create_ChildContentSetByAttributeAndBody(SourceSpan? source, string attribute)
189public static RazorDiagnostic Create_ChildContentMixedWithExplicitChildContent(SourceSpan? source, ComponentIntermediateNode component)
201public static RazorDiagnostic Create_ChildContentHasInvalidAttribute(SourceSpan? source, string attribute, string element)
209public static RazorDiagnostic Create_ChildContentHasInvalidParameter(SourceSpan? source, string attribute, string element)
219SourceSpan? source,
245SourceSpan? source,
262SourceSpan? source,
277public static RazorDiagnostic Create_ChildContentHasInvalidParameterOnComponent(SourceSpan? source, string attribute, string element)
285public static RazorDiagnostic Create_UnsupportedComponentImportContent(SourceSpan? source)
293public static RazorDiagnostic CreateBindAttributeParameter_MissingBind(SourceSpan? source, string attribute)
304public static RazorDiagnostic Create_DuplicateMarkupAttribute(string attributeName, SourceSpan? source = null)
313public static RazorDiagnostic Create_DuplicateMarkupAttributeDirective(string attributeName, string directiveAttributeName, SourceSpan? source = null)
321public static RazorDiagnostic Create_DuplicateComponentParameter(string attributeName, SourceSpan? source = null)
330public static RazorDiagnostic Create_DuplicateComponentParameterDirective(string attributeName, string directiveAttributeName, SourceSpan? source = null)
338public static RazorDiagnostic Create_ComponentNamesCannotStartWithLowerCase(string componentName, SourceSpan? source = null)
346public static RazorDiagnostic Create_UnexpectedMarkupElement(string elementName, SourceSpan? source = null)
354public static RazorDiagnostic Create_InconsistentStartAndEndTagName(string startTagName, string endTagName, SourceSpan? source = null)
362public static RazorDiagnostic CreateEventHandlerParameter_Duplicates(SourceSpan? source, string attribute, TagHelperDirectiveAttributeParameterIntermediateNode[] attributes)
374public static RazorDiagnostic CreateBindAttributeParameter_UseBindGet(SourceSpan? source, string attribute)
383public static RazorDiagnostic CreateBindAttributeParameter_MissingBindGet(SourceSpan? source, string attribute)
391public static RazorDiagnostic CreateBindAttribute_MissingBindSet(SourceSpan? source, string attributeGet, string attributeSet)
399public static RazorDiagnostic CreateBindAttributeParameter_InvalidSyntaxBindAndBindGet(SourceSpan? source, string attribute)
407public static RazorDiagnostic CreateBindAttributeParameter_InvalidSyntaxBindSetAfter(SourceSpan? source, string attribute)
415public static RazorDiagnostic CreateBindAttributeParameter_UnsupportedSyntaxBindGetSet(SourceSpan? source, string attribute)
425public static RazorDiagnostic CreateFormName_NotAForm(SourceSpan? source)
433public static RazorDiagnostic CreateAttribute_ValidOnlyOnComponent(SourceSpan? source, string attribute)
441public static RazorDiagnostic CreateRenderModeAttribute_ComponentDeclaredRenderMode(SourceSpan? source, string component)
Language\DefaultTagHelperResolutionPhase.cs (38)
335if (diagSource is SourceSpan ds)
342if (elementNode is { HasMissingEndCloseAngle: true, EndTagSpan: SourceSpan endDs })
355if (diagSource is SourceSpan ds)
372if (diagSource is SourceSpan ds)
432if (current.Source is SourceSpan cs && next.Source is SourceSpan ns)
507child.Source ?? SourceSpan.Undefined, childTagName, parentTagName, allowedChildrenString));
522child.Source ?? SourceSpan.Undefined, childTagName, parentTagName, allowedChildrenString));
534child.Source ?? SourceSpan.Undefined, parentTagName, allowedChildrenString));
543child.Source ?? SourceSpan.Undefined, parentTagName, allowedChildrenString));
652SourceSpan? source,
777private static SourceSpan? ComputeValueSource(HtmlAttributeIntermediateNode htmlAttr)
779SourceSpan? result = null;
788if (token.Source is SourceSpan tokenSource)
794else if (child.Source is SourceSpan childSource)
802private static SourceSpan MergeSpans(SourceSpan a, SourceSpan b)
806var first = a.AbsoluteIndex <= b.AbsoluteIndex ? a : b;
807var last = a.AbsoluteIndex + a.Length >= b.AbsoluteIndex + b.Length ? a : b;
819internal static SourceSpan MergeSourceSpans(SourceSpan first, SourceSpan last)
916SourceSpan expressionSource,
934private static (string Content, SourceSpan? Source) CollectAttributeValueContent(HtmlAttributeValueIntermediateNode attrValue)
963private static HtmlContentIntermediateNode CreateEmptyHtmlContent(SourceSpan? source)
975private static CSharpIntermediateToken CreateEmptyCSharpToken(SourceSpan? source)
1001private static SourceSpan? ExtendSpanBackward(SourceSpan? source, int prefixLength)
1017private static (string Content, SourceSpan? MergedSpan) CollectUnresolvedLiteralContent(
1019SourceSpan? valueSourceSpan)
1022SourceSpan? firstSpan = null;
1023SourceSpan? lastSpan = null;
1101if (elementNode.EndTagSpan is SourceSpan ets)
1110if (diagSource is SourceSpan ds)
1157elementNode.Source ?? SourceSpan.Undefined,
1264SourceSpan? valueSourceSpan,
1306SourceSpan? valueSourceSpan,
Language\DefaultTagHelperResolutionPhase.LegacyTagHelperResolver.cs (43)
21SourceSpan? valueSourceSpan,
159unresolvedAttr.AttributeNameSpan ?? SourceSpan.Undefined, attributeName, tagHelperNode.TagName, propertyType!));
184unresolvedAttr.AttributeNameSpan ?? SourceSpan.Undefined, attributeName, tagHelperNode.TagName, propertyType!));
573if (htmlAttr.Source is SourceSpan attrSource && sourceDocument != null)
598var valueSource = new SourceSpan(
617SourceSpan? lastAtTokenSource = null;
627if (intermediateToken.Content == "@" && intermediateToken.Source is SourceSpan src)
629if (lastAtTokenSource is SourceSpan last && last.AbsoluteIndex == src.AbsoluteIndex)
656if (attrContent == "@" && tokenSource is SourceSpan ats)
658if (lastAtTokenSource is SourceSpan last && last.AbsoluteIndex == ats.AbsoluteIndex)
671if (lastAtTokenSource is SourceSpan atSrc)
676var emptySource = new SourceSpan(atSrc.FilePath, transAbsIdx, atSrc.LineIndex, transCharIdx, 0, 0, transCharIdx);
679var transSource = new SourceSpan(atSrc.FilePath, transAbsIdx, atSrc.LineIndex, transCharIdx, 1, 0, transCharIdx + 1);
687if (firstInnerChild.Source is SourceSpan innerSource)
691var openSource = new SourceSpan(innerSource.FilePath, openAbsIndex, innerSource.LineIndex, openCharIndex, 1, 0, openCharIndex + 1);
700if (lastInnerChild.Source is SourceSpan lastSource)
704var closeSource = new SourceSpan(lastSource.FilePath, closeAbsIndex, lastSource.LineIndex, closeCharIndex, 1, 0, closeCharIndex + 1);
720if (htmlAttr.Source is SourceSpan attrSource && sourceDocument != null)
740var openParenSource = new SourceSpan(
766var closeParenSource = new SourceSpan(
851private static SourceSpan? ComputeEmptyValueSource(HtmlAttributeIntermediateNode htmlAttr)
853if (htmlAttr.Source is not SourceSpan attrSource)
1135if (current.Source is SourceSpan currentSource && next.Source is SourceSpan nextSource)
1218if (a.Source is SourceSpan aSource && b.Source is SourceSpan bSource)
1230SourceSpan? valueSourceSpan,
1328var contentSpan = new SourceSpan(
1344SourceSpan? firstSpan = null;
1345SourceSpan? lastSpan = null;
1392SourceSpan vss,
1432SourceSpan? emptySpan = null;
1472using var pendingLiteralParts = new PooledArrayBuilder<(string text, SourceSpan? source)>();
1473SourceSpan? pendingFirstSpan = null;
1474SourceSpan? pendingLastSpan = null;
1565ref PooledArrayBuilder<(string text, SourceSpan? source)> pendingParts,
1566ref SourceSpan? pendingFirstSpan,
1567ref SourceSpan? pendingLastSpan)
1602codeChild.Source ?? elementNode.Source ?? SourceSpan.Undefined, elementNode.TagName));
1610var diagSource = exprChild.Source ?? elementNode.Source ?? SourceSpan.Undefined;
1638ref SourceSpan? firstSpan,
1639ref SourceSpan? lastSpan)
Language\RazorDiagnosticFactory.cs (60)
36public static RazorDiagnostic CreateParsing_UnterminatedStringLiteral(SourceSpan location)
44public static RazorDiagnostic CreateParsing_BlockCommentNotTerminated(SourceSpan location)
52public static RazorDiagnostic CreateParsing_HelperDirectiveNotAvailable(SourceSpan location)
60public static RazorDiagnostic CreateParsing_UnexpectedWhiteSpaceAtStartOfCodeBlock(SourceSpan location)
68public static RazorDiagnostic CreateParsing_UnexpectedEndOfFileAtStartOfCodeBlock(SourceSpan location)
76public static RazorDiagnostic CreateParsing_UnexpectedCharacterAtStartOfCodeBlock(SourceSpan location, string content)
84public static RazorDiagnostic CreateParsing_ExpectedEndOfBlockBeforeEOF(SourceSpan location, string blockName, string closeBlock, string openBlock)
92public static RazorDiagnostic CreateParsing_ReservedWord(SourceSpan location, string content)
100public static RazorDiagnostic CreateParsing_SingleLineControlFlowStatementsCannotContainMarkup(SourceSpan location)
108public static RazorDiagnostic CreateParsing_AtInCodeMustBeFollowedByColonParenOrIdentifierStart(SourceSpan location)
116public static RazorDiagnostic CreateParsing_UnexpectedNestedCodeBlock(SourceSpan location)
124public static RazorDiagnostic CreateParsing_DirectiveTokensMustBeSeparatedByWhitespace(SourceSpan location, string directiveName)
132public static RazorDiagnostic CreateParsing_UnexpectedEOFAfterDirective(SourceSpan location, string directiveName, string expectedToken)
140public static RazorDiagnostic CreateParsing_DirectiveExpectsTypeName(SourceSpan location, string directiveName)
148public static RazorDiagnostic CreateParsing_DirectiveExpectsNamespace(SourceSpan location, string directiveName)
156public static RazorDiagnostic CreateParsing_DirectiveExpectsIdentifier(SourceSpan location, string directiveName)
164public static RazorDiagnostic CreateParsing_DirectiveExpectsQuotedStringLiteral(SourceSpan location, string directiveName)
172public static RazorDiagnostic CreateParsing_UnexpectedDirectiveLiteral(SourceSpan location, string directiveName, string expected)
180public static RazorDiagnostic CreateParsing_DirectiveMustHaveValue(SourceSpan location, string directiveName)
188public static RazorDiagnostic CreateParsing_IncompleteQuotesAroundDirective(SourceSpan location, string directiveName)
196public static RazorDiagnostic CreateParsing_InvalidTagHelperPrefixValue(SourceSpan location, string directiveName, char character, string prefix)
204public static RazorDiagnostic CreateParsing_MarkupBlockMustStartWithTag(SourceSpan location)
212public static RazorDiagnostic CreateParsing_OuterTagMissingName(SourceSpan location)
220public static RazorDiagnostic CreateParsing_TextTagCannotContainAttributes(SourceSpan location)
228public static RazorDiagnostic CreateParsing_UnfinishedTag(SourceSpan location, string tagName)
236public static RazorDiagnostic CreateParsing_MissingEndTag(SourceSpan location, string tagName)
244public static RazorDiagnostic CreateParsing_UnexpectedEndTag(SourceSpan location, string tagName)
252public static RazorDiagnostic CreateParsing_ExpectedCloseBracketBeforeEOF(SourceSpan location, string openBrace, string closeBrace)
260public static RazorDiagnostic CreateParsing_RazorCommentNotTerminated(SourceSpan location)
268public static RazorDiagnostic CreateParsing_TagHelperIndexerAttributeNameMustIncludeKey(SourceSpan location, string attributeName, string tagName)
276public static RazorDiagnostic CreateParsing_TagHelperAttributeListMustBeWellFormed(SourceSpan location)
284public static RazorDiagnostic CreateParsing_TagHelpersCannotHaveCSharpInTagDeclaration(SourceSpan location, string tagName)
292public static RazorDiagnostic CreateParsing_TagHelperAttributesMustHaveAName(SourceSpan location, string tagName)
300public static RazorDiagnostic CreateParsing_TagHelperMustNotHaveAnEndTag(SourceSpan location, string tagName, string displayName, TagStructure tagStructure)
308public static RazorDiagnostic CreateParsing_TagHelperFoundMalformedTagHelper(SourceSpan location, string tagName)
316public static RazorDiagnostic CreateParsing_TagHelperMissingCloseAngle(SourceSpan location, string tagName)
324public static RazorDiagnostic CreateParsing_InvalidTagHelperLookupText(SourceSpan location, string lookupText)
332public static RazorDiagnostic CreateParsing_DirectiveExpectsCSharpAttribute(SourceSpan location, string directiveName)
340public static RazorDiagnostic CreateParsing_DirectiveExpectsBooleanLiteral(SourceSpan location, string directiveName)
348public static RazorDiagnostic CreateParsing_GenericTypeParameterIdentifierMismatch(SourceSpan location, string directiveName, string constraintIdentifier, string originalMember)
356public static RazorDiagnostic CreateParsing_UnexpectedIdentifier(SourceSpan location, string content, params string[] options)
364public static RazorDiagnostic CreateParsing_DirectiveExpectsIdentifierOrExpression(SourceSpan location, string directiveName)
372public static RazorDiagnostic CreateParsing_VoidElement(SourceSpan location, string tagName)
380public static RazorDiagnostic CreateParsing_PreprocessorDirectivesMustBeAtTheStartOfLine(SourceSpan location)
388public static RazorDiagnostic CreateParsing_PossibleMisplacedPreprocessorDirective(SourceSpan location)
396public static RazorDiagnostic CreateParsing_DefineAndUndefNotAllowed(SourceSpan location)
418public static RazorDiagnostic CreateParsing_DuplicateDirective(SourceSpan location, string directive)
426public static RazorDiagnostic CreateParsing_SectionsCannotBeNested(SourceSpan location)
434public static RazorDiagnostic CreateParsing_InlineMarkupBlocksCannotBeNested(SourceSpan location)
442public static RazorDiagnostic CreateParsing_NamespaceImportAndTypeAliasCannotExistWithinCodeBlock(SourceSpan location)
450public static RazorDiagnostic CreateParsing_DirectiveMustAppearAtStartOfLine(SourceSpan location, string directiveName)
458public static RazorDiagnostic CreateTagHelper_CodeBlocksNotSupportedInAttributes(SourceSpan? location)
466public static RazorDiagnostic CreateTagHelper_InlineMarkupBlocksNotSupportedInAttributes(SourceSpan? location, string expectedTypeName)
474public static RazorDiagnostic CreateTagHelper_EmptyBoundAttribute(SourceSpan location, string attributeName, string tagName, string propertyTypeName)
482public static RazorDiagnostic CreateTagHelper_CannotHaveNonTagContent(SourceSpan location, string tagName, string allowedChildren)
490public static RazorDiagnostic CreateTagHelper_InvalidNestedTag(SourceSpan location, string tagName, string parent, string allowedChildren)
498public static RazorDiagnostic CreateTagHelper_InconsistentTagStructure(SourceSpan location, string firstDescriptor, string secondDescriptor, string tagName)
512public static RazorDiagnostic CreateComponent_EditorRequiredParameterNotSpecified(SourceSpan? location, string tagName, string parameterName)
675public static RazorDiagnostic CreateRewriter_InsufficientStack(SourceSpan? location = null)
689public static RazorDiagnostic CreateCssRewriting_ImportNotAllowed(SourceSpan location)
Language\SourceSpan.cs (18)
12public readonly struct SourceSpan : IEquatable<SourceSpan>
14public static readonly SourceSpan Undefined = new SourceSpan(SourceLocation.Undefined, 0);
61public bool Equals(SourceSpan other)
73return obj is SourceSpan span && Equals(span);
99internal readonly SourceSpan GetZeroWidthEndSpan()
104internal readonly SourceSpan Slice(int startIndex, int length)
109public static bool operator ==(SourceSpan left, SourceSpan right)
114public static bool operator !=(SourceSpan left, SourceSpan right)
119public readonly int CompareByStartThenLength(SourceSpan other)
130public readonly SourceSpan WithFilePath(string filePath) => new(filePath, AbsoluteIndex, LineIndex, CharacterIndex, Length, LineCount, EndCharacterIndex);
131public readonly SourceSpan WithAbsoluteIndex(int absoluteIndex) => new(FilePath, absoluteIndex, LineIndex, CharacterIndex, Length, LineCount, EndCharacterIndex);
132public readonly SourceSpan WithLineIndex(int lineIndex) => new(FilePath, AbsoluteIndex, lineIndex, CharacterIndex, Length, LineCount, EndCharacterIndex);
133public readonly SourceSpan WithCharacterIndex(int characterIndex) => new(FilePath, AbsoluteIndex, LineIndex, characterIndex, Length, LineCount, EndCharacterIndex);
134public readonly SourceSpan WithLength(int length) => new(FilePath, AbsoluteIndex, LineIndex, CharacterIndex, length, LineCount, EndCharacterIndex);
135public readonly SourceSpan WithLineCount(int lineCount) => new(FilePath, AbsoluteIndex, LineIndex, CharacterIndex, Length, lineCount, EndCharacterIndex);
136public readonly SourceSpan WithEndCharacterIndex(int endCharacterIndex) => new(FilePath, AbsoluteIndex, LineIndex, CharacterIndex, Length, LineCount, endCharacterIndex);