Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into synchronousFlushing
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed May 8, 2017
2 parents a825831 + 022d70e commit d8d06b4
Show file tree
Hide file tree
Showing 66 changed files with 3,089 additions and 659 deletions.
53 changes: 37 additions & 16 deletions build/Targets/Imports.targets
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
<DisableImplicitFrameworkReferences Condition="'$(DisableImplicitFrameworkReferences)' == ''" >true</DisableImplicitFrameworkReferences>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>

<IbcMergePath>$(NuGetPackageRoot)\Microsoft.DotNet.IBCMerge\$(MicrosoftDotNetIBCMerge)\lib\net45\ibcmerge.exe</IbcMergePath>
</PropertyGroup>

<!-- If the project hasn't configured a ruleset, set a default ruleset. -->
Expand Down Expand Up @@ -423,39 +425,43 @@
</PropertyGroup>
</Target>

<!-- The path to IBCMerge.exe must be specified at build time via $(IbcMergePath). Typically this is passed as a
build definition variable -->
<!-- The IBCMerge tool is internal only and hence only available during official Microbuild runs. This target is
specifically not gated on the existance of this file. During an official build it shoudl always be present and
if it's not then an error needs to be raised.
A local build emulating an official build can pass /p:SkipApplyOptimizations=true to avoid this error.
-->
<Target Name="ApplyOptimizations"
Condition="'$(OfficialBuild)' == 'true' AND '$(NonShipping)' != 'true' AND '$(SkipApplyOptimizations)' != 'true' AND Exists('$(OptimizationDataFile)') AND '$(IbcMergePath)' != ''"
Condition="'$(OfficialBuild)' == 'true' AND '$(NonShipping)' != 'true' AND '$(SkipApplyOptimizations)' != 'true' AND Exists('$(OptimizationDataFile)')"
Inputs="@(IntermediateAssembly)"
Outputs="@(IntermediateAssembly);$(PostCompileBinaryModificationSentinelFile)">
<Message Text="Adding optimization data to @(IntermediateAssembly)" />

<Error Text="IBCMerge not found at $(IbcMergePath). Local developer builds should pass /p:SkipApplyOptimizations=true to avoid this"
Condition="!Exists('$(IbcMergePath)')" />

<Exec Command="&quot;$(IbcMergePath)&quot; -q -f -partialNGEN -minify -mo &quot;@(IntermediateAssembly)&quot; -incremental &quot;$(OptimizationDataFile)&quot;"
ConsoleToMSBuild="true">
ConsoleToMSBuild="true"
Condition="Exists('$(IbcMergePath)')">
<Output TaskParameter="ConsoleOutput" PropertyName="IbcMergeOutput" />
</Exec>

<Message Text="$(IbcMergeOutput)" />
</Target>

<!-- This is part of our developer convenience work to allow easy testing of our portable
unit test projects. It's a similar mechanism to CopyNuGetImplementations but is
both unsupported and somewhat special cased to our build setup.
unit test projects. It is special cased to our build setup.
This bug tracks getting an official solution out of MSBuild.
https://github.com/Microsoft/msbuild/issues/1499 -->
<Target Name="DeployPortableOnDeveloperBuild"
Condition="'$(_IsAnyPortableUnitTest)' == 'true' AND '$(DeveloperBuild)' == 'true' AND '$(OS)' == 'Windows_NT' AND '$(RoslynSdkProject)' != 'true'">
<ResolveNuGetPackageAssets IncludeFrameworkReferences="true"
NuGetPackagesDirectory="$(NuGetPackageRoot)"
RuntimeIdentifier="win7"
ProjectLanguage="$(ProjectLanguage)"
ProjectLockFile="$(MSBuildThisFileDirectory)..\..\src\Test\DeployDesktopTestRuntime\project.lock.json"
TargetMonikers=".NETFramework,Version=v4.6">
<Output TaskParameter="ResolvedCopyLocalItems" ItemName="ReferenceCopyLocalPaths" />
</ResolveNuGetPackageAssets>
Condition="'$(_IsAnyPortableUnitTest)' == 'true' AND '$(DeveloperBuild)' == 'true' AND '$(OS)' == 'Windows_NT'">
<MSBuild Projects="$(MSBuildThisFileDirectory)..\..\src\Test\DeployDesktopTestRuntime\DeployDesktopTestRuntime.csproj"
Properties="ExcludeProjectReferences=true"
Targets="GetReferenceCopyLocalPaths">
<Output TaskParameter="TargetOutputs" ItemName="ReferenceCopyLocalPaths" />
</MSBuild>

