This commit is contained in:
parent
4bf3599d79
commit
63b2bcb359
|
@ -38,7 +38,7 @@ namespace MapTo.Extensions
|
||||||
.WriteComment($" IsEnumerable {item.IsEnumerable}")
|
.WriteComment($" IsEnumerable {item.IsEnumerable}")
|
||||||
.WriteComment($" SourcePropertyName {item.SourcePropertyName}")
|
.WriteComment($" SourcePropertyName {item.SourcePropertyName}")
|
||||||
.WriteComment($" TypeSymbol {item.FullyQualifiedType.ToString()}")
|
.WriteComment($" TypeSymbol {item.FullyQualifiedType.ToString()}")
|
||||||
.WriteComment($" TypeSymbol {item.FullyQualifiedType.ToString()}")
|
.WriteComment($" isReadOnly {item.isReadOnly.ToString()}")
|
||||||
.WriteLine();
|
.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace MapTo.Extensions
|
||||||
{
|
{
|
||||||
internal static SourceCode GenerateStructOrClass(this MappingModel model, string structOrClass)
|
internal static SourceCode GenerateStructOrClass(this MappingModel model, string structOrClass)
|
||||||
{
|
{
|
||||||
const bool writeDebugInfo = true;
|
const bool writeDebugInfo = false;
|
||||||
|
|
||||||
using var builder = new SourceBuilder()
|
using var builder = new SourceBuilder()
|
||||||
.WriteLine(GeneratedFilesHeader)
|
.WriteLine(GeneratedFilesHeader)
|
||||||
|
@ -62,27 +62,23 @@ namespace MapTo.Extensions
|
||||||
|
|
||||||
var baseConstructor = /*model.HasMappedBaseClass ? $" : base({mappingContextParameterName}, {sourceClassParameterName})" :*/ string.Empty;
|
var baseConstructor = /*model.HasMappedBaseClass ? $" : base({mappingContextParameterName}, {sourceClassParameterName})" :*/ string.Empty;
|
||||||
|
|
||||||
var readOnlyProperties = model.TypeProperties.GetReadOnlyMappedProperties();
|
|
||||||
|
|
||||||
var stringBuilder = new StringBuilder();
|
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(", ");
|
||||||
stringBuilder.Append($"{property.FullyQualifiedType} {property.SourcePropertyName.ToCamelCase()}");
|
stringBuilder.Append($"{property.FullyQualifiedType} {property.SourcePropertyName.ToCamelCase()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var readOnlyPropertiesArguments = stringBuilder.ToString();
|
var readOnlyPropertiesArguments = stringBuilder.ToString();
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.WriteLine($"public {model.TypeIdentifierName}({model.SourceType} {sourceClassParameterName}{readOnlyPropertiesArguments}){baseConstructor}")
|
.WriteLine($"public {model.TypeIdentifierName}({model.SourceType} {sourceClassParameterName}{readOnlyPropertiesArguments}){baseConstructor}")
|
||||||
.WriteOpeningBracket()
|
.WriteOpeningBracket()
|
||||||
.TryWriteProperties(model.SourceProperties, readOnlyProperties, sourceClassParameterName, mappingContextParameterName, false);
|
.TryWriteProperties(model.SourceProperties, model.TypeProperties, sourceClassParameterName, mappingContextParameterName, false);
|
||||||
|
|
||||||
// End constructor declaration
|
// End constructor declaration
|
||||||
return builder.WriteClosingBracket();
|
return builder.WriteClosingBracket();
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace MapTo.Sources
|
||||||
{
|
{
|
||||||
builder
|
builder
|
||||||
.WriteLine("/// <summary>")
|
.WriteLine("/// <summary>")
|
||||||
.WriteLine("/// Specifies that the annotated class can be mapped from the provided <see cref=\"SourceType\"/>.")
|
.WriteLine("/// Specifies that the annotated class can be updatable.")
|
||||||
.WriteLine("/// </summary>");
|
.WriteLine("/// </summary>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue