From 88fd58ed1b03ab70b62d67ce3ef2d63e51b515a8 Mon Sep 17 00:00:00 2001 From: Wouter Dingemanse Date: Tue, 15 Aug 2023 14:54:10 +0200 Subject: [PATCH 1/7] Change target framework --- .../Detached.Mappers.EntityFramework.Contrib.SysTec.csproj | 2 +- .../Detached.Mappers.Annotation.Tests.csproj | 2 +- .../Detached.Mappers.EntityFramework.Tests.csproj | 2 +- .../Detached.Mappers.HotChocolate.Tests.csproj | 2 +- .../Detached.Mappers.Json.Tests.csproj | 2 +- test/Detached.Mappers.Tests/Detached.Mappers.Tests.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/Detached.Mappers.EntityFramework.Contrib.SysTec.csproj b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/Detached.Mappers.EntityFramework.Contrib.SysTec.csproj index 0547e922..b79b1ae6 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/Detached.Mappers.EntityFramework.Contrib.SysTec.csproj +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/Detached.Mappers.EntityFramework.Contrib.SysTec.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 disable false diff --git a/test/Detached.Mappers.Annotation.Tests/Detached.Mappers.Annotation.Tests.csproj b/test/Detached.Mappers.Annotation.Tests/Detached.Mappers.Annotation.Tests.csproj index f3d07ed7..4b3a0ece 100644 --- a/test/Detached.Mappers.Annotation.Tests/Detached.Mappers.Annotation.Tests.csproj +++ b/test/Detached.Mappers.Annotation.Tests/Detached.Mappers.Annotation.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable diff --git a/test/Detached.Mappers.EntityFramework.Tests/Detached.Mappers.EntityFramework.Tests.csproj b/test/Detached.Mappers.EntityFramework.Tests/Detached.Mappers.EntityFramework.Tests.csproj index ae7fef65..e1854426 100644 --- a/test/Detached.Mappers.EntityFramework.Tests/Detached.Mappers.EntityFramework.Tests.csproj +++ b/test/Detached.Mappers.EntityFramework.Tests/Detached.Mappers.EntityFramework.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 false diff --git a/test/Detached.Mappers.HotChocolate.Tests/Detached.Mappers.HotChocolate.Tests.csproj b/test/Detached.Mappers.HotChocolate.Tests/Detached.Mappers.HotChocolate.Tests.csproj index 3e6be70b..a8fabb51 100644 --- a/test/Detached.Mappers.HotChocolate.Tests/Detached.Mappers.HotChocolate.Tests.csproj +++ b/test/Detached.Mappers.HotChocolate.Tests/Detached.Mappers.HotChocolate.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable disable diff --git a/test/Detached.Mappers.Json.Tests/Detached.Mappers.Json.Tests.csproj b/test/Detached.Mappers.Json.Tests/Detached.Mappers.Json.Tests.csproj index f6da269d..be7219f3 100644 --- a/test/Detached.Mappers.Json.Tests/Detached.Mappers.Json.Tests.csproj +++ b/test/Detached.Mappers.Json.Tests/Detached.Mappers.Json.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable disable diff --git a/test/Detached.Mappers.Tests/Detached.Mappers.Tests.csproj b/test/Detached.Mappers.Tests/Detached.Mappers.Tests.csproj index 7f988d0b..1eb13b7c 100644 --- a/test/Detached.Mappers.Tests/Detached.Mappers.Tests.csproj +++ b/test/Detached.Mappers.Tests/Detached.Mappers.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 false From 155f4beace989a6ba15a7a940dd107c59dffb1b5 Mon Sep 17 00:00:00 2001 From: Wouter Dingemanse Date: Tue, 15 Aug 2023 14:54:35 +0200 Subject: [PATCH 2/7] Add extra test project --- Detached.Mappers.sln | 7 +++ .../Creator.cs | 18 ++++++ .../CreatorConfiguration.cs | 14 +++++ ...Mappers.Tests.Contrib.ScottSoftware.csproj | 36 ++++++++++++ .../TellDbContext.cs | 56 +++++++++++++++++++ .../UnitTest1.cs | 56 +++++++++++++++++++ .../Usings.cs | 1 + .../Work.cs | 14 +++++ .../WorkConfiguration.cs | 13 +++++ 9 files changed, 215 insertions(+) create mode 100644 contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Creator.cs create mode 100644 contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/CreatorConfiguration.cs create mode 100644 contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Detached.Mappers.Tests.Contrib.ScottSoftware.csproj create mode 100644 contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs create mode 100644 contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/UnitTest1.cs create mode 100644 contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Usings.cs create mode 100644 contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Work.cs create mode 100644 contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/WorkConfiguration.cs diff --git a/Detached.Mappers.sln b/Detached.Mappers.sln index 0e7a3926..497acee6 100644 --- a/Detached.Mappers.sln +++ b/Detached.Mappers.sln @@ -43,6 +43,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "contrib", "contrib", "{5409 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Detached.Mappers.Annotation.Tests", "test\Detached.Mappers.Annotation.Tests\Detached.Mappers.Annotation.Tests.csproj", "{713EB397-9271-45F6-811C-CD84CD6BB194}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Detached.Mappers.Tests.Contrib.ScottSoftware", "contrib\Detached.Mappers.Tests.Contrib.ScottSoftware\Detached.Mappers.Tests.Contrib.ScottSoftware.csproj", "{95AA701E-8042-460C-886F-60F550B9A477}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -97,6 +99,10 @@ Global {713EB397-9271-45F6-811C-CD84CD6BB194}.Debug|Any CPU.Build.0 = Debug|Any CPU {713EB397-9271-45F6-811C-CD84CD6BB194}.Release|Any CPU.ActiveCfg = Release|Any CPU {713EB397-9271-45F6-811C-CD84CD6BB194}.Release|Any CPU.Build.0 = Release|Any CPU + {95AA701E-8042-460C-886F-60F550B9A477}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95AA701E-8042-460C-886F-60F550B9A477}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95AA701E-8042-460C-886F-60F550B9A477}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95AA701E-8042-460C-886F-60F550B9A477}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -116,6 +122,7 @@ Global {B6162ECF-00B0-4506-B3E8-2A4B46517ECE} = {42962E94-05D1-4D67-8BB2-572B04CBC3F7} {5409CE02-02AD-448B-85A5-EFEABA6C52C8} = {745CB1E1-F50B-4307-8BD6-1ADDC837102B} {713EB397-9271-45F6-811C-CD84CD6BB194} = {C9521C36-FBA4-4B3E-AE14-A1735E9D1E71} + {95AA701E-8042-460C-886F-60F550B9A477} = {42962E94-05D1-4D67-8BB2-572B04CBC3F7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7FC47439-B36B-45BB-BEEC-A6D595358C63} diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Creator.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Creator.cs new file mode 100644 index 00000000..0cc7f62f --- /dev/null +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Creator.cs @@ -0,0 +1,18 @@ +using System.Collections.ObjectModel; + +namespace Detached.Mappers.Tests.Contrib.ScottSoftware; + +public class Creator +{ + public int Id { get; set; } + + public string FullName { get; set; } + + public DateTime Born { get; set; } + + public DateTime Died { get; set; } + + public string? PrimaryLanguage { get; set; } + + public Collection Works { get; set; } +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/CreatorConfiguration.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/CreatorConfiguration.cs new file mode 100644 index 00000000..f1e81d11 --- /dev/null +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/CreatorConfiguration.cs @@ -0,0 +1,14 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Detached.Mappers.Tests.Contrib.ScottSoftware; + +public class CreatorConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(p => p.Id); + builder.HasMany(p => p.Works).WithOne(a => a.Creator).OnDelete(DeleteBehavior.Cascade); + } +} + diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Detached.Mappers.Tests.Contrib.ScottSoftware.csproj b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Detached.Mappers.Tests.Contrib.ScottSoftware.csproj new file mode 100644 index 00000000..d49e4cab --- /dev/null +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Detached.Mappers.Tests.Contrib.ScottSoftware.csproj @@ -0,0 +1,36 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + ..\..\..\..\.nuget\packages\microsoft.entityframeworkcore\7.0.10\lib\net6.0\Microsoft.EntityFrameworkCore.dll + + + + + + + + diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs new file mode 100644 index 00000000..ec0c21bb --- /dev/null +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs @@ -0,0 +1,56 @@ +using System.Diagnostics; +using Detached.Mappers.EntityFramework; +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace Detached.Mappers.Tests.Contrib.ScottSoftware; + +public class TellDbContext : DbContext +{ + static SqliteConnection _connection; + public DbSet Creators { get; set; } + + public DbSet Works { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (_connection == null) + { + _connection = new SqliteConnection($"DataSource=file:Tell.sqlite3"); + _connection.Open(); + } + + + optionsBuilder + .UseSqlite(_connection) + .EnableSensitiveDataLogging() + .LogTo(message => Debug.WriteLine(message), LogLevel.Information) + .EnableDetailedErrors() + .UseDetached() + .UseMapping(builder => + { + builder.Default(options => + { + options.Type().Member(c => c.Works).Composition(); + }); + } ); + base.OnConfiguring(optionsBuilder); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.ApplyConfiguration(new CreatorConfiguration()); + modelBuilder.ApplyConfiguration(new WorkConfiguration()); + modelBuilder.Entity().HasMany(c => c.Works).WithOne(w => w.Creator) + .HasForeignKey(w => w.CreatorId); + modelBuilder.Entity().HasData(new Creator + { + Id = 1, FullName = @"Douglas Adams", PrimaryLanguage = "EN", Born = new DateTime(1952, 4, 11), + Died = new DateTime(2001, 5, 11) + }); + modelBuilder.Entity().HasData(new Work { Id = 1, CreatorId = 1, Title = @"Young Zaphod Plays It Safe", Language = "EN"}); + base.OnModelCreating(modelBuilder); + base.OnModelCreating(modelBuilder); + } +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/UnitTest1.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/UnitTest1.cs new file mode 100644 index 00000000..3e3e40c6 --- /dev/null +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/UnitTest1.cs @@ -0,0 +1,56 @@ +using Detached.Mappers.EntityFramework; + +namespace Detached.Mappers.Tests.Contrib.ScottSoftware; + +public class UnitTest1 +{ + [Fact] + public void Test1() + { + var correctedTitle = @"The Dragon's Path"; + var correctedName = @"Daniel Abraham"; + using (var context = new TellDbContext()) + { + // create the sqlite db. + context.Database.EnsureCreated(); + var newCreator = context.Map(new Creator + { + FullName = "Daniel Abraham.", PrimaryLanguage = "EN", + Works = new() { new Work { Title = @"The Dragons Path", Language = "EN" } } + }); + context.SaveChanges(); + } + + + using (var context = new TellDbContext()) + { + Assert.Equal(2, context.Creators.Count()); + Assert.Equal(2, context.Works.Count()); + Assert.Equal(2, context.Creators.OrderBy(c => c.Id).Last().Id); + } + + + using (var context = new TellDbContext()) + { + var newId = 2; + var updatedCreator = context.Map(new Creator + { + Id = newId, FullName = "Daniel Abraham", + Works = new() + { + new Work { Title = correctedTitle, Language = "EN", Id = 2, CreatorId = newId }, + new Work { Title = @"The King's Blood", Language = "EN", CreatorId = newId }, + } + }); + context.SaveChanges(); + } + + using (var context = new TellDbContext()) + { + Assert.Equal(2, context.Creators.Count()); + Assert.Equal(correctedName, context.Creators.OrderBy(c => c.Id).Last().FullName); + Assert.Equal(3, context.Works.Count()); // 1 from seed, + 1 from creation, + 1 from updating + Assert.Equal(correctedTitle, context.Works.Where(w => w.Id == 2).Single().Title); + } + } +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Usings.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Usings.cs new file mode 100644 index 00000000..8c927eb7 --- /dev/null +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Work.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Work.cs new file mode 100644 index 00000000..91c4231b --- /dev/null +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Work.cs @@ -0,0 +1,14 @@ +namespace Detached.Mappers.Tests.Contrib.ScottSoftware; + +public class Work +{ + public int Id { get; set; } + + public string Title { get; set; } + + public string Language { get; set; } + + public int CreatorId { get; set; } + + public Creator Creator { get; set; } +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/WorkConfiguration.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/WorkConfiguration.cs new file mode 100644 index 00000000..571e2110 --- /dev/null +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/WorkConfiguration.cs @@ -0,0 +1,13 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Detached.Mappers.Tests.Contrib.ScottSoftware; + +public class WorkConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(p => p.Id); + } +} + From 5d280c5f994e938cb21567998fb619c00af88ba1 Mon Sep 17 00:00:00 2001 From: Wouter Dingemanse Date: Tue, 15 Aug 2023 15:19:06 +0200 Subject: [PATCH 3/7] Consolidate dependencies --- ...hed.Mappers.EntityFramework.Contrib.SysTec.csproj | 6 +++--- ...tached.Mappers.Tests.Contrib.ScottSoftware.csproj | 10 +++++----- .../Detached.Samples.RestApi.csproj | 4 ++-- src/Detached.Annotations/Detached.Annotations.csproj | 1 + .../Detached.Mappers.EntityFramework.csproj | 2 +- .../Detached.Mappers.HotChocolate.csproj | 2 +- .../Detached.Mappers.Json.csproj | 2 +- src/Detached.Mappers/Detached.Mappers.csproj | 6 ++---- .../Detached.Mappers.Annotation.Tests.csproj | 8 ++++---- .../Detached.Mappers.EntityFramework.Tests.csproj | 12 ++++++------ .../Detached.Mappers.HotChocolate.Tests.csproj | 8 ++++---- .../Detached.Mappers.Json.Tests.csproj | 8 ++++---- .../Detached.Mappers.Tests.csproj | 9 ++++----- 13 files changed, 38 insertions(+), 40 deletions(-) diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/Detached.Mappers.EntityFramework.Contrib.SysTec.csproj b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/Detached.Mappers.EntityFramework.Contrib.SysTec.csproj index b79b1ae6..19d71f65 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/Detached.Mappers.EntityFramework.Contrib.SysTec.csproj +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/Detached.Mappers.EntityFramework.Contrib.SysTec.csproj @@ -8,9 +8,9 @@ - - - + + + diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Detached.Mappers.Tests.Contrib.ScottSoftware.csproj b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Detached.Mappers.Tests.Contrib.ScottSoftware.csproj index d49e4cab..60a16657 100644 --- a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Detached.Mappers.Tests.Contrib.ScottSoftware.csproj +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Detached.Mappers.Tests.Contrib.ScottSoftware.csproj @@ -10,14 +10,14 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/sample/Detached.Samples.RestApi/Detached.Samples.RestApi.csproj b/sample/Detached.Samples.RestApi/Detached.Samples.RestApi.csproj index 888c10b2..bf1bcec5 100644 --- a/sample/Detached.Samples.RestApi/Detached.Samples.RestApi.csproj +++ b/sample/Detached.Samples.RestApi/Detached.Samples.RestApi.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/src/Detached.Annotations/Detached.Annotations.csproj b/src/Detached.Annotations/Detached.Annotations.csproj index 804ea0ca..76e2746e 100644 --- a/src/Detached.Annotations/Detached.Annotations.csproj +++ b/src/Detached.Annotations/Detached.Annotations.csproj @@ -22,4 +22,5 @@ + diff --git a/src/Detached.Mappers.EntityFramework/Detached.Mappers.EntityFramework.csproj b/src/Detached.Mappers.EntityFramework/Detached.Mappers.EntityFramework.csproj index e284cbc3..6e44ee60 100644 --- a/src/Detached.Mappers.EntityFramework/Detached.Mappers.EntityFramework.csproj +++ b/src/Detached.Mappers.EntityFramework/Detached.Mappers.EntityFramework.csproj @@ -17,7 +17,7 @@ - + diff --git a/src/Detached.Mappers.HotChocolate/Detached.Mappers.HotChocolate.csproj b/src/Detached.Mappers.HotChocolate/Detached.Mappers.HotChocolate.csproj index cc943bde..fd366473 100644 --- a/src/Detached.Mappers.HotChocolate/Detached.Mappers.HotChocolate.csproj +++ b/src/Detached.Mappers.HotChocolate/Detached.Mappers.HotChocolate.csproj @@ -27,7 +27,7 @@ - + \ No newline at end of file diff --git a/src/Detached.Mappers.Json/Detached.Mappers.Json.csproj b/src/Detached.Mappers.Json/Detached.Mappers.Json.csproj index ad4b4b46..aec791b3 100644 --- a/src/Detached.Mappers.Json/Detached.Mappers.Json.csproj +++ b/src/Detached.Mappers.Json/Detached.Mappers.Json.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/Detached.Mappers/Detached.Mappers.csproj b/src/Detached.Mappers/Detached.Mappers.csproj index 8da87441..12f7623d 100644 --- a/src/Detached.Mappers/Detached.Mappers.csproj +++ b/src/Detached.Mappers/Detached.Mappers.csproj @@ -18,11 +18,9 @@ - - - - + + diff --git a/test/Detached.Mappers.Annotation.Tests/Detached.Mappers.Annotation.Tests.csproj b/test/Detached.Mappers.Annotation.Tests/Detached.Mappers.Annotation.Tests.csproj index 4b3a0ece..989731e1 100644 --- a/test/Detached.Mappers.Annotation.Tests/Detached.Mappers.Annotation.Tests.csproj +++ b/test/Detached.Mappers.Annotation.Tests/Detached.Mappers.Annotation.Tests.csproj @@ -9,13 +9,13 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Detached.Mappers.EntityFramework.Tests/Detached.Mappers.EntityFramework.Tests.csproj b/test/Detached.Mappers.EntityFramework.Tests/Detached.Mappers.EntityFramework.Tests.csproj index e1854426..dd4df5c0 100644 --- a/test/Detached.Mappers.EntityFramework.Tests/Detached.Mappers.EntityFramework.Tests.csproj +++ b/test/Detached.Mappers.EntityFramework.Tests/Detached.Mappers.EntityFramework.Tests.csproj @@ -6,15 +6,15 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Detached.Mappers.HotChocolate.Tests/Detached.Mappers.HotChocolate.Tests.csproj b/test/Detached.Mappers.HotChocolate.Tests/Detached.Mappers.HotChocolate.Tests.csproj index a8fabb51..17e8ba0b 100644 --- a/test/Detached.Mappers.HotChocolate.Tests/Detached.Mappers.HotChocolate.Tests.csproj +++ b/test/Detached.Mappers.HotChocolate.Tests/Detached.Mappers.HotChocolate.Tests.csproj @@ -9,13 +9,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Detached.Mappers.Json.Tests/Detached.Mappers.Json.Tests.csproj b/test/Detached.Mappers.Json.Tests/Detached.Mappers.Json.Tests.csproj index be7219f3..c0a64311 100644 --- a/test/Detached.Mappers.Json.Tests/Detached.Mappers.Json.Tests.csproj +++ b/test/Detached.Mappers.Json.Tests/Detached.Mappers.Json.Tests.csproj @@ -20,13 +20,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Detached.Mappers.Tests/Detached.Mappers.Tests.csproj b/test/Detached.Mappers.Tests/Detached.Mappers.Tests.csproj index 1eb13b7c..d85c01ec 100644 --- a/test/Detached.Mappers.Tests/Detached.Mappers.Tests.csproj +++ b/test/Detached.Mappers.Tests/Detached.Mappers.Tests.csproj @@ -6,14 +6,13 @@ - - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 3cd992a42cfe6ad7c8ea6bb0987b4f639736d51f Mon Sep 17 00:00:00 2001 From: Wouter Dingemanse Date: Tue, 15 Aug 2023 15:23:15 +0200 Subject: [PATCH 4/7] Remove unused dependencies --- .../ComplexModels/Address.cs | 8 ++----- .../ComplexModels/ConcurrencyStampBase.cs | 1 - .../ComplexModels/Country.cs | 10 ++------- .../ComplexModels/CustomerKind.cs | 6 +---- .../ComplexModels/Government.cs | 9 +------- .../ComplexModels/IdBase.cs | 4 +--- .../ComplexModels/OrganizationBase.cs | 5 ----- .../ComplexModels/OrganizationList.cs | 4 ---- .../ComplexModels/OrganizationNotes.cs | 1 - .../ComplexModels/StudentGrades.cs | 1 - .../ComplexModels/SubGovernment.cs | 9 +------- .../DTOs/Bug17/AngebotDTO.cs | 1 - .../DTOs/Bug17/PositionBaseDTO.cs | 4 +--- .../DTOs/CountryDTO.cs | 5 ----- .../DTOs/CountryDTOWithoutPicture.cs | 8 +------ .../DTOs/CourseDTO.cs | 6 +---- .../DTOs/GovernmentDTO.cs | 10 ++------- .../DTOs/IdBaseDTO.cs | 9 ++------ .../DTOs/OrganizationBaseDTO.cs | 12 ++-------- .../DTOs/OrganizationListDTO.cs | 9 ++------ .../DTOs/PictureDTO.cs | 5 ----- .../DTOs/StudentDTO.cs | 13 ++++------- .../DTOs/SubGovernmentDTO.cs | 10 ++------- .../BaseModel/BaseStationOneFirstDTO.cs | 4 +--- .../BaseModel/BaseStationOneFirstOneDTO.cs | 4 +--- .../BaseModel/BaseStationOneSecondDTO.cs | 4 +--- .../BaseModel/BaseStationOneSecondOneDTO.cs | 4 +--- .../DTOs/inheritance/EntityFourDTO.cs | 1 - .../DTOs/inheritance/EntityOneDTO.cs | 1 - .../DTOs/inheritance/EntityThreeDTO.cs | 3 +-- .../DTOs/inheritance/EntityTwoDTO.cs | 3 +-- .../DeepModel/TodoItem.cs | 4 ---- .../DeepModel/User.cs | 7 +----- .../ExtensionMethods.cs | 8 +++---- .../Models/InvoiceRow.cs | 1 - .../Models/StockUnit.cs | 1 - sample/Detached.Samples.RestApi/Startup.cs | 16 +++----------- .../Extensions/TypeExtensions.cs | 5 ++--- .../TypeOptions/JsonArrayTypeOptions.cs | 1 - .../TypeOptions/JsonObjectTypeOptions.cs | 1 - .../Collection/CollectionTypeMapperFactory.cs | 4 +--- .../POCO/Complex/ComplexTypeMapperFactory.cs | 3 +-- .../POCO/Nullable/NullableTypeMapper.cs | 4 +--- .../TypePairs/TypePairMember.cs | 1 - .../Types/Class/Builder/ClassTypeBuilder.cs | 7 +++--- .../Types/Class/ClassTypeExtensions.cs | 5 ++--- .../Types/Class/ClassTypeFactory.cs | 1 - .../CamelCasePropertyNameConvention.cs | 6 ++--- .../Types/Conventions/KeyConvention.cs | 3 +-- .../Types/Dictionary/DictionaryType.cs | 1 - .../OptionalSourceTests.cs | 22 +++++++++---------- .../POCO/Complex/CustomizeMemberTests.cs | 22 +++++-------------- .../POCO/Complex/CyclesTests.cs | 12 ++++------ .../POCO/Complex/NotMappedTests.cs | 3 +-- 54 files changed, 71 insertions(+), 241 deletions(-) diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Address.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Address.cs index 6dc666fd..146c6d8f 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Address.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Address.cs @@ -1,9 +1,4 @@ using Detached.Annotations; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels { @@ -12,8 +7,9 @@ public class Address : IdBase public string Street { get; set; } public string PostalCode { get; set; } public string City { get; set; } - + public int CountryId { get; set; } + [Aggregation] public Country Country { get; set; } } diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/ConcurrencyStampBase.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/ConcurrencyStampBase.cs index b62dfd26..7d4ad23a 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/ConcurrencyStampBase.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/ConcurrencyStampBase.cs @@ -1,5 +1,4 @@ using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels; diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Country.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Country.cs index 22337933..6652832f 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Country.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Country.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels { public class Country : IdBase { @@ -14,4 +8,4 @@ public class Country : IdBase public int? FlagPictureId { get; set; } public Picture FlagPicture { get; set; } } -} +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/CustomerKind.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/CustomerKind.cs index 3ef49cc5..cff87340 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/CustomerKind.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/CustomerKind.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Government.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Government.cs index f6953ba5..07476524 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Government.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/Government.cs @@ -1,11 +1,4 @@ -using Detached.Annotations; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels { public class Government : OrganizationBase { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/IdBase.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/IdBase.cs index e16d7151..8702ad03 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/IdBase.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/IdBase.cs @@ -1,6 +1,4 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationBase.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationBase.cs index ab4f2d7d..25d57ad7 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationBase.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationBase.cs @@ -1,10 +1,5 @@ using Detached.Annotations; -using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationList.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationList.cs index 87f679ff..955ef5aa 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationList.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationList.cs @@ -1,9 +1,5 @@ using Detached.Annotations; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationNotes.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationNotes.cs index 4c5a0e19..a14a8221 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationNotes.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/OrganizationNotes.cs @@ -1,6 +1,5 @@ using Detached.Annotations; using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/StudentGrades.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/StudentGrades.cs index 57c555a4..6a80dbd6 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/StudentGrades.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/StudentGrades.cs @@ -1,4 +1,3 @@ -using Detached.Annotations; using Microsoft.EntityFrameworkCore; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels; diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/SubGovernment.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/SubGovernment.cs index f72458ea..be56c411 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/SubGovernment.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ComplexModels/SubGovernment.cs @@ -1,11 +1,4 @@ -using Detached.Annotations; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels { public class SubGovernment : Government { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/Bug17/AngebotDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/Bug17/AngebotDTO.cs index 05eac598..ec57416d 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/Bug17/AngebotDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/Bug17/AngebotDTO.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.Bug17; diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/Bug17/PositionBaseDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/Bug17/PositionBaseDTO.cs index 003e8832..ea010c99 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/Bug17/PositionBaseDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/Bug17/PositionBaseDTO.cs @@ -1,6 +1,4 @@ -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.Bug17; +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.Bug17; public abstract class PositionBaseDTO : IdBaseDTO { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CountryDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CountryDTO.cs index 90acb850..5f3060c7 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CountryDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CountryDTO.cs @@ -1,9 +1,4 @@ using Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace GraphInheritenceTests.DTOs { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CountryDTOWithoutPicture.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CountryDTOWithoutPicture.cs index 32a36221..8710cdbc 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CountryDTOWithoutPicture.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CountryDTOWithoutPicture.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs { public class CountryDTOWithoutPicture : IdBaseDTO { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CourseDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CourseDTO.cs index 35a95a6f..d8ff7225 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CourseDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/CourseDTO.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/GovernmentDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/GovernmentDTO.cs index 2fa3af65..adb3a5b3 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/GovernmentDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/GovernmentDTO.cs @@ -1,13 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs { public class GovernmentDTO : OrganizationBaseDTO { public string GovernmentIdentifierCode { get; set; } } -} +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/IdBaseDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/IdBaseDTO.cs index 855508b4..cac0d80f 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/IdBaseDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/IdBaseDTO.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs { @@ -12,4 +7,4 @@ public abstract class IdBaseDTO : ConcurrencyStampBaseDTO [Key] public int Id { get; set; } } -} +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/OrganizationBaseDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/OrganizationBaseDTO.cs index a22b9c48..cc47d4c4 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/OrganizationBaseDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/OrganizationBaseDTO.cs @@ -1,12 +1,4 @@ -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs { public class OrganizationBaseDTO : IdBaseDTO { @@ -16,4 +8,4 @@ public class OrganizationBaseDTO : IdBaseDTO public int PrimaryAddressId { get; set; } } -} +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/OrganizationListDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/OrganizationListDTO.cs index f8ee354f..d31698e9 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/OrganizationListDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/OrganizationListDTO.cs @@ -1,9 +1,4 @@ -using Detached.Annotations; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs { @@ -13,4 +8,4 @@ public class OrganizationListDTO : IdBaseDTO public List Organizations { get; set; } = new List(); } -} +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/PictureDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/PictureDTO.cs index 37947718..48f59095 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/PictureDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/PictureDTO.cs @@ -1,9 +1,4 @@ using Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace GraphInheritenceTests.DTOs { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/StudentDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/StudentDTO.cs index 4d01b3f1..bcb0f04a 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/StudentDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/StudentDTO.cs @@ -1,18 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels; +using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs { public class StudentDTO : IdBaseDTO { public string Name { get; set; } - + public int Age { get; set; } - + public StudentGrades Grades { get; set; } } -} +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/SubGovernmentDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/SubGovernmentDTO.cs index 32aba4e4..17870283 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/SubGovernmentDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/SubGovernmentDTO.cs @@ -1,13 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs { public class SubGovernmentDTO : GovernmentDTO { public string SubName { get; set; } } -} +} \ No newline at end of file diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneFirstDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneFirstDTO.cs index 87cda915..48015083 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneFirstDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneFirstDTO.cs @@ -1,6 +1,4 @@ -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels.inheritance.BaseModel; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; public abstract class BaseStationOneFirstDTO : BaseHeadDTO { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneFirstOneDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneFirstOneDTO.cs index 47330e44..56caaa59 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneFirstOneDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneFirstOneDTO.cs @@ -1,6 +1,4 @@ -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels.inheritance.BaseModel; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; public abstract class BaseStationOneFirstOneDTO : BaseStationOneFirstDTO { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneSecondDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneSecondDTO.cs index b400f377..4901d1e2 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneSecondDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneSecondDTO.cs @@ -1,6 +1,4 @@ -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels.inheritance.BaseModel; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; public abstract class BaseStationOneSecondDTO : BaseHeadDTO { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneSecondOneDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneSecondOneDTO.cs index 0bce68ae..cffc360f 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneSecondOneDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/BaseModel/BaseStationOneSecondOneDTO.cs @@ -1,6 +1,4 @@ -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels.inheritance.BaseModel; - -namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; +namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; public abstract class BaseStationOneSecondOneDTO : BaseStationOneSecondDTO { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityFourDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityFourDTO.cs index 3f2f8c7b..6f4c3c7d 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityFourDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityFourDTO.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels.inheritance.BaseModel; using Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance; diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityOneDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityOneDTO.cs index 86e202ca..4d1e8094 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityOneDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityOneDTO.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels.inheritance.BaseModel; using Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance; diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityThreeDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityThreeDTO.cs index 912d0333..2b4dacd1 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityThreeDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityThreeDTO.cs @@ -1,5 +1,4 @@ -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels.inheritance.BaseModel; -using Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; +using Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance; diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityTwoDTO.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityTwoDTO.cs index 06557018..98f2e88b 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityTwoDTO.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DTOs/inheritance/EntityTwoDTO.cs @@ -1,5 +1,4 @@ -using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels.inheritance.BaseModel; -using Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; +using Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance.BaseModel; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DTOs.inheritance; diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DeepModel/TodoItem.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DeepModel/TodoItem.cs index 42d969d7..00c2090e 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DeepModel/TodoItem.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DeepModel/TodoItem.cs @@ -1,10 +1,6 @@ using Detached.Annotations; using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Detached.Mappers.EntityFramework.Contrib.SysTec.DeepModel { diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DeepModel/User.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DeepModel/User.cs index ec272e8b..48943aa8 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DeepModel/User.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/DeepModel/User.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using Detached.Annotations; using Detached.Mappers.EntityFramework.Contrib.SysTec.ComplexModels; diff --git a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ExtensionMethods.cs b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ExtensionMethods.cs index c2d2c07c..d4bd4a3f 100644 --- a/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ExtensionMethods.cs +++ b/contrib/Detached.Mappers.EntityFramework.Contrib.SysTec/ExtensionMethods.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace Detached.Mappers.EntityFramework.Contrib.SysTec { @@ -15,7 +12,8 @@ public static string GetFriendlyName(this Enum genericEnum) MemberInfo[] memberInfo = genericEnumType.GetMember(genericEnum.ToString()); if (memberInfo != null && memberInfo.Length > 0) { - var _attribs = memberInfo[0].GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false); + var _attribs = memberInfo[0] + .GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false); if (_attribs != null && _attribs.Length > 0) { return ((System.ComponentModel.DescriptionAttribute)_attribs.ElementAt(0)).Description; @@ -25,4 +23,4 @@ public static string GetFriendlyName(this Enum genericEnum) return genericEnum.ToString(); } } -} +} \ No newline at end of file diff --git a/sample/Detached.Samples.RestApi/Models/InvoiceRow.cs b/sample/Detached.Samples.RestApi/Models/InvoiceRow.cs index d9a325ca..cb819554 100644 --- a/sample/Detached.Samples.RestApi/Models/InvoiceRow.cs +++ b/sample/Detached.Samples.RestApi/Models/InvoiceRow.cs @@ -1,5 +1,4 @@ using Detached.Annotations; -using Detached.Mappers.Annotations; using System.ComponentModel.DataAnnotations; namespace Detached.Mappers.Samples.RestApi.Models diff --git a/sample/Detached.Samples.RestApi/Models/StockUnit.cs b/sample/Detached.Samples.RestApi/Models/StockUnit.cs index 888559d0..4fef7c20 100644 --- a/sample/Detached.Samples.RestApi/Models/StockUnit.cs +++ b/sample/Detached.Samples.RestApi/Models/StockUnit.cs @@ -1,5 +1,4 @@ using Detached.Annotations; -using Detached.Mappers.Annotations; using System.ComponentModel.DataAnnotations; namespace Detached.Mappers.Samples.RestApi.Models diff --git a/sample/Detached.Samples.RestApi/Startup.cs b/sample/Detached.Samples.RestApi/Startup.cs index 3352619a..cfe521d8 100644 --- a/sample/Detached.Samples.RestApi/Startup.cs +++ b/sample/Detached.Samples.RestApi/Startup.cs @@ -10,7 +10,6 @@ using Microsoft.Extensions.Hosting; using System; using System.Collections.Generic; -using Detached.Mappers.Annotations; namespace Detached.Mappers.Samples.RestApi { @@ -38,10 +37,7 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); - services.Configure(m => - { - m.Type().Entity(true); - }); + services.Configure(m => { m.Type().Entity(true); }); } public class User { } @@ -55,10 +51,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MainDbCo app.UseSwagger(); - app.UseSwaggerUI(c => - { - c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); - }); + app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); if (env.IsDevelopment()) { @@ -71,10 +64,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MainDbCo app.UseAuthorization(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); + app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } void Seed(MainDbContext db) diff --git a/src/Detached.Mappers.HotChocolate/Extensions/TypeExtensions.cs b/src/Detached.Mappers.HotChocolate/Extensions/TypeExtensions.cs index 3dcae170..c7188e50 100644 --- a/src/Detached.Mappers.HotChocolate/Extensions/TypeExtensions.cs +++ b/src/Detached.Mappers.HotChocolate/Extensions/TypeExtensions.cs @@ -1,5 +1,4 @@ -using Detached.Mappers.HotChocolate.Types; -using Detached.Mappers.Types; +using Detached.Mappers.Types; using HotChocolate; using System; @@ -17,4 +16,4 @@ public static bool IsOptional(this Type clrType) return clrType.IsGenericType && clrType.GetGenericTypeDefinition() == typeof(Optional<>); } } -} +} \ No newline at end of file diff --git a/src/Detached.Mappers.Json/TypeOptions/JsonArrayTypeOptions.cs b/src/Detached.Mappers.Json/TypeOptions/JsonArrayTypeOptions.cs index 57983424..003a00f3 100644 --- a/src/Detached.Mappers.Json/TypeOptions/JsonArrayTypeOptions.cs +++ b/src/Detached.Mappers.Json/TypeOptions/JsonArrayTypeOptions.cs @@ -4,7 +4,6 @@ using System.Linq.Expressions; using System.Text.Json.Nodes; using static Detached.RuntimeTypes.Expressions.ExtendedExpression; -using static System.Linq.Expressions.Expression; namespace Detached.Mappers.Json.TypeOptions { diff --git a/src/Detached.Mappers.Json/TypeOptions/JsonObjectTypeOptions.cs b/src/Detached.Mappers.Json/TypeOptions/JsonObjectTypeOptions.cs index 3de75a8c..b66a2879 100644 --- a/src/Detached.Mappers.Json/TypeOptions/JsonObjectTypeOptions.cs +++ b/src/Detached.Mappers.Json/TypeOptions/JsonObjectTypeOptions.cs @@ -4,7 +4,6 @@ using System.Linq.Expressions; using System.Text.Json.Nodes; using static Detached.RuntimeTypes.Expressions.ExtendedExpression; -using static System.Linq.Expressions.Expression; namespace Detached.Mappers.Json.TypeOptions { diff --git a/src/Detached.Mappers/TypeMappers/POCO/Collection/CollectionTypeMapperFactory.cs b/src/Detached.Mappers/TypeMappers/POCO/Collection/CollectionTypeMapperFactory.cs index 05f4d645..4d416547 100644 --- a/src/Detached.Mappers/TypeMappers/POCO/Collection/CollectionTypeMapperFactory.cs +++ b/src/Detached.Mappers/TypeMappers/POCO/Collection/CollectionTypeMapperFactory.cs @@ -1,11 +1,9 @@ -using Detached.Mappers.Annotations; -using Detached.Mappers.TypePairs; +using Detached.Mappers.TypePairs; using Detached.Mappers.Types; using Detached.Mappers.Types.Class; using System; using System.Linq.Expressions; using static Detached.RuntimeTypes.Expressions.ExtendedExpression; -using static System.Linq.Expressions.Expression; namespace Detached.Mappers.TypeMappers.POCO.Collection { diff --git a/src/Detached.Mappers/TypeMappers/POCO/Complex/ComplexTypeMapperFactory.cs b/src/Detached.Mappers/TypeMappers/POCO/Complex/ComplexTypeMapperFactory.cs index 709aeec8..7e8c7961 100644 --- a/src/Detached.Mappers/TypeMappers/POCO/Complex/ComplexTypeMapperFactory.cs +++ b/src/Detached.Mappers/TypeMappers/POCO/Complex/ComplexTypeMapperFactory.cs @@ -1,5 +1,4 @@ -using Detached.Mappers.Annotations; -using Detached.Mappers.TypePairs; +using Detached.Mappers.TypePairs; using Detached.Mappers.Types.Class; using System; using System.Linq.Expressions; diff --git a/src/Detached.Mappers/TypeMappers/POCO/Nullable/NullableTypeMapper.cs b/src/Detached.Mappers/TypeMappers/POCO/Nullable/NullableTypeMapper.cs index 388c1c54..e8f3a6b0 100644 --- a/src/Detached.Mappers/TypeMappers/POCO/Nullable/NullableTypeMapper.cs +++ b/src/Detached.Mappers/TypeMappers/POCO/Nullable/NullableTypeMapper.cs @@ -1,6 +1,4 @@ -using System; - -namespace Detached.Mappers.TypeMappers.POCO.Nullable +namespace Detached.Mappers.TypeMappers.POCO.Nullable { public class NullableTypeMapper : TypeMapper where TSource : struct diff --git a/src/Detached.Mappers/TypePairs/TypePairMember.cs b/src/Detached.Mappers/TypePairs/TypePairMember.cs index ac07026c..41ae351a 100644 --- a/src/Detached.Mappers/TypePairs/TypePairMember.cs +++ b/src/Detached.Mappers/TypePairs/TypePairMember.cs @@ -1,6 +1,5 @@ using Detached.Mappers.Types; using System.Collections.Generic; -using System.Linq.Expressions; namespace Detached.Mappers.TypePairs { diff --git a/src/Detached.Mappers/Types/Class/Builder/ClassTypeBuilder.cs b/src/Detached.Mappers/Types/Class/Builder/ClassTypeBuilder.cs index fd796e2a..4f9462c4 100644 --- a/src/Detached.Mappers/Types/Class/Builder/ClassTypeBuilder.cs +++ b/src/Detached.Mappers/Types/Class/Builder/ClassTypeBuilder.cs @@ -1,7 +1,5 @@ -using Detached.Mappers.Annotations; -using Detached.Mappers.TypePairs; +using Detached.Mappers.TypePairs; using Detached.Mappers.TypePairs.Builder; -using Detached.Mappers.Types; using System; using System.Linq.Expressions; using System.Reflection; @@ -81,7 +79,8 @@ public ClassTypeBuilder IncludePrimitives() return this; } - public ClassTypeDiscriminatorBuilder Discriminator(Expression> selector) + public ClassTypeDiscriminatorBuilder Discriminator( + Expression> selector) { ClassTypeMember memberOptions = GetMember(selector); TypeOptions.SetDiscriminatorName(memberOptions.Name); diff --git a/src/Detached.Mappers/Types/Class/ClassTypeExtensions.cs b/src/Detached.Mappers/Types/Class/ClassTypeExtensions.cs index ba4aa41f..ba1c6eb8 100644 --- a/src/Detached.Mappers/Types/Class/ClassTypeExtensions.cs +++ b/src/Detached.Mappers/Types/Class/ClassTypeExtensions.cs @@ -1,5 +1,4 @@ -using Detached.Mappers.Annotations; -using Detached.RuntimeTypes.Reflection; +using Detached.RuntimeTypes.Reflection; using System; using System.Collections.Generic; using System.Reflection; @@ -111,4 +110,4 @@ public static string GetConcurrencyTokenName(this IType type) return result as string; } } -} +} \ No newline at end of file diff --git a/src/Detached.Mappers/Types/Class/ClassTypeFactory.cs b/src/Detached.Mappers/Types/Class/ClassTypeFactory.cs index 9e0f9102..8104e9a3 100644 --- a/src/Detached.Mappers/Types/Class/ClassTypeFactory.cs +++ b/src/Detached.Mappers/Types/Class/ClassTypeFactory.cs @@ -1,5 +1,4 @@ using Detached.Mappers.Annotations; -using Detached.Mappers.Types.Class; using Detached.Mappers.Types.Conventions; using Detached.PatchTypes; using Detached.RuntimeTypes.Reflection; diff --git a/src/Detached.Mappers/Types/Conventions/CamelCasePropertyNameConvention.cs b/src/Detached.Mappers/Types/Conventions/CamelCasePropertyNameConvention.cs index c9f50193..063bff72 100644 --- a/src/Detached.Mappers/Types/Conventions/CamelCasePropertyNameConvention.cs +++ b/src/Detached.Mappers/Types/Conventions/CamelCasePropertyNameConvention.cs @@ -1,6 +1,4 @@ -using Detached.Mappers.Types; - -namespace Detached.Mappers.Types.Conventions +namespace Detached.Mappers.Types.Conventions { public class CamelCasePropertyNameConvention : IPropertyNameConvention { @@ -9,4 +7,4 @@ public string GetSourcePropertyName(IType sourceType, IType targetType, string t return char.ToLower(targetMemberName[0]) + targetMemberName.Substring(1); } } -} +} \ No newline at end of file diff --git a/src/Detached.Mappers/Types/Conventions/KeyConvention.cs b/src/Detached.Mappers/Types/Conventions/KeyConvention.cs index cc1d5b9e..fea79242 100644 --- a/src/Detached.Mappers/Types/Conventions/KeyConvention.cs +++ b/src/Detached.Mappers/Types/Conventions/KeyConvention.cs @@ -1,5 +1,4 @@ -using Detached.Mappers.Annotations; -using Detached.Mappers.Types.Class; +using Detached.Mappers.Types.Class; using System.Linq; namespace Detached.Mappers.Types.Conventions diff --git a/src/Detached.Mappers/Types/Dictionary/DictionaryType.cs b/src/Detached.Mappers/Types/Dictionary/DictionaryType.cs index fe3859a6..9dd8f004 100644 --- a/src/Detached.Mappers/Types/Dictionary/DictionaryType.cs +++ b/src/Detached.Mappers/Types/Dictionary/DictionaryType.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq.Expressions; using static Detached.RuntimeTypes.Expressions.ExtendedExpression; -using static System.Linq.Expressions.Expression; namespace Detached.Mappers.Types.Dictionary { diff --git a/test/Detached.Mappers.HotChocolate.Tests/OptionalSourceTests.cs b/test/Detached.Mappers.HotChocolate.Tests/OptionalSourceTests.cs index c0d9ec41..76499b1d 100644 --- a/test/Detached.Mappers.HotChocolate.Tests/OptionalSourceTests.cs +++ b/test/Detached.Mappers.HotChocolate.Tests/OptionalSourceTests.cs @@ -1,5 +1,3 @@ -using Detached.Mappers; -using Detached.Mappers.HotChocolate; using Detached.PatchTypes; using HotChocolate; using Xunit; @@ -21,11 +19,11 @@ public void map_optional_source_set() Id = 1, Name = "dto", Nested = new Optional( - new SubDTO - { - Id = 2, - Name = "subdto" - } + new SubDTO + { + Id = 2, + Name = "subdto" + } ) }; @@ -48,11 +46,11 @@ public void map_optional_source_unset() { Id = 1, Nested = new Optional( - new SubDTO - { - Id = 2, - Name = "subdto" - } + new SubDTO + { + Id = 2, + Name = "subdto" + } ) }; diff --git a/test/Detached.Mappers.Tests/POCO/Complex/CustomizeMemberTests.cs b/test/Detached.Mappers.Tests/POCO/Complex/CustomizeMemberTests.cs index bf3daa67..ce6fa5c5 100644 --- a/test/Detached.Mappers.Tests/POCO/Complex/CustomizeMemberTests.cs +++ b/test/Detached.Mappers.Tests/POCO/Complex/CustomizeMemberTests.cs @@ -1,9 +1,6 @@ using Detached.PatchTypes; using System.Collections.Generic; -using System.Linq.Expressions; using Xunit; -using static Detached.RuntimeTypes.Expressions.ExtendedExpression; -using static System.Linq.Expressions.Expression; namespace Detached.Mappers.Tests.POCO.Complex { @@ -14,18 +11,12 @@ public void customize_property() { MapperOptions mapperOptions = new MapperOptions(); mapperOptions.Type() - .Member(m => m.Value) - .Setter((@this, value, mapContext) => - { - @this.Value = value + 1; - }); + .Member(m => m.Value) + .Setter((@this, value, mapContext) => { @this.Value = value + 1; }); mapperOptions.Type() - .Member(m => m.Value) - .Getter((@this, mapContext) => - { - return @this.Value + 1; - }); + .Member(m => m.Value) + .Getter((@this, mapContext) => { return @this.Value + 1; }); Mapper mapper = new Mapper(mapperOptions); @@ -47,10 +38,7 @@ public class TargetEntity : IPatch public int Value { - get - { - return _value; - } + get { return _value; } set { if (_value != value) diff --git a/test/Detached.Mappers.Tests/POCO/Complex/CyclesTests.cs b/test/Detached.Mappers.Tests/POCO/Complex/CyclesTests.cs index 079138b5..e4f98f5d 100644 --- a/test/Detached.Mappers.Tests/POCO/Complex/CyclesTests.cs +++ b/test/Detached.Mappers.Tests/POCO/Complex/CyclesTests.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using Xunit; namespace Detached.Mappers.Tests.POCO.Complex @@ -77,7 +73,7 @@ public class DirectCycle } public class RootDTO - { + { public int Id { get; set; } public string Name { get; set; } @@ -86,7 +82,7 @@ public class RootDTO } public class Root - { + { public int Id { get; set; } public string Name { get; set; } @@ -112,4 +108,4 @@ public class Item public string Name { get; set; } } } -} +} \ No newline at end of file diff --git a/test/Detached.Mappers.Tests/POCO/Complex/NotMappedTests.cs b/test/Detached.Mappers.Tests/POCO/Complex/NotMappedTests.cs index d73c1713..eeebbcd1 100644 --- a/test/Detached.Mappers.Tests/POCO/Complex/NotMappedTests.cs +++ b/test/Detached.Mappers.Tests/POCO/Complex/NotMappedTests.cs @@ -1,5 +1,4 @@ using Detached.Annotations; -using System.ComponentModel.DataAnnotations.Schema; using Xunit; namespace Detached.Mappers.Tests.POCO.Complex @@ -37,4 +36,4 @@ public class Entity public string Text2 { get; set; } } } -} +} \ No newline at end of file From 3464f91217a36b36501fe5e47fa3c42ec69dbd7a Mon Sep 17 00:00:00 2001 From: Wouter Dingemanse Date: Tue, 15 Aug 2023 15:26:26 +0200 Subject: [PATCH 5/7] Fix tests --- .../MapIgnoreAnnotationTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Detached.Mappers.Annotation.Tests/MapIgnoreAnnotationTests.cs b/test/Detached.Mappers.Annotation.Tests/MapIgnoreAnnotationTests.cs index 6b0d16cd..2305c202 100644 --- a/test/Detached.Mappers.Annotation.Tests/MapIgnoreAnnotationTests.cs +++ b/test/Detached.Mappers.Annotation.Tests/MapIgnoreAnnotationTests.cs @@ -13,7 +13,7 @@ public void attribute_must_set_annotation() IType type = mapper.Options.GetType(typeof(AnnotatedEntity)); ITypeMember member = type.GetMember("Items"); - Assert.True(member.Annotations.ContainsKey(MapIgnoreAnnotationHandlerExtensions.KEY)); + Assert.True(Attribute.IsDefined(typeof(AnnotatedEntity).GetProperty(nameof(AnnotatedEntity.Items)), typeof(MapIgnoreAttribute))); } [Fact] @@ -28,7 +28,7 @@ public void fluent_must_set_annotation() IType type = mapper.Options.GetType(typeof(AnnotatedEntity)); ITypeMember member = type.GetMember("Items"); - Assert.True(member.Annotations.ContainsKey(MapIgnoreAnnotationHandlerExtensions.KEY)); + Assert.True(Attribute.IsDefined(typeof(AnnotatedEntity).GetProperty(nameof(AnnotatedEntity.Items)), typeof(MapIgnoreAttribute))); } [Fact] From 0e2c954dd443778bd772eba29b29753ad318671d Mon Sep 17 00:00:00 2001 From: Wouter Dingemanse Date: Wed, 6 Sep 2023 11:02:15 +0200 Subject: [PATCH 6/7] Make it work on linux --- .../TellDbContext.cs | 1 - sample/Detached.Samples.RestApi/Startup.cs | 2 +- sample/Detached.Samples.RestApi/appsettings.json | 2 +- .../Fixture/TestDbContext.cs | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs index ec0c21bb..72c6dd58 100644 --- a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs @@ -27,7 +27,6 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) .EnableSensitiveDataLogging() .LogTo(message => Debug.WriteLine(message), LogLevel.Information) .EnableDetailedErrors() - .UseDetached() .UseMapping(builder => { builder.Default(options => diff --git a/sample/Detached.Samples.RestApi/Startup.cs b/sample/Detached.Samples.RestApi/Startup.cs index cfe521d8..df445040 100644 --- a/sample/Detached.Samples.RestApi/Startup.cs +++ b/sample/Detached.Samples.RestApi/Startup.cs @@ -30,7 +30,7 @@ public void ConfigureServices(IServiceCollection services) services.AddDbContext(cfg => { - cfg.UseSqlServer(Configuration.GetConnectionString("MainDb")); + cfg.UseSqlite(Configuration.GetConnectionString("MainDb")); cfg.UseDetached(); }); diff --git a/sample/Detached.Samples.RestApi/appsettings.json b/sample/Detached.Samples.RestApi/appsettings.json index dde32406..45191ebe 100644 --- a/sample/Detached.Samples.RestApi/appsettings.json +++ b/sample/Detached.Samples.RestApi/appsettings.json @@ -8,6 +8,6 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "MainDb": "Server=.;Database=DetachedTest;Trusted_Connection=True;" + "MainDb": "DataSource=file:main_db.sql3?cache=shared" } } diff --git a/test/Detached.Mappers.EntityFramework.Tests/Fixture/TestDbContext.cs b/test/Detached.Mappers.EntityFramework.Tests/Fixture/TestDbContext.cs index b78cbed1..f949c088 100644 --- a/test/Detached.Mappers.EntityFramework.Tests/Fixture/TestDbContext.cs +++ b/test/Detached.Mappers.EntityFramework.Tests/Fixture/TestDbContext.cs @@ -24,8 +24,8 @@ public static async Task Create(bool overwrite = true, services.AddDbContext(opts => { - opts//.UseSqlite($"DataSource=file:{dbName}?mode=memory&cache=shared") - .UseSqlServer($"Server=localhost\\SQLEXPRESS;Database={dbName};User Id=sa;Password=Sa12345.;Encrypt=False;") + opts.UseSqlite($"DataSource=file:{dbName}?mode=memory&cache=shared") + //.UseSqlServer($"Server=localhost\\SQLEXPRESS;Database={dbName};User Id=sa;Password=Sa12345.;Encrypt=False;") .EnableSensitiveDataLogging() .EnableDetailedErrors() .UseMapping(); From 3e7e199a754da0db9f0087c2dc364c05dd13c72f Mon Sep 17 00:00:00 2001 From: Wouter Dingemanse Date: Fri, 29 Sep 2023 10:57:13 +0200 Subject: [PATCH 7/7] Change --- .../TellDbContext.cs | 19 +++++++++---------- .../UnitTest1.cs | 12 ++++++------ .../Work.cs | 3 +-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs index 72c6dd58..0cce84ec 100644 --- a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/TellDbContext.cs @@ -9,6 +9,7 @@ namespace Detached.Mappers.Tests.Contrib.ScottSoftware; public class TellDbContext : DbContext { static SqliteConnection _connection; + public DbSet Creators { get; set; } public DbSet Works { get; set; } @@ -21,7 +22,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) _connection.Open(); } - + optionsBuilder .UseSqlite(_connection) .EnableSensitiveDataLogging() @@ -29,11 +30,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) .EnableDetailedErrors() .UseMapping(builder => { - builder.Default(options => - { - options.Type().Member(c => c.Works).Composition(); - }); - } ); + builder.Default(mapperOptions => { mapperOptions.Type().Member(f => f.Creator).Parent(); }); + }); base.OnConfiguring(optionsBuilder); } @@ -41,15 +39,16 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfiguration(new CreatorConfiguration()); modelBuilder.ApplyConfiguration(new WorkConfiguration()); - modelBuilder.Entity().HasMany(c => c.Works).WithOne(w => w.Creator) - .HasForeignKey(w => w.CreatorId); + modelBuilder.Entity().HasMany(c => c.Works).WithOne(w => w.Creator); + modelBuilder.Entity().HasData(new Creator { Id = 1, FullName = @"Douglas Adams", PrimaryLanguage = "EN", Born = new DateTime(1952, 4, 11), Died = new DateTime(2001, 5, 11) }); - modelBuilder.Entity().HasData(new Work { Id = 1, CreatorId = 1, Title = @"Young Zaphod Plays It Safe", Language = "EN"}); - base.OnModelCreating(modelBuilder); + /*modelBuilder.Entity().HasData(new Work + { Id = 1, Creator = new Creator { Id = 1 }, Title = @"Young Zaphod Plays It Safe", Language = "EN" });*/ + base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/UnitTest1.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/UnitTest1.cs index 3e3e40c6..1e8f37f9 100644 --- a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/UnitTest1.cs +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/UnitTest1.cs @@ -9,11 +9,12 @@ public void Test1() { var correctedTitle = @"The Dragon's Path"; var correctedName = @"Daniel Abraham"; + // create the sqlite db. + new TellDbContext().Database.EnsureCreated(); + using (var context = new TellDbContext()) { - // create the sqlite db. - context.Database.EnsureCreated(); - var newCreator = context.Map(new Creator + context.Map(new Creator { FullName = "Daniel Abraham.", PrimaryLanguage = "EN", Works = new() { new Work { Title = @"The Dragons Path", Language = "EN" } } @@ -21,7 +22,6 @@ public void Test1() context.SaveChanges(); } - using (var context = new TellDbContext()) { Assert.Equal(2, context.Creators.Count()); @@ -38,8 +38,8 @@ public void Test1() Id = newId, FullName = "Daniel Abraham", Works = new() { - new Work { Title = correctedTitle, Language = "EN", Id = 2, CreatorId = newId }, - new Work { Title = @"The King's Blood", Language = "EN", CreatorId = newId }, + new Work { Title = correctedTitle, Language = "EN", Id = 2, Creator = new Creator { Id = newId } }, + new Work { Title = @"The King's Blood", Language = "EN", Creator = new Creator { Id = newId } }, } }); context.SaveChanges(); diff --git a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Work.cs b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Work.cs index 91c4231b..1f6b6d38 100644 --- a/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Work.cs +++ b/contrib/Detached.Mappers.Tests.Contrib.ScottSoftware/Work.cs @@ -8,7 +8,6 @@ public class Work public string Language { get; set; } - public int CreatorId { get; set; } - public Creator Creator { get; set; } + public int? CreatorId { get; set; } } \ No newline at end of file