986 references to From
ConfigurationSchemaGenerator.Tests (2)
GeneratorTests.cs (2)
30private static readonly SyntaxTree s_implicitUsingsSyntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From( 1561var sourceSyntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceText));
IdeCoreBenchmarks (3)
ProjectOperationBenchmarks.cs (2)
17private static readonly SourceText s_newText = SourceText.From("text"); 68var emptySourceText = SourceText.From("", Encoding.UTF8);
SyntacticChangeRangeBenchmark.cs (1)
43_text = SourceText.From(text);
Microsoft.Analyzers.Extra.Tests (2)
Resources\FileVisibleToAnalyzer.cs (1)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Resources\RoslynTestUtils.cs (1)
507return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Analyzers.Local.Tests (2)
Resources\FileVisibleToAnalyzer.cs (1)
26public override SourceText? GetText(CancellationToken cancellationToken = default) => SourceText.From(File.ReadAllText(Path));
Resources\RoslynTestUtils.cs (1)
508return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.AspNetCore.Analyzer.Testing (2)
DiagnosticProject.cs (1)
80solution = solution.AddDocument(documentId, newFileName, SourceText.From(sources[i]));
DiagnosticVerifier.cs (1)
181Solution = Solution.AddDocument(documentId, newFileName, SourceText.From(source));
Microsoft.AspNetCore.App.Analyzers (1)
Infrastructure\VirtualChars\CSharpVirtualCharService.cs (1)
204var tokenSourceText = SourceText.From(token.Text);
Microsoft.AspNetCore.App.Analyzers.Test (1)
Verifiers\CSharpSourceGeneratorVerifier.cs (1)
26(typeof(TSourceGenerator), generatedFileName, SourceText.From(generatedSource, Encoding.UTF8))
Microsoft.AspNetCore.Components.Analyzers.Tests (1)
Helpers\DiagnosticVerifier.Helper.cs (1)
164solution = solution.AddDocument(documentId, newFileName, SourceText.From(source));
Microsoft.AspNetCore.Components.SdkAnalyzers.Tests (1)
Helpers\DiagnosticVerifier.Helper.cs (1)
164solution = solution.AddDocument(documentId, newFileName, SourceText.From(source));
Microsoft.AspNetCore.Http.Extensions.Tests (11)
RequestDelegateGenerator\CompileTimeCreationTests.cs (10)
56project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 57project = project.AddDocument("OtherTestMapActions.cs", SourceText.From(otherSource, Encoding.UTF8)).Project; 82project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 83project = project.AddDocument("OtherTestMapActions.cs", SourceText.From(otherSource, Encoding.UTF8)).Project; 165project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8), filePath: Path.Combine(currentDirectory, "TestMapActions.cs")).Project; 232project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 286project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 333project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 669project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project; 726project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
306var project = _baseProject.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
Microsoft.AspNetCore.Http.Microbenchmarks (2)
RequestDelegateGeneratorBenchmarks.cs (1)
32project = project.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
306var project = _baseProject.AddDocument("TestMapActions.cs", SourceText.From(source, Encoding.UTF8)).Project;
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (1)
RuntimeViewCompiler.cs (1)
374var sourceText = SourceText.From(compilationContent, Encoding.UTF8);
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.Test (1)
CSharpCompilerTest.cs (1)
266var syntaxTree = compiler.CreateSyntaxTree(SourceText.From(content));
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (4)
HubClientProxyGenerator.Emitter.cs (2)
123_context.AddSource("HubClientProxy.g.cs", SourceText.From(extensions.ToString(), Encoding.UTF8)); 192_context.AddSource($"HubClientProxy.{typeSpec.TypeName}.g.cs", SourceText.From(registrationMethodBody.ToString(), Encoding.UTF8));
HubServerProxyGenerator.Emitter.cs (2)
75_context.AddSource("HubServerProxy.g.cs", SourceText.From(getProxy.ToString(), Encoding.UTF8)); 163_context.AddSource($"HubServerProxy.{classSpec.ClassTypeName}.g.cs", SourceText.From(proxy.ToString(), Encoding.UTF8));
Microsoft.CodeAnalysis (12)
CommandLine\AnalyzerConfig.cs (1)
180return Parse(SourceText.From(text), pathToFile);
SourceGeneration\GeneratorContexts.cs (2)
82public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 274public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8));
SourceGeneration\IncrementalContexts.cs (2)
121public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8)); 158public void AddSource(string hintName, string source) => AddSource(hintName, SourceText.From(source, Encoding.UTF8));
Text\CompositeText.cs (2)
194return SourceText.From(string.Empty, original.Encoding, original.ChecksumAlgorithm); 223segments.Insert(i, SourceText.From("\r\n"));
Text\LargeText.cs (2)
62return SourceText.From(string.Empty, encoding, checksumAlgorithm); 85return SourceText.From(string.Empty, encodingOpt, checksumAlgorithm);
Text\SourceText.cs (3)
149return From(text, encoding, checksumAlgorithm); 506return SourceText.From(string.Empty, this.Encoding, this.ChecksumAlgorithm); 804var segment = SourceText.From(change.NewText!, this.Encoding, this.ChecksumAlgorithm);
Microsoft.CodeAnalysis.CodeStyle (4)
src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (2)
72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (1)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (1)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile);
Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities (2)
src\Features\DiagnosticsTestUtilities\CodeActions\CodeFixVerifierHelper.cs (2)
103return explicitEditorConfig is object ? SourceText.From(explicitEditorConfig, Encoding.UTF8) : null; 132return SourceText.From(analyzerConfig.ToString(), Encoding.UTF8);
Microsoft.CodeAnalysis.CSharp (11)
Parser\LanguageParser_InterpolatedString.cs (3)
73using var tempLexer = new Lexer(SourceText.From(originalText), this.Options, allowPreprocessorDirectives: false); 374using var tempLexer = new Lexer(SourceText.From(expressionText), options, allowPreprocessorDirectives: false, interpolationFollowedByColon: interpolation.HasColon); 465using var tempLexer = new Lexer(SourceText.From(fakeString), this.Options, allowPreprocessorDirectives: false);
Syntax\CSharpSyntaxTree.cs (2)
460return ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode, cancellationToken); 928=> ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken);
Syntax\CSharpSyntaxTree.Dummy.cs (2)
35return SourceText.From(string.Empty, Encoding, ChecksumAlgorithm); 40text = SourceText.From(string.Empty, Encoding, ChecksumAlgorithm);
Syntax\SyntaxFactory.cs (4)
1562return CSharpSyntaxTree.ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), (CSharpParseOptions?)options, path, diagnosticOptions: null, isGeneratedCode: null, cancellationToken); 1913return SourceText.From(text, Encoding.UTF8).GetSubText(offset); 2790return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken); 2818return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode, cancellationToken);
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (1)
193var tokenSourceText = SourceText.From(token.Text);
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (1)
CommandLineTests.cs (1)
14041context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha1));
Microsoft.CodeAnalysis.CSharp.EditorFeatures (1)
StringCopyPaste\StringCopyPasteHelpers.cs (1)
503var text = SourceText.From(change.NewText);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (64)
CodeActions\ApplyChangesOperationTests.cs (7)
80return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content")); 85return solution.WithDocumentText(document2.Id, SourceText.From("NewProgram2Content")); 112return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content")); 144return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content1")); 149return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content2")); 175return solution.WithDocumentText(document1.Id, SourceText.From("NewProgram1Content1")); 212return solution.WithDocumentText(document2.Id, SourceText.From("NewProgram1Content2"));
Completion\CompletionProviders\LoadDirectiveCompletionProviderTests.cs (1)
87Assert.Equal(expectedResult, provider.ShouldTriggerCompletion(languageServices.LanguageServices, SourceText.From(text), position, trigger: default, CompletionOptions.Default, OptionSet.Empty));
Completion\CompletionProviders\ReferenceDirectiveCompletionProviderTests.cs (1)
128Assert.Equal(expectedResult, provider.ShouldTriggerCompletion(languageServices.LanguageServices, SourceText.From(text), position, trigger: default, CompletionOptions.Default, OptionSet.Empty));
Completion\CompletionServiceTests.cs (3)
49var text = SourceText.From("class C { }"); 107var text = SourceText.From("class C { }"); 221document = document.WithText(SourceText.From(sourceMarkup.Replace("C1", "C2")));
Diagnostics\DiagnosticAnalyzerDriver\DiagnosticAnalyzerDriverTests.cs (1)
165var additionalText = new TestAdditionalText("add.config", SourceText.From("random text"));
EditorConfigSettings\Updater\SettingsUpdaterTests.cs (3)
43.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From(""), filePath: EditorconfigPath))); 55var text = SourceText.From(contents); 413var newText = await settingsProvider.GetChangedEditorConfigAsync(SourceText.From(string.Empty));
ExtractMethod\ExtractMethodTests.cs (1)
11357.AddDocument("Document", SourceText.From(""));
Formatting\CodeCleanupTests.cs (2)
805project = project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfigText), filePath: @"z:\\.editorconfig").Project; 901project = project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfigText), filePath: @"z:\\.editorconfig").Project;
Formatting\CodeCleanupTests.TestFixers.cs (2)
116return solution.AddDocument(DocumentId.CreateNewId(project.Id), "new.cs", SourceText.From("")); 172return solution.AddDocument(DocumentId.CreateNewId(project.Id), "new.cs", SourceText.From(""));
Formatting\Indentation\SmartTokenFormatterFormatTokenTests.cs (2)
565SourceText.From(code).Lines.IndexOf(position), 632SourceText.From(code).Lines.IndexOf(position),
Intents\IntentTestsBase.cs (1)
112testDocument.Update(SourceText.From(currentDocumentText));
PdbSourceDocument\AbstractPdbSourceDocumentTests.cs (2)
162var result = pdbService.TryAddDocumentToWorkspace((MetadataAsSourceWorkspace)masWorkspace!, file.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out _); 199var sourceText = SourceText.From(source, encoding: encoding ?? Encoding.UTF8);
PdbSourceDocument\ImplementationAssemblyLookupServiceTests.cs (17)
43var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 81var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 123var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 161var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 185sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 222var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 245sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 283var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 306sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 338var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 361sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 389var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 412sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 454var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 477sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 512var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 535var typeForwardSourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
PdbSourceDocument\PdbSourceDocumentTests.cs (13)
409var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 439var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8); 475var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 522var sourceText = SourceText.From(metadataSource, Encoding.UTF8); 548sourceText = SourceText.From(typeForwardSource, Encoding.UTF8); 725CompileTestSource(path, SourceText.From(source2, Encoding.UTF8), project, Location.OnDisk, Location.OnDisk, buildReferenceAssembly: false, windowsPdb: false); 876var sourceText = SourceText.From(source, Encoding.UTF8); 927var sourceText1 = SourceText.From(source1, Encoding.UTF8); 928var sourceText2 = SourceText.From(source2, Encoding.UTF8); 975var result = service.TryAddDocumentToWorkspace(requestPath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentId); 998var openResult = service.TryAddDocumentToWorkspace(file.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentId); 1049var openResult = service.TryAddDocumentToWorkspace(fileOne.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentId); 1060Assert.Throws<System.InvalidOperationException>(() => service.TryAddDocumentToWorkspace(fileTwo.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentIdTwo));
StringIndentation\StringIndentationTests.cs (1)
42var text = SourceText.From(val);
Workspaces\WorkspaceTests_EditorFeatures.cs (7)
733var newSolution = oldSolution.WithDocumentText(document.Id, SourceText.From(newText)); 761var newSolution = oldSolution.AddDocument(DocumentId.CreateNewId(project1.Id), "Doc2", SourceText.From(doc2Text)); 1114var newSolution = oldSolution.WithAdditionalDocumentText(additionalDoc.Id, SourceText.From(newText)); 1147var newSolution = oldSolution.WithAnalyzerConfigDocumentText(analyzerConfigDoc.Id, SourceText.From(newText)); 1273var newSolution = oldSolution.AddAnalyzerConfigDocument(newDocId, "app.config", SourceText.From("text")); 1337var doc = project.AddAnalyzerConfigDocument("app.config", SourceText.From("text")); 1421workspace.GetTestDocument(originalDocumentId).Update(SourceText.From("class Program2 { }"));
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (1)
CodeGen\CodeGenTupleTest.cs (1)
22612var text = SourceText.From(source1);
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (7)
PDB\CheckSumTest.cs (2)
34var tree1 = SyntaxFactory.ParseSyntaxTree(StringText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), path: "sha1.cs"); 35var tree256 = SyntaxFactory.ParseSyntaxTree(StringText.From(source256, Encoding.UTF8, SourceHashAlgorithm.Sha256), path: "sha256.cs");
PDB\CSharpPDBTestBase.cs (1)
39var text = SourceText.From(source);
PDB\PDBTests.cs (4)
47var tree3 = SyntaxFactory.ParseSyntaxTree(SourceText.From("class C { }", encoding: null), path: "Bar.cs"); 68var tree4 = SyntaxFactory.ParseSyntaxTree(SourceText.From("class D { public void F() { } }", new UTF8Encoding(false, false)), path: "Baz.cs"); 104context.AddSource("hint2", SourceText.From("class G2 { void F() {} }", Encoding.UTF8, checksumAlgorithm: SourceHashAlgorithm.Sha256)); 106Assert.Throws<ArgumentException>(() => context.AddSource("hint3", SourceText.From("class G3 { void F() {} }", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha256)));
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (11)
EditAndContinue\CSharpEditAndContinueAnalyzerTests.cs (11)
45AddDocument("test.cs", SourceText.From(source, Encoding.UTF8), filePath: Path.Combine(TempRoot.Root, "test.cs")).Project.Solution; 307var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 372var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 434var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 516var newSolution = workspace.CurrentSolution.WithDocumentText(documentId, SourceText.From(source2)); 585var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 624var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)); 665var newSolution = oldSolution.AddDocument(newDocId, "goo.cs", SourceText.From(source2), filePath: Path.Combine(TempRoot.Root, "goo.cs")); 711var newSolution = oldSolution.AddDocument(newDocId, "goo.cs", SourceText.From(source2), filePath: Path.Combine(TempRoot.Root, "goo.cs")); 744var newSolution = oldSolution.AddDocument(documentId, "goo.cs", SourceText.From(source2), filePath: filePath); 799var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2));
Microsoft.CodeAnalysis.CSharp.Scripting (1)
CSharpScript.cs (1)
37return Script.CreateInitialScript<T>(CSharpScriptCompiler.Instance, SourceText.From(code, options?.FileEncoding, SourceHashAlgorithms.Default), options, globalsType, assemblyLoader);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (53)
Semantics\TopLevelStatementsTests.cs (1)
8788var newText = SourceText.From(text2, Encoding.UTF8, SourceHashAlgorithms.Default);
SourceGeneration\AdditionalSourcesCollectionTests.cs (23)
54asc.Add(hintName, SourceText.From("public class D{}", Encoding.UTF8)); 70asc.Add(hintName, SourceText.From("public class D{}", Encoding.UTF8)); 110var exception = Assert.Throws<ArgumentException>(nameof(hintName), () => asc.Add(hintName, SourceText.From("public class D{}", Encoding.UTF8))); 120asc.Add("file3.cs", SourceText.From("", Encoding.UTF8)); 121asc.Add("file1.cs", SourceText.From("", Encoding.UTF8)); 122asc.Add("file2.cs", SourceText.From("", Encoding.UTF8)); 123asc.Add("file5.cs", SourceText.From("", Encoding.UTF8)); 124asc.Add("file4.cs", SourceText.From("", Encoding.UTF8)); 144asc.Add(names[i], SourceText.From("", Encoding.UTF8)); 166asc.Add(hintName1, SourceText.From("", Encoding.UTF8)); 167var exception = Assert.Throws<ArgumentException>("hintName", () => asc.Add(hintName2, SourceText.From("", Encoding.UTF8))); 176asc.Add("hintName1", SourceText.From("", Encoding.UTF8)); 177asc.Add("hintName2", SourceText.From("", Encoding.UTF8)); 180asc2.Add("hintName3", SourceText.From("", Encoding.UTF8)); 181asc2.Add("hintName1", SourceText.From("", Encoding.UTF8)); 200asc.Add(addHintName, SourceText.From("", Encoding.UTF8)); 212asc.Add(addHintName, SourceText.From("", Encoding.UTF8)); 224asc.Add("file1.cs", SourceText.From("", Encoding.UTF8)); 225asc.Add("file2.cs", SourceText.From("", Encoding.UTF32)); 226asc.Add("file3.cs", SourceText.From("", Encoding.Unicode)); 229Assert.Throws<ArgumentException>(() => asc.Add("file4.cs", SourceText.From(""))); 232Assert.Throws<ArgumentException>(() => asc.Add("file5.cs", SourceText.From("", encoding: null))); 234var exception = Assert.Throws<ArgumentException>(() => asc.Add("file5.cs", SourceText.From("", encoding: null)));
SourceGeneration\GeneratorDriverTests.cs (12)
460sgc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 463Assert.Throws<ArgumentException>("hintName", () => sgc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8))); 466Assert.Throws<ArgumentException>("hintName", () => sgc.AddSource("test.cs", SourceText.From("public class D{}", Encoding.UTF8))); 491spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 494Assert.Throws<ArgumentException>("hintName", () => spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8))); 497Assert.Throws<ArgumentException>("hintName", () => spc.AddSource("test.cs", SourceText.From("public class D{}", Encoding.UTF8))); 504spc.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); 586var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("test", SourceText.From("public class D {}", Encoding.UTF8)); }); 616var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("test", SourceText.From("public class D {}", Encoding.UTF8)); sgc.AddSource("test2", SourceText.From("public class E {}", Encoding.UTF8)); }); 756e.AddSource("a", SourceText.From("public class E {}", Encoding.UTF8)); 780var generator = new CallbackGenerator((ic) => { }, (sgc) => { sgc.AddSource("a", SourceText.From("")); });
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.cs (6)
1525driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From("")))); 1567driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1615driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1668driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1729compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1781compilation.SyntaxTrees.First().WithChangedText(SourceText.From("""
SourceGeneration\GeneratorDriverTests_Attributes_SimpleName.cs (8)
1160compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(""" 1210compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(""" 1266compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1423compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1468compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1520compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1571compilation.SyntaxTrees.First().WithChangedText(SourceText.From(""" 1633compilation.SyntaxTrees.Last().WithChangedText(SourceText.From("""
SourceGeneration\SyntaxAwareGeneratorTests.cs (3)
420onExecute: (e) => { e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 510onExecute: (e) => { receiver = e.SyntaxReceiver; e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); } 2052onExecute: (e) => { e.AddSource("test", SourceText.From("public class D{}", Encoding.UTF8)); }
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (139)
Diagnostics\LineSpanDirectiveTests.cs (8)
27var textA = SourceText.From(sourceA); 73var textA = SourceText.From(sourceA); 166var textA = SourceText.From(sourceA); 217var textA = SourceText.From(sourceA); 245var textB = SourceText.From(sourceB); 286var textA = SourceText.From(sourceA); 335var textA = SourceText.From(sourceA); 389var textA = SourceText.From(sourceA);
IncrementalParsing\IncrementalParsingTests.cs (90)
29var itext = SourceText.From(text); 36var itext = SourceText.From(text); 961var text = SourceText.From(@"partial class C{}"); 975var text = SourceText.From(@"partial class C{}"); 989SourceText oldText = SourceText.From(@" 1005SourceText oldText = SourceText.From(@" 1021SourceText oldText = SourceText.From(@" 1038SourceText oldText = SourceText.From(@" 1054SourceText oldText = SourceText.From(@" 1067SourceText oldText = SourceText.From(@" 1083SourceText oldText = SourceText.From(@" 1095SourceText oldText = SourceText.From(@" 1107SourceText oldText = SourceText.From(@" class A 1123SourceText oldText = SourceText.From(@"public class TestClass 1136SourceText oldText = SourceText.From(@"using System; 1151SourceText oldText = SourceText.From(@"public class MyClass { 1163SourceText oldText = SourceText.From(@" 1177SourceText startingText = SourceText.From(@" 1198SourceText startingText = SourceText.From(@" 1217SourceText startingText = SourceText.From(@" 1237SourceText oldText = SourceText.From(@"class MyClass 1257SourceText oldText = SourceText.From(@" 1281SourceText oldText = SourceText.From(@" 1305SourceText oldText = SourceText.From(@"interface IGoo 1329SourceText oldText = SourceText.From(@"interface IGoo 1353SourceText oldText = SourceText.From(@"using System.Runtime.CompilerServices; 1375SourceText oldText = SourceText.From(@"class A 1399SourceText oldText = SourceText.From(@"public class MyClass { 1421SourceText oldText = SourceText.From(@"public class MyClass { 1512SourceText oldText = SourceText.From(@"class filesystem{ 1531SourceText oldText = SourceText.From(@"class CSTR020mod{ public static void CSTR020() { ON ERROR GOTO ErrorTrap; } }"); 1547SourceText oldText = SourceText.From(@"class A 1567SourceText oldText = SourceText.From(@"public class DynClassDrived 1589SourceText oldText = SourceText.From(@"public class MemberClass 1609SourceText oldText = SourceText.From(@"public class MemberClass 1628SourceText oldText = SourceText.From(@"class Test 1650SourceText oldText = SourceText.From( 1677SourceText oldText = SourceText.From( 1703SourceText oldText = SourceText.From( 1728SourceText oldText = SourceText.From( 1750SourceText oldText = SourceText.From( 1805SourceText oldText = SourceText.From( 1827SourceText oldText = SourceText.From( 1848SourceText oldText = SourceText.From( 1869SourceText oldText = SourceText.From( 1892SourceText oldText = SourceText.From( 1913SourceText oldText = SourceText.From( 1933SourceText oldText = SourceText.From( 1951SourceText oldText = SourceText.From( 1972SourceText oldText = SourceText.From( 1995SourceText oldText = SourceText.From( 2012SourceText oldText = SourceText.From( 2030SourceText oldText = SourceText.From( 2048SourceText oldText = SourceText.From( 2069SourceText oldText = SourceText.From( 2104SourceText oldText = SourceText.From( 2128SourceText oldText = SourceText.From( 2146SourceText oldText = SourceText.From( 2164SourceText oldText = SourceText.From( 2183SourceText oldText = SourceText.From( 2214SourceText oldText = SourceText.From( 2239SourceText oldText = SourceText.From( 2258SourceText oldText = SourceText.From( 2276SourceText oldText = SourceText.From( 2295SourceText oldText = SourceText.From( 2314SourceText oldText = SourceText.From( 2335SourceText oldText = SourceText.From( 2354SourceText oldText = SourceText.From( 2381SourceText oldText = SourceText.From( 2409SourceText oldText = SourceText.From( 2431SourceText oldText = SourceText.From( 2450SourceText oldText = SourceText.From( 2482SourceText oldText = SourceText.From( 2515SourceText oldText = SourceText.From( 2541SourceText oldText = SourceText.From( 2566SourceText oldText = SourceText.From( 2596SourceText oldText = SourceText.From( 2625SourceText oldText = SourceText.From( 2646SourceText oldText = SourceText.From( 2678SourceText oldText = SourceText.From( 2706SourceText oldText = SourceText.From( 2744var text = SourceText.From(str); 2762SourceText oldText = SourceText.From(@" 2780SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2809SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 2839SourceText oldText = SourceText.From(@"System.Console.WriteLine(true) 3097var oldText = SourceText.From(items[0]); 3128var oldText = SourceText.From(@" 3154var newText = SourceText.From(@" 3772SourceText newText = SourceText.From(token + oldText.ToString());
LexicalAndXml\CrefLexerTests.cs (1)
444using (var lexer = new InternalSyntax.Lexer(SourceText.From(text + "'"), TestOptions.RegularWithDocumentationComments))
LexicalAndXml\LexicalTests.cs (2)
73using (var lexer = new InternalSyntax.Lexer(SourceText.From(text), _options)) 86using (var lexer = new InternalSyntax.Lexer(SourceText.From(text), _options))
LexicalAndXml\NameAttributeValueLexerTests.cs (1)
408using (var lexer = new InternalSyntax.Lexer(SourceText.From(text + "'"), TestOptions.RegularWithDocumentationComments))
LexicalAndXml\PreprocessorTests.cs (2)
93var itext = SourceText.From(text); 100var itext = SourceText.From(text);
LexicalAndXml\SyntaxTokenParserTests.cs (16)
19var sourceText = SourceText.From("class C { }"); 29var sourceText = SourceText.From(""" 66var sourceText = SourceText.From(""" 110var sourceText = SourceText.From(""" 149var sourceText = SourceText.From(""" 183var sourceText = SourceText.From("""class"""); 193var sourceText = SourceText.From("class C { }"); 202var sourceText = SourceText.From("class C { }"); 212var sourceText = SourceText.From(""" 261var sourceText = SourceText.From("when identifier class"); 272var sourceText = SourceText.From("class C { }"); 291var sourceText = SourceText.From("/* test */ class C { }"); 320var sourceText = SourceText.From(""" 354var sourceText = SourceText.From("class C { }"); 368var sourceText = SourceText.From("/* test */ class C { }"); 387var sourceText = SourceText.From("""
LexicalAndXml\XmlDocCommentTests.cs (1)
34var itext = SourceText.From(text);
Parsing\ParsingTests.cs (1)
371var lexer = new Syntax.InternalSyntax.Lexer(Text.SourceText.From(text), CSharpParseOptions.Default);
Parsing\RoundTrippingTests.cs (3)
28var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text), options); 103var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(text), path: ""); 1581var itext = SourceText.From(text);
Syntax\Mocks\MockCSharpSyntaxTree.cs (1)
29_sourceText = source ?? SourceText.From("", Encoding.UTF8, SourceHashAlgorithm.Sha256);
Syntax\SyntaxTreeTests.cs (9)
86SyntaxTreeFactoryKind.ParseText => CSharpSyntaxTree.ParseText(SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256), parseOptions), 87SyntaxTreeFactoryKind.Subclass => new MockCSharpSyntaxTree(root, SourceText.From(source, Encoding.UTF8, SourceHashAlgorithm.Sha256), parseOptions), 142SourceText.From(""), 149var newTree = tree.WithChangedText(SourceText.From("class C { }")); 157SourceText.From(""), 173SourceText.From(""), 189SourceText.From(""), 259var oldText = SourceText.From("class B {}", Encoding.Unicode, SourceHashAlgorithms.Default); 301var oldText = SourceText.From("class B {}", Encoding.Unicode, SourceHashAlgorithms.Default);
TextExtensions.cs (4)
27return SourceText.From(newFullText); 37return SourceText.From(newFullText); 47return SourceText.From(newFullText); 61return SourceText.From(newFullText);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (3)
BasicCompilationUtils.cs (1)
36var tree = VisualBasicSyntaxTree.ParseText(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default));
CSharpTestSource.cs (1)
41var stringText = SourceText.From(text, encoding ?? Encoding.UTF8, checksumAlgorithm);
DiagnosticTestUtilities.cs (1)
67select SyntaxFactory.ParseSyntaxTree(SourceText.From(text, encoding: null, SourceHashAlgorithms.Default))).ToArray();
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\EmbeddedLanguages\VirtualChars\CSharpVirtualCharService.cs (1)
193var tokenSourceText = SourceText.From(token.Text);
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (2)
Formatting\FormattingMultipleSpanTests.cs (1)
165var document = project.AddDocument("Document", SourceText.From(""));
Formatting\FormattingTreeEditTests.cs (1)
25return project.AddDocument("code", SourceText.From(code));
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (3)
LanguageServer\AbstractLanguageServerProtocolTests.cs (1)
417var loader = TextLoader.From(TextAndVersion.Create(SourceText.From(markup), version, TestSpanMapper.GeneratedFileName));
Rename\RenamerTests.cs (2)
55var startSourceText = SourceText.From(startDocument.Text); 188var startSourceText = SourceText.From(startDocument.Text);
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (21)
CodeFixes\CodeFixServiceTests.cs (2)
949var newText = SourceText.From(text.ToString() + Title); 1069sourceDocument = sourceDocument.WithText(SourceText.From(code));
CodeGeneration\AbstractCodeGenerationTests.cs (1)
36.AddDocument("Fake Document", SourceText.From(normalizedSyntax));
CodeRefactorings\CodeRefactoringServiceTest.cs (3)
206.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(""), filePath: "c:\\.editorconfig").Project 207.AddAnalyzerConfigDocument(".globalconfig", SourceText.From("is_global = true"), filePath: "c:\\.globalconfig").Project; 246var newText = SourceText.From(text.ToString() + Title);
Diagnostics\DiagnosticAnalyzerServiceTests.cs (6)
173project = project.AddAnalyzerConfigDocument(".editorconfig", filePath: "z:\\.editorconfig", text: SourceText.From(editorconfigText)).Project; 176var document = project.AddDocument("test.cs", SourceText.From("class A {}"), filePath: "z:\\test.cs"); 312loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A {}"), VersionStamp.Create(), filePath: "test.cs")), 361text: SourceText.From(analyzerConfigText), 391loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A {}"), VersionStamp.Create(), filePath: "test.cs")), 891return workspace.AddDocument(project.Id, "Empty.cs", SourceText.From("class A { B B {get} }"));
EditAndContinue\EditAndContinueLanguageServiceTests.cs (2)
119.AddDocument(documentId = DocumentId.CreateNewId(projectId), "test.cs", SourceText.From("class C { }", Encoding.UTF8), filePath: "test.cs")); 270Text = SourceText.From(source3, Encoding.UTF8, SourceHashAlgorithm.Sha1)
Extensions\ITextExtensionsTests.cs (1)
129var text = SourceText.From(code);
Extensions\ITextLineExtensionsTests.cs (1)
129var text = SourceText.From(codeLine);
Preview\PreviewWorkspaceTests.cs (2)
80var changedSolution = previewWorkspace.CurrentSolution.Projects.First().Documents.First().WithText(SourceText.From(text)).Project.Solution; 100var sourceTextContainer = SourceText.From("Text").Container;
SymbolFinder\DependentTypeFinderTests.cs (1)
40return solution.AddProject(pi).AddDocument(did, $"{projectName}.{suffix}", SourceText.From(code));
Workspaces\TextFactoryTests.cs (2)
85var text = SourceText.From("Hello, World!"); 105var text = SourceText.From("Hello, World!", Encoding.ASCII);
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (4)
Diagnostics\AdditionalFileDiagnosticsTests.vb (1)
45Dim newSln = workspace.CurrentSolution.AddAdditionalDocument(DocumentId.CreateNewId(project.Id), "App.Config", SourceText.From("false"))
Diagnostics\DiagnosticServiceTests.vb (1)
1418additionalDoc = additionalDoc.WithText(SourceText.From(newAdditionalDocText))
FindReferences\FindReferencesTests.vb (1)
524solution = solution.WithDocumentText(document2.Id, SourceText.From(""))
Simplification\ParameterSimplificationTests.vb (1)
24.AddDocument("Document", SourceText.From(input))
Microsoft.CodeAnalysis.Features (6)
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (1)
509private static readonly SourceText s_emptySource = SourceText.From("");
EditAndContinue\CommittedSolution.cs (1)
341return SourceText.From(text, sourceText.Encoding, checksumAlgorithm);
MetadataAsSource\MetadataAsSourceGeneratedFileInfo.cs (1)
74var assemblyInfoSourceText = SourceText.From(assemblyInfoString, Encoding, ChecksumAlgorithm);
SemanticSearch\SemanticSearchUtilities.cs (1)
64=> SourceText.From(query, Encoding.UTF8, SourceHashAlgorithm.Sha256);
src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (2)
72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
Microsoft.CodeAnalysis.Features.Test.Utilities (1)
Snippets\AbstractSnippetProviderTests.cs (1)
44var editorConfigDoc = document.Project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfig), filePath: "/.editorconfig");
Microsoft.CodeAnalysis.Features.UnitTests (17)
EditAndContinue\ActiveStatementsMapTests.cs (3)
118.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution; 173.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution; 224.AddDocument("doc", SourceText.From(source, Encoding.UTF8), filePath: "a.cs").Project.Solution;
EditAndContinue\CompileTimeSolutionProviderTests.cs (5)
48AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: additionalFilePath). 49AddAnalyzerConfigDocument(analyzerConfigId, "config", SourceText.From(""), filePath: "RazorSourceGenerator.razorencconfig"). 102context.AddSource("hint", SourceText.From(s)); 117.AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: "additional.razor") 118.AddAnalyzerConfigDocument(analyzerConfigId, "config", SourceText.From(analyzerConfigText), filePath: "Z:\\RazorSourceGenerator.razorencconfig"),
EditAndContinue\EditAndContinueWorkspaceServiceTests.cs (4)
408solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 428solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath); 623AddDocument("a.cs", SourceText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 923AddDocument(documentId, "test.cs", SourceText.From(source1, encoding, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path);
EditAndContinue\EditSessionActiveStatementsTests.cs (2)
321var baseText = SourceText.From(baseSource); 473var sourceTextV1 = SourceText.From(markedSourceV1);
EditAndContinue\EmitSolutionUpdateResultsTests.cs (1)
73AddDocument(sourcePath, SourceText.From("class C {}", Encoding.UTF8), filePath: Path.Combine(TempRoot.Root, sourcePath));
EditAndContinue\RemoteEditAndContinueServiceTests.cs (1)
81.AddDocument(documentId, "test.cs", SourceText.From("class C { }", Encoding.UTF8), filePath: "test.cs")
EditAndContinue\WatchHotReloadServiceTests.cs (1)
136context.AddSource("generated.cs", SourceText.From("generated: " + additionalText, Encoding.UTF8, SourceHashAlgorithm.Sha256));
Microsoft.CodeAnalysis.LanguageServer (1)
HostWorkspace\Razor\RazorDynamicFileInfoProvider.cs (1)
144return Task.FromResult(TextAndVersion.Create(SourceText.From(""), VersionStamp.Default));
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (9)
ProtocolConversionsTests.cs (6)
192var sourceText = SourceText.From(markup); 205var sourceText = SourceText.From(markup); 219var sourceText = SourceText.From(markup); 238var sourceText = SourceText.From(markup); 252var sourceText = SourceText.From(markup); 262var sourceText = SourceText.From(markup);
Workspaces\LspWorkspaceManagerTests.cs (2)
558.AddDocument(filePath, SourceText.From("ProjectSystemText"), filePath: filePath) 615testLspServer.TestWorkspace.CurrentSolution.WithDocumentText(document.Id, SourceText.From("New Disk Contents")));
Workspaces\SourceGeneratedDocumentTests.cs (1)
173await testLspServer.TestWorkspace.ChangeDocumentAsync(testLspServer.TestWorkspace.Documents.Single(d => !d.IsSourceGenerated).Id, SourceText.From("new text"));
Microsoft.CodeAnalysis.Rebuild.UnitTests (1)
BasicDeterministicKeyBuilderTests.cs (1)
32SourceText.From(content, checksumAlgorithm: hashAlgorithm, encoding: Encoding.UTF8),
Microsoft.CodeAnalysis.Scripting (4)
Hosting\CommandLine\CommandLineRunner.cs (3)
233var script = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(initialScriptCodeOpt), options, globals.GetType(), assemblyLoaderOpt: null); 260var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), options.ParseOptions, cancellationToken); 285newScript = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(code ?? string.Empty), options, globals.GetType(), assemblyLoaderOpt: null);
Script.cs (1)
118return new Script<TResult>(Compiler, Builder, SourceText.From(code ?? "", options.FileEncoding), options, GlobalsType, this);
Microsoft.CodeAnalysis.Scripting.TestUtilities (3)
TestCompilationFactory.cs (3)
24new[] { CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) }, 33new[] { VisualBasic.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) }, 42new[] { CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) },
Microsoft.CodeAnalysis.Test.Utilities (15)
AssemblyLoadTestFixture.cs (1)
532syntaxTrees: new SyntaxTree[] { SyntaxFactory.ParseSyntaxTree(SourceText.From(csSource, encoding: null, SourceHashAlgorithms.Default)) },
CommonTestBase.cs (2)
388var tree = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(code, encoding: null, SourceHashAlgorithms.Default), options: parseOptions); 478trees[i] = VisualBasic.VisualBasicSyntaxTree.ParseText(SourceText.From(files[i], encoding, SourceHashAlgorithms.Default), options: parseOptions, path: sourceFileNames?[i]);
Compilation\CompilationExtensions.cs (1)
510new[] { CSharpSyntaxTree.ParseText(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default)) },
Mocks\Silverlight.cs (4)
88CSharpSyntaxTree.ParseText(SourceText.From(TestResources.NetFX.Minimal.mincorlib_cs)), 89CSharpSyntaxTree.ParseText(SourceText.From(corlibExtraCode)), 90CSharpSyntaxTree.ParseText(SourceText.From(assemblyAttributes)), 98syntaxTrees: [CSharpSyntaxTree.ParseText(SourceText.From(assemblyAttributes))],
Mocks\StdOle.cs (2)
75CSharpSyntaxTree.ParseText(SourceText.From(code)), 76CSharpSyntaxTree.ParseText(SourceText.From(assemblyAttributes))
SourceGeneration\TestGenerators.cs (4)
40context.AddSource(hintName, SourceText.From(content, Encoding.UTF8)); 98: SourceText.From(source, Encoding.UTF8))); 109: SourceText.From(source, Encoding.UTF8))); 145_content = SourceText.From(content, Encoding.UTF8);
TestBase.cs (1)
192var syntaxTree = Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(source, encoding: null, SourceHashAlgorithms.Default));
Microsoft.CodeAnalysis.TestAnalyzerReference (4)
HelloWorldGenerator.cs (3)
27context.AddSource(GeneratedEnglishClassName, SourceText.From($$""" 38context.AddSource(GeneratedSpanishClassName, SourceText.From($$""" 48context.AddSource(GeneratedEnglishClassName + "WithTime", SourceText.From($$"""
NonSourceFileRefactoring.cs (1)
28var newText = SourceText.From(text.ToString() + Environment.NewLine + "# Refactored");
Microsoft.CodeAnalysis.UnitTests (134)
AnalyzerAssemblyLoaderTests.cs (2)
1213[CSharpSyntaxTree.ParseText(SourceText.From(testCode, encoding: null, checksumAlgorithm: SourceHashAlgorithms.Default))], 1315[CSharpSyntaxTree.ParseText(SourceText.From(analyzerCode, encoding: null, checksumAlgorithm: SourceHashAlgorithms.Default))],
EmbeddedTextTests.cs (6)
39Assert.Throws<ArgumentException>("text", () => EmbeddedText.FromSource("path", SourceText.From("source"))); 103var source = SourceText.From("", new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), SourceHashAlgorithm.Sha1); 145var source = SourceText.From(SmallSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 187var source = SourceText.From(LargeSource, Encoding.Unicode, SourceHashAlgorithms.Default); 200var expected = SourceText.From(SmallSource, Encoding.UTF8, SourceHashAlgorithm.Sha1); 215var expected = SourceText.From(LargeSource, Encoding.UTF8, SourceHashAlgorithm.Sha1);
Text\CompositeTextTests.cs (3)
56var sourceText = SourceText.From(contents); 75yield return [SourceText.From(contents)]; 82var sourceText = SourceText.From(contents[..i]);
Text\SourceTextStreamTests.cs (2)
27var sourceText = SourceText.From("hello world", s_utf8NoBom); 50var sourceText = SourceText.From(text, encoding);
Text\SourceTextTests.cs (19)
56Assert.Same(s_utf8, SourceText.From(HelloWorld, s_utf8).Encoding); 57Assert.Same(s_unicode, SourceText.From(HelloWorld, s_unicode).Encoding); 85Assert.Equal(SourceHashAlgorithm.Sha1, SourceText.From(HelloWorld).ChecksumAlgorithm); 99Assert.Equal(algorithm, SourceText.From(HelloWorld, checksumAlgorithm: algorithm).ChecksumAlgorithm); 121verifyChecksumAndContentHash(SourceText.From(HelloWorld, encodingNoBOM, checksumAlgorithm), checksumNoBOM, expectedContentHash); 122verifyChecksumAndContentHash(SourceText.From(HelloWorld, encodingBOM, checksumAlgorithm), checksumBOM, expectedContentHash); 166verifyChecksumAndContentHash(fromChanges(SourceText.From(HelloWorld, encodingNoBOM, checksumAlgorithm)), checksumNoBOM, expectedContentHash); 167verifyChecksumAndContentHash(fromChanges(SourceText.From(HelloWorld, encodingBOM, checksumAlgorithm)), checksumBOM, expectedContentHash); 213var f = SourceText.From(HelloWorld, s_utf8); 215Assert.True(f.ContentEquals(SourceText.From(HelloWorld, s_utf8))); 216Assert.False(f.ContentEquals(SourceText.From(HelloWorld + "o", s_utf8))); 217Assert.True(SourceText.From(HelloWorld, s_utf8).ContentEquals(SourceText.From(HelloWorld, s_utf8))); 353var expectedSourceText = SourceText.From(expected); 369var expectedSourceText = SourceText.From(expected); 425var sourceText = SourceText.From("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); 444var sourceText = SourceText.From(Text); 456SourceText.From("ABC").Write(TextWriter.Null, TextSpan.FromBounds(4, 4))); 465SourceText.From("ABC").Write(TextWriter.Null, TextSpan.FromBounds(2, 4)));
Text\StringText_LineTest.cs (13)
19var text = SourceText.From("goo" + newLine); 30var text = SourceText.From("goo" + Environment.NewLine); 41var text = SourceText.From("goo" + Environment.NewLine + "bar"); 52var text = SourceText.From("goo"); 61var text = SourceText.From("abcdef"); 68var text = SourceText.From("abcdef"); 75var text = SourceText.From("abcdef"); 82var text = SourceText.From("goo" + Environment.NewLine); 97var text = SourceText.From(Environment.NewLine); 106var text = SourceText.From("abcdef"); 113var text = SourceText.From("abcdef"); 120var text = SourceText.From("abcdef"); 127var text = SourceText.From("abcdef");
Text\StringTextTest.cs (13)
46var data = SourceText.From("goo", Encoding.UTF8); 54var data = SourceText.From("goo"); 61var data = SourceText.From(string.Empty); 69Assert.Throws<ArgumentNullException>(() => SourceText.From((string)null, Encoding.UTF8)); 83var data = SourceText.From(string.Empty, Encoding.UTF8); 152var data = SourceText.From("goo" + newLine + " bar"); 165var data = SourceText.From(text); 176var data = SourceText.From("goo\r\nbar"); 185var data = SourceText.From("goo\n\rbar\u2028"); 196var data = SourceText.From(""); 207var data = SourceText.From(text); 217var data = SourceText.From(text); 224var data = SourceText.From("The quick brown fox jumps over the lazy dog", Encoding.UTF8);
Text\TextChangeTests.cs (68)
32var text = SourceText.From("Hello World"); 40var text = SourceText.From("Hello World"); 48var text = SourceText.From("Hello World"); 56var text = SourceText.From("Hello World"); 64var text = SourceText.From("Hello World"); 72var text = SourceText.From("Hello World"); 86var text = SourceText.From("Hello World"); 97var text = SourceText.From("Hello World"); 110var text = SourceText.From("Hello World"); 124var text = SourceText.From("Hello World"); 139var text = SourceText.From("Hello World"); 151var text = SourceText.From("Hello World"); 163var text = SourceText.From("Hello World"); 177var text = SourceText.From("Hello World"); 189var text = SourceText.From("Hello World", Encoding.Unicode, SourceHashAlgorithms.Default); 204var text = SourceText.From("Hello World"); 214var text = SourceText.From("Hello World"); 231var text = SourceText.From(new string('.', 2048), Encoding.Unicode, SourceHashAlgorithms.Default); // start bigger than GetText() copy buffer 270var changedText = SourceText.From(originalText).WithChanges(changes); 271Assert.Equal(SourceText.From(changedText.ToString()).Lines, changedText.Lines, new TextLineEqualityComparer()); 348var text = SourceText.From(str); 368var text = SourceText.From(str); 387var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 401var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 412var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 423var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 439var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 456var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 476var text = SourceText.From("abcdefghijklmnopqrstuvwxyz"); 490var t = SourceText.From(a); 520var t = SourceText.From(a); 564var text = SourceText.From("This is the old text"); 610var text = SourceText.From("small preamble"); 635var original = SourceText.From("Hello World"); 646var original = SourceText.From("Hello World"); 656var original = SourceText.From("Hello World"); 671var original = SourceText.From("01234"); 685var original = SourceText.From("012"); 699var original = SourceText.From("01234"); 712var original = SourceText.From("Hello World"); 726var original = SourceText.From("Hello World"); 740var original = SourceText.From("Hello World"); 754var original = SourceText.From("01234"); 767var original = SourceText.From("01234"); 780var original = SourceText.From("01234"); 793var original = SourceText.From("01234"); 806var original = SourceText.From("01234"); 820var original = SourceText.From("01234"); 834var original = SourceText.From("01234"); 846var original = SourceText.From("Hell"); 860var original = SourceText.From("Hell "); 876var original = SourceText.From("Hell Word"); 892var original = SourceText.From("Hell"); 907var original = SourceText.From("Hell"); 965var originalText = SourceText.From(string.Join("", Enumerable.Range(0, random.Next(10)))); 1046var originalText = SourceText.From("01234"); 1060var original = SourceText.From("01234"); 1074var originalText = SourceText.From("01234"); 1088var originalText = SourceText.From("01234"); 1101var originalText = SourceText.From("012345"); 1115var originalText = SourceText.From("01234567"); 1129var originalText = SourceText.From("01234"); 1143var originalText = SourceText.From("01234"); 1157var originalText = SourceText.From("012345"); 1171var originalText = SourceText.From("0123456"); 1185var originalText = SourceText.From("012345"); 1199var originalText = SourceText.From("01234"); 1223var text = SourceText.From(content);
Text\TextUtilitiesTests.cs (8)
35Assert.Equal(0, TextUtilities.GetLengthOfLineBreak(SourceText.From("aoeu"), 0)); 36Assert.Equal(0, TextUtilities.GetLengthOfLineBreak(SourceText.From("aoeu"), 2)); 45Assert.Equal(1, TextUtilities.GetLengthOfLineBreak(SourceText.From("\naoeu"), 0)); 46Assert.Equal(1, TextUtilities.GetLengthOfLineBreak(SourceText.From("a\nbaou"), 1)); 47Assert.Equal(0, TextUtilities.GetLengthOfLineBreak(SourceText.From("a\n"), 0)); 56Assert.Equal(2, TextUtilities.GetLengthOfLineBreak(SourceText.From("\r\n"), 0)); 57Assert.Equal(1, TextUtilities.GetLengthOfLineBreak(SourceText.From("\n\r"), 0)); 66Assert.Equal(1, TextUtilities.GetLengthOfLineBreak(SourceText.From("\r"), 0));
Microsoft.CodeAnalysis.VisualBasic (8)
Binding\Binder_Expressions.vb (1)
1102Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(codeToParse))
OptionsValidator.vb (1)
30Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(importFileText), VisualBasicParseOptions.Default, "")
Syntax\SyntaxNodeFactories.vb (3)
50Return ParseSyntaxTree(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, cancellationToken) 79Return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, cancellationToken) 283Return SourceText.From(text, Encoding.UTF8).GetSubText(offset)
Syntax\VisualBasicSyntaxTree.DummySyntaxTree.vb (2)
29Return SourceText.From(String.Empty, Me.Encoding, ChecksumAlgorithm) 33text = SourceText.From(String.Empty, Me.Encoding, ChecksumAlgorithm)
Syntax\VisualBasicSyntaxTree.vb (1)
252SourceText.From(text, encoding),
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests (1)
src\Features\VisualBasicTest\Utils.vb (1)
14Dim text = SourceText.From(code)
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (1)
PDB\PDBTests.vb (1)
27Dim tree3 = SyntaxFactory.ParseSyntaxTree(SourceText.From("Class C : End Class", encoding:=Nothing), path:="Bar.vb")
Microsoft.CodeAnalysis.VisualBasic.Features.UnitTests (7)
EditAndContinue\VisualBasicEditAndContinueAnalyzerTests.vb (6)
30AddDocument("test.vb", SourceText.From(source, Encoding.UTF8), filePath:=Path.Combine(TempRoot.Root, "test.vb")).Project.Solution 470Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 555Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 613Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 644Dim newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2)) 675Dim newSolution = oldSolution.AddDocument(newDocId, "goo.vb", SourceText.From(source2), filePath:=Path.Combine(TempRoot.Root, "goo.vb"))
Utils.vb (1)
14Dim text = SourceText.From(code)
Microsoft.CodeAnalysis.VisualBasic.Scripting (1)
VisualBasicScript.vb (1)
27Return Script.CreateInitialScript(Of T)(VisualBasicScriptCompiler.Instance, SourceText.From(If(code, String.Empty)), options, globalsType, assemblyLoader)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (11)
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.vb (6)
1000driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From("")))) 1042driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1091driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1144driver = driver.RunGenerators(compilation.AddSyntaxTrees(compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1204compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1258compilation.SyntaxTrees.First().WithChangedText(SourceText.From("
SourceGeneration\GeneratorDriverTests_Attributes_SimpleName.vb (5)
1209compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(" 1250compilation.SyntaxTrees.Last().WithChangedText(SourceText.From(" 1414compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1456compilation.SyntaxTrees.First().WithChangedText(SourceText.From(" 1509compilation.SyntaxTrees.Last().WithChangedText(SourceText.From("
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (1)
SymbolsTests\Source\TypeTests.vb (1)
687Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(text), VisualBasicParseOptions.Default, "")
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (86)
IncrementalParser\IncrementalParser.vb (60)
81Dim text As SourceText = SourceText.From(_s) 104Dim text As SourceText = SourceText.From("") 124Dim oldText = SourceText.From(_s) 702Dim oldText = SourceText.From(code) 741Dim oldText = SourceText.From(code) 766Dim oldText = SourceText.From(code) 790Dim oldText = SourceText.From(code) 822Dim oldText = SourceText.From(source) 864Dim oldText = SourceText.From(source) 883Dim oldText = SourceText.From(source) 904Dim oldText = SourceText.From(source) 933Dim oldText = SourceText.From(source) 962Dim oldText = SourceText.From(source) 986Dim oldText = SourceText.From(source) 1008Dim oldText = SourceText.From(source) 1028Dim oldText = SourceText.From(source) 1051Dim oldText = SourceText.From(source) 1077Dim oldText = SourceText.From(source) 1103Dim oldText = SourceText.From(source) 1221Dim oldText = SourceText.From(code) 1239Dim oldText = SourceText.From(code) 1264Dim oldText = SourceText.From(source) 1288Dim oldText = SourceText.From(source) 1312Dim oldText = SourceText.From(source) 1336Dim oldText = SourceText.From(source) 1359Dim oldText = SourceText.From(source) 1382Dim oldText = SourceText.From(source) 1402Dim oldText = SourceText.From(source) 1422Dim oldText = SourceText.From(source) 1442Dim oldText = SourceText.From(source) 1462Dim oldText = SourceText.From(source) 1487Dim oldText = SourceText.From(source) 1517Dim oldText = SourceText.From(oldSource) 1551Dim oldText = SourceText.From(oldSource) 1582Dim oldText = SourceText.From(source) 1671Dim oldText = SourceText.From(code) 1765Dim oldText = SourceText.From(source) 1792Dim oldText = SourceText.From(source) 1821Dim oldText = SourceText.From(source) 1841Dim oldText = SourceText.From(source) 1860Dim oldText = SourceText.From(source) 1885Dim oldText = SourceText.From(source) 1917Dim oldText = SourceText.From(source) 1951Dim oldText = SourceText.From(source) 1982Dim oldText = SourceText.From(source) 2013Dim oldText = SourceText.From(source) 2045Dim oldText = SourceText.From(source) 2075Dim oldText = SourceText.From(source) 2106Dim oldText = SourceText.From(source) 2208Dim oldText = SourceText.From(source) 2240Dim oldText = SourceText.From(source) 2274Dim oldText = SourceText.From(source) 2300Dim oldText = SourceText.From(source) 2331Dim oldText = SourceText.From(source) 2365Dim oldText = SourceText.From(source) 2401Dim oldText = SourceText.From(source) 2429Dim oldText = SourceText.From(source) 2463Dim oldText = SourceText.From(source) 2492Dim oldText = SourceText.From(source) 2544Dim oldText = SourceText.From(source)
Parser\DeclarationTests.vb (1)
15Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(text), VisualBasicParseOptions.Default, "")
Parser\ParseDirectives.vb (1)
1260Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(text), options, "")
Parser\ParseExpression.vb (4)
2247Dim text = SourceText.From(source) 2264Dim text = SourceText.From(source) 2281Dim text = SourceText.From(source) 2299Dim text = SourceText.From(source)
QuickTokenTableTests.vb (4)
12Dim txt = SourceText.From(s) 28Dim txt = SourceText.From(s) 86Using scanner As New InternalSyntax.Scanner(SourceText.From(New String(buf)), TestOptions.Regular) 107Using scanner As New InternalSyntax.Scanner(SourceText.From(New String(buf)), TestOptions.Regular)
Scanner\ScanConditionalTests.vb (4)
19Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular) 37Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular) 78Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular) 118Using s As New InternalSyntax.Scanner(SourceText.From(Str), TestOptions.Regular)
Scanner\XmlScannerTests.vb (6)
16Dim str = SourceText.From(" <!-- hello there --> ") 43Dim str = SourceText.From(" <![CDATA[some data / > < % @ here ]]> ") 195Dim str = SourceText.From(" <E1 /> ") 324Using s As New InternalSyntax.Scanner(SourceText.From("&#x03C0;"), TestOptions.Regular) 331Using s = New InternalSyntax.Scanner(SourceText.From("&#x03C0"), TestOptions.Regular) 343Using s As New InternalSyntax.Scanner(SourceText.From("&#x103fe;"), TestOptions.Regular)
Syntax\ManualTests.vb (1)
225Dim text = SourceText.From(code)
Syntax\SyntaxTreeTests.vb (5)
34SourceText.From(""), 37Dim newTree = tree.WithChangedText(SourceText.From("Class B : End Class")) 44SourceText.From(""), 55SourceText.From(""), 66SourceText.From(""),
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (4)
BasicTestSource.vb (1)
24Dim sourceTest = SourceText.From(text, If(encoding, Encoding.UTF8), checksumAlgorithm)
CompilationTestUtils.vb (1)
653Dim text = SourceText.From(codeWithoutMarker, Encoding.UTF8)
ParserTestUtilities.vb (2)
113Dim tree = VisualBasicSyntaxTree.ParseText(SourceText.From(source, encoding), options:=If(options, TestOptions.RegularLatest), path:=fileName) 254Dim oldText = SourceText.From(node.oldText)
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (3)
CaseCorrection\VisualBasicCaseCorrectionTestBase.vb (1)
17Dim document = project.AddDocument("Document", SourceText.From(code))
Formatting\FormattingTests.vb (1)
3016Dim document = project.AddDocument("Document", SourceText.From(inputOutput))
Formatting\VisualBasicFormattingTestBase.vb (1)
58Dim document = project.AddDocument("Document", SourceText.From(code))
Microsoft.CodeAnalysis.Workspaces (6)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\EditorConfigParser.cs (1)
40return Parse<TEditorConfigFile, TResult, TAccumulator>(SourceText.From(text), pathToFile, accumulator);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EditorConfig\Parsing\NamingStyles\EditorConfigNamingStylesParser.cs (1)
18=> Parse(SourceText.From(editorConfigText), pathToEditorConfigFile);
Workspace\Host\TextFactory\TextFactoryService.cs (1)
37: SourceText.From(reader.ReadToEnd(), encoding, checksumAlgorithm);
Workspace\Solution\Solution.cs (1)
1039=> this.AddAdditionalDocument(documentId, name, SourceText.From(text), folders, filePath);
Workspace\Solution\TextDocumentState.cs (1)
164: CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, encoding: null, loadTextOptions.ChecksumAlgorithm), VersionStamp.Default, filePath));
Workspace\Solution\TextLoader.cs (1)
177SourceText.From(string.Empty, Encoding.UTF8),
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (10)
VisualStudioMSBuildWorkspaceTests.cs (10)
398var solution1 = solution.WithDocumentText(document.Id, SourceText.From("using test;")); 2014var newText = SourceText.From("public class Bar { }"); 2057var newText = SourceText.From("public class Bar { }"); 2117var newText = SourceText.From("using System.Diagnostics;\r\n" + text.ToString()); 2144var newText = SourceText.From("New Text In Additional File.\r\n" + text.ToString()); 2170var newText = SourceText.From("public class Bar { }"); 2206workspace.TryApplyChanges(workspace.CurrentSolution.AddAdditionalDocument(DocumentId.CreateNewId(csProjectId), "foo.xaml", SourceText.From("<foo></foo>"))); 2242workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(doc.Id, SourceText.From(newText), PreservationMode.PreserveIdentity)); 2277SourceText.From(newText), 2906var noEncodingDoc = document.WithText(SourceText.From(text.ToString(), encoding: null));
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (4)
Formatting\FormattingTestBase.cs (1)
49var document = project.AddDocument("Document", SourceText.From(code));
GenerateFileForEachAdditionalFileWithContentsCommented.cs (1)
35return SourceText.From(generatedText.ToString(), encoding: Encoding.UTF8);
TestTextLoader.cs (1)
20_textAndVersion = TextAndVersion.Create(SourceText.From(text, encoding: null, checksumAlgorithm), VersionStamp.Create());
Workspaces\TestHostDocument.cs (1)
189=> Task.FromResult(TextAndVersion.Create(SourceText.From(_text, encoding: null, options.ChecksumAlgorithm), VersionStamp.Create(), _hostDocument.FilePath));
Microsoft.CodeAnalysis.Workspaces.UnitTests (178)
CodeCleanup\AddMissingTokensTests.cs (1)
2733.AddDocument("Document", SourceText.From(code));
CodeCleanup\CodeCleanupTests.cs (1)
420return project.AddDocument("Document", SourceText.From(code));
CodeCleanup\FixIncorrectTokenTests.cs (1)
758.AddDocument("Document", SourceText.From(code));
CodeCleanup\NormalizeModifiersOrOperatorsTests.cs (1)
1033return project.AddDocument("Document", SourceText.From(code));
CodeCleanup\ReduceTokenTests.cs (1)
2021.AddDocument("Document", SourceText.From(code));
CodeCleanup\RemoveUnnecessaryLineContinuationTests.cs (1)
1463return project.AddDocument("Document", SourceText.From(code));
EditorConfigParsing\NamingStyleParserTests.cs (2)
19var editorconfig = SourceText.From(DefaultDotNet6EditorConfigText); 48var editorconfig = SourceText.From(RoslynEditorConfigText);
FindAllDeclarationsTests.cs (1)
703solution = solution.AddDocument(did, "VBDocument.vb", SourceText.From(source));
FindAllDeclarationsTests.TestSolutionsAndProject.cs (2)
102solution = solution.AddDocument(did, "goo" + i + ".cs", SourceText.From(sourceTexts[i])); 119solution = solution.AddDocument(did, "goo" + i + ".cs", SourceText.From(sourceTexts[i]));
FindReferencesTests.cs (5)
40return solution.AddProject(pi).AddDocument(did, $"{projectName}.{suffix}", SourceText.From(code)); 56return solution.AddProject(pi).AddDocument(did, $"{projectName}.{suffix}", SourceText.From(code)); 66.AddDocument(did, "goo.cs", SourceText.From(sourceText)); 82solution = solution.AddDocument(did, $"goo{docCounter++}.cs", SourceText.From(sourceText)); 126.AddDocument(did, "goo.cs", SourceText.From(text));
Formatter\FormatterTests.cs (5)
42=> Task.FromResult(document.WithText(SourceText.From($"Formatted with options: {lineFormattingOptions.ToString().Replace("\r", "\\r").Replace("\n", "\\n")}"))); 52var document = workspace.AddDocument(project.Id, "File.dummy", SourceText.From("dummy")); 70var document = workspace.AddDocument(project.Id, "File.dummy", SourceText.From("dummy")); 115var csDocument = workspace.AddDocument(csProject.Id, "File.cs", SourceText.From("class C { }")); 116var vbDocument = workspace.AddDocument(vbProject.Id, "File.vb", SourceText.From("Class C : End Class"));
GeneratedCodeRecognitionTests.cs (2)
60SourceText.From(@" 66SourceText.From(@"
LinkedFileDiffMerging\LinkedFileDiffMergingTests.cs (2)
21var startSourceText = SourceText.From(startText); 46.WithDocumentText(documentIds[i], SourceText.From(text));
SemanticModelReuse\SemanticModelReuseTests.cs (25)
30.AddDocument("Document", SourceText.From(code)); 90var document2 = document1.WithText(SourceText.From("class C { void M() { return null; } }")); 107var document2 = document1.WithText(SourceText.From("class C { long M() { return; } }")); 113var document3 = document2.WithText(SourceText.From("class C { long M() { return 0; } }")); 130var document2 = document1.WithText(SourceText.From("class C { void M() { return 0; } }")); 136var document3 = document1.WithText(SourceText.From("class C { void M() { return 1; } }")); 153var document2 = document1.WithText(SourceText.From("class C { int M { get { return 1; } } }")); 159var document3 = document1.WithText(SourceText.From("class C { int M { get { return 2; } } }")); 176var document2 = document1.WithText(SourceText.From("class C { event System.Action E { add { return 1; } } }")); 182var document3 = document1.WithText(SourceText.From("class C { event System.Action E { add { return 2; } } }")); 199var document2 = document1.WithText(SourceText.From("class C { int this[int i] { get { return 1; } } }")); 205var document3 = document1.WithText(SourceText.From("class C { int this[int i] { get { return 2; } } }")); 223var document2 = document1.WithText(SourceText.From("class C { void M() { return null; } }")); 250var document2 = document1.WithText(SourceText.From(source2)); 334var document2 = document1.WithText(SourceText.From(@" 367var document2 = document1.WithText(SourceText.From(source2)); 373var document3 = document2.WithText(SourceText.From(@" 400var document2 = document1.WithText(SourceText.From(@" 411var document3 = document1.WithText(SourceText.From(@" 440var document2 = document1.WithText(SourceText.From(@" 453var document3 = document1.WithText(SourceText.From(@" 484var document2 = document1.WithText(SourceText.From(@" 497var document3 = document1.WithText(SourceText.From(@" 527var document2 = document1.WithText(SourceText.From(@" 558var document2 = document1.WithText(SourceText.From(@"
Simplifier\SimplifierTests.cs (3)
29return workspace.AddDocument(project.Id, "CSharpFile.cs", SourceText.From("class C { }")); 78var csDocument = workspace.AddDocument(csProject.Id, "File.cs", SourceText.From("class C { }")); 79var vbDocument = workspace.AddDocument(vbProject.Id, "File.vb", SourceText.From("Class C : End Class"));
SolutionTests\SolutionTests.cs (66)
334.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From("config")); 350var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 374var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 398var text = SourceText.From("new text"); 451var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 539var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 622var text = SourceText.From("new text without pp directives", encoding: null, SourceHashAlgorithm.Sha1); 705var text = SourceText.From("#if true", encoding: null, SourceHashAlgorithm.Sha1); 781var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1); 868var text = SourceText.From(" ", encoding: null, SourceHashAlgorithm.Sha1); 920var text = SourceText.From("new text"); 942var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 966var text = SourceText.From("new text"); 988var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default); 1108loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD1;", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1127loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1146loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))), 1619var textC = SourceText.From("class C {}", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha1); 2311var solution4 = solution3.AddAnalyzerConfigDocument(editorConfigId, ".editorconfig", SourceText.From(editorConfigContent), filePath: Path.Combine(s_projectDir, "subfolder", ".editorconfig")); 2483var root = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From("class C {}", encoding: null, SourceHashAlgorithm.Sha1)).GetRoot(); 3161.AddDocument(documentId, "DocumentName", SourceText.From("class Class{}")); 3773.AddDocument(did, "test", SourceText.From(language == LanguageNames.CSharp ? "class C {}" : "Class C : End Class", Encoding.UTF8, SourceHashAlgorithm.Sha256), filePath: "old path"); 3978var solution2 = solution.WithDocumentText(did3, SourceText.From(text4)); 3991var doc = ws.AddDocument(proj.Id, "a.cs", SourceText.From("public class c { }", Encoding.UTF32)); 4052workspace.AddDocument(project1.Id, "Broken.cs", SourceText.From("class ")); 4074project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 4076var documentToFreeze = project.AddDocument("DocumentToFreeze.cs", SourceText.From("")); 4099project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 4101var documentToFreeze = project.AddDocument("DocumentToFreeze.cs", SourceText.From("")); 4127project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 4129var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }")); 4133var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { /*no top level change*/ } }")); 4172project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 4174var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }")); 4178var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { } public void NewMethod() { } }")); 4236var document = workspace.AddDocument(project2.Id, "Test.cs", SourceText.From("")); 4340document = document.WithText(SourceText.From("// Source File with Changes")); 4366.WithDocumentText(documentId1, SourceText.From("// Document 1 Changed")) 4367.WithDocumentText(documentId2, SourceText.From("// Document 2 Changed")) 4368.WithDocumentText(documentId3, SourceText.From("// Document 3 Changed")); 4688loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4721loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4762loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4774TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA6789.severity = error"), VersionStamp.Default)), 4810loader: TextLoader.From(TextAndVersion.Create(SourceText.From("is_global = true\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default))))); 4856loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ngenerated_code = true"), VersionStamp.Default))))); 5421var text = SourceText.From("public class C { }"); 5469var sourceTextToRelease = ObjectReference.CreateFromFactory(static () => SourceText.From(Guid.NewGuid().ToString())); 5517.AddDocument(documentId, "test.cs", SourceText.From("public class C { }"), filePath: sourcePath) 5518.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), ".editorconfig", SourceText.From($"[{pattern}]\nindent_style = tab"), filePath: configPath); 5578project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 5595project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project; 5616project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5617project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project; 5644project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5645project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project; 5674project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5675project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project; 5706project1 = project1.AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5715var forkedProject1 = frozenSolution.WithDocumentText(project1.Documents.Single().Id, SourceText.From("class Doc2 { }")).GetProject(project1.Id); 5734project1 = project1.AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; 5754var forkedProject1 = frozenSolution.WithDocumentText(project1.Documents.Single().Id, SourceText.From("class Doc2 { }")).GetProject(project1.Id); 5783project = project.AddDocument("Extra.ts", SourceText.From("class Extra { }")).Project; 5806.AddDocument($"Document", SourceText.From("class C { }"), filePath: @"c:\test\Document.cs").Project; 5816.AddDocument($"Document", SourceText.From("class C { }"), filePath: @"c:\test\Document.cs").Project; 5827old => old.WithDocumentText(documentId1, SourceText.From(lastContents)),
SolutionTests\SolutionWithSourceGeneratorTests.cs (21)
206project = project.AdditionalDocuments.First().WithAdditionalDocumentText(SourceText.From("Changed text!")).Project; 230project = project.AddDocument("Source.cs", SourceText.From("")).Project; 263project = project.Solution.WithDocumentText(documentId, SourceText.From("// Changed Source File")).Projects.Single(); 306project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Hello, everyone!")).Projects.Single(); 311project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Good evening, everyone!")).Projects.Single(); 375SourceText.From("Hello, world!!!!")).Projects.Single(); 489project = project.Documents.Single().WithText(SourceText.From("// Change")).Project; 595var differentOpenTextContainer = SourceText.From("// Open Text").Container; 619var differentOpenTextContainer = SourceText.From("// StaticContent", Encoding.UTF8).Container; 634.AddAdditionalDocument("Test.txt", SourceText.From("")); 639var differentOpenTextContainer = SourceText.From("// Open Text").Container; 670var differentOpenTextContainer = SourceText.From("// Open Text").Container; 697var differentOpenTextContainer = SourceText.From("// Open Text").Container; 734documentToFreeze = documentToFreeze.WithText(SourceText.From("// Changed Source File")); 764document = document.WithText(SourceText.From("// Something else")); 793document = document.WithText(SourceText.From("// Something else")); 827document = document.WithText(SourceText.From("// Something else")); 888identity, DateTime.Now, SourceText.From("// Frozen Document")); 915[(sourceGeneratedDocument1.Identity, DateTime.Now, SourceText.From("// Frozen 1")), (sourceGeneratedDocument2.Identity, DateTime.Now, SourceText.From("// Frozen 2"))]); 935sourceGeneratedDocumentIdentity, sourceGeneratedDocument.GenerationDateTime, SourceText.From("// Hello, World"));
SolutionTests\TextLoaderTests.cs (3)
82public static readonly TextAndVersion Value = TextAndVersion.Create(SourceText.From(""), VersionStamp.Default); 91public static new readonly TextAndVersion Value = TextAndVersion.Create(SourceText.From(""), VersionStamp.Default); 100public static readonly TextAndVersion Value = TextAndVersion.Create(SourceText.From(""), VersionStamp.Default);
SolutionTests\TryApplyChangesTests.cs (1)
166Assert.True(workspace.TryApplyChanges(project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From("")).Project.Solution));
SymbolKeyTests.cs (2)
862var sourceText = SourceText.From(text); 909var sourceText = SourceText.From(text);
SyntaxPathTests.cs (4)
90var text = SourceText.From(string.Empty); 104var text = SourceText.From("class C {}"); 397var text = SourceText.From("using X; class C {}"); 416return SourceText.From(newFullText);
SyntaxReferenceTests.cs (2)
32.AddDocument(did, "Test.cs", SourceText.From(source)); 42.AddDocument(did, "Test.vb", SourceText.From(source));
UtilityTest\SourceTextSerializationTests.cs (1)
57return SourceText.From(sb.ToString());
WorkspaceServiceTests\TemporaryStorageServiceTests.cs (6)
38var text = SourceText.From(new string(' ', 4096) + "public class A {}"); 42text = SourceText.From(string.Empty); 46text = SourceText.From(new string(' ', 1024 * 1024) + "public class A {}"); 280var text = SourceText.From(new string(' ', 4096) + "public class A {}", Encoding.ASCII); 284text = SourceText.From(string.Empty); 288text = SourceText.From(new string(' ', 1024 * 1024) + "public class A {}");
WorkspaceTests\AdhocWorkspaceTests.cs (13)
73var doc = ws.AddDocument(project.Id, name, SourceText.From(source)); 155loader: TextLoader.From(TextAndVersion.Create(SourceText.From(""), VersionStamp.Create()))); 213var text = SourceText.From("public class C { }"); 247var text = SourceText.From("public class C { }"); 281var text = SourceText.From("public class C { }"); 320var text = SourceText.From("public class C { }"); 378var docid1 = ws.AddDocument(projid, "A.cs", SourceText.From("public class A { }")).Id; 379var docid2 = ws.AddDocument(projid, "B.cs", SourceText.From("public class B { }")).Id; 415var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 446var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 482var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 514var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 545var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From(""));
WorkspaceTests\WorkspaceTests.cs (6)
25var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 27var changedDoc = originalDoc.WithText(SourceText.From("new")); 38var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 54var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 73var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From("")); 90var originalDoc = ws.AddDocument(projectId, "TestDocument", SourceText.From(""));
Microsoft.Extensions.Logging.Generators (1)
LoggerMessageGenerator.Roslyn3.11.cs (1)
39context.AddSource("LoggerMessage.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Extensions.Options.SourceGeneration (1)
Generator.cs (1)
56context.AddSource("Validators.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.ComplianceReports.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.ContextualOptions.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.Logging (1)
LoggingGenerator.cs (1)
49context.AddSource("Logging.g.cs", SourceText.From(result, Encoding.UTF8));
Microsoft.Gen.Logging.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.Metrics (2)
MetricsGenerator.cs (2)
40context.AddSource("Factory.g.cs", SourceText.From(factory, Encoding.UTF8)); 44context.AddSource("Metrics.g.cs", SourceText.From(metrics, Encoding.UTF8));
Microsoft.Gen.Metrics.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Gen.MetricsReports.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
549return document.WithText(SourceText.From(newText.ToString(), newText.Encoding, newText.ChecksumAlgorithm));
Microsoft.Maui.Controls.SourceGen (3)
CodeBehindGenerator.cs (3)
295 context.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8)); 377 context.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8)); 640 sourceProductionContext.AddSource(hintName, SourceText.From(sb.ToString(), Encoding.UTF8));
Microsoft.ML.AutoML.SourceGenerator (3)
EstimatorTypeGenerator.cs (1)
53context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorFactoryGenerator.cs (1)
48context.AddSource(className + ".cs", SourceText.From(code.TransformText(), Encoding.UTF8));
SweepableEstimatorGenerator.cs (1)
73context.AddSource(c.Item1 + ".cs", SourceText.From(c.Item2, Encoding.UTF8));
Microsoft.VisualStudio.LanguageServices (1)
Preview\TopLevelChange.cs (1)
161solution = solution.AddAnalyzerConfigDocument(oldDocument.Id, oldDocument.Name, SourceText.From(oldText), oldDocument.Folders, oldDocument.FilePath);
Microsoft.VisualStudio.LanguageServices.CSharp (1)
ProjectSystemShim\TempPECompilerService.cs (1)
45var sourceText = SourceText.From(fileContents[i], parsedArguments.Encoding, parsedArguments.ChecksumAlgorithm);
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (3)
DocumentOutline\DocumentOutlineTestsBase.cs (1)
109solution = solution.WithDocumentText(document.Id, SourceText.From(documentText.ToString(), System.Text.Encoding.UTF8));
EditorConfigSettings\Aggregator\SettingsAggregatorTests.cs (1)
32.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From("config"), filePath: "/a/b")));
EditorConfigSettings\DataProvider\DataProviderTests.cs (1)
34.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From("config"), filePath: "/a/b")));
Microsoft.VisualStudio.LanguageServices.LiveShare (2)
Client\Projects\WorkspaceFileTextLoaderNoException.cs (1)
32return Task.FromResult(TextAndVersion.Create(SourceText.From("", encoding: null, options.ChecksumAlgorithm), VersionStamp.Create()));
Client\RemoteLanguageServiceWorkspace.cs (1)
302text = SourceText.From(File.ReadAllText(document.FilePath));
Microsoft.VisualStudio.LanguageServices.UnitTests (3)
ProjectSystemShim\VisualStudioProjectTests\WorkspaceChangedEventTests.vb (1)
130project.AddSourceTextContainer(SourceText.From("// Test").Container, "Z:\Test.cs")
SolutionExplorer\SourceGeneratorItemTests.vb (1)
256SourceText.From("Changed"),
Venus\DocumentService_IntegrationTests.vb (1)
186Dim newDocument = document.WithText(SourceText.From(""))
Roslyn.VisualStudio.Next.UnitTests (57)
Remote\RemoteHostClientServiceFactoryTests.cs (1)
48var document = workspace.AddDocument(project.Id, "doc.cs", SourceText.From("code"));
Remote\SnapshotSerializationTests.cs (8)
50var document1 = project1.AddDocument("Document1", SourceText.From(csCode)); 54var document2 = project2.AddDocument("Document2", SourceText.From(vbCode)); 60.AddAdditionalDocument("Additional", SourceText.From("hello"), ["test"], @".\Add").Project.Solution; 67loader: TextLoader.From(TextAndVersion.Create(SourceText.From("root = true"), VersionStamp.Create())))]); 153var document = workspace.CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.CSharp).AddDocument("Document", SourceText.From(code)); 173var document = solution.AddProject("Project", "Project.dll", LanguageNames.CSharp).AddDocument("Document", SourceText.From(code)); 532var document = CreateWorkspace().CurrentSolution.AddProject("empty", "empty", LanguageNames.CSharp).AddDocument("empty", SourceText.From("")); 607var sourceText = SourceText.From("Hello", Encoding.UTF8);
Services\ServiceHubServicesTests.cs (32)
436var tempDoc = project.AddDocument("X.cs", SourceText.From("// ")); 451Assert.True(localWorkspace.SetCurrentSolution(s => s.WithDocumentText(tempDocId, SourceText.From("// " + i)), WorkspaceChangeKind.SolutionChanged)); 497=> SourceText.From(content, encoding ?? Encoding.UTF8, checksumAlgorithm); 720return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 742solution = solution.WithTextDocumentText(tempDocId, SourceText.From("// new contents")); 775var tempDoc = project.AddDocument("X.cs", SourceText.From("// ")); 804return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 859return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8))); 913var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 922var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 964var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 973var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1005var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1014var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1048var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1057var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1100var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1110var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1153var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1163var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1206var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1216var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1251var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1261var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1296var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1305var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1339var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1348var tempDoc = project2.AddDocument("X.cs", SourceText.From("// ")); 1431Contract.ThrowIfFalse(workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(normalDocId, SourceText.From("// new text")))); 1545var tempDoc = project1.AddDocument("X.cs", SourceText.From("// ")); 1737solution = current.AddDocument($"Document{i}", SourceText.From(documents[i])).Project.Solution; 1743solution = current.AddAdditionalDocument($"AdditionalDocument{i}", SourceText.From(additionalDocuments[i])).Project.Solution;
Services\SolutionServiceTests.cs (16)
160await VerifySolutionUpdate(code, s => s.WithDocumentText(s.Projects.First().DocumentIds.First(), SourceText.From(code + " "))); 315project = project.AddDocument("newDocument", SourceText.From("// new text")).Project; 335loader: TextLoader.From(TextAndVersion.Create(SourceText.From("test"), VersionStamp.Create()))); 346return s.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("changed")); 367loader: TextLoader.From(TextAndVersion.Create(SourceText.From("root = true"), VersionStamp.Create(), filePath: configPath)), 379return s.WithAnalyzerConfigDocumentText(analyzerConfigDocumentId, SourceText.From("root = false")); 399loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A { }"), VersionStamp.Create()))); 410return s.WithDocumentText(documentId, SourceText.From("class Changed { }")); 437var currentSolution = remoteSolution1.WithDocumentText(remoteSolution1.Projects.First().Documents.First().Id, SourceText.From(code + " class Test2 { }")); 446currentSolution = oopSolution2.WithDocumentText(oopSolution2.Projects.First().Documents.First().Id, SourceText.From(code + " class Test3 { }")); 522var frozenText1 = SourceText.From("// Hello, World!"); 531var frozenText2 = SourceText.From("// Hello, World! A second time!"); 835solution = solution.GetProject(project1.Id).AddDocument("X.cs", SourceText.From("// X")).Project.Solution; 836solution = solution.GetProject(project2.Id).AddDocument("Y.vb", SourceText.From("' Y")).Project.Solution; 890solution = solution.GetProject(project1.Id).AddDocument("X.cs", SourceText.From("// X")).Project.Solution; 891solution = solution.GetProject(project2.Id).AddDocument("Y.cs", SourceText.From("// Y")).Project.Solution;
StackDepthTest (1)
Program.cs (1)
79var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(stringText, encoding: null, SourceHashAlgorithm.Sha256), parseOptions);
System.Private.CoreLib.Generators (1)
EventSourceGenerator.Emitter.cs (1)
27context.AddSource($"{ec.ClassName}.g.cs", SourceText.From(sb.ToString(), Encoding.UTF8));
System.Text.Json.SourceGeneration (1)
src\libraries\Common\src\SourceGenerators\SourceWriter.cs (1)
67return SourceText.From(_sb.ToString(), Encoding.UTF8);
System.Windows.Forms.Analyzers.CSharp.Tests (2)
Generators\ApplicationConfigurationGeneratorTests.cs (1)
222SourceText.From(
TestAdditionalText.cs (1)
27: this(path, SourceText.From(text, encoding))
System.Windows.Forms.Analyzers.Tests (6)
System\Windows\Forms\Analyzers\AppManifestAnalyzerTests.cs (6)
47SourceText manifestFile = SourceText.From( 63SourceText manifestFile = SourceText.From( 81SourceText manifestFile = SourceText.From( 104SourceText manifestFile = SourceText.From( 127SourceText manifestFile = SourceText.From( 146SourceText manifestFile = SourceText.From(