Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f885ee7c
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,发现更多精彩内容 >>
提交
f885ee7c
编写于
8月 05, 2019
作者:
A
Andrew Hall (METAL)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PR feedback
上级
ef0abfae
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
36 addition
and
37 deletion
+36
-37
src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs
src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs
+1
-1
src/VisualStudio/CSharp/Impl/Utilities/CSharpParseOptionsChangingService.cs
...Sharp/Impl/Utilities/CSharpParseOptionsChangingService.cs
+9
-7
src/VisualStudio/CSharp/Test/ProjectSystemShim/CPS/AdditionalPropertiesTests.cs
...p/Test/ProjectSystemShim/CPS/AdditionalPropertiesTests.cs
+16
-26
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProject.cs
...e/Def/Implementation/ProjectSystem/VisualStudioProject.cs
+8
-1
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
...Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
+2
-2
未找到文件。
src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace.cs
浏览文件 @
f885ee7c
src/VisualStudio/CSharp/Impl/Utilities/CSharpParseOptionsChangingService.cs
浏览文件 @
f885ee7c
...
...
@@ -3,6 +3,7 @@
#
nullable
enable
using
System.Composition
;
using
System.Drawing.Text
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CSharp
;
using
Microsoft.CodeAnalysis.Host.Mef
;
...
...
@@ -25,20 +26,21 @@ public bool CanApplyChange(ParseOptions oldOptions, ParseOptions newOptions, str
var
oldCSharpOptions
=
(
CSharpParseOptions
)
oldOptions
;
var
newCSharpOptions
=
(
CSharpParseOptions
)
newOptions
;
LanguageVersion
parsedMaxLanguageVersion
;
// Currently, only changes to the LanguageVersion of parse options are supported.
if
(
oldCSharpOptions
.
WithLanguageVersion
(
newCSharpOptions
.
SpecifiedLanguageVersion
)
!=
newOptions
)
{
return
false
;
}
if
(
string
.
IsNullOrEmpty
(
maxLangVersion
))
{
parsedMaxLanguageVersion
=
LanguageVersion
.
Latest
;
return
true
;
}
else
{
Contract
.
ThrowIfFalse
(
LanguageVersionFacts
.
TryParse
(
maxLangVersion
,
out
parsedMaxLanguageVersion
));
Contract
.
ThrowIfFalse
(
LanguageVersionFacts
.
TryParse
(
maxLangVersion
,
out
var
parsedMaxLanguageVersion
));
return
newCSharpOptions
.
LanguageVersion
<=
parsedMaxLanguageVersion
;
}
// Currently, only changes to the LanguageVersion of parse options are supported.
return
oldCSharpOptions
.
WithLanguageVersion
(
newCSharpOptions
.
SpecifiedLanguageVersion
)
==
newOptions
&&
newCSharpOptions
.
LanguageVersion
<=
parsedMaxLanguageVersion
;
}
public
void
Apply
(
ParseOptions
options
,
ProjectPropertyStorage
storage
)
...
...
src/VisualStudio/CSharp/Test/ProjectSystemShim/CPS/AdditionalPropertiesTests.cs
浏览文件 @
f885ee7c
...
...
@@ -33,47 +33,37 @@ static string DefaultNamespaceOfSingleProject(TestEnvironment environment)
=>
environment
.
Workspace
.
CurrentSolution
.
Projects
.
Single
().
DefaultNamespace
;
}
[
Wpf
Fact
]
[
Wpf
Theory
]
[
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ProjectSystemShims
)]
public
void
SetProperty_MaxSupportedLangVersion_CPS
()
[
InlineData
(
LanguageVersion
.
CSharp7_3
)]
[
InlineData
(
LanguageVersion
.
CSharp8
)]
[
InlineData
(
LanguageVersion
.
Latest
)]
[
InlineData
(
LanguageVersion
.
LatestMajor
)]
[
InlineData
(
LanguageVersion
.
Preview
)]
public
void
SetProperty_MaxSupportedLangVersion_CPS
(
LanguageVersion
maxSupportedLangVersion
)
{
var
catalog
=
TestEnvironment
.
s_exportCatalog
.
Value
.
WithParts
(
typeof
(
CSharpParseOptionsChangingService
));
const
LanguageVersion
attemptedVersion
=
LanguageVersion
.
CSharp8
;
var
factory
=
ExportProviderCache
.
GetOrCreateExportProviderFactory
(
catalog
);
using
(
var
environment
=
new
TestEnvironment
(
exportProviderFactory
:
factory
))
using
(
var
project
=
CSharpHelpers
.
CreateCSharpCPSProject
(
environment
,
"Test"
))
{
Assert
.
True
(
CanApplyVersionChange
(
environment
,
LanguageVersion
.
CSharp8
));
// Test max version is less than attempted version
var
maxSupportedLangVersion
=
LanguageVersion
.
CSharp7_3
;
project
.
SetProperty
(
AdditionalPropertyNames
.
MaxSupportedLangVersion
,
maxSupportedLangVersion
.
ToDisplayString
());
Assert
.
False
(
CanApplyVersionChange
(
environment
,
LanguageVersion
.
CSharp8
));
// Test max version equals attempted version
maxSupportedLangVersion
=
LanguageVersion
.
CSharp8
;
project
.
SetProperty
(
AdditionalPropertyNames
.
MaxSupportedLangVersion
,
maxSupportedLangVersion
.
ToDisplayString
());
Assert
.
True
(
CanApplyVersionChange
(
environment
,
LanguageVersion
.
CSharp8
));
// Test max version is greater than attempted version
maxSupportedLangVersion
=
LanguageVersion
.
Preview
;
project
.
SetProperty
(
AdditionalPropertyNames
.
MaxSupportedLangVersion
,
maxSupportedLangVersion
.
ToDisplayString
());
Assert
.
True
(
CanApplyVersionChange
(
environment
,
LanguageVersion
.
CSharp8
));
}
static
bool
CanApplyVersionChange
(
TestEnvironment
environment
,
LanguageVersion
newVersion
)
using
(
var
cpsProject
=
CSharpHelpers
.
CreateCSharpCPSProject
(
environment
,
"Test"
))
{
var
project
=
environment
.
Workspace
.
CurrentSolution
.
Projects
.
Single
();
var
oldParseOptions
=
(
CSharpParseOptions
)
project
.
ParseOptions
;
return
environment
.
Workspace
.
CanApplyParseOptionChange
(
cpsProject
.
SetProperty
(
AdditionalPropertyNames
.
MaxSupportedLangVersion
,
maxSupportedLangVersion
.
ToDisplayString
());
var
canApply
=
environment
.
Workspace
.
CanApplyParseOptionChange
(
oldParseOptions
,
oldParseOptions
.
WithLanguageVersion
(
new
Version
),
oldParseOptions
.
WithLanguageVersion
(
attempted
Version
),
project
);
Assert
.
Equal
(
attemptedVersion
<=
maxSupportedLangVersion
,
canApply
);
}
}
}
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProject.cs
浏览文件 @
f885ee7c
...
...
@@ -314,7 +314,14 @@ internal string DefaultNamespace
w
=>
w
.
OnDefaultNamespaceChanged
(
Id
,
value
));
}
internal
void
SetMaxLangVersion
(
string
version
)
=>
_workspace
.
SetMaxLanguageVersion
(
Id
,
version
);
/// <summary>
/// The max language version supported for this project, if applicable. Useful to help indicate what
/// language version features should be suggested to a user, as well as if they can be upgraded.
/// </summary>
internal
string
MaxLangVersion
{
set
=>
_workspace
.
SetMaxLanguageVersion
(
Id
,
value
);
}
#
region
Batching
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
浏览文件 @
f885ee7c
...
...
@@ -1889,11 +1889,11 @@ internal void EnsureDocumentOptionProvidersInitialized()
}
}
internal
void
SetMaxLanguageVersion
(
ProjectId
projectId
,
string
maxLang
Ver
)
internal
void
SetMaxLanguageVersion
(
ProjectId
projectId
,
string
maxLang
uageVersion
)
{
lock
(
_gate
)
{
_projectToMaxSupportedLangVersionMap
[
projectId
]
=
maxLang
Ver
;
_projectToMaxSupportedLangVersionMap
[
projectId
]
=
maxLang
uageVersion
;
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录