Skip to content

Commit

Permalink
Merge in 'release/6.0' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot committed Oct 4, 2023
2 parents 8a56239 + 7fb644d commit cb934d0
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 15 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup Label="Version settings">
<VersionPrefix>6.0.23</VersionPrefix>
<VersionPrefix>6.0.24</VersionPrefix>
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
<IncludeSourceRevisionInInformationalVersion>False</IncludeSourceRevisionInInformationalVersion>
<IsServicingBuild Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</IsServicingBuild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private IReadOnlyList<MigrationOperation> RewriteOperations(
createTableOperation.PrimaryKey = AddPrimaryKeyOperation.CreateFrom(primaryKey);
}

foreach (var column in table.Columns.Where(c => c.Order.HasValue).OrderBy(c => c.Order.Value)
foreach (var column in table.Columns.Where(c => c.Order.HasValue).OrderBy(c => c.Order!.Value)
.Concat(table.Columns.Where(c => !c.Order.HasValue)))
{
if (!column.TryGetDefaultValue(out var defaultValue))
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ArrayPropertyValues(InternalEntityEntry internalEntry, object?[] values)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override object ToObject()
=> MaterializerSource.GetMaterializer(EntityType)(
=> EntityType.GetOrCreateMaterializer(MaterializerSource)(
new MaterializationContext(
new ValueBuffer(_values),
InternalEntry.StateManager.Context));
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/ChangeTracking/Internal/StateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public virtual InternalEntityEntry CreateEntry(IDictionary<string, object?> valu
}

var valueBuffer = new ValueBuffer(valuesArray);
var entity = EntityMaterializerSource.GetMaterializer(entityType)(new MaterializationContext(valueBuffer, Context));
var entity = entityType.GetOrCreateMaterializer(EntityMaterializerSource)(new MaterializationContext(valueBuffer, Context));

var shadowPropertyValueBuffer = new ValueBuffer(shadowPropertyValuesArray);
var entry = new InternalEntityEntry(this, entityType, entity, shadowPropertyValueBuffer);
Expand Down
11 changes: 11 additions & 0 deletions src/EFCore/Metadata/IReadOnlyEntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;

namespace Microsoft.EntityFrameworkCore.Metadata
Expand Down Expand Up @@ -803,6 +805,15 @@ IReadOnlyProperty GetProperty(string name)
/// <returns>The service properties defined on this entity type.</returns>
IEnumerable<IReadOnlyServiceProperty> GetServiceProperties();

/// <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>
[EntityFrameworkInternal]
Func<MaterializationContext, object> GetOrCreateMaterializer(IEntityMaterializerSource source);

/// <summary>
/// <para>
/// Creates a human-readable representation of the given metadata.
Expand Down
11 changes: 11 additions & 0 deletions src/EFCore/Metadata/Internal/EntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Microsoft.EntityFrameworkCore.Utilities;
Expand Down Expand Up @@ -3551,6 +3552,16 @@ private void UpdateServiceOnlyConstructorBindingConfigurationSource(Configuratio
=> _serviceOnlyConstructorBindingConfigurationSource =
configurationSource.Max(_serviceOnlyConstructorBindingConfigurationSource);

/// <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>
[EntityFrameworkInternal]
public virtual Func<MaterializationContext, object> GetOrCreateMaterializer(IEntityMaterializerSource source)
=> source.GetMaterializer(this);

#endregion

#region Explicit interface implementations
Expand Down
17 changes: 17 additions & 0 deletions src/EFCore/Metadata/RuntimeEntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Microsoft.EntityFrameworkCore.ValueGeneration;
Expand Down Expand Up @@ -72,6 +74,7 @@ private readonly SortedDictionary<string, RuntimeServiceProperty> _serviceProper
private Func<MaterializationContext, object>? _instanceFactory;
private IProperty[]? _foreignKeyProperties;
private IProperty[]? _valueGeneratingProperties;
private Func<MaterializationContext, object>? _materializer;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -814,6 +817,20 @@ public virtual InstantiationBinding? ServiceOnlyConstructorBinding
public static PropertyInfo? FindIndexerProperty(Type type)
=> type.FindIndexerProperty();

/// <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>
[EntityFrameworkInternal]
public virtual Func<MaterializationContext, object> GetOrCreateMaterializer(IEntityMaterializerSource source)
=> EntityMaterializerSource.UseOldBehavior31866
? source.GetMaterializer(this)
: NonCapturingLazyInitializer.EnsureInitialized(
ref _materializer, this, source,
static (e, s) => s.GetMaterializer(e));

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
Expand Down
36 changes: 25 additions & 11 deletions src/EFCore/Query/Internal/EntityMaterializerSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal
/// </summary>
public class EntityMaterializerSource : IEntityMaterializerSource
{
/// <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 static readonly bool UseOldBehavior31866 =
AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue31866", out var enabled31866) && enabled31866;

private ConcurrentDictionary<IEntityType, Func<MaterializationContext, object>>? _materializers;

/// <summary>
Expand Down Expand Up @@ -146,16 +155,21 @@ private ConcurrentDictionary<IEntityType, Func<MaterializationContext, object>>
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual Func<MaterializationContext, object> GetMaterializer(IEntityType entityType)
=> Materializers.GetOrAdd(
entityType, e =>
{
var materializationContextParameter
= Expression.Parameter(typeof(MaterializationContext), "materializationContext");
return Expression.Lambda<Func<MaterializationContext, object>>(
CreateMaterializeExpression(e, "instance", materializationContextParameter),
materializationContextParameter)
.Compile();
});
{
return UseOldBehavior31866
? Materializers.GetOrAdd(entityType, static (e, s) => CreateMaterializer(s, e), this)
: CreateMaterializer(this, entityType);

static Func<MaterializationContext, object> CreateMaterializer(EntityMaterializerSource self, IEntityType e)
{
var materializationContextParameter
= Expression.Parameter(typeof(MaterializationContext), "materializationContext");

return Expression.Lambda<Func<MaterializationContext, object>>(
self.CreateMaterializeExpression(e, "instance", materializationContextParameter),
materializationContextParameter)
.Compile();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Update;
using Newtonsoft.Json;
Expand Down Expand Up @@ -562,6 +563,9 @@ public IEnumerable<IDictionary<string, object>> GetSeedData(bool providerValues
public IEnumerable<IServiceProperty> GetServiceProperties()
=> throw new NotImplementedException();

public Func<MaterializationContext, object> GetOrCreateMaterializer(IEntityMaterializerSource source)
=> throw new NotImplementedException();

public IEnumerable<ISkipNavigation> GetSkipNavigations()
=> throw new NotImplementedException();

Expand Down

0 comments on commit cb934d0

Please sign in to comment.