@@ -94,7 +94,7 @@ private void BuildProjectAsMethod(INamedTypeSymbol mapperSymbol, MappingPlan pla
9494 var sourceTypeName = plan . SourceType . ToDisplayString ( ) ;
9595 var destTypeName = plan . DestinationType . ToDisplayString ( ) ;
9696 BuildXmlDoc ( mapperSymbol , "Project" ) ;
97- Indent ( ) ; _sb . AppendLine ( $ "public override { destTypeName } Project ({ sourceTypeName } source)") ;
97+ Indent ( ) ; _sb . AppendLine ( $ "public override { destTypeName } ProjectGenerated ({ sourceTypeName } source)") ;
9898 Indent ( ) ; _sb . AppendLine ( "{" ) ;
9999 _indentationLevel ++ ;
100100 GenerateNullCheck ( "source" , destTypeName ) ;
@@ -109,7 +109,7 @@ private void BuildBuildMethod(INamedTypeSymbol mapperSymbol, MappingPlan plan)
109109 var sourceTypeName = plan . SourceType . ToDisplayString ( ) ;
110110 var destTypeName = plan . DestinationType . ToDisplayString ( ) ;
111111 BuildXmlDoc ( mapperSymbol , "Build" ) ;
112- Indent ( ) ; _sb . AppendLine ( $ "public override { destTypeName } Build ({ sourceTypeName } source)") ;
112+ Indent ( ) ; _sb . AppendLine ( $ "public override { destTypeName } BuildGenerated ({ sourceTypeName } source)") ;
113113 Indent ( ) ; _sb . AppendLine ( "{" ) ;
114114 _indentationLevel ++ ;
115115 GenerateNullCheck ( "source" , destTypeName ) ;
@@ -122,39 +122,34 @@ private void BuildBuildMethod(INamedTypeSymbol mapperSymbol, MappingPlan plan)
122122 private void GenerateCreationBlock ( string variableName , ITypeSymbol variableType , MappingPlan plan , string sourceVarName , bool isBuild = false )
123123 {
124124 Indent ( ) ;
125- if ( isBuild ) _sb . AppendLine ( "return BuildRefiner(" ) ;
126- else _sb . AppendLine ( "return ProjectAsRefiner(" ) ;
127- _indentationLevel ++ ;
128- Indent ( ) ;
129125
130126 switch ( plan . Creation . Method )
131127 {
132128 case CreationMethod . ConstructorWithParameters :
133129 var constructorArgs = GetMethodArguments ( plan . Creation . Constructor , plan . Creation , sourceVarName ) ;
134- _sb . AppendLine ( $ "new { variableType . ToDisplayString ( ) } ({ constructorArgs } )") ;
130+ _sb . AppendLine ( $ "return new { variableType . ToDisplayString ( ) } ({ constructorArgs } ); ") ;
135131 break ;
136132 case CreationMethod . FactoryMethod :
137133 var factoryArgs = GetMethodArguments ( plan . Creation . FactoryMethod , plan . Creation , sourceVarName ) ;
138- _sb . AppendLine ( $ "{ variableType . ToDisplayString ( ) } .{ plan . Creation . FactoryMethod . Name } ({ factoryArgs } )") ;
134+ _sb . AppendLine ( $ "return { variableType . ToDisplayString ( ) } .{ plan . Creation . FactoryMethod . Name } ({ factoryArgs } ); ") ;
139135 break ;
140136 case CreationMethod . ParameterlessConstructor :
141- _sb . AppendLine ( $ "new { variableType . ToDisplayString ( ) } ") ;
137+ _sb . AppendLine ( $ "return new { variableType . ToDisplayString ( ) } ") ;
142138 Indent ( ) ; _sb . AppendLine ( "{" ) ;
143139 _indentationLevel ++ ;
144140 GenerateMappingInstructions ( sourceVarName , null , plan ) ;
145141 _indentationLevel -- ;
146- Indent ( ) ; _sb . AppendLine ( "}" ) ;
142+ Indent ( ) ; _sb . AppendLine ( "}; " ) ;
147143 break ;
148144 default :
149145 if ( isBuild )
150146 {
151- _sb . AppendLine ( $ "BuildFactoryFallback({ variableName } )") ;
147+ _sb . AppendLine ( $ "var fallback = BuildFactoryFallback({ sourceVarName } );") ;
148+ _sb . AppendLine ( "if (fallback != null) return fallback;" ) ;
152149 }
153- _sb . AppendLine ( $ "new { variableType . ToDisplayString ( ) } ()") ;
150+ _sb . AppendLine ( $ "return new { variableType . ToDisplayString ( ) } (); ") ;
154151 break ;
155152 }
156- Indent ( ) ; _sb . Append ( $ ", { sourceVarName } );") ;
157- _indentationLevel -- ;
158153 _sb . AppendLine ( ) ;
159154
160155 }
0 commit comments