Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
8dc9e41f
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,发现更多精彩内容 >>
提交
8dc9e41f
编写于
1月 22, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated annotations based on code review feedback
上级
911faded
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
19 addition
and
21 deletion
+19
-21
src/Compilers/Core/MSBuildTask/CommandLineBuilderExtension.cs
...Compilers/Core/MSBuildTask/CommandLineBuilderExtension.cs
+4
-3
src/Compilers/Core/MSBuildTaskTests/IntegrationTests.cs
src/Compilers/Core/MSBuildTaskTests/IntegrationTests.cs
+6
-16
src/Test/Utilities/Portable/Platform/Desktop/TestHelpers.cs
src/Test/Utilities/Portable/Platform/Desktop/TestHelpers.cs
+9
-2
未找到文件。
src/Compilers/Core/MSBuildTask/CommandLineBuilderExtension.cs
浏览文件 @
8dc9e41f
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
using
System
;
using
System
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.Diagnostics.CodeAnalysis
;
using
System.Globalization
;
using
System.Globalization
;
using
System.Text
;
using
System.Text
;
using
Microsoft.Build.Framework
;
using
Microsoft.Build.Framework
;
...
@@ -174,7 +175,7 @@ internal void AppendSwitchWithSplitting(string switchName, string? parameter, st
...
@@ -174,7 +175,7 @@ internal void AppendSwitchWithSplitting(string switchName, string? parameter, st
/// even if it contains the separators and white space only
/// even if it contains the separators and white space only
/// Split on the characters provided.
/// Split on the characters provided.
/// </summary>
/// </summary>
internal
static
bool
IsParameterEmpty
(
string
parameter
,
params
char
[]
splitOn
)
internal
static
bool
IsParameterEmpty
(
[
NotNullWhen
(
false
)]
string
?
parameter
,
params
char
[]
splitOn
)
{
{
if
(
parameter
!=
null
)
if
(
parameter
!=
null
)
{
{
...
@@ -202,12 +203,12 @@ internal void AppendSwitchIfNotNull
...
@@ -202,12 +203,12 @@ internal void AppendSwitchIfNotNull
(
(
string
switchName
,
string
switchName
,
ITaskItem
[]?
parameters
,
ITaskItem
[]?
parameters
,
string
[]
metadataNames
,
string
[]
?
metadataNames
,
bool
[]?
treatAsFlags
// May be null. In this case no metadata are treated as flags.
bool
[]?
treatAsFlags
// May be null. In this case no metadata are treated as flags.
)
)
{
{
Debug
.
Assert
(
treatAsFlags
==
null
Debug
.
Assert
(
treatAsFlags
==
null
||
(
metadataNames
.
Length
==
treatAsFlags
.
Length
),
||
(
metadataNames
?
.
Length
==
treatAsFlags
.
Length
),
"metadataNames and treatAsFlags should have the same length."
);
"metadataNames and treatAsFlags should have the same length."
);
if
(
parameters
!=
null
)
if
(
parameters
!=
null
)
...
...
src/Compilers/Core/MSBuildTaskTests/IntegrationTests.cs
浏览文件 @
8dc9e41f
...
@@ -11,25 +11,20 @@
...
@@ -11,25 +11,20 @@
using
System.Linq
;
using
System.Linq
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Roslyn.Test.Utilities
;
using
Roslyn.Test.Utilities
;
using
Roslyn.Utilities
;
using
Xunit
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.BuildTasks.UnitTests
namespace
Microsoft.CodeAnalysis.BuildTasks.UnitTests
{
{
public
class
IntegrationTests
:
TestBase
public
class
IntegrationTests
:
TestBase
{
{
private
static
readonly
string
s_msbuildDirectory
;
private
static
readonly
string
?
s_msbuildDirectory
;
private
static
readonly
string
?
s_msbuildExecutable
;
static
IntegrationTests
()
static
IntegrationTests
()
{
{
s_msbuildDirectory
=
DesktopTestHelpers
.
GetMSBuildDirectory
();
s_msbuildDirectory
=
DesktopTestHelpers
.
GetMSBuildDirectory
();
if
(
s_msbuildDirectory
!=
null
)
{
s_msbuildExecutable
=
Path
.
Combine
(
s_msbuildDirectory
,
"MSBuild.exe"
);
}
}
}
private
readonly
string
_msbuildExecutable
;
private
readonly
TempDirectory
_tempDirectory
;
private
readonly
TempDirectory
_tempDirectory
;
private
readonly
List
<
Process
>
_existingServerList
=
new
List
<
Process
>();
private
readonly
List
<
Process
>
_existingServerList
=
new
List
<
Process
>();
private
readonly
string
_buildTaskDll
;
private
readonly
string
_buildTaskDll
;
...
@@ -41,6 +36,7 @@ public IntegrationTests()
...
@@ -41,6 +36,7 @@ public IntegrationTests()
throw
new
InvalidOperationException
(
"Could not locate MSBuild"
);
throw
new
InvalidOperationException
(
"Could not locate MSBuild"
);
}
}
_msbuildExecutable
=
Path
.
Combine
(
s_msbuildDirectory
,
"MSBuild.exe"
);
_tempDirectory
=
Temp
.
CreateDirectory
();
_tempDirectory
=
Temp
.
CreateDirectory
();
_existingServerList
=
Process
.
GetProcessesByName
(
Path
.
GetFileNameWithoutExtension
(
"VBCSCompiler"
)).
ToList
();
_existingServerList
=
Process
.
GetProcessesByName
(
Path
.
GetFileNameWithoutExtension
(
"VBCSCompiler"
)).
ToList
();
_buildTaskDll
=
typeof
(
ManagedCompiler
).
Assembly
.
Location
;
_buildTaskDll
=
typeof
(
ManagedCompiler
).
Assembly
.
Location
;
...
@@ -409,10 +405,8 @@ End Class
...
@@ -409,10 +405,8 @@ End Class
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/1445"
)]
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/1445"
)]
public
void
SimpleMSBuild
()
public
void
SimpleMSBuild
()
{
{
RoslynDebug
.
Assert
(
s_msbuildExecutable
is
object
);
string
arguments
=
string
.
Format
(
@"/m /nr:false /t:Rebuild /p:UseSharedCompilation=false /p:UseRoslyn=1 HelloSolution.sln"
);
string
arguments
=
string
.
Format
(
@"/m /nr:false /t:Rebuild /p:UseSharedCompilation=false /p:UseRoslyn=1 HelloSolution.sln"
);
var
result
=
RunCommandLineCompiler
(
s
_msbuildExecutable
,
arguments
,
_tempDirectory
,
SimpleMsBuildFiles
);
var
result
=
RunCommandLineCompiler
(
_msbuildExecutable
,
arguments
,
_tempDirectory
,
SimpleMsBuildFiles
);
using
(
var
resultFile
=
GetResultFile
(
_tempDirectory
,
@"bin\debug\helloproj.exe"
))
using
(
var
resultFile
=
GetResultFile
(
_tempDirectory
,
@"bin\debug\helloproj.exe"
))
{
{
...
@@ -610,10 +604,8 @@ End Class
...
@@ -610,10 +604,8 @@ End Class
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/16301"
)]
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/16301"
)]
public
void
ReportAnalyzerMSBuild
()
public
void
ReportAnalyzerMSBuild
()
{
{
RoslynDebug
.
Assert
(
s_msbuildExecutable
is
object
);
string
arguments
=
string
.
Format
(
@"/m /nr:false /t:Rebuild /p:UseSharedCompilation=false /p:UseRoslyn=1 HelloSolution.sln"
);
string
arguments
=
string
.
Format
(
@"/m /nr:false /t:Rebuild /p:UseSharedCompilation=false /p:UseRoslyn=1 HelloSolution.sln"
);
var
result
=
RunCommandLineCompiler
(
s
_msbuildExecutable
,
arguments
,
_tempDirectory
,
ReportAnalyzerMsBuildFiles
,
var
result
=
RunCommandLineCompiler
(
_msbuildExecutable
,
arguments
,
_tempDirectory
,
ReportAnalyzerMsBuildFiles
,
new
Dictionary
<
string
,
string
>
new
Dictionary
<
string
,
string
>
{
{
"MyMSBuildToolsPath"
,
Path
.
GetDirectoryName
(
typeof
(
IntegrationTests
).
Assembly
.
Location
)
}
});
{
{
"MyMSBuildToolsPath"
,
Path
.
GetDirectoryName
(
typeof
(
IntegrationTests
).
Assembly
.
Location
)
}
});
...
@@ -624,8 +616,6 @@ public void ReportAnalyzerMSBuild()
...
@@ -624,8 +616,6 @@ public void ReportAnalyzerMSBuild()
[
Fact
(
Skip
=
"failing msbuild"
)]
[
Fact
(
Skip
=
"failing msbuild"
)]
public
void
SolutionWithPunctuation
()
public
void
SolutionWithPunctuation
()
{
{
RoslynDebug
.
Assert
(
s_msbuildExecutable
is
object
);
var
testDir
=
_tempDirectory
.
CreateDirectory
(
@"SLN;!@(goo)'^1"
);
var
testDir
=
_tempDirectory
.
CreateDirectory
(
@"SLN;!@(goo)'^1"
);
var
slnFile
=
testDir
.
CreateFile
(
"Console;!@(goo)'^(Application1.sln"
).
WriteAllText
(
var
slnFile
=
testDir
.
CreateFile
(
"Console;!@(goo)'^(Application1.sln"
).
WriteAllText
(
@"
@"
...
@@ -790,7 +780,7 @@ public class Class1
...
@@ -790,7 +780,7 @@ public class Class1
}
}
"
);
"
);
var
result
=
RunCommandLineCompiler
(
s
_msbuildExecutable
,
"/p:UseSharedCompilation=false"
,
testDir
.
Path
);
var
result
=
RunCommandLineCompiler
(
_msbuildExecutable
,
"/p:UseSharedCompilation=false"
,
testDir
.
Path
);
Assert
.
Equal
(
0
,
result
.
ExitCode
);
Assert
.
Equal
(
0
,
result
.
ExitCode
);
Assert
.
Equal
(
""
,
result
.
Errors
);
Assert
.
Equal
(
""
,
result
.
Errors
);
}
}
...
...
src/Test/Utilities/Portable/Platform/Desktop/TestHelpers.cs
浏览文件 @
8dc9e41f
#
if
NET472
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
#if NET472
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Collections.Immutable
;
...
@@ -275,7 +282,7 @@ public override void Initialize(AnalysisContext context)
...
@@ -275,7 +282,7 @@ public override void Initialize(AnalysisContext context)
return
analyzerImage
;
return
analyzerImage
;
}
}
public
static
string
GetMSBuildDirectory
()
public
static
string
?
GetMSBuildDirectory
()
{
{
var
vsVersion
=
Environment
.
GetEnvironmentVariable
(
"VisualStudioVersion"
)
??
"14.0"
;
var
vsVersion
=
Environment
.
GetEnvironmentVariable
(
"VisualStudioVersion"
)
??
"14.0"
;
using
(
var
key
=
Registry
.
LocalMachine
.
OpenSubKey
(
$@"SOFTWARE\Microsoft\MSBuild\ToolsVersions\
{
vsVersion
}
"
,
false
))
using
(
var
key
=
Registry
.
LocalMachine
.
OpenSubKey
(
$@"SOFTWARE\Microsoft\MSBuild\ToolsVersions\
{
vsVersion
}
"
,
false
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录