1042 references to Path
InteractiveHost.UnitTests (37)
AbstractInteractiveHostTests.cs (1)
209return (file.Path, image);
InteractiveHostCoreInitTests.cs (2)
58var dllDir = Path.GetDirectoryName(dll.Path)!; 86await Host.AddReferenceAsync(Path.GetFileName(dll.Path));
InteractiveHostDesktopInitTests.cs (2)
31var dllDir = Path.GetDirectoryName(dll.Path)!; 59await Host.AddReferenceAsync(Path.GetFileName(dll.Path));
InteractiveHostDesktopTests.cs (32)
183var file = Temp.CreateFile().WriteAllText(MethodWithInfiniteLoop + "\r\nfoo();").Path; 202var file = Temp.CreateFile().WriteAllText("1 1").Path; 237").Path; 273await Host.ExecuteFileAsync(file.Path); 276Assert.True(errorOut.StartsWith(file.Path + "(1,7):", StringComparison.Ordinal), "Error output should start with file name, line and column"); 464Assert.True(await LoadReference(file1.Path)); 465Assert.True(await LoadReference(file2.Path)); 509#r ""{file.Path}"" 521#r ""{file.Path}"" 552#r ""{file1.Path}"" 553#r ""{file2.Path}"" 563Assert.Equal(@"(2,1): error CS1704: An assembly with the same simple name 'C' has already been imported. Try removing one of the references (e.g. '" + file1.Path + @"') or sign them to enable side-by-side. 587#r ""{file1.Path}"" 588#r ""{file2.Path}"" 705rspFile.WriteAllText($"/lib:{directory1.Path} /r:Assembly2.dll {initFile.Path}"); 707await Host.ResetAsync(new InteractiveHostOptions(Host.OptionsOpt!.HostPath, rspFile.Path, CultureInfo.InvariantCulture, CultureInfo.InvariantCulture, Host.OptionsOpt!.Platform)); 723{string.Format(InteractiveHostResources.Loading_context_from_0, Path.GetFileName(rspFile.Path))} 743rspFile.WriteAllText($"{initFile.Path}"); 745await Host.ResetAsync(new InteractiveHostOptions(Host.OptionsOpt!.HostPath, rspFile.Path, CultureInfo.InvariantCulture, CultureInfo.InvariantCulture, Host.OptionsOpt!.Platform)); 749@$"{initFile.Path}(1,1): error CS0006: {string.Format(CSharpResources.ERR_NoMetadataFile, "Assembly.dll")}", error); 770await Host.ResetAsync(new InteractiveHostOptions(Host.OptionsOpt!.HostPath, rspFile.Path, CultureInfo.InvariantCulture, CultureInfo.InvariantCulture, Host.OptionsOpt!.Platform)); 803$@"{string.Format(InteractiveHostResources.Loading_context_from_0, Path.GetFileName(rspFile.Path))} 818{initFile.Path} 821await Host.ResetAsync(new InteractiveHostOptions(Host.OptionsOpt!.HostPath, rspFile.Path, CultureInfo.InvariantCulture, CultureInfo.InvariantCulture, Host.OptionsOpt!.Platform)); 827AssertEx.AssertEqualToleratingWhitespaceDifferences($@"{initFile.Path}(1,3): error CS1002: {CSharpResources.ERR_SemicolonExpected} 831{string.Format(InteractiveHostResources.Loading_context_from_0, Path.GetFileName(rspFile.Path))} 848await Host.ResetAsync(new InteractiveHostOptions(Host.OptionsOpt!.HostPath, rspFile.Path, CultureInfo.InvariantCulture, CultureInfo.InvariantCulture, Host.OptionsOpt!.Platform)); 853$@"{string.Format(InteractiveHostResources.Loading_context_from_0, Path.GetFileName(rspFile.Path))} 916#r """ + dll.Path + @""" 945await Execute($@"#r ""{libFile.Path}"""); 1028await Host.ResetAsync(new InteractiveHostOptions(Host.OptionsOpt!.HostPath, rspFile.Path, culture, uiCulture, Host.OptionsOpt!.Platform)); 1038{string.Format(InteractiveHostResources.Loading_context_from_0, Path.GetFileName(rspFile.Path))}
Microsoft.Build.Tasks.CodeAnalysis.UnitTests (40)
CopyRefAssemblyTests.cs (22)
47File.WriteAllText(file.Path, ""); 52SourcePath = file.Path, 65File.WriteAllText(file.Path, "test"); 71SourcePath = file.Path, 76AssertEx.AssertEqualToleratingWhitespaceDifferences($$"""Copying reference assembly from "{{file.Path}}" to "{{dest}}".""", engine.Log); 85File.WriteAllText(source.Path, "test"); 87File.WriteAllText(dest.Path, "dest"); 92SourcePath = source.Path, 93DestinationPath = dest.Path, 99Could not extract the MVID from "{{source.Path}}". Are you sure it is a reference assembly? 100Copying reference assembly from "{{source.Path}}" to "{{dest}}". 104Assert.Equal("test", File.ReadAllText(dest.Path)); 112File.WriteAllBytes(source.Path, TestResources.General.MVID1); 113var sourceTimestamp = File.GetLastWriteTimeUtc(source.Path).ToString("O"); 116File.WriteAllBytes(dest.Path, TestResources.General.MVID2); 117var destTimestamp = File.GetLastWriteTimeUtc(dest.Path).ToString("O"); 123SourcePath = source.Path, 124DestinationPath = dest.Path, 130Source reference assembly "{{source.Path}}" (timestamp "{{sourceTimestamp}}", MVID "f851dda2-6ea3-475e-8c0d-19bd3c4d9437") differs from destination "{{dest.Path}}" (timestamp "{{destTimestamp}}", MVID "8e1ed25b-2980-4f32-9dee-c1e3b0a57c4b"). 131Copying reference assembly from "{{source.Path}}" to "{{dest.Path}}".
DotNetSdkTests.cs (6)
42<Compile Include=""{libFile.Path}"" Link=""Lib.cs"" /> 433editorConfigFile2.Path 494globalConfigFile.Path, 495globalConfigFile2.Path 561globalConfigFile.Path, 562globalConfigFile2.Path
IntegrationTests.cs (2)
23return ProcessUtilities.Run(file.Path, "", Path.GetDirectoryName(file.Path));
RuntimeHostInfoTests.cs (1)
84File.CreateSymbolicLink(path: symlinkPath, pathToTarget: globalDotNetExe.Path);
SdkIntegrationTests.cs (7)
120var binlogPath = RunBuild(projectFile.Path); 149var binlogPath = RunBuild(projectFile.Path); 188var binlogPath = RunBuild(projectFile.Path); 225var binlogPath = RunBuild(projectFile.Path); 257<EditorConfigFiles Include="{analyzerGlobalConfig.Path}" /> 267var binlogPath = RunBuild(projectFile.Path); 272.Single(f => f.FullPath.Equals(analyzerGlobalConfig.Path, StringComparison.OrdinalIgnoreCase))
TestUtilities\DotNetSdkTestBase.cs (2)
194Project.Path, 236Project.Path,
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (396)
CommandLineIVTTests.cs (8)
38source2.Path, 44var outputFilePath = $"{Path.GetFileName(dir.Path)}{Path.DirectorySeparatorChar}{Path.GetFileName(source2.Path)}"; 115source2.Path, 121var outputFilePath = $"{Path.GetFileName(dir.Path)}{Path.DirectorySeparatorChar}{Path.GetFileName(source2.Path)}"; 194source2.Path, 200var outputFilePath = $"{Path.GetFileName(dir.Path)}{Path.DirectorySeparatorChar}{Path.GetFileName(source2.Path)}"; 279source2.Path, 285var outputFilePath = $"{Path.GetFileName(dir.Path)}{Path.DirectorySeparatorChar}{Path.GetFileName(source2.Path)}";
CommandLineTests.cs (362)
147var cmd = CreateCSharpCompiler(null, dir.Path, new[] { "/nologo", "/errorlog:errorlog", $"/doc:{docName}", "/warnaserror", src.Path }); 167var cmd = CreateCSharpCompiler(null, dir.Path, new[] { "/nologo", "/t:library", "/preferreduilang:en", $"/doc:{docName}", src.Path }); 200"/analyzerconfig:" + analyzerConfig.Path, 201src.Path }); 203Assert.Equal(analyzerConfig.Path, Assert.Single(cmd.Arguments.AnalyzerConfigPaths)); 243"/analyzerconfig:" + modifyPath(editorconfig.Path, doubleSlashAnalyzerConfig), 244modifyPath(src.Path, doubleSlashSource), 292"/analyzerconfig:" + analyzerConfig.Path, 295"/additionalfile:" + additionalFile.Path, 296src.Path }); 298Assert.Equal(analyzerConfig.Path, Assert.Single(cmd.Arguments.AnalyzerConfigPaths)); 345"/analyzerconfig:" + analyzerConfig.Path, 346src.Path }); 348Assert.Equal(analyzerConfig.Path, Assert.Single(cmd.Arguments.AnalyzerConfigPaths)); 354$@"warning InvalidSeverityInAnalyzerConfig: The diagnostic 'cs0169' was given an invalid severity 'garbage' in the analyzer config file at '{analyzerConfig.Path}'. 381"/analyzerconfig:" + analyzerConfig1.Path, 382"/analyzerconfig:" + analyzerConfig2.Path, 383src.Path 401var cmd = CreateCSharpCompiler(null, dir.Path, new[] { "/nologo", src.Path }); 421var cmd = CreateCSharpCompiler(null, dir.Path, new[] { "/nologo", "/codepage:932", src.Path }); 454").Path; 876string tmpFileName = Temp.CreateFile().WriteAllBytes(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }).Path; 1248CleanupAllGeneratedFiles(file1.Path); 1249CleanupAllGeneratedFiles(file2.Path); 1250CleanupAllGeneratedFiles(file3.Path); 1251CleanupAllGeneratedFiles(file4.Path); 1252CleanupAllGeneratedFiles(file5.Path); 2266AssertEx.Equal(File.ReadAllBytes(sl.Path), blob); 2271CleanupAllGeneratedFiles(src.Path); 2295AssertEx.Equal(File.ReadAllBytes(sl.Path), blob); 2299CleanupAllGeneratedFiles(src.Path); 2324CleanupAllGeneratedFiles(src.Path); 2444expectedEmbeddedMap.Add(src.Path, embed_cs); 2449expectedEmbeddedMap.Add(src2.Path, embed2_cs); 2454expectedEmbeddedMap.Add(txt.Path, embed_xyz); 2477CleanupAllGeneratedFiles(src.Path); 2795CleanupAllGeneratedFiles(file.Path); 2817CleanupAllGeneratedFiles(file.Path); 2842var parsedArgs = DefaultParse(new string[] { @"/ruleset:" + file.Path, "a.cs" }, WorkingDirectory); 2844Assert.Equal(expected: file.Path, actual: parsedArgs.RuleSetPath); 2868var parsedArgs = DefaultParse(new string[] { @"/ruleset:" + "\"" + file.Path + "\"", "a.cs" }, WorkingDirectory); 2870Assert.Equal(expected: file.Path, actual: parsedArgs.RuleSetPath); 2897parsedArgs = DefaultParse(new string[] { @"/ruleset:" + file.Path, "a.cs" }, WorkingDirectory); 2900Assert.Equal(expected: file.Path, actual: parsedArgs.RuleSetPath); 2905Assert.Equal(file.Path, (string)err.Arguments[0]); 2937CleanupAllGeneratedFiles(file.Path); 2965var csc = CreateCSharpCompiler(null, dir.Path, new[] { "/nologo", "/preferreduilang:en", "/t:library", "/a:" + Assembly.GetExecutingAssembly().Location, "a.cs", "/ruleset:" + ruleSetFile.Path }); 2972CleanupAllGeneratedFiles(file.Path); 3002"/ruleset:" + ruleSetFile.Path, "/warnaserror+", "/nowarn:8032" }); 3013"/warnaserror+", "/ruleset:" + ruleSetFile.Path, "/nowarn:8032" }); 3020CleanupAllGeneratedFiles(file.Path); 3521"/ruleset:" + ruleSetFile.Path, "/warn:0" }); 3532"/warn:0", "/ruleset:" + ruleSetFile.Path }); 3539CleanupAllGeneratedFiles(file.Path); 3692CleanupAllGeneratedFiles(file.Path); 3712CleanupAllGeneratedFiles(file.Path); 4335var srcDirectory = Path.GetDirectoryName(srcFile.Path); 4346var silverlight = Temp.CreateFile().WriteAllBytes(Silverlight.System).Path; 4347var net4_0dll = Temp.CreateFile().WriteAllBytes(Net461.Resources.System).Path; 4355"/appconfig:" + appConfigFile.Path, 4356srcFile.Path }).Run(outWriter); 4360CleanupAllGeneratedFiles(srcFile.Path); 4361CleanupAllGeneratedFiles(appConfigFile.Path); 4368var srcDirectory = Path.GetDirectoryName(srcFile.Path); 4375srcFile.Path }).Run(outWriter); 4379CleanupAllGeneratedFiles(srcFile.Path); 4495var csc = CreateCSharpCompiler(null, dir.Path, new[] { "/modulename:hocusPocus ", "/out:" + exeName + " ", file1.Path }); 4520CleanupAllGeneratedFiles(file1.Path); 4764CleanupAllGeneratedFiles(src.Path); 4783CleanupAllGeneratedFiles(src.Path); 4791var filePath = tempFolder.CreateFile("temp").Path; 4811CleanupAllGeneratedFiles(src.Path); 5913public class Mod { }").Path; 5918public class Mod { }").Path; 5923class Test { static void Main() {} }").Path; 5960string source1 = Temp.CreateFile(prefix: "", extension: ".cs").WriteAllText(@"public static class Extensions { public static bool EB(this bool b) { return b; } }").Path; 5961string source2 = Temp.CreateFile(prefix: "", extension: ".cs").WriteAllText(@"class C { static void Main() {} }").Path; 5980string source1 = Temp.CreateFile(prefix: "", extension: ".cs").WriteAllText(@"class Mod { }").Path; 5981string source2 = Temp.CreateFile(prefix: "", extension: ".cs").WriteAllText(@"class C { static void Main() {} }").Path; 6160var srcFile = Temp.CreateFile().WriteAllText("\u265A").Path; 6164var output = ProcessUtilities.RunAndGetOutput("cmd", "/C \"" + s_CSharpCompilerExecutable + "\" /nologo /preferreduilang:en /t:library " + srcFile + " > " + tempOut.Path, expectedRetCode: 1); 6169CleanupAllGeneratedFiles(tempOut.Path); 6175var srcFile = Temp.CreateFile().WriteAllText("\u265A").Path; 6179var output = ProcessUtilities.RunAndGetOutput("cmd", "/C \"" + s_CSharpCompilerExecutable + "\" /utf8output /nologo /preferreduilang:en /t:library " + srcFile + " > " + tempOut.Path, expectedRetCode: 1); 6184CleanupAllGeneratedFiles(tempOut.Path); 6204CleanupAllGeneratedFiles(aCs.Path); 6218CleanupAllGeneratedFiles(aCs.Path); 6232CleanupAllGeneratedFiles(aCs.Path); 6332var kfile = "/keyfile:" + snkFile.Path; 6337parsedArgs = DefaultParse(new[] { "/t:library", kfile, "/r:" + cs1698a.Path, "CS1698b.cs" }, WorkingDirectory); 6340parsedArgs = DefaultParse(new[] { "/t:library", kfile, "/r:" + cs1698b.Path, "/out:" + cs1698a.Path, "CS1698.cs" }, WorkingDirectory); 6350CleanupAllGeneratedFiles(snkFile.Path); 6351CleanupAllGeneratedFiles(cs1698a.Path); 6352CleanupAllGeneratedFiles(cs1698b.Path); 6353CleanupAllGeneratedFiles(cs1698.Path); 6359var binaryPath = Temp.CreateFile().WriteAllBytes(Net461.Resources.mscorlib).Path; 6444").Path; 6449").Path; 6468").Path; 6477").Path; 6482").Path; 6490").Path; 6496").Path; 6543").Path; 6548").Path; 6584").Path; 6590").Path; 6625").Path; 6631").Path; 6975CleanupAllGeneratedFiles(file.Path); 6999CleanupAllGeneratedFiles(file.Path); 7022CleanupAllGeneratedFiles(file.Path); 7050CleanupAllGeneratedFiles(file.Path); 7110CleanupAllGeneratedFiles(file1.Path); 7111CleanupAllGeneratedFiles(file2.Path); 7133CleanupAllGeneratedFiles(file.Path); 7233CleanupAllGeneratedFiles(file.Path); 7261CleanupAllGeneratedFiles(file.Path); 7289CleanupAllGeneratedFiles(file.Path); 7315CleanupAllGeneratedFiles(file.Path); 7341CleanupAllGeneratedFiles(file.Path); 7506CleanupAllGeneratedFiles(file.Path); 7545CleanupAllGeneratedFiles(file.Path); 7814Path.GetFileName(sourceFile.Path), 7824string.Format("/win32manifest:{0}", Path.GetFileName(manifestFile.Path)), 7825Path.GetFileName(sourceFile.Path), 7867}").Path; 7871").Path; 7914}").Path; 7918").Path; 7948}").Path; 7952").Path; 7982}").Path; 7986").Path; 8022outWriter.ToString().Replace(Path.GetFileName(src.Path), "{FILE}").Trim()); 8031CleanupAllGeneratedFiles(src.Path); 8037return Temp.CreateFile().WriteAllBytes(cscRsp).Path; 8177string OriginalSource = src.Path; 8187CleanupAllGeneratedFiles(src.Path); 8247CleanupAllGeneratedFiles(src.Path); 8290CleanupAllGeneratedFiles(src.Path); 8291CleanupAllGeneratedFiles(xml.Path); 8361CleanupAllGeneratedFiles(src.Path); 8362CleanupAllGeneratedFiles(xml.Path); 8401}").Path; 8538}").Path; 8577").Path; 8601").Path; 8635").Path; 8654string source = Temp.CreateFile(prefix: "", extension: ".cs").WriteAllText(@"class Test { static void Main() {} }").Path; 8655string badres = Temp.CreateFile().WriteAllBytes(TestResources.DiagnosticTests.badresfile).Path; 8680string source = Temp.CreateFile(prefix: "", extension: ".cs").WriteAllText(@"class Test { static void Main() {} }").Path; 8681string badres = Temp.CreateFile().WriteAllBytes(new byte[] { 0, 0 }).Path; 8709}").Path; 8729} ").Path; 8773using (var stream = File.OpenWrite(exe.Path)) 8780using (var stream = File.OpenWrite(pdb.Path)) 8786int exitCode1 = CreateCSharpCompiler(null, dir.Path, new[] { "/debug:full", "/out:Program.exe", source1.Path }).Run(outWriter); 8789ValidateZeroes(exe.Path, oldSize); 8790ValidateZeroes(pdb.Path, oldSize); 8792int exitCode2 = CreateCSharpCompiler(null, dir.Path, new[] { "/debug:full", "/out:Program.exe", source2.Path }).Run(outWriter); 8795using (var peFile = File.OpenRead(exe.Path)) 8797PdbValidation.ValidateDebugDirectory(peFile, null, pdb.Path, hashAlgorithm: default, hasEmbeddedPdb: false, isDeterministic: false); 8800Assert.True(new FileInfo(exe.Path).Length < oldSize); 8801Assert.True(new FileInfo(pdb.Path).Length < oldSize); 8803int exitCode3 = CreateCSharpCompiler(null, dir.Path, new[] { "/debug:full", "/out:Program.exe", source3.Path }).Run(outWriter); 8806using (var peFile = File.OpenRead(exe.Path)) 8808PdbValidation.ValidateDebugDirectory(peFile, null, pdb.Path, hashAlgorithm: default, hasEmbeddedPdb: false, isDeterministic: false); 8844var fsDll = new FileStream(libDll.Path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete); 8845var fsPdb = new FileStream(libPdb.Path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete); 8848int exitCode = CreateCSharpCompiler(null, dir.Path, new[] { "/target:library", "/debug:full", libSrc.Path }).Run(outWriter); 8856AssertEx.Equal(new byte[] { 0x4D, 0x5A }, ReadBytes(libDll.Path, 2)); 8859AssertEx.Equal(new byte[] { 0x4D, 0x69 }, ReadBytes(libPdb.Path, 2)); 8884var fsDll = new FileStream(libDll.Path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete); 8885var fsPdb = new FileStream(libPdb.Path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete); 8894var output = ProcessUtilities.RunAndGetOutput(s_CSharpCompilerExecutable, $"/target:library /debug:portable \"{libSrc.Path}\"", startFolder: dir.ToString()); 8910using (var fsNewDll = File.OpenRead(libDll.Path)) 8916AssertEx.Equal(new[] { (byte)'B', (byte)'S', (byte)'J', (byte)'B' }, ReadBytes(libPdb.Path, 4)); 8925File.Delete(libSrc.Path); 8926File.Delete(libDll.Path); 8927File.Delete(libPdb.Path); 8950File.SetAttributes(libDll.Path, FileAttributes.ReadOnly); 8952var fsDll = new FileStream(libDll.Path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete); 8955int exitCode = CreateCSharpCompiler(null, dir.Path, new[] { "/target:library", "/preferreduilang:en", libSrc.Path }).Run(outWriter); 8956Assert.Contains($"error CS2012: Cannot open '{libDll.Path}' for writing", outWriter.ToString()); 8958AssertEx.Equal(new[] { (byte)'D', (byte)'L', (byte)'L' }, ReadBytes(libDll.Path, 3)); 8974int exitCode = CreateCSharpCompiler(null, dir.Path, new[] { "/target:library", "/preferreduilang:en", libSrc.Path }).Run(outWriter); 9178} ").Path; 9222string sourcePath = Temp.CreateFile(prefix: "", extension: ".cs").WriteAllText(source).Path; 9247var sourcePath = Temp.CreateFile(directory: WorkingDirectory, extension: ".cs").WriteAllText(source).Path; 9320commandLineArgs = new[] { @"tmpDir\a.cs", tempFile.Path }; 9331commandLineArgs = new[] { tempFile.Path, @"tmpDir\*.cs" }; 9346commandLineArgs = new[] { "/preferreduilang:en", tempFile.Path, "tmpDir\a.cs" }; 9351commandLineArgs = new[] { tempFile.Path, @"tmpDi\r*a?.cs" }; 9360commandLineArgs = new[] { tempFile.Path, currentDrive + @":a.cs" }; 9366commandLineArgs = new[] { "/preferreduilang:en", tempFile.Path, @":a.cs" }; 9371CleanupAllGeneratedFiles(tempFile.Path); 9444var srcDirectory = Path.GetDirectoryName(srcFile.Path); 9450new[] { "/reportanalyzer", "/t:library", srcFile.Path }, 9469CleanupAllGeneratedFiles(srcFile.Path); 9476var srcDirectory = Path.GetDirectoryName(srcFile.Path); 9482new[] { "/reportanalyzer", "/t:library", srcFile.Path }, 9496CleanupAllGeneratedFiles(srcFile.Path); 9503var srcDirectory = Path.GetDirectoryName(srcFile.Path); 9509new[] { "/reportanalyzer", "/t:library", srcFile.Path }, 9522CleanupAllGeneratedFiles(srcFile.Path); 9563var srcDirectory = Path.GetDirectoryName(srcFile.Path); 9565var args = new List<string>() { "/reportanalyzer", "/t:library", "/a:" + typeof(DoNothingGenerator).Assembly.Location, srcFile.Path }; 9587CleanupAllGeneratedFiles(srcFile.Path); 9596var srcDirectory = Path.GetDirectoryName(srcFile.Path); 9605new[] { "/reportanalyzer", "/t:library", srcFile.Path }, 9621CleanupAllGeneratedFiles(srcFile.Path); 9636workingDirectory: Path.GetDirectoryName(srcFile.Path), 9637args: new[] { "/errorlog:" + errorLog.Path, "/warnaserror+", "/nologo", "/t:library", srcFile.Path }, 9647CleanupAllGeneratedFiles(srcFile.Path); 9648CleanupAllGeneratedFiles(errorLog.Path); 9656var srcDirectory = Path.GetDirectoryName(srcFile.Path); 9659var csc = CreateCSharpCompiler(null, WorkingDirectory, new[] { "/t:library", srcFile.Path }, 9673CleanupAllGeneratedFiles(srcFile.Path); 9681var srcDirectory = Path.GetDirectoryName(srcFile.Path); 9684var csc = CreateCSharpCompiler(null, WorkingDirectory, new[] { "/t:library", $"/warnaserror:{AnalyzerExecutor.AnalyzerExceptionDiagnosticId}", srcFile.Path }, 9695CleanupAllGeneratedFiles(srcFile.Path); 9703var srcDirectory = Path.GetDirectoryName(srcFile.Path); 9706var csc = CreateCSharpCompiler(null, WorkingDirectory, new[] { "/t:library", srcFile.Path }, 9717CleanupAllGeneratedFiles(srcFile.Path); 9810").Path; 9861DefaultParse(new[] { "/lib:" + invalidPath, sourceFile.Path }, WorkingDirectory).Errors.Verify( 9864DefaultParse(new[] { "/lib:" + nonExistentPath, sourceFile.Path }, WorkingDirectory).Errors.Verify( 9869DefaultParse(new[] { sourceFile.Path }, WorkingDirectory, additionalReferenceDirectories: invalidPath).Errors.Verify( 9872DefaultParse(new[] { sourceFile.Path }, WorkingDirectory, additionalReferenceDirectories: nonExistentPath).Errors.Verify( 9876CleanupAllGeneratedFiles(sourceFile.Path); 9902string filePath = Temp.CreateFile().WriteAllText(@"class C {}").Path; 10075string filePath = Temp.CreateFile().WriteAllText(source).Path; 10125string filePath = Temp.CreateFile().WriteAllText(source).Path; 10196CleanupAllGeneratedFiles(src.Path); 10255CleanupAllGeneratedFiles(src.Path); 10321CleanupAllGeneratedFiles(src.Path); 10428CleanupAllGeneratedFiles(src.Path); 10431void RunWithCache() => VerifyOutput(dir, src, includeCurrentAssemblyAsAnalyzerReference: false, additionalFlags: new[] { "/langversion:preview", "/features:enable-generator-cache", "/additionalFile:" + additionalFile.Path }, generators: new[] { generator.AsSourceGenerator() }, driverCache: cache, analyzers: null); 10525CleanupAllGeneratedFiles(src.Path); 10528void RunWithCache() => VerifyOutput(dir, src, includeCurrentAssemblyAsAnalyzerReference: false, additionalFlags: new[] { "/langversion:preview", "/features:enable-generator-cache", "/analyzerConfig:" + editorconfig.Path, "/analyzerConfig:" + globalconfig.Path }, generators: new[] { generator.AsSourceGenerator() }, driverCache: cache, analyzers: null); 10562CleanupAllGeneratedFiles(src.Path); 10602CleanupAllGeneratedFiles(src.Path); 10633sourceFile.Path 10730CleanupAllGeneratedFiles(file.Path); 10842CleanupAllGeneratedFiles(file.Path); 10985CleanupAllGeneratedFiles(file.Path); 11183CleanupAllGeneratedFiles(file.Path); 11267CleanupAllGeneratedFiles(file.Path); 11371CleanupAllGeneratedFiles(file.Path); 11470CleanupAllGeneratedFiles(src.Path); 11819var output = ProcessUtilities.RunAndGetOutput(csc32exe.Path, $@"/nologo /debug:full /deterministic /out:Program.exe /pathmap:""{dir32.Path}""=X:\ ""{sourceFile.Path}""", expectedRetCode: 0, startFolder: dir32.Path); 11822output = ProcessUtilities.RunAndGetOutput(s_CSharpCompilerExecutable, $@"/nologo /debug:full /deterministic /out:Program.exe /pathmap:""{dir64.Path}""=X:\ ""{sourceFile.Path}""", expectedRetCode: 0, startFolder: dir64.Path); 12093var cscPath = dir.CopyFile(s_CSharpCompilerExecutable).Path; 12570string filePath = Temp.CreateFile().WriteAllText("").Path; 12590string filePath = Temp.CreateFile().WriteAllText("").Path; 12653CleanupAllGeneratedFiles(srcFile.Path); 12715CleanupAllGeneratedFiles(srcFile.Path); 12771CleanupAllGeneratedFiles(srcFile.Path); 12858CleanupAllGeneratedFiles(sourceFile.Path); 12959CleanupAllGeneratedFiles(sourceFile.Path); 13069CleanupAllGeneratedFiles(sourceFile.Path); 13092CleanupAllGeneratedFiles(srcFile.Path); 13118CleanupAllGeneratedFiles(srcFile.Path); 13185CleanupAllGeneratedFiles(srcFile.Path); 13213CleanupAllGeneratedFiles(srcFile.Path); 13473"/analyzerconfig:" + analyzerConfig.Path, 13474src.Path }; 13493arguments = arguments.Append($"/ruleset:{rulesetFile.Path}"); 13499Assert.Equal(analyzerConfig.Path, Assert.Single(cmd.Arguments.AnalyzerConfigPaths)); 13591additionalArgs = additionalArgs.Append("/analyzerconfig:" + analyzerConfig.Path).ToArray(); 13641additionalArgs = additionalArgs.Append("/ruleset:" + rulesetFile.Path).ToArray(); 13729"/analyzerconfig:" + analyzerConfig.Path, 13730src.Path }; 13744Assert.Equal(analyzerConfig.Path, Assert.Single(cmd.Arguments.AnalyzerConfigPaths)); 13789output = VerifyOutput(dir, src, additionalFlags: new[] { "/nullable", "/analyzerconfig:" + analyzerConfig.Path }, expectedWarningCount: 1, includeCurrentAssemblyAsAnalyzerReference: false); 13798output = VerifyOutput(dir, src, additionalFlags: new[] { "/nullable", "/analyzerconfig:" + analyzerConfig.Path }, expectedWarningCount: 1, includeCurrentAssemblyAsAnalyzerReference: false); 13806output = VerifyOutput(dir, src, additionalFlags: new[] { "/nullable", "/analyzerconfig:" + analyzerConfig.Path }, expectedWarningCount: 1, includeCurrentAssemblyAsAnalyzerReference: false); 13828var args = new[] { "/nologo", "/t:library", "/preferreduilang:en", src.Path }; 13867var args = new[] { "/warnaserror+", $"/warnaserror-:{diagnosticId}", "/nologo", "/t:library", "/preferreduilang:en", src.Path }; 13958additionalFlags = additionalFlags.Append($"/analyzerconfig:{analyzerConfig.Path}").ToArray(); 14006CleanupAllGeneratedFiles(src.Path); 14061CleanupAllGeneratedFiles(src.Path); 14092CleanupAllGeneratedFiles(src.Path); 14130<file id=""1"" name=""{src.Path}"" language=""C#"" checksumAlgorithm=""SHA256"" checksum=""A0-78-BB-A8-E8-B1-E1-3B-E8-63-80-7D-CE-CC-4B-0D-14-EF-06-D3-9B-14-52-E1-95-C6-64-D1-36-EC-7C-25"" /> 14172<file id=""1"" name=""{src.Path}"" language=""C#"" checksumAlgorithm=""SHA1"" checksum=""8A-B8-FF-37-76-5D-12-10-93-F1-CF-51-3E-51-1B-76-2B-90-15-C4"" /> 14218CleanupAllGeneratedFiles(src.Path); 14248CleanupAllGeneratedFiles(src.Path); 14282CleanupAllGeneratedFiles(src.Path); 14320CleanupAllGeneratedFiles(src.Path); 14351options: TestOptions.DebugDll.WithCryptoKeyFile(Path.GetFileName(snk.Path)).WithStrongNameProvider(virtualSnProvider), 14390CleanupAllGeneratedFiles(src.Path); 14411CleanupAllGeneratedFiles(src.Path); 14434CleanupAllGeneratedFiles(src.Path); 14503CleanupAllGeneratedFiles(src.Path); 14531CleanupAllGeneratedFiles(src.Path); 14599CleanupAllGeneratedFiles(src.Path); 14668CleanupAllGeneratedFiles(src.Path); 14749CleanupAllGeneratedFiles(src.Path); 14768VerifyOutput(dir, src, includeCurrentAssemblyAsAnalyzerReference: false, additionalFlags: new[] { "/analyzerconfig:" + analyzerConfig.Path }, generators: new[] { generator }, analyzers: null); 14831"/analyzerconfig:" + analyzerConfig1.Path, 14832"/analyzerconfig:" + analyzerConfig2.Path, 14833"/analyzerconfig:" + analyzerConfig3.Path, 14835src.Path 14899new[] { "/t:library", "/preferreduilang:en", "/nologo", "/warnaserror+", src.Path }, 14919new[] { "/t:library", "/nologo", "/nowarn:CS8785", src.Path }, 14944new[] { "/t:library", "/preferreduilang:en", "/nologo", "/warnaserror+", src.Path }, 14964new[] { "/t:library", "/nologo", "/nowarn:CS8784", src.Path }, 14999VerifyOutput(dir, src, includeCurrentAssemblyAsAnalyzerReference: false, additionalFlags: new[] { "/additionalfile:" + additionalFile.Path, "/langversion:preview", "/out:embed.exe" }, generators: new[] { generator }, analyzers: null); 15002CleanupAllGeneratedFiles(src.Path); 15044new[] { "/nologo", "/t:library", srcFile.Path }, 15050CleanupAllGeneratedFiles(srcFile.Path); 15073"/analyzerconfig:" + analyzerConfig1.Path, 15074"/analyzerconfig:" + analyzerConfig2.Path, 15075src.Path 15103var output = VerifyOutput(dir, src, additionalFlags: new[] { "/analyzerconfig:" + analyzerConfig.Path + "," + analyzerConfig2.Path }, expectedWarningCount: 1, includeCurrentAssemblyAsAnalyzerReference: false); 15122output = VerifyOutput(dir, src, additionalFlags: new[] { "/analyzerconfig:" + analyzerConfig.Path + "," + analyzerConfig2.Path }, expectedWarningCount: 1, includeCurrentAssemblyAsAnalyzerReference: false); 15153"/analyzerconfig:" + analyzerConfig.Path, 15154"/analyzerconfig:" + globalConfig.Path, 15157"/additionalfile:" + additionalFile.Path, 15158src.Path }); 15238additionalFlags: configs.SelectAsArray(c => "/analyzerconfig:" + c.Path) 15260VerifyOutput(dir, src, additionalFlags: new[] { "/warnaserror+", "/analyzerconfig:" + globalConfig.Path }, includeCurrentAssemblyAsAnalyzerReference: false); 15283additionalFlags = additionalFlags.Append("/analyzerconfig:" + globalConfig.Path).ToArray(); 15317[{PathUtilities.NormalizeWithForwardSlash(src.Path)}] 15321VerifyOutput(dir, src, additionalFlags: new[] { "/nowarn:0164", "/analyzerconfig:" + globalConfig.Path }, expectedErrorCount: 0, includeCurrentAssemblyAsAnalyzerReference: false); 15338VerifyOutput(dir, src, additionalFlags: new[] { "/analyzerconfig:" + globalConfig.Path }, expectedErrorCount: 1, includeCurrentAssemblyAsAnalyzerReference: false, analyzers: new[] { new WarningDiagnosticAnalyzer() }); 15340VerifyOutput(dir, src, additionalFlags: new[] { "/nowarn:Warning01", "/analyzerconfig:" + globalConfig.Path }, includeCurrentAssemblyAsAnalyzerReference: false, analyzers: new[] { new WarningDiagnosticAnalyzer() }); 15360additionalFlags: new[] { "/additionalfile:" + additionalFile.Path }, 15441additionalArgs = additionalArgs.Append("/analyzerconfig:" + analyzerConfig.Path).ToArray(); 15562string path1 = additionalFile1.Path; 15563string path2 = additionalFile2?.Path ?? Path.Combine(srcDirectory.Path, additionalFilePath2); 15614var output = VerifyOutput(dir, src, additionalFlags: new[] { "/analyzer:" + notAnalyzer.Path }, expectedWarningCount: 1, includeCurrentAssemblyAsAnalyzerReference: false); 15618VerifyOutput(dir, src, additionalFlags: new[] { "/analyzer:" + notAnalyzer.Path, "/nowarn:CS8034" }, expectedWarningCount: 0, includeCurrentAssemblyAsAnalyzerReference: false); 15621output = VerifyOutput(dir, src, additionalFlags: new[] { "/analyzer:" + notAnalyzer.Path, "/warnAsError:CS8034" }, expectedErrorCount: 1, includeCurrentAssemblyAsAnalyzerReference: false); 15638var output = VerifyOutput(dir, src, additionalFlags: new[] { "/analyzer:" + notAnalyzer.Path }, expectedWarningCount: 1, includeCurrentAssemblyAsAnalyzerReference: false); 15642VerifyOutput(dir, src, additionalFlags: new[] { "/analyzer:" + notAnalyzer.Path, "/analyzerConfig:" + globalconfig.Path }, includeCurrentAssemblyAsAnalyzerReference: false); 15679src.Path }); 15690"/analyzerconfig:" + analyzerConfig.Path, 15691src.Path }); 15693Assert.Equal(analyzerConfig.Path, Assert.Single(cmd.Arguments.AnalyzerConfigPaths)); 15731src.Path }); 15743src.Path }); 15813src.Path }); 15824"/analyzerconfig:" + analyzerConfig.Path, 15825src.Path }); 15827Assert.Equal(analyzerConfig.Path, Assert.Single(cmd.Arguments.AnalyzerConfigPaths)); 15866src.Path }); 15878src.Path }); 15944"/analyzerconfig:" + analyzerConfig.Path, 15945src.Path }); 15983"/analyzerconfig:" + analyzerConfig.Path, 15984src.Path }); 16023"/analyzerconfig:" + analyzerConfig.Path, 16024src.Path });
SarifErrorLoggerTests.cs (9)
41var hello = Temp.CreateFile().WriteAllText(helloWorldCS).Path; 72var sourceFile = Temp.CreateFile().WriteAllText(source).Path; 106var sourceFile = Temp.CreateFile().WriteAllText(source).Path; 138var sourceFile = Temp.CreateFile().WriteAllText(source).Path; 175var sourceFile = Temp.CreateFile().WriteAllText(source).Path; 210var sourceFile = Temp.CreateFile().WriteAllText(source).Path; 245var sourceFile = Temp.CreateFile().WriteAllText(source).Path; 280var sourceFile = Temp.CreateFile().WriteAllText(source).Path; 313var sourceFile = Temp.CreateFile().WriteAllText(source).Path;
SarifV2ErrorLoggerTests.cs (7)
445var sourceFile = Temp.CreateFile().WriteAllText(source).Path; 525var sourceFile1 = sourceDir.CreateFile("source1.cs").WriteAllText(source1).Path; 526var sourceFile2 = sourceDir.CreateFile("source2.cs").WriteAllText(source2).Path; 527var editorconfigFile = sourceDir.CreateFile(".editorconfig").WriteAllText(editorconfigText).Path; 597var sourceFile = Temp.CreateFile().WriteAllText(source).Path; 681string[] arguments = new[] { "/nologo", sourceFile.Path, "/preferreduilang:en", $"/errorlog:{errorLogFile}{GetErrorLogQualifier(version)}" }; 748CleanupAllGeneratedFiles(sourceFile.Path);
TouchedFileLoggingTests.cs (10)
38var hello = Temp.CreateFile().WriteAllText(helloWorldCS).Path; 66var hello = Temp.CreateFile().WriteAllText(helloWorldCS).Path; 77</configuration>").Path; 79var silverlight = Temp.CreateFile().WriteAllBytes(Silverlight.System).Path; 80var net4_0dll = Temp.CreateFile().WriteAllBytes(Net461.Resources.System).Path; 112var hello = Temp.CreateFile().WriteAllText(helloWorldCS).Path; 113var snkPath = Temp.CreateFile("TestKeyPair_", ".snk").WriteAllBytes(TestResources.General.snKey).Path; 151public class C { }").Path; 160"/doc:" + xml.Path, 172expectedWrites.Add(xml.Path);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (6)
Emit\CompilationEmitTests.cs (1)
2002options: TestOptions.ReleaseDll.WithCryptoKeyFile(snk.Path).WithPublicSign(true));
Emit\ResourceTests.cs (5)
58lib = LoadLibraryEx(exe.Path, IntPtr.Zero, 0x00000002); 119var fileVer = FileVersionInfo.GetVersionInfo(exe.Path); 148lib = LoadLibraryEx(exe.Path, IntPtr.Zero, 0x00000002); 201var fileVer = FileVersionInfo.GetVersionInfo(exe.Path); 847lib = LoadLibraryEx(exeFile.Path, IntPtr.Zero, 0x00000002);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (12)
Attributes\EmitTestStrongNameProvider.cs (1)
32var keyFile = Temp.CreateFile().WriteAllBytes(TestResources.General.snKey).Path;
Attributes\InternalsVisibleToAndStrongNameTests.cs (9)
383CSharpCompilation other = CreateCompilation(s, options: TestOptions.ReleaseDll.WithCryptoKeyFile(tempFile.Path), parseOptions: parseOptions); 537[assembly: System.Reflection.AssemblyKeyFile(@""" + snk.Path + @""")] 541c = CreateCompilation(source1, options: TestOptions.SigningReleaseModule.WithCryptoKeyFile(snk.Path).WithPublicSign(true)); 610.WithCryptoKeyFile(snk.Path) 632.WithCryptoKeyFile(pubKeyFile.Path) 656.WithCryptoKeyFile(pubKeyFile.Path) 721.WithCryptoKeyFile(snk.Path), 742.WithCryptoKeyFile(snk.Path), 1517using (var metadata = new FileStream(file.Path, FileMode.Open))
Semantics\ExtensionTests.cs (2)
51834string xmlFilePath = xmlFile.Path; 51888string xmlFilePath = xmlFile.Path;
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (1)
EditAndContinue\StatementEditingTests.cs (1)
4006delegateDefs = MetadataReference.CreateFromImage(File.ReadAllBytes(tempAssembly.Path));
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests (31)
InteractiveSessionReferencesTests.cs (31)
345#r ""{c1.Path}"" 346#r ""{c2.Path}"" 361#r ""{c1.Path}"" 363#r ""{c2.Path}"" 381#r ""{c1.Path}"" 382#r ""{c2.Path}"" 400#r ""{c1.Path}"" 402#r ""{c2.Path}"" 420#r ""{c1.Path}"" 428#r ""{c2.Path}"" 446Diagnostic(ErrorCode.ERR_NoImplicitConv, "c2").WithArguments($"C [{c2.Path}]", $"C [{c1.Path}]")); 630var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 632var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 644Assert.Equal(fileBase1.Path, ((PortableExecutableReference)libBaseRefAndSymbol.Key).FilePath); 688var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 690var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 702Assert.Equal(fileBase1.Path, ((PortableExecutableReference)libBaseRefAndSymbol.Key).FilePath); 754var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 756var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 822var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 824var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 890var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 892var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 958var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 960var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 1026var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 1028var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 1094var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 1097var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 1120var s0 = await CSharpScript.RunAsync("C c;", ScriptOptions.WithReferences(libFile.Path));
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (43)
CommandLineRunnerTests.cs (22)
262""{script.Path}"" 269args: [$@"@""{rsp.Path}""", "/arg5", "--", "/arg7"], 293args: [script.Path, "arg1", "arg2", "arg3"]); 310args: [script.Path, "@arg1", "@arg2", "@arg3"]); 328{script.Path} 336args: [$"@{rsp.Path}", "/arg5", "--", "/arg7"], 359args: ["--", script.Path, "@arg1", "@arg2", "@arg3"]); 445script.Path 536var runner = CreateRunner([$"/loadpath:{dir1.Path}", $"/loadpaths:{dir2.Path};{dir3.Path}", main.Path]); 573var runner = CreateRunner(["/r:4.dll", $"/lib:{dir1.Path}", $"/libpath:{dir2.Path}", $"/libpaths:{dir3.Path};{dir4.Path}", main.Path]); 673var csi = CreateRunner(["b.csx"], responseFile: rsp.Path); 702var runner = CreateRunner(["/i", init.Path], input: 722var runner = CreateRunner([$@"/r:""{reference.Path}""", "/i", init.Path], input: 729{init.Path}(2,3): error CS1002: {CSharpResources.ERR_SemicolonExpected} 737$@"{init.Path}(2,3): error CS1002: {CSharpResources.ERR_SemicolonExpected}", 829$@"#r ""{file1.Path}"" 831#r ""{file2.Path}"" 838> #r ""{file1.Path}"" 840> #r ""{file2.Path}"" 843{string.Format(ScriptingResources.AssemblyAlreadyLoaded, libBaseName, "0.0.0.0", fileBase1.Path, fileBase2.Path)}
InteractiveSessionReferencesTests.cs (9)
40#r ""{libFile.Path}"" 86var libDRef = MetadataReference.CreateFromFile(libDFile.Path); 94var r1 = swapReferences ? libBFile.Path : libAFile.Path; 95var r2 = swapReferences ? libAFile.Path : libBFile.Path; 131var libBRef = MetadataReference.CreateFromFile(libBFile.Path); 137#r ""{libAFile.Path}"" 143File.Move(libBFile.Path, Path.Combine(dir.Path, "libB.dll"));
InteractiveSessionTests.cs (12)
1214lib1.Emit(file1.Path); 1222lib2.Emit(file2.Path); 1225#r ""{file1.Path}"" 1226#r ""{file2.Path}"" 1237lib.Emit(file.Path); 1239string dir = Path.Combine(Path.GetDirectoryName(file.Path), "subdir"); 1240string libFileName = Path.GetFileName(file.Path); 1255lib.Emit(file.Path); 1257string root = Path.GetPathRoot(file.Path); 1258string unrooted = file.Path[root.Length..]; 1296var r2 = CSharpScript.Create($@"#r ""{fileMain.Path}""", ScriptOptions).ContinueWith($@"M.X.F").RunAsync().Result.ReturnValue; 1327var r2 = CSharpScript.Create($@"#r ""{fileMain.Path}""", ScriptOptions).ContinueWith($@"M.X.F").RunAsync().Result.ReturnValue;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (1)
Semantics\SemanticErrorTests.cs (1)
22098var comp = CreateCompilationWithMscorlib40AndDocumentationComments(string.Format(sourceTemplate, xmlFile.Path));
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (76)
Compilation\GetUnusedImportDirectivesTests.cs (1)
212var snkPath = Temp.CreateFile().WriteAllBytes(TestResources.General.snKey).Path;
Compilation\ReferenceManagerTests.cs (10)
852string p1 = Temp.CreateFile().WriteAllBytes(TestResources.General.MDTestLib1).Path; 924string p1 = dir.CreateFile("netModule1.netmodule").WriteAllBytes(TestResources.SymbolsTests.netModule.netModule1).Path; 993string p1 = Temp.CreateFile().WriteAllBytes(Net461.Resources.SystemCore).Path; 994string p2 = Temp.CreateFile().CopyContentFrom(p1).Path; 1013var p1 = Temp.CreateFile().WriteAllBytes(Net461.Resources.System).Path; 1014var p2 = Temp.CreateFile().WriteAllBytes(Net20.Resources.System).Path; 1043var ref1 = AssemblyMetadata.CreateFromFile(exe1.Path).GetReference(aliases: ImmutableArray.Create("A1")); 1044var ref2 = AssemblyMetadata.CreateFromFile(exe2.Path).GetReference(aliases: ImmutableArray.Create("A2")); 1270var path1 = Temp.CreateFile().WriteAllBytes(TestResources.General.MDTestLib1).Path; 1271var path2 = Temp.CreateFile().WriteAllBytes(TestResources.General.MDTestLib2).Path;
DocumentationComments\DocumentationCommentCompilerTests.cs (51)
4497string xmlFilePath = xmlFile.Path; 4532string xmlFilePath = xmlFile.Path; 4570string xmlFilePath = xmlFile.Path; 4605string xmlFilePath = xmlFile.Path; 4641string xmlFilePath = xmlFile.Path; 4795var comp = CreateCompilationUtil(string.Format(sourceTemplate, xmlFile.Path)); 4866var comp = CreateCompilationUtil(string.Format(sourceTemplate, xmlFile.Path)); 4892var xmlFilePath = xmlFile.Path; 4929var xmlFilePath1 = xmlFile1.Path; 4932var xmlFilePath2 = xmlFile2.Path; 4965var xmlFilePath = xmlFile.Path; 4999var xmlFilePath1 = xmlFile1.Path; 5002var xmlFilePath2 = xmlFile2.Path; 5032var xmlFilePath = xmlFile.Path; 5066var xmlFilePath1 = xmlFile1.Path; 5069var xmlFilePath2 = xmlFile2.Path; 5099var xmlFilePath = xmlFile.Path; 5131var xmlFilePath = xmlFile.Path; 5165var xmlFilePath = xmlFile.Path; 5219var xmlFilePath = xmlFile.Path; 5258var xmlFilePath1 = xmlFile1.Path; 5261var xmlFilePath2 = xmlFile2.Path; 5297var xmlFilePath = xmlFile.Path; 5374var xmlFilePath = xmlFile.Path; 5409var xmlFilePath = xmlFile.Path; 5444var xmlFilePath = xmlFile.Path; 5491var xmlFilePath = xmlFile.Path; 5532var xmlFilePath = xmlFile.Path; 5586var xmlFilePath = xmlFile.Path; 5631var xmlFilePath = xmlFile.Path; 5708var xmlFilePath = xmlFile.Path; 5788var xmlFilePath = xmlFile.Path; 5859var xmlFilePath = xmlFile.Path; 5903var xmlFilePath = xmlFile.Path; 5941var xmlFilePath = xmlFile.Path; 5982var xmlFilePath = xmlFile.Path; 6018var xmlFilePath = xmlFile.Path; 6060var xmlFilePath = xmlFile.Path; 6130var xmlFilePath = xmlFile.Path; 6299var xmlFilePath = xmlFile.Path; 7019var comp = CreateCompilationUtil(string.Format(sourceTemplate, xmlFile.Path)); 7037Assert.Equal(string.Format(expectedTemplate, TestHelpers.AsXmlCommentText(xmlFile.Path)), actual); 8268var xmlFilePath = xmlFile.Path; 8358string fullPath = xmlFile.Path; 8382/// <include file='file://" + xmlFile.Path + @"' path='hello'/> 8389@"<include file='file://" + xmlFile.Path + @"' path='hello'/>"). 8390WithArguments("file://" + xmlFile.Path, "hello", "File not found.").WithLocation(2, 5)); 8400string xmlFilePath = Path.GetFileName(xmlFile.Path); 8401string dirPath = Path.GetDirectoryName(xmlFile.Path); 8452/// <include file='" + xmlFile.Path + @"' path='hello'/> 8500var xmlFilePath = xmlFile.Path;
DocumentationComments\DocumentationModeTests.cs (1)
369var xmlFilePath = xmlFile.Path;
Symbols\CompilationCreationTests.cs (9)
2677var data = Temp.CreateFile().WriteAllBytes(Net461.Resources.SystemData).Path; 2678var core = Temp.CreateFile().WriteAllBytes(Net461.Resources.SystemCore).Path; 2679var xml = Temp.CreateFile().WriteAllBytes(Net461.Resources.SystemXml).Path; 2680var system = Temp.CreateFile().WriteAllBytes(Net461.Resources.System).Path; 2722var data = Temp.CreateFile().WriteAllBytes(Net461.Resources.SystemData).Path; 2723var core = Temp.CreateFile().WriteAllBytes(Net461.Resources.SystemCore).Path; 2724var system = Temp.CreateFile().WriteAllBytes(Net461.Resources.System).Path; 2774var csClasses01 = Temp.CreateFile().WriteAllBytes(TestResources.MetadataTests.InterfaceAndClass.CSClasses01).Path; 2775var csInterfaces01 = Temp.CreateFile().WriteAllBytes(TestResources.MetadataTests.InterfaceAndClass.CSInterfaces01).Path;
Symbols\Metadata\PE\TypeForwarders.cs (2)
1599var result = ProcessUtilities.RunAndGetOutput(asmB.Path); 1607result = ProcessUtilities.RunAndGetOutput(asmB2.Path);
Symbols\SymbolErrorTests.cs (2)
7160ilBytes = ReadFromFile(reference.Path); 7229ilBytes = ReadFromFile(reference.Path);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CSharpTestBase.cs (1)
2101return MetadataReference.CreateFromImage(ReadFromFile(tempAssembly.Path));
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (8)
EditAndContinue\EditorManagedHotReloadLanguageServiceTests.cs (5)
536loader: new WorkspaceFileTextLoader(workspace.Services.SolutionServices, sourceFile.Path, Encoding.UTF8), 537filePath: sourceFile.Path)); 542var moduleId = EmitAndLoadLibraryToDebuggee(projectId, source1, sourceFilePath: sourceFile.Path); 548File.WriteAllText(sourceFile.Path, "class C1 { void M() { System.Console.WriteLine(\"b\"); } }", Encoding.UTF8); 561Assert.Equal(sourceFile.Path, key);
Emit\CompilationOutputFilesTests.cs (2)
40var outputs = new CompilationOutputFiles(dllFile.Path, pdbFile.Path);
Utilities\SymbolEquivalenceComparerTests.cs (1)
1937var bytes = File.ReadAllBytes(tempAssembly.Path);
Microsoft.CodeAnalysis.ExternalAccess.HotReload.UnitTests (15)
HotReloadServiceTests.cs (15)
52AddTestDocument(source: null, sourceFileA.Path, out var documentIdA).Project.Solution; 99[$"P: {sourceFileA.Path}: (0,17)-(0,18): Error ENC0110: {string.Format(FeaturesResources.Changing_the_signature_of_0_requires_restarting_the_application_because_it_is_not_supported_by_the_runtime, FeaturesResources.method)}"], 117[$"{sourceFileA.Path}: (0,72)-(0,73): Error CS1002: {CSharpResources.ERR_SemicolonExpected}"], 132$"{sourceFileA.Path}: (0,21)-(0,28): Error CS0103: {string.Format(CSharpResources.ERR_NameNotInContext, "Unknown")}", 133$"{sourceFileA.Path}: (0,51)-(0,52): Warning CS0219: {string.Format(CSharpResources.WRN_UnreferencedVarAssg, "x")}", 229.AddAdditionalTestDocument(source: null, additionalFileA.Path, out var documentIdA) 267var syntaxTree = context.Compilation.SyntaxTrees.Single(t => t.FilePath == sourceFile.Path); 275.AddTestDocument(source: null, sourceFile.Path).Project 276.AddAnalyzerConfigTestDocument([("content", source1)], configFile.Path, out var configId).Project.Solution 315AddTestDocument(source: null, sourceFileA.Path, out var documentIdA).Project.Solution; 317EmitLibrary(projectId, source1, sourceFileA.Path, assemblyName: "Proj"); 337sourceFileA.Path, 343$"P: {sourceFileA.Path}: (0,0)-(0,0): Warning ENC1008: {message}", 370.AddAdditionalTestDocument(source: null, additionalFileA.Path, out var documentIdA) 410AddTestDocument(source: null, sourceFileA.Path, out var documentIdA).Project.Solution;
Microsoft.CodeAnalysis.Features.Test.Utilities (1)
EditAndContinue\EditAndContinueWorkspaceTestBase.cs (1)
155=> projectDirectory?.CreateFile(fileName).WriteAllText(content, Encoding.UTF8).Path ?? Path.Combine(TempRoot.Root, fileName);
Microsoft.CodeAnalysis.Features.UnitTests (92)
EditAndContinue\EditAndContinueWorkspaceServiceTests.cs (89)
66var sourceTreeA1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesA1, sourceBytesA1.Length, encodingA, SourceHashAlgorithms.Default), TestOptions.Regular, sourceFileA.Path); 67var sourceTreeB1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesB1, sourceBytesB1.Length, encodingB, SourceHashAlgorithms.Default), TestOptions.Regular, sourceFileB.Path); 68var sourceTreeC1 = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceBytesC1, sourceBytesC1.Length, encodingC, SourceHashAlgorithm.Sha1), TestOptions.Regular, sourceFileC.Path); 90loader: new WorkspaceFileTextLoader(solution.Services, sourceFileA.Path, encodingA), 91filePath: sourceFileA.Path)); 97loader: new WorkspaceFileTextLoader(solution.Services, sourceFileB.Path, encodingB), 98filePath: sourceFileB.Path)); 104loader: new WorkspaceFileTextLoader(solution.Services, sourceFileC.Path, encodingC), 105filePath: sourceFileC.Path)); 111loader: new WorkspaceFileTextLoader(solution.Services, sourceFileE.Path, encodingE), 112filePath: sourceFileE.Path)); 133filePath: sourceFileD.Path)); 142solution = solution.WithDocumentTextLoader(documentIdB, new WorkspaceFileTextLoader(solution.Services, sourceFileB.Path, encodingB), PreservationMode.PreserveValue); 203solution = solution.WithProjectOutputFilePath(document.Project.Id, moduleFile.Path); 204_mockCompilationOutputs.Add(document.Project.Id, new CompilationOutputFiles(moduleFile.Path)); 306AddTestDocument(source1, sourceFile.Path, out var documentId).Project.Solution; 330$"test: {sourceFile.Path}: (2,0)-(2,22): Error ENC2012: {string.Format(FeaturesResources.EditAndContinueDisallowedByProject, ["test", "*optimized*"])}" 402AddTestDocument(source, sourceFile1.Path, out var documentId).Project.Solution; 502AddTestDocument(source, sourceFile1.Path, out var documentId).Project.Solution; 598AddTestDocument(source, sourceFile1.Path, out var documentId).Project.Solution; 673AddTestDocument(source, sourceFile.Path).Project.Solution; 734AddTestDocument(source, sourceFile.Path, out var documentId).Project.Solution; 780AddTestDocument(source, sourceFile.Path, out var documentId).Project.Solution; 828AddTestDocument(source, sourceFile.Path, out var documentId).Project.Solution; 863AddTestDocument(source, sourceFile.Path, out var documentId).Project.Solution; 901solution = solution.WithProjectOutputFilePath(projectId, moduleFile.Path).AddDocument(documentInfo); 903_mockCompilationOutputs.Add(projectId, new CompilationOutputFiles(moduleFile.Path)); 979var sourceFilePath = dir.CreateFile(sourceFileName).WriteAllText(source, Encoding.UTF8).Path; 1075using var stream = File.OpenRead(moduleFile.Path); 1090_mockCompilationOutputs.Add(projectId, new CompilationOutputFiles(moduleFile.Path)); 1111[$"proj: <no location>: Error ENC1001: {string.Format(FeaturesResources.ErrorReadingFile, moduleFile.Path, expectedErrorMessage)}"], 1163AddDocument("a.cs", CreateText(source1), filePath: sourceFile.Path); 1168var moduleId = EmitAndLoadLibraryToDebuggee(project.Id, source1, sourceFilePath: sourceFile.Path); 1194[$"proj: {document2.FilePath}: (0,0)-(0,0): Error ENC1006: {string.Format(FeaturesResources.UnableToReadSourceFileOrPdb, sourceFile.Path)}"], 1220AddDocument("a.cs", SourceText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 1225var moduleId = EmitAndLoadLibraryToDebuggee(project.Id, source1, sourceFilePath: sourceFile.Path, checksumAlgorithm: SourceHashAlgorithms.Default); 1234using var fileLock = File.Open(sourceFile.Path, FileMode.Open, FileAccess.Read, FileShare.None); 1245[$"test: {document1.FilePath}: (0,0)-(0,0): Error ENC1006: {string.Format(FeaturesResources.UnableToReadSourceFileOrPdb, sourceFile.Path)}"], 1281AddDocument("test.cs", CreateText(sourceA), filePath: sourceFileA.Path); 1287EmitAndLoadLibraryToDebuggee(project.Id, sourceA, sourceFilePath: sourceFileA.Path); 1297var documentB = project.AddTestDocument(sourceB, path: sourceFileB.Path); 1346AddTestDocument(sourceA, sourceFileA.Path).Project. 1347AddTestDocument(sourceB, sourceFileA.Path, out var documentBId).Project.Solution; 1377AddTestDocument(source1, sourceFile1.Path, out var documentBId).Project.Solution; 1388solution = solution.AddTestDocument(projectId, source2, sourceFile2.Path, out var document2Id).Project.Solution; 1438var moduleId = EmitLibrary(project.Id, source1, sourceFilePath: sourceFile.Path); 1445var document0 = project.AddTestDocument(source0, path: sourceFile.Path); 1627AddDocument(documentId = DocumentId.CreateNewId(projectId), "test.cs", SourceText.From(editorSource, editorEncoding, SourceHashAlgorithm.Sha1), filePath: sourceFile.Path); 1631var moduleId = EmitAndLoadLibraryToDebuggee(projectId, fileSource, sourceFilePath: sourceFile.Path, encoding: compilerEncoding, defaultEncoding: defaultEncoding, checksumAlgorithm: SourceHashAlgorithm.Sha256); 1880var moduleId = EmitAndLoadLibraryToDebuggee(projectId, source0, sourceFilePath: sourceFile.Path); 1886var document1 = project.AddTestDocument(source1, path: sourceFile.Path); 1923moduleId = EmitAndLoadLibraryToDebuggee(projectId, source0, sourceFilePath: sourceFile.Path); 1969AddDocument("test.cs", CreateText(source1), filePath: sourceFile.Path); 1974var moduleId = EmitAndLoadLibraryToDebuggee(project.Id, source1, sourceFilePath: sourceFile.Path); 2013AddDocument("test.cs", CreateText(source1), filePath: sourceFile.Path); 2018var moduleId = EmitLibrary(project.Id, source1, sourceFilePath: sourceFile.Path); 2237AddTestDocument(sourceV1, sourceFile.Path, out var documentId).Project. 2238AddTestDocument(globalUsings, globalUsingsFile.Path).Project.Solution; 2684.AddTestDocument(sourceA1, path: sourceFileA.Path, out var documentAId).Project.Solution; 2693.AddTestDocument(sourceB1, path: sourceFileB.Path, out var documentBId).Project.Solution 2725.AddTestDocument(sourceA1, path: sourceFileA.Path, out var documentAId).Project.Solution 2727.AddTestDocument(sourceB1, path: sourceFileB.Path, out var documentBId).Project.Solution; 2770.AddTestDocument(sourceA1, path: sourceFileA.Path, out var documentAId).Project.Solution; 2774var mvidA = EmitAndLoadLibraryToDebuggee(projectAId, sourceA1, sourceFilePath: sourceFileA.Path, assemblyName: "A"); 2775var mvidB = EmitAndLoadLibraryToDebuggee(projectBId, sourceB1, sourceFilePath: sourceFileB.Path, assemblyName: "B"); 2786sourceFileA.Path, 2791sourceFileB.Path, 2801AddTestDocument("class B { virtual int F() => 1; }", path: sourceFileB.Path, out var documentBId).Project.Solution; 3160AddDocument("test.cs", sourceText1, filePath: sourceFile.Path); 3169Assert.Equal(sourceFile.Path, filePath); 3176var moduleId = EmitAndLoadLibraryToDebuggee(documentId.ProjectId, source1, encoding: sjis, checksumAlgorithm: checksumAlg, sourceFilePath: sourceFile.Path); 3209solution = solution.WithDocumentText(documentId, CreateTextFromFile(sourceFile.Path, sjis)); 3253AddDocument("test.cs", CreateText(source2), filePath: sourceFile.Path); 3260var moduleId = EmitAndLoadLibraryToDebuggee(project.Id, source1, sourceFilePath: sourceFile.Path); 3336var moduleId = EmitAndLoadLibraryToDebuggee(project.Id, source1, sourceFilePath: sourceFile.Path); 3359var document1 = project.AddDocument("test.cs", sourceText1, filePath: sourceFile.Path); 3394AddDocument("test.cs", CreateText("class C1 { void M() { System.Console.WriteLine(0); } }"), filePath: sourceFile.Path); 3399var moduleId = EmitLibrary(project.Id, sourceOnDisk, sourceFilePath: sourceFile.Path); 3576_mockCompilationOutputs.Add(document1.Project.Id, new CompilationOutputFiles(moduleFile.Path, pdbFile.Path)); 4371_mockCompilationOutputs.Add(projectA.Id, new CompilationOutputFiles(moduleFileA.Path, pdbFileA.Path)); 4372_mockCompilationOutputs.Add(projectB.Id, new CompilationOutputFiles(moduleFileB.Path, pdbFileB.Path)); 4505var sourcePath = dir.CreateFile("Lib.cs").WriteAllText(source1, Encoding.UTF8).Path; 4605var sourcePath = dir.CreateFile("Lib.cs").WriteAllText(source1, Encoding.UTF8).Path; 5714var moduleId = EmitLibrary(projectP.Id, source1, sourceFileA.Path, assemblyName: "Proj"); 5720loader: new WorkspaceFileTextLoader(solution.Services, sourceFileA.Path, Encoding.UTF8), 5721filePath: sourceFileA.Path));
EditAndContinue\UnitTestingHotReloadServiceTests.cs (3)
35var moduleId = EmitLibrary(projectP.Id, source1, sourceFileA.Path, assemblyName: "Proj"); 43loader: new WorkspaceFileTextLoader(solution.Services, sourceFileA.Path, Encoding.UTF8), 44filePath: sourceFileA.Path));
Microsoft.CodeAnalysis.LanguageServer.UnitTests (61)
ExportProviderBuilderTests.cs (2)
143var fileInfo = new FileInfo(tempFile.Path); 146return tempFile.Path;
FileBasedProgramsEntryPointDiscoveryTests.cs (14)
113AssertSequenceEqualAndStable([appFile.Path], () => discovery.FindEntryPoints(tempDir.Path)); 120AssertEx.SequenceEqual([appFile.Path], discovery.FindEntryPoints(tempDir.Path)); 123File.Delete(appFile.Path); 128AssertEx.SequenceEqual([appFile.Path], discovery.FindEntryPoints(tempDir.Path)); 138AssertEx.SequenceEqual([appFile.Path], discovery.FindEntryPoints(tempDir.Path)); 166AssertSequenceEqualAndStable([app2File.Path], () => discovery.FindEntryPoints(tempDir.Path)); 196AssertSequenceEqualAndStable([appFile.Path], () => discovery.FindEntryPoints(tempDir.Path)); 199File.Delete(csprojFile.Path); 200AssertSequenceEqualAndStable([appFile.Path, programFile.Path], () => discovery.FindEntryPoints(tempDir.Path)); 231var (workspace, document) = await GetRequiredLspWorkspaceAndDocumentAsync(CreateAbsoluteDocumentUri(appFile.Path), testLspServer); 264var (workspace, document) = await GetLspWorkspaceAndDocumentAsync(CreateAbsoluteDocumentUri(appFile.Path), testLspServer); 289var (workspace, document) = await GetLspWorkspaceAndDocumentAsync(CreateAbsoluteDocumentUri(appFile.Path), testLspServer); 314AssertEx.SequenceEqual([appFile.Path], discovery.FindEntryPoints(tempDir.Path));
FileBasedProgramsWorkspaceTests.cs (40)
96var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 133var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 156var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 193var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 219var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 247var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 280var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 440var looseFileUriOne = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 577var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 627var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 667var looseFileUri = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 752var looseFileUriOne = ProtocolConversions.CreateAbsoluteDocumentUri(sourceFile.Path); 816var appCsUri = CreateAbsoluteDocumentUri(appCsFile.Path); 840using var fileChangeContext = fileChangeWatcher.CreateContext([new WatchedDirectory(Path.GetDirectoryName(appCsFile.Path)!, extensionFilters: [])]); 844if (path == appCsFile.Path) 941var appCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(appCsFile.Path); 955var utilCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(utilCsFile.Path); 997var appCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(appCsFile.Path); 1010.AddDocument("Util.cs", SourceText.From(utilCsText), filePath: utilCsFile.Path) 1020var utilCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(utilCsFile.Path); 1069var utilCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(utilCsFile.Path); 1077var appCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(appCsFile.Path); 1135var utilCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(utilCsFile.Path); 1153Assert.Contains(document.Project.Documents, document => document.FilePath == appCsFile.Path); 1175var appCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(appCsFile.Path); 1186.AddDocument("App.cs", SourceText.From(appCsText), filePath: appCsFile.Path) 1196var utilCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(appCsFile.Path); 1241.AddDocument("App.cs", SourceText.From(appCsText), filePath: appCsFile.Path) 1246var appCsUri = ProtocolConversions.CreateAbsoluteDocumentUri(appCsFile.Path); 1291var fileUri = CreateAbsoluteDocumentUri(file.Path); 1301File.Delete(csprojFile.Path); 1351var fileUri = CreateAbsoluteDocumentUri(file.Path); 1381var fileUri = CreateAbsoluteDocumentUri(file.Path); 1412var fileUri = CreateAbsoluteDocumentUri(file.Path); 1422File.Delete(csprojFile.Path); 1473var fileUri = CreateAbsoluteDocumentUri(file.Path); 1508var fileUri = CreateAbsoluteDocumentUri(file.Path); 1542var fileUri = CreateAbsoluteDocumentUri(file.Path); 1566var fileUri = CreateAbsoluteDocumentUri(file.Path); 1599var fileUri = CreateAbsoluteDocumentUri(file.Path);
VirtualProjectXmlProviderTests.cs (5)
71var contentNullable = await projectProvider.GetVirtualProjectContentAsync(appFile.Path, LoggerFactory.CreateLogger<VirtualProjectXmlProviderTests>(), CancellationToken.None); 96var contentNullable = await projectProvider.GetVirtualProjectContentAsync(appFile.Path, logger, CancellationToken.None); 129var contentNullable = await projectProvider.GetVirtualProjectContentAsync(appFile.Path, LoggerFactory.CreateLogger<VirtualProjectXmlProviderTests>(), CancellationToken.None); 181var contentNullable = await projectProvider.GetVirtualProjectContentAsync(appFile.Path, LoggerFactory.CreateLogger<VirtualProjectXmlProviderTests>(), CancellationToken.None); 186Assert.Equal(appFile.Path, diagnostic.Location.Path);
Microsoft.CodeAnalysis.Scripting.Desktop.UnitTests (23)
MetadataShadowCopyProviderTests.cs (23)
87var sc1 = _provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly); 88var sc2 = _provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly); 90Assert.Equal(dll.Path, sc1.PrimaryModule.OriginalPath); 91Assert.NotEqual(dll.Path, sc1.PrimaryModule.FullPath); 95Assert.Equal(File.ReadAllBytes(dll.Path), File.ReadAllBytes(sc1.PrimaryModule.FullPath)); 96Assert.Equal(File.ReadAllBytes(doc.Path), File.ReadAllBytes(sc1.DocumentationFile.FullPath)); 104_provider.SuppressShadowCopy(dll.Path); 106var sc1 = _provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly); 126var sc1 = _provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly); 127Assert.NotEqual(dll.Path, sc1.PrimaryModule.FullPath); 139string path0 = dir.CreateFile("MultiModule.dll").WriteAllBytes(TestResources.SymbolsTests.MultiModule.MultiModuleDll).Path; 140string path1 = dir.CreateFile("mod2.netmodule").WriteAllBytes(TestResources.SymbolsTests.MultiModule.mod2).Path; 141string path2 = dir.CreateFile("mod3.netmodule").WriteAllBytes(TestResources.SymbolsTests.MultiModule.mod3).Path; 185var f0 = Temp.CreateFile().WriteAllText("bogus").Path; 188string f1 = Temp.CreateFile().WriteAllBytes(TestResources.SymbolsTests.MultiModule.MultiModuleDll).Path; 199var sc1 = _provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly); 200var sc2 = _provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly); 202var md1 = _provider.GetMetadata(dll.Path, MetadataImageKind.Assembly); 212var sc3a = _provider.GetMetadataShadowCopy(dll2.Path, MetadataImageKind.Module); 229var sc = provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly); 235sc = provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly); 241sc = provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly); 247sc = provider.GetMetadataShadowCopy(dll.Path, MetadataImageKind.Assembly);
Microsoft.CodeAnalysis.Scripting.UnitTests (6)
RuntimeMetadataReferenceResolverTests.cs (6)
31packageResolver: new PackageResolver(ImmutableDictionary<string, ImmutableArray<string>>.Empty.Add("nuget:N/1.0", ImmutableArray.Create(assembly1.Path, assembly2.Path))), 37AssertEx.SetEqual(actualReferences.SelectAsArray(r => r.FilePath), assembly1.Path, assembly2.Path); 43AssertEx.SetEqual(actualReferences.SelectAsArray(r => r.FilePath), assembly2.Path); 58AssertEx.SetEqual(actualReferences.SelectAsArray(r => r.FilePath), assembly2.Path);
Microsoft.CodeAnalysis.Test.Utilities (10)
AssemblyLoadTestFixture.cs (3)
403", MetadataReference.CreateFromFile(delta1InAnalyzerReferencesDelta1.Path), compilerReference); 547var fileInfo = new FileInfo(tempFile.Path); 550return tempFile.Path;
Metadata\IlasmUtilities.cs (3)
80string sourceFileName = Path.GetFileNameWithoutExtension(sourceFile.Path); 84Path.ChangeExtension(Path.GetFileName(sourceFile.Path), "dll")); 111var arguments = $"\"{sourceFile.Path}\" -DLL {(autoInherit ? "" : "-noautoinherit")} -out=\"{assemblyPath}\"";
TempFiles\DisposableFile.cs (4)
29if (Path != null) 33File.Delete(Path); 40DeleteFileOnClose(Path); 48{1}: {2}", Path, ex.GetType().Name, ex.Message), ex);
Microsoft.CodeAnalysis.UnitTests (106)
AnalyzerAssemblyLoaderTests.cs (26)
574var deltaFile = tempDir.CreateDirectory("a").CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta1).Path; 575var gammaFile = tempDir.CreateDirectory("b").CreateFile("Gamma.dll").CopyContentFrom(testFixture.Gamma).Path; 686var deltaFile1 = tempDir.CreateDirectory("a").CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta1).Path; 688var gammaFile = tempSubDir.CreateFile("Gamma.dll").CopyContentFrom(testFixture.Gamma).Path; 689var deltaFile2 = tempSubDir.CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta1).Path; 728var deltaFile = tempDir.CreateDirectory("a").CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta1).Path; 729var gammaFile = tempDir.CreateDirectory("b").CreateFile("Gamma.dll").CopyContentFrom(testFixture.Gamma).Path; 980var unregisteredDeltaPath = dir1.CopyFile(testFixture.Delta2).Path; 981var epsilonPath = dir1.CopyFile(testFixture.Epsilon).Path; 984var registeredDeltaPath = dir2.CopyFile(testFixture.Delta2).Path; 1038var epsilonFile = tempDir1.CreateFile("Epsilon.dll").CopyContentFrom(testFixture.Epsilon).Path; 1039var delta1File = tempDir1.CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta1).Path; 1040var delta2File = tempDir2.CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta2).Path; 1278var deltaNewFilePath = dir.CopyFile(deltaFilePath).Path; 1292var assemblyFilePath = dir.CreateFile(assemblyName + ".dll").WriteAllBytes(array).Path; 1423var destFile = tempRoot.CreateDirectory().CreateOrOpenFile($"{assembly.GetName().Name}.dll").Path; 1458var deltaCopy = tempDir.CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta1).Path; 1483var deltaCopy = tempDir.CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta1).Path; 1518var delta1File = tempDir1.CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta1).Path; 1519var delta2File = tempDir2.CreateFile("Delta.dll").CopyContentFrom(testFixture.Delta2).Path; 1520var gammaFile = tempDir3.CreateFile("Gamma.dll").CopyContentFrom(testFixture.Gamma).Path; 1574var path = tempFile.Path; 1609var analyzerPath = tempDir.CreateFile("AnalyzerWithLoc.dll").CopyContentFrom(testFixture.AnalyzerWithLoc).Path; 1610var analyzerResourcesPath = tempDir.CreateDirectory("en-GB").CreateFile("AnalyzerWithLoc.resources.dll").CopyContentFrom(testFixture.AnalyzerWithLocResourceEnGB).Path; 1632var analyzerPath = tempDir.CreateFile("AnalyzerWithLoc.dll").CopyContentFrom(testFixture.AnalyzerWithLoc).Path; 1633var analyzerResourcesPath = tempDir.CreateDirectory("es").CreateFile("AnalyzerWithLoc.resources.dll").CopyContentFrom(testFixture.AnalyzerWithLocResourceEnGB).Path;
Analyzers\AnalyzerFileReferenceTests.cs (4)
199var textFile = directory.CreateFile("Goo.txt").WriteAllText("I am the very model of a modern major general.").Path; 231var textFile = directory.CreateFile("Goo.txt").WriteAllText("I am the very model of a modern major general.").Path; 319args: new[] { "/nologo", $@"/analyzer:""{_testFixture.AnalyzerWithLaterFakeCompilerDependency}""", "/nostdlib", $@"/r:""{corlib}""", "/out:something.dll", source.Path }, 348args: new[] { "/nologo", $@"/analyzer:""{_testFixture.AnalyzerWithFakeCompilerDependency}""", $@"/analyzer:""{_testFixture.AnalyzerWithFakeCompilerDependency}""", "/nostdlib", $@"/r:""{corlib}""", "/out:something.dll", source.Path },
AssemblyUtilitiesTests.cs (12)
46var assemblyFile = directory.CreateFile("FakeAssembly.dll").Path; 58var assemblyFile = directory.CreateFile("FakeAssembly.dll").Path; 59var satelliteFile = directory.CreateFile("FakeAssembly.resources.dll").Path; 71var assemblyFile = directory.CreateFile("FakeAssembly.dll").Path; 72var satelliteFile = directory.CreateDirectory("de").CreateFile("FakeAssembly.resources.dll").Path; 84var assemblyFile = directory.CreateFile("FakeAssembly.dll").Path; 85var satelliteFile = directory.CreateDirectory("de").CreateDirectory("FakeAssembly.resources").CreateFile("FakeAssembly.resources.dll").Path; 97var assemblyFile = directory.CreateFile("FakeAssembly.dll").Path; 98var satelliteFileDE = directory.CreateDirectory("de").CreateFile("FakeAssembly.resources.dll").Path; 99var satelliteFileFR = directory.CreateDirectory("fr").CreateFile("FakeAssembly.resources.dll").Path; 111var assemblyFile = directory.CreateFile("FakeAssembly.dll").Path; 112var satelliteFile = directory.CreateDirectory("de").CreateDirectory("OtherAssembly.resources").CreateFile("FakeAssembly.resources.dll").Path;
CommonCommandLineParserTests.cs (14)
45return RuleSet.LoadEffectiveRuleSetFromFile(file.Path); 48return RuleSetProcessor.LoadFromFile(file.Path); 474var ruleSet = RuleSet.LoadEffectiveRuleSetFromFile(file.Path); 989RuleSet.LoadEffectiveRuleSetFromFile(file.Path); 994Assert.Contains(string.Format(CodeAnalysisResources.InvalidRuleSetInclude, newFile.Path, string.Format(CodeAnalysisResources.RuleSetBadAttributeValue, "Action", "Default")), e.Message, StringComparison.Ordinal); 1014var includePaths = RuleSet.GetEffectiveIncludesFromFile(file.Path); 1017Assert.Equal(expected: file.Path, actual: includePaths[0]); 1051var includePaths = RuleSet.GetEffectiveIncludesFromFile(file.Path); 1054Assert.Equal(expected: file.Path, actual: includePaths[0]); 1055Assert.Equal(expected: include.Path, actual: includePaths[1]); 1103var includePaths = RuleSet.GetEffectiveIncludesFromFile(file.Path); 1106Assert.Equal(expected: file.Path, actual: includePaths[0]); 1107Assert.Equal(expected: include1.Path, actual: includePaths[1]); 1108Assert.Equal(expected: include2.Path, actual: includePaths[2]);
FileSystem\RelativePathResolverTests.cs (2)
167var f1 = dir1.CreateFile("f.dll").Path; 168var f2 = dir2.CreateFile("f.dll").Path;
MetadataReferences\AssemblyIdentityComparerTests.cs (1)
632policyPath: appConfig.Path);
MetadataReferences\AssemblyMetadataTests.cs (2)
59var mm = dir.CreateFile("MultiModule.dll").WriteAllBytes(TestResources.SymbolsTests.MultiModule.MultiModuleDll).Path; 142var metadata = AssemblyMetadata.CreateFromFile(invalidModuleName.Path);
MetadataReferences\AssemblyPortabilityPolicyTests.cs (28)
75var stream = new FileStream(appConfig.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); 80Assert.Throws<COMException>(() => FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path)); 89Assert.Throws<COMException>(() => FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path)); 105Assert.Throws<COMException>(() => FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path)); 125var stream = new FileStream(appConfig.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); 127AssertIsEnabled(appConfig.Path, platform: false, nonPlatform: true, fusionOnly: true); 142<linkedConfiguration href=""file://" + appConfig2.Path + @"""/> 161AssertIsEnabled(appConfig1.Path, platform: false, nonPlatform: true); 175AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: true); 183AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: true); 193AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: true); 209AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: true); 227AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: true); 245AssertIsEnabled(appConfig.Path, platform: false, nonPlatform: true); 263AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: false); 281AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: false); 300AssertIsEnabled(appConfig.Path, platform: false, nonPlatform: false); 320AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: false); 344AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: true); 364AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: true); 381AssertIsEnabled(appConfig.Path, platform: true, nonPlatform: true); 389var policy = FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path); 402var policy1 = FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path); 403var policy2 = FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path); 408policy2 = FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path); 413policy2 = FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path); 427policy2 = FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path); 432policy2 = FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig2.Path);
MetadataReferences\MetadataReferenceTests.cs (12)
96var stream = File.OpenRead(file.Path); 110File.Delete(file.Path); 163var r = MetadataReference.CreateFromFile(file.Path, 166Assert.Equal(file.Path, r.FilePath); 167Assert.Equal(file.Path, r.Display); 173Assert.Equal(props, MetadataReference.CreateFromFile(file.Path, props).Properties); 176File.Delete(file.Path); 187var r = MetadataReference.CreateFromFile(file.Path, MetadataReferenceProperties.Module); 189Assert.Equal(file.Path, r.FilePath); 190Assert.Equal(file.Path, r.Display); 196Assert.Equal(props, MetadataReference.CreateFromFile(file.Path, props).Properties); 199File.Delete(file.Path);
ShadowCopyAnalyzerPathResolverTests.cs (1)
36var analyzerPath = TempRoot.CreateDirectory().CreateFile("analyzer.dll").Path;
Text\StringTextDecodingTests.cs (4)
218string path = Temp.CreateFile().WriteAllBytes(encoding.GetBytes(expectedText)).Path; 306File.WriteAllText(tmpFile.Path, expectedText, encoding); 308using (FileStream fs = new FileStream(tmpFile.Path, FileMode.Open, FileAccess.Read)) 322using (FileStream fs = new FileStream(tmpFile.Path, FileMode.Open, FileAccess.Read))
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (1)
VisualStudioMSBuildWorkspaceTests.cs (1)
3213var expectedEditorConfigPath = SolutionDirectory.CreateOrOpenFile(".editorconfig").Path;
Microsoft.CodeAnalysis.Workspaces.UnitTests (9)
CommandLineProject\CommandLineProjectWorkspaceTests.cs (1)
42Assert.Equal(tempFile.Path, gooDoc.FilePath);
SolutionTests\SolutionTests.cs (8)
1687solution = solution.AddDocument(DocumentInfo.Create(fileDocumentId, "d.cs", loader: new FileTextLoader(fileD.Path, defaultEncoding: null), filePath: fileD.Path)); 3497.AddDocument(did, "x", new WorkspaceFileTextLoader(workspace.Services.SolutionServices, file.Path, Encoding.UTF8)); 3546.AddDocument(did, "x", new WorkspaceFileTextLoader(workspace.Services.SolutionServices, file.Path, Encoding.UTF8)); 3613.AddDocument(did, "x", new WorkspaceFileTextLoader(workspace.Services.SolutionServices, file.Path, Encoding.UTF8)); 4723var loader = new TestSmallFileTextLoader(file.Path, Encoding.UTF8); 4725var textLength = FileUtilities.GetFileLength(file.Path); 4727var expected = string.Format(WorkspacesResources.File_0_size_of_1_exceeds_maximum_allowed_size_of_2, file.Path, textLength, 1);
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (27)
PersistentStorage\AbstractPersistentStorageTests.cs (3)
978var info = SolutionInfo.Create(SolutionId.CreateNewId(), VersionStamp.Create(), solutionFile.Path); 987filePath: nullPaths ? null : projectFile.Path)); 992filePath: nullPaths ? null : documentFile.Path));
ProjectSystemShim\CPS\AnalyzersTests.cs (5)
39project.SetOptions([$"/ruleset:{ruleSetFile.Path}"]); 64project.SetOptions([$"/ruleset:{ruleSetFile.Path}"]); 67project.SetOptions([$"/ruleset:{ruleSetFile.Path}"]); 81project.SetOptions([$"/ruleset:{ruleSetFile.Path}"]); 85Assert.Equal(ruleSetFile.Path, environment.Workspace.TryGetRuleSetPathForProject(projectId));
ProjectSystemShim\CPS\CSharpCompilerOptionsTests.cs (1)
162var newFilePath = Temp.CreateFile().Path;
ProjectSystemShim\CPS\CSharpReferencesTests.cs (1)
135var analyzerAssemblyFullPath = tempRoot.CreateFile().Path;
ProjectSystemShim\LegacyProject\AnalyzersTests.cs (14)
44((IAnalyzerHost)project).SetRuleSetFile(ruleSetFile.Path); 59((IAnalyzerHost)project).SetRuleSetFile(ruleSetFile.Path); 62Assert.Equal(ruleSetFile.Path, environment.Workspace.TryGetRuleSetPathForProject(projectId)); 79((IAnalyzerHost)project).SetRuleSetFile(ruleSetFile.Path); 111((IAnalyzerHost)project).SetRuleSetFile(ruleSetFile.Path); 135((IAnalyzerHost)project).SetRuleSetFile(ruleSetFile.Path); 150var pathWithExtraBackslashes = ruleSetFile.Path.Replace(@"\", @"\\"); 156Assert.Equal(expected: ruleSetFile.Path, actual: projectRuleSetFile); 179((IAnalyzerHost)project).SetRuleSetFile(ruleSetFile.Path); 215((IAnalyzerHost)project).SetRuleSetFile(ruleSetFile.Path); 244/ruleset:"{ruleSetFile.Path}" 251((IAnalyzerHost)project).SetRuleSetFile(ruleSetFile.Path); 260File.WriteAllText(ruleSetFile.Path, ruleSetSource.Replace("Error", "Warning")); 261await environment.RaiseFileChangeAsync(ruleSetFile.Path);
ProjectSystemShim\VisualStudioCompilationOutputFilesTests.cs (3)
38var debugDirPdbPath = exactPdbPath ? pdbFile.Path : "a/y/z/lib.pdb"; 48var outputs = new CompilationOutputFilesWithImplicitPdbPath(dllFile.Path); 93var outputs = new CompilationOutputFilesWithImplicitPdbPath(dllFile.Path);
Roslyn.VisualStudio.Next.UnitTests (12)
EditorFactoryTests.cs (1)
44var filePath = tempRoot.CreateFile("Test", "cs").Path;
Remote\SnapshotSerializationTests.cs (9)
427var reference = new AnalyzerFileReference(location, new MockShadowCopyAnalyzerAssemblyLoader(ImmutableDictionary<string, string>.Empty.Add(location, file.Path))); 448var reference = new AnalyzerFileReference(location, new MockShadowCopyAnalyzerAssemblyLoader(ImmutableDictionary<string, string>.Empty.Add(location, file.Path))); 485var analyzer1 = new AnalyzerFileReference(file1.Path, TestAnalyzerAssemblyLoader.LoadNotImplemented); 486var analyzer2 = new AnalyzerFileReference(file2.Path, TestAnalyzerAssemblyLoader.LoadNotImplemented); 494AssertEx.Equal([file1.Path, file2.Path], recovered.GetProject(project.Id).AnalyzerReferences.Select(r => r.FullPath)); 567var tempCorlibXml = tempDir.CreateFile(Path.ChangeExtension(tempCorlib.Path, "xml")); 585.AddMetadataReference(MetadataReference.CreateFromFile(tempCorlib.Path)) 703return new AnalyzerFileReference(original, new MockShadowCopyAnalyzerAssemblyLoader(ImmutableDictionary<string, string>.Empty.Add(original, shadow.Path)));
Services\ServiceHubServicesTests.cs (2)
375p1, VersionStamp.Create(), "p1", "p1", LanguageNames.CSharp, outputFilePath: file.Path, 379metadataReferences: [MetadataReference.CreateFromFile(file.Path)])
VBCSCompiler.UnitTests (27)
AnalyzerConsistencyCheckerTests.cs (11)
72var emitResult = comp.Emit(file.Path); 120new CommandLineAnalyzerReference(mvidAlpha1.Path), 121new CommandLineAnalyzerReference(mvidAlpha2.Path)); 145ImmutableArray.Create(new CommandLineAnalyzerReference(mvidAlpha1.Path)), 150File.Delete(mvidAlpha1.Path); 152Assert.Equal(mvidAlpha1.Path, mvidAlpha2.Path); 155ImmutableArray.Create(new CommandLineAnalyzerReference(mvidAlpha2.Path)), 165Assert.Contains(mvidAlpha1.Path, errorMessage); 166Assert.Contains(mvidAlpha2.Path, errorMessage); 240var analyzerReferences = ImmutableArray.Create(new CommandLineAnalyzerReference(compFile.Path));
CompilerServerTests.cs (14)
190var srcFile = tempDir.CreateFile("test.cs").WriteAllText(source).Path; 231var result = ProcessUtilities.Run(file.Path, "", Path.GetDirectoryName(file.Path)); 308var srcFile = _tempDirectory.CreateFile("test.cs").WriteAllText("♕").Path; 330var srcFile = _tempDirectory.CreateFile("test.vb").WriteAllText("♕").Path; 354var srcFile = _tempDirectory.CreateFile("test.vb").WriteAllText("♕").Path; 1115var srcFile = _tempDirectory.CreateFile("test.cs").WriteAllText("♕").Path; 1137var srcFile = _tempDirectory.CreateFile("test.vb").WriteAllText(@"♕").Path; 1164var srcFile = _tempDirectory.CreateFile("test.cs").WriteAllText("♕").Path; 1186var srcFile = _tempDirectory.CreateFile("test.vb").WriteAllText(@"♕").Path; 1271var srcFile = _tempDirectory.CreateFile("test.cs").WriteAllText("♕").Path; 1295var srcFile = _tempDirectory.CreateFile("test.cs").WriteAllText("♕").Path; 1361var srcFile = _tempDirectory.CreateFile("test.cs").WriteAllText("").Path; 1395var srcFile = _tempDirectory.CreateFile("test.vb").WriteAllText("").Path;
TouchedFileLoggingTests.cs (2)
58var source1 = Temp.CreateFile().WriteAllText(HelloWorldCS).Path; 109var source1 = Temp.CreateFile().WriteAllText(HelloWorldVB).Path;