Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: SRM and SCI update #25594

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ac8ec16
Remove TestWorkspace from WorkspacesTestUtilities
sharwell Mar 19, 2018
c2d44d0
Move several helper methods from MinimalTestExportProvider to ExportP…
sharwell Mar 19, 2018
2409375
Implement UseExportProviderAttribute for single-test scoping of Expor…
sharwell Mar 19, 2018
aad82d2
Move UseExportProviderAttribute to the workspaces layer
sharwell Mar 20, 2018
d38b799
Implement RoslynServices hook
sharwell Mar 19, 2018
19aef6d
Use correct ExportProvider in TestWorkspace
sharwell Mar 15, 2018
58c1a55
Split test to avoid creating multiple export providers in a single test
sharwell Mar 17, 2018
3a64f13
Encapsulate field SyntaxGeneratorTests._g to avoid creating ExportPro…
sharwell Mar 17, 2018
12a7896
Update WorkspaceFixture to support disposing the workspace between ea…
sharwell Mar 15, 2018
6894e9e
Remove shared ExportProvider from TestHostServices
sharwell Mar 17, 2018
7eb0b2d
Avoid attempts to create ExportProvider in test constructors
sharwell Mar 17, 2018
c5465fc
Apply UseExportProviderAttribute to tests where required
sharwell Mar 19, 2018
33a1a3b
Always obtain IAsynchronousOperationListenerProvider from MEF
sharwell Mar 21, 2018
860428e
Clear cancelled items from IForegroundNotificationService during test…
sharwell Mar 21, 2018
7e8391f
Remove sharing of ExportProvider instances between tests
sharwell Feb 16, 2018
0f7eeec
Improve the caching mechanism used for export providers during testing
sharwell Mar 20, 2018
8401a66
Use ApplicationIdle instead of SystemIdle in DispatcherExtensions
sharwell Mar 21, 2018
c53626a
Update code comment to reflect actual behavior
sharwell Mar 22, 2018
b0b89a2
Add missing project references
sharwell Mar 23, 2018
426c63f
Fix failure to dispose of workspaces during tests
sharwell Mar 23, 2018
d84b8ec
Update PATH to our xcopy CLI
jaredpar Mar 27, 2018
06dcac6
Added both ExpressionBody and BlockBody to the underlying BoundNode f…
333fred Mar 27, 2018
3efd039
Addressed PR feedback, updated ILocalFunctionOperation to final desig…
333fred Mar 29, 2018
902b18e
Add missing file, update test for clearer output.
333fred Mar 29, 2018
a7dba96
Document code and slightly refactor to improve clarity/maintainability
sharwell Mar 29, 2018
b7b1d49
[SQLite] Fix continuous probing for sqlite
Therzok Mar 19, 2018
66d97c9
Run integration tests on an STA thread
sharwell Mar 14, 2018
53178e6
Avoid calling AttachThreadInput for two identical threads
sharwell Mar 29, 2018
4070bfe
Skip failing tests DumpLocalVariableValue
sharwell Mar 29, 2018
3c001e3
Disable flaky tests EncapsulateThroughCommand
sharwell Mar 29, 2018
08fee02
Install a COM message filter to handle retry operations when the firs…
sharwell Mar 14, 2018
54330a6
Make DebugAssertFailureException serializable in all available builds
sharwell Mar 29, 2018
208e464
Addressed PR feedback.
333fred Mar 29, 2018
b9180c3
Replace HostWaitHelper (integration tests) with asynchronous code
sharwell Mar 29, 2018
3688699
Retry calls to GetCurrentPattern if they return UIA_E_ELEMENTNOTAVAIL…
sharwell Mar 29, 2018
b13e974
Retry pattern operations if they return UIA_E_ELEMENTNOTAVAILABLE
sharwell Mar 29, 2018
90127a6
Make escape analysis over unexpected nodes to return conservative res…
VSadov Mar 29, 2018
b6b0f03
Merge pull request #25590 from Therzok/fix24042
sharwell Mar 30, 2018
0ad00b2
Merge pull request #25750 from jaredpar/fix-it
jaredpar Mar 30, 2018
d90dbcd
CR feedback. Removed irrelevant code from tests.
VSadov Mar 30, 2018
cb01cd3
added more logging for completion to track some test failures where c…
heejaechang Mar 30, 2018
bd72846
Foreach to For refactoring (#25460)
heejaechang Mar 30, 2018
1d5c75e
Use System.InvalidOperationException to avoid exception serialization…
sharwell Mar 30, 2018
8b08df1
Merge pull request #25782 from 333fred/local-function-extra-binding
333fred Mar 30, 2018
8a7ff8f
Merge pull request #25467 from sharwell/sta-integration-tests
sharwell Mar 30, 2018
4536ccb
Fix signing of swix project output
jaredpar Mar 30, 2018
e7427b5
Merge remote-tracking branch 'dotnet/dev15.7.x' into isolate-tests
sharwell Mar 30, 2018
aefa753
Updates from code review feedback
sharwell Mar 30, 2018
7933a9f
Merge pull request #25850 from jaredpar/fix-swix
jaredpar Mar 31, 2018
ba524a7
Switch to vs-threading pattern for UI-thread affinitized code
sharwell Mar 31, 2018
3630339
Merge pull request #25819 from VSadov/fix25398
VSadov Mar 31, 2018
b45fa2d
Merge pull request #25455 from sharwell/com-message-filter
sharwell Mar 31, 2018
3c17eae
Rename EnabledViaUseExportProviderAttributeOnly for clarity
sharwell Mar 31, 2018
0666f37
Use Create and GetOrCreate method prefixes as appropriate for clarity
sharwell Mar 31, 2018
e5ff94f
Remove unnecessary null checks
sharwell Mar 31, 2018
9c1df9f
Add guidance for users who hit ExportProvider-related exceptions betw…
sharwell Mar 31, 2018
2e7f840
Use Lazy<T> to simplify value initialization
sharwell Mar 31, 2018
10548cd
Simplify the Join operation used for waiters during test cleanup
sharwell Mar 31, 2018
a4eb409
Fix race condition in AsynchronousSerialWorkQueue work cancellation
sharwell Mar 31, 2018
8ede7e4
Avoid scheduling work that's already cancelled
sharwell Mar 31, 2018
0e76c45
Merge pull request #25681 from sharwell/isolate-tests
sharwell Mar 31, 2018
c76f590
LINQ query to foreach (#25362)
ivanbasov Apr 1, 2018
4045ce0
Downgrade desktop projects to net46
tmat Mar 20, 2018
374150d
Remove workarounds
tmat Mar 23, 2018
183f866
Update SCI, SRM, DSR, MDV to the latest versions
tmat Apr 1, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<MaxVersion>$(AssemblyVersion)</MaxVersion>
</SuggestedBindingRedirects>
<SuggestedBindingRedirects Include="System.Collections.Immutable, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<MaxVersion>1.2.1.0</MaxVersion>
<MaxVersion>1.2.3.0</MaxVersion>
</SuggestedBindingRedirects>
<SuggestedBindingRedirects Include="System.Console, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<MaxVersion>4.0.1.0</MaxVersion>
Expand All @@ -49,7 +49,7 @@
<MaxVersion>4.0.1.0</MaxVersion>
</SuggestedBindingRedirects>
<SuggestedBindingRedirects Include="System.Reflection.Metadata, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<MaxVersion>1.4.1.0</MaxVersion>
<MaxVersion>1.4.3.0</MaxVersion>
</SuggestedBindingRedirects>
<SuggestedBindingRedirects Include="System.Threading.Thread, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<MaxVersion>4.0.1.0</MaxVersion>
Expand Down
14 changes: 7 additions & 7 deletions build/Targets/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@
<MicrosoftCSharpVersion>4.3.0</MicrosoftCSharpVersion>
<MicrosoftDiagnosticsRuntimeVersion>0.8.31-beta</MicrosoftDiagnosticsRuntimeVersion>
<MicrosoftDiagnosticsTracingTraceEventVersion>1.0.35</MicrosoftDiagnosticsTracingTraceEventVersion>
<MicrosoftDiaSymReaderVersion>1.2.0</MicrosoftDiaSymReaderVersion>
<MicrosoftDiaSymReaderConverterVersion>1.1.0-beta1-62628-01</MicrosoftDiaSymReaderConverterVersion>
<MicrosoftDiaSymReaderConverterXmlVersion>1.1.0-beta1-62628-01</MicrosoftDiaSymReaderConverterXmlVersion>
<MicrosoftDiaSymReaderVersion>1.3.0-beta-62801-02</MicrosoftDiaSymReaderVersion>
<MicrosoftDiaSymReaderConverterVersion>1.1.0-beta1-62801-01</MicrosoftDiaSymReaderConverterVersion>
<MicrosoftDiaSymReaderConverterXmlVersion>1.1.0-beta1-62801-01</MicrosoftDiaSymReaderConverterXmlVersion>
<MicrosoftDiaSymReaderNativeVersion>1.7.0</MicrosoftDiaSymReaderNativeVersion>
<MicrosoftDiaSymReaderPortablePdbVersion>1.4.0</MicrosoftDiaSymReaderPortablePdbVersion>
<MicrosoftDiaSymReaderPortablePdbVersion>1.5.0-beta-62801-02</MicrosoftDiaSymReaderPortablePdbVersion>
<MicrosoftDotNetIBCMerge>4.7.2-alpha-00001</MicrosoftDotNetIBCMerge>
<MicrosoftDotNetVersionToolsVersion>1.0.27-prerelease-01811-02</MicrosoftDotNetVersionToolsVersion>
<MicrosoftDotNetBuildTasksFeedVersion>2.1.0-prerelease-02419-02</MicrosoftDotNetBuildTasksFeedVersion>
<MicrosoftIdentityModelClientsActiveDirectoryVersion>3.13.8</MicrosoftIdentityModelClientsActiveDirectoryVersion>
<MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>15.0.26730-alpha</MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>
<MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>14.3.25407-alpha</MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>
<MicrosoftMetadataVisualizerVersion>1.0.0-beta1-61531-03</MicrosoftMetadataVisualizerVersion>
<MicrosoftMetadataVisualizerVersion>1.0.0-beta1-62801-01</MicrosoftMetadataVisualizerVersion>
<MicrosoftMSXMLVersion>8.0.0.0-alpha</MicrosoftMSXMLVersion>
<!-- Using a private build of Microsoft.Net.Test.SDK to work around issue https://github.com/Microsoft/vstest/issues/373 -->
<MicrosoftNETTestSdkVersion>15.6.0-dev</MicrosoftNETTestSdkVersion>
Expand Down Expand Up @@ -158,7 +158,7 @@
<SystemAppContextVersion>4.3.0</SystemAppContextVersion>
<SystemCollectionsVersion>4.3.0</SystemCollectionsVersion>
<SystemCollectionsConcurrentVersion>4.3.0</SystemCollectionsConcurrentVersion>
<SystemCollectionsImmutableVersion>1.3.1</SystemCollectionsImmutableVersion>
<SystemCollectionsImmutableVersion>1.5.0-preview2-26401-03</SystemCollectionsImmutableVersion>
<SystemConsoleVersion>4.3.0</SystemConsoleVersion>
<SystemDataCommonVersion>4.3.0</SystemDataCommonVersion>
<SystemDiagnosticsContractsVersion>4.3.0</SystemDiagnosticsContractsVersion>
Expand Down Expand Up @@ -191,7 +191,7 @@
<SystemObjectModelVersion>4.3.0</SystemObjectModelVersion>
<SystemReflectionVersion>4.3.0</SystemReflectionVersion>
<SystemReflectionExtensionsVersion>4.3.0</SystemReflectionExtensionsVersion>
<SystemReflectionMetadataVersion>1.4.2</SystemReflectionMetadataVersion>
<SystemReflectionMetadataVersion>1.6.0-preview2-26401-03</SystemReflectionMetadataVersion>
<SystemReflectionPrimitivesVersion>4.3.0</SystemReflectionPrimitivesVersion>
<SystemReflectionTypeExtensionsVersion>4.3.0</SystemReflectionTypeExtensionsVersion>
<SystemResourcesResourceManagerVersion>4.3.0</SystemResourcesResourceManagerVersion>
Expand Down
2 changes: 1 addition & 1 deletion build/Targets/Roslyn.Toolsets.Xunit.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<ForceGenerationOfBindingRedirects>true</ForceGenerationOfBindingRedirects>

<RuntimeIdentifier Condition="'$(TargetFramework)' == 'net461' AND '$(RuntimeIdentifier)' == '' AND '$(OS)' == 'Windows_NT'">$(RoslynDesktopRuntimeIdentifier)</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(TargetFramework)' == 'net46' AND '$(RuntimeIdentifier)' == '' AND '$(OS)' == 'Windows_NT'">$(RoslynDesktopRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

<Target Name="Test" DependsOnTargets="Build">
Expand Down
3 changes: 1 addition & 2 deletions build/Targets/Settings.props
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
<!-- Disable analyzers if NuGet deviated from the expected restore location (e.g. by changing case on a case-sensitive file system) -->
<UseRoslynAnalyzers Condition="!Exists('$(NuGetPackageRoot)\Microsoft.CodeQuality.Analyzers\$(RoslynDiagnosticsNugetPackageVersion)\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll')">False</UseRoslynAnalyzers>
<RoslynDiagnosticsPropsFilePath>$(NuGetPackageRoot)/microsoft.net.roslyndiagnostics/$(RoslynDiagnosticsNugetPackageVersion)/build/Microsoft.Net.RoslynDiagnostics.props</RoslynDiagnosticsPropsFilePath>
<RoslynPortableTargetFrameworks>net461;netcoreapp2.0</RoslynPortableTargetFrameworks>
<RoslynPortableTargetFrameworks46>net46;netcoreapp2.0</RoslynPortableTargetFrameworks46>
<RoslynPortableTargetFrameworks>net46;netcoreapp2.0</RoslynPortableTargetFrameworks>
<RoslynPortableRuntimeIdentifiers>win;win-x64;linux-x64;osx-x64</RoslynPortableRuntimeIdentifiers>
<RoslynDesktopRuntimeIdentifier>win</RoslynDesktopRuntimeIdentifier>
<RoslynDesktopRuntimeIdentifierX86>win-x86</RoslynDesktopRuntimeIdentifierX86>
Expand Down
2 changes: 1 addition & 1 deletion build/ToolsetPackages/RoslynToolset.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="RoslynTools.ReferenceAssemblies" Version="$(RoslynToolsReferenceAssembliesVersion)" ExcludeAssets="all" />
<PackageReference Include="Microsoft.DiaSymReader.Pdb2Pdb" Version="$(MicrosoftDiaSymReaderPdb2PdbVersion)" ExcludeAssets="all" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
<PackageReference Include="FakeSign" Version="$(FakeSignVersion)" ExcludeAssets="all" />
<PackageReference Include="MicroBuild.Core.Sentinel" Version="$(MicroBuildCoreSentinelVersion)" ExcludeAssets="all" />
<PackageReference Include="MicroBuild.Core" Version="$(MicroBuildCoreVersion)" ExcludeAssets="all" />
Expand Down
11 changes: 9 additions & 2 deletions build/config/SignToolData.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"strongName": null,
"values": [
"Dlls\\ServicesTestUtilities\\Roslyn.Services.Test.Utilities.dll",
"Dlls\\TestUtilities\\net461\\Roslyn.Test.Utilities.dll",
"Dlls\\TestUtilities\\net46\\Roslyn.Test.Utilities.dll",
"Dlls\\VisualStudioIntegrationTestUtilities\\Microsoft.VisualStudio.IntegrationTest.Utilities.dll",
"Vsix\\VisualStudioIntegrationTestSetup\\Microsoft.VisualStudio.IntegrationTest.Setup.dll"
]
Expand Down Expand Up @@ -144,7 +144,9 @@
"Vsix\\VisualStudioSetup.Next\\Roslyn.VisualStudio.Setup.Next.vsix",
"Vsix\\VisualStudioSetup\\Roslyn.VisualStudio.Setup.vsix",
"Vsix\\Roslyn\\RoslynDeployment.vsix",
"Vsix\\VisualStudioIntegrationTestSetup\\Microsoft.VisualStudio.IntegrationTest.Setup.vsix"
"Vsix\\VisualStudioIntegrationTestSetup\\Microsoft.VisualStudio.IntegrationTest.Setup.vsix",
"Vsix\\CodeAnalysisCompilers\\Microsoft.CodeAnalysis.Compilers.vsix",
"Vsix\\PortableFacades\\PortableFacades.vsix"
]
},
{
Expand Down Expand Up @@ -224,14 +226,19 @@
"System.IO.Pipes.AccessControl.dll",
"System.IO.Pipes.dll",
"System.IO.dll",
"System.Net.Security.dll",
"System.Net.Sockets.dll",
"System.Reflection.Metadata.1.0.21.nupkg",
"System.Reflection.Metadata.dll",
"System.Reflection.TypeExtensions.dll",
"System.Reflection.dll",
"System.Resources.Reader.dll",
"System.Runtime.InteropServices.RuntimeInformation.dll",
"System.Runtime.Serialization.Primitives.dll",
"System.Security.AccessControl.dll",
"System.Security.Claims.dll",
"System.Security.Cryptography.Algorithms.dll",
"System.Security.Cryptography.Csp.dll",
"System.Security.Cryptography.Encoding.dll",
"System.Security.Cryptography.Primitives.dll",
"System.Security.Cryptography.X509Certificates.dll",
Expand Down
4 changes: 3 additions & 1 deletion build/scripts/build-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ function Ensure-NuGet() {
# Ensure the proper SDK in installed in our %PATH%. This is how MSBuild locates the
# SDK. Returns the location to the dotnet exe
function Ensure-DotnetSdk() {

# Check to see if the specified dotnet installations meets our build requirements
function Test-DotnetDir([string]$dotnetDir, [string]$runtimeVersion, [string]$sdkVersion) {
$sdkPath = Join-Path $dotnetDir "sdk\$sdkVersion"
Expand Down Expand Up @@ -180,6 +179,9 @@ function Ensure-DotnetSdk() {
Exec-Block { & $destFile -Version $sdkVersion -InstallDir $cliDir } | Out-Null
Exec-Block { & $destFile -Version $runtimeVersion -SharedRuntime -InstallDir $cliDir } | Out-Null
}
else {
${env:PATH} = "$cliDir;${env:PATH}"
}

return (Join-Path $cliDir "dotnet.exe")
}
Expand Down
9 changes: 8 additions & 1 deletion build/scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ function Restore-Packages() {
Write-Host "Restoring $($both[0])"
$projectFilePath = $both[1]
$projectFileName = [IO.Path]::GetFileNameWithoutExtension($projectFilePath)
$logFilePath = Join-Path $logsDir "Restore-$($projectFileName).binlog"
$logFilePath = ""
if ($binaryLog) {
$logFilePath = Join-Path $logsDir "Restore-$($projectFileName).binlog"
}
Restore-Project $dotnet $both[1] $logFilePath
}
}
Expand Down Expand Up @@ -283,6 +286,10 @@ function Build-ExtraSignArtifacts() {
Run-MSBuild "..\Compilers\Server\VBCSCompiler\VBCSCompiler.csproj" "/p:TargetFramework=netcoreapp2.0 /t:PublishWithoutBuilding"
Write-Host "Publishing MSBuildTask"
Run-MSBuild "..\Compilers\Core\MSBuildTask\MSBuildTask.csproj" "/p:TargetFramework=netcoreapp2.0 /t:PublishWithoutBuilding"
Write-Host "Building PortableFacades Swix"
Run-MSBuild "DevDivVsix\PortableFacades\PortableFacades.swixproj"
Write-Host "Building CompilersCodeAnalysis Swix"
Run-MSBuild "DevDivVsix\CompilersPackage\Microsoft.CodeAnalysis.Compilers.swixproj"

$dest = @($configDir)
foreach ($dir in $dest) {
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if [[ "${runtime}" == "dotnet" ]]; then
target_framework=netcoreapp2.0
xunit_console="${nuget_dir}"/xunit.runner.console/"${xunit_console_version}"/tools/${target_framework}/xunit.console.dll
elif [[ "${runtime}" == "mono" ]]; then
target_framework=net461
target_framework=net46
xunit_console="${nuget_dir}"/xunit.runner.console/"${xunit_console_version}"/tools/net452/xunit.console.exe
else
echo "Unknown runtime: ${runtime}"
Expand Down
33 changes: 26 additions & 7 deletions src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2328,8 +2328,20 @@ internal static uint GetValEscape(BoundExpression expr, uint scopeOfTheContainin
// Unsafe code will always be allowed to escape.
return Binder.ExternalScope;

case BoundKind.AsOperator:
case BoundKind.AwaitExpression:
case BoundKind.ConditionalAccess:
case BoundKind.NullCoalescingOperator:
case BoundKind.ArrayAccess:
// only possible in error cases (if possible at all)
return scopeOfTheContainingExpression;

default:
throw ExceptionUtilities.UnexpectedValue($"{expr.Kind} expression of {expr.Type} type");
// in error situations some unexpected nodes could make here
// returning "scopeOfTheContainingExpression" seems safer than throwing.
// we will still assert to make sure that all nodes are accounted for.
Debug.Assert(false, $"{expr.Kind} expression of {expr.Type} type");
return scopeOfTheContainingExpression;
}
}

Expand Down Expand Up @@ -2643,20 +2655,28 @@ internal static bool CheckValEscape(SyntaxNode node, BoundExpression expr, uint
var operandExpression = ((BoundPointerIndirectionOperator)expr).Operand;
return CheckValEscape(operandExpression.Syntax, operandExpression, escapeFrom, escapeTo, checkingReceiver, diagnostics);

case BoundKind.AsOperator:
case BoundKind.AwaitExpression:
case BoundKind.ConditionalAccess:
case BoundKind.NullCoalescingOperator:
case BoundKind.ArrayAccess:
// only possible in error cases (if possible at all)
return false;

default:
throw ExceptionUtilities.UnexpectedValue($"{expr.Kind} expression of {expr.Type} type");
// in error situations some unexpected nodes could make here
// returning "false" seems safer than throwing.
// we will still assert to make sure that all nodes are accounted for.
Debug.Assert(false, $"{expr.Kind} expression of {expr.Type} type");
return false;

#region "cannot produce ref-like values"
// case BoundKind.ThrowExpression:
// case BoundKind.ArgListOperator:
// case BoundKind.ArgList:
// case BoundKind.RefTypeOperator:
// case BoundKind.AddressOfOperator:
// case BoundKind.AsOperator:
// case BoundKind.TypeOfOperator:
// case BoundKind.ArrayAccess:
// case BoundKind.NullCoalescingOperator:
// case BoundKind.AwaitExpression:
// case BoundKind.IsOperator:
// case BoundKind.SizeOfOperator:
// case BoundKind.DynamicMemberAccess:
Expand All @@ -2674,7 +2694,6 @@ internal static bool CheckValEscape(SyntaxNode node, BoundExpression expr, uint
// case BoundKind.NoPiaObjectCreationExpression:
// case BoundKind.BaseReference:
// case BoundKind.Literal:
// case BoundKind.ConditionalAccess:
// case BoundKind.IsPatternExpression:
// case BoundKind.DeconstructionAssignmentOperator:
// case BoundKind.EventAccess:
Expand Down
63 changes: 37 additions & 26 deletions src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,50 +492,61 @@ private BoundStatement BindLocalFunctionStatement(LocalFunctionStatementSyntax n
var hasErrors = localSymbol.ScopeBinder
.ValidateDeclarationNameConflictsInScope(localSymbol, diagnostics);

BoundBlock block;
BoundBlock blockBody = null;
BoundBlock expressionBody = null;
if (node.Body != null)
{
block = BindEmbeddedBlock(node.Body, diagnostics);
blockBody = runAnalysis(BindEmbeddedBlock(node.Body, diagnostics), diagnostics);

if (node.ExpressionBody != null)
{
var expressionBodyDiagnostics = new DiagnosticBag();
expressionBody = runAnalysis(BindExpressionBodyAsBlock(node.ExpressionBody, expressionBodyDiagnostics), expressionBodyDiagnostics);
}
}
else if (node.ExpressionBody != null)
{
block = BindExpressionBodyAsBlock(node.ExpressionBody, diagnostics);
expressionBody = runAnalysis(BindExpressionBodyAsBlock(node.ExpressionBody, diagnostics), diagnostics);
}
else
{
block = null;
hasErrors = true;
diagnostics.Add(ErrorCode.ERR_LocalFunctionMissingBody, localSymbol.Locations[0], localSymbol);
}

if (block != null)
{
localSymbol.ComputeReturnType();

// Have to do ControlFlowPass here because in MethodCompiler, we don't call this for synthed methods
// rather we go directly to LowerBodyOrInitializer, which skips over flow analysis (which is in CompileMethod)
// (the same thing - calling ControlFlowPass.Analyze in the lowering - is done for lambdas)
// It's a bit of code duplication, but refactoring would make things worse.
var endIsReachable = ControlFlowPass.Analyze(localSymbol.DeclaringCompilation, localSymbol, block, diagnostics);
if (endIsReachable)
{
if (ImplicitReturnIsOkay(localSymbol))
{
block = FlowAnalysisPass.AppendImplicitReturn(block, localSymbol);
}
else
{
diagnostics.Add(ErrorCode.ERR_ReturnExpected, localSymbol.Locations[0], localSymbol);
}
}
}
Debug.Assert(blockBody != null || expressionBody != null || hasErrors);

localSymbol.GetDeclarationDiagnostics(diagnostics);

Symbol.CheckForBlockAndExpressionBody(
node.Body, node.ExpressionBody, node, diagnostics);

return new BoundLocalFunctionStatement(node, localSymbol, block, hasErrors);
return new BoundLocalFunctionStatement(node, localSymbol, blockBody, expressionBody, hasErrors);

BoundBlock runAnalysis(BoundBlock block, DiagnosticBag blockDiagnostics)
{
if (block != null)
{
// Have to do ControlFlowPass here because in MethodCompiler, we don't call this for synthed methods
// rather we go directly to LowerBodyOrInitializer, which skips over flow analysis (which is in CompileMethod)
// (the same thing - calling ControlFlowPass.Analyze in the lowering - is done for lambdas)
// It's a bit of code duplication, but refactoring would make things worse.
var endIsReachable = ControlFlowPass.Analyze(localSymbol.DeclaringCompilation, localSymbol, block, blockDiagnostics);
if (endIsReachable)
{
if (ImplicitReturnIsOkay(localSymbol))
{
block = FlowAnalysisPass.AppendImplicitReturn(block, localSymbol);
}
else
{
blockDiagnostics.Add(ErrorCode.ERR_ReturnExpected, localSymbol.Locations[0], localSymbol);
}
}
}

return block;
}
}

private bool ImplicitReturnIsOkay(MethodSymbol method)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.CodeAnalysis.CSharp
{
internal partial class BoundLocalFunctionStatement
{
public BoundBlock Body { get => BlockBody ?? ExpressionBody; }
}
}
3 changes: 2 additions & 1 deletion src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,8 @@
-->
<Node Name="BoundLocalFunctionStatement" Base="BoundStatement">
<Field Name="Symbol" Type="LocalFunctionSymbol"/>
<Field Name="Body" Type="BoundBlock" Null="allow"/>
<Field Name="BlockBody" Type="BoundBlock" Null="allow"/>
<Field Name="ExpressionBody" Type="BoundBlock" Null="allow"/>
</Node>

<!--
Expand Down
Loading