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

Use primary constructors #74359

Merged
merged 98 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
875e6cb
Use primary constructors
CyrusNajmabadi Jul 11, 2024
10e5a36
Use primary constructors
CyrusNajmabadi Jul 11, 2024
c1ad7a1
Use primary constructors
CyrusNajmabadi Jul 11, 2024
7313a67
Use primary constructors
CyrusNajmabadi Jul 11, 2024
21f91ea
Use primary constructors
CyrusNajmabadi Jul 11, 2024
f1f411e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
a2a7b87
Use primary constructors
CyrusNajmabadi Jul 11, 2024
b4aea1e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
2d8de09
Use primary constructors
CyrusNajmabadi Jul 11, 2024
e4aa837
Use primary constructors
CyrusNajmabadi Jul 11, 2024
47e73dd
Use primary constructors
CyrusNajmabadi Jul 11, 2024
a64561f
Use primary constructors
CyrusNajmabadi Jul 11, 2024
7efd396
Use primary constructors
CyrusNajmabadi Jul 11, 2024
20c3877
Use primary constructors
CyrusNajmabadi Jul 11, 2024
70ede96
Use primary constructors
CyrusNajmabadi Jul 11, 2024
32142a6
Use primary constructors
CyrusNajmabadi Jul 11, 2024
357adee
Use primary constructors
CyrusNajmabadi Jul 11, 2024
d7cc202
Use primary constructors
CyrusNajmabadi Jul 11, 2024
27cbefc
Use primary constructors
CyrusNajmabadi Jul 11, 2024
91aff87
Use primary constructors
CyrusNajmabadi Jul 11, 2024
e9e5a8e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
3005421
Use primary constructors
CyrusNajmabadi Jul 11, 2024
aef5c26
Use primary constructors
CyrusNajmabadi Jul 11, 2024
a01ce6e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
4cc8f87
Use primary constructors
CyrusNajmabadi Jul 11, 2024
93e299c
Use primary constructors
CyrusNajmabadi Jul 11, 2024
0ae63be
Use primary constructors
CyrusNajmabadi Jul 11, 2024
d6a4cfa
Use primary constructors
CyrusNajmabadi Jul 11, 2024
1b4bc00
Use primary constructors
CyrusNajmabadi Jul 11, 2024
a186e30
Use primary constructors
CyrusNajmabadi Jul 11, 2024
814a56d
Use primary constructors
CyrusNajmabadi Jul 11, 2024
05cfea1
Use primary constructors
CyrusNajmabadi Jul 11, 2024
b51cfd0
Use primary constructors
CyrusNajmabadi Jul 11, 2024
5ef5079
Use primary constructors
CyrusNajmabadi Jul 11, 2024
a462902
Use primary constructors
CyrusNajmabadi Jul 11, 2024
10a57ac
Use primary constructors
CyrusNajmabadi Jul 11, 2024
12b9d00
Use primary constructors
CyrusNajmabadi Jul 11, 2024
8ef545d
Use primary constructors
CyrusNajmabadi Jul 11, 2024
3e6463e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
8d3ccc1
Use primary constructors
CyrusNajmabadi Jul 11, 2024
246f074
Use primary constructors
CyrusNajmabadi Jul 11, 2024
497ef27
Use primary constructors
CyrusNajmabadi Jul 11, 2024
effb334
Use primary constructors
CyrusNajmabadi Jul 11, 2024
5f2852e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
dc24902
Use primary constructors
CyrusNajmabadi Jul 11, 2024
3a091d3
Use primary constructors
CyrusNajmabadi Jul 11, 2024
81e6e6f
Use primary constructors
CyrusNajmabadi Jul 11, 2024
0d9c961
Use primary constructors
CyrusNajmabadi Jul 11, 2024
2e8d516
Use primary constructors
CyrusNajmabadi Jul 11, 2024
265a5ef
Use primary constructors
CyrusNajmabadi Jul 11, 2024
a8670e8
Use primary constructors
CyrusNajmabadi Jul 11, 2024
7e5865e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
664fc9c
Use primary constructors
CyrusNajmabadi Jul 11, 2024
1434198
Use primary constructors
CyrusNajmabadi Jul 11, 2024
aa883b3
Use primary constructors
CyrusNajmabadi Jul 11, 2024
26f124d
Use primary constructors
CyrusNajmabadi Jul 11, 2024
fdbea4c
Use primary constructors
CyrusNajmabadi Jul 11, 2024
4df2a2c
Use primary constructors
CyrusNajmabadi Jul 11, 2024
74d9187
Use primary constructors
CyrusNajmabadi Jul 11, 2024
8ff8463
Use primary constructors
CyrusNajmabadi Jul 11, 2024
ad8806a
Use primary constructors
CyrusNajmabadi Jul 11, 2024
673f127
Use primary constructors
CyrusNajmabadi Jul 11, 2024
d2e09e1
Use primary constructors
CyrusNajmabadi Jul 11, 2024
ff189f2
Use primary constructors
CyrusNajmabadi Jul 11, 2024
871910e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
8d35f5e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
4fb8645
Use primary constructors
CyrusNajmabadi Jul 11, 2024
5b52d3a
Use primary constructors
CyrusNajmabadi Jul 11, 2024
ecd96b6
Use primary constructors
CyrusNajmabadi Jul 11, 2024
022d31e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
9733a3e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
528802d
Use primary constructors
CyrusNajmabadi Jul 11, 2024
eeb97d2
Use primary constructors
CyrusNajmabadi Jul 11, 2024
3be1f89
Use primary constructors
CyrusNajmabadi Jul 11, 2024
da96f4c
Use primary constructors
CyrusNajmabadi Jul 11, 2024
e5af26c
Use primary constructors
CyrusNajmabadi Jul 11, 2024
d3699bb
Use primary constructors
CyrusNajmabadi Jul 11, 2024
822261e
Use primary constructors
CyrusNajmabadi Jul 11, 2024
ad8b965
Use primary constructors
CyrusNajmabadi Jul 11, 2024
7223f61
Use primary constructors
CyrusNajmabadi Jul 11, 2024
35a8a3d
Use primary constructors
CyrusNajmabadi Jul 11, 2024
a6697c5
Use primary constructors
CyrusNajmabadi Jul 11, 2024
a262a42
Use primary constructors
CyrusNajmabadi Jul 11, 2024
0158171
Use primary constructors
CyrusNajmabadi Jul 11, 2024
49feaa6
Use primary constructors
CyrusNajmabadi Jul 11, 2024
f051ba7
Use primary constructors
CyrusNajmabadi Jul 11, 2024
ecd915c
Add nrt support
CyrusNajmabadi Jul 11, 2024
8b0a94d
Add nrt support
CyrusNajmabadi Jul 11, 2024
4f6ef0c
Add nrt support
CyrusNajmabadi Jul 11, 2024
d58662d
Add nrt support
CyrusNajmabadi Jul 11, 2024
dbb782c
Add nrt support
CyrusNajmabadi Jul 11, 2024
de0632d
Add nrt support
CyrusNajmabadi Jul 11, 2024
343ac0f
Add nrt support
CyrusNajmabadi Jul 11, 2024
fd1da7a
Add nrt support
CyrusNajmabadi Jul 11, 2024
eb8362c
Add nrt support
CyrusNajmabadi Jul 11, 2024
81ecd91
Add nrt support
CyrusNajmabadi Jul 11, 2024
dc48454
Add nrt support
CyrusNajmabadi Jul 11, 2024
0a6f8a5
Add nrt support
CyrusNajmabadi Jul 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@
// 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.Composition;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.AddAccessibilityModifiers;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Host.Mef;

