Fix UseUpdate usage
This commit is contained in:
parent
f7963d2d7e
commit
aa5b01cdc4
|
@ -13,7 +13,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()
|
||||
|
@ -58,12 +58,10 @@ namespace MapTo.Extensions
|
|||
.WriteLine()
|
||||
// Class body
|
||||
.GeneratePublicConstructor(model);
|
||||
foreach (var targetSourceType in model.MappedSourceTypes)
|
||||
{
|
||||
if (model.IsTypeUpdatable && targetSourceType.TypeProperties.GetWritableMappedProperties().Length > 0) builder.GenerateUpdateMethod(model);
|
||||
if (model.IsTypeUpdatable && targetSourceType.TypeFields.GetWritableMappedProperties().Length > 0) builder.GenerateUpdateMethod(model);
|
||||
}
|
||||
|
||||
var addedMembers = new List<MappedMember>();
|
||||
|
||||
if (model.IsTypeUpdatable) builder.GenerateUpdateMethod(model);
|
||||
if (model.IsJsonExtension) builder.WriteToJsonMethod(model);
|
||||
|
||||
|
||||
|
@ -116,7 +114,8 @@ namespace MapTo.Extensions
|
|||
.WriteOpeningBracket()
|
||||
.WriteAssignmentMethod(model, otherProperties.ToArray().ToImmutableArray(), sourceClassParameterName, mappingContextParameterName, false);
|
||||
|
||||
builder.WriteClosingBracket();
|
||||
builder.WriteClosingBracket()
|
||||
.WriteLine();
|
||||
}
|
||||
|
||||
// End constructor declaration
|
||||
|
@ -302,35 +301,31 @@ namespace MapTo.Extensions
|
|||
var sourceClassParameterName = targetSourceType.SourceTypeIdentifierName.ToCamelCase();
|
||||
|
||||
builder
|
||||
.GenerateUpdaterMethodsXmlDocs(model, sourceClassParameterName)
|
||||
.GenerateUpdaterMethodsXmlDocs(model, sourceClassParameterName, targetSourceType)
|
||||
.WriteLine($"public void Update({targetSourceType.SourceType} {sourceClassParameterName})")
|
||||
.WriteOpeningBracket()
|
||||
.WriteAssignmentMethod(model, null, sourceClassParameterName, "context", true)
|
||||
.WriteClosingBracket();
|
||||
.WriteClosingBracket()
|
||||
.WriteLine();
|
||||
}
|
||||
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static SourceBuilder GenerateUpdaterMethodsXmlDocs(this SourceBuilder builder, MappingModel model, string sourceClassParameterName)
|
||||
private static SourceBuilder GenerateUpdaterMethodsXmlDocs(this SourceBuilder builder, MappingModel model, string sourceClassParameterName,
|
||||
MappedSourceType mappedSourceType)
|
||||
{
|
||||
if (!model.Options.GenerateXmlDocument)
|
||||
{
|
||||
return builder;
|
||||
}
|
||||
|
||||
foreach (var targetSourceType in model.MappedSourceTypes)
|
||||
{
|
||||
builder
|
||||
.WriteLine("/// <summary>")
|
||||
.WriteLine($"/// Updates <see cref=\"{model.TypeIdentifierName}\"/> and sets its participating properties")
|
||||
.WriteLine($"/// using the property values from <paramref name=\"{sourceClassParameterName}\"/>.")
|
||||
.WriteLine("/// </summary>")
|
||||
.WriteLine($"/// <param name=\"{sourceClassParameterName}\">The instance of <see cref=\"{targetSourceType.SourceType}\"/> to use as source.</param>");
|
||||
|
||||
}
|
||||
|
||||
builder
|
||||
.WriteLine("/// <summary>")
|
||||
.WriteLine($"/// Updates <see cref=\"{model.TypeIdentifierName}\"/> and sets its participating properties")
|
||||
.WriteLine($"/// using the property values from <paramref name=\"{sourceClassParameterName}\"/>.")
|
||||
.WriteLine("/// </summary>")
|
||||
.WriteLine($"/// <param name=\"{sourceClassParameterName}\">The instance of <see cref=\"{mappedSourceType.SourceType}\"/> to use as source.</param>");
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MapTo.Extensions;
|
||||
using MapTo.Sources;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
@ -507,7 +505,7 @@ namespace MapTo
|
|||
|
||||
var typeIdentifierName = TypeSyntax.GetIdentifierName();
|
||||
var isTypeInheritFromMappedBaseClass = IsTypeInheritFromMappedBaseClass(semanticModel);
|
||||
var isTypeUpdatable = false; //IsTypeUpdatable();
|
||||
var isTypeUpdatable = true; //IsTypeUpdatable();
|
||||
var hasJsonExtension = false; // HasJsonExtension();
|
||||
|
||||
List<MappedSourceType> mappedSourceTypes = new List<MappedSourceType>();
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace MapTo.Sources
|
|||
if (options.GenerateXmlDocument)
|
||||
{
|
||||
builder
|
||||
.WriteLine()
|
||||
.WriteLine("/// <summary>")
|
||||
.WriteLine("/// Specifies the mapping behavior of the annotated property.")
|
||||
.WriteLine("/// </summary>")
|
||||
|
|
Loading…
Reference in New Issue