1 write to Source
Microsoft.CodeAnalysis.Razor.Compiler (1)
Language\RazorCodeDocument.cs (1)
55Source = source;
183 references to Source
Microsoft.AspNetCore.Razor.Language.UnitTests (17)
DefaultRazorCSharpLoweringPhaseTest.cs (3)
22codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source)); 39codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source)); 62codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source));
DefaultRazorIntermediateNodeLoweringPhaseIntegrationTest.cs (1)
178var expectedSourceLocation = new SourceSpan(codeDocument.Source.FilePath, 1, 0, 1, 12);
DefaultRazorIntermediateNodeLoweringPhaseTest.cs (8)
38codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); 76codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); 115codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); 152codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); 182codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); 215codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); 266codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options)); 292codeDocument = codeDocument.WithSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, parseOptions));
DefaultRazorSyntaxTreePhaseTest.cs (3)
68var originalSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); 69var firstPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); 70var secondPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source);
RazorCodeDocumentExtensionsTest.cs (2)
20var importSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); 543var syntaxTree = RazorSyntaxTree.Parse(codeDocument.Source);
Microsoft.AspNetCore.Razor.Test.Common (13)
Language\IntegrationTests\IntegrationTestBase.cs (4)
264(CSharpSyntaxTree)CSharpSyntaxTree.ParseText(csharpDocument.Text, CSharpParseOptions, path: code.CodeDocument.Source.FilePath ?? string.Empty), 464var serializedMappings = SourceMappingsSerializer.Serialize(csharpDocument, codeDocument.Source); 490var sourceContent = codeDocument.Source.Text.ToString(); 496var sourceSpan = span.GetSourceSpan(codeDocument.Source);
Language\IntegrationTests\RazorBaselineIntegrationTestBase.cs (7)
83var serializedMappings = SourceMappingsSerializer.Serialize(document, codeDocument.Source); 103var text = SourceMappingsSerializer.Serialize(document, codeDocument.Source); 142var actualMappings = SourceMappingsSerializer.Serialize(document, codeDocument.Source); 162var content = codeDocument.Source.Text.GetSubText(new TextSpan(sourceMapping.OriginalSpan.AbsoluteIndex, sourceMapping.OriginalSpan.Length)).ToString(); 212Assert.All(linePragmas.Where(p => p.FilePath == codeDocument.Source.FilePath), p => Assert.True(p.IsEnhanced)); 279var lastSlash = codeDocument.Source.FilePath.LastIndexOfAny(['/', '\\']); 280var fileName = lastSlash == -1 ? null : codeDocument.Source.FilePath[(lastSlash + 1)..];
Language\IntegrationTests\RazorIntegrationTestBase.cs (2)
454var windowsPath = Path.Combine(ArbitraryWindowsPath, generated.CodeDocument.Source.RelativePath ?? "").Replace('/', '\\'); 455expected = expected.Replace(windowsPath, generated.CodeDocument.Source.FilePath);
Microsoft.AspNetCore.Razor.Test.Common.Tooling (4)
Language\IntegrationTests\RazorToolingIntegrationTestBase.cs (2)
328var windowsPath = Path.Combine(ArbitraryWindowsPath, generated.CodeDocument.Source.RelativePath).Replace('/', '\\'); 329expected = expected.Replace(windowsPath, generated.CodeDocument.Source.FilePath);
ProjectSystem\TestDocumentSnapshot.cs (2)
45return new(_codeDocument.Source.Text); 65result = _codeDocument.Source.Text;
Microsoft.CodeAnalysis.Razor.Compiler (44)
Language\Components\ComponentDocumentClassifierPass.cs (4)
63var checksum = ChecksumUtilities.BytesToString(codeDocument.Source.Text.GetChecksum()); 140if (codeDocument.Source.FilePath == null || codeDocument.Source.RelativePath == null) 145var relativePath = NormalizePath(codeDocument.Source.RelativePath);
Language\DefaultRazorCSharpLoweringPhase.cs (1)
42codeDocument.Source,
Language\DefaultRazorParsingPhase.cs (1)
22var syntaxTree = RazorSyntaxTree.Parse(codeDocument.Source, options, cancellationToken);
Language\DefaultRazorTagHelperContextDiscoveryPhase_Pooling.cs (1)
40var filePath = codeDocument.Source.FilePath;
Language\DefaultTagHelperResolutionPhase.cs (1)
71var sourceDocument = codeDocument.Source;
Language\Extensions\MetadataAttributePass.cs (3)
65var identifier = _identifierFeature?.GetIdentifier(codeDocument, codeDocument.Source); 108var checksum = codeDocument.Source.Text.GetChecksum(); 109var checksumAlgorithm = codeDocument.Source.Text.ChecksumAlgorithm;
Language\NamespaceComputer.cs (2)
26var filePath = codeDocument.Source.FilePath; 27var relativePath = codeDocument.Source.RelativePath;
Language\RazorCodeDocument.cs (9)
120return new RazorCodeDocument(Source, Imports, ParserOptions, CodeGenerationOptions, value, _referencedTagHelpers, _syntaxTree, _tagHelperRewrittenSyntaxTree, _importSyntaxTrees, _tagHelperContext, _documentNode, _csharpDocument, _directiveTagHelperContributions); 141return new RazorCodeDocument(Source, Imports, ParserOptions, CodeGenerationOptions, _tagHelpers, value, _syntaxTree, _tagHelperRewrittenSyntaxTree, _importSyntaxTrees, _tagHelperContext, _documentNode, _csharpDocument, _directiveTagHelperContributions); 163return new RazorCodeDocument(Source, Imports, ParserOptions, CodeGenerationOptions, _tagHelpers, _referencedTagHelpers, value, _tagHelperRewrittenSyntaxTree, _importSyntaxTrees, _tagHelperContext, _documentNode, _csharpDocument, _directiveTagHelperContributions); 185return new RazorCodeDocument(Source, Imports, ParserOptions, CodeGenerationOptions, _tagHelpers, _referencedTagHelpers, _syntaxTree, value, _importSyntaxTrees, _tagHelperContext, _documentNode, _csharpDocument, _directiveTagHelperContributions); 212return new RazorCodeDocument(Source, Imports, ParserOptions, CodeGenerationOptions, _tagHelpers, _referencedTagHelpers, _syntaxTree, _tagHelperRewrittenSyntaxTree, value, _tagHelperContext, _documentNode, _csharpDocument, _directiveTagHelperContributions); 235return new RazorCodeDocument(Source, Imports, ParserOptions, CodeGenerationOptions, _tagHelpers, _referencedTagHelpers, _syntaxTree, _tagHelperRewrittenSyntaxTree, _importSyntaxTrees, value, _documentNode, _csharpDocument, _directiveTagHelperContributions); 257return new RazorCodeDocument(Source, Imports, ParserOptions, CodeGenerationOptions, _tagHelpers, _referencedTagHelpers, _syntaxTree, _tagHelperRewrittenSyntaxTree, _importSyntaxTrees, _tagHelperContext, value, _csharpDocument, _directiveTagHelperContributions); 279return new RazorCodeDocument(Source, Imports, ParserOptions, CodeGenerationOptions, _tagHelpers, _referencedTagHelpers, _syntaxTree, _tagHelperRewrittenSyntaxTree, _importSyntaxTrees, _tagHelperContext, _documentNode, value, _directiveTagHelperContributions); 292return new RazorCodeDocument(Source, Imports, ParserOptions, CodeGenerationOptions, _tagHelpers, _referencedTagHelpers, _syntaxTree, _tagHelperRewrittenSyntaxTree, _importSyntaxTrees, _tagHelperContext, _documentNode, _csharpDocument, value);
Language\RazorCodeDocumentExtensions.cs (3)
18var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; 44(codeDocument.FileKind.IsLegacy() && string.Equals(Path.GetFileName(codeDocument.Source.FilePath), MvcImportProjectFeature.ImportsFileName, StringComparison.OrdinalIgnoreCase));
Language\RazorHtmlWriter.cs (1)
41var source = codeDocument.Source;
Mvc.Version1_X\MvcViewDocumentClassifierPass.cs (3)
27var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; 32var checksum = ChecksumUtilities.BytesToString(codeDocument.Source.Text.GetChecksum());
Mvc.Version2_X\AssemblyAttributeInjectionPass.cs (1)
51var escapedPath = MakeVerbatimStringLiteral(ConvertToViewEnginePath(codeDocument.Source.RelativePath));
Mvc.Version2_X\MvcViewDocumentClassifierPass.cs (3)
27var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; 32var checksum = ChecksumUtilities.BytesToString(codeDocument.Source.Text.GetChecksum());
Mvc.Version2_X\NamespaceDirective.cs (1)
72@namespace.Name = GetNamespace(codeDocument.Source.FilePath, directive);
Mvc.Version2_X\RazorPageDocumentClassifierPass.cs (4)
59var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath; 64var checksum = ChecksumUtilities.BytesToString(codeDocument.Source.Text.GetChecksum()); 125var leadingDirectiveCodeDocument = LeadingDirectiveParsingEngine.CreateCodeDocument(codeDocument.Source);
Mvc\CreateNewOnMetadataUpdateAttributePass.cs (1)
46var identifier = identifierFeature.GetIdentifier(codeDocument, codeDocument.Source);
Mvc\MvcViewDocumentClassifierPass.cs (1)
47var checksum = ChecksumUtilities.BytesToString(codeDocument.Source.Text.GetChecksum());
Mvc\RazorPageDocumentClassifierPass.cs (2)
77var checksum = ChecksumUtilities.BytesToString(codeDocument.Source.Text.GetChecksum()); 144var leadingDirectiveCodeDocument = LeadingDirectiveParsingEngine.CreateCodeDocument(codeDocument.Source);
SourceGenerators\RazorSourceGenerator.cs (2)
357filePathToDocument.Add(codeDocument.Source.FilePath!, (hintName, codeDocument)); 358hintNameToFilePath.Add(hintName, codeDocument.Source.FilePath!);
Microsoft.CodeAnalysis.Razor.Workspaces (74)
AutoInsert\AutoClosingTagOnAutoInsertProvider.cs (1)
51var sourceText = codeDocument.Source.Text;
AutoInsert\CloseTextTagOnAutoInsertProvider.cs (1)
44if (!codeDocument.Source.Text.TryGetAbsoluteIndex(position, out var absoluteIndex))
CodeActions\CodeActionsService.cs (1)
103var sourceText = codeDocument.Source.Text;
CodeActions\Razor\ComponentAccessibilityCodeActionProvider.cs (2)
292var startTagTextEdit = LspFactory.CreateTextEdit(startTag.Name.GetRange(context.CodeDocument.Source), newTagName); 299var endTagTextEdit = LspFactory.CreateTextEdit(endTag.Name.GetRange(context.CodeDocument.Source), newTagName);
CodeActions\Razor\ExtractToCodeBehindCodeActionResolver.cs (1)
54var removeRange = codeDocument.Source.Text.GetRange(actionParams.RemoveStart, actionParams.RemoveEnd);
CodeActions\Razor\ExtractToComponentCodeActionResolver.cs (1)
44var text = componentDocument.Source.Text;
CodeActions\Razor\ExtractToCssCodeActionResolver.cs (1)
46var removeRange = codeDocument.Source.Text.GetRange(actionParams.RemoveStart, actionParams.RemoveEnd);
CodeActions\Razor\GenerateEventHandlerCodeActionResolver.cs (1)
132Edits = [code.Source.Text.GetTextEdit(razorChange)],
CodeActions\Razor\PromoteUsingCodeActionProvider.cs (1)
47var line = context.CodeDocument.Source.Text.Lines.GetLineFromPosition(context.StartAbsoluteIndex);
CodeActions\Razor\SimplifyFullyQualifiedComponentCodeActionResolver.cs (1)
34var text = codeDocument.Source.Text;
CodeActions\Razor\SimplifyTagToSelfClosingCodeActionResolver.cs (1)
33var text = componentDocument.Source.Text;
CodeActions\Razor\WrapAttributesCodeActionProvider.cs (1)
47var linePositionSpan = attribute.GetLinePositionSpan(context.CodeDocument.Source);
Completion\Delegation\DesignTimeHelperResponseRewriter.cs (1)
49var sourceText = codeDocument.Source.Text;
Completion\Delegation\TextEditResponseRewriter.cs (1)
17var sourceText = codeDocument.Source.Text;
Completion\RazorCompletionListProvider.cs (1)
116var filePath = codeDocument.Source.FilePath.AssumeNotNull();
Diagnostics\RazorDiagnosticHelper.cs (1)
21var sourceText = codeDocument.Source.Text;
Diagnostics\RazorTranslateDiagnosticsService.cs (2)
84var sourceText = codeDocument.Source.Text; 544syntaxTree.FindInnermostNode(codeDocument.Source.Text, originalRange.Start) is { Parent.Parent: RazorUsingDirectiveSyntax usingDirectiveSyntax })
Diagnostics\TaskListDiagnosticProvider.cs (1)
19var source = codeDocument.Source.Text;
DocumentMapping\AbstractDocumentMappingService.cs (6)
54var sourceText = csharpDocument.CodeDocument.Source.Text; 91var sourceText = csharpDocument.CodeDocument.Source.Text; 149razorPosition = csharpDocument.CodeDocument.Source.Text.GetLinePosition(razorIndex); 168var hostDocumentLine = csharpDocument.CodeDocument.Source.Text.GetLinePosition(razorIndex).Line; 301rangeRange = csharpDocument.CodeDocument.Source.Text.GetLinePositionSpan(mapping.OriginalSpan); 372var sourceDocument = csharpDocument.CodeDocument.Source;
DocumentMapping\IDocumentMappingServiceExtensions.cs (1)
25var sourceText = codeDocument.Source.Text;
DocumentMapping\PreferHtmlInAttributeValuesDocumentPositionStrategy.cs (1)
45return new DocumentPositionInfo(RazorLanguageKind.Html, codeDocument.Source.Text.GetPosition(absolutePosition), absolutePosition);
DocumentMapping\RazorEditService.cs (1)
43var originalRazorSourceText = codeDocument.Source.Text;
DocumentMapping\RazorEditService_Methods.cs (2)
44var source = codeDocument.Source; 82var sourceText = codeDocument.Source.Text;
DocumentMapping\RazorEditService_UsingDirectives.cs (5)
168endPosition = AdjustPositionToEndOfLine(endPosition, codeDocument.Source.Text); 190AddRemoveEdit(ref edits, node, codeDocument.Source.Text); 212endPosition = AdjustPositionToEndOfLine(endPosition, codeDocument.Source.Text); 224AddRemoveEdit(ref edits, node, codeDocument.Source.Text); 348else if (firstBlockOfUsingsBuilder[^1].IsNextTo(razorDirective, codeDocument.Source.Text))
DocumentMapping\RazorEditService_WorkspaceEdit.cs (1)
147var razorSourceText = codeDocument.Source.Text;
Extensions\RazorCodeDocumentExtensions.cs (2)
45var sourceText = codeDocument.Source.Text; 105var documentLength = codeDocument.Source.Text.Length;
FindAllReferences\FindAllReferencesHelper.cs (2)
42var line = codeDoc.Source.Text.Lines[lineNumber]; 48return codeDoc.Source.Text.ToString(TextSpan.FromBounds(start, line.End));
FoldingRanges\AbstractSyntaxNodeFoldingProvider.cs (1)
17var sourceText = codeDocument.Source.Text;
FoldingRanges\FoldingRangeService.cs (2)
119var sourceText = codeDocument.Source.Text; 126_logger.LogWarning($"Got a folding range of ({range.StartLine}-{range.EndLine}) but Razor document {codeDocument.Source.FilePath} only has {sourceText.Lines.Count} lines.");
FoldingRanges\UsingsFoldingRangeProvider.cs (1)
18var sourceDocument = codeDocument.Source;
Formatting\FormattingContext.cs (1)
56public SourceText SourceText => CodeDocument.Source.Text;
Formatting\Passes\CSharpFormattingPass.CSharpDocumentGenerator.cs (2)
90lineInfoBuilder.SetCapacityIfLarger(codeDocument.Source.Text.Lines.Count); 158private readonly SourceText _sourceText = codeDocument.Source.Text;
Formatting\Passes\CSharpOnTypeFormattingPass.cs (2)
121var originalText = codeDocument.Source.Text; 1152var documentText = codeDocument.Source.Text.ToString();
Formatting\Passes\HtmlFormattingPass.cs (3)
91var originalText = codeDocument.Source.Text; 278element.GetLinePositionSpan(codeDocument.Source).SpansMultipleLines()) 293comment.GetLinePositionSpan(codeDocument.Source).SpansMultipleLines())
Formatting\RazorFormattingService.cs (2)
86var sourceText = codeDocument.Source.Text; 295logger?.LogSourceText("InitialDocument", codeDocument.Source.Text);
Formatting\UsingDirectiveHelper.cs (6)
136var usingDirectiveLineIndex = codeDocument.Source.Text.GetLinePosition(usingDirective.Node.Span.Start).Line; 173if (endIndex < codeDocument.Source.Text.Length) 175return codeDocument.Source.Text.GetLinePosition(endIndex).Line; 179return codeDocument.Source.Text.Lines.Count; 226var sourceText = codeDocument.Source.Text; 272var sourceText = codeDocument.Source.Text;
Hover\HoverFactory.cs (3)
93var span = containingTagNameToken.GetLinePositionSpan(codeDocument.Source); 95var filePath = codeDocument.Source.FilePath.AssumeNotNull(); 154var span = attribute.GetLinePositionSpan(codeDocument.Source);
LinkedEditingRange\LinkedEditingRangeHelper.cs (3)
22if (!codeDocument.Source.Text.TryGetSourceLocation(linePosition, out var validLocation)) 34var startSpan = startTagNameToken.GetLinePositionSpan(codeDocument.Source); 35var endSpan = endTagNameToken.GetLinePositionSpan(codeDocument.Source);
SemanticTokens\AbstractRazorSemanticTokensInfoService.cs (4)
75var textSpan = codeDocument.Source.Text.GetTextSpan(span); 147var razorSource = codeDocument.Source.Text; 225var sourceText = codeDocument.Source.Text; 293var sourceText = razorCodeDocument.Source.Text;
SemanticTokens\SemanticTokensVisitor.cs (2)
557var source = _razorCodeDocument.Source; 596var source = _razorCodeDocument.Source;
Utilities\WrapWithTagHelper.cs (1)
21var sourceText = codeDocument.Source.Text;
Microsoft.CodeAnalysis.Razor.Workspaces.UnitTests (3)
Diagnostics\TaskListDiagnosticProviderTest.cs (2)
63codeDocument = codeDocument.WithTagHelperRewrittenSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source)); 64var inputText = codeDocument.Source.Text;
Hover\HoverFactoryTest.cs (1)
97var expectedRange = codeDocument.Source.Text.GetRange(code.Span);
Microsoft.CodeAnalysis.Remote.Razor (22)
CodeActions\RemoteCodeActionsService.cs (1)
39var absoluteIndex = codeDocument.Source.Text.GetRequiredAbsoluteIndex(request.Range.Start);
Debugging\RemoteDataTipRangeService.cs (1)
44var razorIndex = codeDocument.Source.Text.GetRequiredAbsoluteIndex(position);
Debugging\RemoteDebugInfoService.cs (1)
118var sourceText = codeDocument.Source.Text;
Diagnostics\RemoteDiagnosticsService.cs (3)
67var sourceText = codeDocument.Source.Text; 114var convertedDiagnostics = RazorDiagnosticHelper.Convert(razorDiagnostics, codeDocument.Source.Text, context.Snapshot); 123var sourceText = codeDocument.Source.Text;
DocumentMapping\RemoteSpanMappingService.cs (2)
109var source = codeDocument.Source.Text; 112var filePath = codeDocument.Source.FilePath.AssumeNotNull();
FindAllReferences\RemoteFindAllReferencesService.cs (1)
56if (!codeDocument.Source.Text.TryGetAbsoluteIndex(position, out var hostDocumentIndex))
Formatting\RemoteFormattingService.cs (1)
117var sourceText = codeDocument.Source.Text;
GoToDefinition\RemoteGoToDefinitionService.cs (1)
53if (!codeDocument.Source.Text.TryGetAbsoluteIndex(position, out var hostDocumentIndex))
GoToImplementation\RemoteGoToImplementationService.cs (1)
49if (!codeDocument.Source.Text.TryGetAbsoluteIndex(position, out var hostDocumentIndex))
Hover\RemoteHoverService.cs (1)
51var sourceText = codeDocument.Source.Text;
InlayHints\RemoteInlayHintService.cs (1)
64var razorSourceText = codeDocument.Source.Text;
InlineCompletion\RemoteInlineCompletionService.cs (2)
37if (!codeDocument.Source.Text.TryGetAbsoluteIndex(linePosition, out var hostDocumentPosition)) 70var hostDocumentIndex = codeDocument.Source.Text.GetRequiredAbsoluteIndex(razorRange.End);
ProjectSystem\Extensions.cs (1)
26var filePath = codeDocument.Source.FilePath;
RazorDocumentServiceBase.cs (1)
52if (!codeDocument.Source.Text.TryGetAbsoluteIndex(position, out var hostDocumentIndex))
RemoveAndSortUsings\RemoteRemoveAndSortUsingsService.cs (2)
43var sourceText = codeDocument.Source.Text; 90return textEdits.SelectAsArray(codeDocument.Source.Text.GetTextChange);
Rename\RemoteRenameService.cs (1)
61var hostDocumentIndex = codeDocument.Source.Text.GetRequiredAbsoluteIndex(position);
SignatureHelp\RemoteSignatureHelpService.cs (1)
36var absoluteIndex = codeDocument.Source.Text.GetRequiredAbsoluteIndex(linePosition);
Microsoft.VisualStudio.LanguageServices.Razor.UnitTests (3)
src\Razor\src\Razor\test\Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests\AutoInsert\PreferHtmlInAttributeValuesDocumentPositionInfoStrategyTest.cs (1)
50var position = codeDocument.Source.Text.GetPosition(cursorPosition);
src\Razor\src\Razor\test\Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests\CodeActions\Html\HtmlCodeActionProviderTest.cs (2)
154.ReturnsAsync(codeDocument.Source.Text); 167codeDocument.Source.Text,
Microsoft.VisualStudioCode.RazorExtension.UnitTests (3)
src\Razor\src\Razor\test\Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests\AutoInsert\PreferHtmlInAttributeValuesDocumentPositionInfoStrategyTest.cs (1)
50var position = codeDocument.Source.Text.GetPosition(cursorPosition);
src\Razor\src\Razor\test\Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests\CodeActions\Html\HtmlCodeActionProviderTest.cs (2)
154.ReturnsAsync(codeDocument.Source.Text); 167codeDocument.Source.Text,