namespace Microsoft.CodeAnalysis.CSharp.AddAccessibilityModifiers;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddAccessibilityModifiers), Shared]
internal class CSharpAddAccessibilityModifiersCodeFixProvider : AbstractAddAccessibilityModifiersCodeFixProvider
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
internal sealed class CSharpAddAccessibilityModifiersCodeFixProvider() : AbstractAddAccessibilityModifiersCodeFixProvider
{
[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CSharpAddAccessibilityModifiersCodeFixProvider()
{
}

protected override SyntaxNode MapToDeclarator(SyntaxNode node)
{
switch (node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
namespace Microsoft.CodeAnalysis.CSharp.AddAccessibilityModifiers;

[ExportLanguageService(typeof(IAddAccessibilityModifiersService), LanguageNames.CSharp), Shared]
internal class CSharpAddAccessibilityModifiersService : CSharpAddAccessibilityModifiers, IAddAccessibilityModifiersService
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpAddAccessibilityModifiersService()
{
}
}
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class CSharpAddAccessibilityModifiersService() : CSharpAddAccessibilityModifiers, IAddAccessibilityModifiersService;
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@
namespace Microsoft.CodeAnalysis.CSharp.AddAnonymousTypeMemberName;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddAnonymousTypeMemberName), Shared]
internal class CSharpAddAnonymousTypeMemberNameCodeFixProvider
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
internal sealed class CSharpAddAnonymousTypeMemberNameCodeFixProvider()
: AbstractAddAnonymousTypeMemberNameCodeFixProvider<
ExpressionSyntax,
AnonymousObjectCreationExpressionSyntax,
AnonymousObjectMemberDeclaratorSyntax>
{
private const string CS0746 = nameof(CS0746); // Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.

[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CSharpAddAnonymousTypeMemberNameCodeFixProvider()
{
}

public override ImmutableArray<string> FixableDiagnosticIds { get; }
= [CS0746];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.Diagnostics;
Expand All @@ -16,14 +15,10 @@
namespace Microsoft.CodeAnalysis.CSharp.Diagnostics.AddBraces;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddBraces), Shared]
internal sealed class CSharpAddBracesCodeFixProvider : SyntaxEditorBasedCodeFixProvider
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
internal sealed class CSharpAddBracesCodeFixProvider() : SyntaxEditorBasedCodeFixProvider
{
[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CSharpAddBracesCodeFixProvider()
{
}

public override ImmutableArray<string> FixableDiagnosticIds
=> [IDEDiagnosticIds.AddBracesDiagnosticId];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.AddInheritdoc;
using static CSharpSyntaxTokens;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddInheritdoc), Shared]
internal sealed class AddInheritdocCodeFixProvider : SyntaxEditorBasedCodeFixProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class AddInheritdocCodeFixProvider() : SyntaxEditorBasedCodeFixProvider
{
/// <summary>
/// CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
/// </summary>
private const string CS1591 = nameof(CS1591);

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

public override ImmutableArray<string> FixableDiagnosticIds => [CS1591];

public override async Task RegisterCodeFixesAsync(CodeFixContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,17 @@
namespace Microsoft.CodeAnalysis.CSharp.AddObsoleteAttribute;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddObsoleteAttribute), Shared]
internal class CSharpAddObsoleteAttributeCodeFixProvider
: AbstractAddObsoleteAttributeCodeFixProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class CSharpAddObsoleteAttributeCodeFixProvider()
: AbstractAddObsoleteAttributeCodeFixProvider(CSharpSyntaxFacts.Instance, CSharpCodeFixesResources.Add_Obsolete)
{
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
[
"CS0612",
"CS0618",
"CS0672",
"CS1062",
"CS1064"
, // The best overloaded Add method 'MyCollection.Add(int)' for the collection initializer element is obsolete"
"CS1064",
];

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpAddObsoleteAttributeCodeFixProvider()
: base(CSharpSyntaxFacts.Instance, CSharpCodeFixesResources.Add_Obsolete)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
Expand All @@ -18,7 +16,9 @@ namespace Microsoft.CodeAnalysis.CSharp.AddParameter;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddParameter), Shared]
[ExtensionOrder(Before = PredefinedCodeFixProviderNames.GenerateConstructor)]
internal class CSharpAddParameterCodeFixProvider : AbstractAddParameterCodeFixProvider<
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
internal sealed class CSharpAddParameterCodeFixProvider() : AbstractAddParameterCodeFixProvider<
ArgumentSyntax,
AttributeArgumentSyntax,
ArgumentListSyntax,
Expand All @@ -34,12 +34,6 @@ internal class CSharpAddParameterCodeFixProvider : AbstractAddParameterCodeFixPr

