From 63b2bcb3593440fb332917bed7d6c78827195dbe Mon Sep 17 00:00:00 2001 From: Wvader <34067397+wvader@users.noreply.github.com> Date: Wed, 8 Dec 2021 18:29:16 +0000 Subject: [PATCH] , --- src/MapTo/Extensions/CommonExtensions.cs | 2 +- src/MapTo/Extensions/CommonSource.cs | 14 +++++--------- src/MapTo/Sources/UseUpdateAttributeSource.cs | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/MapTo/Extensions/CommonExtensions.cs b/src/MapTo/Extensions/CommonExtensions.cs index 3291ac4..248c096 100644 --- a/src/MapTo/Extensions/CommonExtensions.cs +++ b/src/MapTo/Extensions/CommonExtensions.cs @@ -38,7 +38,7 @@ namespace MapTo.Extensions .WriteComment($" IsEnumerable {item.IsEnumerable}") .WriteComment($" SourcePropertyName {item.SourcePropertyName}") .WriteComment($" TypeSymbol {item.FullyQualifiedType.ToString()}") - .WriteComment($" TypeSymbol {item.FullyQualifiedType.ToString()}") + .WriteComment($" isReadOnly {item.isReadOnly.ToString()}") .WriteLine(); } diff --git a/src/MapTo/Extensions/CommonSource.cs b/src/MapTo/Extensions/CommonSource.cs index a158a20..fd11b71 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 = true; + const bool writeDebugInfo = false; using var builder = new SourceBuilder() .WriteLine(GeneratedFilesHeader) @@ -62,27 +62,23 @@ namespace MapTo.Extensions var baseConstructor = /*model.HasMappedBaseClass ? $" : base({mappingContextParameterName}, {sourceClassParameterName})" :*/ string.Empty; - var readOnlyProperties = model.TypeProperties.GetReadOnlyMappedProperties(); - var stringBuilder = new StringBuilder(); - for (int i = 0; i < readOnlyProperties.Length; i++) + foreach (var property in model.TypeProperties) { - var property = readOnlyProperties[i]; - if(!model.SourceProperties.IsMappedProperty(property)) + if (!model.SourceProperties.IsMappedProperty(property)) { stringBuilder.Append(", "); stringBuilder.Append($"{property.FullyQualifiedType} {property.SourcePropertyName.ToCamelCase()}"); } - } - + var readOnlyPropertiesArguments = stringBuilder.ToString(); builder .WriteLine($"public {model.TypeIdentifierName}({model.SourceType} {sourceClassParameterName}{readOnlyPropertiesArguments}){baseConstructor}") .WriteOpeningBracket() - .TryWriteProperties(model.SourceProperties, readOnlyProperties, sourceClassParameterName, mappingContextParameterName, false); + .TryWriteProperties(model.SourceProperties, model.TypeProperties, sourceClassParameterName, mappingContextParameterName, false); // End constructor declaration return builder.WriteClosingBracket(); diff --git a/src/MapTo/Sources/UseUpdateAttributeSource.cs b/src/MapTo/Sources/UseUpdateAttributeSource.cs index 2d0f49a..dae6d71 100644 --- a/src/MapTo/Sources/UseUpdateAttributeSource.cs +++ b/src/MapTo/Sources/UseUpdateAttributeSource.cs @@ -21,7 +21,7 @@ namespace MapTo.Sources { builder .WriteLine("/// ") - .WriteLine("/// Specifies that the annotated class can be mapped from the provided .") + .WriteLine("/// Specifies that the annotated class can be updatable.") .WriteLine("/// "); }