Skip to content

Commit 3f18d11

Browse files
committed
Fix Compiled models tests
1 parent dd86811 commit 3f18d11

53 files changed

Lines changed: 56504 additions & 25 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// <auto-generated />
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Infrastructure;
4+
using TestNamespace;
5+
6+
#pragma warning disable 219, 612, 618
7+
#nullable disable
8+
9+
[assembly: DbContextModel(typeof(DbContext), typeof(DbContextModel))]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// <auto-generated />
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Infrastructure;
4+
using Microsoft.EntityFrameworkCore.Metadata;
5+
6+
#pragma warning disable 219, 612, 618
7+
#nullable disable
8+
9+
namespace TestNamespace
10+
{
11+
[DbContext(typeof(DbContext))]
12+
public partial class DbContextModel : RuntimeModel
13+
{
14+
private static readonly bool _useOldBehavior31751 =
15+
System.AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue31751", out var enabled31751) && enabled31751;
16+
17+
static DbContextModel()
18+
{
19+
var model = new DbContextModel();
20+
21+
if (_useOldBehavior31751)
22+
{
23+
model.Initialize();
24+
}
25+
else
26+
{
27+
var thread = new System.Threading.Thread(RunInitialization, 10 * 1024 * 1024);
28+
thread.Start();
29+
thread.Join();
30+
31+
void RunInitialization()
32+
{
33+
model.Initialize();
34+
}
35+
}
36+
37+
model.Customize();
38+
_instance = (DbContextModel)model.FinalizeModel();
39+
}
40+
41+
private static DbContextModel _instance;
42+
public static IModel Instance => _instance;
43+
44+
partial void Initialize();
45+
46+
partial void Customize();
47+
}
48+
}

test/EFCore.Jet.FunctionalTests/Scaffolding/Baselines/BigModel/DbContextModelBuilder.cs

Lines changed: 2930 additions & 0 deletions
Large diffs are not rendered by default.

test/EFCore.Jet.FunctionalTests/Scaffolding/Baselines/BigModel/DependentBaseEntityType.cs

