Skip to content

Commit

Permalink
Obsolete CoreTypeMapping.ValueGeneratorFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriySvyryd authored Jul 31, 2023
1 parent 120e6c0 commit 82e96d9
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((ICheckConstraint)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoreStoredProcedure)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoreStoredProcedureParameter)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoreStoredProcedureResultColumn)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoreStoredProcedureReturnValue)this).ToDebugString(),
Expand Down
1 change: 0 additions & 1 deletion src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoredProcedure)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoredProcedureMapping)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoredProcedureParameter)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoredProcedureParameterMapping)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoredProcedureResultColumn)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IStoredProcedureResultColumnMapping)this).ToDebugString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public RelationalConverterMappingHints(
int? scale = null,
bool? unicode = null,
bool? fixedLength = null,
Func<IProperty, ITypeBase, ValueGenerator>? valueGeneratorFactory = null,
Func<IProperty, IEntityType, ValueGenerator>? valueGeneratorFactory = null,
DbType? dbType = null)
: base(size, precision, scale, unicode, valueGeneratorFactory)
{
Expand Down Expand Up @@ -71,7 +71,9 @@ public override ConverterMappingHints With(ConverterMappingHints? hints)
hints.Scale ?? Scale,
hints.IsUnicode ?? IsUnicode,
(hints as RelationalConverterMappingHints)?.IsFixedLength ?? IsFixedLength,
#pragma warning disable CS0612 // Type or member is obsolete
hints.ValueGeneratorFactory ?? ValueGeneratorFactory,
#pragma warning restore CS0612 // Type or member is obsolete
(hints as RelationalConverterMappingHints)?.DbType ?? DbType);

/// <inheritdoc />
Expand All @@ -84,7 +86,9 @@ public override ConverterMappingHints Override(ConverterMappingHints? hints)
Scale ?? hints.Scale,
IsUnicode ?? hints.IsUnicode,
IsFixedLength ?? (hints as RelationalConverterMappingHints)?.IsFixedLength,
#pragma warning disable CS0612 // Type or member is obsolete
ValueGeneratorFactory ?? hints.ValueGeneratorFactory,
#pragma warning restore CS0612 // Type or member is obsolete
DbType ?? (hints as RelationalConverterMappingHints)?.DbType);

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/EFCore/Metadata/RuntimeSkipNavigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public override string ToString()
/// 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>
[EntityFrameworkInternal]
public virtual DebugView DebugView
=> new(
() => ((IReadOnlySkipNavigation)this).ToDebugString(),
Expand Down
5 changes: 4 additions & 1 deletion src/EFCore/Storage/CoreTypeMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,10 @@ protected CoreTypeMapping(CoreTypeMappingParameters parameters)
_providerValueComparer = parameters.ProviderValueComparer;
}

#pragma warning disable CS0612 // Type or member is obsolete
ValueGeneratorFactory = parameters.ValueGeneratorFactory
?? converter?.MappingHints?.ValueGeneratorFactory;
#pragma warning restore CS0612 // Type or member is obsolete
}

/// <summary>
Expand Down Expand Up @@ -242,7 +244,8 @@ public virtual ValueConverter? Converter
/// An optional factory for creating a specific <see cref="ValueGenerator" /> to use with
/// this mapping.
/// </summary>
public virtual Func<IProperty, ITypeBase, ValueGenerator>? ValueGeneratorFactory { get; }
[Obsolete]
public virtual Func<IProperty, IEntityType, ValueGenerator>? ValueGeneratorFactory { get; }

/// <summary>
/// A <see cref="ValueComparer" /> adds custom value snapshotting and comparison for
Expand Down
11 changes: 9 additions & 2 deletions src/EFCore/Storage/ValueConversion/ConverterMappingHints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ public ConverterMappingHints(
int? precision = null,
int? scale = null,
bool? unicode = null,
Func<IProperty, ITypeBase, ValueGenerator>? valueGeneratorFactory = null)
Func<IProperty, IEntityType, ValueGenerator>? valueGeneratorFactory = null)
{
Size = size;
Precision = precision;
Scale = scale;
IsUnicode = unicode;
#pragma warning disable CS0612 // Type or member is obsolete
ValueGeneratorFactory = valueGeneratorFactory;
#pragma warning restore CS0612 // Type or member is obsolete
}

/// <summary>
Expand All @@ -54,7 +56,9 @@ public virtual ConverterMappingHints With(ConverterMappingHints? hints)
hints.Precision ?? Precision,
hints.Scale ?? Scale,
hints.IsUnicode ?? IsUnicode,
#pragma warning disable CS0612 // Type or member is obsolete
hints.ValueGeneratorFactory ?? ValueGeneratorFactory)
#pragma warning restore CS0612 // Type or member is obsolete
: hints.Override(this);

/// <summary>
Expand All @@ -74,7 +78,9 @@ public virtual ConverterMappingHints Override(ConverterMappingHints? hints)
Precision ?? hints.Precision,
Scale ?? hints.Scale,
IsUnicode ?? hints.IsUnicode,
#pragma warning disable CS0612 // Type or member is obsolete
ValueGeneratorFactory ?? hints.ValueGeneratorFactory)
#pragma warning restore CS0612 // Type or member is obsolete
: hints.With(this);

/// <summary>
Expand All @@ -101,5 +107,6 @@ public virtual ConverterMappingHints Override(ConverterMappingHints? hints)
/// An optional factory for creating a specific <see cref="ValueGenerator" /> to use for model
/// values when this converter is being used.
/// </summary>
public virtual Func<IProperty, ITypeBase, ValueGenerator>? ValueGeneratorFactory { get; }
[Obsolete]
public virtual Func<IProperty, IEntityType, ValueGenerator>? ValueGeneratorFactory { get; }
}
12 changes: 9 additions & 3 deletions src/EFCore/ValueGeneration/ValueGeneratorSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,22 @@ public ValueGeneratorSelector(ValueGeneratorSelectorDependencies dependencies)
public virtual ValueGenerator Select(IProperty property, ITypeBase typeBase)
=> Cache.GetOrAdd(property, typeBase, (p, t) => CreateFromFactory(p, t) ?? Create(p, t));

private static ValueGenerator? CreateFromFactory(IProperty property, ITypeBase entityType)
private static ValueGenerator? CreateFromFactory(IProperty property, ITypeBase structuralType)
{
var factory = property.GetValueGeneratorFactory();
if (factory == null)
{
var mapping = property.GetTypeMapping();
factory = mapping.ValueGeneratorFactory;
#pragma warning disable CS0612 // Type or member is obsolete
if (mapping.ValueGeneratorFactory != null
&& structuralType is IEntityType)
{
factory = (p, t) => mapping.ValueGeneratorFactory.Invoke(p, (IEntityType)t);
}
#pragma warning restore CS0612 // Type or member is obsolete
}

return factory?.Invoke(property, entityType);
return factory?.Invoke(property, structuralType);
}

/// <summary>
Expand Down

0 comments on commit 82e96d9

Please sign in to comment.