Make dotnet format happy again (except for RYU0001)

This commit is contained in:
TSR Berry 2024-01-16 05:00:59 +01:00
parent cb6ab72a48
commit 3a7ff61029
No known key found for this signature in database
GPG key ID: 52353C0A4CCA15E2
3 changed files with 22 additions and 22 deletions

View file

@ -9,29 +9,29 @@ namespace Ryujinx.Analyzers
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class CatchClauseAnalyzer : DiagnosticAnalyzer
{
public const string LoggerIdentifier = "Logger";
public const string LogClassIdentifier = "LogClass";
private const string LoggerIdentifier = "Logger";
private const string LogClassIdentifier = "LogClass";
public const string DiagnosticId = "RYU0001";
private static readonly LocalizableString Title = new LocalizableResourceString(nameof(Resources.RYU0001Title),
private static readonly LocalizableString _title = new LocalizableResourceString(nameof(Resources.RYU0001Title),
Resources.ResourceManager, typeof(Resources));
private static readonly LocalizableString MessageFormat =
private static readonly LocalizableString _messageFormat =
new LocalizableResourceString(nameof(Resources.RYU0001MessageFormat), Resources.ResourceManager,
typeof(Resources));
private static readonly LocalizableString Description =
private static readonly LocalizableString _description =
new LocalizableResourceString(nameof(Resources.RYU0001Description), Resources.ResourceManager,
typeof(Resources));
private const string Category = "Maintainability";
private static readonly DiagnosticDescriptor Rule = new(DiagnosticId, Title, MessageFormat, Category,
DiagnosticSeverity.Warning, isEnabledByDefault: true, description: Description);
private static readonly DiagnosticDescriptor _rule = new(DiagnosticId, _title, _messageFormat, Category,
DiagnosticSeverity.Warning, isEnabledByDefault: true, description: _description);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
ImmutableArray.Create(Rule);
ImmutableArray.Create(_rule);
public override void Initialize(AnalysisContext context)
{
@ -171,7 +171,7 @@ namespace Ryujinx.Analyzers
// Find catch clauses without declaration.
if (catchDeclaration == null)
{
var diagnostic = Diagnostic.Create(Rule,
var diagnostic = Diagnostic.Create(_rule,
// The highlighted area in the analyzed source code. Keep it as specific as possible.
catchClauseSyntax.GetLocation(),
// The value is passed to 'MessageFormat' argument of your 'Rule'.
@ -182,7 +182,7 @@ namespace Ryujinx.Analyzers
// Find catch declarations without an identifier
else if (string.IsNullOrWhiteSpace(catchDeclaration.Identifier.Text))
{
var diagnostic = Diagnostic.Create(Rule,
var diagnostic = Diagnostic.Create(_rule,
// The highlighted area in the analyzed source code. Keep it as specific as possible.
catchClauseSyntax.GetLocation(),
// The value is passed to 'MessageFormat' argument of your 'Rule'.
@ -214,11 +214,11 @@ namespace Ryujinx.Analyzers
}
}
}
// Create a diagnostic report if the exception was not logged
if (!exceptionLogged)
{
var diagnostic = Diagnostic.Create(Rule,
var diagnostic = Diagnostic.Create(_rule,
// The highlighted area in the analyzed source code. Keep it as specific as possible.
catchClauseSyntax.GetLocation(),
// The value is passed to 'MessageFormat' argument of your 'Rule'.

View file

@ -78,12 +78,12 @@ namespace Ryujinx.Analyzers
if (catchClauseSyntax.Declaration == null)
{
// System.Exception exception
catchDeclaration =
SyntaxFactory.CatchDeclaration(
SyntaxFactory.QualifiedName(
SyntaxFactory.IdentifierName("System"), SyntaxFactory.IdentifierName("Exception")),
SyntaxFactory.Identifier("exception")
);
catchDeclaration =
SyntaxFactory.CatchDeclaration(
SyntaxFactory.QualifiedName(
SyntaxFactory.IdentifierName("System"), SyntaxFactory.IdentifierName("Exception")),
SyntaxFactory.Identifier("exception")
);
}
else
{

View file

@ -19,7 +19,7 @@ namespace Ryujinx.Tests.Analyzers
[Fact]
public async Task CatchWithoutDeclaration_WarningDiagnostic()
{
const string text = @"
const string Text = @"
using System;
public class MyClass
@ -41,13 +41,13 @@ public class MyClass
var expected = Verifier.Diagnostic()
.WithSpan(12, 9, 15, 10)
.WithArguments("Exception");
await Verifier.VerifyAnalyzerAsync(text, expected).ConfigureAwait(false);
await Verifier.VerifyAnalyzerAsync(Text, expected).ConfigureAwait(false);
}
[Fact]
public async Task CatchWithoutIdentifier_WarningDiagnostic()
{
const string text = @"
const string Text = @"
using System;
public class MyClass
@ -69,7 +69,7 @@ public class MyClass
var expected = Verifier.Diagnostic()
.WithSpan(12, 9, 15, 10)
.WithArguments("NullReferenceException");
await Verifier.VerifyAnalyzerAsync(text, expected).ConfigureAwait(false);
await Verifier.VerifyAnalyzerAsync(Text, expected).ConfigureAwait(false);
}
[Fact]