-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Initial support for adding obsolete attributes to primary constructors #79271
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
Conversation
@@ -25,7 +26,7 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.Fixers | |||
[method: Obsolete("This exported object must be obtained through the MEF export provider.", error: true)] | |||
public sealed class FixerWithFixAllFix() : CodeFixProvider | |||
{ | |||
public sealed override ImmutableArray<string> FixableDiagnosticIds { get; } = ImmutableArray.Create(DiagnosticIds.OverrideGetFixAllProviderRuleId); | |||
public sealed override ImmutableArray<string> FixableDiagnosticIds { get; } = [DiagnosticIds.OverrideGetFixAllProviderRuleId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just cleanup in this file.
|
||
namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.Fixers | ||
{ | ||
public abstract class ApplyDiagnosticAnalyzerAttributeFix : CodeFixProvider | ||
{ | ||
public sealed override ImmutableArray<string> FixableDiagnosticIds { get; } = ImmutableArray.Create(DiagnosticIds.MissingDiagnosticAnalyzerAttributeRuleId); | ||
public sealed override ImmutableArray<string> FixableDiagnosticIds { get; } = [DiagnosticIds.MissingDiagnosticAnalyzerAttributeRuleId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just cleanup in this file.
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.Fixers | ||
{ | ||
public abstract class CompareSymbolsCorrectlyFix : CodeFixProvider | ||
{ | ||
public sealed override ImmutableArray<string> FixableDiagnosticIds { get; } = | ||
ImmutableArray.Create(DiagnosticIds.CompareSymbolsCorrectlyRuleId); | ||
[DiagnosticIds.CompareSymbolsCorrectlyRuleId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just cleanup in this file.
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.Fixers | ||
{ | ||
public abstract class ConfigureGeneratedCodeAnalysisFix : CodeFixProvider | ||
{ | ||
public override ImmutableArray<string> FixableDiagnosticIds { get; } = ImmutableArray.Create(ConfigureGeneratedCodeAnalysisAnalyzer.Rule.Id); | ||
public override ImmutableArray<string> FixableDiagnosticIds { get; } = [ConfigureGeneratedCodeAnalysisAnalyzer.Rule.Id]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just cleanup in this file.
DiagnosticIds.DefineDiagnosticTitleCorrectlyRuleId, | ||
DiagnosticIds.DefineDiagnosticMessageCorrectlyRuleId, | ||
DiagnosticIds.DefineDiagnosticDescriptionCorrectlyRuleId, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just cleanup in this file.
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.Fixers | ||
{ | ||
public abstract class EnableConcurrentExecutionFix : CodeFixProvider | ||
{ | ||
public override ImmutableArray<string> FixableDiagnosticIds { get; } = ImmutableArray.Create(EnableConcurrentExecutionAnalyzer.Rule.Id); | ||
public override ImmutableArray<string> FixableDiagnosticIds { get; } = [EnableConcurrentExecutionAnalyzer.Rule.Id]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just cleanup in this file.
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CodeActions; | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers; | ||
using Microsoft.CodeAnalysis.Shared.Extensions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving off of duplicative extension to roslyn ones.
GenerateErrorArgument(generator, allowNamedArgument: document.Project.Language == LanguageNames.CSharp), | ||
]); | ||
|
||
obsoleteAttributeList = isPrimaryConstructorTypeDeclaration ? this.AddMethodTarget(obsoleteAttributeList) : obsoleteAttributeList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the updated logic.
{ | ||
var source = $@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switched to raw strings and file scoped namespace.
[WindowsOnlyTheory] | ||
[InlineData("System.Composition")] | ||
[InlineData("System.ComponentModel.Composition")] | ||
public async Task NotMarkedObsolete_PrimaryConstructor_CSharpAsync(string mefNamespace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new test for thsi scenario.
@@ -1,45 +0,0 @@ | |||
// Licensed to the .NET Foundation under one or more agreements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicates of roslyn extensions. deleted.
@JoeRobich ptal. |
This has been annoying me that this Roslyn-Analyzers fixer doesn't work the moment you use primary constructors.