Skip to content

Commit

Permalink
React to PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriySvyryd committed Jan 22, 2021
1 parent c0685a7 commit f7869a7
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public RelationalModelRuntimeInitializer(
/// <param name="model"> The model to initialize. </param>
/// <param name="preValidation">
/// <see langword="true"/> indicates that only pre-validation initialization should be performed;
/// <see langword="false"/> indicates that only post-validation initialization should be performed;
/// <see langword="false"/> indicates that only post-validation initialization should be performed.
/// </param>
protected override void InitializeModel(IModel model, bool preValidation)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ public sealed record RelationalConventionSetBuilderDependencies
/// </para>
/// </summary>
[EntityFrameworkInternal]
public RelationalConventionSetBuilderDependencies()
public RelationalConventionSetBuilderDependencies([NotNull] IRelationalAnnotationProvider relationalAnnotationProvider)
{
Check.NotNull(relationalAnnotationProvider, nameof(relationalAnnotationProvider));

#pragma warning disable CS0618 // Type or member is obsolete
RelationalAnnotationProvider = relationalAnnotationProvider;
#pragma warning restore CS0618 // Type or member is obsolete
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public static SqlServerValueGenerationStrategy GetValueGenerationStrategy(
internal static SqlServerValueGenerationStrategy GetValueGenerationStrategy(
[NotNull] this IProperty property,
in StoreObjectIdentifier storeObject,
ITypeMappingSource typeMappingSource)
ITypeMappingSource? typeMappingSource)
{
var annotation = property.FindAnnotation(SqlServerAnnotationNames.ValueGenerationStrategy);
if (annotation != null)
Expand Down Expand Up @@ -421,7 +421,7 @@ private static SqlServerValueGenerationStrategy GetDefaultValueGenerationStrateg
private static SqlServerValueGenerationStrategy GetDefaultValueGenerationStrategy(
IProperty property,
in StoreObjectIdentifier storeObject,
ITypeMappingSource typeMappingSource)
ITypeMappingSource? typeMappingSource)
{
var modelStrategy = property.DeclaringEntityType.Model.GetValueGenerationStrategy();

Expand Down Expand Up @@ -522,7 +522,7 @@ public static bool IsCompatibleWithValueGeneration([NotNull] IProperty property)
private static bool IsCompatibleWithValueGeneration(
[NotNull] IProperty property,
in StoreObjectIdentifier storeObject,
ITypeMappingSource typeMappingSource)
ITypeMappingSource? typeMappingSource)
{
var type = property.ClrType;

Expand Down
4 changes: 2 additions & 2 deletions src/EFCore/Infrastructure/Annotatable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ protected virtual Annotation SetRuntimeAnnotation(
/// </returns>
public virtual TValue GetOrAddRuntimeAnnotationValue<TValue, TArg>(
string name,
Func<TArg, TValue> valueFactory,
TArg factoryArgument)
Func<TArg?, TValue> valueFactory,
TArg? factoryArgument)
=> (TValue)GetOrCreateRuntimeAnnotations().GetOrAdd(
name,
static (n, t) => t.Annotatable.CreateRuntimeAnnotation(n, t.CreateValue(t.Argument)),
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore/Infrastructure/IAnnotatable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public interface IAnnotatable
/// </returns>
TValue GetOrAddRuntimeAnnotationValue<TValue, TArg>(
[NotNull] string name,
[NotNull] Func<TArg, TValue> valueFactory,
[CanBeNull] TArg factoryArgument);
[NotNull] Func<TArg?, TValue> valueFactory,
[CanBeNull] TArg? factoryArgument);
}
}
2 changes: 1 addition & 1 deletion src/EFCore/Infrastructure/ModelRuntimeInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public virtual IModel Initialize(IModel model, IDiagnosticsLogger<DbLoggerCatego
/// <param name="model"> The model to initialize. </param>
/// <param name="preValidation">
/// <see langword="true"/> indicates that only pre-validation initialization should be performed;
/// <see langword="false"/> indicates that only post-validation initialization should be performed;
/// <see langword="false"/> indicates that only post-validation initialization should be performed.
/// </param>
protected virtual void InitializeModel([NotNull] IModel model, bool preValidation)
{
Expand Down
23 changes: 11 additions & 12 deletions src/EFCore/Metadata/Internal/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class Model : ConventionAnnotatable, IMutableModel, IConventionModel
private ChangeTrackingStrategy? _changeTrackingStrategy;

private ConfigurationSource? _changeTrackingStrategyConfigurationSource;
private ModelDependencies? _scopedModelDependencies;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -96,7 +97,8 @@ public Model([NotNull] ConventionSet conventions, [CanBeNull] ModelDependencies?
/// </summary>
public virtual ConventionDispatcher ConventionDispatcher
{
[DebuggerStepThrough] get => _conventionDispatcher ?? throw new InvalidOperationException(CoreStrings.ModelReadOnly);
[DebuggerStepThrough]
get => _conventionDispatcher ?? throw new InvalidOperationException(CoreStrings.ModelReadOnly);
}

/// <summary>
Expand All @@ -106,7 +108,12 @@ public virtual ConventionDispatcher ConventionDispatcher
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[CA.DisallowNull]
public virtual ModelDependencies? ScopedModelDependencies { get; [param: NotNull] set; }
public virtual ModelDependencies? ScopedModelDependencies
{
get => _scopedModelDependencies;
[param: NotNull]
set => _scopedModelDependencies = value;
}

/// <summary>
/// Indicates whether the model is read-only.
Expand All @@ -118,14 +125,6 @@ public virtual ConventionDispatcher ConventionDispatcher
/// </summary>
public virtual bool IsModelReadOnly => _conventionDispatcher == null;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsValidated { get; set; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down Expand Up @@ -877,7 +876,7 @@ public virtual IConventionBatch DelayConventions()
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual T Track<T>([NotNull] Func<T> func, [CanBeNull] [CA.DisallowNull] ref IConventionForeignKey? foreignKey)
public virtual T Track<T>([NotNull] Func<T> func, [CanBeNull][CA.DisallowNull] ref IConventionForeignKey? foreignKey)
{
EnsureMutable();
return ConventionDispatcher.Track(func, ref foreignKey);
Expand Down Expand Up @@ -913,7 +912,7 @@ private IModel MakeReadonly()
{
// ConventionDispatcher should never be accessed once the model is made read-only.
_conventionDispatcher = null;
ScopedModelDependencies = null!;
_scopedModelDependencies = null;
return this;
}

Expand Down
12 changes: 3 additions & 9 deletions src/EFCore/Metadata/Internal/Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,9 @@ private static bool DefaultIsConcurrencyToken
public virtual CoreTypeMapping? TypeMapping
{
get
{
if (_typeMapping == null
&& IsReadOnly)
{
_typeMapping = ((IModel)DeclaringEntityType.Model).ModelDependencies?.TypeMappingSource.FindMapping(this);
}

return _typeMapping;
}
=> _typeMapping == null && IsReadOnly
? _typeMapping ??= ((IModel)DeclaringEntityType.Model).ModelDependencies?.TypeMappingSource.FindMapping(this)
: _typeMapping;

[param: NotNull]
set => SetTypeMapping(value, ConfigurationSource.Explicit);
Expand Down

0 comments on commit f7869a7

Please sign in to comment.