diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index ec7389aa47b53..e21f50d218c4c 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,9 +7,9 @@ https://github.com/dotnet/arcade 0ca849f0b71866b007fedaaa938cee63f8d056a6 - + https://github.com/dotnet/roslyn - 9b40ab852a3b59ce9cef33b3e97c17af13c8e694 + 5b972bceb846f5d15f991a479e285067a75103e4 https://github.com/dotnet/arcade diff --git a/eng/Versions.props b/eng/Versions.props index 46d7855df35cb..85a993e433bd0 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -23,7 +23,7 @@ - 3.10.0-3.21223.23 + 4.0.0-2.21253.8 diff --git a/src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs b/src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs index 4af6c89fe02ca..326a0fc2cdb94 100644 --- a/src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs +++ b/src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs @@ -38,6 +38,40 @@ class C VerifyTypingCharacter(code, expected); } + [WpfFact, Trait(Traits.Feature, Traits.Features.DocumentationComments)] + public void TypingCharacter_Record() + { + var code = +@"//$$ +record R;"; + + var expected = +@"/// +/// $$ +/// +record R;"; + + VerifyTypingCharacter(code, expected); + } + + [WpfFact, Trait(Traits.Feature, Traits.Features.DocumentationComments)] + public void TypingCharacter_RecordWithPositionalParameters() + { + var code = +@"//$$ +record R(string S, int I);"; + + var expected = +@"/// +/// $$ +/// +/// +/// +record R(string S, int I);"; + + VerifyTypingCharacter(code, expected); + } + [WpfFact, Trait(Traits.Feature, Traits.Features.DocumentationComments)] public void TypingCharacter_Class_NewLine() { @@ -1467,6 +1501,36 @@ class C VerifyInsertCommentCommand(code, expected); } + [WpfFact, Trait(Traits.Feature, Traits.Features.DocumentationComments)] + public void Command_Record() + { + var code = "record R$$;"; + + var expected = +@"/// +/// $$ +/// +record R;"; + + VerifyInsertCommentCommand(code, expected); + } + + [WpfFact, Trait(Traits.Feature, Traits.Features.DocumentationComments)] + public void Command_RecordWithPositionalParameters() + { + var code = "record R$$(string S, int I);"; + + var expected = +@"/// +/// $$ +/// +/// +/// +record R(string S, int I);"; + + VerifyInsertCommentCommand(code, expected); + } + [WorkItem(4817, "https://github.com/dotnet/roslyn/issues/4817")] [WpfFact, Trait(Traits.Feature, Traits.Features.DocumentationComments)] public void Command_Class_AutoGenerateXmlDocCommentsOff() diff --git a/src/Features/CSharp/Portable/DocumentationComments/DocumentationCommentSnippetService.cs b/src/Features/CSharp/Portable/DocumentationComments/DocumentationCommentSnippetService.cs index 079e46c889145..53dcae7f19d17 100644 --- a/src/Features/CSharp/Portable/DocumentationComments/DocumentationCommentSnippetService.cs +++ b/src/Features/CSharp/Portable/DocumentationComments/DocumentationCommentSnippetService.cs @@ -39,6 +39,7 @@ protected override bool SupportsDocumentationComments(MemberDeclarationSyntax me switch (member.Kind()) { case SyntaxKind.ClassDeclaration: + case SyntaxKind.RecordDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.StructDeclaration: case SyntaxKind.DelegateDeclaration: diff --git a/src/Workspaces/Core/Portable/LinkedFileDiffMerging/DefaultDocumentTextDifferencingService.cs b/src/Workspaces/Core/Portable/LinkedFileDiffMerging/DefaultDocumentTextDifferencingService.cs index b499fa50fc95e..941a4c1ecffd1 100644 --- a/src/Workspaces/Core/Portable/LinkedFileDiffMerging/DefaultDocumentTextDifferencingService.cs +++ b/src/Workspaces/Core/Portable/LinkedFileDiffMerging/DefaultDocumentTextDifferencingService.cs @@ -2,8 +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. -#nullable disable - +using System; using System.Collections.Immutable; using System.Composition; using System.Diagnostics.CodeAnalysis; @@ -18,7 +17,7 @@ namespace Microsoft.CodeAnalysis internal class DefaultDocumentTextDifferencingService : IDocumentTextDifferencingService { [ImportingConstructor] - [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Incorrectly used in production code: https://github.com/dotnet/roslyn/issues/42839")] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public DefaultDocumentTextDifferencingService() { } diff --git a/src/Workspaces/Core/Portable/LinkedFileDiffMerging/LinkedFileDiffMergingSession.cs b/src/Workspaces/Core/Portable/LinkedFileDiffMerging/LinkedFileDiffMergingSession.cs index 7db0a8f527a14..18e31f305fcdc 100644 --- a/src/Workspaces/Core/Portable/LinkedFileDiffMerging/LinkedFileDiffMergingSession.cs +++ b/src/Workspaces/Core/Portable/LinkedFileDiffMerging/LinkedFileDiffMergingSession.cs @@ -85,7 +85,7 @@ private async Task MergeLinkedDocumentGroupAsync( // Automatically merge non-conflicting diffs while collecting the conflicting diffs - var textDifferencingService = _oldSolution.Workspace.Services.GetService() ?? new DefaultDocumentTextDifferencingService(); + var textDifferencingService = _oldSolution.Workspace.Services.GetRequiredService(); var appliedChanges = await textDifferencingService.GetTextChangesAsync(_oldSolution.GetDocument(linkedDocumentGroup.First()), _newSolution.GetDocument(linkedDocumentGroup.First()), cancellationToken).ConfigureAwait(false); var unmergedChanges = new List(); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/MemberDeclarationSyntaxExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/MemberDeclarationSyntaxExtensions.cs index f2ef822ad2493..1e03341fec4e1 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/MemberDeclarationSyntaxExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/MemberDeclarationSyntaxExtensions.cs @@ -114,32 +114,6 @@ public static TypeParameterListSyntax GetTypeParameterList(this MemberDeclaratio return null; } - public static BaseParameterListSyntax GetParameterList(this MemberDeclarationSyntax member) - { - if (member != null) - { - switch (member.Kind()) - { - case SyntaxKind.DelegateDeclaration: - return ((DelegateDeclarationSyntax)member).ParameterList; - case SyntaxKind.MethodDeclaration: - return ((MethodDeclarationSyntax)member).ParameterList; - case SyntaxKind.ConstructorDeclaration: - return ((ConstructorDeclarationSyntax)member).ParameterList; - case SyntaxKind.DestructorDeclaration: - return ((DestructorDeclarationSyntax)member).ParameterList; - case SyntaxKind.IndexerDeclaration: - return ((IndexerDeclarationSyntax)member).ParameterList; - case SyntaxKind.OperatorDeclaration: - return ((OperatorDeclarationSyntax)member).ParameterList; - case SyntaxKind.ConversionOperatorDeclaration: - return ((ConversionOperatorDeclarationSyntax)member).ParameterList; - } - } - - return null; - } - public static MemberDeclarationSyntax WithParameterList( this MemberDeclarationSyntax member, BaseParameterListSyntax parameterList) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions.cs index aa7e41d1a1e87..b848ed9dcd8c2 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SyntaxNodeExtensions.cs @@ -257,8 +257,8 @@ node is UsingStatementSyntax || _ => null, }; - public static BaseParameterListSyntax? GetParameterList(this SyntaxNode declaration) - => declaration.Kind() switch + public static BaseParameterListSyntax? GetParameterList(this SyntaxNode? declaration) + => declaration?.Kind() switch { SyntaxKind.DelegateDeclaration => ((DelegateDeclarationSyntax)declaration).ParameterList, SyntaxKind.MethodDeclaration => ((MethodDeclarationSyntax)declaration).ParameterList, @@ -270,6 +270,7 @@ node is UsingStatementSyntax || SyntaxKind.ParenthesizedLambdaExpression => ((ParenthesizedLambdaExpressionSyntax)declaration).ParameterList, SyntaxKind.LocalFunctionStatement => ((LocalFunctionStatementSyntax)declaration).ParameterList, SyntaxKind.AnonymousMethodExpression => ((AnonymousMethodExpressionSyntax)declaration).ParameterList, + SyntaxKind.RecordDeclaration => ((RecordDeclarationSyntax)declaration).ParameterList, _ => null, }; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.cs index 95638f77b5652..2a0c055bec68b 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpRemoveUnnecessaryImportsService.cs @@ -26,10 +26,8 @@ namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryImports internal partial class CSharpRemoveUnnecessaryImportsService : AbstractRemoveUnnecessaryImportsService { - public static readonly CSharpRemoveUnnecessaryImportsService Instance = new(); - [ImportingConstructor] - [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Incorrectly used in production code: https://github.com/dotnet/roslyn/issues/42839")] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public CSharpRemoveUnnecessaryImportsService() { } diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb index 1ab6a292dae38..70fc7b223c7ac 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.vb @@ -17,13 +17,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Partial Friend NotInheritable Class VisualBasicIndentationService Inherits AbstractIndentationService(Of CompilationUnitSyntax) - Public Shared ReadOnly DefaultInstance As New VisualBasicIndentationService() Public Shared ReadOnly WithoutParameterAlignmentInstance As New VisualBasicIndentationService(NoOpFormattingRule.Instance) Private ReadOnly _specializedIndentationRule As AbstractFormattingRule - + Public Sub New() Me.New(Nothing) End Sub