Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/features/required-members' int…
Browse files Browse the repository at this point in the history
…o enforce-setting

* upstream/features/required-members: (78 commits)
  [main] Update dependencies from dotnet/roslyn (dotnet#59792)
  Annotate BreakpointSpans and fix NREs (dotnet#59846)
  Editor namespaces refactoring - part 1 (dotnet#59907)
  [main] Update dependencies from dotnet/source-build-externals (dotnet#59845)
  Update PublishData.json (dotnet#59952)
  ...and the comment
  Revert the last change in the compiler layer
  Force SVsExtensionManager to load before InProcComponent creation
  Handle nameof situation, moved logic back to workspaces layer
  Add back OmniSharpInlineHints (dotnet#59941)
  Initialize AsyncCompletionTracker in a fire-and-forget manner
  Try to load the extension manager from the main thread as well
  Use the correct GUID for SVsUserNotificationsService
  Update CodeStyle/format/SDK versions (dotnet#59903)
  Create attribute default arguments during binding (dotnet#59750)
  Undo refactoring part 2
  Undo refactoring
  Move logic of symbol filtering to compiling layer. Refactoring
  Clean up diagnostic and solution crawler options - take 2 (dotnet#59233)
  Add quotes in string for clarity
  ...
  • Loading branch information
333fred committed Mar 15, 2022
2 parents 2ca360a + 44f9669 commit 07c1413
Show file tree
Hide file tree
Showing 541 changed files with 4,760 additions and 2,154 deletions.
14 changes: 1 addition & 13 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,4 @@ FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}

# Set up machine requirements to build the repo
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends cmake llvm-9 clang-9 \
build-essential python curl git lldb-6.0 liblldb-6.0-dev \
libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev \
libssl-dev libnuma-dev libkrb5-dev zlib1g-dev ninja-build

# Install V8 Engine
SHELL ["/bin/bash", "-c"]

RUN curl -sSL "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/linux/chromium-v8/v8-linux64-rel-8.5.183.zip" -o ./v8.zip \
&& unzip ./v8.zip -d /usr/local/v8 \
&& echo $'#!/usr/bin/env bash\n\
"/usr/local/v8/d8" --snapshot_blob="/usr/local/v8/snapshot_blob.bin" "$@"\n' > /usr/local/bin/v8 \
&& chmod +x /usr/local/bin/v8
&& apt-get -y install --no-install-recommends curl git
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ src/Compilers/**/PublicAPI.Unshipped.txt @dotnet/roslyn-api-owners
src/Workspaces/**/PublicAPI.Unshipped.txt @dotnet/roslyn-api-owners
src/Features/**/PublicAPI.Unshipped.txt @dotnet/roslyn-api-owners
src/EditorFeatures/**/PublicAPI.Unshipped.txt @dotnet/roslyn-api-owners

src/Tools/ExternalAccess/OmniSharp*/ @333fred @joerobich
8 changes: 8 additions & 0 deletions docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,11 @@ https://github.com/dotnet/roslyn/issues/57750
public S() { Y = 0; } // ok
}
```

7. <a name="7"></a>Before Visual Studio 17.2, the C# compiler would accept incorrect default argument values involving a reference conversion of a string constant, and would emit `null` as the constant value instead of the default value specified in source. In Visual Studio 17.2, this becomes an error. See [roslyn#59806](https://github.com/dotnet/roslyn/pull/59806).
For instance, the following results in an error in 17.2:
```csharp
void M(IEnumerable<char> s = "hello")
```

3 changes: 2 additions & 1 deletion docs/contributing/Compiler Test Plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ This document provides guidance for thinking about language interactions and tes

# General concerns:
- Completeness of the specification as a guide for testing (is the spec complete enough to suggest what the compiler should do in each scenario?)
- Other external documentation
- *Ping* for new breaking changes and general ping for partner teams (Bill, Kathleen, Mads, IDE, Razor)
- Help review external documentation
- Backward and forward compatibility (interoperation with previous and future compilers, each in both directions)
- Error handling/recovery (missing libraries, including missing types in mscorlib; errors in parsing, ambiguous lookup, inaccessible lookup, wrong kind of thing found, instance vs static thing found, wrong type for the context, value vs variable)
- BCL (including mono) and other customer impact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
2. Each IDE diagnostic ID has a dedicated documentation page. For example:
1. Diagnostic with code style option: <https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0011>
2. Diagnostic without code style option: <https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0004>
3. Multiple diagnostic IDs sharing the same option(s): <https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0003-ide0009>
3. Multiple diagnostic IDs sharing the same option(s): <https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0003-ide0009>. In this case, a [redirection](https://github.com/dotnet/docs/blob/7ae7272d643aa1c6db96cad8d09d4c2332855960/.openpublishing.redirection.fundamentals.json#L11-L14) for all diagnostic IDs must be added.

3. We have tabular indices for IDE diagnostic IDs and code style options for easier reference and navigation:
1. Primary index (rule ID + code style options): <https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/>
Expand All @@ -20,14 +20,14 @@

Roslyn IDE team (@dotnet/roslyn-ide) is responsible for ensuring that the documentation for IDE analyzers is up-to-date. Whenever we add a new IDE analyzer, add new code style option(s) OR update semantics of existing IDE analyzers the following needs to be done:

1. **Action required in [dotnet\docs](https://github.com/dotnet/docs) repo**:
1. **Action required in [dotnet/docs](https://github.com/dotnet/docs) repo**:
1. If you _creating a Roslyn PR for an IDE analyzer_:
1. Please follow the steps at [Contribute docs for 'IDExxxx' rules](https://docs.microsoft.com/contribute/dotnet/dotnet-contribute-code-analysis#contribute-docs-for-idexxxx-rules) to add documentation for IDE analyzers to [dotnet\docs](https://github.com/dotnet/docs) repo.
1. Please follow the steps at [Contribute docs for 'IDExxxx' rules](https://docs.microsoft.com/contribute/dotnet/dotnet-contribute-code-analysis#contribute-docs-for-idexxxx-rules) to add documentation for IDE analyzers to [dotnet/docs](https://github.com/dotnet/docs) repo.
2. Ideally, the documentation PR should be created in parallel to the Roslyn PR or immediately following the approval/merge of Roslyn PR.
2. If you are _reviewing a Roslyn PR for an IDE analyzer_:
1. Please ensure that the analyzer author is made aware of the above doc contribution requirements, especially if it is a community PR.
2. If the documentation PR in is not being created in parallel to the Roslyn PR, please ensure that a [new doc issue](https://github.com/dotnet/docs/issues) is filed in `dotnet/docs` repo to track this work.

2. **No action required in Roslyn repo**: Help links have been hooked up to IDE code style analyzers in Roslyn repo in the base analyzer types, so every new IDE analyzer diagnostic ID will automatically have `https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ideXXXX` as its help link. There is no action required on the Roslyn PR to ensure this linking.

If you feel any of the existing IDE rule docs have insufficient or incorrect information, please submit a PR to [dotnet\docs](https://github.com/dotnet/docs) repo to update the documentation.
If you feel any of the existing IDE rule docs have insufficient or incorrect information, please submit a PR to [dotnet/docs](https://github.com/dotnet/docs) repo to update the documentation.
2 changes: 1 addition & 1 deletion dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"isRoot": true,
"tools": {
"dotnet-format": {
"version": "6.0.257007",
"version": "6.2.315104",
"commands": [
"dotnet-format"
]
Expand Down
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Sha>7e80445ee82adbf9a8e6ae601ac5e239d982afaa</Sha>
<SourceBuild RepoName="xliff-tasks" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="7.0.0-alpha.1.22114.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="7.0.0-alpha.1.22154.1">
<Uri>https://github.com/dotnet/source-build-externals</Uri>
<Sha>a28332454bd70964205fb18bf3d0a1146a228b25</Sha>
<Sha>c349f5f0326edcd47b302a8c6731fc3c7ae7a1ef</Sha>
<SourceBuild RepoName="source-build-externals" ManagedOnly="true" />
</Dependency>
</ProductDependencies>
Expand All @@ -18,9 +18,9 @@
<Sha>68a9b6dc9c0f375893fcdab74b7dd2538afb1c4b</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.1.0-3.22075.3">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.1.0-5.22128.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>592501cbb9c9394072a245c15b3458ff88155d85</Sha>
<Sha>5d10d428050c0d6afef30a072c4ae68776621877</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="7.0.0-beta.22122.3">
<Uri>https://github.com/dotnet/arcade</Uri>
Expand Down
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<MajorVersion>4</MajorVersion>
<MinorVersion>2</MinorVersion>
<PatchVersion>0</PatchVersion>
<PreReleaseVersionLabel>2</PreReleaseVersionLabel>
<PreReleaseVersionLabel>3</PreReleaseVersionLabel>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<!--
By default the assembly version in official builds is "$(MajorVersion).$(MinorVersion).0.0".
Keep the setting conditional. The toolset sets the assembly version to 42.42.42.42 if not set explicitly.
-->
<AssemblyVersion Condition="'$(OfficialBuild)' == 'true' or '$(DotNetUseShippingVersions)' == 'true'">$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
<MicrosoftNetCompilersToolsetVersion>4.1.0-3.22075.3</MicrosoftNetCompilersToolsetVersion>
<MicrosoftNetCompilersToolsetVersion>4.1.0-5.22128.4</MicrosoftNetCompilersToolsetVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Versions used by several individual references below -->
Expand All @@ -24,7 +24,7 @@
<MicrosoftCodeAnalysisTestingVersion>1.1.2-beta1.22122.4</MicrosoftCodeAnalysisTestingVersion>
<MicrosoftVisualStudioExtensibilityTestingVersion>0.1.127-beta</MicrosoftVisualStudioExtensibilityTestingVersion>
<!-- CodeStyleAnalyzerVersion should we updated together with version of dotnet-format in dotnet-tools.json -->
<CodeStyleAnalyzerVersion>4.0.1</CodeStyleAnalyzerVersion>
<CodeStyleAnalyzerVersion>4.1.0</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>16.10.230</VisualStudioEditorPackagesVersion>
<VisualStudioEditorNewPackagesVersion>17.0.487</VisualStudioEditorNewPackagesVersion>
<ILAsmPackageVersion>5.0.0-alpha1.19409.1</ILAsmPackageVersion>
Expand Down
18 changes: 16 additions & 2 deletions eng/config/PublishData.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,9 @@
"packageFeeds": "default",
"channels": [],
"vsBranch": "rel/d17.2",
"insertionCreateDraftPR": true,
"vsMajorVersion": 17,
"insertionTitlePrefix": "[d17.2p1]"
"insertionTitlePrefix": "[d17.2p2]"
},
"main": {
"nugetKind": [
Expand All @@ -235,7 +236,20 @@
"vsBranch": "main",
"vsMajorVersion": 17,
"insertionCreateDraftPR": false,
"insertionTitlePrefix": "[d17.2p2]"
"insertionTitlePrefix": "[d17.2p3]"
},
"release/dev17.3": {
"nugetKind": [
"Shipping",
"NonShipping"
],
"version": "4.3.*",
"packageFeeds": "default",
"channels": [],
"vsBranch": "main",
"vsMajorVersion": 17,
"insertionCreateDraftPR": true,
"insertionTitlePrefix": "[d17.3p1]"
},
"features/NullableReferenceTypes": {
"nugetKind": "PerBuildPreRelease",
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/test-integration-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ steps:
condition: not(succeeded())

- task: PublishBuildArtifacts@1
displayName: Publish Screenshots
displayName: Publish Screenshots and Test Attachments
inputs:
PathtoPublish: '$(Build.SourcesDirectory)\artifacts\bin\Microsoft.VisualStudio.LanguageServices.IntegrationTests\${{ parameters.configuration }}\net472\xUnitResults'
PathtoPublish: '$(Build.SourcesDirectory)\artifacts\bin\Microsoft.VisualStudio.LanguageServices.IntegrationTests\${{ parameters.configuration }}\net472\TestResults'
ArtifactName: '$(System.JobAttempt)-Screenshots ${{ parameters.configuration }} OOP64_${{ parameters.oop64bit }} OOPCoreClr_${{ parameters.oopCoreClr }} LspEditor_${{ parameters.lspEditor }} $(Build.BuildNumber)'
publishLocation: Container
continueOnError: true
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"sdk": {
"version": "6.0.100",
"version": "6.0.200",
"allowPrerelease": true,
"rollForward": "latestPatch"
},
"tools": {
"dotnet": "6.0.100",
"dotnet": "6.0.200",
"vs": {
"version": "16.10"
},
Expand Down
4 changes: 1 addition & 3 deletions src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<Compile Include="$(MSBuildThisFileDirectory)SimplifyInterpolation\CSharpSimplifyInterpolationCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyLinqExpression\CSharpSimplifyLinqExpressionCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyPropertyPattern\CSharpSimplifyPropertyPatternCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\CSharpUseCollectionInitializerCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCompoundAssignment\CSharpUseCompoundAssignmentCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs" />
Expand Down Expand Up @@ -79,7 +80,4 @@
<ItemGroup Condition="'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'">
<ExpectedCompile Include="$(MSBuildThisFileDirectory)**\*$(DefaultLanguageSourceExtension)" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)ConvertNamespace\" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions src/Analyzers/CSharp/CodeFixes/CSharpCodeFixesResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,7 @@
<data name="Place_colon_on_following_line" xml:space="preserve">
<value>Place colon on following line</value>
</data>
<data name="Fix_record_declaration" xml:space="preserve">
<value>Fix_record_declaration</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;

namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.TransposeRecordKeyword
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.TransposeRecordKeyword), Shared]
internal class CSharpTransposeRecordKeywordCodeFixProvider : SyntaxEditorBasedCodeFixProvider
{
private const string CS9012 = nameof(CS9012); // Unexpected keyword 'record'. Did you mean 'record struct' or 'record class'?

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpTransposeRecordKeywordCodeFixProvider()
{
}

public override ImmutableArray<string> FixableDiagnosticIds
=> ImmutableArray.Create(CS9012);

internal override CodeFixCategory CodeFixCategory
=> CodeFixCategory.Compile;

private static bool TryGetRecordDeclaration(
Diagnostic diagnostic, CancellationToken cancellationToken, [NotNullWhen(true)] out RecordDeclarationSyntax? recordDeclaration)
{
recordDeclaration = diagnostic.Location.FindNode(cancellationToken) as RecordDeclarationSyntax;
return recordDeclaration != null;
}

private static bool TryGetTokens(
RecordDeclarationSyntax recordDeclaration,
out SyntaxToken classOrStructKeyword,
out SyntaxToken recordKeyword)
{
recordKeyword = recordDeclaration.Keyword;
if (!recordKeyword.IsMissing)
{
var leadingTrivia = recordKeyword.LeadingTrivia;
var skippedTriviaIndex = leadingTrivia.IndexOf(SyntaxKind.SkippedTokensTrivia);
if (skippedTriviaIndex >= 0)
{
var skippedTrivia = leadingTrivia[skippedTriviaIndex];
var structure = (SkippedTokensTriviaSyntax)skippedTrivia.GetStructure()!;
var tokens = structure.Tokens;
if (tokens.Count == 1)
{
classOrStructKeyword = tokens.Single();
if (classOrStructKeyword.Kind() is SyntaxKind.ClassKeyword or SyntaxKind.StructKeyword)
{
// Because the class/struct keyword is skipped trivia on the record keyword, it will
// not have trivia of it's own. So we need to move the other trivia appropriate trivia
// on the record keyword to it.
var remainingLeadingTrivia = SyntaxFactory.TriviaList(leadingTrivia.Skip(skippedTriviaIndex + 1));
var trailingTriviaTakeUntil = remainingLeadingTrivia.IndexOf(SyntaxKind.EndOfLineTrivia) is >= 0 and var eolIndex
? eolIndex + 1
: remainingLeadingTrivia.Count;

classOrStructKeyword = classOrStructKeyword
.WithLeadingTrivia(SyntaxFactory.TriviaList(remainingLeadingTrivia.Skip(trailingTriviaTakeUntil)))
.WithTrailingTrivia(recordKeyword.TrailingTrivia);
recordKeyword = recordKeyword
.WithLeadingTrivia(leadingTrivia.Take(skippedTriviaIndex))
.WithTrailingTrivia(SyntaxFactory.TriviaList(remainingLeadingTrivia.Take(trailingTriviaTakeUntil)));

return true;
}
}
}
}

classOrStructKeyword = default;
return false;
}

public override Task RegisterCodeFixesAsync(CodeFixContext context)
{
var document = context.Document;
var cancellationToken = context.CancellationToken;

var diagnostic = context.Diagnostics.First();
if (TryGetRecordDeclaration(diagnostic, cancellationToken, out var recordDeclaration) &&
TryGetTokens(recordDeclaration, out _, out _))
{
context.RegisterCodeFix(
new MyCodeAction(c => this.FixAsync(document, diagnostic, c)),
diagnostic);
}

return Task.CompletedTask;
}

protected override Task FixAllAsync(
Document document, ImmutableArray<Diagnostic> diagnostics,
SyntaxEditor editor, CancellationToken cancellationToken)
{
foreach (var diagnostic in diagnostics)
{
if (TryGetRecordDeclaration(diagnostic, cancellationToken, out var recordDeclaration))
{
editor.ReplaceNode(
recordDeclaration,
(current, _) =>
{
var currentRecordDeclaration = (RecordDeclarationSyntax)current;
if (!TryGetTokens(currentRecordDeclaration, out var classOrStructKeyword, out var recordKeyword))
return currentRecordDeclaration;

return currentRecordDeclaration
.WithClassOrStructKeyword(classOrStructKeyword)
.WithKeyword(recordKeyword);
});
}
}

return Task.CompletedTask;
}

private class MyCodeAction : CustomCodeActions.DocumentChangeAction
{
public MyCodeAction(
Func<CancellationToken, Task<Document>> createChangedDocument)
: base(CSharpCodeFixesResources.Fix_record_declaration, createChangedDocument, nameof(CSharpTransposeRecordKeywordCodeFixProvider))
{
}
}
}
}

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

Loading

0 comments on commit 07c1413

Please sign in to comment.