mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Improved style checker
This commit is contained in:
@@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.Diagnostics;
|
|||||||
|
|
||||||
namespace GlitchyEngine.StyleChecker;
|
namespace GlitchyEngine.StyleChecker;
|
||||||
|
|
||||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
//[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||||
public class StyleChecker : DiagnosticAnalyzer
|
public class StyleChecker : DiagnosticAnalyzer
|
||||||
{
|
{
|
||||||
public const string DiagnosticId = "MakeConst2";
|
public const string DiagnosticId = "MakeConst2";
|
||||||
|
|||||||
@@ -66,14 +66,7 @@ public class CatchUnmanagedCallersOnlyAnalyzer : DiagnosticAnalyzer
|
|||||||
if (method.Body is not null)
|
if (method.Body is not null)
|
||||||
{
|
{
|
||||||
// Check if the outer most statement is a try-catch block.
|
// Check if the outer most statement is a try-catch block.
|
||||||
var tryStatement = method.Body.Statements.FirstOrDefault(s => s is TryStatementSyntax) as TryStatementSyntax;
|
if (method.Body.Statements.FirstOrDefault() is TryStatementSyntax tryStatement)
|
||||||
if (tryStatement is null)
|
|
||||||
{
|
|
||||||
// If there is no try-catch block, report a diagnostic.
|
|
||||||
ReportDiagnostic();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Check if the try block has a catch clause.
|
// Check if the try block has a catch clause.
|
||||||
if (tryStatement.Catches.Count == 0)
|
if (tryStatement.Catches.Count == 0)
|
||||||
@@ -98,6 +91,12 @@ public class CatchUnmanagedCallersOnlyAnalyzer : DiagnosticAnalyzer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If there is no try-catch block, report a diagnostic.
|
||||||
|
ReportDiagnostic();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (method.ExpressionBody is not null)
|
else if (method.ExpressionBody is not null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user