Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
d3bc63fb
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
d3bc63fb
编写于
12月 10, 2020
作者:
T
Tomáš Matoušek
提交者:
GitHub
12月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prefer more specific path map key (#49670)
上级
5faff982
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
25 addition
and
3 deletion
+25
-3
src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs
...rs/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs
+2
-0
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
+6
-0
src/Compilers/Core/Portable/CommandLine/CommandLineParser.cs
src/Compilers/Core/Portable/CommandLine/CommandLineParser.cs
+8
-0
src/Compilers/Core/Portable/SourceFileResolver.cs
src/Compilers/Core/Portable/SourceFileResolver.cs
+1
-3
src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb
...asic/Portable/CommandLine/VisualBasicCommandLineParser.vb
+2
-0
src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
...ompilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
+6
-0
未找到文件。
src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs
浏览文件 @
d3bc63fb
...
...
@@ -1482,6 +1482,8 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string? ba
new
CSharpRequiredLanguageVersion
(
MessageID
.
IDS_FeatureNullableReferenceTypes
.
RequiredVersion
())),
Location
.
None
));
}
pathMap
=
SortPathMap
(
pathMap
);
return
new
CSharpCommandLineArguments
{
IsScriptRunner
=
IsScriptCommandLineParser
,
...
...
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
浏览文件 @
d3bc63fb
...
...
@@ -10740,6 +10740,12 @@ public void PathMapParser()
parsedArgs.Errors.Verify();
Assert.Equal(KeyValuePairUtil.Create("a =,b" + s, "1,= 2" + s), parsedArgs.PathMap[0]);
Assert.Equal(KeyValuePairUtil.Create("x =,y" + s, "3 4" + s), parsedArgs.PathMap[1]);
parsedArgs = DefaultParse(new[] { @"/pathmap:C:\temp\=/_1/,C:\temp\a\=/_2/,C:\temp\a\b\=/_3/", "a.cs", @"a\b.cs", @"a\b\c.cs" }, WorkingDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(KeyValuePairUtil.Create(@"C:\temp\a\b\", "/_3/"), parsedArgs.PathMap[0]);
Assert.Equal(KeyValuePairUtil.Create(@"C:\temp\a\", "/_2/"), parsedArgs.PathMap[1]);
Assert.Equal(KeyValuePairUtil.Create(@"C:\temp\", "/_1/"), parsedArgs.PathMap[2]);
}
[Theory]
...
...
src/Compilers/Core/Portable/CommandLine/CommandLineParser.cs
浏览文件 @
d3bc63fb
...
...
@@ -1195,5 +1195,13 @@ internal static bool TryParseUInt16(string? value, out ushort result)
CompilerOptionParseUtilities
.
ParseFeatures
(
builder
,
features
);
return
builder
.
ToImmutable
();
}
/// <summary>
/// Sort so that more specific keys precede less specific.
/// When mapping a path we find the first key in the array that is a prefix of the path.
/// If multiple keys are prefixes of the path we want to use the longest (more specific) one for the mapping.
/// </summary>
internal
static
ImmutableArray
<
KeyValuePair
<
string
,
string
>>
SortPathMap
(
ImmutableArray
<
KeyValuePair
<
string
,
string
>>
pathMap
)
=>
pathMap
.
Sort
((
x
,
y
)
=>
-
x
.
Key
.
Length
.
CompareTo
(
y
.
Key
.
Length
));
}
}
src/Compilers/Core/Portable/SourceFileResolver.cs
浏览文件 @
d3bc63fb
...
...
@@ -61,15 +61,13 @@ public SourceFileResolver(ImmutableArray<string> searchPaths, string? baseDirect
{
var
pathMapBuilder
=
ArrayBuilder
<
KeyValuePair
<
string
,
string
>>.
GetInstance
(
pathMap
.
Length
);
foreach
(
var
kv
in
pathMap
)
foreach
(
var
(
key
,
value
)
in
pathMap
)
{
var
key
=
kv
.
Key
;
if
(
key
==
null
||
key
.
Length
==
0
)
{
throw
new
ArgumentException
(
CodeAnalysisResources
.
EmptyKeyInPathMap
,
nameof
(
pathMap
));
}
var
value
=
kv
.
Value
;
if
(
value
==
null
)
{
throw
new
ArgumentException
(
CodeAnalysisResources
.
NullValueInPathMap
,
nameof
(
pathMap
));
...
...
src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb
浏览文件 @
d3bc63fb
...
...
@@ -1440,6 +1440,8 @@ lVbRuntimePlus:
' If the script is passed without the `\i` option simply execute the script (`vbi script.vbx`).
interactiveMode
=
interactiveMode
Or
(
IsScriptCommandLineParser
AndAlso
sourceFiles
.
Count
=
0
)
pathMap
=
SortPathMap
(
pathMap
)
Return
New
VisualBasicCommandLineArguments
With
{
.
IsScriptRunner
=
IsScriptCommandLineParser
,
...
...
src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
浏览文件 @
d3bc63fb
...
...
@@ -3483,6 +3483,12 @@ print Goodbye, World"
parsedArgs.Errors.Verify()
Assert.Equal(KeyValuePairUtil.Create("a =,b" & s, "1,= 2" & s), parsedArgs.PathMap(0))
Assert.Equal(KeyValuePairUtil.Create("x =,y" & s, "3 4" & s), parsedArgs.PathMap(1))
parsedArgs = DefaultParse({"/pathmap:C:\temp\=/_1/,C:\temp\a\=/_2/,C:\temp\a\b\=/_3/", "a.cs", "a\b.cs", "a\b\c.cs"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(KeyValuePairUtil.Create("C:\temp\a\b\", "/_3/"), parsedArgs.PathMap(0))
Assert.Equal(KeyValuePairUtil.Create("C:\temp\a\", "/_2/"), parsedArgs.PathMap(1))
Assert.Equal(KeyValuePairUtil.Create("C:\temp\", "/_1/"), parsedArgs.PathMap(2))
End Sub
' PathMapKeepsCrossPlatformRoot and PathMapInconsistentSlashes should be in an
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录