From 808f353cac02f8f088839a701549fd545d8af646 Mon Sep 17 00:00:00 2001 From: Wvader <34067397+wvader@users.noreply.github.com> Date: Tue, 7 Dec 2021 11:46:45 +0000 Subject: [PATCH] Try enforce struct usage --- src/MapTo/MapToGenerator.cs | 2 +- src/MapTo/Sources/MapClassSource.cs | 2 +- src/MapTo/Sources/MapStructSource.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MapTo/MapToGenerator.cs b/src/MapTo/MapToGenerator.cs index d9a7742..d740394 100644 --- a/src/MapTo/MapToGenerator.cs +++ b/src/MapTo/MapToGenerator.cs @@ -62,7 +62,7 @@ namespace MapTo var (source, hintName) = typeDeclarationSyntax switch { StructDeclarationSyntax => MapStructSource.Generate(mappingContext.Model), - ClassDeclarationSyntax => MapStructSource.Generate(mappingContext.Model), + ClassDeclarationSyntax => MapClassSource.Generate(mappingContext.Model), RecordDeclarationSyntax => MapRecordSource.Generate(mappingContext.Model), _ => throw new ArgumentOutOfRangeException() }; diff --git a/src/MapTo/Sources/MapClassSource.cs b/src/MapTo/Sources/MapClassSource.cs index 21c94de..23f61f5 100644 --- a/src/MapTo/Sources/MapClassSource.cs +++ b/src/MapTo/Sources/MapClassSource.cs @@ -75,7 +75,7 @@ namespace MapTo.Sources var baseConstructor = model.HasMappedBaseClass ? $" : base({mappingContextParameterName}, {sourceClassParameterName})" : string.Empty; builder - .WriteLine($"private protected {model.TypeIdentifierName}({MappingContextSource.ClassName} {mappingContextParameterName}, {model.SourceType} {sourceClassParameterName}){baseConstructor}") + .WriteLine($"public {model.TypeIdentifierName}({MappingContextSource.ClassName} {mappingContextParameterName}, {model.SourceType} {sourceClassParameterName}){baseConstructor}") .WriteOpeningBracket() .WriteLine($"if ({mappingContextParameterName} == null) throw new ArgumentNullException(nameof({mappingContextParameterName}));") .WriteLine($"if ({sourceClassParameterName} == null) throw new ArgumentNullException(nameof({sourceClassParameterName}));") diff --git a/src/MapTo/Sources/MapStructSource.cs b/src/MapTo/Sources/MapStructSource.cs index fdf1acc..12be73a 100644 --- a/src/MapTo/Sources/MapStructSource.cs +++ b/src/MapTo/Sources/MapStructSource.cs @@ -63,7 +63,7 @@ namespace MapTo.Sources var baseConstructor = model.HasMappedBaseClass ? $" : base({mappingContextParameterName}, {sourceClassParameterName})" : string.Empty; builder - .WriteLine($"private protected {model.TypeIdentifierName}({MappingContextSource.ClassName} {mappingContextParameterName}, {model.SourceType} {sourceClassParameterName}){baseConstructor}") + .WriteLine($"public {model.TypeIdentifierName}({MappingContextSource.ClassName} {mappingContextParameterName}, {model.SourceType} {sourceClassParameterName}){baseConstructor}") .WriteOpeningBracket() .WriteLine() .WriteLine($"{mappingContextParameterName}.{MappingContextSource.RegisterMethodName}({sourceClassParameterName}, this);")