Skip to content

Commit

Permalink
Nullable annotations for metadata 2
Browse files Browse the repository at this point in the history
Annotates Model, Property, Navigation, Key, Index, and all their extensions.

Part of #19007
  • Loading branch information
roji committed Oct 30, 2020
1 parent 4699660 commit 66afa93
Show file tree
Hide file tree
Showing 84 changed files with 720 additions and 533 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public virtual IPrincipalKeyValueFactory<TKey> Create<TKey>([NotNull] IKey key)
? CreateSimpleFactory<TKey>(key)
: (IPrincipalKeyValueFactory<TKey>)CreateCompositeFactory(key);

[UsedImplicitly]
private static SimplePrincipalKeyValueFactory<TKey> CreateSimpleFactory<TKey>(IKey key)
{
var dependentFactory = new DependentKeyValueFactoryFactory();
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore/ChangeTracking/ValueComparerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using JetBrains.Annotations;

#nullable enable

namespace Microsoft.EntityFrameworkCore.ChangeTracking
{
/// <summary>
Expand Down
75 changes: 39 additions & 36 deletions src/EFCore/Extensions/ConventionEntityTypeExtensions.cs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/EFCore/Extensions/ConventionNavigationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable enable

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore/Extensions/ConventionPropertyBaseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
Expand Down
30 changes: 16 additions & 14 deletions src/EFCore/Extensions/ConventionPropertyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Microsoft.EntityFrameworkCore.ValueGeneration;

#nullable enable

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
Expand All @@ -26,8 +28,8 @@ public static class ConventionPropertyExtensions
/// </summary>
/// <param name="property"> The foreign key property. </param>
/// <returns> The first associated principal property, or <see langword="null" /> if none exists. </returns>
public static IConventionProperty FindFirstPrincipal([NotNull] this IConventionProperty property)
=> (IConventionProperty)((IProperty)property).FindFirstPrincipal();
public static IConventionProperty? FindFirstPrincipal([NotNull] this IConventionProperty property)
=> (IConventionProperty?)((IProperty)property).FindFirstPrincipal();

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

/// <summary>
/// Gets all primary or alternate keys that use this property (including composite keys in which this property
Expand All @@ -88,7 +90,7 @@ public static IEnumerable<IConventionKey> GetContainingKeys([NotNull] this IConv
/// <param name="property"> The property. </param>
/// <param name="typeMapping"> The <see cref="CoreTypeMapping" /> for this property. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
public static CoreTypeMapping SetTypeMapping(
public static CoreTypeMapping? SetTypeMapping(
[NotNull] this IConventionProperty property,
[NotNull] CoreTypeMapping typeMapping,
bool fromDataAnnotation = false)
Expand Down Expand Up @@ -280,7 +282,7 @@ public static CoreTypeMapping SetTypeMapping(
/// </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> The configured value. </returns>
public static Func<IProperty, IEntityType, ValueGenerator> SetValueGeneratorFactory(
public static Func<IProperty, IEntityType, ValueGenerator>? SetValueGeneratorFactory(
[NotNull] this IConventionProperty property,
[NotNull] Func<IProperty, IEntityType, ValueGenerator> valueGeneratorFactory,
bool fromDataAnnotation = false)
Expand All @@ -302,9 +304,9 @@ public static Func<IProperty, IEntityType, ValueGenerator> SetValueGeneratorFact
/// <param name="converter"> The converter, or <see langword="null" /> to remove any previously set converter. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> The configured value. </returns>
public static ValueConverter SetValueConverter(
public static ValueConverter? SetValueConverter(
[NotNull] this IConventionProperty property,
[CanBeNull] ValueConverter converter,
[CanBeNull] ValueConverter? converter,
bool fromDataAnnotation = false)
=> property.AsProperty().SetValueConverter(
converter, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
Expand All @@ -324,9 +326,9 @@ public static ValueConverter SetValueConverter(
/// <param name="providerClrType"> The type to use, or <see langword="null" /> to remove any previously set type. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> The configured value. </returns>
public static Type SetProviderClrType(
public static Type? SetProviderClrType(
[NotNull] this IConventionProperty property,
[CanBeNull] Type providerClrType,
[CanBeNull] Type? providerClrType,
bool fromDataAnnotation = false)
=> property.AsProperty().SetProviderClrType(
providerClrType, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
Expand All @@ -346,9 +348,9 @@ public static Type SetProviderClrType(
/// <param name="comparer"> The comparer, or <see langword="null" /> to remove any previously set comparer. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> The configured value. </returns>
public static ValueComparer SetValueComparer(
public static ValueComparer? SetValueComparer(
[NotNull] this IConventionProperty property,
[CanBeNull] ValueComparer comparer,
[CanBeNull] ValueComparer? comparer,
bool fromDataAnnotation = false)
=> property.AsProperty().SetValueComparer(
comparer, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
Expand All @@ -370,7 +372,7 @@ public static ValueComparer SetValueComparer(
[Obsolete("Use SetValueComparer. Only a single value comparer is allowed for a given property.")]
public static void SetKeyValueComparer(
[NotNull] this IConventionProperty property,
[CanBeNull] ValueComparer comparer,
[CanBeNull] ValueComparer? comparer,
bool fromDataAnnotation = false)
=> property.AsProperty().SetValueComparer(
comparer, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
Expand All @@ -393,7 +395,7 @@ public static void SetKeyValueComparer(
[Obsolete("Use SetValueComparer. Only a single value comparer is allowed for a given property.")]
public static void SetStructuralValueComparer(
[NotNull] this IConventionProperty property,
[CanBeNull] ValueComparer comparer,
[CanBeNull] ValueComparer? comparer,
bool fromDataAnnotation = false)
=> property.SetKeyValueComparer(comparer, fromDataAnnotation);

Expand Down
2 changes: 2 additions & 0 deletions src/EFCore/Extensions/ConventionTypeBaseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
Expand Down
Loading

0 comments on commit 66afa93

Please sign in to comment.