Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into merges/main-to-feat…
Browse files Browse the repository at this point in the history
…ures/interpolated-string

* upstream/main: (92 commits)
  Keep casts when necessary to prefer a constant pattern over a type pattern
  Remove SyntaxKind.DataKeyword (#53614)
  Display 'readonly' for record structs (#53634)
  Update Building, Debugging, and Testing on Windows.md (#53543)
  Update dependencies from https://github.com/dotnet/arcade build 20210521.3 (#53617)
  Introduce resx for BuildValidator and MS.CA.Rebuild to allow localization (#53447)
  Report obsoletion diagnostics for slice and indexer (#53463)
  Update BasicGenerateConstructorDialog.cs
  Add searchbox in generate overrides dialog
  Allow `with` on anonymous types (#53248)
  Report diagnostic on correct node (#53538)
  Fix NotNullIfNotNull delegate conversion (#53409)
  Verify quick info session in InvokeQuickInfo
  Remove unnecessary retry
  Ensure no navbar IO on the UI thread
  Enable nullable reference types
  Fix timeout behavior in GetQuickInfo
  Add a semantic model based GetQuickInfoAsync entry point into QuickInfoServiceWithProviders
  Move semantic model based quick info API up to CommonQuickInfoProvider type
  Fix dnceng build by forcing the use of xcopy msbuild
  ...
  • Loading branch information
333fred committed May 24, 2021
2 parents a520ef8 + 1a02675 commit 77ec844
Show file tree
Hide file tree
Showing 258 changed files with 8,588 additions and 1,939 deletions.
3 changes: 2 additions & 1 deletion azure-pipelines-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ stages:
- DotNetFramework
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: NetCoreInternal-Pool
queue: BuildPool.Windows.10.Amd64.VS2019.Pre
queue: BuildPool.Server.Amd64.VS2017

steps:
# Make sure our two pipelines generate builds with distinct build numbers to avoid confliction.
Expand All @@ -77,6 +77,7 @@ stages:
arguments: '-buildNumber $(Build.BuildNumber) -oddOrEven even'
${{ if eq(variables['System.TeamProject'], 'internal') }}:
arguments: '-buildNumber $(Build.BuildNumber) -oddOrEven odd'
condition: eq(variables['System.JobAttempt'], '1')

- powershell: Write-Host "##vso[task.setvariable variable=SourceBranchName]$('$(Build.SourceBranch)'.Substring('refs/heads/'.Length))"
displayName: Setting SourceBranchName variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ The minimal required version of .NET Framework is 4.7.2.

1. [Visual Studio 2019 16.9](https://visualstudio.microsoft.com/downloads/)
- Ensure C#, VB, MSBuild, .NET Core and Visual Studio Extensibility are included in the selected work loads
- Ensure Visual Studio is on Version "16.8" or greater
- Ensure Visual Studio is on Version "16.9" or greater
- Ensure "Use previews of the .NET Core SDK" is checked in Tools -> Options -> Environment -> Preview Features
- Restart Visual Studio
1. [.NET 6.0 Preview 1 SDK](https://dotnet.microsoft.com/download/dotnet-core/6.0) [Windows x64 installer](https://dotnet.microsoft.com/download/dotnet/thank-you/sdk-6.0.100-preview.1-windows-x64-installer)
1. [.NET 6.0 Preview 3 SDK](https://dotnet.microsoft.com/download/dotnet-core/6.0) [Windows x64 installer](https://dotnet.microsoft.com/download/dotnet/thank-you/sdk-6.0.100-preview.3-windows-x64-installer)
1. [PowerShell 5.0 or newer](https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell). If you are on Windows 10, you are fine; you'll only need to upgrade if you're on earlier versions of Windows. The download link is under the ["Upgrading existing Windows PowerShell"](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-windows-powershell?view=powershell-6#upgrading-existing-windows-powershell) heading.
1. Run Restore.cmd
1. Open Roslyn.sln
Expand Down Expand Up @@ -73,7 +73,7 @@ The Rosyln solution is designed to support easy debugging via F5. Several of ou
projects produce VSIX which deploy into Visual Studio during build. The F5 operation
will start a new Visual Studio instance using those VSIX which override our installed
binaries. This means trying out a change to the language, IDE or debugger is as
simple as hitting F5.
simple as hitting F5. Note that for changes to the compiler, out-of-process builds won't use the privately built version of the compiler.

The startup project needs to be set to `RoslynDeployment`. This should be
the default but in some cases will need to be set explicitly.
Expand Down
1 change: 1 addition & 0 deletions docs/contributing/Compiler Test Plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This document provides guidance for thinking about language interactions and tes
- VB/F# interop
- Performance and stress testing
- Can build VS
- Check that `Obsolete` is honored for members used in binding/lowering

# Type and members
- Access modifiers (public, protected, internal, protected internal, private protected, private), static, ref
Expand Down
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.21264.2">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.21271.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>42de78a825b575a1ddeb73020a01fb8cd9311d09</Sha>
<Sha>50f5645789f9119c906755cb1d2549acdeb0d0b7</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.0.0-2.21253.8">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5b972bceb846f5d15f991a479e285067a75103e4</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.21264.2">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.21271.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>42de78a825b575a1ddeb73020a01fb8cd9311d09</Sha>
<Sha>50f5645789f9119c906755cb1d2549acdeb0d0b7</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
-->
<PropertyGroup>
<BasicUndoVersion>0.9.3</BasicUndoVersion>
<BenchmarkDotNetVersion>0.12.1</BenchmarkDotNetVersion>
<BenchmarkDotNetDiagnosticsWindowsVersion>0.12.1</BenchmarkDotNetDiagnosticsWindowsVersion>
<BenchmarkDotNetVersion>0.13.0</BenchmarkDotNetVersion>
<BenchmarkDotNetDiagnosticsWindowsVersion>0.13.0</BenchmarkDotNetDiagnosticsWindowsVersion>
<DiffPlexVersion>1.4.4</DiffPlexVersion>
<EnvDTEVersion>$(MicrosoftVisualStudioShellPackagesVersion)</EnvDTEVersion>
<EnvDTE80Version>$(MicrosoftVisualStudioShellPackagesVersion)</EnvDTE80Version>
Expand Down
8 changes: 8 additions & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ function TestUsingRunTests() {
}
}

if ($ci) {
$env:ROSLYN_TEST_CI = "true"
}

if ($testIOperation) {
$env:ROSLYN_TEST_IOPERATION = "true"
}
Expand Down Expand Up @@ -455,6 +459,10 @@ function TestUsingRunTests() {
Exec-Console $dotnetExe "$runTests $args"
} finally {
Get-Process "xunit*" -ErrorAction SilentlyContinue | Stop-Process
if ($ci) {
Remove-Item env:\ROSLYN_TEST_CI
}

if ($testIOperation) {
Remove-Item env:\ROSLYN_TEST_IOPERATION
}
Expand Down
12 changes: 6 additions & 6 deletions eng/common/generate-locproject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $ErrorActionPreference = "Stop"

Import-Module -Name (Join-Path $PSScriptRoot 'native\CommonLibrary.psm1')

$exclusionsFilePath = "$SourcesDirectory\Localize\LocExclusions.json"
$exclusionsFilePath = "$SourcesDirectory\eng\Localize\LocExclusions.json"
$exclusions = @{ Exclusions = @() }
if (Test-Path -Path $exclusionsFilePath)
{
Expand Down Expand Up @@ -92,14 +92,14 @@ Write-Host "LocProject.json generated:`n`n$json`n`n"
Pop-Location

if (!$UseCheckedInLocProjectJson) {
New-Item "$SourcesDirectory\Localize\LocProject.json" -Force # Need this to make sure the Localize directory is created
Set-Content "$SourcesDirectory\Localize\LocProject.json" $json
New-Item "$SourcesDirectory\eng\Localize\LocProject.json" -Force # Need this to make sure the Localize directory is created
Set-Content "$SourcesDirectory\eng\Localize\LocProject.json" $json
}
else {
New-Item "$SourcesDirectory\Localize\LocProject-generated.json" -Force # Need this to make sure the Localize directory is created
Set-Content "$SourcesDirectory\Localize\LocProject-generated.json" $json
New-Item "$SourcesDirectory\eng\Localize\LocProject-generated.json" -Force # Need this to make sure the Localize directory is created
Set-Content "$SourcesDirectory\eng\Localize\LocProject-generated.json" $json

if ((Get-FileHash "$SourcesDirectory\Localize\LocProject-generated.json").Hash -ne (Get-FileHash "$SourcesDirectory\Localize\LocProject.json").Hash) {
if ((Get-FileHash "$SourcesDirectory\eng\Localize\LocProject-generated.json").Hash -ne (Get-FileHash "$SourcesDirectory\eng\Localize\LocProject.json").Hash) {
Write-PipelineTelemetryError -Category "OneLocBuild" -Message "Existing LocProject.json differs from generated LocProject.json. Download LocProject-generated.json and compare them."

exit 1
Expand Down
4 changes: 2 additions & 2 deletions eng/common/templates/job/onelocbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
locProj: Localize/LocProject.json
locProj: eng/Localize/LocProject.json
outDir: $(Build.ArtifactStagingDirectory)
lclSource: ${{ parameters.LclSource }}
lclPackageId: ${{ parameters.LclPackageId }}
Expand All @@ -79,7 +79,7 @@ jobs:
- task: PublishBuildArtifacts@1
displayName: Publish LocProject.json
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/Localize/'
PathtoPublish: '$(Build.SourcesDirectory)/eng/Localize/'
PublishLocation: Container
ArtifactName: Loc
condition: ${{ parameters.condition }}
28 changes: 3 additions & 25 deletions eng/config/PublishData.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"vsBranch": "rel/d16.11",
"vsMajorVersion": 16
},
"main-vs-deps": {
"release/dev17.0-preview1-vs-deps": {
"nugetKind": [
"Shipping",
"NonShipping"
Expand All @@ -197,18 +197,7 @@
"vsBranch": "main",
"vsMajorVersion": 17
},
"release/dev17.0-preview1-nopia-vs-deps": {
"nugetKind": [
"Shipping",
"NonShipping"
],
"version": "4.0.*",
"packageFeeds": "default",
"channels": [],
"vsBranch": "feature/d17initial",
"vsMajorVersion": 17
},
"release/dev17.0-preview1-vs-deps": {
"main-vs-deps": {
"nugetKind": [
"Shipping",
"NonShipping"
Expand All @@ -219,17 +208,6 @@
"vsBranch": "feature/d17initial",
"vsMajorVersion": 17
},
"release/dev17.0-vs-deps": {
"nugetKind": [
"Shipping",
"NonShipping"
],
"version": "4.0.*",
"packageFeeds": "default",
"channels": [],
"vsBranch": "main",
"vsMajorVersion": 17
},
"main": {
"nugetKind": [
"Shipping",
Expand All @@ -238,7 +216,7 @@
"version": "4.0.*",
"packageFeeds": "arcade",
"channels": [],
"vsBranch": "main",
"vsBranch": "feature/d17initial",
"vsMajorVersion": 17
},
"features/NullableReferenceTypes": {
Expand Down
9 changes: 0 additions & 9 deletions eng/targets/Imports.targets
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@
-->
<RoslynCheckCodeStyle Condition="'$(RoslynCheckCodeStyle)' == '' AND '$(DisableNullableWarnings)' == 'true'">false</RoslynCheckCodeStyle>
<RoslynCheckCodeStyle Condition="'$(RoslynCheckCodeStyle)' == '' AND ('$(ContinuousIntegrationBuild)' != 'true' OR '$(RoslynEnforceCodeStyle)' == 'true')">true</RoslynCheckCodeStyle>

<!--
When markup compilation is involved, WPF generates .g.cs files via the GenerateTemporaryTargetAssembly task.
These do not always have the correct full-paths to their respective .xaml files annotated in them in the #line directives.
This can cause compile errors if these files are included in Source Link.
https://github.com/dotnet/wpf/issues/1718
-->
<EmbedUntrackedSources Condition="$(UseWpf) == 'true'">false</EmbedUntrackedSources>
<EmbedUntrackedSources Condition="$(EmbedUntrackedSources) == ''">true</EmbedUntrackedSources>
</PropertyGroup>

<!--
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"xcopy-msbuild": "16.8.0-preview2.1"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21264.2",
"Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.21264.2"
"Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21271.3",
"Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.21271.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.LanguageServices;
using Microsoft.CodeAnalysis.CSharp.Precedence;
Expand All @@ -24,19 +25,20 @@ protected override ISyntaxFacts GetSyntaxFacts()
=> CSharpSyntaxFacts.Instance;

protected override bool CanRemoveParentheses(
ParenthesizedExpressionSyntax parenthesizedExpression, SemanticModel semanticModel,
ParenthesizedExpressionSyntax parenthesizedExpression,
SemanticModel semanticModel, CancellationToken cancellationToken,
out PrecedenceKind precedence, out bool clarifiesPrecedence)
{
return CanRemoveParenthesesHelper(
parenthesizedExpression, semanticModel,
parenthesizedExpression, semanticModel, cancellationToken,
out precedence, out clarifiesPrecedence);
}

public static bool CanRemoveParenthesesHelper(
ParenthesizedExpressionSyntax parenthesizedExpression, SemanticModel semanticModel,
ParenthesizedExpressionSyntax parenthesizedExpression, SemanticModel semanticModel, CancellationToken cancellationToken,
out PrecedenceKind parentPrecedenceKind, out bool clarifiesPrecedence)
{
var result = parenthesizedExpression.CanRemoveParentheses(semanticModel);
var result = parenthesizedExpression.CanRemoveParentheses(semanticModel, cancellationToken);
if (!result)
{
parentPrecedenceKind = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.LanguageServices;
using Microsoft.CodeAnalysis.CSharp.Precedence;
Expand All @@ -24,17 +25,15 @@ protected override ISyntaxFacts GetSyntaxFacts()
=> CSharpSyntaxFacts.Instance;

protected override bool CanRemoveParentheses(
ParenthesizedPatternSyntax parenthesizedExpression, SemanticModel semanticModel,
ParenthesizedPatternSyntax parenthesizedExpression,
SemanticModel semanticModel, CancellationToken cancellationToken,
out PrecedenceKind precedence, out bool clarifiesPrecedence)
{
return CanRemoveParenthesesHelper(
parenthesizedExpression,
out precedence, out clarifiesPrecedence);
return CanRemoveParenthesesHelper(parenthesizedExpression, out precedence, out clarifiesPrecedence);
}

public static bool CanRemoveParenthesesHelper(
ParenthesizedPatternSyntax parenthesizedPattern,
out PrecedenceKind parentPrecedenceKind, out bool clarifiesPrecedence)
ParenthesizedPatternSyntax parenthesizedPattern, out PrecedenceKind parentPrecedenceKind, out bool clarifiesPrecedence)
{
var result = parenthesizedPattern.CanRemoveParentheses();
if (!result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ private static void HandleSingleIfStatementForm(
}

newStatement = newStatement.WithAdditionalAnnotations(Formatter.Annotation);
newStatement = AppendTriviaWithoutEndOfLines(newStatement, ifStatement);

cancellationToken.ThrowIfCancellationRequested();

editor.ReplaceNode(ifStatement, newStatement);
Expand Down Expand Up @@ -143,12 +145,24 @@ private static void HandleVariableAndIfStatementForm(
SyntaxFactory.MemberBindingExpression(SyntaxFactory.IdentifierName(nameof(Action.Invoke))), invocationExpression.ArgumentList)));

newStatement = newStatement.WithAdditionalAnnotations(Formatter.Annotation);
newStatement = AppendTriviaWithoutEndOfLines(newStatement, ifStatement);

editor.ReplaceNode(ifStatement, newStatement);
editor.RemoveNode(localDeclarationStatement, SyntaxRemoveOptions.KeepLeadingTrivia | SyntaxRemoveOptions.AddElasticMarker);
cancellationToken.ThrowIfCancellationRequested();
}

private static T AppendTriviaWithoutEndOfLines<T>(T newStatement, IfStatementSyntax ifStatement) where T : SyntaxNode
{
// We're combining trivia from the delegate invocation and the end of the if statement
// but we don't want two EndOfLines so we ignore the one on the invocation (if it exists)
var expressionTrivia = newStatement.GetTrailingTrivia();
var expressionTriviaWithoutEndOfLine = expressionTrivia.Where(t => !t.IsKind(SyntaxKind.EndOfLineTrivia));
var ifStatementTrivia = ifStatement.GetTrailingTrivia();

return newStatement.WithTrailingTrivia(expressionTriviaWithoutEndOfLine.Concat(ifStatementTrivia));
}

private class MyCodeAction : CustomCodeActions.DocumentChangeAction
{
public MyCodeAction(Func<CancellationToken, Task<Document>> createChangedDocument)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using System.Composition;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.RemoveUnnecessaryParentheses;
Expand All @@ -22,10 +23,10 @@ public CSharpRemoveUnnecessaryParenthesesCodeFixProvider()
{
}

protected override bool CanRemoveParentheses(SyntaxNode current, SemanticModel semanticModel)
protected override bool CanRemoveParentheses(SyntaxNode current, SemanticModel semanticModel, CancellationToken cancellationToken)
=> current switch
{
ParenthesizedExpressionSyntax p => CSharpRemoveUnnecessaryExpressionParenthesesDiagnosticAnalyzer.CanRemoveParenthesesHelper(p, semanticModel, out _, out _),
ParenthesizedExpressionSyntax p => CSharpRemoveUnnecessaryExpressionParenthesesDiagnosticAnalyzer.CanRemoveParenthesesHelper(p, semanticModel, cancellationToken, out _, out _),
ParenthesizedPatternSyntax p => CSharpRemoveUnnecessaryPatternParenthesesDiagnosticAnalyzer.CanRemoveParenthesesHelper(p, out _, out _),
_ => false,
};
Expand Down
Loading

0 comments on commit 77ec844

Please sign in to comment.