From 31ac58f274ac87d4ff02428fd030664b1edbdff1 Mon Sep 17 00:00:00 2001 From: Wvader <34067397+wvader@users.noreply.github.com> Date: Sat, 11 Dec 2021 11:51:54 +0000 Subject: [PATCH] tru fix --- src/MapTo/Extensions/CommonExtensions.cs | 2 ++ src/MapTo/Extensions/CommonSource.cs | 6 +++--- test/TestConsoleApp/Data/FinanceTransaction.cs | 1 + .../Data/FinanceTransactionInsertDto.cs | 16 ++++++++++++++++ .../Data/FinanceTransactionReadDto.cs | 3 +-- test/TestConsoleApp/Data/UserList.cs | 1 - test/TestConsoleApp/Data/UserUpdateDto.cs | 2 -- test/TestConsoleApp/ViewModels/UserViewModel.cs | 15 --------------- 8 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 test/TestConsoleApp/Data/FinanceTransactionInsertDto.cs delete mode 100644 test/TestConsoleApp/ViewModels/UserViewModel.cs diff --git a/src/MapTo/Extensions/CommonExtensions.cs b/src/MapTo/Extensions/CommonExtensions.cs index 248c096..f02df28 100644 --- a/src/MapTo/Extensions/CommonExtensions.cs +++ b/src/MapTo/Extensions/CommonExtensions.cs @@ -36,6 +36,8 @@ namespace MapTo.Extensions .WriteComment($" Type {item.Type}") .WriteComment($" MappedSourcePropertyTypeName {item.MappedSourcePropertyTypeName}") .WriteComment($" IsEnumerable {item.IsEnumerable}") + .WriteComment($" FullyQualifiedType {item.FullyQualifiedType}") + .WriteComment($" EnumerableTypeArgument {item.EnumerableTypeArgument}") .WriteComment($" SourcePropertyName {item.SourcePropertyName}") .WriteComment($" TypeSymbol {item.FullyQualifiedType.ToString()}") .WriteComment($" isReadOnly {item.isReadOnly.ToString()}") diff --git a/src/MapTo/Extensions/CommonSource.cs b/src/MapTo/Extensions/CommonSource.cs index fd11b71..27ce9ff 100644 --- a/src/MapTo/Extensions/CommonSource.cs +++ b/src/MapTo/Extensions/CommonSource.cs @@ -10,7 +10,7 @@ namespace MapTo.Extensions { internal static SourceCode GenerateStructOrClass(this MappingModel model, string structOrClass) { - const bool writeDebugInfo = false; + const bool writeDebugInfo = true; using var builder = new SourceBuilder() .WriteLine(GeneratedFilesHeader) @@ -66,7 +66,7 @@ namespace MapTo.Extensions foreach (var property in model.TypeProperties) { - if (!model.SourceProperties.IsMappedProperty(property)) + if (!model.TypeProperties.IsMappedProperty(property)) { stringBuilder.Append(", "); stringBuilder.Append($"{property.FullyQualifiedType} {property.SourcePropertyName.ToCamelCase()}"); @@ -88,7 +88,7 @@ namespace MapTo.Extensions foreach(var prop in properties) { - if (prop.FullyQualifiedType == property.FullyQualifiedType) return true; + if (prop.FullyQualifiedType.ToString() == property.FullyQualifiedType.ToString()) return true; } return false; diff --git a/test/TestConsoleApp/Data/FinanceTransaction.cs b/test/TestConsoleApp/Data/FinanceTransaction.cs index aaba5fb..99c13e2 100644 --- a/test/TestConsoleApp/Data/FinanceTransaction.cs +++ b/test/TestConsoleApp/Data/FinanceTransaction.cs @@ -20,6 +20,7 @@ namespace BlueWest.Data Sell } + [MapFrom(typeof(FinanceTransactionInsertDto))] public partial struct FinanceTransaction { public int Id { get; } diff --git a/test/TestConsoleApp/Data/FinanceTransactionInsertDto.cs b/test/TestConsoleApp/Data/FinanceTransactionInsertDto.cs new file mode 100644 index 0000000..d91b03a --- /dev/null +++ b/test/TestConsoleApp/Data/FinanceTransactionInsertDto.cs @@ -0,0 +1,16 @@ +using System; + +namespace BlueWest.Data +{ + + public partial struct FinanceTransactionInsertDto + { + public int UserId { get; set; } + public FinanceTransactionType FinanceTransactionType { get; } + public FinanceSymbol FinanceSymbol { get; } + public double Amount { get; } // To Buy + public double Quantity { get; } // Bought + public double Fee { get; } + public DateTime DateTime { get; } + } +} \ No newline at end of file diff --git a/test/TestConsoleApp/Data/FinanceTransactionReadDto.cs b/test/TestConsoleApp/Data/FinanceTransactionReadDto.cs index ca36fb4..02e47b2 100644 --- a/test/TestConsoleApp/Data/FinanceTransactionReadDto.cs +++ b/test/TestConsoleApp/Data/FinanceTransactionReadDto.cs @@ -7,9 +7,8 @@ namespace BlueWest.Data { [MapFrom(typeof(FinanceTransaction))] - public partial struct FinanceTransactionReadDto + partial struct FinanceTransactionReadDto { - public int Id { get; set; } public int UserId { get; set; } public FinanceTransactionType FinanceTransactionType { get; } public FinanceSymbol FinanceSymbol { get; } diff --git a/test/TestConsoleApp/Data/UserList.cs b/test/TestConsoleApp/Data/UserList.cs index c7c0dc0..b653d18 100644 --- a/test/TestConsoleApp/Data/UserList.cs +++ b/test/TestConsoleApp/Data/UserList.cs @@ -11,7 +11,6 @@ namespace BlueWest.Data Users = users; } - public int Length => Users.Count; } } \ No newline at end of file diff --git a/test/TestConsoleApp/Data/UserUpdateDto.cs b/test/TestConsoleApp/Data/UserUpdateDto.cs index 48844fd..456193f 100644 --- a/test/TestConsoleApp/Data/UserUpdateDto.cs +++ b/test/TestConsoleApp/Data/UserUpdateDto.cs @@ -15,7 +15,5 @@ namespace BlueWest.Data public double BTCAmount { get; set; } public double LTCAmount { get; set; } - - } } \ No newline at end of file diff --git a/test/TestConsoleApp/ViewModels/UserViewModel.cs b/test/TestConsoleApp/ViewModels/UserViewModel.cs deleted file mode 100644 index 8ba0590..0000000 --- a/test/TestConsoleApp/ViewModels/UserViewModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using BlueWest.Data; -using MapTo; -using TestConsoleApp.Data.Models; - -namespace TestConsoleApp.ViewModels -{ - [MapFrom(typeof(User))] - public partial struct UserViewModel - { - public int Id { get; set; } - - public DateTimeOffset RegisteredAt { get; } - } -} \ No newline at end of file