Skip to content

Commit

Permalink
Merge pull request #623 from StefanMaron/TryCatch
Browse files Browse the repository at this point in the history
Add TryCatch to investigate InvalidCastException
  • Loading branch information
Arthurvdv authored May 23, 2024
2 parents 7e1ccc3 + 422d0ae commit ee98f89
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Design/Rule0043SecretText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BusinessCentral.LinterCop.Design
[DiagnosticAnalyzer]
public class Rule0043SecretText : DiagnosticAnalyzer
{
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create<DiagnosticDescriptor>(DiagnosticDescriptors.Rule0043SecretText);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create<DiagnosticDescriptor>(DiagnosticDescriptors.Rule0043SecretText, DiagnosticDescriptors.Rule0000ErrorInRule);

private static readonly string authorization = "Authorization";

Expand Down Expand Up @@ -90,7 +90,14 @@ private void AnalyzeHttpObjects(OperationAnalysisContext ctx)
return;
}

if (!IsAuthorizationArgument(operation.Arguments[0])) return;
try
{
if (!IsAuthorizationArgument(operation.Arguments[0])) return;
}
catch (InvalidCastException)
{
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0000ErrorInRule, ctx.Operation.Syntax.GetLocation(), new Object[] { "Rule0043", "InvalidCastException", "at Line 63" }));
}

if (!IsArgumentOfTypeSecretText(operation.Arguments[1]))
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0043SecretText, ctx.Operation.Syntax.GetLocation()));
Expand Down

0 comments on commit ee98f89

Please sign in to comment.