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

Nullable annotations for metadata 2 #23147

Merged
1 commit merged into from
Oct 31, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/EFCore/ChangeTracking/Internal/KeyPropagator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private static InternalEntityEntry TryPropagateValue(InternalEntityEntry entry,

private ValueGenerator TryGetValueGenerator(IProperty property)
{
var generationProperty = property.GetGenerationProperty();
var generationProperty = property.FindGenerationProperty();

return generationProperty != null
? _valueGeneratorSelector.Select(generationProperty, generationProperty.DeclaringEntityType)
Expand Down
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]
smitpatel marked this conversation as resolved.
Show resolved Hide resolved
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
28 changes: 15 additions & 13 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 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