Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around mono bug affecting Xamarin Android (#22982) #22995

Merged
merged 1 commit into from
Oct 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/EFCore/Metadata/Conventions/NonNullableConventionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ protected virtual bool IsNonNullableReferenceType(
var state = GetOrInitializeState(modelBuilder);

// First check for [MaybeNull] on the return value. If it exists, the member is nullable.
// Note: avoid using GetCustomAttribute<> below because of https://github.com/mono/mono/issues/17477
var isMaybeNull = memberInfo switch
{
FieldInfo f => f.GetCustomAttribute<CA.MaybeNullAttribute>() != null,
PropertyInfo p => p.GetMethod?.ReturnParameter?.GetCustomAttribute<CA.MaybeNullAttribute>() != null,
FieldInfo f
=> f.CustomAttributes.Any(a => a.AttributeType == typeof(CA.MaybeNullAttribute)),
PropertyInfo p
=> p.GetMethod?.ReturnParameter?.CustomAttributes?.Any(a => a.AttributeType == typeof(CA.MaybeNullAttribute)) == true,
_ => false
};

Expand Down