Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f7594c50
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f7594c50
编写于
11月 10, 2017
作者:
A
Ashley Hauck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce the use of the preprocessor
Prefer to use runtime checks instead.
上级
9ff9ac1c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
47 addition
and
45 deletion
+47
-45
src/Compilers/CSharp/csc/csc.csproj
src/Compilers/CSharp/csc/csc.csproj
+3
-0
src/Compilers/Server/VBCSCompiler/DesktopBuildServerController.cs
...ilers/Server/VBCSCompiler/DesktopBuildServerController.cs
+2
-5
src/Compilers/Server/VBCSCompiler/VBCSCompiler.csproj
src/Compilers/Server/VBCSCompiler/VBCSCompiler.csproj
+4
-1
src/Compilers/Server/VBCSCompilerTests/CompilerServerTests.cs
...Compilers/Server/VBCSCompilerTests/CompilerServerTests.cs
+6
-9
src/Compilers/Server/VBCSCompilerTests/ServerUtil.cs
src/Compilers/Server/VBCSCompilerTests/ServerUtil.cs
+1
-5
src/Compilers/Shared/BuildClient.cs
src/Compilers/Shared/BuildClient.cs
+21
-8
src/Compilers/Shared/BuildServerConnection.cs
src/Compilers/Shared/BuildServerConnection.cs
+0
-6
src/Compilers/Shared/DesktopBuildClient.cs
src/Compilers/Shared/DesktopBuildClient.cs
+7
-11
src/Compilers/VisualBasic/vbc/vbc.csproj
src/Compilers/VisualBasic/vbc/vbc.csproj
+3
-0
未找到文件。
src/Compilers/CSharp/csc/csc.csproj
浏览文件 @
f7594c50
...
...
@@ -36,6 +36,9 @@
<Compile
Include=
"..\..\Shared\CoreClrAnalyzerAssemblyLoader.cs"
>
<Link>
CoreClrAnalyzerAssemblyLoader.cs
</Link>
</Compile>
<Compile
Include=
"..\..\Shared\CoreClrShim.cs"
>
<Link>
CoreClrShim.cs
</Link>
</Compile>
<Compile
Include=
"..\..\Shared\DesktopBuildClient.cs"
>
<Link>
DesktopBuildClient.cs
</Link>
</Compile>
...
...
src/Compilers/Server/VBCSCompiler/DesktopBuildServerController.cs
浏览文件 @
f7594c50
...
...
@@ -36,11 +36,8 @@ internal static ICompilerServerHost CreateCompilerServerHost()
// VBCSCompiler is installed in the same directory as csc.exe and vbc.exe which is also the
// location of the response files.
var
clientDirectory
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
#if NET46
var
sdkDirectory
=
RuntimeEnvironment
.
GetRuntimeDirectory
();
#else
var
sdkDirectory
=
(
string
)
null
;
#endif
var
sdkDirectory
=
BuildClient
.
GetSystemSdkDirectory
();
return
new
DesktopCompilerServerHost
(
clientDirectory
,
sdkDirectory
);
}
...
...
src/Compilers/Server/VBCSCompiler/VBCSCompiler.csproj
浏览文件 @
f7594c50
...
...
@@ -23,7 +23,7 @@
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"
/>
<ItemGroup>
<Reference
Include=
"System.Configuration"
Condition=
"'$(TargetFramework)' != 'netcoreapp2.0'"
/>
<Reference
Include=
"System.Configuration"
Condition=
"'$(TargetFramework)' != 'netcoreapp2.0'"
/>
<PackageReference
Include=
"Microsoft.NETCore.App"
Version=
"$(MicrosoftNETCoreAppVersion)"
Condition=
"'$(TargetFramework)' == 'netcoreapp2.0'"
/>
<PackageReference
Include=
"System.IO.Pipes.AccessControl"
Version=
"$(SystemIOPipesAccessControlVersion)"
Condition=
"'$(TargetFramework)' == 'netcoreapp2.0'"
/>
</ItemGroup>
...
...
@@ -37,6 +37,9 @@
<Compile
Include=
"..\..\Shared\CoreClrAnalyzerAssemblyLoader.cs"
>
<Link>
CoreClrAnalyzerAssemblyLoader.cs
</Link>
</Compile>
<Compile
Include=
"..\..\Shared\CoreClrShim.cs"
>
<Link>
CoreClrShim.cs
</Link>
</Compile>
<Compile
Include=
"..\..\Shared\DesktopAnalyzerAssemblyLoader.cs"
>
<Link>
DesktopAnalyzerAssemblyLoader.cs
</Link>
</Compile>
...
...
src/Compilers/Server/VBCSCompilerTests/CompilerServerTests.cs
浏览文件 @
f7594c50
...
...
@@ -198,11 +198,7 @@ private static (T Result, string Output) UseTextWriter<T>(Encoding encoding, Fun
var
client
=
ServerUtil
.
CreateBuildClient
(
language
);
client
.
TimeoutOverride
=
Timeout
.
Infinite
;
#if NET461
var
sdkDir
=
RuntimeEnvironment
.
GetRuntimeDirectory
();
#else
string
sdkDir
=
null
;
#endif
var
sdkDir
=
ServerUtil
.
DefaultSdkDirectory
;
var
buildPaths
=
new
BuildPaths
(
clientDir
:
Path
.
GetDirectoryName
(
typeof
(
CommonCompiler
).
Assembly
.
Location
),
...
...
@@ -222,10 +218,11 @@ private static DisposableFile GetResultFile(TempDirectory directory, string resu
private
static
void
RunCompilerOutput
(
TempFile
file
,
string
expectedOutput
)
{
#if NET461
var
result
=
ProcessUtilities
.
Run
(
file
.
Path
,
""
,
Path
.
GetDirectoryName
(
file
.
Path
));
Assert
.
Equal
(
expectedOutput
.
Trim
(),
result
.
Output
.
Trim
());
#endif
if
(!
CoreClrShim
.
IsRunningOnCoreClr
)
{
var
result
=
ProcessUtilities
.
Run
(
file
.
Path
,
""
,
Path
.
GetDirectoryName
(
file
.
Path
));
Assert
.
Equal
(
expectedOutput
.
Trim
(),
result
.
Output
.
Trim
());
}
}
private
static
void
VerifyResult
((
int
ExitCode
,
string
Output
)
result
)
...
...
src/Compilers/Server/VBCSCompilerTests/ServerUtil.cs
浏览文件 @
f7594c50
...
...
@@ -69,11 +69,7 @@ public void Dispose()
internal
static
class
ServerUtil
{
internal
static
string
DefaultClientDirectory
{
get
;
}
=
Path
.
GetDirectoryName
(
typeof
(
DesktopBuildClientTests
).
Assembly
.
Location
);
#if NET461
internal
static
string
DefaultSdkDirectory
{
get
;
}
=
RuntimeEnvironment
.
GetRuntimeDirectory
();
#else
internal
static
string
DefaultSdkDirectory
{
get
;
}
=
null
;
#endif
internal
static
string
DefaultSdkDirectory
{
get
;
}
=
BuildClient
.
GetSystemSdkDirectory
();
internal
static
BuildPaths
CreateBuildPaths
(
string
workingDir
,
string
tempDir
)
{
...
...
src/Compilers/Shared/BuildClient.cs
浏览文件 @
f7594c50
...
...
@@ -40,6 +40,18 @@ internal abstract class BuildClient
{
protected
static
bool
IsRunningOnWindows
=>
Path
.
DirectorySeparatorChar
==
'\\'
;
public
static
string
GetSystemSdkDirectory
()
{
if
(
CoreClrShim
.
IsRunningOnCoreClr
)
{
return
null
;
}
else
{
return
RuntimeEnvironment
.
GetRuntimeDirectory
();
}
}
/// <summary>
/// Run a compilation through the compiler server and print the output
/// to the console. If the compiler server fails, run the fallback
...
...
@@ -191,15 +203,16 @@ private static bool UseNativeArguments()
return
false
;
}
#if NET46
if
(
CoreClrShim
.
IsRunningOnCoreClr
)
{
// The native invoke ends up giving us both CoreRun and the exe file.
// We've decided to ignore backcompat for CoreCLR,
// and use the Main()-provided arguments
// https://github.com/dotnet/roslyn/issues/6677
return
false
;
}
return
true
;
#else
// (Not NET46 -> on CoreCLR)
// The native invoke ends up giving us both CoreRun and the exe file.
// Need to find a good way to remove the host as well as the EXE argument.
// https://github.com/dotnet/roslyn/issues/6677
return
false
;
#endif
}
/// <summary>
...
...
src/Compilers/Shared/BuildServerConnection.cs
浏览文件 @
f7594c50
...
...
@@ -341,13 +341,7 @@ internal sealed class BuildServerConnection
internal
static
bool
TryCreateServerCore
(
string
clientDir
,
string
pipeName
)
{
#if NETSTANDARD1_3
bool
isRunningOnCoreClr
=
CoreClrShim
.
IsRunningOnCoreClr
;
#elif NET46
bool
isRunningOnCoreClr
=
false
;
#elif NETCOREAPP2_0
bool
isRunningOnCoreClr
=
true
;
#endif
string
expectedPath
;
string
processArguments
;
if
(
isRunningOnCoreClr
)
...
...
src/Compilers/Shared/DesktopBuildClient.cs
浏览文件 @
f7594c50
...
...
@@ -3,11 +3,8 @@
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Reflection
;
using
System.Runtime.InteropServices
;
namespace
Microsoft.CodeAnalysis.CommandLine
{
...
...
@@ -31,15 +28,14 @@ internal DesktopBuildClient(RequestLanguage language, CompileFunc compileFunc, I
internal
static
int
Run
(
IEnumerable
<
string
>
arguments
,
RequestLanguage
language
,
CompileFunc
compileFunc
,
IAnalyzerAssemblyLoader
analyzerAssemblyLoader
)
{
#if NET46
var
sdkDir
=
RuntimeEnvironment
.
GetRuntimeDirectory
();
#else
string
sdkDir
=
null
;
var
sdkDir
=
GetSystemSdkDirectory
();
if
(
CoreClrShim
.
IsRunningOnCoreClr
)
{
// Register encodings for console
// https://github.com/dotnet/roslyn/issues/10785
System
.
Text
.
Encoding
.
RegisterProvider
(
System
.
Text
.
CodePagesEncodingProvider
.
Instance
);
}
// Register encodings for console
// https://github.com/dotnet/roslyn/issues/10785
System
.
Text
.
Encoding
.
RegisterProvider
(
System
.
Text
.
CodePagesEncodingProvider
.
Instance
);
#endif
var
client
=
new
DesktopBuildClient
(
language
,
compileFunc
,
analyzerAssemblyLoader
);
var
clientDir
=
AppContext
.
BaseDirectory
;
var
workingDir
=
Directory
.
GetCurrentDirectory
();
...
...
src/Compilers/VisualBasic/vbc/vbc.csproj
浏览文件 @
f7594c50
...
...
@@ -35,6 +35,9 @@
<Compile
Include=
"..\..\Shared\CoreClrAnalyzerAssemblyLoader.cs"
>
<Link>
CoreClrAnalyzerAssemblyLoader.cs
</Link>
</Compile>
<Compile
Include=
"..\..\Shared\CoreClrShim.cs"
>
<Link>
CoreClrShim.cs
</Link>
</Compile>
<Compile
Include=
"..\..\Shared\DesktopBuildClient.cs"
>
<Link>
DesktopBuildClient.cs
</Link>
</Compile>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录