<!-- Desktop tests need to load the Desktop version of the TestUtilities via reflection at runtime without
referencing the assembly at compile time. However, it looks like adding a project-to-project reference
Expand All @@ -471,8 +477,23 @@
</MSBuild>
</Target>

<!-- When getting the dependencies to copy local for developer builds to portable project outputs,
(see above), we need to filter out the project references as they create cycles back to the
calling test projects and we are only interested in getting the nuget copy local items raised
from the deployment project's project.assets.json. -->
<Target Name="RemoveExcludedProjectReferences"
Condition="'$(ExcludeProjectReferences)' == 'true'">
<ItemGroup>
<ProjectReference Remove="@(ProjectReference)" />
</ItemGroup>
</Target>

<Target Name="GetReferenceCopyLocalPaths"
DependsOnTargets="RemoveExcludedProjectReferences;ResolveAssemblyReferences"
Returns="@(ReferenceCopyLocalPaths)" />

<!-- Returns the current build version. Used in .vsixmanifests to substitute our build version into them -->
<Target Name="GetBuildVersion" Outputs="$(VsixVersion)" />
<Target Name="GetBuildVersion" Returns="$(VsixVersion)" />

<!--
In order to leverage LUT testing we need to have both of the follownig packages in
Expand Down
1 change: 1 addition & 0 deletions build/Targets/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<MicrosoftDiaSymReaderConverterXmlVersion>1.0.0-beta1-61618-01</MicrosoftDiaSymReaderConverterXmlVersion>
<MicrosoftDiaSymReaderNativeVersion>1.5.0</MicrosoftDiaSymReaderNativeVersion>
<MicrosoftDiaSymReaderPortablePdbVersion>1.2.0</MicrosoftDiaSymReaderPortablePdbVersion>
<MicrosoftDotNetIBCMerge>4.7.1-alpha-00001</MicrosoftDotNetIBCMerge>
<MicrosoftIdentityModelClientsActiveDirectoryVersion>3.13.8</MicrosoftIdentityModelClientsActiveDirectoryVersion>
<MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>15.0.26201-alpha</MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>
<MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>14.3.25407-alpha</MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>
Expand Down
10 changes: 10 additions & 0 deletions build/ToolsetPackages/InternalToolset.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(MSBuildThisFileDirectory)..\Targets\Packages.props" />
<Import Project="$(MSBuildThisFileDirectory)..\Targets\FixedPackages.props" />
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.IBCMerge" Version="$(MicrosoftDotNetIBCMerge)" />
</ItemGroup>
</Project>
22 changes: 20 additions & 2 deletions src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,26 @@ private bool CheckValidPatternType(
//case ConversionKind.ImplicitConstant:
//case ConversionKind.ImplicitNumeric:
default:
Error(diagnostics, ErrorCode.ERR_PatternWrongType, typeSyntax, operandType, patternType);
return true;
if (operandType.ContainsTypeParameter() || patternType.ContainsTypeParameter())
{
LanguageVersion requiredVersion = MessageID.IDS_FeatureGenericPatternMatching.RequiredVersion();
if (requiredVersion > Compilation.LanguageVersion)
{
Error(diagnostics, ErrorCode.ERR_PatternWrongGenericTypeInVersion, typeSyntax,
operandType, patternType,
Compilation.LanguageVersion.ToDisplayString(),
new CSharpRequiredLanguageVersion(requiredVersion));
return true;
}

// permit pattern-matching when one of the types is an open type in C# 7.1.
break;
}
else
{
Error(diagnostics, ErrorCode.ERR_PatternWrongType, typeSyntax, operandType, patternType);
return true;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ internal bool AddLabel(BoundPatternSwitchLabel label, DiagnosticBag diagnostics,
// For purposes of subsumption, we do not take into consideration the value
// of the input expression. Therefore we consider null possible if the type permits.
Syntax = label.Syntax;
var subsumedErrorCode = CheckSubsumed(label.Pattern, _subsumptionTree, inputCouldBeNull: true);
var inputCouldBeNull = _subsumptionTree.Type.CanContainNull();
var subsumedErrorCode = CheckSubsumed(label.Pattern, _subsumptionTree, inputCouldBeNull: inputCouldBeNull);
if (subsumedErrorCode != 0 && subsumedErrorCode != ErrorCode.ERR_NoImplicitConvCast)
{
if (!label.HasErrors)
Expand Down
4 changes: 1 addition & 3 deletions src/Compilers/CSharp/Portable/BoundTree/DecisionTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static DecisionTree Create(BoundExpression expression, TypeSymbol type, S
expression = new BoundLocal(expression.Syntax, temp, null, type);
}

if (expression.Type.CanContainNull())
if (type.CanContainNull() || type.SpecialType == SpecialType.None)
{
// 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
Expand All @@ -104,8 +104,6 @@ public static DecisionTree Create(BoundExpression expression, TypeSymbol type, S
else
{
// If it is a (e.g. builtin) value type, we can switch on its (constant) values.
// If it isn't a builtin, in practice we will only use the Default part of the
// ByValue.
return new ByValue(expression, type, temp);
}
}
Expand Down
31 changes: 20 additions & 11 deletions src/Compilers/CSharp/Portable/BoundTree/DecisionTreeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private DecisionTree AddByValue(DecisionTree.Guarded guarded, BoundConstantPatte

private DecisionTree AddByValue(DecisionTree.ByValue byValue, BoundConstantPattern value, DecisionMaker makeDecision)
{
Debug.Assert(value.Value.Type == byValue.Type);
Debug.Assert(value.Value.Type.Equals(byValue.Type, TypeCompareKind.IgnoreDynamicAndTupleNames));
if (byValue.Default != null)
{
return AddByValue(byValue.Default, value, makeDecision);
Expand Down Expand Up @@ -221,7 +221,7 @@ private DecisionTree AddByValue(DecisionTree.ByType byType, BoundConstantPattern
var kvp = byType.TypeAndDecision[i];
var matchedType = kvp.Key;
var decision = kvp.Value;
if (matchedType.TupleUnderlyingTypeOrSelf() == value.Value.Type.TupleUnderlyingTypeOrSelf())
if (matchedType.Equals(value.Value.Type, TypeCompareKind.IgnoreDynamicAndTupleNames))
{
forType = decision;
break;
Expand Down Expand Up @@ -260,21 +260,30 @@ private DecisionTree AddByType(DecisionTree decision, TypeSymbol type, DecisionM
case DecisionTree.DecisionKind.ByValue:
{
var byValue = (DecisionTree.ByValue)decision;
DecisionTree result;
if (byValue.Default == null)
{
byValue.Default = makeDecision(byValue.Expression, byValue.Type);
if (byValue.Default.MatchIsComplete)
if (byValue.Type.Equals(type, TypeCompareKind.IgnoreDynamicAndTupleNames))
{
byValue.MatchIsComplete = true;
result = byValue.Default = makeDecision(byValue.Expression, byValue.Type);
}
else
{
byValue.Default = new DecisionTree.ByType(byValue.Expression, byValue.Type, null);
result = AddByType(byValue.Default, type, makeDecision);
}

return byValue.Default;
}
else
{
Debug.Assert(byValue.Default.Type == type);
return Add(byValue.Default, makeDecision);
result = AddByType(byValue.Default, type, makeDecision);
}

if (byValue.Default.MatchIsComplete)
{
byValue.MatchIsComplete = true;
}

return result;
}
case DecisionTree.DecisionKind.Guarded:
return AddByType((DecisionTree.Guarded)decision, type, makeDecision);
Expand Down Expand Up @@ -321,7 +330,7 @@ private DecisionTree AddByType(DecisionTree.ByType byType, TypeSymbol type, Deci
if (byType.TypeAndDecision.Count != 0)
{
var lastTypeAndDecision = byType.TypeAndDecision.Last();
if (lastTypeAndDecision.Key.TupleUnderlyingTypeOrSelf() == type.TupleUnderlyingTypeOrSelf())
if (lastTypeAndDecision.Key.Equals(type, TypeCompareKind.IgnoreDynamicAndTupleNames))
{
result = Add(lastTypeAndDecision.Value, makeDecision);
}
Expand Down Expand Up @@ -533,7 +542,7 @@ private DecisionTree Add(DecisionTree.ByType byType, DecisionMaker makeDecision)
TypeSymbol patternType,
ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if (expressionType == patternType)
if ((object)expressionType == (object)patternType)
{
return true;
}
Expand Down
11 changes: 10 additions & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4891,7 +4891,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<value>The switch case has already been handled by a previous case.</value>
</data>
<data name="ERR_PatternWrongType" xml:space="preserve">
<value>An expression of type {0} cannot be handled by a pattern of type {1}.</value>
<value>An expression of type '{0}' cannot be handled by a pattern of type '{1}'.</value>
</data>
<data name="WRN_AttributeIgnoredWhenPublicSigning" xml:space="preserve">
<value>Attribute '{0}' is ignored when public signing is specified.</value>
Expand Down Expand Up @@ -5070,4 +5070,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_VoidInTuple" xml:space="preserve">
<value>A tuple may not contain a value of type 'void'.</value>
</data>
<data name="ERR_PatternWrongGenericTypeInVersion" xml:space="preserve">
<value>An expression of type '{0}' cannot be handled by a pattern of type '{1}' in C# {2}. Please use language version {3} or greater.</value>
</data>
</root>
12 changes: 11 additions & 1 deletion src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,17 @@ private void EmitMethodDefIndexExpression(BoundMethodDefIndex node)
Debug.Assert(node.Method.IsDefinition);
Debug.Assert(node.Type.SpecialType == SpecialType.System_Int32);
_builder.EmitOpCode(ILOpCode.Ldtoken);
EmitSymbolToken(node.Method, node.Syntax, null, encodeAsRawDefinitionToken: true);

// For partial methods, we emit pseudo token based on the symbol for the partial
// definition part as opposed to the symbol for the partial implementation part.
// We will need to resolve the symbol associated with each pseudo token in order
// to compute the real method definition tokens later. For partial methods, this
// resolution can only succeed if the associated symbol is the symbol for the
// partial definition and not the symbol for the partial implementation (see
// MethodSymbol.ResolvedMethodImpl()).
var symbol = node.Method.PartialDefinitionPart ?? node.Method;

EmitSymbolToken(symbol, node.Syntax, null, encodeAsRawDefinitionToken: true);
}

private void EmitMaximumMethodDefIndexExpression(BoundMaximumMethodDefIndex node)
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,8 +1476,13 @@ internal enum ErrorCode
WRN_Experimental = 8305,
ERR_TupleInferredNamesNotAvailable = 8306,

#region diagnostics for C# 7.1

ERR_BadDynamicMethodArgDefaultLiteral = 9000,
ERR_DefaultLiteralNotValid = 9001,
WRN_DefaultInSwitch = 9002,
ERR_PatternWrongGenericTypeInVersion = 9003,

#endregion diagnostics for C# 7.1
}
}
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/MessageID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ internal enum MessageID
IDS_ThrowExpression = MessageBase + 12717,
IDS_FeatureDefaultLiteral = MessageBase + 12718,
IDS_FeatureInferredTupleNames = MessageBase + 12719,
IDS_FeatureGenericPatternMatching = MessageBase + 12720,
}

// Message IDs may refer to strings that need to be localized.
Expand Down Expand Up @@ -188,6 +189,7 @@ internal static LanguageVersion RequiredVersion(this MessageID feature)
// C# 7.1 features.
case MessageID.IDS_FeatureDefaultLiteral:
case MessageID.IDS_FeatureInferredTupleNames:
case MessageID.IDS_FeatureGenericPatternMatching:
return LanguageVersion.CSharp7_1;

// C# 7 features.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private DecisionTree LowerToDecisionTree(
}
}

if (defaultLabel != null)
if (defaultLabel != null && !loweredDecisionTree.MatchIsComplete)
{
Add(loweredDecisionTree, (e, t) => new DecisionTree.Guarded(loweredExpression, loweredExpression.Type, default(ImmutableArray<KeyValuePair<BoundExpression, BoundExpression>>), defaultSection, null, defaultLabel));
}
Expand Down Expand Up @@ -219,7 +219,8 @@ private void LowerDecisionTree(BoundExpression expression, DecisionTree decision
// Store the input expression into a temp
if (decisionTree.Expression != expression)
{
_loweredDecisionTree.Add(_factory.Assignment(decisionTree.Expression, expression));
var convertedExpression = _factory.Convert(decisionTree.Expression.Type, expression);
_loweredDecisionTree.Add(_factory.Assignment(decisionTree.Expression, convertedExpression));
}

if (_declaredTempSet.Add(decisionTree.Temp))
Expand Down
Loading

0 comments on commit d8d06b4

Please sign in to comment.