提交 401e6cf0 编写于 作者: J Jonathon Marolf

Merge remote-tracking branch 'upstream/master' into merge-master-into-post-dev15-20170126-100235

# Conflicts:
#	src/EditorFeatures/CSharpTest/CSharpEditorServicesTest.csproj
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. --> <!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project ToolsVersion="14.0" DefaultTargets="BuildAndTest" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" DefaultTargets="BuildAndTest" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)build\Targets\Dependencies.props" /> <Import Project="$(MSBuildThisFileDirectory)build\Targets\Versions.props" />
<!-- At the moment Jenkins runs on a machine without any build of Visual Studio 2015. Hence we must <!-- At the moment Jenkins runs on a machine without any build of Visual Studio 2015. Hence we must
use a 2013 compatible solution. --> use a 2013 compatible solution. -->
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
<IncludePattern Condition="'$(IncludePattern)' == '' AND '$(TestVsi)' != 'true'">*.UnitTests.dll</IncludePattern> <IncludePattern Condition="'$(IncludePattern)' == '' AND '$(TestVsi)' != 'true'">*.UnitTests.dll</IncludePattern>
<IncludePattern Condition="'$(IncludePattern)' == '' AND '$(TestVsi)' == 'true'">*.IntegrationTests.dll</IncludePattern> <IncludePattern Condition="'$(IncludePattern)' == '' AND '$(TestVsi)' == 'true'">*.IntegrationTests.dll</IncludePattern>
<OutputDirectory>Binaries\$(Configuration)</OutputDirectory> <OutputDirectory>Binaries\$(Configuration)</OutputDirectory>
<NuGetPackageRoot>$(UserProfile)\.nuget\packages</NuGetPackageRoot>
<CoreClrTestDirectory>$(OutputDirectory)\CoreClrTest</CoreClrTestDirectory> <CoreClrTestDirectory>$(OutputDirectory)\CoreClrTest</CoreClrTestDirectory>
<MSBuildCommonProperties> <MSBuildCommonProperties>
RestorePackages=false; RestorePackages=false;
......
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.26014.0 VisualStudioVersion = 15.0.26020.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysisTest", "src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysisTest", "src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}"
EndProject EndProject
...@@ -284,14 +284,14 @@ Global ...@@ -284,14 +284,14 @@ Global
{E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Debug|Any CPU.Build.0 = Debug|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|Any CPU.ActiveCfg = Release|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|Any CPU.Build.0 = Release|Any CPU {E58EE9D7-1239-4961-A0C1-F9EC3952C4C1}.Release|Any CPU.Build.0 = Release|Any CPU
{E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Debug|Any CPU.ActiveCfg = Debug|x64 {E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Debug|Any CPU.Build.0 = Debug|x64 {E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Release|Any CPU.ActiveCfg = Release|x64 {E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Release|Any CPU.Build.0 = Release|x64 {E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Release|Any CPU.Build.0 = Release|Any CPU
{8CE3A581-2969-4864-A803-013E9D977C3A}.Debug|Any CPU.ActiveCfg = Debug|x64 {8CE3A581-2969-4864-A803-013E9D977C3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CE3A581-2969-4864-A803-013E9D977C3A}.Debug|Any CPU.Build.0 = Debug|x64 {8CE3A581-2969-4864-A803-013E9D977C3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CE3A581-2969-4864-A803-013E9D977C3A}.Release|Any CPU.ActiveCfg = Release|x64 {8CE3A581-2969-4864-A803-013E9D977C3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CE3A581-2969-4864-A803-013E9D977C3A}.Release|Any CPU.Build.0 = Release|x64 {8CE3A581-2969-4864-A803-013E9D977C3A}.Release|Any CPU.Build.0 = Release|Any CPU
{1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
......
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.26109.2 VisualStudioVersion = 15.0.26020.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysisTest", "src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysisTest", "src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}"
EndProject EndProject
...@@ -804,14 +804,14 @@ Global ...@@ -804,14 +804,14 @@ Global
{CF450DCE-D12B-4A11-8D2D-A7A125372C48}.Debug|Any CPU.Build.0 = Debug|Any CPU {CF450DCE-D12B-4A11-8D2D-A7A125372C48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF450DCE-D12B-4A11-8D2D-A7A125372C48}.Release|Any CPU.ActiveCfg = Release|Any CPU {CF450DCE-D12B-4A11-8D2D-A7A125372C48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF450DCE-D12B-4A11-8D2D-A7A125372C48}.Release|Any CPU.Build.0 = Release|Any CPU {CF450DCE-D12B-4A11-8D2D-A7A125372C48}.Release|Any CPU.Build.0 = Release|Any CPU
{E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Debug|Any CPU.ActiveCfg = Debug|x64 {E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Debug|Any CPU.Build.0 = Debug|x64 {E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Release|Any CPU.ActiveCfg = Release|x64 {E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Release|Any CPU.Build.0 = Release|x64 {E3CD2895-76A8-4D11-A316-EA67CB5EA42C}.Release|Any CPU.Build.0 = Release|Any CPU
{8CE3A581-2969-4864-A803-013E9D977C3A}.Debug|Any CPU.ActiveCfg = Debug|x64 {8CE3A581-2969-4864-A803-013E9D977C3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CE3A581-2969-4864-A803-013E9D977C3A}.Debug|Any CPU.Build.0 = Debug|x64 {8CE3A581-2969-4864-A803-013E9D977C3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CE3A581-2969-4864-A803-013E9D977C3A}.Release|Any CPU.ActiveCfg = Release|x64 {8CE3A581-2969-4864-A803-013E9D977C3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CE3A581-2969-4864-A803-013E9D977C3A}.Release|Any CPU.Build.0 = Release|x64 {8CE3A581-2969-4864-A803-013E9D977C3A}.Release|Any CPU.Build.0 = Release|Any CPU
{CCBD3438-3E84-40A9-83AD-533F23BCFCA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CCBD3438-3E84-40A9-83AD-533F23BCFCA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCBD3438-3E84-40A9-83AD-533F23BCFCA5}.Debug|Any CPU.Build.0 = Debug|Any CPU {CCBD3438-3E84-40A9-83AD-533F23BCFCA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCBD3438-3E84-40A9-83AD-533F23BCFCA5}.Release|Any CPU.ActiveCfg = Release|Any CPU {CCBD3438-3E84-40A9-83AD-533F23BCFCA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
......
...@@ -9,6 +9,7 @@ REM Because override the C#/VB toolset to build against our LKG package, it is i ...@@ -9,6 +9,7 @@ REM Because override the C#/VB toolset to build against our LKG package, it is i
REM that we do not reuse MSBuild nodes from other jobs/builds on the machine. Otherwise, REM that we do not reuse MSBuild nodes from other jobs/builds on the machine. Otherwise,
REM we'll run into issues such as https://github.com/dotnet/roslyn/issues/6211. REM we'll run into issues such as https://github.com/dotnet/roslyn/issues/6211.
set MSBuildAdditionalCommandLineArgs=/nologo /m /nodeReuse:false /consoleloggerparameters:Verbosity=minimal /filelogger /fileloggerparameters:Verbosity=normal set MSBuildAdditionalCommandLineArgs=/nologo /m /nodeReuse:false /consoleloggerparameters:Verbosity=minimal /filelogger /fileloggerparameters:Verbosity=normal
set BuildAndTestBuildTarget=BuildAndTest
:ParseArguments :ParseArguments
if "%1" == "" goto :DoneParsing if "%1" == "" goto :DoneParsing
...@@ -22,6 +23,8 @@ if /I "%1" == "/testBuildCorrectness" set TestBuildCorrectness=true&&shift&& got ...@@ -22,6 +23,8 @@ if /I "%1" == "/testBuildCorrectness" set TestBuildCorrectness=true&&shift&& got
if /I "%1" == "/testPerfCorrectness" set TestPerfCorrectness=true&&shift&& goto :ParseArguments if /I "%1" == "/testPerfCorrectness" set TestPerfCorrectness=true&&shift&& goto :ParseArguments
if /I "%1" == "/testPerfRun" set TestPerfRun=true&&shift&& goto :ParseArguments if /I "%1" == "/testPerfRun" set TestPerfRun=true&&shift&& goto :ParseArguments
if /I "%1" == "/testVsi" set TestVsi=true&&shift&& goto :ParseArguments if /I "%1" == "/testVsi" set TestVsi=true&&shift&& goto :ParseArguments
if /I "%1" == "/skipTest" set BuildAndTestBuildTarget=Build&&shift&&goto :ParseArguments
if /I "%1" == "/skipCommitPrinting" set SkipCommitPrinting=1&&shift&&goto :ParseArguments
REM /buildTimeLimit is the time limit, measured in minutes, for the Jenkins job that runs REM /buildTimeLimit is the time limit, measured in minutes, for the Jenkins job that runs
REM the build. The Jenkins script netci.groovy passes the time limit to this script. REM the build. The Jenkins script netci.groovy passes the time limit to this script.
...@@ -61,8 +64,10 @@ if defined testBuildCorrectness ( ...@@ -61,8 +64,10 @@ if defined testBuildCorrectness (
) )
REM Output the commit that we're building, for reference in Jenkins logs REM Output the commit that we're building, for reference in Jenkins logs
echo Building this commit: if not "%SkipCommitPrinting" == "1" (
git show --no-patch --pretty=raw HEAD echo Building this commit:
git show --no-patch --pretty=raw HEAD
)
REM Build with the real assembly version, since that's what's contained in the bootstrap compiler redirects REM Build with the real assembly version, since that's what's contained in the bootstrap compiler redirects
msbuild %MSBuildAdditionalCommandLineArgs% /p:UseShippingAssemblyVersion=true /p:InitialDefineConstants=BOOTSTRAP "%RoslynRoot%build\Toolset\Toolset.csproj" /p:NuGetRestorePackages=false /p:Configuration=%BuildConfiguration% /fileloggerparameters:LogFile="%bindir%\Bootstrap.log" || goto :BuildFailed msbuild %MSBuildAdditionalCommandLineArgs% /p:UseShippingAssemblyVersion=true /p:InitialDefineConstants=BOOTSTRAP "%RoslynRoot%build\Toolset\Toolset.csproj" /p:NuGetRestorePackages=false /p:Configuration=%BuildConfiguration% /fileloggerparameters:LogFile="%bindir%\Bootstrap.log" || goto :BuildFailed
...@@ -115,7 +120,7 @@ if defined TestPerfRun ( ...@@ -115,7 +120,7 @@ if defined TestPerfRun (
exit /b 0 exit /b 0
) )
msbuild %MSBuildAdditionalCommandLineArgs% /p:BootstrapBuildPath="%bindir%\Bootstrap" BuildAndTest.proj /p:Configuration=%BuildConfiguration% /p:Test64=%Test64% /p:TestVsi=%TestVsi% /p:RunProcessWatchdog=%RunProcessWatchdog% /p:BuildStartTime=%BuildStartTime% /p:"ProcDumpExe=%ProcDumpExe%" /p:BuildTimeLimit=%BuildTimeLimit% /p:PathMap="%RoslynRoot%=q:\roslyn" /p:Feature=pdb-path-determinism /fileloggerparameters:LogFile="%bindir%\Build.log";verbosity=diagnostic /p:DeployExtension=false || goto :BuildFailed msbuild %MSBuildAdditionalCommandLineArgs% /p:BootstrapBuildPath="%bindir%\Bootstrap" BuildAndTest.proj /t:%BuildAndTestBuildTarget% /p:Configuration=%BuildConfiguration% /p:Test64=%Test64% /p:TestVsi=%TestVsi% /p:RunProcessWatchdog=%RunProcessWatchdog% /p:BuildStartTime=%BuildStartTime% /p:"ProcDumpExe=%ProcDumpExe%" /p:BuildTimeLimit=%BuildTimeLimit% /p:PathMap="%RoslynRoot%=q:\roslyn" /p:Feature=pdb-path-determinism /fileloggerparameters:LogFile="%bindir%\Build.log";verbosity=diagnostic /p:DeployExtension=false || goto :BuildFailed
powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\check-msbuild.ps1" "%bindir%\Build.log" || goto :BuildFailed powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\check-msbuild.ps1" "%bindir%\Build.log" || goto :BuildFailed
call :TerminateBuildProcesses || goto :BuildFailed call :TerminateBuildProcesses || goto :BuildFailed
...@@ -145,10 +150,16 @@ exit /b 1 ...@@ -145,10 +150,16 @@ exit /b 1
@REM An error-level of 1 means that the process was found, but could not be killed. @REM An error-level of 1 means that the process was found, but could not be killed.
echo Killing all build-related processes echo Killing all build-related processes
taskkill /F /IM msbuild.exe > nul taskkill /F /IM msbuild.exe > nul 2>&1
if %ERRORLEVEL% == 1 exit /b 1 if %ERRORLEVEL% == 1 (
echo ERROR: taskkill for msbuild.exe failed
exit /b 1
)
taskkill /F /IM vbcscompiler.exe > nul taskkill /F /IM vbcscompiler.exe > nul 2>&1
if %ERRORLEVEL% == 1 exit /b 1 if %ERRORLEVEL% == 1 (
echo ERROR: taskkill for vbcscompiler.exe failed
exit /b 1
)
exit /b 0 exit /b 0
...@@ -9,7 +9,7 @@ usage() ...@@ -9,7 +9,7 @@ usage()
echo "Options" echo "Options"
echo " --debug Build Debug (default)" echo " --debug Build Debug (default)"
echo " --release Build Release" echo " --release Build Release"
echo " --skiptests Do not run tests" echo " --skiptest Do not run tests"
echo " --skipcrossgen Do not crossgen the bootstrapped compiler" echo " --skipcrossgen Do not crossgen the bootstrapped compiler"
echo " --skipcommitprinting Do not print commit information" echo " --skipcommitprinting Do not print commit information"
echo " --nocache Force download of toolsets" echo " --nocache Force download of toolsets"
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\build\Targets\Settings.props" /> <Import Project="..\..\..\..\build\Targets\Settings.props" />
<PropertyGroup> <PropertyGroup>
<Platform Condition="'$(Platform)' == ''">x64</Platform> <Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<!-- Misspelling, bug in NuGet targets --> <!-- Misspelling, bug in NuGet targets -->
<RuntimeIndentifier>x64</RuntimeIndentifier> <RuntimeIndentifier>x64</RuntimeIndentifier>
<NuGetRuntimeIdentifier>$(BaseNuGetRuntimeIdentifier)-$(RuntimeIndentifier)</NuGetRuntimeIdentifier> <NuGetRuntimeIdentifier>$(BaseNuGetRuntimeIdentifier)-$(RuntimeIndentifier)</NuGetRuntimeIdentifier>
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
<Name>CSharpCodeAnalysis</Name> <Name>CSharpCodeAnalysis</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
<ItemGroup> <ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs"> <Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link> <Link>BuildClient.cs</Link>
......
...@@ -241,9 +241,13 @@ private ErrorCode CheckSubsumed(BoundPattern pattern, DecisionTree decisionTree, ...@@ -241,9 +241,13 @@ private ErrorCode CheckSubsumed(BoundPattern pattern, DecisionTree decisionTree,
{ {
var type = td.Key; var type = td.Key;
var decision = td.Value; var decision = td.Value;
// if the pattern's type is already handled by the previous pattern
// or the previous pattern handles all of the (non-null) input data...
if (ExpressionOfTypeMatchesPatternType( if (ExpressionOfTypeMatchesPatternType(
declarationPattern.DeclaredType.Type.TupleUnderlyingTypeOrSelf(), type, ref _useSiteDiagnostics) == true) declarationPattern.DeclaredType.Type.TupleUnderlyingTypeOrSelf(), type, ref _useSiteDiagnostics) == true ||
ExpressionOfTypeMatchesPatternType(byType.Type, type, ref _useSiteDiagnostics) == true)
{ {
// then we check if the pattern is subsumed by the previous decision
var error = CheckSubsumed(pattern, decision, inputCouldBeNull); var error = CheckSubsumed(pattern, decision, inputCouldBeNull);
if (error != 0) if (error != 0)
{ {
......
...@@ -223,6 +223,13 @@ private void BuildSwitchLabels(SyntaxList<SwitchLabelSyntax> labelsSyntax, Binde ...@@ -223,6 +223,13 @@ private void BuildSwitchLabels(SyntaxList<SwitchLabelSyntax> labelsSyntax, Binde
boundLabelExpression = ConvertCaseExpression(labelSyntax, boundLabelExpression, sectionBinder, ref boundLabelConstantOpt, tempDiagnosticBag); boundLabelExpression = ConvertCaseExpression(labelSyntax, boundLabelExpression, sectionBinder, ref boundLabelConstantOpt, tempDiagnosticBag);
break; break;
case SyntaxKind.CasePatternSwitchLabel:
// bind the pattern, to cause its pattern variables to be inferred if necessary
var matchLabel = (CasePatternSwitchLabelSyntax)labelSyntax;
var pattern = sectionBinder.BindPattern(
matchLabel.Pattern, SwitchGoverningExpression, SwitchGoverningType, labelSyntax.HasErrors, tempDiagnosticBag, wasSwitchCase: true);
break;
default: default:
// No constant value // No constant value
break; break;
......
...@@ -53,7 +53,7 @@ public static DecisionTree Create(BoundExpression expression, TypeSymbol type, S ...@@ -53,7 +53,7 @@ public static DecisionTree Create(BoundExpression expression, TypeSymbol type, S
expression = new BoundLocal(expression.Syntax, temp, null, type); expression = new BoundLocal(expression.Syntax, temp, null, type);
} }
if (expression.Type.CanBeAssignedNull()) if (expression.Type.CanContainNull())
{ {
// We need the ByType decision tree to separate null from non-null values. // We need the ByType decision tree to separate null from non-null values.
// Note that, for the purpose of the decision tree (and subsumption), we // Note that, for the purpose of the decision tree (and subsumption), we
......
...@@ -286,15 +286,16 @@ private void LowerDecisionTree(DecisionTree.ByType byType) ...@@ -286,15 +286,16 @@ private void LowerDecisionTree(DecisionTree.ByType byType)
var defaultLabel = _factory.GenerateLabel("byTypeDefault"); var defaultLabel = _factory.GenerateLabel("byTypeDefault");
// input is not a constant // input is not a constant
if (byType.Type.CanBeAssignedNull()) if (byType.Type.CanContainNull())
{ {
// first test for null // first test for null
var notNullLabel = _factory.GenerateLabel("notNull"); var notNullLabel = _factory.GenerateLabel("notNull");
var inputExpression = byType.Expression; var inputExpression = byType.Expression;
var nullValue = _factory.Null(byType.Type); var objectType = _factory.SpecialType(SpecialType.System_Object);
var nullValue = _factory.Null(objectType);
BoundExpression notNull = byType.Type.IsNullableType() BoundExpression notNull = byType.Type.IsNullableType()
? _localRewriter.RewriteNullableNullEquality(_factory.Syntax, BinaryOperatorKind.NullableNullNotEqual, byType.Expression, nullValue, _factory.SpecialType(SpecialType.System_Boolean)) ? _localRewriter.RewriteNullableNullEquality(_factory.Syntax, BinaryOperatorKind.NullableNullNotEqual, byType.Expression, nullValue, _factory.SpecialType(SpecialType.System_Boolean))
: _factory.ObjectNotEqual(byType.Expression, nullValue); : _factory.ObjectNotEqual(nullValue, _factory.Convert(objectType, byType.Expression));
_loweredDecisionTree.Add(_factory.ConditionalGoto(notNull, notNullLabel, true)); _loweredDecisionTree.Add(_factory.ConditionalGoto(notNull, notNullLabel, true));
LowerDecisionTree(byType.Expression, byType.WhenNull); LowerDecisionTree(byType.Expression, byType.WhenNull);
if (byType.WhenNull?.MatchIsComplete != true) if (byType.WhenNull?.MatchIsComplete != true)
......
...@@ -119,6 +119,15 @@ internal void GetDeclarationDiagnostics(DiagnosticBag addTo) ...@@ -119,6 +119,15 @@ internal void GetDeclarationDiagnostics(DiagnosticBag addTo)
// force lazy init // force lazy init
ComputeParameters(); ComputeParameters();
foreach (var p in _syntax.ParameterList.Parameters)
{
if (p.IsArgList)
{
addTo.Add(ErrorCode.ERR_IllegalVarArgs, p.Location);
}
}
ComputeReturnType(); ComputeReturnType();
var diags = ImmutableInterlocked.InterlockedExchange(ref _diagnostics, default(ImmutableArray<Diagnostic>)); var diags = ImmutableInterlocked.InterlockedExchange(ref _diagnostics, default(ImmutableArray<Diagnostic>));
......
...@@ -27,6 +27,12 @@ public static bool CanBeAssignedNull(this TypeSymbol type) ...@@ -27,6 +27,12 @@ public static bool CanBeAssignedNull(this TypeSymbol type)
return type.IsReferenceType || type.IsPointerType() || type.IsNullableType(); return type.IsReferenceType || type.IsPointerType() || type.IsNullableType();
} }
public static bool CanContainNull(this TypeSymbol type)
{
// unbound type parameters might contain null, even though they cannot be *assigned* null.
return !type.IsValueType || type.IsNullableType();
}
public static bool CanBeConst(this TypeSymbol typeSymbol) public static bool CanBeConst(this TypeSymbol typeSymbol)
{ {
Debug.Assert((object)typeSymbol != null); Debug.Assert((object)typeSymbol != null);
......
...@@ -1615,18 +1615,24 @@ static void Main() ...@@ -1615,18 +1615,24 @@ static void Main()
} }
"; ";
VerifyDiagnostics(source, VerifyDiagnostics(source,
// (10,31): error CS0190: The __arglist construct is valid only within a variable argument method // (10,31): error CS0190: The __arglist construct is valid only within a variable argument method
// Console.WriteLine(__arglist); // Console.WriteLine(__arglist);
Diagnostic(ErrorCode.ERR_ArgsInvalid, "__arglist").WithLocation(10, 31), Diagnostic(ErrorCode.ERR_ArgsInvalid, "__arglist").WithLocation(10, 31),
// (18,31): error CS4013: Instance of type 'RuntimeArgumentHandle' cannot be used inside an anonymous function, query expression, iterator block or async method // (18,31): error CS4013: Instance of type 'RuntimeArgumentHandle' cannot be used inside an anonymous function, query expression, iterator block or async method
// Console.WriteLine(__arglist); // Console.WriteLine(__arglist);
Diagnostic(ErrorCode.ERR_SpecialByRefInLambda, "__arglist").WithArguments("System.RuntimeArgumentHandle").WithLocation(18, 31), Diagnostic(ErrorCode.ERR_SpecialByRefInLambda, "__arglist").WithArguments("System.RuntimeArgumentHandle").WithLocation(18, 31),
// (26,31): error CS0190: The __arglist construct is valid only within a variable argument method // (24,20): error CS1669: __arglist is not valid in this context
// Console.WriteLine(__arglist); // void Local(__arglist)
Diagnostic(ErrorCode.ERR_ArgsInvalid, "__arglist").WithLocation(26, 31), Diagnostic(ErrorCode.ERR_IllegalVarArgs, "__arglist").WithLocation(24, 20),
// (34,31): error CS4013: Instance of type 'RuntimeArgumentHandle' cannot be used inside an anonymous function, query expression, iterator block or async method // (26,31): error CS0190: The __arglist construct is valid only within a variable argument method
// Console.WriteLine(__arglist); // Console.WriteLine(__arglist);
Diagnostic(ErrorCode.ERR_SpecialByRefInLambda, "__arglist").WithArguments("System.RuntimeArgumentHandle").WithLocation(34, 31) Diagnostic(ErrorCode.ERR_ArgsInvalid, "__arglist").WithLocation(26, 31),
// (32,20): error CS1669: __arglist is not valid in this context
// void Local(__arglist)
Diagnostic(ErrorCode.ERR_IllegalVarArgs, "__arglist").WithLocation(32, 20),
// (34,31): error CS4013: Instance of type 'RuntimeArgumentHandle' cannot be used inside an anonymous function, query expression, iterator block or async method
// Console.WriteLine(__arglist);
Diagnostic(ErrorCode.ERR_SpecialByRefInLambda, "__arglist").WithArguments("System.RuntimeArgumentHandle").WithLocation(34, 31)
); );
} }
...@@ -1800,10 +1806,12 @@ IEnumerable<int> Local(__arglist) ...@@ -1800,10 +1806,12 @@ IEnumerable<int> Local(__arglist)
} }
"; ";
VerifyDiagnostics(source, VerifyDiagnostics(source,
// (9,26): error CS1636: __arglist is not allowed in the parameter list of iterators // (9,26): error CS1636: __arglist is not allowed in the parameter list of iterators
// IEnumerable<int> Local(__arglist) // IEnumerable<int> Local(__arglist)
Diagnostic(ErrorCode.ERR_VarargsIterator, "Local").WithLocation(9, 26) Diagnostic(ErrorCode.ERR_VarargsIterator, "Local").WithLocation(9, 26),
); // (9,32): error CS1669: __arglist is not valid in this context
// IEnumerable<int> Local(__arglist)
Diagnostic(ErrorCode.ERR_IllegalVarArgs, "__arglist").WithLocation(9, 32));
} }
[Fact] [Fact]
......
...@@ -4618,7 +4618,49 @@ public static void Main(string[] args) ...@@ -4618,7 +4618,49 @@ public static void Main(string[] args)
); );
} }
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/16559")] [Fact, WorkItem(16559, "https://github.com/dotnet/roslyn/issues/16559")]
public void CasePatternVariableUsedInCaseExpression()
{
var program = @"
public class Program5815
{
public static void Main(object o)
{
switch (o)
{
case Color Color:
case Color? Color2:
break;
}
}
private static object M() => null;
}";
var compilation = CreateCompilationWithMscorlib45(program).VerifyDiagnostics(
// (9,32): error CS1525: Invalid expression term 'break'
// case Color? Color2:
Diagnostic(ErrorCode.ERR_InvalidExprTerm, "").WithArguments("break").WithLocation(9, 32),
// (9,32): error CS1003: Syntax error, ':' expected
// case Color? Color2:
Diagnostic(ErrorCode.ERR_SyntaxError, "").WithArguments(":", "break").WithLocation(9, 32),
// (8,18): error CS0118: 'Color' is a variable but is used like a type
// case Color Color:
Diagnostic(ErrorCode.ERR_BadSKknown, "Color").WithArguments("Color", "variable", "type").WithLocation(8, 18),
// (9,25): error CS0103: The name 'Color2' does not exist in the current context
// case Color? Color2:
Diagnostic(ErrorCode.ERR_NameNotInContext, "Color2").WithArguments("Color2").WithLocation(9, 25)
);
var tree = compilation.SyntaxTrees.Single();
var model = compilation.GetSemanticModel(tree);
var colorDecl = GetPatternDeclarations(tree, "Color").ToArray();
var colorRef = GetReferences(tree, "Color").ToArray();
Assert.Equal(1, colorDecl.Length);
Assert.Equal(2, colorRef.Length);
Assert.Null(model.GetSymbolInfo(colorRef[0]).Symbol);
VerifyModelForDeclarationPattern(model, colorDecl[0], colorRef[1]);
}
[Fact, WorkItem(16559, "https://github.com/dotnet/roslyn/issues/16559")]
public void Fuzz5815() public void Fuzz5815()
{ {
var program = @" var program = @"
...@@ -4635,21 +4677,33 @@ public static void Main(string[] args) ...@@ -4635,21 +4677,33 @@ public static void Main(string[] args)
} }
private static object M() => null; private static object M() => null;
}"; }";
CreateCompilationWithMscorlib45(program).VerifyDiagnostics( var compilation = CreateCompilationWithMscorlib45(program).VerifyDiagnostics(
// (9,18): error CS0150: A constant value is expected
// case true ? x3 : 4:
Diagnostic(ErrorCode.ERR_ConstantExpected, "true ? x3 : 4").WithLocation(9, 18)
); );
var tree = compilation.SyntaxTrees.Single();
var model = compilation.GetSemanticModel(tree);
var x3Decl = GetPatternDeclarations(tree, "x3").ToArray();
var x3Ref = GetReferences(tree, "x3").ToArray();
Assert.Equal(1, x3Decl.Length);
Assert.Equal(1, x3Ref.Length);
VerifyModelForDeclarationPattern(model, x3Decl[0], x3Ref);
} }
[Fact(Skip = "This test generator is capable of producing crashes that are not yet fixed; see, for example, Fuzz5815")] [Fact(Skip = "https://github.com/dotnet/roslyn/issues/16721")]
public void Fuzz() public void Fuzz()
{ {
int dt = Math.Abs(new DateTime().Ticks.GetHashCode() % 10000000); const int numTests = 1000000;
for (int i = 1; i < 100000; i++) int dt = (int)Math.Abs(DateTime.Now.Ticks % 1000000000);
for (int i = 1; i < numTests; i++)
{ {
PatternMatchingFuzz(i + dt); PatternMatchingFuzz(i + dt);
} }
} }
public void PatternMatchingFuzz(int dt) private static void PatternMatchingFuzz(int dt)
{ {
Random r = new Random(dt); Random r = new Random(dt);
...@@ -4735,5 +4789,187 @@ public static void Main(string[] args) ...@@ -4735,5 +4789,187 @@ public static void Main(string[] args)
var program = string.Format(body, dt, statement); var program = string.Format(body, dt, statement);
CreateCompilationWithMscorlib45(program).GetDiagnostics(); CreateCompilationWithMscorlib45(program).GetDiagnostics();
} }
[Fact, WorkItem(16671, "https://github.com/dotnet/roslyn/issues/16671")]
public void TypeParameterSubsumption01()
{
var program = @"
using System;
public class Program
{
public static void Main(string[] args)
{
PatternMatching<Base, Derived>(new Base());
PatternMatching<Base, Derived>(new Derived());
PatternMatching<Base, Derived>(null);
PatternMatching<object, int>(new object());
PatternMatching<object, int>(2);
PatternMatching<object, int>(null);
PatternMatching<object, int?>(new object());
PatternMatching<object, int?>(2);
PatternMatching<object, int?>(null);
}
static void PatternMatching<TBase, TDerived>(TBase o) where TDerived : TBase
{
switch (o)
{
case TDerived td:
Console.WriteLine(nameof(TDerived));
break;
case TBase tb:
Console.WriteLine(nameof(TBase));
break;
default:
Console.WriteLine(""Neither"");
break;
}
}
}
class Base
{
}
class Derived : Base
{
}
";
var compilation = CreateCompilationWithMscorlib45(program, options: TestOptions.DebugExe).VerifyDiagnostics(
);
var comp = CompileAndVerify(compilation, expectedOutput: @"TBase
TDerived
Neither
TBase
TDerived
Neither
TBase
TDerived
Neither");
}
[Fact, WorkItem(16671, "https://github.com/dotnet/roslyn/issues/16671")]
public void TypeParameterSubsumption02()
{
var program = @"
using System;
public class Program
{
static void PatternMatching<TBase, TDerived>(TBase o) where TDerived : TBase
{
switch (o)
{
case TBase tb:
Console.WriteLine(nameof(TBase));
break;
case TDerived td:
Console.WriteLine(nameof(TDerived));
break;
default:
Console.WriteLine(""Neither"");
break;
}
}
}
class Base
{
}
class Derived : Base
{
}
";
var compilation = CreateCompilationWithMscorlib45(program).VerifyDiagnostics(
// (12,18): error CS8120: The switch case has already been handled by a previous case.
// case TDerived td:
Diagnostic(ErrorCode.ERR_PatternIsSubsumed, "TDerived td").WithLocation(12, 18),
// (13,17): warning CS0162: Unreachable code detected
// Console.WriteLine(nameof(TDerived));
Diagnostic(ErrorCode.WRN_UnreachableCode, "Console").WithLocation(13, 17)
);
}
[Fact, WorkItem(16688, "https://github.com/dotnet/roslyn/issues/16688")]
public void TypeParameterSubsumption03()
{
var program = @"
using System.Collections.Generic;
public class Program
{
private static void Pattern<T>(T thing) where T : class
{
switch (thing)
{
case T tThing:
break;
case IEnumerable<object> s:
break;
}
}
}
";
var compilation = CreateCompilationWithMscorlib45(program).VerifyDiagnostics(
// (11,18): error CS8120: The switch case has already been handled by a previous case.
// case IEnumerable<object> s:
Diagnostic(ErrorCode.ERR_PatternIsSubsumed, "IEnumerable<object> s").WithLocation(11, 18),
// (12,17): warning CS0162: Unreachable code detected
// break;
Diagnostic(ErrorCode.WRN_UnreachableCode, "break").WithLocation(12, 17)
);
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/16696")]
public void TypeParameterSubsumption04()
{
var program = @"
using System.Collections.Generic;
public class Program
{
private static void Pattern<TBase, TDerived>(object thing) where TBase : class where TDerived : TBase
{
switch (thing)
{
case IEnumerable<TBase> sequence:
break;
case IEnumerable<TDerived> derivedSequence:
break;
}
}
}
";
var compilation = CreateCompilationWithMscorlib45(program).VerifyDiagnostics(
// (11,18): error CS8120: The switch case has already been handled by a previous case.
// case IEnumerable<TDerived> derivedSequence:
Diagnostic(ErrorCode.ERR_PatternIsSubsumed, "IEnumerable<TDerived> derivedSequence").WithLocation(11, 18),
// (12,17): warning CS0162: Unreachable code detected
// break;
Diagnostic(ErrorCode.WRN_UnreachableCode, "break").WithLocation(12, 17)
);
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/16696")]
public void TypeParameterSubsumption05()
{
var program = @"
using System.Collections.Generic;
public class Program
{
private static void Pattern<TBase, TDerived>(object thing) where TBase : class where TDerived : TBase
{
switch (thing)
{
case IEnumerable<object> s:
break;
case IEnumerable<TDerived> derivedSequence:
break;
}
}
}
";
var compilation = CreateCompilationWithMscorlib45(program).VerifyDiagnostics(
// (11,18): error CS8120: The switch case has already been handled by a previous case.
// case IEnumerable<TDerived> derivedSequence:
Diagnostic(ErrorCode.ERR_PatternIsSubsumed, "IEnumerable<TDerived> derivedSequence").WithLocation(11, 18),
// (12,17): warning CS0162: Unreachable code detected
// break;
Diagnostic(ErrorCode.WRN_UnreachableCode, "break").WithLocation(12, 17)
);
}
} }
} }
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\..\build\Targets\Settings.props" /> <Import Project="..\..\..\..\build\Targets\Settings.props" />
<PropertyGroup> <PropertyGroup>
<Platform Condition="'$(Platform)' == ''">x64</Platform> <Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<!-- Misspelling, bug in NuGet targets --> <!-- Misspelling, bug in NuGet targets -->
<RuntimeIndentifier>x64</RuntimeIndentifier> <RuntimeIndentifier>x64</RuntimeIndentifier>
<NuGetRuntimeIdentifier>$(BaseNuGetRuntimeIdentifier)-$(RuntimeIndentifier)</NuGetRuntimeIdentifier> <NuGetRuntimeIdentifier>$(BaseNuGetRuntimeIdentifier)-$(RuntimeIndentifier)</NuGetRuntimeIdentifier>
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
<Name>BasicCodeAnalysis</Name> <Name>BasicCodeAnalysis</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
<ItemGroup> <ItemGroup>
<Compile Include="..\..\Shared\BuildClient.cs"> <Compile Include="..\..\Shared\BuildClient.cs">
<Link>BuildClient.cs</Link> <Link>BuildClient.cs</Link>
......
...@@ -196,6 +196,7 @@ ...@@ -196,6 +196,7 @@
<Compile Include="Classification\TotalClassifierTests_Dynamic.cs" /> <Compile Include="Classification\TotalClassifierTests_Dynamic.cs" />
<Compile Include="CodeActions\AbstractCSharpCodeActionTest.cs" /> <Compile Include="CodeActions\AbstractCSharpCodeActionTest.cs" />
<Compile Include="CodeActions\UseNamedArguments\UseNamedArgumentsTests.cs" /> <Compile Include="CodeActions\UseNamedArguments\UseNamedArgumentsTests.cs" />
<Compile Include="Completion\CompletionProviders\OverrideCompletionProviderTests_ExpressionBody.cs" />
<Compile Include="ConvertToInterpolatedString\ConvertConcatenationToInterpolatedStringTests.cs" /> <Compile Include="ConvertToInterpolatedString\ConvertConcatenationToInterpolatedStringTests.cs" />
<Compile Include="ConvertToInterpolatedString\ConvertPlaceholderToInterpolatedStringTests.cs" /> <Compile Include="ConvertToInterpolatedString\ConvertPlaceholderToInterpolatedStringTests.cs" />
<Compile Include="CodeActions\EncapsulateField\EncapsulateFieldTests.cs" /> <Compile Include="CodeActions\EncapsulateField\EncapsulateFieldTests.cs" />
......
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Completion.Providers;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders
{
// OverrideCompletionProviderTests overrides SetWorkspaceOptions to disable
// expression-body members. This class does the opposite.
public class OverrideCompletionProviderTests_ExpressionBody : AbstractCSharpCompletionProviderTests
{
public OverrideCompletionProviderTests_ExpressionBody(CSharpTestWorkspaceFixture workspaceFixture) : base(workspaceFixture)
{
}
internal override CompletionProvider CreateCompletionProvider()
{
return new OverrideCompletionProvider();
}
protected override void SetWorkspaceOptions(TestWorkspace workspace)
{
workspace.Options = workspace.Options.WithChangedOption(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CodeStyleOptions.TrueWithSuggestionEnforcement)
.WithChangedOption(CSharpCodeStyleOptions.PreferExpressionBodiedProperties, CodeStyleOptions.TrueWithSuggestionEnforcement)
.WithChangedOption(CSharpCodeStyleOptions.PreferExpressionBodiedMethods, CodeStyleOptions.TrueWithSuggestionEnforcement);
}
[WorkItem(16331, "https://github.com/dotnet/roslyn/issues/16334")]
[WpfFact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CommitProducesExpressionBodyProperties()
{
var markupBeforeCommit = @"class B
{
public virtual int A { get; set; }
class C : B
{
override A$$
}
}";
var expectedCodeAfterCommit = @"class B
{
public virtual int A { get; set; }
class C : B
{
public override int A { get => base.A$$; set => base.A = value; }
}
}";
await VerifyCustomCommitProviderAsync(markupBeforeCommit, "A", expectedCodeAfterCommit);
}
[WorkItem(16331, "https://github.com/dotnet/roslyn/issues/16334")]
[WpfFact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CommitProducesExpressionBodyGetterOnlyProperty()
{
var markupBeforeCommit = @"class B
{
public virtual int A { get; }
class C : B
{
override A$$
}
}";
var expectedCodeAfterCommit = @"class B
{
public virtual int A { get; }
class C : B
{
public override int A => base.A;$$
}
}";
await VerifyCustomCommitProviderAsync(markupBeforeCommit, "A", expectedCodeAfterCommit);
}
[WorkItem(16331, "https://github.com/dotnet/roslyn/issues/16334")]
[WpfFact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CommitProducesExpressionBodyMethod()
{
var markupBeforeCommit = @"class B
{
public virtual int A() => 2;
class C : B
{
override A$$
}
}";
var expectedCodeAfterCommit = @"class B
{
public virtual int A() => 2;
class C : B
{
public override int A() => base.A();$$
}
}";
await VerifyCustomCommitProviderAsync(markupBeforeCommit, "A()", expectedCodeAfterCommit);
}
}
}
\ No newline at end of file
...@@ -179,6 +179,13 @@ private async Task<TriggerIdentifierKind> DetermineIfRenamableIdentifierAsync(Sn ...@@ -179,6 +179,13 @@ private async Task<TriggerIdentifierKind> DetermineIfRenamableIdentifierAsync(Sn
} }
else else
{ {
// We do not yet support renaming (inline rename or rename tracking) on
// named tuple elements.
if (renameSymbolInfo.Symbols.Single().ContainingType?.IsTupleType() == true)
{
return TriggerIdentifierKind.NotRenamable;
}
return await DetermineIfRenamableSymbolAsync(renameSymbolInfo.Symbols.Single(), document, token).ConfigureAwait(false); return await DetermineIfRenamableSymbolAsync(renameSymbolInfo.Symbols.Single(), document, token).ConfigureAwait(false);
} }
} }
......
...@@ -1284,15 +1284,16 @@ End Class ...@@ -1284,15 +1284,16 @@ End Class
[WpfFact] [WpfFact]
[Trait(Traits.Feature, Traits.Features.RenameTracking)] [Trait(Traits.Feature, Traits.Features.RenameTracking)]
public async Task RenameExplicitTupleField() [WorkItem(371205, "https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=371205")]
public async Task RenameTrackingNotOnExplicitTupleReturnDeclaration_CSharp()
{ {
var code = @" var code = @"
class C class C
{ {
void M() void M()
{ {
(int Item1, int) x = (1, 2); (int abc$$, int) x = (1, 2);
var y = x.Item1$$; var y = x.abc;
} }
}"; }";
using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.CSharp)) using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.CSharp))
...@@ -1300,32 +1301,20 @@ void M() ...@@ -1300,32 +1301,20 @@ void M()
state.EditorOperations.Backspace(); state.EditorOperations.Backspace();
state.EditorOperations.Backspace(); state.EditorOperations.Backspace();
await state.AssertTag("Item1", "Ite", invokeAction: true);
// Make sure the rename completed
var expectedCode = @"
class C
{
void M()
{
(int Ite, int) x = (1, 2);
var y = x.Ite;
}
}";
Assert.Equal(expectedCode, state.HostDocument.TextBuffer.CurrentSnapshot.GetText());
await state.AssertNoTag(); await state.AssertNoTag();
} }
} }
[WpfFact] [WpfFact]
[Trait(Traits.Feature, Traits.Features.RenameTracking)] [Trait(Traits.Feature, Traits.Features.RenameTracking)]
public async Task RenameExplicitTupleFieldVB() [WorkItem(371205, "https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=371205")]
public async Task RenameTrackingNotOnExplicitTupleReturnDeclaration_VB()
{ {
var code = @" var code = @"
class C class C
Sub M() Sub M()
Dim x as (Item1 as integer, int Item2 as integer) = (1, 2) Dim x as (abc$$ as integer, int Item2 as integer) = (1, 2)
Dim y = x.Item1$$ Dim y = x.abc
End Sub End Sub
End Class"; End Class";
using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.VisualBasic)) using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.VisualBasic))
...@@ -1333,148 +1322,88 @@ End Sub ...@@ -1333,148 +1322,88 @@ End Sub
state.EditorOperations.Backspace(); state.EditorOperations.Backspace();
state.EditorOperations.Backspace(); state.EditorOperations.Backspace();
await state.AssertTag("Item1", "Ite", invokeAction: true);
// Make sure the rename completed
var expectedCode = @"
class C
Sub M()
Dim x as (Ite as integer, int Item2 as integer) = (1, 2)
Dim y = x.Ite
End Sub
End Class";
Assert.Equal(expectedCode, state.HostDocument.TextBuffer.CurrentSnapshot.GetText());
await state.AssertNoTag(); await state.AssertNoTag();
} }
} }
[WpfFact] [WpfFact]
[Trait(Traits.Feature, Traits.Features.RenameTracking)] [Trait(Traits.Feature, Traits.Features.RenameTracking)]
public async Task RenameExplicitTupleField01() [WorkItem(371205, "https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=371205")]
public async Task RenameTrackingNotOnExplicitTupleFieldReference_CSharp()
{ {
var code = @" var code = @"
class C class C
{ {
void M() void M()
{ {
(int Ite, int) x = (1, 2); (int abc, int) x = (1, 2);
var y = x.Ite$$; var y = x.abc$$;
} }
}"; }";
using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.CSharp)) using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.CSharp))
{ {
state.EditorOperations.InsertText("m1"); state.EditorOperations.Backspace();
state.EditorOperations.Backspace();
await state.AssertTag("Ite", "Item1", invokeAction: true);
// Make sure the rename completed
var expectedCode = @"
class C
{
void M()
{
(int Item1, int) x = (1, 2);
var y = x.Item1;
}
}";
Assert.Equal(expectedCode, state.HostDocument.TextBuffer.CurrentSnapshot.GetText());
await state.AssertNoTag(); await state.AssertNoTag();
} }
} }
[WpfFact] [WpfFact]
[Trait(Traits.Feature, Traits.Features.RenameTracking)] [Trait(Traits.Feature, Traits.Features.RenameTracking)]
public async Task RenameExplicitTupleField01VB() [WorkItem(371205, "https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=371205")]
public async Task RenameTrackingNotOnExplicitTupleFieldReference_VB()
{ {
var code = @" var code = @"
class C class C
Sub M() Sub M()
Dim x as (Ite as Integer, Item2 as Integer) = (1, 2) Dim x as (abc as integer, int Item2 as integer) = (1, 2)
var y = x.Ite$$ Dim y = x.abc$$
End Sub End Sub
End Class"; End Class";
using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.VisualBasic)) using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.VisualBasic))
{ {
state.EditorOperations.InsertText("m1"); state.EditorOperations.Backspace();
state.EditorOperations.Backspace();
await state.AssertTag("Ite", "Item1", invokeAction: true);
// Make sure the rename completed
var expectedCode = @"
class C
Sub M()
Dim x as (Item1 as Integer, Item2 as Integer) = (1, 2)
var y = x.Item1
End Sub
End Class";
Assert.Equal(expectedCode, state.HostDocument.TextBuffer.CurrentSnapshot.GetText());
await state.AssertNoTag(); await state.AssertNoTag();
} }
} }
[WpfFact] [WpfFact]
[Trait(Traits.Feature, Traits.Features.RenameTracking)] [Trait(Traits.Feature, Traits.Features.RenameTracking)]
public async Task RenameExplicitTupleFieldExtended() [WorkItem(371205, "https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=371205")]
public async Task RenameTrackingNotOnExplicitTupleElementsInDeclarations_CSharp()
{ {
var code = @" var code = @"
class C class C
{ {
void M() void M()
{ {
(int, int, int, int, int, int, int, int, int Item9, int) x = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); var t = (x$$: 1, y: 2);
var y = x.Item9$$;
} }
}"; }";
using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.CSharp)) using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.CSharp))
{ {
state.EditorOperations.Backspace(); state.EditorOperations.InsertText("2");
state.EditorOperations.Backspace();
await state.AssertTag("Item9", "Ite", invokeAction: true);
// Make sure the rename completed
var expectedCode = @"
class C
{
void M()
{
(int, int, int, int, int, int, int, int, int Ite, int) x = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
var y = x.Ite;
}
}";
Assert.Equal(expectedCode, state.HostDocument.TextBuffer.CurrentSnapshot.GetText());
await state.AssertNoTag(); await state.AssertNoTag();
} }
} }
[WpfFact] [WpfFact]
[Trait(Traits.Feature, Traits.Features.RenameTracking)] [Trait(Traits.Feature, Traits.Features.RenameTracking)]
public async Task RenameExplicitTupleFieldExtendedVB() [WorkItem(371205, "https://devdiv.visualstudio.com/DevDiv/_workitems?_a=edit&id=371205")]
public async Task RenameTrackingNotOnExplicitTupleElementsInDeclarations_VB()
{ {
var code = @" var code = @"
class C Class C
Sub M() Sub M()
Dim x as (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Item9 As Integer, Integer) = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); Dim t = (x$$:=1, y:=2)
var y = x.Item9$$;
End Sub End Sub
End Class"; End Class";
using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.VisualBasic)) using (var state = await RenameTrackingTestState.CreateAsync(code, LanguageNames.VisualBasic))
{ {
state.EditorOperations.Backspace(); state.EditorOperations.InsertText("2");
state.EditorOperations.Backspace();
await state.AssertTag("Item9", "Ite", invokeAction: true);
// Make sure the rename completed
var expectedCode = @"
class C
Sub M()
Dim x as (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Ite As Integer, Integer) = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
var y = x.Ite;
End Sub
End Class";
Assert.Equal(expectedCode, state.HostDocument.TextBuffer.CurrentSnapshot.GetText());
await state.AssertNoTag(); await state.AssertNoTag();
} }
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
"Newtonsoft.Json": "8.0.3", "Newtonsoft.Json": "8.0.3",
"Nerdbank.FullDuplexStream": "1.0.1", "Nerdbank.FullDuplexStream": "1.0.1",
"BasicUndo": "0.9.3", "BasicUndo": "0.9.3",
"Microsoft.ServiceHub.Client": "1.0.177-rc-g56d40a8a02",
"Microsoft.VisualStudio.Platform.VSEditor": "15.0.26014-alpha", "Microsoft.VisualStudio.Platform.VSEditor": "15.0.26014-alpha",
"Microsoft.VisualStudio.Platform.VSEditor.Interop": "15.0.26014-alpha", "Microsoft.VisualStudio.Platform.VSEditor.Interop": "15.0.26014-alpha",
"Microsoft.VisualStudio.Composition": "15.0.66-rc", "Microsoft.VisualStudio.Composition": "15.0.66-rc",
...@@ -16,7 +17,7 @@ ...@@ -16,7 +17,7 @@
"Microsoft.VisualStudio.Language.CallHierarchy": "15.0.26014-alpha", "Microsoft.VisualStudio.Language.CallHierarchy": "15.0.26014-alpha",
"Microsoft.VisualStudio.Language.NavigateTo.Interfaces": "15.0.26014-alpha", "Microsoft.VisualStudio.Language.NavigateTo.Interfaces": "15.0.26014-alpha",
"Microsoft.VisualStudio.Text.UI": "15.0.26014-alpha", "Microsoft.VisualStudio.Text.UI": "15.0.26014-alpha",
"Microsoft.VisualStudio.Text.UI.Wpf": "15.0.26014-alpha", "Microsoft.VisualStudio.Text.UI.Wpf": "15.0.26014-alpha"
}, },
"frameworks": { "frameworks": {
"net46": { } "net46": { }
......
...@@ -205,7 +205,9 @@ protected override int GetTargetCaretPosition(SyntaxNode caretTarget) ...@@ -205,7 +205,9 @@ protected override int GetTargetCaretPosition(SyntaxNode caretTarget)
if (propertyDeclaration.AccessorList != null && propertyDeclaration.AccessorList.Accessors.Any()) if (propertyDeclaration.AccessorList != null && propertyDeclaration.AccessorList.Accessors.Any())
{ {
// move to the end of the last statement of the first accessor // move to the end of the last statement of the first accessor
var firstAccessorStatement = propertyDeclaration.AccessorList.Accessors.First().Body.Statements.Last(); var firstAccessor = propertyDeclaration.AccessorList.Accessors[0];
var firstAccessorStatement = (SyntaxNode)firstAccessor.Body?.Statements.LastOrDefault() ??
firstAccessor.ExpressionBody.Expression;
return firstAccessorStatement.GetLocation().SourceSpan.End; return firstAccessorStatement.GetLocation().SourceSpan.End;
} }
else else
......
{ {
"dependencies": { }, "dependencies": {
"Microsoft.ServiceHub.Client": "1.0.177-rc-g56d40a8a02"
},
"frameworks": { "frameworks": {
"net46": { } "net46": { }
}, },
......
...@@ -147,6 +147,7 @@ var PackagesNotBuiltOnCore = new HashSet<string> ...@@ -147,6 +147,7 @@ var PackagesNotBuiltOnCore = new HashSet<string>
"Microsoft.CodeAnalysis.VisualBasic.Features", "Microsoft.CodeAnalysis.VisualBasic.Features",
"Microsoft.CodeAnalysis.Workspaces.Common", "Microsoft.CodeAnalysis.Workspaces.Common",
"Microsoft.Net.Compilers", "Microsoft.Net.Compilers",
"Microsoft.VisualStudio.IntegrationTest.Utilities",
"Microsoft.VisualStudio.LanguageServices", "Microsoft.VisualStudio.LanguageServices",
"Microsoft.VisualStudio.LanguageServices.Next", "Microsoft.VisualStudio.LanguageServices.Next",
"Microsoft.VisualStudio.LanguageServices.Razor.RemoteClient", "Microsoft.VisualStudio.LanguageServices.Razor.RemoteClient",
......
...@@ -27,28 +27,32 @@ internal AssemblyUtil(string binariesPath) ...@@ -27,28 +27,32 @@ internal AssemblyUtil(string binariesPath)
/// <summary> /// <summary>
/// There are some DLLs whose abscence is expected and should not be considered an error. These /// There are some DLLs whose abscence is expected and should not be considered an error. These
/// are assemblies which are used as light up functionality. /// are assemblies which are either light up components or are a part of the VS reference graph
/// which are never deployed for our tests.
///
/// The key here though is to be very explicit about DLLs which are okay to be absent. In the past
/// we had build issues which failed to properly deploy important binaries like MS.CA and hence
/// produced bad content cache keys.
/// </summary> /// </summary>
internal bool IsKnownLightUpAssembly(AssemblyName name) internal bool IsKnownMissingAssembly(AssemblyName name)
{ {
switch (name.Name) switch (name.Name)
{ {
// This light up probing is done by the scripting layer.
case "System.Runtime.Loader": case "System.Runtime.Loader":
// This light up probing is done by the scripting layer.
return true; return true;
case "Microsoft.VisualStudio.GraphModel": case "Microsoft.VisualStudio.CodeAnalysis":
// This dependency needs to be better rationalized in our model. case "Microsoft.VisualStudio.CodeAnalysis.Sdk":
// https://github.com/dotnet/roslyn/issues/16201
return true;
case "Microsoft.VisualStudio.TeamSystem.Common": case "Microsoft.VisualStudio.TeamSystem.Common":
// The MS.VS.CA.Sdk.UI dependency needs to properly list this as a reference and it
// needs to be included in our model.
// https://github.com/dotnet/roslyn/issues/16202
return true;
case "Microsoft.VisualStudio.Repository": case "Microsoft.VisualStudio.Repository":
// This is not represented in our compile graph nor is it properly a part of our case "Microsoft.VisualStudio.DeveloperTools":
// build output in Dev15 builds. case "Microsoft.VisualStudio.Diagnostics.Assert":
// https://github.com/dotnet/roslyn/issues/16206 case "Microsoft.VisualStudio.Diagrams.View.Interfaces":
case "Microsoft.VisualStudio.Shell.ViewManager":
case "Microsoft.VisualStudio.VCProjectEngine":
case "Microsoft.VisualStudio.VirtualTreeGrid":
// These are assemblies which are a part of the tranisitive build graph but are known to
// not be a part of our testing code.
return true; return true;
default: default:
return false; return false;
......
...@@ -86,7 +86,7 @@ private void AppendReferences(StringBuilder builder, string assemblyPath) ...@@ -86,7 +86,7 @@ private void AppendReferences(StringBuilder builder, string assemblyPath)
var currentHash = GetFileChecksum(currentPath); var currentHash = GetFileChecksum(currentPath);
references.Add(Tuple.Create(current.Name, currentHash)); references.Add(Tuple.Create(current.Name, currentHash));
} }
else if (assemblyUtil.IsKnownLightUpAssembly(current)) else if (assemblyUtil.IsKnownMissingAssembly(current))
{ {
references.Add(Tuple.Create(current.Name, "<missing light up reference>")); references.Add(Tuple.Create(current.Name, "<missing light up reference>"));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册