-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor out the baselines for CSharpRuntimeModelCodeGeneratorTest
- Loading branch information
1 parent
0740f1c
commit 7d1c6cf
Showing
103 changed files
with
57,259 additions
and
56,695 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/EFCore.Design.Tests/Scaffolding/Internal/Baselines/BigModel/BigContextModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// <auto-generated /> | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Scaffolding.Internal; | ||
|
||
#pragma warning disable 219, 612, 618 | ||
#nullable disable | ||
|
||
namespace TestNamespace | ||
{ | ||
[DbContext(typeof(CSharpRuntimeModelCodeGeneratorTest.BigContext))] | ||
public partial class BigContextModel : RuntimeModel | ||
{ | ||
private static readonly bool _useOldBehavior31751 = | ||
System.AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue31751", out var enabled31751) && enabled31751; | ||
|
||
static BigContextModel() | ||
{ | ||
var model = new BigContextModel(); | ||
|
||
if (_useOldBehavior31751) | ||
{ | ||
model.Initialize(); | ||
} | ||
else | ||
{ | ||
var thread = new System.Threading.Thread(RunInitialization, 10 * 1024 * 1024); | ||
thread.Start(); | ||
thread.Join(); | ||
|
||
void RunInitialization() | ||
{ | ||
model.Initialize(); | ||
} | ||
} | ||
|
||
model.Customize(); | ||
_instance = (BigContextModel)model.FinalizeModel(); | ||
} | ||
|
||
private static BigContextModel _instance; | ||
public static IModel Instance => _instance; | ||
|
||
partial void Initialize(); | ||
|
||
partial void Customize(); | ||
} | ||
} |
3,441 changes: 3,441 additions & 0 deletions
3,441
test/EFCore.Design.Tests/Scaffolding/Internal/Baselines/BigModel/BigContextModelBuilder.cs
Large diffs are not rendered by default.
Oops, something went wrong.
196 changes: 196 additions & 0 deletions
196
test/EFCore.Design.Tests/Scaffolding/Internal/Baselines/BigModel/DependentBaseEntityType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
// <auto-generated /> | ||
using System; | ||
using System.Reflection; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.ChangeTracking; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Migrations.Design; | ||
using Microsoft.EntityFrameworkCore.Scaffolding.Internal; | ||
using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.EntityFrameworkCore.Storage.Json; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
using Microsoft.EntityFrameworkCore.ValueGeneration; | ||
|
||
#pragma warning disable 219, 612, 618 | ||
#nullable disable | ||
|
||
namespace TestNamespace | ||
{ | ||
internal partial class DependentBaseEntityType | ||
{ | ||
public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null) | ||
{ | ||
var runtimeEntityType = model.AddEntityType( | ||
"Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGeneratorTest+DependentBase<byte?>", | ||
typeof(CSharpRuntimeModelCodeGeneratorTest.DependentBase<byte?>), | ||
baseEntityType, | ||
discriminatorProperty: "EnumDiscriminator", | ||
discriminatorValue: CSharpMigrationsGeneratorTest.Enum1.One, | ||
derivedTypesCount: 1, | ||
propertyCount: 4, | ||
navigationCount: 1, | ||
foreignKeyCount: 2, | ||
unnamedIndexCount: 1, | ||
keyCount: 1); | ||
|
||
var principalId = runtimeEntityType.AddProperty( | ||
"PrincipalId", | ||
typeof(long), | ||
afterSaveBehavior: PropertySaveBehavior.Throw, | ||
sentinel: 0L); | ||
principalId.TypeMapping = SqlServerLongTypeMapping.Default.Clone( | ||
comparer: new ValueComparer<long>( | ||
(long v1, long v2) => v1 == v2, | ||
(long v) => v.GetHashCode(), | ||
(long v) => v), | ||
keyComparer: new ValueComparer<long>( | ||
(long v1, long v2) => v1 == v2, | ||
(long v) => v.GetHashCode(), | ||
(long v) => v), | ||
providerValueComparer: new ValueComparer<long>( | ||
(long v1, long v2) => v1 == v2, | ||
(long v) => v.GetHashCode(), | ||
(long v) => v)); | ||
principalId.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); | ||
|
||
var principalAlternateId = runtimeEntityType.AddProperty( | ||
"PrincipalAlternateId", | ||
typeof(Guid), | ||
afterSaveBehavior: PropertySaveBehavior.Throw, | ||
sentinel: new Guid("00000000-0000-0000-0000-000000000000")); | ||
principalAlternateId.TypeMapping = GuidTypeMapping.Default.Clone( | ||
comparer: new ValueComparer<Guid>( | ||
(Guid v1, Guid v2) => v1 == v2, | ||
(Guid v) => v.GetHashCode(), | ||
(Guid v) => v), | ||
keyComparer: new ValueComparer<Guid>( | ||
(Guid v1, Guid v2) => v1 == v2, | ||
(Guid v) => v.GetHashCode(), | ||
(Guid v) => v), | ||
providerValueComparer: new ValueComparer<Guid>( | ||
(Guid v1, Guid v2) => v1 == v2, | ||
(Guid v) => v.GetHashCode(), | ||
(Guid v) => v), | ||
mappingInfo: new RelationalTypeMappingInfo( | ||
storeTypeName: "uniqueidentifier")); | ||
principalAlternateId.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); | ||
|
||
var enumDiscriminator = runtimeEntityType.AddProperty( | ||
"EnumDiscriminator", | ||
typeof(CSharpMigrationsGeneratorTest.Enum1), | ||
afterSaveBehavior: PropertySaveBehavior.Throw, | ||
valueGeneratorFactory: new DiscriminatorValueGeneratorFactory().Create); | ||
enumDiscriminator.TypeMapping = IntTypeMapping.Default.Clone( | ||
comparer: new ValueComparer<CSharpMigrationsGeneratorTest.Enum1>( | ||
(CSharpMigrationsGeneratorTest.Enum1 v1, CSharpMigrationsGeneratorTest.Enum1 v2) => object.Equals((object)v1, (object)v2), | ||
(CSharpMigrationsGeneratorTest.Enum1 v) => v.GetHashCode(), | ||
(CSharpMigrationsGeneratorTest.Enum1 v) => v), | ||
keyComparer: new ValueComparer<CSharpMigrationsGeneratorTest.Enum1>( | ||
(CSharpMigrationsGeneratorTest.Enum1 v1, CSharpMigrationsGeneratorTest.Enum1 v2) => object.Equals((object)v1, (object)v2), | ||
(CSharpMigrationsGeneratorTest.Enum1 v) => v.GetHashCode(), | ||
(CSharpMigrationsGeneratorTest.Enum1 v) => v), | ||
providerValueComparer: new ValueComparer<int>( | ||
(int v1, int v2) => v1 == v2, | ||
(int v) => v, | ||
(int v) => v), | ||
converter: new ValueConverter<CSharpMigrationsGeneratorTest.Enum1, int>( | ||
(CSharpMigrationsGeneratorTest.Enum1 value) => (int)value, | ||
(int value) => (CSharpMigrationsGeneratorTest.Enum1)value), | ||
jsonValueReaderWriter: new JsonConvertedValueReaderWriter<CSharpMigrationsGeneratorTest.Enum1, int>( | ||
JsonInt32ReaderWriter.Instance, | ||
new ValueConverter<CSharpMigrationsGeneratorTest.Enum1, int>( | ||
(CSharpMigrationsGeneratorTest.Enum1 value) => (int)value, | ||
(int value) => (CSharpMigrationsGeneratorTest.Enum1)value))); | ||
enumDiscriminator.SetSentinelFromProviderValue(0); | ||
enumDiscriminator.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); | ||
|
||
var id = runtimeEntityType.AddProperty( | ||
"Id", | ||
typeof(byte?), | ||
propertyInfo: typeof(CSharpRuntimeModelCodeGeneratorTest.DependentBase<byte?>).GetProperty("Id", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), | ||
fieldInfo: typeof(CSharpRuntimeModelCodeGeneratorTest.DependentBase<byte?>).GetField("<Id>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), | ||
nullable: true); | ||
id.TypeMapping = SqlServerByteTypeMapping.Default.Clone( | ||
comparer: new ValueComparer<byte?>( | ||
(Nullable<byte> v1, Nullable<byte> v2) => v1.HasValue && v2.HasValue && (byte)v1 == (byte)v2 || !v1.HasValue && !v2.HasValue, | ||
(Nullable<byte> v) => v.HasValue ? (int)(byte)v : 0, | ||
(Nullable<byte> v) => v.HasValue ? (Nullable<byte>)(byte)v : default(Nullable<byte>)), | ||
keyComparer: new ValueComparer<byte?>( | ||
(Nullable<byte> v1, Nullable<byte> v2) => v1.HasValue && v2.HasValue && (byte)v1 == (byte)v2 || !v1.HasValue && !v2.HasValue, | ||
(Nullable<byte> v) => v.HasValue ? (int)(byte)v : 0, | ||
(Nullable<byte> v) => v.HasValue ? (Nullable<byte>)(byte)v : default(Nullable<byte>)), | ||
providerValueComparer: new ValueComparer<byte?>( | ||
(Nullable<byte> v1, Nullable<byte> v2) => v1.HasValue && v2.HasValue && (byte)v1 == (byte)v2 || !v1.HasValue && !v2.HasValue, | ||
(Nullable<byte> v) => v.HasValue ? (int)(byte)v : 0, | ||
(Nullable<byte> v) => v.HasValue ? (Nullable<byte>)(byte)v : default(Nullable<byte>))); | ||
id.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); | ||
|
||
var key = runtimeEntityType.AddKey( | ||
new[] { principalId, principalAlternateId }); | ||
runtimeEntityType.SetPrimaryKey(key); | ||
|
||
var index = runtimeEntityType.AddIndex( | ||
new[] { principalId }, | ||
unique: true); | ||
|
||
return runtimeEntityType; | ||
} | ||
|
||
public static RuntimeForeignKey CreateForeignKey1(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType) | ||
{ | ||
var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("PrincipalId") }, | ||
principalEntityType.FindKey(new[] { principalEntityType.FindProperty("Id") }), | ||
principalEntityType, | ||
deleteBehavior: DeleteBehavior.Cascade, | ||
unique: true, | ||
required: true); | ||
|
||
return runtimeForeignKey; | ||
} | ||
|
||
public static RuntimeForeignKey CreateForeignKey2(RuntimeEntityType declaringEntityType, RuntimeEntityType principalEntityType) | ||
{ | ||
var runtimeForeignKey = declaringEntityType.AddForeignKey(new[] { declaringEntityType.FindProperty("PrincipalId"), declaringEntityType.FindProperty("PrincipalAlternateId") }, | ||
principalEntityType.FindKey(new[] { principalEntityType.FindProperty("Id"), principalEntityType.FindProperty("AlternateId") }), | ||
principalEntityType, | ||
deleteBehavior: DeleteBehavior.ClientNoAction, | ||
unique: true, | ||
required: true); | ||
|
||
var principal = declaringEntityType.AddNavigation("Principal", | ||
runtimeForeignKey, | ||
onDependent: true, | ||
typeof(CSharpRuntimeModelCodeGeneratorTest.PrincipalDerived<CSharpRuntimeModelCodeGeneratorTest.DependentBase<byte?>>), | ||
propertyInfo: typeof(CSharpRuntimeModelCodeGeneratorTest.DependentBase<byte?>).GetProperty("Principal", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), | ||
fieldInfo: typeof(CSharpRuntimeModelCodeGeneratorTest.DependentBase<byte?>).GetField("<Principal>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)); | ||
|
||
var dependent = principalEntityType.AddNavigation("Dependent", | ||
runtimeForeignKey, | ||
onDependent: false, | ||
typeof(CSharpRuntimeModelCodeGeneratorTest.DependentBase<byte?>), | ||
propertyInfo: typeof(CSharpRuntimeModelCodeGeneratorTest.PrincipalDerived<CSharpRuntimeModelCodeGeneratorTest.DependentBase<byte?>>).GetProperty("Dependent", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), | ||
fieldInfo: typeof(CSharpRuntimeModelCodeGeneratorTest.PrincipalDerived<CSharpRuntimeModelCodeGeneratorTest.DependentBase<byte?>>).GetField("<Dependent>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), | ||
eagerLoaded: true, | ||
lazyLoadingEnabled: false); | ||
|
||
return runtimeForeignKey; | ||
} | ||
|
||
public static void CreateAnnotations(RuntimeEntityType runtimeEntityType) | ||
{ | ||
runtimeEntityType.AddAnnotation("DiscriminatorMappingComplete", false); | ||
runtimeEntityType.AddAnnotation("Relational:FunctionName", null); | ||
runtimeEntityType.AddAnnotation("Relational:MappingStrategy", "TPH"); | ||
runtimeEntityType.AddAnnotation("Relational:Schema", null); | ||
runtimeEntityType.AddAnnotation("Relational:SqlQuery", null); | ||
runtimeEntityType.AddAnnotation("Relational:TableName", "DependentBase<byte?>"); | ||
runtimeEntityType.AddAnnotation("Relational:ViewName", null); | ||
runtimeEntityType.AddAnnotation("Relational:ViewSchema", null); | ||
|
||
Customize(runtimeEntityType); | ||
} | ||
|
||
static partial void Customize(RuntimeEntityType runtimeEntityType); | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
...EFCore.Design.Tests/Scaffolding/Internal/Baselines/BigModel/DependentDerivedEntityType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// <auto-generated /> | ||
using System; | ||
using System.Reflection; | ||
using Microsoft.EntityFrameworkCore.ChangeTracking; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Migrations.Design; | ||
using Microsoft.EntityFrameworkCore.Scaffolding.Internal; | ||
using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
|
||
#pragma warning disable 219, 612, 618 | ||
#nullable disable | ||
|
||
namespace TestNamespace | ||
{ | ||
internal partial class DependentDerivedEntityType | ||
{ | ||
public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType baseEntityType = null) | ||
{ | ||
var runtimeEntityType = model.AddEntityType( | ||
"Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGeneratorTest+DependentDerived<byte?>", | ||
typeof(CSharpRuntimeModelCodeGeneratorTest.DependentDerived<byte?>), | ||
baseEntityType, | ||
discriminatorProperty: "EnumDiscriminator", | ||
discriminatorValue: CSharpMigrationsGeneratorTest.Enum1.Two, | ||
propertyCount: 2); | ||
|
||
var data = runtimeEntityType.AddProperty( | ||
"Data", | ||
typeof(string), | ||
propertyInfo: typeof(CSharpRuntimeModelCodeGeneratorTest.DependentDerived<byte?>).GetProperty("Data", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), | ||
fieldInfo: typeof(CSharpRuntimeModelCodeGeneratorTest.DependentDerived<byte?>).GetField("<Data>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly), | ||
nullable: true, | ||
maxLength: 20, | ||
unicode: false); | ||
data.TypeMapping = SqlServerStringTypeMapping.Default.Clone( | ||
comparer: new ValueComparer<string>( | ||
(string v1, string v2) => v1 == v2, | ||
(string v) => v.GetHashCode(), | ||
(string v) => v), | ||
keyComparer: new ValueComparer<string>( | ||
(string v1, string v2) => v1 == v2, | ||
(string v) => v.GetHashCode(), | ||
(string v) => v), | ||
providerValueComparer: new ValueComparer<string>( | ||
(string v1, string v2) => v1 == v2, | ||
(string v) => v.GetHashCode(), | ||
(string v) => v), | ||
mappingInfo: new RelationalTypeMappingInfo( | ||
storeTypeName: "char(20)", | ||
size: 20, | ||
dbType: System.Data.DbType.AnsiStringFixedLength)); | ||
data.AddAnnotation("Relational:IsFixedLength", true); | ||
data.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); | ||
|
||
var money = runtimeEntityType.AddProperty( | ||
"Money", | ||
typeof(decimal), | ||
precision: 9, | ||
scale: 3, | ||
sentinel: 0m); | ||
money.TypeMapping = SqlServerDecimalTypeMapping.Default.Clone( | ||
comparer: new ValueComparer<decimal>( | ||
(decimal v1, decimal v2) => v1 == v2, | ||
(decimal v) => v.GetHashCode(), | ||
(decimal v) => v), | ||
keyComparer: new ValueComparer<decimal>( | ||
(decimal v1, decimal v2) => v1 == v2, | ||
(decimal v) => v.GetHashCode(), | ||
(decimal v) => v), | ||
providerValueComparer: new ValueComparer<decimal>( | ||
(decimal v1, decimal v2) => v1 == v2, | ||
(decimal v) => v.GetHashCode(), | ||
(decimal v) => v), | ||
mappingInfo: new RelationalTypeMappingInfo( | ||
storeTypeName: "decimal(9,3)", | ||
precision: 9, | ||
scale: 3)); | ||
money.AddAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.None); | ||
|
||
return runtimeEntityType; | ||
} | ||
|
||
public static void CreateAnnotations(RuntimeEntityType runtimeEntityType) | ||
{ | ||
runtimeEntityType.AddAnnotation("Relational:FunctionName", null); | ||
runtimeEntityType.AddAnnotation("Relational:Schema", null); | ||
runtimeEntityType.AddAnnotation("Relational:SqlQuery", null); | ||
runtimeEntityType.AddAnnotation("Relational:TableName", "DependentBase<byte?>"); | ||
runtimeEntityType.AddAnnotation("Relational:ViewName", null); | ||
runtimeEntityType.AddAnnotation("Relational:ViewSchema", null); | ||
|
||
Customize(runtimeEntityType); | ||
} | ||
|
||
static partial void Customize(RuntimeEntityType runtimeEntityType); | ||
} | ||
} |
Oops, something went wrong.