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

Move analyzer RCS1036 to Formatting.Analyzers (RCS0063) #1600

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Move analyzer [RCS1036](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1036) to Formatting.Analyzers as [RCS0063](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0063) ([PR](https://github.com/dotnet/roslynator/pull/1600))
- Old analyzer still works but is marked as obsolete.

## [4.12.11] - 2025-01-28

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override ImmutableArray<string> FixableDiagnosticIds
{
return ImmutableArray.Create(
DiagnosticIdentifiers.RemoveTrailingWhitespace,
DiagnosticIdentifiers.RemoveUnnecessaryBlankLine);
DiagnosticIdentifiers.Obsolete_RemoveUnnecessaryBlankLine);
}
}

Expand Down Expand Up @@ -54,7 +54,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
context.RegisterCodeFix(codeAction, diagnostic);
break;
}
case DiagnosticIdentifiers.RemoveUnnecessaryBlankLine:
case DiagnosticIdentifiers.Obsolete_RemoveUnnecessaryBlankLine:
{
CodeAction codeAction = CodeAction.Create(
"Remove blank line",
Expand Down
41 changes: 40 additions & 1 deletion src/Analyzers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,43 @@ public class C
</Sample>
</Samples>
</Analyzer>
<Analyzer>
<Id>RCS0063</Id>
<Identifier>RemoveUnnecessaryBlankLine</Identifier>
<Title>Remove unnecessary blank line</Title>
<DefaultSeverity>Info</DefaultSeverity>
<IsEnabledByDefault>false</IsEnabledByDefault>
<Samples>
<Sample>
<Before><![CDATA[public class Foo
{

private string _f;


public bool Bar()
{

return false;

}

}]]></Before>
<After><![CDATA[public class Foo
{
private string _f;

public bool Bar()
{
return false;
}
}]]></After>
</Sample>
</Samples>
<ConfigOptions>
<Option Key="blank_line_between_closing_brace_and_switch_section" />
</ConfigOptions>
</Analyzer>
<Analyzer>
<Id>RCS1001</Id>
<Identifier>AddBracesWhenExpressionSpansOverMultipleLines</Identifier>
Expand Down Expand Up @@ -2470,8 +2507,10 @@ if (f)
</Analyzer>
<Analyzer>
<Id>RCS1036</Id>
<Identifier>RemoveUnnecessaryBlankLine</Identifier>
<Identifier>Obsolete_RemoveUnnecessaryBlankLine</Identifier>
<Title>Remove unnecessary blank line</Title>
<Status>Obsolete</Status>
<ObsoleteMessage>Use RCS0063 instead</ObsoleteMessage>
<DefaultSeverity>Info</DefaultSeverity>
<IsEnabledByDefault>true</IsEnabledByDefault>
<Samples>
Expand Down
4 changes: 2 additions & 2 deletions src/Analyzers/Analysis/WhitespaceAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
Immutable.InterlockedInitialize(
ref _supportedDiagnostics,
DiagnosticRules.RemoveTrailingWhitespace,
DiagnosticRules.RemoveUnnecessaryBlankLine);
DiagnosticRules.Obsolete_RemoveUnnecessaryBlankLine);
}

return _supportedDiagnostics;
Expand Down Expand Up @@ -83,7 +83,7 @@ private static void AnalyzeTrailingTrivia(SyntaxTreeAnalysisContext context)
{
DiagnosticHelpers.ReportDiagnostic(
context,
DiagnosticRules.RemoveUnnecessaryBlankLine,
DiagnosticRules.Obsolete_RemoveUnnecessaryBlankLine,
Location.Create(context.Tree, emptyLines));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void Initialize(AnalysisContext context)
Validate(ref context, compilationOptions, options, Flags.ConvertMethodGroupToAnonymousFunction, ref flags, DiagnosticRules.UseAnonymousFunctionOrMethodGroup, ConfigOptions.UseAnonymousFunctionOrMethodGroup, LegacyConfigOptions.ConvertMethodGroupToAnonymousFunction, ConfigOptionValues.UseAnonymousFunctionOrMethodGroup_AnonymousFunction);
Validate(ref context, compilationOptions, options, Flags.RemoveCallToConfigureAwait, ref flags, DiagnosticRules.ConfigureAwait, ConfigOptions.ConfigureAwait, LegacyConfigOptions.RemoveCallToConfigureAwait, "false");
Validate(ref context, compilationOptions, options, Flags.RemoveAccessibilityModifiers, ref flags, DiagnosticRules.AddOrRemoveAccessibilityModifiers, ConfigOptions.AccessibilityModifiers, LegacyConfigOptions.RemoveAccessibilityModifiers, ConfigOptionValues.AccessibilityModifiers_Implicit);
Validate(ref context, compilationOptions, options, Flags.RemoveEmptyLineBetweenClosingBraceAndSwitchSection, ref flags, DiagnosticRules.RemoveUnnecessaryBlankLine, ConfigOptions.BlankLineBetweenClosingBraceAndSwitchSection, LegacyConfigOptions.RemoveEmptyLineBetweenClosingBraceAndSwitchSection, "false");
Validate(ref context, compilationOptions, options, Flags.RemoveEmptyLineBetweenClosingBraceAndSwitchSection, ref flags, DiagnosticRules.Obsolete_RemoveUnnecessaryBlankLine, ConfigOptions.BlankLineBetweenClosingBraceAndSwitchSection, LegacyConfigOptions.RemoveEmptyLineBetweenClosingBraceAndSwitchSection, "false");
Validate(ref context, compilationOptions, options, Flags.RemoveParenthesesFromConditionOfConditionalExpressionWhenExpressionIsSingleToken, ref flags, DiagnosticRules.AddOrRemoveParenthesesFromConditionInConditionalOperator, ConfigOptions.ConditionalOperatorConditionParenthesesStyle, LegacyConfigOptions.RemoveParenthesesFromConditionOfConditionalExpressionWhenExpressionIsSingleToken, ConfigOptionValues.ConditionalOperatorConditionParenthesesStyle_OmitWhenConditionIsSingleToken);
Validate(ref context, compilationOptions, options, Flags.RemoveParenthesesWhenCreatingNewObject, ref flags, DiagnosticRules.UseImplicitOrExplicitObjectCreation, ConfigOptions.ObjectCreationParenthesesStyle, LegacyConfigOptions.RemoveParenthesesWhenCreatingNewObject, ConfigOptionValues.ObjectCreationParenthesesStyle_Omit);
#pragma warning disable CS0618 // Type or member is obsolete
Expand Down
Loading
Loading