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 ParameterMustBeSingleIfNonScalarAnalyzer : AnalyzerBase
public ParameterMustBeSingleIfNonScalarAnalyzer()
: base(
"Parameters of non-scalar types are limited to one per command",
"This parameter has a non-scalar type so it must be the only such parameter in the command.")
"This parameter has a non-scalar type so it must be the only such parameter in the command. " +
"Property bound to another non-scalar parameter: `{0}`.")
{
}
@@ -48,7 +49,10 @@ public class ParameterMustBeSingleIfNonScalarAnalyzer : AnalyzerBase
if (!otherParameter.IsScalar())
{
context.ReportDiagnostic(
CreateDiagnostic(propertyDeclaration.Identifier.GetLocation())
CreateDiagnostic(
propertyDeclaration.Identifier.GetLocation(),
otherProperty.Name
)
);
}
}