private static readonly ImmutableArray<string> AddParameterFixableDiagnosticIds = [CS1501, CS1503, CS1660, CS1729, CS1739];

[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CSharpAddParameterCodeFixProvider()
{
}

public override ImmutableArray<string> FixableDiagnosticIds
=> AddParameterFixableDiagnosticIds;

Expand All @@ -52,14 +46,14 @@ protected override ImmutableArray<string> CannotConvertDiagnosticIds
protected override ITypeSymbol GetArgumentType(SyntaxNode argumentNode, SemanticModel semanticModel, CancellationToken cancellationToken)
=> ((ArgumentSyntax)argumentNode).DetermineParameterType(semanticModel, cancellationToken);

protected override RegisterFixData<ArgumentSyntax> TryGetLanguageSpecificFixInfo(
protected override RegisterFixData<ArgumentSyntax>? TryGetLanguageSpecificFixInfo(
SemanticModel semanticModel,
SyntaxNode node,
CancellationToken cancellationToken)
{
if (node is ConstructorInitializerSyntax constructorInitializer)
{
var constructorDeclaration = constructorInitializer.Parent;
var constructorDeclaration = constructorInitializer.GetRequiredParent();
if (semanticModel.GetDeclaredSymbol(constructorDeclaration, cancellationToken) is IMethodSymbol constructorSymbol)
{
var type = constructorSymbol.ContainingType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ namespace Microsoft.CodeAnalysis.CSharp.AliasAmbiguousType;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AliasAmbiguousType), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.FullyQualify)]
internal class CSharpAliasAmbiguousTypeCodeFixProvider : AbstractAliasAmbiguousTypeCodeFixProvider
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
internal sealed class CSharpAliasAmbiguousTypeCodeFixProvider() : AbstractAliasAmbiguousTypeCodeFixProvider
{
/// <summary>
/// 'reference' is an ambiguous reference between 'identifier' and 'identifier'
/// </summary>
private const string CS0104 = nameof(CS0104);

[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CSharpAliasAmbiguousTypeCodeFixProvider()
{
}

public override ImmutableArray<string> FixableDiagnosticIds
=> [CS0104];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
namespace Microsoft.CodeAnalysis.CSharp.AssignOutParameters;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AssignOutParametersAboveReturn), Shared]
internal class AssignOutParametersAboveReturnCodeFixProvider : AbstractAssignOutParametersCodeFixProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class AssignOutParametersAboveReturnCodeFixProvider() : AbstractAssignOutParametersCodeFixProvider
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public AssignOutParametersAboveReturnCodeFixProvider()
{
}

protected override void TryRegisterFix(CodeFixContext context, Document document, SyntaxNode container, SyntaxNode location)
{
RegisterCodeFix(context, CSharpCodeFixesResources.Assign_out_parameters, nameof(CSharpCodeFixesResources.Assign_out_parameters));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
namespace Microsoft.CodeAnalysis.CSharp.AssignOutParameters;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AssignOutParametersAtStart), Shared]
internal class AssignOutParametersAtStartCodeFixProvider : AbstractAssignOutParametersCodeFixProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class AssignOutParametersAtStartCodeFixProvider() : AbstractAssignOutParametersCodeFixProvider
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public AssignOutParametersAtStartCodeFixProvider()
{
}

protected override void TryRegisterFix(CodeFixContext context, Document document, SyntaxNode container, SyntaxNode location)
{
// Don't offer if we're already the starting statement of the container. This case will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@ namespace Microsoft.CodeAnalysis.CSharp.ConditionalExpressionInStringInterpolati
using static CSharpSyntaxTokens;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddParenthesesAroundConditionalExpressionInInterpolatedString), Shared]
internal class CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider : CodeFixProvider
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
internal sealed class CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider() : CodeFixProvider
{
private const string CS8361 = nameof(CS8361); //A conditional expression cannot be used directly in a string interpolation because the ':' ends the interpolation.Parenthesize the conditional expression.

[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider()
{
}

// CS8361 is a syntax error and it is unlikely that there is more than one CS8361 at a time.
public override FixAllProvider? GetFixAllProvider() => null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
namespace Microsoft.CodeAnalysis.CSharp.ConflictMarkerResolution;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ConflictMarkerResolution), Shared]
internal class CSharpResolveConflictMarkerCodeFixProvider : AbstractResolveConflictMarkerCodeFixProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class CSharpResolveConflictMarkerCodeFixProvider()
: AbstractResolveConflictMarkerCodeFixProvider(CSharpSyntaxKinds.Instance, CS8300)
{
private const string CS8300 = nameof(CS8300); // Merge conflict marker encountered

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpResolveConflictMarkerCodeFixProvider()
: base(CSharpSyntaxKinds.Instance, CS8300)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@
namespace Microsoft.CodeAnalysis.CSharp.ConvertNamespace;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ConvertNamespace), Shared]
internal class ConvertNamespaceCodeFixProvider : SyntaxEditorBasedCodeFixProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class ConvertNamespaceCodeFixProvider() : SyntaxEditorBasedCodeFixProvider
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public ConvertNamespaceCodeFixProvider()
{
}
public override ImmutableArray<string> FixableDiagnosticIds
=> [IDEDiagnosticIds.UseBlockScopedNamespaceDiagnosticId, IDEDiagnosticIds.UseFileScopedNamespaceDiagnosticId];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@ namespace Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression;
using Constants = ConvertSwitchStatementToExpressionConstants;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ConvertSwitchStatementToExpression), Shared]
internal sealed partial class ConvertSwitchStatementToExpressionCodeFixProvider : SyntaxEditorBasedCodeFixProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed partial class ConvertSwitchStatementToExpressionCodeFixProvider() : SyntaxEditorBasedCodeFixProvider
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public ConvertSwitchStatementToExpressionCodeFixProvider()
{
}

