1060 references to From
Analyzer.Utilities.UnitTests (3)
ConfigurationSchemaGenerator.Tests (2)
GenerateDocumentationAndConfigFiles (3)
IdeCoreBenchmarks (3)
Metrics (3)
Metrics.Legacy (3)
Microsoft.Analyzers.Extra.Tests (2)
Microsoft.Analyzers.Local.Tests (2)
Microsoft.AspNetCore.Analyzer.Testing (2)
Microsoft.AspNetCore.App.Analyzers (1)
Microsoft.AspNetCore.App.Analyzers.Test (1)
Microsoft.AspNetCore.Components.Analyzers.Tests (1)
Microsoft.AspNetCore.Components.SdkAnalyzers.Tests (1)
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;
Microsoft.AspNetCore.Http.Microbenchmarks (2)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (1)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.Test (1)
Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests (1)
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (4)
Microsoft.CodeAnalysis (13)
Microsoft.CodeAnalysis.Analyzers (3)
Microsoft.CodeAnalysis.AnalyzerUtilities (3)
Microsoft.CodeAnalysis.BannedApiAnalyzers (3)
Microsoft.CodeAnalysis.CodeStyle (4)
Microsoft.CodeAnalysis.CodeStyle.UnitTestUtilities (2)
Microsoft.CodeAnalysis.CSharp (11)
Syntax\CSharpSyntaxTree.cs (2)
459return ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode, cancellationToken);
929=> ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken);
Syntax\SyntaxFactory.cs (4)
1562return CSharpSyntaxTree.ParseText(SourceText.From(text, encoding, SourceHashAlgorithm.Sha1), (CSharpParseOptions?)options, path, diagnosticOptions: null, isGeneratedCode: null, cancellationToken);
1924return SourceText.From(text, Encoding.UTF8).GetSubText(offset);
2801return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode: null, cancellationToken);
2829return ParseSyntaxTree(SourceText.From(text, encoding), options, path, diagnosticOptions, isGeneratedCode, cancellationToken);
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (4)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (64)
PdbSourceDocument\ImplementationAssemblyLookupServiceTests.cs (17)
42var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
80var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
122var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
160var sourceText = SourceText.From(metadataSource, Encoding.UTF8);
184sourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
221var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
244sourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
282var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
305sourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
337var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
360sourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
388var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
411sourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
453var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
476sourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
511var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
534var typeForwardSourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
PdbSourceDocument\PdbSourceDocumentTests.cs (13)
408var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
438var sourceText = SourceText.From(metadataSource, encoding: Encoding.UTF8);
474var sourceText = SourceText.From(metadataSource, Encoding.UTF8);
521var sourceText = SourceText.From(metadataSource, Encoding.UTF8);
547sourceText = SourceText.From(typeForwardSource, Encoding.UTF8);
724CompileTestSource(path, SourceText.From(source2, Encoding.UTF8), project, Location.OnDisk, Location.OnDisk, buildReferenceAssembly: false, windowsPdb: false);
875var sourceText = SourceText.From(source, Encoding.UTF8);
926var sourceText1 = SourceText.From(source1, Encoding.UTF8);
927var sourceText2 = SourceText.From(source2, Encoding.UTF8);
974var result = service.TryAddDocumentToWorkspace(requestPath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentId);
997var openResult = service.TryAddDocumentToWorkspace(file.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentId);
1048var openResult = service.TryAddDocumentToWorkspace(fileOne.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentId);
1059Assert.Throws<System.InvalidOperationException>(() => service.TryAddDocumentToWorkspace(fileTwo.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentIdTwo));
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (7)
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 (10)
EditAndContinue\CSharpEditAndContinueAnalyzerTests.cs (10)
303var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2));
368var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2));
430var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2));
510var newSolution = workspace.CurrentSolution.WithDocumentText(documentId, SourceText.From(source2));
579var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2));
618var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2));
659var newSolution = oldSolution.AddDocument(newDocId, "goo.cs", SourceText.From(source2), filePath: Path.Combine(TempRoot.Root, "goo.cs"));
705var newSolution = oldSolution.AddDocument(newDocId, "goo.cs", SourceText.From(source2), filePath: Path.Combine(TempRoot.Root, "goo.cs"));
738var newSolution = oldSolution.AddDocument(documentId, "goo.cs", SourceText.From(source2), filePath: filePath);
795var newSolution = oldSolution.WithDocumentText(documentId, SourceText.From(source2));
Microsoft.CodeAnalysis.CSharp.Scripting (1)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (53)
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("")); });
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (140)
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);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (3)
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (2)
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (2)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (21)
Diagnostics\DiagnosticAnalyzerServiceTests.cs (6)
170project = project.AddAnalyzerConfigDocument(".editorconfig", filePath: "z:\\.editorconfig", text: SourceText.From(editorconfigText)).Project;
173var document = project.AddDocument("test.cs", SourceText.From("class A {}"), filePath: "z:\\test.cs");
256loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A {}"), VersionStamp.Create(), filePath: "test.cs")),
303text: SourceText.From(analyzerConfigText),
333loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A {}"), VersionStamp.Create(), filePath: "test.cs")),
825return workspace.AddDocument(project.Id, "Empty.cs", SourceText.From("class A { B B {get} }"));
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (4)
Microsoft.CodeAnalysis.Features (6)
Microsoft.CodeAnalysis.Features.UnitTests (18)
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 (5)
413solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath);
433solution = solution.AddDocument(designTimeOnlyDocumentId, designTimeOnlyFileName, SourceText.From(sourceDesignTimeOnly, Encoding.UTF8), filePath: designTimeOnlyFilePath);
632AddDocument("a.cs", SourceText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path);
1003AddDocument(documentId, "test.cs", SourceText.From(source1, encoding, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path);
1911context.AddSource("generated.cs", SourceText.From("generated: " + additionalText, Encoding.UTF8, SourceHashAlgorithm.Sha256));
Microsoft.CodeAnalysis.LanguageServer.Protocol (1)
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (9)
Microsoft.CodeAnalysis.LanguageServer.UnitTests (1)
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (3)
Microsoft.CodeAnalysis.PublicApiAnalyzers (3)
Microsoft.CodeAnalysis.PublicApiAnalyzers.CodeFixes (2)
Microsoft.CodeAnalysis.Rebuild.UnitTests (1)
Microsoft.CodeAnalysis.ResxSourceGenerator (7)
Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests (2)
Microsoft.CodeAnalysis.Scripting (4)
Hosting\CommandLine\CommandLineRunner.cs (3)
231var script = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(initialScriptCodeOpt), options, globals.GetType(), assemblyLoaderOpt: null);
258var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), options.ParseOptions, cancellationToken);
283newScript = Script.CreateInitialScript<object>(_scriptCompiler, SourceText.From(code ?? string.Empty), options, globals.GetType(), assemblyLoaderOpt: null);
Microsoft.CodeAnalysis.Scripting.TestUtilities (3)
Microsoft.CodeAnalysis.Test.Utilities (15)
Microsoft.CodeAnalysis.TestAnalyzerReference (4)
Microsoft.CodeAnalysis.UnitTests (137)
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\SourceTextTests.cs (20)
29SourceText[] texts = [SourceText.From(string.Empty), SourceText.From([], 0), SourceText.From(new MemoryStream())];
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\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)
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)
288Return SourceText.From(text, Encoding.UTF8).GetSubText(offset)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.UnitTests (1)
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (1)
Microsoft.CodeAnalysis.VisualBasic.Features.UnitTests (6)
Microsoft.CodeAnalysis.VisualBasic.Scripting (1)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (11)
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (1)
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (86)
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (4)
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (3)
Microsoft.CodeAnalysis.Workspaces (9)
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (10)
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (4)
Microsoft.CodeAnalysis.Workspaces.UnitTests (189)
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"));
SolutionTests\SolutionTests.cs (66)
332.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), "editorcfg", SourceText.From("config"));
348var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1);
372var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default);
396var text = SourceText.From("new text");
449var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1);
537var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1);
620var text = SourceText.From("new text without pp directives", encoding: null, SourceHashAlgorithm.Sha1);
703var text = SourceText.From("#if true", encoding: null, SourceHashAlgorithm.Sha1);
779var text = SourceText.From("new text", encoding: null, SourceHashAlgorithm.Sha1);
866var text = SourceText.From(" ", encoding: null, SourceHashAlgorithm.Sha1);
918var text = SourceText.From("new text");
940var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default);
964var text = SourceText.From("new text");
986var textAndVersion = TextAndVersion.Create(SourceText.From("new text"), VersionStamp.Default);
1106loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class NewD1;", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))),
1125loader: TextLoader.From(TextAndVersion.Create(SourceText.From("new text1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))),
1144loader: TextLoader.From(TextAndVersion.Create(SourceText.From("#new empty1", Encoding.UTF32, SourceHashAlgorithm.Sha256), VersionStamp.Create(), filePath: Path.Combine(s_projectDir, "newD1.cs"))),
1617var textC = SourceText.From("class C {}", encoding: null, checksumAlgorithm: SourceHashAlgorithm.Sha1);
2309var solution4 = solution3.AddAnalyzerConfigDocument(editorConfigId, ".editorconfig", SourceText.From(editorConfigContent), filePath: Path.Combine(s_projectDir, "subfolder", ".editorconfig"));
2504var root = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From("class C {}", encoding: Encoding.ASCII, SourceHashAlgorithm.Sha1)).GetRoot();
3187.AddDocument(documentId, "DocumentName", SourceText.From("class Class{}"));
3799.AddDocument(did, "test", SourceText.From(language == LanguageNames.CSharp ? "class C {}" : "Class C : End Class", Encoding.UTF8, SourceHashAlgorithm.Sha256), filePath: "old path");
4011var solution2 = solution.WithDocumentText(did3, SourceText.From(text4));
4024var doc = ws.AddDocument(proj.Id, "a.cs", SourceText.From("public class c { }", Encoding.UTF32));
4089workspace.AddDocument(project1.Id, "Broken.cs", SourceText.From("class "));
4111project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project;
4113var documentToFreeze = project.AddDocument("DocumentToFreeze.cs", SourceText.From(""));
4136project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project;
4138var documentToFreeze = project.AddDocument("DocumentToFreeze.cs", SourceText.From(""));
4164project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project;
4166var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }"));
4170var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { /*no top level change*/ } }"));
4209project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project;
4211var documentToFreezeOriginal = project.AddDocument("DocumentToFreeze.cs", SourceText.From("class DocumentToFreeze { void M() { } }"));
4215var solution = project.Solution.WithDocumentText(documentToFreezeOriginal.Id, SourceText.From("class DocumentToFreeze { void M() { } public void NewMethod() { } }"));
4277var document = workspace.AddDocument(project2.Id, "Test.cs", SourceText.From(""));
4381document = document.WithText(SourceText.From("// Source File with Changes"));
4407.WithDocumentText(documentId1, SourceText.From("// Document 1 Changed"))
4408.WithDocumentText(documentId2, SourceText.From("// Document 2 Changed"))
4409.WithDocumentText(documentId3, SourceText.From("// Document 3 Changed"));
4729loader: 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)))));
4803loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default)))));
4815TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ndotnet_diagnostic.CA6789.severity = error"), VersionStamp.Default)),
4851loader: TextLoader.From(TextAndVersion.Create(SourceText.From("is_global = true\r\n\r\ndotnet_diagnostic.CA1234.severity = error"), VersionStamp.Default)))));
4897loader: TextLoader.From(TextAndVersion.Create(SourceText.From("[*.*]\r\n\r\ngenerated_code = true"), VersionStamp.Default)))));
5479var text = SourceText.From("public class C { }");
5527var sourceTextToRelease = ObjectReference.CreateFromFactory(static () => SourceText.From(Guid.NewGuid().ToString()));
5575.AddDocument(documentId, "test.cs", SourceText.From("public class C { }"), filePath: sourcePath)
5576.AddAnalyzerConfigDocument(DocumentId.CreateNewId(projectId), ".editorconfig", SourceText.From($"[{pattern}]\nindent_style = tab"), filePath: configPath);
5636project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).Project;
5653project = project.AddDocument("Extra.cs", SourceText.From("class Extra { }")).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;
5702project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project;
5703project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project;
5732project1 = project2.Solution.GetProject(project1.Id).AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project;
5733project2 = project1.Solution.GetProject(project2.Id).AddDocument("Doc2", SourceText.From("class Doc2 { }")).Project;
5764project1 = project1.AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project;
5773var forkedProject1 = frozenSolution.WithDocumentText(project1.Documents.Single().Id, SourceText.From("class Doc2 { }")).GetProject(project1.Id);
5792project1 = project1.AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project;
5812var forkedProject1 = frozenSolution.WithDocumentText(project1.Documents.Single().Id, SourceText.From("class Doc2 { }")).GetProject(project1.Id);
5841project = project.AddDocument("Extra.ts", SourceText.From("class Extra { }")).Project;
5864.AddDocument($"Document", SourceText.From("class C { }"), filePath: @"c:\test\Document.cs").Project;
5874.AddDocument($"Document", SourceText.From("class C { }"), filePath: @"c:\test\Document.cs").Project;
5885old => old.WithDocumentText(documentId1, SourceText.From(lastContents)),
SolutionTests\SolutionWithSourceGeneratorTests.cs (33)
207project = project.AdditionalDocuments.First().WithAdditionalDocumentText(SourceText.From("Changed text!")).Project;
231project = project.AddDocument("Source.cs", SourceText.From("")).Project;
264project = project.Solution.WithDocumentText(documentId, SourceText.From("// Changed Source File")).Projects.Single();
307project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Hello, everyone!")).Projects.Single();
312project = project.Solution.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("Good evening, everyone!")).Projects.Single();
376SourceText.From("Hello, world!!!!")).Projects.Single();
490project = project.Documents.Single().WithText(SourceText.From("// Change")).Project;
596var differentOpenTextContainer = SourceText.From("// Open Text").Container;
620var differentOpenTextContainer = SourceText.From("// StaticContent", Encoding.UTF8).Container;
635.AddAdditionalDocument("Test.txt", SourceText.From(""));
640var differentOpenTextContainer = SourceText.From("// Open Text").Container;
671var differentOpenTextContainer = SourceText.From("// Open Text").Container;
698var differentOpenTextContainer = SourceText.From("// Open Text").Container;
735documentToFreeze = documentToFreeze.WithText(SourceText.From("// Changed Source File"));
765document = document.WithText(SourceText.From("// Something else"));
794document = document.WithText(SourceText.From("// Something else"));
828document = document.WithText(SourceText.From("// Something else"));
889identity, DateTime.Now, SourceText.From("// Frozen Document"));
916[(sourceGeneratedDocument1.Identity, DateTime.Now, SourceText.From("// Frozen 1")), (sourceGeneratedDocument2.Identity, DateTime.Now, SourceText.From("// Frozen 2"))]);
936sourceGeneratedDocumentIdentity, sourceGeneratedDocument.GenerationDateTime, SourceText.From("// Hello, World"));
1000[(ordinaryDocument.Id, SourceText.From("// Regular modified")),
1001(sourceGeneratedDocument.Id, SourceText.From("// Source gen modified"))]);
1155sourceGeneratedDocument = sourceGeneratedDocument.WithText(SourceText.From("// Something else"));
1183sourceGeneratedDocument = sourceGeneratedDocument.WithText(SourceText.From("// Something else"));
1187sourceGeneratedDocument = sourceGeneratedDocument.WithText(SourceText.From("// Thrice is nice"));
1219var solution = sourceGeneratedDocument1.WithText(SourceText.From("// Change doc 1")).Project.Solution;
1226solution = sourceGeneratedDocument2!.WithText(SourceText.From("// Change doc 2")).Project.Solution;
1268newDocument = newDocument.WithText(SourceText.From("// Changed frozen document"));
1277identity, DateTime.Now, SourceText.From("// Frozen Document"));
1314identity, DateTime.Now, SourceText.From("// Frozen Document"));
1345identity, DateTime.Now, SourceText.From("// Frozen Document"));
1380identity, DateTime.Now, SourceText.From("// Frozen Document"));
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)
Microsoft.Extensions.Options.SourceGeneration (1)
Microsoft.Extensions.Validation.ValidationsGenerator (1)
Microsoft.Gen.ComplianceReports.Unit.Tests (1)
Microsoft.Gen.ContextualOptions.Unit.Tests (1)
Microsoft.Gen.Logging (1)
Microsoft.Gen.Logging.Unit.Tests (1)
Microsoft.Gen.MetadataExtractor.Unit.Tests (1)
Microsoft.Gen.Metrics (2)
Microsoft.Gen.Metrics.Unit.Tests (1)
Microsoft.Gen.MetricsReports.Unit.Tests (1)
Microsoft.Maui.Controls.SourceGen (3)
Microsoft.ML.AutoML.SourceGenerator (3)
Microsoft.VisualStudio.LanguageServices (1)
Microsoft.VisualStudio.LanguageServices.CSharp (1)
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (2)
Microsoft.VisualStudio.LanguageServices.LiveShare (2)
Microsoft.VisualStudio.LanguageServices.UnitTests (3)
Roslyn.Diagnostics.Analyzers (3)
Roslyn.Diagnostics.CSharp.Analyzers (1)
Roslyn.VisualStudio.Next.UnitTests (58)
Remote\SnapshotSerializationTests.cs (9)
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);
625sourceText = SourceText.From("Hello", new NotSerializableEncoding());
Services\ServiceHubServicesTests.cs (32)
451var tempDoc = project.AddDocument("X.cs", SourceText.From("// "));
466Assert.True(localWorkspace.SetCurrentSolution(s => s.WithDocumentText(tempDocId, SourceText.From("// " + i)), WorkspaceChangeKind.SolutionChanged));
512=> SourceText.From(content, encoding ?? Encoding.UTF8, checksumAlgorithm);
735return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8)));
757solution = solution.WithTextDocumentText(tempDocId, SourceText.From("// new contents"));
790var tempDoc = project.AddDocument("X.cs", SourceText.From("// "));
819return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8)));
874return ImmutableArray.Create(("hint", SourceText.From($"// generated document {callCount}", Encoding.UTF8)));
928var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
937var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
979var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
988var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
1020var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
1029var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
1063var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
1072var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
1115var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
1125var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
1168var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
1178var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
1221var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
1231var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
1266var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
1276var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
1311var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
1320var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
1354var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
1363var tempDoc = project2.AddDocument("X.cs", SourceText.From("// "));
1446Contract.ThrowIfFalse(workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(normalDocId, SourceText.From("// new text"))));
1560var tempDoc = project1.AddDocument("X.cs", SourceText.From("// "));
1852solution = current.AddDocument($"Document{i}", SourceText.From(documents[i])).Project.Solution;
1858solution = current.AddAdditionalDocument($"AdditionalDocument{i}", SourceText.From(additionalDocuments[i])).Project.Solution;
Services\SolutionServiceTests.cs (16)
159await VerifySolutionUpdate(code, s => s.WithDocumentText(s.Projects.First().DocumentIds.First(), SourceText.From(code + " ")));
314project = project.AddDocument("newDocument", SourceText.From("// new text")).Project;
334loader: TextLoader.From(TextAndVersion.Create(SourceText.From("test"), VersionStamp.Create())));
345return s.WithAdditionalDocumentText(additionalDocumentId, SourceText.From("changed"));
366loader: TextLoader.From(TextAndVersion.Create(SourceText.From("root = true"), VersionStamp.Create(), filePath: configPath)),
378return s.WithAnalyzerConfigDocumentText(analyzerConfigDocumentId, SourceText.From("root = false"));
398loader: TextLoader.From(TextAndVersion.Create(SourceText.From("class A { }"), VersionStamp.Create())));
409return s.WithDocumentText(documentId, SourceText.From("class Changed { }"));
436var currentSolution = remoteSolution1.WithDocumentText(remoteSolution1.Projects.First().Documents.First().Id, SourceText.From(code + " class Test2 { }"));
445currentSolution = oopSolution2.WithDocumentText(oopSolution2.Projects.First().Documents.First().Id, SourceText.From(code + " class Test3 { }"));
521var frozenText1 = SourceText.From("// Hello, World!");
530var frozenText2 = SourceText.From("// Hello, World! A second time!");
834solution = solution.GetProject(project1.Id).AddDocument("X.cs", SourceText.From("// X")).Project.Solution;
835solution = solution.GetProject(project2.Id).AddDocument("Y.vb", SourceText.From("' Y")).Project.Solution;
889solution = solution.GetProject(project1.Id).AddDocument("X.cs", SourceText.From("// X")).Project.Solution;
890solution = solution.GetProject(project2.Id).AddDocument("Y.cs", SourceText.From("// Y")).Project.Solution;
StackDepthTest (1)
System.Private.CoreLib.Generators (2)
System.Text.Json.SourceGeneration (1)
System.Windows.Forms.Analyzers.CSharp.Tests (1)
System.Windows.Forms.Analyzers.Tests (6)
Test.Utilities (4)
Text.Analyzers (4)
Text.Analyzers.UnitTests (1)