Skip to content

Commit 216b034

Browse files
committed
Nullable annotations for metadata 2
Annotates Model, Property, Navigation, Key, Index, and all their extensions. Part of #19007
1 parent 4699660 commit 216b034

File tree

90 files changed

+779
-584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+779
-584
lines changed

src/EFCore/ChangeTracking/Internal/KeyPropagator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static InternalEntityEntry TryPropagateValue(InternalEntityEntry entry,
184184

185185
private ValueGenerator TryGetValueGenerator(IProperty property)
186186
{
187-
var generationProperty = property.GetGenerationProperty();
187+
var generationProperty = property.FindGenerationProperty();
188188

189189
return generationProperty != null
190190
? _valueGeneratorSelector.Select(generationProperty, generationProperty.DeclaringEntityType)

src/EFCore/ChangeTracking/Internal/KeyValueFactoryFactory.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public virtual IPrincipalKeyValueFactory<TKey> Create<TKey>([NotNull] IKey key)
2828
? CreateSimpleFactory<TKey>(key)
2929
: (IPrincipalKeyValueFactory<TKey>)CreateCompositeFactory(key);
3030

31-
[UsedImplicitly]
3231
private static SimplePrincipalKeyValueFactory<TKey> CreateSimpleFactory<TKey>(IKey key)
3332
{
3433
var dependentFactory = new DependentKeyValueFactoryFactory();

src/EFCore/ChangeTracking/ValueComparerExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
using JetBrains.Annotations;
55

6+
#nullable enable
7+
68
namespace Microsoft.EntityFrameworkCore.ChangeTracking
79
{
810
/// <summary>

src/EFCore/Extensions/ConventionEntityTypeExtensions.cs

Lines changed: 39 additions & 36 deletions
Large diffs are not rendered by default.

src/EFCore/Extensions/ConventionNavigationExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using JetBrains.Annotations;
66
using Microsoft.EntityFrameworkCore.Metadata;
77

8+
#nullable enable
9+
810
// ReSharper disable once CheckNamespace
911
namespace Microsoft.EntityFrameworkCore
1012
{

src/EFCore/Extensions/ConventionPropertyBaseExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using Microsoft.EntityFrameworkCore.Metadata.Internal;
77
using Microsoft.EntityFrameworkCore.Utilities;
88

9+
#nullable enable
10+
911
// ReSharper disable once CheckNamespace
1012
namespace Microsoft.EntityFrameworkCore
1113
{

src/EFCore/Extensions/ConventionPropertyExtensions.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
1313
using Microsoft.EntityFrameworkCore.ValueGeneration;
1414

15+
#nullable enable
16+
1517
// ReSharper disable once CheckNamespace
1618
namespace Microsoft.EntityFrameworkCore
1719
{
@@ -26,8 +28,8 @@ public static class ConventionPropertyExtensions
2628
/// </summary>
2729
/// <param name="property"> The foreign key property. </param>
2830
/// <returns> The first associated principal property, or <see langword="null" /> if none exists. </returns>
29-
public static IConventionProperty FindFirstPrincipal([NotNull] this IConventionProperty property)
30-
=> (IConventionProperty)((IProperty)property).FindFirstPrincipal();
31+
public static IConventionProperty? FindFirstPrincipal([NotNull] this IConventionProperty property)
32+
=> (IConventionProperty?)((IProperty)property).FindFirstPrincipal();
3133

3234
/// <summary>
3335
/// Finds the list of principal properties including the given property that the given property is constrained by
@@ -68,8 +70,8 @@ public static IEnumerable<IConventionIndex> GetContainingIndexes([NotNull] this
6870
/// <returns>
6971
/// The primary that use this property, or <see langword="null" /> if it is not part of the primary key.
7072
/// </returns>
71-
public static IConventionKey FindContainingPrimaryKey([NotNull] this IConventionProperty property)
72-
=> (IConventionKey)((IProperty)property).FindContainingPrimaryKey();
73+
public static IConventionKey? FindContainingPrimaryKey([NotNull] this IConventionProperty property)
74+
=> (IConventionKey?)((IProperty)property).FindContainingPrimaryKey();
7375

7476
/// <summary>
7577
/// Gets all primary or alternate keys that use this property (including composite keys in which this property
@@ -280,7 +282,7 @@ public static CoreTypeMapping SetTypeMapping(
280282
/// </param>
281283
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
282284
/// <returns> The configured value. </returns>
283-
public static Func<IProperty, IEntityType, ValueGenerator> SetValueGeneratorFactory(
285+
public static Func<IProperty, IEntityType, ValueGenerator>? SetValueGeneratorFactory(
284286
[NotNull] this IConventionProperty property,
285287
[NotNull] Func<IProperty, IEntityType, ValueGenerator> valueGeneratorFactory,
286288
bool fromDataAnnotation = false)
@@ -302,9 +304,9 @@ public static Func<IProperty, IEntityType, ValueGenerator> SetValueGeneratorFact
302304
/// <param name="converter"> The converter, or <see langword="null" /> to remove any previously set converter. </param>
303305
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
304306
/// <returns> The configured value. </returns>
305-
public static ValueConverter SetValueConverter(
307+
public static ValueConverter? SetValueConverter(
306308
[NotNull] this IConventionProperty property,
307-
[CanBeNull] ValueConverter converter,
309+
[CanBeNull] ValueConverter? converter,
308310
bool fromDataAnnotation = false)
309311
=> property.AsProperty().SetValueConverter(
310312
converter, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
@@ -324,9 +326,9 @@ public static ValueConverter SetValueConverter(
324326
/// <param name="providerClrType"> The type to use, or <see langword="null" /> to remove any previously set type. </param>
325327
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
326328
/// <returns> The configured value. </returns>
327-
public static Type SetProviderClrType(
329+
public static Type? SetProviderClrType(
328330
[NotNull] this IConventionProperty property,
329-
[CanBeNull] Type providerClrType,
331+
[CanBeNull] Type? providerClrType,
330332
bool fromDataAnnotation = false)
331333
=> property.AsProperty().SetProviderClrType(
332334
providerClrType, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
@@ -346,9 +348,9 @@ public static Type SetProviderClrType(
346348
/// <param name="comparer"> The comparer, or <see langword="null" /> to remove any previously set comparer. </param>
347349
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
348350
/// <returns> The configured value. </returns>
349-
public static ValueComparer SetValueComparer(
351+
public static ValueComparer? SetValueComparer(
350352
[NotNull] this IConventionProperty property,
351-
[CanBeNull] ValueComparer comparer,
353+
[CanBeNull] ValueComparer? comparer,
352354
bool fromDataAnnotation = false)
353355
=> property.AsProperty().SetValueComparer(
354356
comparer, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
@@ -370,7 +372,7 @@ public static ValueComparer SetValueComparer(
370372
[Obsolete("Use SetValueComparer. Only a single value comparer is allowed for a given property.")]
371373
public static void SetKeyValueComparer(
372374
[NotNull] this IConventionProperty property,
373-
[CanBeNull] ValueComparer comparer,
375+
[CanBeNull] ValueComparer? comparer,
374376
bool fromDataAnnotation = false)
375377
=> property.AsProperty().SetValueComparer(
376378
comparer, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
@@ -393,7 +395,7 @@ public static void SetKeyValueComparer(
393395
[Obsolete("Use SetValueComparer. Only a single value comparer is allowed for a given property.")]
394396
public static void SetStructuralValueComparer(
395397
[NotNull] this IConventionProperty property,
396-
[CanBeNull] ValueComparer comparer,
398+
[CanBeNull] ValueComparer? comparer,
397399
bool fromDataAnnotation = false)
398400
=> property.SetKeyValueComparer(comparer, fromDataAnnotation);
399401

src/EFCore/Extensions/ConventionTypeBaseExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using Microsoft.EntityFrameworkCore.Metadata.Internal;
77
using Microsoft.EntityFrameworkCore.Utilities;
88

9+
#nullable enable
10+
911
// ReSharper disable once CheckNamespace
1012
namespace Microsoft.EntityFrameworkCore
1113
{

0 commit comments

Comments
 (0)