提交 98b912d6 编写于 作者: J Jared Parsons 提交者: Jared Parsons

Change to Directory.GetCurrentDirectory

The API Environment.CurrentDirectory is not available on CoreFX.
Switching all uses to Directory.GetCurrentDirectory which is an
equivalent API (it is actually how Environment.CurrentDirectory is often
implemented).

closes #1829
上级 59e57b4f
......@@ -2726,7 +2726,7 @@ public void CompilationWithReferenceDirectives_Errors()
Diagnostic(ErrorCode.ERR_ReferenceDirectiveOnlyAllowedInScripts, @"#r ""System.Core"""));
}
private static readonly string s_resolvedPath = Path.GetPathRoot(Environment.CurrentDirectory) + "RESOLVED";
private static readonly string s_resolvedPath = Path.GetPathRoot(Directory.GetCurrentDirectory()) + "RESOLVED";
private class DummyFileProvider : MetadataFileReferenceProvider
{
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis.BuildTasks;
using static Microsoft.CodeAnalysis.CompilerServer.BuildProtocolConstants;
......@@ -13,7 +14,7 @@ public static int Main(string[] args)
=> BuildClient.RunWithConsoleOutput(
args,
clientDir: AppDomain.CurrentDomain.BaseDirectory,
workingDir: Environment.CurrentDirectory,
workingDir: Directory.GetCurrentDirectory(),
sdkDir: RuntimeEnvironment.GetRuntimeDirectory(),
language: RequestLanguage.CSharpCompile,
fallbackCompiler: Csc.Run);
......
......@@ -385,7 +385,7 @@ private string CurrentDirectoryToUse()
// if ToolTask didn't override. MSBuild uses the process directory.
string workingDirectory = GetWorkingDirectory();
if (string.IsNullOrEmpty(workingDirectory))
workingDirectory = Environment.CurrentDirectory;
workingDirectory = Directory.GetCurrentDirectory();
return workingDirectory;
}
......
......@@ -51,7 +51,7 @@ private static string MSBuildDirectory
private static string MSBuildExecutable { get; } = Path.Combine(MSBuildDirectory, "MSBuild.exe");
private static readonly string s_workingDirectory = Environment.CurrentDirectory;
private static readonly string s_workingDirectory = Directory.GetCurrentDirectory();
private static string ResolveAssemblyPath(string exeName)
{
var path = Path.Combine(s_workingDirectory, exeName);
......@@ -1949,7 +1949,7 @@ private Task<int> DumpProcess(int pid)
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.CreateNoWindow = true;
processStartInfo.FileName = pathToProcDump;
processStartInfo.WorkingDirectory = Environment.CurrentDirectory;
processStartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
processStartInfo.UseShellExecute = false;
processStartInfo.Arguments = " -accepteula -c 0 -ma " + pid.ToString();
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis.BuildTasks;
using static Microsoft.CodeAnalysis.CompilerServer.BuildProtocolConstants;
......@@ -13,7 +14,7 @@ public static int Main(string[] args)
=> BuildClient.RunWithConsoleOutput(
args,
clientDir: AppDomain.CurrentDomain.BaseDirectory,
workingDir: Environment.CurrentDirectory,
workingDir: Directory.GetCurrentDirectory(),
sdkDir: RuntimeEnvironment.GetRuntimeDirectory(),
language: RequestLanguage.VisualBasicCompile,
fallbackCompiler: Vbc.Run);
......
......@@ -68,7 +68,7 @@ public void UpOneDirectoryNotShownAtRoot()
// after so many ".." we should be at the root drive an should no longer suggest the parent. we can determine
// our current directory depth by counting the number of backslashes present in the current working directory
// and after that many references to "..", we are at the root.
int depth = Environment.CurrentDirectory.Count(c => c == Path.DirectorySeparatorChar);
int depth = Directory.GetCurrentDirectory().Count(c => c == Path.DirectorySeparatorChar);
var pathToRoot = string.Concat(Enumerable.Repeat(@"..\", depth));
VerifyItemExistsInInteractive(
......
......@@ -89,7 +89,7 @@ public void Initialize(Type replType)
_hostObject = new InteractiveHostObject();
_options = _options
.WithBaseDirectory(Environment.CurrentDirectory)
.WithBaseDirectory(Directory.GetCurrentDirectory())
.AddReferences(_hostObject.GetType().Assembly);
_hostObject.ReferencePaths.AddRange(_options.SearchPaths);
......@@ -393,7 +393,7 @@ private void CompleteExecution(RemoteAsyncOperation<RemoteExecutionResult> opera
// send any updates to the host object and current directory back to the client:
var newSourcePaths = _hostObject.SourcePaths.List.GetNewContent();
var newReferencePaths = _hostObject.ReferencePaths.List.GetNewContent();
var currentDirectory = Environment.CurrentDirectory;
var currentDirectory = Directory.GetCurrentDirectory();
var oldWorkingDirectory = _options.BaseDirectory;
var newWorkingDirectory = (oldWorkingDirectory != currentDirectory) ? currentDirectory : null;
......
......@@ -26,7 +26,7 @@ public abstract partial class CommonTestBase : TestBase
static CommonTestBase()
{
var configFileName = Path.GetFileName(Assembly.GetExecutingAssembly().Location) + ".config";
var configFilePath = Path.Combine(Environment.CurrentDirectory, configFileName);
var configFilePath = Path.Combine(Directory.GetCurrentDirectory(), configFileName);
if (File.Exists(configFilePath))
{
......
......@@ -364,7 +364,7 @@ public async Task<Solution> OpenSolutionAsync(string solutionFilePath, Cancellat
this.ClearSolution();
var absoluteSolutionPath = this.GetAbsoluteSolutionPath(solutionFilePath, Environment.CurrentDirectory);
var absoluteSolutionPath = this.GetAbsoluteSolutionPath(solutionFilePath, Directory.GetCurrentDirectory());
using (_dataGuard.DisposableWait(cancellationToken))
{
......@@ -505,7 +505,7 @@ public async Task<Project> OpenProjectAsync(string projectFilePath, Cancellation
}
string fullPath;
if (this.TryGetAbsoluteProjectPath(projectFilePath, Environment.CurrentDirectory, ReportMode.Throw, out fullPath))
if (this.TryGetAbsoluteProjectPath(projectFilePath, Directory.GetCurrentDirectory(), ReportMode.Throw, out fullPath))
{
IProjectFileLoader loader;
if (this.TryGetLoaderFromProjectPath(projectFilePath, ReportMode.Throw, out loader))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册