-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
This little class has come to the rescue for the code generated JSON serialization I am performing.
For generics it performs a little differently.
The Modes array kicks in with values from the outer most argument to the innermost.
If you want to know if IEnumerable<string>? is nullable then the following does the trick
public static bool HasNullableAttribute(this PropertyInfo pi)
{
var v = pi.GetCustomAttributes(false)
.OfType<System.Runtime.CompilerServices.NullableAttribute>()
.FirstOrDefault();
if (v != default)
{
if(pi.PropertyType.IsGenericType && (v.Modes?.Length ?? 0) > 0)
{
return v.Modes[0] == 2;
}
return v.Mode == 2;
}
return false;
}
Metadata
Metadata
Assignees
Labels
No labels