From eb4bb1c2578bdfac0b27be30180cad73ed556002 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Fri, 30 Oct 2020 22:20:38 +0200 Subject: [PATCH] Remove nullability from mutable Add methods And FinalizeModel --- .../Extensions/MutableEntityTypeExtensions.cs | 18 +++++++++--------- .../Extensions/MutableModelExtensions.cs | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/EFCore/Extensions/MutableEntityTypeExtensions.cs b/src/EFCore/Extensions/MutableEntityTypeExtensions.cs index ffd4ea325b8..a57852c6f89 100644 --- a/src/EFCore/Extensions/MutableEntityTypeExtensions.cs +++ b/src/EFCore/Extensions/MutableEntityTypeExtensions.cs @@ -181,7 +181,7 @@ public static IEnumerable GetDeclaredIndexes([NotNull] this IMuta /// The entity type. /// The property to use as an alternate key. /// The newly created key. - public static IMutableKey? AddKey( + public static IMutableKey AddKey( [NotNull] this IMutableEntityType entityType, [NotNull] IMutableProperty property) => Check.NotNull(entityType, nameof(entityType)).AddKey(new[] { property }); @@ -316,7 +316,7 @@ public static IEnumerable GetDeclaredReferencingForeignKeys( /// base type of the hierarchy). /// /// The newly created foreign key. - public static IMutableForeignKey? AddForeignKey( + public static IMutableForeignKey AddForeignKey( [NotNull] this IMutableEntityType entityType, [NotNull] IMutableProperty property, [NotNull] IMutableKey principalKey, @@ -453,7 +453,7 @@ public static IEnumerable GetNavigations([NotNull] this IMut /// The entity type. /// The corresponding member on the entity class. /// The newly created property. - public static IMutableProperty? AddProperty( + public static IMutableProperty AddProperty( [NotNull] this IMutableEntityType entityType, [NotNull] MemberInfo memberInfo) => Check.NotNull(entityType, nameof(entityType)) @@ -465,10 +465,10 @@ public static IEnumerable GetNavigations([NotNull] this IMut /// The entity type. /// The name of the property to add. /// The newly created property. - public static IMutableProperty? AddProperty( + public static IMutableProperty AddProperty( [NotNull] this IMutableEntityType entityType, [NotNull] string name) - => ((EntityType)entityType).AddProperty(name, ConfigurationSource.Explicit); + => ((EntityType)entityType).AddProperty(name, ConfigurationSource.Explicit)!; /// /// Adds a property to this entity type. @@ -477,11 +477,11 @@ public static IEnumerable GetNavigations([NotNull] this IMut /// The name of the property to add. /// The type of value the property will hold. /// The newly created property. - public static IMutableProperty? AddProperty( + public static IMutableProperty AddProperty( [NotNull] this IMutableEntityType entityType, [NotNull] string name, [NotNull] Type propertyType) - => ((EntityType)entityType).AddProperty(name, propertyType, ConfigurationSource.Explicit, ConfigurationSource.Explicit); + => ((EntityType)entityType).AddProperty(name, propertyType, ConfigurationSource.Explicit, ConfigurationSource.Explicit)!; /// /// Adds a property backed up by an indexer to this entity type. @@ -490,7 +490,7 @@ public static IEnumerable GetNavigations([NotNull] this IMut /// The name of the property to add. /// The type of value the property will hold. /// The newly created property. - public static IMutableProperty? AddIndexerProperty( + public static IMutableProperty AddIndexerProperty( [NotNull] this IMutableEntityType entityType, [NotNull] string name, [NotNull] Type propertyType) @@ -526,7 +526,7 @@ public static IEnumerable GetNavigations([NotNull] this IMut /// The entity type. /// The property to be indexed. /// The newly created index. - public static IMutableIndex? AddIndex( + public static IMutableIndex AddIndex( [NotNull] this IMutableEntityType entityType, [NotNull] IMutableProperty property) => Check.NotNull(entityType, nameof(entityType)).AddIndex(new[] { property }); diff --git a/src/EFCore/Extensions/MutableModelExtensions.cs b/src/EFCore/Extensions/MutableModelExtensions.cs index 7ec353d9acd..f00b40e1cc9 100644 --- a/src/EFCore/Extensions/MutableModelExtensions.cs +++ b/src/EFCore/Extensions/MutableModelExtensions.cs @@ -206,9 +206,9 @@ public static void SetChangeTrackingStrategy( /// The model to add the ignored type to. /// The entity type to be ignored. /// The name of the ignored type. - public static string? AddIgnored([NotNull] this IMutableModel model, [NotNull] Type type) + public static string AddIgnored([NotNull] this IMutableModel model, [NotNull] Type type) => Check.NotNull((Model)model, nameof(model)).AddIgnored( - Check.NotNull(type, nameof(type)), ConfigurationSource.Explicit); + Check.NotNull(type, nameof(type)), ConfigurationSource.Explicit)!; /// /// Returns a value indicating whether the entity types using the given type should be configured @@ -262,7 +262,7 @@ public static void AddShared([NotNull] this IMutableModel model, [NotNull] Type /// /// The model to finalize. /// The finalized . - public static IModel? FinalizeModel([NotNull] this IMutableModel model) - => ((Model)model).FinalizeModel(); + public static IModel FinalizeModel([NotNull] this IMutableModel model) + => ((Model)model).FinalizeModel()!; } }