public class AuthConfiguration
{
public string? RedirectPath { get; set; }
public IEnumerable<string>? Scopes { get; set; }
}
internal static class AuthConfigurationValidator
{
public static void Validate(AuthConfiguration configuration)
{
Requires.NotNullOrWhiteSpace(configuration.RedirectPath, nameof(configuration.RedirectPath));
Requires.NotNullOrEmpty(configuration.Scopes, nameof(configuration.Scopes));
}
}
Both calls to Requires generate a compiler warning:
Warning CS8604 Possible null reference argument for parameter 'value' in 'void Requires.NotNullOrWhiteSpace(string value, string? parameterName)'.
Warning CS8604 Possible null reference argument for parameter 'values' in 'void Requires.NotNullOrEmpty<string>(IEnumerable<string> values, string? parameterName)'.
If the signatures for those methods are changed so that the values parameter is marked as nullable, then this warning should go away.
Is this a valid scenario or am I missing something about how the nullability rules work?
Given the following code
Both calls to
Requires
generate a compiler warning:If the signatures for those methods are changed so that the
values
parameter is marked as nullable, then this warning should go away.Is this a valid scenario or am I missing something about how the nullability rules work?