Lines changed: 354 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// <auto-generated />
2+
using System.Runtime.CompilerServices;
3+
using Microsoft.EntityFrameworkCore.Scaffolding;
4+
5+
#pragma warning disable 219, 612, 618
6+
#nullable disable
7+
8+
namespace TestNamespace
9+
{
10+
public static class DependentBaseUnsafeAccessors<TKey>
11+
{
12+
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Id>k__BackingField")]
13+
public static extern ref TKey Id(CompiledModelTestBase.DependentBase<TKey> @this);
14+
15+
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Principal>k__BackingField")]
16+
public static extern ref CompiledModelTestBase.PrincipalDerived<CompiledModelTestBase.DependentBase<TKey>> Principal(CompiledModelTestBase.DependentBase<TKey> @this);
17+
}
18+
}
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
// <auto-generated />
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Reflection;
5+
using EntityFrameworkCore.Jet.Storage.Internal;
6+
using Microsoft.EntityFrameworkCore.ChangeTracking;
7+
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
8+
using Microsoft.EntityFrameworkCore.Infrastructure;
9+
using Microsoft.EntityFrameworkCore.Metadata;
10+
using Microsoft.EntityFrameworkCore.Metadata.Internal;
11+
using Microsoft.EntityFrameworkCore.Scaffolding;
12+
using Microsoft.EntityFrameworkCore.Storage;
13+
14+
#pragma warning disable 219, 612, 618
15+
#nullable disable
16+
17+
namespace TestNamespace
18+
{
19+
[EntityFrameworkInternal]
20+
public partial class DependentDerivedEntityType
21+
{
22+
public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null)
23+
{
24+
var runtimeEntityType = model.AddEntityType(
25+
"Microsoft.EntityFrameworkCore.Scaffolding.CompiledModelTestBase+DependentDerived<byte?>",
26+
typeof(CompiledModelTestBase.DependentDerived<byte?>),
27+
baseEntityType,
28+
discriminatorProperty: "EnumDiscriminator",
29+
discriminatorValue: CompiledModelTestBase.Enum1.Two,
30+
propertyCount: 2);
31+
32+
var data = runtimeEntityType.AddProperty(
33+
"Data",
34+
typeof(string),
35+
propertyInfo: typeof(CompiledModelTestBase.DependentDerived<byte?>).GetProperty("Data", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
36+
fieldInfo: typeof(CompiledModelTestBase.DependentDerived<byte?>).GetField("<Data>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
37+
nullable: true,
38+
maxLength: 20,
39+
unicode: false);
40+
data.SetGetter(
41+
string (CompiledModelTestBase.DependentDerived<byte?> instance) => DependentDerivedUnsafeAccessors<byte?>.Data(instance),
42+
bool (CompiledModelTestBase.DependentDerived<byte?> instance) => DependentDerivedUnsafeAccessors<byte?>.Data(instance) == null);
43+
data.SetSetter(
44+
CompiledModelTestBase.DependentDerived<byte?> (CompiledModelTestBase.DependentDerived<byte?> instance, string value) =>
45+
{
46+
DependentDerivedUnsafeAccessors<byte?>.Data(instance) = value;
47+
return instance;
48+
});
49+
data.SetMaterializationSetter(
50+
CompiledModelTestBase.DependentDerived<byte?> (CompiledModelTestBase.DependentDerived<byte?> instance, string value) =>
51+
{
52+
DependentDerivedUnsafeAccessors<byte?>.Data(instance) = value;
53+
return instance;
54+
});
55+
data.SetAccessors(
56+
string (IInternalEntry entry) => DependentDerivedUnsafeAccessors<byte?>.Data(((CompiledModelTestBase.DependentDerived<byte?>)(entry.Entity))),
57+
string (IInternalEntry entry) => DependentDerivedUnsafeAccessors<byte?>.Data(((CompiledModelTestBase.DependentDerived<byte?>)(entry.Entity))),
58+
string (IInternalEntry entry) => entry.ReadOriginalValue<string>(data, 4),
59+
string (IInternalEntry entry) => entry.GetCurrentValue<string>(data));
60+
data.SetPropertyIndexes(
61+
index: 4,
62+
originalValueIndex: 4,
63+
shadowIndex: -1,
64+
relationshipIndex: -1,
65+
storeGenerationIndex: -1);
66+
data.TypeMapping = JetStringTypeMapping.Default.Clone(
67+
comparer: new ValueComparer<string>(
68+
bool (string v1, string v2) => v1 == v2,
69+
int (string v) => ((object)v).GetHashCode(),
70+
string (string v) => v),
71+
keyComparer: new ValueComparer<string>(
72+
bool (string v1, string v2) => v1 == v2,
73+
int (string v) => ((object)v).GetHashCode(),
74+
string (string v) => v),
75+
providerValueComparer: new ValueComparer<string>(
76+
bool (string v1, string v2) => v1 == v2,
77+
int (string v) => ((object)v).GetHashCode(),
78+
string (string v) => v),
79+
mappingInfo: new RelationalTypeMappingInfo(
80+
storeTypeName: "char(20)",
81+
size: 20,
82+
unicode: false,
83+
fixedLength: true));
84+
data.AddAnnotation("Relational:IsFixedLength", true);
85+
86+
var money = runtimeEntityType.AddProperty(
87+
"Money",
88+
typeof(decimal),
89+
precision: 9,
90+
scale: 3,
91+
sentinel: 0m);
92+
money.SetAccessors(
93+
decimal (IInternalEntry entry) => entry.ReadShadowValue<decimal>(3),
94+
decimal (IInternalEntry entry) => entry.ReadShadowValue<decimal>(3),
95+
decimal (IInternalEntry entry) => entry.ReadOriginalValue<decimal>(money, 5),
96+
decimal (IInternalEntry entry) => entry.GetCurrentValue<decimal>(money));
97+
money.SetPropertyIndexes(
98+
index: 5,
99+
originalValueIndex: 5,
100+
shadowIndex: 3,
101+
relationshipIndex: -1,
102+
storeGenerationIndex: -1);
103+
money.TypeMapping = JetDecimalTypeMapping.Default.Clone(
104+
comparer: new ValueComparer<decimal>(
105+
bool (decimal v1, decimal v2) => v1 == v2,
106+
int (decimal v) => ((object)v).GetHashCode(),
107+
decimal (decimal v) => v),
108+
keyComparer: new ValueComparer<decimal>(
109+
bool (decimal v1, decimal v2) => v1 == v2,
110+
int (decimal v) => ((object)v).GetHashCode(),
111+
decimal (decimal v) => v),
112+
providerValueComparer: new ValueComparer<decimal>(
113+
bool (decimal v1, decimal v2) => v1 == v2,
114+
int (decimal v) => ((object)v).GetHashCode(),
115+
decimal (decimal v) => v),
116+
mappingInfo: new RelationalTypeMappingInfo(
117+
storeTypeName: "decimal(9,3)",
118+
precision: 9,
119+
scale: 3));
120+
121+
return runtimeEntityType;
122+
}
123+
124+
public static void CreateAnnotations(RuntimeEntityType runtimeEntityType)
125+
{
126+
var principalId = runtimeEntityType.FindProperty("PrincipalId");
127+
var principalAlternateId = runtimeEntityType.FindProperty("PrincipalAlternateId");
128+
var enumDiscriminator = runtimeEntityType.FindProperty("EnumDiscriminator");
129+
var id = runtimeEntityType.FindProperty("Id");
130+
var data = runtimeEntityType.FindProperty("Data");
131+
var money = runtimeEntityType.FindProperty("Money");
132+
var principal = runtimeEntityType.FindNavigation("Principal");
133+
runtimeEntityType.SetOriginalValuesFactory(
134+
ISnapshot (IInternalEntry source) =>
135+
{
136+
var structuralType8 = ((CompiledModelTestBase.DependentDerived<byte?>)(source.Entity));
137+
return ((ISnapshot)(new Snapshot<long, Guid, CompiledModelTestBase.Enum1, byte?, string, decimal>(((ValueComparer<long>)(((IProperty)principalId).GetValueComparer())).Snapshot(source.GetCurrentValue<long>(principalId)), ((ValueComparer<Guid>)(((IProperty)principalAlternateId).GetValueComparer())).Snapshot(source.GetCurrentValue<Guid>(principalAlternateId)), ((ValueComparer<CompiledModelTestBase.Enum1>)(((IProperty)enumDiscriminator).GetValueComparer())).Snapshot(source.GetCurrentValue<CompiledModelTestBase.Enum1>(enumDiscriminator)), (source.GetCurrentValue<byte?>(id) == null ? null : ((ValueComparer<byte?>)(((IProperty)id).GetValueComparer())).Snapshot(source.GetCurrentValue<byte?>(id))), (source.GetCurrentValue<string>(data) == null ? null : ((ValueComparer<string>)(((IProperty)data).GetValueComparer())).Snapshot(source.GetCurrentValue<string>(data))), ((ValueComparer<decimal>)(((IProperty)money).GetValueComparer())).Snapshot(source.GetCurrentValue<decimal>(money)))));
138+
});
139+
runtimeEntityType.SetStoreGeneratedValuesFactory(
140+
ISnapshot () => ((ISnapshot)(new Snapshot<long, Guid>(((ValueComparer<long>)(((IProperty)principalId).GetValueComparer())).Snapshot(default(long)), ((ValueComparer<Guid>)(((IProperty)principalAlternateId).GetValueComparer())).Snapshot(default(Guid))))));
141+
runtimeEntityType.SetTemporaryValuesFactory(
142+
ISnapshot (IInternalEntry source) => ((ISnapshot)(new Snapshot<long, Guid>(default(long), default(Guid)))));
143+
runtimeEntityType.SetShadowValuesFactory(
144+
ISnapshot (IDictionary<string, object> source) => ((ISnapshot)(new Snapshot<long, Guid, CompiledModelTestBase.Enum1, decimal>((source.ContainsKey("PrincipalId") ? ((long)(source["PrincipalId"])) : 0L), (source.ContainsKey("PrincipalAlternateId") ? ((Guid)(source["PrincipalAlternateId"])) : new Guid("00000000-0000-0000-0000-000000000000")), (source.ContainsKey("EnumDiscriminator") ? ((CompiledModelTestBase.Enum1)(source["EnumDiscriminator"])) : CompiledModelTestBase.Enum1.Default), (source.ContainsKey("Money") ? ((decimal)(source["Money"])) : 0M)))));
145+
runtimeEntityType.SetEmptyShadowValuesFactory(
146+
ISnapshot () => ((ISnapshot)(new Snapshot<long, Guid, CompiledModelTestBase.Enum1, decimal>(default(long), default(Guid), default(CompiledModelTestBase.Enum1), default(decimal)))));
147+
runtimeEntityType.SetRelationshipSnapshotFactory(
148+
ISnapshot (IInternalEntry source) =>
149+
{
150+
var structuralType8 = ((CompiledModelTestBase.DependentDerived<byte?>)(source.Entity));
151+
return ((ISnapshot)(new Snapshot<long, Guid, object>(((ValueComparer<long>)(((IProperty)principalId).GetKeyValueComparer())).Snapshot(source.GetCurrentValue<long>(principalId)), ((ValueComparer<Guid>)(((IProperty)principalAlternateId).GetKeyValueComparer())).Snapshot(source.GetCurrentValue<Guid>(principalAlternateId)), source.GetCurrentValue<CompiledModelTestBase.PrincipalDerived<CompiledModelTestBase.DependentBase<byte?>>>(principal))));
152+
});
153+
runtimeEntityType.SetCounts(new PropertyCounts(
154+
propertyCount: 6,
155+
navigationCount: 1,
156+
complexPropertyCount: 0,
157+
complexCollectionCount: 0,
158+
originalValueCount: 6,
159+
shadowCount: 4,
160+
relationshipCount: 3,
161+
storeGeneratedCount: 2));
162+
runtimeEntityType.AddAnnotation("Relational:FunctionName", null);
163+
runtimeEntityType.AddAnnotation("Relational:Schema", null);
164+
runtimeEntityType.AddAnnotation("Relational:SqlQuery", null);
165+
runtimeEntityType.AddAnnotation("Relational:TableName", "DependentBase<byte?>");
166+
runtimeEntityType.AddAnnotation("Relational:ViewName", null);
167+
runtimeEntityType.AddAnnotation("Relational:ViewSchema", null);
168+
169+
Customize(runtimeEntityType);
170+
}
171+
172+
static partial void Customize(RuntimeEntityType runtimeEntityType);
173+
}
174+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// <auto-generated />
2+
using System;
3+
using System.Runtime.CompilerServices;
4+
using Microsoft.EntityFrameworkCore.Scaffolding;
5+
6+
#pragma warning disable 219, 612, 618
7+
#nullable disable
8+
9+
namespace TestNamespace
10+
{
11+
public static class DependentDerivedUnsafeAccessors<TKey>
12+
{
13+
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<Data>k__BackingField")]
14+
public static extern ref string Data(CompiledModelTestBase.DependentDerived<TKey> @this);
15+
}
16+
}

0 commit comments

Comments
 (0)