-
Notifications
You must be signed in to change notification settings - Fork 32
AV1553: Suppress on CallerArgumentExpressions #136
Copy link
Copy link
Closed
Description
Analyzer
AV1553: DoNotUseOptionalParameterWithDefaultValueNullAnalyzer
Repro steps
#nullable enable
internal static class ArgumentGuard
{
public static void NotNull<T>(T? value, [CallerArgumentExpression("value")] string? parameterName = null)
where T : class
{
ArgumentNullException.ThrowIfNull(value, parameterName);
}
}Expected behavior
No warning on parameterName, because the purpose of using CallerArgumentExpression is an optional string, which is filled in by the C# compiler. Using a non-nullable parameterName or removing the default value or null causes errors/warnings on the use of this attribute.
Actual behavior
Warning AV1553: Optional parameter 'parameterName' of type 'string' has default value 'null'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels