From 95f591779dccf406b87960b0375a2f2e44919671 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Sat, 29 Jun 2024 09:49:07 +0200 Subject: [PATCH 1/4] Mark tests as skipped instead of replacing with no-op --- .../Scaffolding/CompiledModelCosmosTest.cs | 8 ++++---- .../Scaffolding/CompiledModelInMemoryTest.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs index 72d63b646a8..3ed4080a3bb 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs @@ -146,13 +146,13 @@ public virtual Task Basic_cosmos_model() Assert.Equal(new[] { id, partitionId, blob, storeId, jObject, eTag }, dataEntity.GetProperties()); }); - // Primitive collections not supported yet + [ConditionalFact(Skip = "Primitive collections not supported yet")] public override Task BigModel() - => Task.CompletedTask; + => base.BigModel(); - // Primitive collections not supported yet + [ConditionalFact(Skip = "Primitive collections not supported yet")] public override Task ComplexTypes() - => Task.CompletedTask; + => base.ComplexTypes(); protected override TestHelpers TestHelpers => CosmosTestHelpers.Instance; protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; diff --git a/test/EFCore.InMemory.FunctionalTests/Scaffolding/CompiledModelInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Scaffolding/CompiledModelInMemoryTest.cs index 58af999098a..9a93d99f988 100644 --- a/test/EFCore.InMemory.FunctionalTests/Scaffolding/CompiledModelInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Scaffolding/CompiledModelInMemoryTest.cs @@ -494,9 +494,9 @@ protected virtual void AssertCyclesModel(IModel model) TestHelpers.ModelAsserter.AssertEqual(principalBaseFk.PrincipalKey.Properties, dependentFk.Properties); } - // Primitive collections not supported completely + [ConditionalFact(Skip = "Primitive collections not supported completely")] public override Task BigModel() - => Task.CompletedTask; + => base.BigModel(); public class Scaffolding { From b1c3bd8e01c16b084f4b468aecfbae70fecd4315 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Fri, 28 Jun 2024 18:15:41 +0200 Subject: [PATCH 2/4] Avoid most silent failures in `CompiledModelTestBase.AssertBaseline` Instead of considering the test passed if no check was done, mark it as failed. Additionally, handle paths mangled by DeterministicSourcePaths. --- .../Scaffolding/CompiledModelTestBase.cs | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs b/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs index 4607bdbad93..f4716331208 100644 --- a/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs +++ b/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs @@ -1465,7 +1465,8 @@ private IModel CompileModel( { var build = new BuildSource { - Sources = scaffoldedFiles.ToDictionary(f => f.Path, f => f.Code), NullableReferenceTypes = options.UseNullableReferenceTypes + Sources = scaffoldedFiles.ToDictionary(f => f.Path, f => f.Code), + NullableReferenceTypes = options.UseNullableReferenceTypes }; AddReferences(build); @@ -1491,42 +1492,50 @@ private void AssertBaseline( string testName) { var testDirectory = Path.GetDirectoryName(_filePath); - if (string.IsNullOrEmpty(testDirectory) - || !Directory.Exists(testDirectory)) + if (string.IsNullOrEmpty(testDirectory)) { - return; + return; // cannot look for the baseline } - var baselinesDirectory = Path.Combine(testDirectory, "Baselines", testName); - try + var prefix = Path.DirectorySeparatorChar + "_" + Path.DirectorySeparatorChar; + if (testDirectory.StartsWith(prefix)) { - Directory.CreateDirectory(baselinesDirectory); + // assumes a current directory like /path/to/efcore/artifacts/bin/EFCore.Sqlite.FunctionalTests/Release/net9.0 + // so that a path mangled by DeterministicSourcePaths such as /_/test/EFCore.Sqlite.FunctionalTests/Scaffolding becomes + // /path/to/efcore/test/EFCore.Sqlite.FunctionalTests/Scaffolding + testDirectory = string.Join(Path.DirectorySeparatorChar, Enumerable.Repeat("..", 5)) + testDirectory[2..]; } - catch + if (!Directory.Exists(testDirectory)) { - return; + throw new Exception($"Test directory '{testDirectory}' not found from '{Directory.GetCurrentDirectory()}'"); } + var baselinesDirectory = Path.Combine(testDirectory, "Baselines", testName); + Directory.CreateDirectory(baselinesDirectory); + var shouldRewrite = Environment.GetEnvironmentVariable("EF_TEST_REWRITE_BASELINES")?.ToUpper() is "1" or "TRUE"; + List<(string Path, Exception Exception)> exceptions = []; foreach (var file in scaffoldedFiles) { var fullFilePath = Path.Combine(baselinesDirectory, file.Path); - if (!File.Exists(fullFilePath) - || shouldRewrite) + try { - File.WriteAllText(fullFilePath, file.Code); + Assert.Equal(File.ReadAllText(fullFilePath), file.Code, ignoreLineEndingDifferences: true); } - else + catch (Exception ex) { - try - { - Assert.Equal(File.ReadAllText(fullFilePath), file.Code, ignoreLineEndingDifferences: true); - } - catch (Exception ex) + if (shouldRewrite) { - throw new Exception($"Difference found in {file.Path}", ex); + File.WriteAllText(fullFilePath, file.Code); } + + exceptions.Add((file.Path, ex)); } } + + foreach (var (path, ex) in exceptions) + { + throw new Exception($"Difference found in {path}", ex); + } } } From 6b67e70556e758720a422285f137983141f80f74 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Sat, 29 Jun 2024 03:13:08 +0200 Subject: [PATCH 3/4] Update baselines --- .../Baselines/BigModel/ManyTypesEntityType.cs | 28 +++++++++---------- .../ManyTypesEntityType.cs | 28 +++++++++---------- .../Baselines/BigModel/ManyTypesEntityType.cs | 28 +++++++++---------- .../ManyTypesEntityType.cs | 28 +++++++++---------- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs index 2d40767a42b..0b1bdc09403 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs @@ -14933,11 +14933,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); nullableUri.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -14988,11 +14988,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); nullableUriArray.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), keyComparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), providerValueComparer: new ValueComparer( @@ -15018,11 +15018,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas (string v) => new Uri(v, UriKind.RelativeOrAbsolute)))), elementMapping: SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -17259,11 +17259,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uri.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -17314,11 +17314,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uriArray.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), keyComparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), providerValueComparer: new ValueComparer( @@ -17344,11 +17344,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas (string v) => new Uri(v, UriKind.RelativeOrAbsolute)))), elementMapping: SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -17400,11 +17400,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uriToStringConverterProperty.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( diff --git a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/BigModel_with_JSON_columns/ManyTypesEntityType.cs b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/BigModel_with_JSON_columns/ManyTypesEntityType.cs index 2d40767a42b..0b1bdc09403 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/BigModel_with_JSON_columns/ManyTypesEntityType.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/BigModel_with_JSON_columns/ManyTypesEntityType.cs @@ -14933,11 +14933,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); nullableUri.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -14988,11 +14988,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); nullableUriArray.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), keyComparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), providerValueComparer: new ValueComparer( @@ -15018,11 +15018,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas (string v) => new Uri(v, UriKind.RelativeOrAbsolute)))), elementMapping: SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -17259,11 +17259,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uri.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -17314,11 +17314,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uriArray.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), keyComparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), providerValueComparer: new ValueComparer( @@ -17344,11 +17344,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas (string v) => new Uri(v, UriKind.RelativeOrAbsolute)))), elementMapping: SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -17400,11 +17400,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uriToStringConverterProperty.TypeMapping = SqlServerStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( diff --git a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs index 849e4e248b0..168afa9209f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/Baselines/BigModel/ManyTypesEntityType.cs @@ -13374,11 +13374,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); nullableUri.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -13423,11 +13423,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); nullableUriArray.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), keyComparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), providerValueComparer: new ValueComparer( @@ -13448,11 +13448,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas (string v) => new Uri(v, UriKind.RelativeOrAbsolute)))), elementMapping: SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -15392,11 +15392,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uri.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -15441,11 +15441,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uriArray.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), keyComparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), providerValueComparer: new ValueComparer( @@ -15466,11 +15466,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas (string v) => new Uri(v, UriKind.RelativeOrAbsolute)))), elementMapping: SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -15516,11 +15516,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uriToStringConverterProperty.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( diff --git a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/Baselines/BigModel_with_JSON_columns/ManyTypesEntityType.cs b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/Baselines/BigModel_with_JSON_columns/ManyTypesEntityType.cs index 849e4e248b0..168afa9209f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/Baselines/BigModel_with_JSON_columns/ManyTypesEntityType.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/Baselines/BigModel_with_JSON_columns/ManyTypesEntityType.cs @@ -13374,11 +13374,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); nullableUri.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -13423,11 +13423,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); nullableUriArray.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), keyComparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), providerValueComparer: new ValueComparer( @@ -13448,11 +13448,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas (string v) => new Uri(v, UriKind.RelativeOrAbsolute)))), elementMapping: SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -15392,11 +15392,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uri.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -15441,11 +15441,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uriArray.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), keyComparer: new ListOfReferenceTypesComparer(new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v)), providerValueComparer: new ValueComparer( @@ -15466,11 +15466,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas (string v) => new Uri(v, UriKind.RelativeOrAbsolute)))), elementMapping: SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( @@ -15516,11 +15516,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas storeGenerationIndex: -1); uriToStringConverterProperty.TypeMapping = SqliteStringTypeMapping.Default.Clone( comparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), keyComparer: new ValueComparer( - (Uri v1, Uri v2) => v1 == v2, + (Uri v1, Uri v2) => v1 == null && v2 == null || v1 != null && v2 != null && v1.Equals(v2), (Uri v) => ((object)v).GetHashCode(), (Uri v) => v), providerValueComparer: new ValueComparer( From 57ecfcaeda1d2658f30761ee94ffe0380cf5934b Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Tue, 2 Jul 2024 00:34:56 +0200 Subject: [PATCH 4/4] Aggregate all of the exceptions Instead of throwing the first exception, throw an aggregation of all of them. --- .../Scaffolding/CompiledModelTestBase.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs b/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs index f4716331208..f008e6c6a53 100644 --- a/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs +++ b/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs @@ -1514,7 +1514,7 @@ private void AssertBaseline( Directory.CreateDirectory(baselinesDirectory); var shouldRewrite = Environment.GetEnvironmentVariable("EF_TEST_REWRITE_BASELINES")?.ToUpper() is "1" or "TRUE"; - List<(string Path, Exception Exception)> exceptions = []; + List exceptions = []; foreach (var file in scaffoldedFiles) { var fullFilePath = Path.Combine(baselinesDirectory, file.Path); @@ -1529,13 +1529,13 @@ private void AssertBaseline( File.WriteAllText(fullFilePath, file.Code); } - exceptions.Add((file.Path, ex)); + exceptions.Add(new Exception($"Difference found in {file.Path}", ex)); } } - foreach (var (path, ex) in exceptions) + if (exceptions.Count > 0) { - throw new Exception($"Difference found in {path}", ex); + throw new AggregateException($"Differences found in {exceptions.Count} files", exceptions); } } }