Add more contextual information to diagnostics

This commit is contained in:
Oleksii Holub
2022-04-20 20:27:53 +03:00
parent 864efd3179
commit 5c848056c5
10 changed files with 42 additions and 18 deletions

View File

@@ -13,7 +13,8 @@ public class ParameterMustBeLastIfNonScalarAnalyzer : AnalyzerBase
public ParameterMustBeLastIfNonScalarAnalyzer()
: base(
"Parameters of non-scalar types must be the last in order",
"This parameter has a non-scalar type so it must be the last in order (its order must be highest within the command).")
"This parameter has a non-scalar type so it must be the last in order (its order must be highest within the command). " +
"Property bound to another non-scalar parameter: `{0}`.")
{
}
@@ -48,7 +49,10 @@ public class ParameterMustBeLastIfNonScalarAnalyzer : AnalyzerBase
if (otherParameter.Order > parameter.Order)
{
context.ReportDiagnostic(
CreateDiagnostic(propertyDeclaration.Identifier.GetLocation())
CreateDiagnostic(
propertyDeclaration.Identifier.GetLocation(),
otherProperty.Name
)
);
}
}