Skip to content

Commit

Permalink
Merge pull request #33445 from dotnet/merges/master-to-features/reado…
Browse files Browse the repository at this point in the history
…nly-members

Merge master to features/readonly-members
  • Loading branch information
dotnet-automerge-bot authored Feb 16, 2019
2 parents d733674 + 12f4665 commit 3fcc422
Show file tree
Hide file tree
Showing 179 changed files with 1,128 additions and 242 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<RoslynDiagnosticsNugetPackageVersion>2.6.2-beta2</RoslynDiagnosticsNugetPackageVersion>
<CodeStyleLayerCodeAnalysisVersion>2.8.2</CodeStyleLayerCodeAnalysisVersion>
<MicrosoftCodeAnalysisTestingVersion>1.0.0-beta1-63310-01</MicrosoftCodeAnalysisTestingVersion>
<CodeStyleAnalyzerVersion>2.11.0-beta2-63603-03</CodeStyleAnalyzerVersion>
<CodeStyleAnalyzerVersion>3.1.0-beta1-19113-04</CodeStyleAnalyzerVersion>

<BasicUndoVersion>0.9.3</BasicUndoVersion>
<BenchmarkDotNetVersion>0.11.1</BenchmarkDotNetVersion>
Expand Down
10 changes: 5 additions & 5 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,11 @@ function Ensure-ProcDump() {
}

function Prepare-TempDir() {
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\.editorconfig") $TempDir
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\Directory.Build.props") $TempDir
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\Directory.Build.targets") $TempDir
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\Directory.Build.rsp") $TempDir
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\NuGet.Config") $TempDir
Copy-Item (Join-Path $RepoRoot "src\Workspaces\MSBuildTest\Resources\.editorconfig") $TempDir
Copy-Item (Join-Path $RepoRoot "src\Workspaces\MSBuildTest\Resources\Directory.Build.props") $TempDir
Copy-Item (Join-Path $RepoRoot "src\Workspaces\MSBuildTest\Resources\Directory.Build.targets") $TempDir
Copy-Item (Join-Path $RepoRoot "src\Workspaces\MSBuildTest\Resources\Directory.Build.rsp") $TempDir
Copy-Item (Join-Path $RepoRoot "src\Workspaces\MSBuildTest\Resources\NuGet.Config") $TempDir
}

