Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3b2afea
Move code down
CyrusNajmabadi Jul 26, 2024
964d7b1
move more down
CyrusNajmabadi Jul 26, 2024
71e4899
Move resources
CyrusNajmabadi Jul 26, 2024
d2fe977
Move resources
CyrusNajmabadi Jul 26, 2024
f59033e
Move more down
CyrusNajmabadi Jul 26, 2024
86b4155
add back resource
CyrusNajmabadi Jul 26, 2024
2dfaaeb
move down
CyrusNajmabadi Jul 26, 2024
4a7873e
move down
CyrusNajmabadi Jul 26, 2024
d6efcfc
Move more extensions?
CyrusNajmabadi Jul 26, 2024
56edab7
in progress
CyrusNajmabadi Jul 26, 2024
22159a5
in progress
CyrusNajmabadi Jul 26, 2024
d8c43ad
moving todwn
CyrusNajmabadi Jul 26, 2024
a23e9df
Code style split
CyrusNajmabadi Jul 26, 2024
005ac06
Code style split
CyrusNajmabadi Jul 26, 2024
6fa3531
move
CyrusNajmabadi Jul 26, 2024
a6d744d
Move code down
CyrusNajmabadi Jul 26, 2024
372d8a6
Fixes
CyrusNajmabadi Jul 26, 2024
3d1a2ef
move tests
CyrusNajmabadi Jul 26, 2024
798a1b1
Move down
CyrusNajmabadi Jul 26, 2024
0af1651
Move resources
CyrusNajmabadi Jul 26, 2024
f21b204
Move resources
CyrusNajmabadi Jul 26, 2024
ebcf445
Move resources
CyrusNajmabadi Jul 26, 2024
bca5881
move extensions down
CyrusNajmabadi Jul 26, 2024
264085f
Move down
CyrusNajmabadi Jul 26, 2024
6f853ec
Fixes
CyrusNajmabadi Jul 26, 2024
c119b91
Fixes
CyrusNajmabadi Jul 26, 2024
e3bbefa
Fixes
CyrusNajmabadi Jul 26, 2024
b741cac
move down
CyrusNajmabadi Jul 26, 2024
399e288
Move tests
CyrusNajmabadi Jul 26, 2024
b11e3bd
revert
CyrusNajmabadi Jul 26, 2024
7a6208f
revert
CyrusNajmabadi Jul 26, 2024
979b477
share code
CyrusNajmabadi Jul 27, 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
13 changes: 13 additions & 0 deletions src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,22 @@
<Compile Include="$(MSBuildThisFileDirectory)DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Formatting\CSharpFormattingCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateConstructor\CSharpGenerateConstructorService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateConstructor\GenerateConstructorCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateConstructor\GenerateConstructorDiagnosticIds.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateDefaultConstructors\CSharpGenerateDefaultConstructorsCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateDefaultConstructors\CSharpGenerateDefaultConstructorsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateEnumMember\CSharpGenerateEnumMemberService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateEnumMember\GenerateEnumMemberCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateMethod\GenerateConversionCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateMethod\GenerateDeconstructMethodCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateMethod\GenerateMethodCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateParameterizedMember\CSharpCommonGenerationServiceMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateParameterizedMember\CSharpGenerateConversionService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateParameterizedMember\CSharpGenerateDeconstructMethodService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateParameterizedMember\CSharpGenerateMethodService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateParameterizedMember\CSharpGenerateParameterizedMemberService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateVariable\CSharpGenerateVariableCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HideBase\HideBaseCodeFixProvider.AddNewKeywordAction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HideBase\HideBaseCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ImplementAbstractClass\CSharpImplementAbstractClassCodeFixProvider.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ namespace Microsoft.CodeAnalysis.CSharp.GenerateConstructor;
/// </summary>
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateConstructor), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.FullyQualify)]
internal class GenerateConstructorCodeFixProvider : AbstractGenerateMemberCodeFixProvider
[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 GenerateConstructorCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public GenerateConstructorCodeFixProvider()
{
}

public override ImmutableArray<string> FixableDiagnosticIds => GenerateConstructorDiagnosticIds.AllDiagnosticIds;

protected override Task<ImmutableArray<CodeAction>> GetCodeActionsAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@
namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateEnumMember;

[ExportLanguageService(typeof(IGenerateEnumMemberService), LanguageNames.CSharp), Shared]
internal partial class CSharpGenerateEnumMemberService :
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed partial class CSharpGenerateEnumMemberService() :
AbstractGenerateEnumMemberService<CSharpGenerateEnumMemberService, SimpleNameSyntax, ExpressionSyntax>
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpGenerateEnumMemberService()
{
}

protected override bool IsIdentifierNameGeneration(SyntaxNode node)
=> node is IdentifierNameSyntax;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.GenerateEnumMember;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateEnumMember), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateConstructor)]
internal class GenerateEnumMemberCodeFixProvider : AbstractGenerateMemberCodeFixProvider
[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 GenerateEnumMemberCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
private const string CS0117 = nameof(CS0117); // error CS0117: 'Color' does not contain a definition for 'Red'
private const string CS1061 = nameof(CS1061); // error CS1061: 'Color' does not contain a definition for 'Red' and no accessible extension method 'Red' accepting a first argument of type 'Color' could be found

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

public override ImmutableArray<string> FixableDiagnosticIds { get; } =
[CS0117, CS1061];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.GenerateMethod;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateConversion), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateEnumMember)]
internal class GenerateConversionCodeFixProvider : AbstractGenerateMemberCodeFixProvider
[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 GenerateConversionCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
private const string CS0029 = nameof(CS0029); // error CS0029: Cannot implicitly convert type 'type' to 'type'
private const string CS0030 = nameof(CS0030); // error CS0030: Cannot convert type 'type' to 'type'

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

public override ImmutableArray<string> FixableDiagnosticIds
{
get { return [CS0029, CS0030]; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ internal static class GenerateMethodDiagnosticIds
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateEnumMember)]
[ExtensionOrder(Before = PredefinedCodeFixProviderNames.PopulateSwitch)]
[ExtensionOrder(Before = PredefinedCodeFixProviderNames.GenerateVariable)]
internal sealed class GenerateMethodCodeFixProvider : AbstractGenerateMemberCodeFixProvider
[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 GenerateMethodCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public GenerateMethodCodeFixProvider()
{
}

public override ImmutableArray<string> FixableDiagnosticIds { get; } =
GenerateMethodDiagnosticIds.FixableDiagnosticIds;

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

[ExportLanguageService(typeof(IGenerateConversionService), LanguageNames.CSharp), Shared]
internal partial class CSharpGenerateConversionService :
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed partial class CSharpGenerateConversionService() :
AbstractGenerateConversionService<CSharpGenerateConversionService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpGenerateConversionService()
{
}

protected override bool IsImplicitConversionGeneration(SyntaxNode node)
{
return node is ExpressionSyntax &&
Expand Down Expand Up @@ -220,8 +216,8 @@ private static IMethodSymbol GenerateMethodSymbol(
}

protected override string GetImplicitConversionDisplayText(AbstractGenerateParameterizedMemberService<CSharpGenerateConversionService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>.State state)
=> string.Format(CSharpFeaturesResources.Generate_implicit_conversion_operator_in_0, state.TypeToGenerateIn.Name);
=> string.Format(CodeFixesResources.Generate_implicit_conversion_operator_in_0, state.TypeToGenerateIn.Name);

protected override string GetExplicitConversionDisplayText(AbstractGenerateParameterizedMemberService<CSharpGenerateConversionService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>.State state)
=> string.Format(CSharpFeaturesResources.Generate_explicit_conversion_operator_in_0, state.TypeToGenerateIn.Name);
=> string.Format(CodeFixesResources.Generate_explicit_conversion_operator_in_0, state.TypeToGenerateIn.Name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@
namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateMethod;

[ExportLanguageService(typeof(IGenerateDeconstructMemberService), LanguageNames.CSharp), Shared]
internal sealed class CSharpGenerateDeconstructMethodService :
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class CSharpGenerateDeconstructMethodService() :
AbstractGenerateDeconstructMethodService<CSharpGenerateDeconstructMethodService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpGenerateDeconstructMethodService()
{
}

protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol containingType)
=> containingType.ContainingTypesOrSelfHasUnsafeKeyword();

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

[ExportLanguageService(typeof(IGenerateParameterizedMemberService), LanguageNames.CSharp), Shared]
internal sealed class CSharpGenerateMethodService :
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class CSharpGenerateMethodService() :
AbstractGenerateMethodService<CSharpGenerateMethodService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax>
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpGenerateMethodService()
{
}

protected override bool IsExplicitInterfaceGeneration(SyntaxNode node)
=> node is MethodDeclarationSyntax;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ namespace Microsoft.CodeAnalysis.CSharp.GenerateVariable;

[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateVariable), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateMethod)]
internal class CSharpGenerateVariableCodeFixProvider : AbstractGenerateMemberCodeFixProvider
[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 CSharpGenerateVariableCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
private const string CS1061 = nameof(CS1061); // error CS1061: 'C' does not contain a definition for 'Goo' and no extension method 'Goo' accepting a first argument of type 'C' could be found
private const string CS0103 = nameof(CS0103); // error CS0103: The name 'Goo' does not exist in the current context
Expand All @@ -32,12 +34,6 @@ internal class CSharpGenerateVariableCodeFixProvider : AbstractGenerateMemberCod
private const string CS0120 = nameof(CS0120); // error CS0120: An object reference is required for the non-static field, method, or property 'A'
private const string CS0118 = nameof(CS0118); // error CS0118: 'C' is a type but is used like a variable

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

public override ImmutableArray<string> FixableDiagnosticIds
=> [CS1061, CS0103, CS0117, CS0539, CS0246, CS0120, CS0118];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
<Compile Include="$(MSBuildThisFileDirectory)FixReturnType\FixReturnTypeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ForEachCast\ForEachCastTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Formatting\FormattingAnalyzerTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateConstructor\GenerateConstructorTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateDefaultConstructors\GenerateDefaultConstructorsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateEnumMember\GenerateEnumMemberTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateMethod\GenerateConversionTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateMethod\GenerateDeconstructMethodTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GenerateMethod\GenerateMethodTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HideBase\HideBaseTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ImplementAbstractClass\ImplementAbstractClassTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ImplementAbstractClass\ImplementAbstractClassTests_FixAllTests.cs" />
Expand Down
Loading