diff --git a/src/MapTo/MappingContext.cs b/src/MapTo/MappingContext.cs
index 37c3a80..07e883e 100644
--- a/src/MapTo/MappingContext.cs
+++ b/src/MapTo/MappingContext.cs
@@ -60,8 +60,8 @@ namespace MapTo
{
MappingContext context = typeSyntax switch
{
- ClassDeclarationSyntax => new ClassMappingContext(compilation, sourceGenerationOptions, typeSyntax),
StructDeclarationSyntax => new StructMappingContext(compilation, sourceGenerationOptions, typeSyntax),
+ ClassDeclarationSyntax => new ClassMappingContext(compilation, sourceGenerationOptions, typeSyntax),
RecordDeclarationSyntax => new RecordMappingContext(compilation, sourceGenerationOptions, typeSyntax),
_ => throw new ArgumentOutOfRangeException()
};
diff --git a/src/MapTo/Sources/MapStructSource.cs b/src/MapTo/Sources/MapStructSource.cs
index 6177468..fdf1acc 100644
--- a/src/MapTo/Sources/MapStructSource.cs
+++ b/src/MapTo/Sources/MapStructSource.cs
@@ -18,17 +18,11 @@ namespace MapTo.Sources
.WriteOpeningBracket()
// Class declaration
- .WriteLine($"partial class {model.TypeIdentifierName}")
+ .WriteLine($"partial struct {model.TypeIdentifierName}")
.WriteOpeningBracket();
// Class body
- if (model.GenerateSecondaryConstructor)
- {
- builder
- .GenerateSecondaryConstructor(model)
- .WriteLine();
- }
-
+
builder
.GeneratePrivateConstructor(model)
.WriteLine()
@@ -50,7 +44,7 @@ namespace MapTo.Sources
{
builder
.WriteLine("/// ")
- .WriteLine($"/// Initializes a new instance of the class")
+ .WriteLine($"/// Initializes a new instance of the struct")
.WriteLine($"/// using the property values from the specified .")
.WriteLine("/// ")
.WriteLine($"/// {sourceClassParameterName} is null");
@@ -115,22 +109,7 @@ namespace MapTo.Sources
}
-
- private static SourceBuilder GenerateConvertorMethodsXmlDocs(this SourceBuilder builder, MappingModel model, string sourceClassParameterName)
- {
- if (!model.Options.GenerateXmlDocument)
- {
- return builder;
- }
-
- return builder
- .WriteLine("/// ")
- .WriteLine($"/// Creates a new instance of and sets its participating properties")
- .WriteLine($"/// using the property values from .")
- .WriteLine("/// ")
- .WriteLine($"/// The instance of to use as source.")
- .WriteLine($"/// A new instance of -or- null if is null.");
- }
+
private static SourceBuilder GenerateUpdaterMethodsXmlDocs(this SourceBuilder builder, MappingModel model, string sourceClassParameterName)
{
@@ -147,26 +126,5 @@ namespace MapTo.Sources
.WriteLine($"/// The instance of to use as source.");
}
- private static SourceBuilder GenerateSourceTypeExtensionClass(this SourceBuilder builder, MappingModel model)
- {
- return builder
- .WriteLine($"{model.Options.GeneratedMethodsAccessModifier.ToLowercaseString()} static partial class {model.SourceTypeIdentifierName}To{model.TypeIdentifierName}Extensions")
- .WriteOpeningBracket()
- .GenerateSourceTypeExtensionMethod(model)
- .WriteClosingBracket();
- }
-
- private static SourceBuilder GenerateSourceTypeExtensionMethod(this SourceBuilder builder, MappingModel model)
- {
- var sourceClassParameterName = model.SourceTypeIdentifierName.ToCamelCase();
-
- return builder
- .GenerateConvertorMethodsXmlDocs(model, sourceClassParameterName)
- .WriteLineIf(model.Options.SupportNullableStaticAnalysis, $"[return: NotNullIfNotNull(\"{sourceClassParameterName}\")]")
- .WriteLine($"{model.Options.GeneratedMethodsAccessModifier.ToLowercaseString()} static {model.TypeIdentifierName}{model.Options.NullableReferenceSyntax} To{model.TypeIdentifierName}(this {model.SourceType}{model.Options.NullableReferenceSyntax} {sourceClassParameterName})")
- .WriteOpeningBracket()
- .WriteLine($"return {sourceClassParameterName} == null ? null : new {model.TypeIdentifierName}({sourceClassParameterName});")
- .WriteClosingBracket();
- }
}
}
\ No newline at end of file