mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 11:39:48 +00:00
Added handling for default values for methods
This commit is contained in:
parent
37562d37f6
commit
a45649d3d1
@ -46,6 +46,9 @@ public sealed class EmptyStringAnalyzer : DiagnosticAnalyzer
|
|||||||
if (IsInConstContext(stringLiteral))
|
if (IsInConstContext(stringLiteral))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (IsInParameterDefaultValue(stringLiteral))
|
||||||
|
return;
|
||||||
|
|
||||||
var diagnostic = Diagnostic.Create(RULE, stringLiteral.GetLocation());
|
var diagnostic = Diagnostic.Create(RULE, stringLiteral.GetLocation());
|
||||||
context.ReportDiagnostic(diagnostic);
|
context.ReportDiagnostic(diagnostic);
|
||||||
}
|
}
|
||||||
@ -65,4 +68,21 @@ public sealed class EmptyStringAnalyzer : DiagnosticAnalyzer
|
|||||||
_ => false
|
_ => false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsInParameterDefaultValue(LiteralExpressionSyntax stringLiteral)
|
||||||
|
{
|
||||||
|
// Prüfen, ob das String-Literal Teil eines Parameter-Defaults ist
|
||||||
|
var parameter = stringLiteral.FirstAncestorOrSelf<ParameterSyntax>();
|
||||||
|
if (parameter is null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Überprüfen, ob das String-Literal im Default-Wert des Parameters verwendet wird
|
||||||
|
if (parameter.Default is not null &&
|
||||||
|
parameter.Default.Value == stringLiteral)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user