function List-Processes() {
Expand Down
19 changes: 19 additions & 0 deletions eng/config/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="{generated}" name="{generated}"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
</assembly>
47 changes: 47 additions & 0 deletions eng/targets/Imports.targets
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,51 @@
</TargetFrameworkMonikerAssemblyAttributeText>
</PropertyGroup>
</Target>

<Target Name="_CalculateSubstituteVariablesInApplicationManifestInputsOutputs">
<PropertyGroup>
<_OriginalApplicationManifestPath>$(RepositoryEngineeringDir)config\app.manifest</_OriginalApplicationManifestPath>
<_UpdatedApplicationManifestPath>$(IntermediateOutputPath)$(AssemblyName).exe.manifest</_UpdatedApplicationManifestPath>
</PropertyGroup>
</Target>

<!--
Sets the values of "version" and "name" attributes in assemblyIdentity element in the application manifest file
with values $(AssemblyVersion) and $(AssemblyName) to avoid hardcoding those in the manifest file.
-->
<Target Name="_SubstituteVariablesInApplicationManifest"
BeforeTargets="_SetExternalWin32ManifestProperties;_SetEmbeddedWin32ManifestProperties"
DependsOnTargets="_CalculateSubstituteVariablesInApplicationManifestInputsOutputs;GetAssemblyVersion"
Inputs="$(_OriginalApplicationManifestPath)"
Outputs="$(_UpdatedApplicationManifestPath)"
Condition="'$(OutputType)' == 'Exe' And '$(TargetFramework)' == 'net472'">

<Copy SourceFiles="$(_OriginalApplicationManifestPath)" DestinationFiles="$(_UpdatedApplicationManifestPath)" />

<PropertyGroup>
<_Namespace>
<Namespace Prefix="asm" Uri="urn:schemas-microsoft-com:asm.v1" />
</_Namespace>
</PropertyGroup>

<!-- Update version attribute -->
<XmlPoke XmlInputPath="$(_UpdatedApplicationManifestPath)"
Value="$(AssemblyVersion)"
Query="/asm:assembly/asm:assemblyIdentity/@version"
Namespaces="$(_Namespace)"/>

<!-- Update name attribute -->
<XmlPoke XmlInputPath="$(_UpdatedApplicationManifestPath)"
Value="$(AssemblyName)"
Query="/asm:assembly/asm:assemblyIdentity/@name"
Namespaces="$(_Namespace)"/>

<PropertyGroup>
<ApplicationManifest>$(_UpdatedApplicationManifestPath)</ApplicationManifest>
</PropertyGroup>

<ItemGroup>
<FileWrites Include="$(_UpdatedApplicationManifestPath)"/>
</ItemGroup>
</Target>
</Project>
10 changes: 5 additions & 5 deletions src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3060,19 +3060,19 @@ internal static bool HasHome(
return true;

case BoundKind.ConditionalOperator:
var ternary = (BoundConditionalOperator)expression;
var conditional = (BoundConditionalOperator)expression;

// only ref ternary may be referenced as a variable
if (!ternary.IsRef)
// only ref conditional may be referenced as a variable
if (!conditional.IsRef)
{
return false;
}

// branch that has no home will need a temporary
// if both have no home, just say whole expression has no home
// so we could just use one temp for the whole thing
return HasHome(ternary.Consequence, addressKind, method, peVerifyCompatEnabled, stackLocalsOpt)
&& HasHome(ternary.Alternative, addressKind, method, peVerifyCompatEnabled, stackLocalsOpt);
return HasHome(conditional.Consequence, addressKind, method, peVerifyCompatEnabled, stackLocalsOpt)
&& HasHome(conditional.Alternative, addressKind, method, peVerifyCompatEnabled, stackLocalsOpt);

default:
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Operators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3621,7 +3621,7 @@ private BoundExpression GenerateNullCoalescingAssignmentBadBinaryOpsError(Assign
/// <remarks>
/// From ExpressionBinder::EnsureQMarkTypesCompatible:
///
/// The v2.0 specification states that the types of the second and third operands T and S of a ternary operator
/// The v2.0 specification states that the types of the second and third operands T and S of a conditional operator
/// must be TT and TS such that either (a) TT==TS, or (b), TT->TS or TS->TT but not both.
///
/// Unfortunately that is not what we implemented in v2.0. Instead, we implemented
Expand Down
2 changes: 1 addition & 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.

2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4990,7 +4990,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<value>This combination of arguments to '{0}' is disallowed because it may expose variables referenced by parameter '{1}' outside of their declaration scope</value>
</data>
<data name="ERR_MismatchedRefEscapeInTernary" xml:space="preserve">
<value>Branches of a ref ternary operator cannot refer to variables with incompatible declaration scopes</value>
<value>Branches of a ref conditional operator cannot refer to variables with incompatible declaration scopes</value>
</data>
<data name="ERR_EscapeStackAlloc" xml:space="preserve">
<value>A result of a stackalloc expression of type '{0}' cannot be used in this context because it may be exposed outside of the containing method</value>
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3192,7 +3192,7 @@ private void EmitConditionalOperator(BoundConditionalOperator expr, bool used)
/// </remarks>
private void EmitNullCoalescingOperator(BoundNullCoalescingOperator expr, bool used)
{
Debug.Assert(expr.LeftConversion.IsIdentity, "coalesce with nontrivial left conversions are lowered into ternary.");
Debug.Assert(expr.LeftConversion.IsIdentity, "coalesce with nontrivial left conversions are lowered into conditional.");
Debug.Assert(expr.Type.IsReferenceType);

EmitExpression(expr.LeftOperand, used: true);
Expand Down Expand Up @@ -3242,7 +3242,7 @@ private void EmitNullCoalescingOperator(BoundNullCoalescingOperator expr, bool u
}

// Implicit casts are not emitted. As a result verifier may operate on a different
// types from the types of operands when performing stack merges in coalesce/ternary.
// types from the types of operands when performing stack merges in coalesce/conditional.
// Such differences are in general irrelevant since merging rules work the same way
// for base and derived types.
//
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ internal enum ErrorCode
ERR_NamedArgumentSpecificationBeforeFixedArgumentInDynamicInvocation = 8324,
#endregion diagnostics introduced for C# 7.2

#region diagnostics introduced for `ref readonly`, `ref ternary` and `ref-like` features in C# 7.2
#region diagnostics introduced for `ref readonly`, `ref conditional` and `ref-like` features in C# 7.2
ERR_RefConditionalAndAwait = 8325,
ERR_RefConditionalNeedsTwoRefs = 8326,
ERR_RefConditionalDifferentTypes = 8327,
Expand Down Expand Up @@ -1538,7 +1538,7 @@ internal enum ErrorCode
ERR_EscapeStackAlloc = 8353,
ERR_RefReturnThis = 8354,
ERR_OutAttrOnInParam = 8355,
#endregion diagnostics introduced for `ref readonly`, `ref ternary` and `ref-like` features in C# 7.2
#endregion diagnostics introduced for `ref readonly`, `ref conditional` and `ref-like` features in C# 7.2

ERR_PredefinedValueTupleTypeAmbiguous3 = 8356,
ERR_InvalidVersionFormatDeterministic = 8357,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2735,7 +2735,7 @@ private void VisitArgumentEvaluate(ImmutableArray<BoundExpression> arguments, Im
else
{
// As far as we can tell, there is no scenario relevant to nullability analysis
// where splitting an L-value (for instance with a ref ternary) would affect the result.
// where splitting an L-value (for instance with a ref conditional) would affect the result.
VisitLvalue(argument);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ protected BaseSwitchLocalRewriter(
foreach (var arm in arms)
{
var armBuilder = ArrayBuilder<BoundStatement>.GetInstance();
// We start each switch block with a hidden sequence point so that

// We start each switch block of a switch statement with a hidden sequence point so that
// we do not appear to be in the previous switch block when we begin.
armBuilder.Add(_factory.HiddenSequencePoint());
if (isSwitchStatement)
armBuilder.Add(_factory.HiddenSequencePoint());

_switchArms.Add(arm, armBuilder);
}
}
Expand Down Expand Up @@ -283,10 +286,12 @@ protected BoundDecisionDag ShareTempsIfPossibleAndEvaluateInput(
savedInputExpression = inputTemp;
}

// There is a hidden sequence point after evaluating the input at the start of the code to
// handle the decision dag. This is necessary so that jumps back from a `when` clause into
// In a switch statement, there is a hidden sequence point after evaluating the input at the start of
// the code to handle the decision dag. This is necessary so that jumps back from a `when` clause into
// the decision dag do not appear to jump back up to the enclosing construct.
result.Add(_factory.HiddenSequencePoint());
if (_isSwitchStatement)
result.Add(_factory.HiddenSequencePoint());

return decisionDag;
}

Expand Down Expand Up @@ -584,8 +589,10 @@ private void LowerWhenClause(BoundWhenDecisionDagNode whenClause)
sectionBuilder.Add(conditionalGoto);

Debug.Assert(whenFalse != null);

// We hide the jump back into the decision dag, as it is not logically part of the when clause
sectionBuilder.Add(_factory.HiddenSequencePoint(_factory.Goto(GetDagNodeLabel(whenFalse))));
BoundStatement jump = _factory.Goto(GetDagNodeLabel(whenFalse));
sectionBuilder.Add(_isSwitchStatement ? _factory.HiddenSequencePoint(jump) : jump);
}
else
{
Expand All @@ -607,10 +614,13 @@ private void LowerDecisionDagNode(BoundDecisionDagNode node, BoundDecisionDagNod
BoundExpression sideEffect = LowerEvaluation(evaluationNode.Evaluation);
Debug.Assert(sideEffect != null);
_loweredDecisionDag.Add(_factory.ExpressionStatement(sideEffect));

// We add a hidden sequence point after the evaluation's side-effect, which may be a call out
// to user code such as `Deconstruct` or a property get, to permit edit-and-continue to
// synchronize on changes.
_loweredDecisionDag.Add(_factory.HiddenSequencePoint());
if (_isSwitchStatement)
_loweredDecisionDag.Add(_factory.HiddenSequencePoint());

if (nextNode != evaluationNode.Next)
{
// We only need a goto if we would not otherwise fall through to the desired state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public override BoundNode VisitLoweredConditionalAccess(BoundLoweredConditionalA
private enum ConditionalAccessLoweringKind
{
LoweredConditionalAccess,
Ternary,
TernaryCaptureReceiverByVal
Conditional,
ConditionalCaptureReceiverByVal
}

// IL gen can generate more compact code for certain conditional accesses
Expand All @@ -46,10 +46,10 @@ internal BoundExpression RewriteConditionalAccess(BoundConditionalAccess node, b
}

ConditionalAccessLoweringKind loweringKind;
// dynamic receivers are not directly supported in codegen and need to be lowered to a ternary
var lowerToTernary = node.AccessExpression.Type.IsDynamic();
// dynamic receivers are not directly supported in codegen and need to be lowered to a conditional
var lowerToConditional = node.AccessExpression.Type.IsDynamic();

if (!lowerToTernary)
if (!lowerToConditional)
{
// trivial cases are directly supported in IL gen
loweringKind = ConditionalAccessLoweringKind.LoweredConditionalAccess;
Expand All @@ -61,11 +61,11 @@ internal BoundExpression RewriteConditionalAccess(BoundConditionalAccess node, b
// so we can capture receiver by value in dynamic case regardless of
// the type of receiver
// Nullable receivers are immutable so should be captured by value as well.
loweringKind = ConditionalAccessLoweringKind.TernaryCaptureReceiverByVal;
loweringKind = ConditionalAccessLoweringKind.ConditionalCaptureReceiverByVal;
}
else
{
loweringKind = ConditionalAccessLoweringKind.Ternary;
loweringKind = ConditionalAccessLoweringKind.Conditional;
}


Expand All @@ -84,11 +84,11 @@ internal BoundExpression RewriteConditionalAccess(BoundConditionalAccess node, b

break;

case ConditionalAccessLoweringKind.Ternary:
case ConditionalAccessLoweringKind.Conditional:
_currentConditionalAccessTarget = loweredReceiver;
break;

case ConditionalAccessLoweringKind.TernaryCaptureReceiverByVal:
case ConditionalAccessLoweringKind.ConditionalCaptureReceiverByVal:
temp = _factory.SynthesizedLocal(receiverType);
_currentConditionalAccessTarget = _factory.Local(temp);
break;
Expand Down Expand Up @@ -155,15 +155,15 @@ internal BoundExpression RewriteConditionalAccess(BoundConditionalAccess node, b

break;

case ConditionalAccessLoweringKind.TernaryCaptureReceiverByVal:
case ConditionalAccessLoweringKind.ConditionalCaptureReceiverByVal:
// capture the receiver into a temp
loweredReceiver = _factory.MakeSequence(
_factory.AssignmentExpression(_factory.Local(temp), loweredReceiver),
_factory.Local(temp));

goto case ConditionalAccessLoweringKind.Ternary;
goto case ConditionalAccessLoweringKind.Conditional;

case ConditionalAccessLoweringKind.Ternary:
case ConditionalAccessLoweringKind.Conditional:
{
// (object)r != null ? access : default(T)
var condition = _factory.ObjectNotEqual(
Expand Down
Loading

0 comments on commit 3fcc422

Please sign in to comment.