Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
287897f9
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,发现更多精彩内容 >>
未验证
提交
287897f9
编写于
10月 31, 2019
作者:
M
msftbot[bot]
提交者:
GitHub
10月 31, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #39598 from dotnet/merges/release/dev16.4-to-release/dev16.4-vs-deps
Merge release/dev16.4 to release/dev16.4-vs-deps
上级
b8a5611e
7f1d4af6
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
205 addition
and
15 deletion
+205
-15
eng/build.ps1
eng/build.ps1
+21
-1
src/Features/Core/Portable/AddImport/AbstractAddImportCodeFixProvider.cs
...re/Portable/AddImport/AbstractAddImportCodeFixProvider.cs
+1
-1
src/VisualStudio/CSharp/Test/ProjectSystemShim/CPS/AdditionalPropertiesTests.cs
...p/Test/ProjectSystemShim/CPS/AdditionalPropertiesTests.cs
+37
-3
src/VisualStudio/CSharp/Test/ProjectSystemShim/LegacyProject/CSharpCompilerOptionsTests.cs
...ectSystemShim/LegacyProject/CSharpCompilerOptionsTests.cs
+78
-0
src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs
...lementation/ProjectSystem/Legacy/AbstractLegacyProject.cs
+16
-0
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpUpgradeProject.cs
...ationTest/IntegrationTests/CSharp/CSharpUpgradeProject.cs
+45
-10
src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/MockHierarchy.vb
...stUtilities2/ProjectSystemShim/Framework/MockHierarchy.vb
+7
-0
未找到文件。
eng/build.ps1
浏览文件 @
287897f9
...
...
@@ -331,6 +331,9 @@ function SetVisualStudioBootstrapperBuildArgs() {
# Core function for running our unit / integration tests tests
function
TestUsingOptimizedRunner
()
{
# Capture the Path so we can revert it for integration tests
$originalPath
=
$
env
:
PATH
# Tests need to locate .NET Core SDK
$dotnet
=
InitializeDotNetCli
...
...
@@ -417,9 +420,26 @@ function TestUsingOptimizedRunner() {
$args
+=
"
$dll
"
}
if
(
$testVsi
)
{
# Capture the Environment variables altered by `InitializeDotNetCli` so we can revert to them
$alteredDotNetMultiLevelLookup
=
$
env
:
DOTNET_MULTILEVEL_LOOKUP
$alteredPath
=
$
env
:
PATH
# Resolve runtime, shared framework, or SDK from other locations for integration tests
$
env
:
DOTNET_MULTILEVEL_LOOKUP
=
$null
$
env
:
PATH
=
$originalPath
}
try
{
Exec-Console
$runTests
$args
}
finally
{
}
finally
{
if
(
$testVsi
)
{
# Revert the environment variables to the state `InitializeDotNetCli` left them in
$
env
:
DOTNET_MULTILEVEL_LOOKUP
=
$alteredDotNetMultiLevelLookup
$
env
:
PATH
=
$alteredPath
}
Get-Process
"xunit*"
-ErrorAction
SilentlyContinue
|
Stop-Process
if
(
$testIOperation
)
{
Remove-Item
env:\ROSLYN_TEST_IOPERATION
...
...
src/Features/Core/Portable/AddImport/AbstractAddImportCodeFixProvider.cs
浏览文件 @
287897f9
...
...
@@ -54,7 +54,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
:
null
;
var
installerService
=
GetPackageInstallerService
(
document
);
var
packageSources
=
searchNuGetPackages
&&
symbolSearchService
!=
null
&&
installerService
!=
null
var
packageSources
=
searchNuGetPackages
&&
symbolSearchService
!=
null
&&
installerService
?.
IsEnabled
(
document
.
Project
.
Id
)
==
true
?
installerService
.
GetPackageSources
()
:
ImmutableArray
<
PackageSource
>.
Empty
;
...
...
src/VisualStudio/CSharp/Test/ProjectSystemShim/CPS/AdditionalPropertiesTests.cs
浏览文件 @
287897f9
...
...
@@ -40,7 +40,8 @@ static string DefaultNamespaceOfSingleProject(TestEnvironment environment)
[
InlineData
(
LanguageVersion
.
Latest
)]
[
InlineData
(
LanguageVersion
.
LatestMajor
)]
[
InlineData
(
LanguageVersion
.
Preview
)]
public
void
SetProperty_MaxSupportedLangVersion_CPS
(
LanguageVersion
maxSupportedLangVersion
)
[
InlineData
(
null
)]
public
void
SetProperty_MaxSupportedLangVersion_CPS
(
LanguageVersion
?
maxSupportedLangVersion
)
{
var
catalog
=
TestEnvironment
.
s_exportCatalog
.
Value
.
WithParts
(
...
...
@@ -56,14 +57,47 @@ public void SetProperty_MaxSupportedLangVersion_CPS(LanguageVersion maxSupported
var
project
=
environment
.
Workspace
.
CurrentSolution
.
Projects
.
Single
();
var
oldParseOptions
=
(
CSharpParseOptions
)
project
.
ParseOptions
;
cpsProject
.
SetProperty
(
AdditionalPropertyNames
.
MaxSupportedLangVersion
,
maxSupportedLangVersion
.
ToDisplayString
());
cpsProject
.
SetProperty
(
AdditionalPropertyNames
.
MaxSupportedLangVersion
,
maxSupportedLangVersion
?
.
ToDisplayString
());
var
canApply
=
environment
.
Workspace
.
CanApplyParseOptionChange
(
oldParseOptions
,
oldParseOptions
.
WithLanguageVersion
(
attemptedVersion
),
project
);
Assert
.
Equal
(
attemptedVersion
<=
maxSupportedLangVersion
,
canApply
);
if
(
maxSupportedLangVersion
.
HasValue
)
{
Assert
.
Equal
(
attemptedVersion
<=
maxSupportedLangVersion
.
Value
,
canApply
);
}
else
{
Assert
.
True
(
canApply
);
}
}
}
[
WpfFact
]
public
void
SetProperty_MaxSupportedLangVersion_CPS_NotSet
()
{
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
cpsProject
=
CSharpHelpers
.
CreateCSharpCPSProject
(
environment
,
"Test"
))
{
var
project
=
environment
.
Workspace
.
CurrentSolution
.
Projects
.
Single
();
var
oldParseOptions
=
(
CSharpParseOptions
)
project
.
ParseOptions
;
var
canApply
=
environment
.
Workspace
.
CanApplyParseOptionChange
(
oldParseOptions
,
oldParseOptions
.
WithLanguageVersion
(
attemptedVersion
),
project
);
Assert
.
True
(
canApply
);
}
}
}
...
...
src/VisualStudio/CSharp/Test/ProjectSystemShim/LegacyProject/CSharpCompilerOptionsTests.cs
浏览文件 @
287897f9
...
...
@@ -4,10 +4,13 @@
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CSharp
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.VisualStudio
;
using
Microsoft.VisualStudio.LanguageServices.CSharp.ProjectSystemShim.Interop
;
using
Microsoft.VisualStudio.LanguageServices.CSharp.Utilities
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.Interop
;
using
Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Framework
;
using
Microsoft.VisualStudio.Shell.Interop
;
using
Roslyn.Test.Utilities
;
using
Xunit
;
...
...
@@ -167,5 +170,80 @@ public void ProjectCompilationOutputsChange()
outputs
=
(
CompilationOutputFilesWithImplicitPdbPath
)
environment
.
Workspace
.
GetCompilationOutputs
(
project
.
Test_VisualStudioProject
.
Id
);
Assert
.
Equal
(
@"C:\a\3.dll"
,
outputs
.
AssemblyFilePath
);
}
[
WpfTheory
]
[
InlineData
(
LanguageVersion
.
CSharp7_3
)]
[
InlineData
(
LanguageVersion
.
CSharp8
)]
[
InlineData
(
LanguageVersion
.
Latest
)]
[
InlineData
(
LanguageVersion
.
LatestMajor
)]
[
InlineData
(
LanguageVersion
.
Preview
)]
[
InlineData
(
null
)]
public
void
SetProperty_MaxSupportedLangVersion
(
LanguageVersion
?
maxSupportedLangVersion
)
{
var
catalog
=
TestEnvironment
.
s_exportCatalog
.
Value
.
WithParts
(
typeof
(
CSharpParseOptionsChangingService
));
var
factory
=
ExportProviderCache
.
GetOrCreateExportProviderFactory
(
catalog
);
using
var
environment
=
new
TestEnvironment
(
exportProviderFactory
:
factory
);
var
hierarchy
=
environment
.
CreateHierarchy
(
"CSharpProject"
,
"Bin"
,
projectRefPath
:
null
,
projectCapabilities
:
"CSharp"
);
var
storage
=
Assert
.
IsAssignableFrom
<
IVsBuildPropertyStorage
>(
hierarchy
);
Assert
.
True
(
ErrorHandler
.
Succeeded
(
storage
.
SetPropertyValue
(
"MaxSupportedLangVersion"
,
null
,
(
uint
)
_PersistStorageType
.
PST_PROJECT_FILE
,
maxSupportedLangVersion
?.
ToDisplayString
())));
_
=
CSharpHelpers
.
CreateCSharpProject
(
environment
,
"Test"
,
hierarchy
);
var
project
=
environment
.
Workspace
.
CurrentSolution
.
Projects
.
Single
();
var
oldParseOptions
=
(
CSharpParseOptions
)
project
.
ParseOptions
;
const
LanguageVersion
attemptedVersion
=
LanguageVersion
.
CSharp8
;
var
canApply
=
environment
.
Workspace
.
CanApplyParseOptionChange
(
oldParseOptions
,
oldParseOptions
.
WithLanguageVersion
(
attemptedVersion
),
project
);
if
(
maxSupportedLangVersion
.
HasValue
)
{
Assert
.
Equal
(
attemptedVersion
<=
maxSupportedLangVersion
.
Value
,
canApply
);
}
else
{
Assert
.
True
(
canApply
);
}
}
[
WpfFact
]
public
void
SetProperty_MaxSupportedLangVersion_NotSet
()
{
var
catalog
=
TestEnvironment
.
s_exportCatalog
.
Value
.
WithParts
(
typeof
(
CSharpParseOptionsChangingService
));
var
factory
=
ExportProviderCache
.
GetOrCreateExportProviderFactory
(
catalog
);
using
var
environment
=
new
TestEnvironment
(
exportProviderFactory
:
factory
);
var
hierarchy
=
environment
.
CreateHierarchy
(
"CSharpProject"
,
"Bin"
,
projectRefPath
:
null
,
projectCapabilities
:
"CSharp"
);
var
storage
=
Assert
.
IsAssignableFrom
<
IVsBuildPropertyStorage
>(
hierarchy
);
_
=
CSharpHelpers
.
CreateCSharpProject
(
environment
,
"Test"
,
hierarchy
);
var
project
=
environment
.
Workspace
.
CurrentSolution
.
Projects
.
Single
();
var
oldParseOptions
=
(
CSharpParseOptions
)
project
.
ParseOptions
;
const
LanguageVersion
attemptedVersion
=
LanguageVersion
.
CSharp8
;
var
canApply
=
environment
.
Workspace
.
CanApplyParseOptionChange
(
oldParseOptions
,
oldParseOptions
.
WithLanguageVersion
(
attemptedVersion
),
project
);
Assert
.
True
(
canApply
);
}
}
}
src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs
浏览文件 @
287897f9
...
...
@@ -102,6 +102,11 @@ internal abstract partial class AbstractLegacyProject : ForegroundThreadAffiniti
// (e.g. through a <defaultnamespace> msbuild property)
VisualStudioProject
.
DefaultNamespace
=
GetRootNamespacePropertyValue
(
hierarchy
);
if
(
TryGetMaxLangVersionPropertyValue
(
hierarchy
,
out
var
maxLangVer
))
{
VisualStudioProject
.
MaxLangVersion
=
maxLangVer
;
}
Hierarchy
=
hierarchy
;
ConnectHierarchyEvents
();
RefreshBinOutputPath
();
...
...
@@ -392,5 +397,16 @@ private static string GetRootNamespacePropertyValue(IVsHierarchy hierarchy)
return
null
;
}
private
static
bool
TryGetMaxLangVersionPropertyValue
(
IVsHierarchy
hierarchy
,
out
string
maxLangVer
)
{
if
(!(
hierarchy
is
IVsBuildPropertyStorage
storage
))
{
maxLangVer
=
null
;
return
false
;
}
return
ErrorHandler
.
Succeeded
(
storage
.
GetPropertyValue
(
"MaxSupportedLangVersion"
,
null
,
(
uint
)
_PersistStorageType
.
PST_PROJECT_FILE
,
out
maxLangVer
));
}
}
}
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpUpgradeProject.cs
浏览文件 @
287897f9
...
...
@@ -18,16 +18,16 @@ public CSharpUpgradeProject(VisualStudioInstanceFactory instanceFactory, ITestOu
{
}
private
void
InvokeFix
()
private
void
InvokeFix
(
string
version
=
"latest"
)
{
VisualStudio
.
Editor
.
SetText
(
@"
#error version:
latest
VisualStudio
.
Editor
.
SetText
(
@
$
"
#error version:
{version}
");
VisualStudio
.
Editor
.
Activate
();
VisualStudio
.
Editor
.
PlaceCaret
(
"version:latest
"
);
VisualStudio
.
Editor
.
PlaceCaret
(
$"version:
{
version
}
"
);
VisualStudio
.
Editor
.
InvokeCodeActionList
();
VisualStudio
.
Editor
.
Verify
.
CodeAction
(
"Upgrade this project to C# language version 'latest
'"
,
applyFix
:
true
);
VisualStudio
.
Editor
.
Verify
.
CodeAction
(
$"Upgrade this project to C# language version '
{
version
}
'"
,
applyFix
:
true
);
}
[
WpfFact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/38301"
),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsUpgradeProject
)]
...
...
@@ -49,10 +49,43 @@ public void LegacyProject_AllConfigurationsUpdated()
var
project
=
new
ProjectUtils
.
Project
(
ProjectName
);
VisualStudio
.
SolutionExplorer
.
CreateSolution
(
SolutionName
);
VisualStudio
.
SolutionExplorer
.
AddProject
(
project
,
WellKnownProjectTemplates
.
ClassLibrary
,
LanguageNames
.
CSharp
);
VisualStudio
.
SolutionExplorer
.
AddCustomProject
(
project
,
".csproj"
,
$@"<?xml version=""1.0"" encoding=""utf-8""?>
<Project ToolsVersion=""15.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project=""$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"" Condition=""Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"" />
<PropertyGroup>
<Configuration Condition=""'$(Configuration)' == ''"">Debug</Configuration>
<Platform Condition=""'$(Platform)' == ''"">x64</Platform>
<ProjectGuid>
{{
F4233BA4
-
A4CB
-
498
B
-
BBC1
-
65
A42206B1BA
}}
</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>
{
ProjectName
}
</RootNamespace>
<AssemblyName>
{
ProjectName
}
</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<LangVersion>7.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=""'$(Configuration)|$(Platform)' == 'Debug|x86'"">
<OutputPath>bin\x86\Debug\</OutputPath>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=""'$(Configuration)|$(Platform)' == 'Release|x86'"">
<OutputPath>bin\x86\Release\</OutputPath>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=""'$(Configuration)|$(Platform)' == 'Debug|x64'"">
<OutputPath>bin\x64\Debug\</OutputPath>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=""'$(Configuration)|$(Platform)' == 'Release|x64'"">
<OutputPath>bin\x64\Release\</OutputPath>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<Import Project=""$(MSBuildToolsPath)\Microsoft.CSharp.targets"" />
</Project>"
);
VisualStudio
.
SolutionExplorer
.
AddFile
(
project
,
"C.cs"
,
open
:
true
);
InvokeFix
();
VerifyPropertyInEachConfiguration
(
GetProjectFileElement
(
project
),
"LangVersion"
,
"
latest
"
);
InvokeFix
(
version
:
"7.3"
);
VerifyPropertyInEachConfiguration
(
GetProjectFileElement
(
project
),
"LangVersion"
,
"
7.3
"
);
}
[
WorkItem
(
23342
,
"https://github.com/dotnet/roslyn/issues/23342"
)]
...
...
@@ -77,6 +110,7 @@ public void LegacyProject_MultiplePlatforms_AllConfigurationsUpdated()
<PropertyGroup Condition=""'$(Configuration)|$(Platform)' == 'Debug|x86'"">
<OutputPath>bin\x86\Debug\</OutputPath>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=""'$(Configuration)|$(Platform)' == 'Release|x86'"">
<OutputPath>bin\x86\Release\</OutputPath>
...
...
@@ -91,6 +125,7 @@ public void LegacyProject_MultiplePlatforms_AllConfigurationsUpdated()
<PropertyGroup Condition=""'$(Configuration)|$(Platform)' == 'Release|x64'"">
<OutputPath>bin\x64\Release\</OutputPath>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
...
...
@@ -99,8 +134,8 @@ public void LegacyProject_MultiplePlatforms_AllConfigurationsUpdated()
VisualStudio
.
SolutionExplorer
.
AddFile
(
project
,
"C.cs"
,
open
:
true
);
InvokeFix
();
VerifyPropertyInEachConfiguration
(
GetProjectFileElement
(
project
),
"LangVersion"
,
"
latest
"
);
InvokeFix
(
version
:
"7.3"
);
VerifyPropertyInEachConfiguration
(
GetProjectFileElement
(
project
),
"LangVersion"
,
"
7.3
"
);
}
}
}
src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/MockHierarchy.vb
浏览文件 @
287897f9
...
...
@@ -19,6 +19,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Fr
Private
_projectName
As
String
Private
_projectBinPath
As
String
Private
_maxSupportedLangVer
As
String
Private
ReadOnly
_projectRefPath
As
String
Private
ReadOnly
_projectCapabilities
As
String
Private
ReadOnly
_projectMock
As
Mock
(
Of
EnvDTE
.
Project
)
=
New
Mock
(
Of
EnvDTE
.
Project
)(
MockBehavior
.
Strict
)
...
...
@@ -330,6 +331,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Fr
ElseIf
pszPropName
=
"TargetRefPath"
Then
pbstrPropValue
=
_projectRefPath
Return
VSConstants
.
S_OK
ElseIf
pszPropName
=
"MaxSupportedLangVersion"
Then
pbstrPropValue
=
_maxSupportedLangVer
Return
VSConstants
.
S_OK
End
If
Throw
New
NotSupportedException
(
$
"{NameOf(MockHierarchy)}.{NameOf(GetPropertyValue)} does not support reading {pszPropName}."
)
...
...
@@ -342,6 +346,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Fr
ElseIf
pszPropName
=
"TargetFileName"
Then
_projectName
=
PathUtilities
.
GetFileName
(
pszPropValue
,
includeExtension
:
=
False
)
Return
VSConstants
.
S_OK
ElseIf
pszPropName
=
"MaxSupportedLangVersion"
Then
_maxSupportedLangVer
=
pszPropValue
Return
VSConstants
.
S_OK
End
If
Throw
New
NotImplementedException
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录