mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Add more contextual information to diagnostics
This commit is contained in:
@@ -15,7 +15,8 @@ public class OptionMustHaveUniqueNameAnalyzer : AnalyzerBase
|
||||
: base(
|
||||
"Options must have unique names",
|
||||
"This option's name must be unique within the command (comparison IS NOT case sensitive). " +
|
||||
"Specified name: '{0}'.")
|
||||
"Specified name: `{0}`. " +
|
||||
"Property bound to another option with the same name: `{1}`.")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,7 +56,8 @@ public class OptionMustHaveUniqueNameAnalyzer : AnalyzerBase
|
||||
context.ReportDiagnostic(
|
||||
CreateDiagnostic(
|
||||
propertyDeclaration.Identifier.GetLocation(),
|
||||
option.Name
|
||||
option.Name,
|
||||
otherProperty.Name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ public class OptionMustHaveUniqueShortNameAnalyzer : AnalyzerBase
|
||||
: base(
|
||||
"Options must have unique short names",
|
||||
"This option's short name must be unique within the command (comparison IS case sensitive). " +
|
||||
"Specified short name: '{0}'.")
|
||||
"Specified short name: `{0}` " +
|
||||
"Property bound to another option with the same short name: `{1}`.")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -54,7 +55,8 @@ public class OptionMustHaveUniqueShortNameAnalyzer : AnalyzerBase
|
||||
context.ReportDiagnostic(
|
||||
CreateDiagnostic(
|
||||
propertyDeclaration.Identifier.GetLocation(),
|
||||
option.ShortName
|
||||
option.ShortName,
|
||||
otherProperty.Name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class OptionMustHaveValidNameAnalyzer : AnalyzerBase
|
||||
: base(
|
||||
"Options must have valid names",
|
||||
"This option's name must be at least 2 characters long and must start with a letter. " +
|
||||
"Specified name: '{0}'.")
|
||||
"Specified name: `{0}`.")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class OptionMustHaveValidShortNameAnalyzer : AnalyzerBase
|
||||
: base(
|
||||
"Option short names must be letter characters",
|
||||
"This option's short name must be a single letter character. " +
|
||||
"Specified short name: '{0}'.")
|
||||
"Specified short name: `{0}`.")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ public class ParameterMustBeLastIfNonRequiredAnalyzer : AnalyzerBase
|
||||
public ParameterMustBeLastIfNonRequiredAnalyzer()
|
||||
: base(
|
||||
"Parameters marked as non-required must be the last in order",
|
||||
"This parameter is non-required so it must be the last in order (its order must be highest within the command).")
|
||||
"This parameter is non-required so it must be the last in order (its order must be highest within the command). " +
|
||||
"Property bound to another non-required parameter: `{0}`.")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,7 +49,10 @@ public class ParameterMustBeLastIfNonRequiredAnalyzer : AnalyzerBase
|
||||
if (otherParameter.Order > parameter.Order)
|
||||
{
|
||||
context.ReportDiagnostic(
|
||||
CreateDiagnostic(propertyDeclaration.Identifier.GetLocation())
|
||||
CreateDiagnostic(
|
||||
propertyDeclaration.Identifier.GetLocation(),
|
||||
otherProperty.Name
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ public class ParameterMustBeSingleIfNonRequiredAnalyzer : AnalyzerBase
|
||||
public ParameterMustBeSingleIfNonRequiredAnalyzer()
|
||||
: base(
|
||||
"Parameters marked as non-required are limited to one per command",
|
||||
"This parameter is non-required so it must be the only such parameter in the command.")
|
||||
"This parameter is non-required so it must be the only such parameter in the command. " +
|
||||
"Property bound to another non-required parameter: `{0}`.")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,7 +49,10 @@ public class ParameterMustBeSingleIfNonRequiredAnalyzer : AnalyzerBase
|
||||
if (otherParameter.IsRequired == false)
|
||||
{
|
||||
context.ReportDiagnostic(
|
||||
CreateDiagnostic(propertyDeclaration.Identifier.GetLocation())
|
||||
CreateDiagnostic(
|
||||
propertyDeclaration.Identifier.GetLocation(),
|
||||
otherProperty.Name
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ public class ParameterMustHaveUniqueNameAnalyzer : AnalyzerBase
|
||||
: base(
|
||||
"Parameters must have unique names",
|
||||
"This parameter's name must be unique within the command (comparison IS NOT case sensitive). " +
|
||||
"Specified name: '{0}'.")
|
||||
"Specified name: `{0}`. " +
|
||||
"Property bound to another parameter with the same name: `{1}`.")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,7 +56,8 @@ public class ParameterMustHaveUniqueNameAnalyzer : AnalyzerBase
|
||||
context.ReportDiagnostic(
|
||||
CreateDiagnostic(
|
||||
propertyDeclaration.Identifier.GetLocation(),
|
||||
parameter.Name
|
||||
parameter.Name,
|
||||
otherProperty.Name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ public class ParameterMustHaveUniqueOrderAnalyzer : AnalyzerBase
|
||||
: base(
|
||||
"Parameters must have unique order",
|
||||
"This parameter's order must be unique within the command. " +
|
||||
"Specified order: {0}.")
|
||||
"Specified order: {0}. " +
|
||||
"Property bound to another parameter with the same order: `{1}`.")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,7 +49,8 @@ public class ParameterMustHaveUniqueOrderAnalyzer : AnalyzerBase
|
||||
context.ReportDiagnostic(
|
||||
CreateDiagnostic(
|
||||
propertyDeclaration.Identifier.GetLocation(),
|
||||
parameter.Order
|
||||
parameter.Order,
|
||||
otherProperty.Name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user