diff --git a/src/MapTo/MapTo.csproj b/src/MapTo/MapTo.csproj index 21d8219..abf010e 100644 --- a/src/MapTo/MapTo.csproj +++ b/src/MapTo/MapTo.csproj @@ -18,6 +18,8 @@ https://github.com/mrtaikandi/mapto snupkg MapTo + 1.1 + 1.1 @@ -44,8 +46,4 @@ - - - - diff --git a/src/MapTo/Sources/MapFromAttributeSource.cs b/src/MapTo/Sources/MapFromAttributeSource.cs index fc3f52b..6594832 100644 --- a/src/MapTo/Sources/MapFromAttributeSource.cs +++ b/src/MapTo/Sources/MapFromAttributeSource.cs @@ -26,7 +26,7 @@ namespace MapTo.Sources } builder - .WriteLine("[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]") + .WriteLine("[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]") .WriteLine($"public sealed class {AttributeName}Attribute : Attribute") .WriteOpeningBracket(); diff --git a/src/MapTo/Sources/MapStructSource.cs b/src/MapTo/Sources/MapStructSource.cs index 6177468..a7fdecd 100644 --- a/src/MapTo/Sources/MapStructSource.cs +++ b/src/MapTo/Sources/MapStructSource.cs @@ -147,26 +147,7 @@ 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