public override ImmutableArray<string> FixableDiagnosticIds
=> [IDEDiagnosticIds.ConvertSwitchStatementToExpressionDiagnosticId];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.ConvertToAsync;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ConvertToAsync), Shared]
internal class CSharpConvertToAsyncMethodCodeFixProvider : AbstractConvertToAsyncCodeFixProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class CSharpConvertToAsyncMethodCodeFixProvider() : AbstractConvertToAsyncCodeFixProvider
{
/// <summary>
/// Cannot await void.
/// </summary>
private const string CS4008 = nameof(CS4008);

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

public override ImmutableArray<string> FixableDiagnosticIds => [CS4008];

protected override async Task<string> GetDescriptionAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Immutable;
using System.Composition;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Host.Mef;
Expand All @@ -15,16 +14,12 @@
namespace Microsoft.CodeAnalysis.CSharp.ConvertToRecord;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ConvertToRecord), Shared]
internal class CSharpConvertToRecordCodeFixProvider : CodeFixProvider
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class CSharpConvertToRecordCodeFixProvider() : CodeFixProvider
{
private const string CS8865 = nameof(CS8865); // Only records may inherit from records.

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

public override FixAllProvider? GetFixAllProvider()
=> null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
namespace Microsoft.CodeAnalysis.CSharp.ConvertTypeOfToNameOf;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ConvertTypeOfToNameOf), Shared]
internal class CSharpConvertTypeOfToNameOfCodeFixProvider : AbstractConvertTypeOfToNameOfCodeFixProvider<
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
internal sealed class CSharpConvertTypeOfToNameOfCodeFixProvider() : AbstractConvertTypeOfToNameOfCodeFixProvider<
MemberAccessExpressionSyntax>
{
[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CSharpConvertTypeOfToNameOfCodeFixProvider()
{
}

protected override string GetCodeFixTitle()
=> CSharpCodeFixesResources.Convert_typeof_to_nameof;

Expand Down
Loading
Loading