@@ -11,7 +11,6 @@ namespace SqlMarshal;
11
11
using System . Text ;
12
12
using Microsoft . CodeAnalysis ;
13
13
using Microsoft . CodeAnalysis . CSharp ;
14
- using Microsoft . CodeAnalysis . CSharp . Syntax ;
15
14
using Microsoft . CodeAnalysis . Text ;
16
15
using static Microsoft . CodeAnalysis . CSharp . SyntaxFactory ;
17
16
using static SqlMarshal . Extensions ;
@@ -101,6 +100,15 @@ internal static IEnumerable<string> GetUsings(ClassGenerationContext classGenera
101
100
}
102
101
}
103
102
103
+ /// <summary>
104
+ /// Gets code for parameter declaration.
105
+ /// </summary>
106
+ /// <param name="methodSymbol">Method symbol from which we copy parameter.</param>
107
+ /// <param name="parameter">Parameter to copy.</param>
108
+ /// <param name="index">Index of parameter to copy.</param>
109
+ /// <returns>Generated syntax node for the parameter.</returns>
110
+ protected abstract SyntaxNode GetParameterDeclaration ( IMethodSymbol methodSymbol , IParameterSymbol parameter , int index ) ;
111
+
104
112
private static string GetAccessibility ( Accessibility a )
105
113
{
106
114
return a switch
@@ -138,26 +146,6 @@ private static string GetAccessibility(Accessibility a)
138
146
return null ;
139
147
}
140
148
141
- private static string GetParameterDeclaration ( IMethodSymbol methodSymbol , IParameterSymbol parameter , int index )
142
- {
143
- if ( parameter . RefKind == RefKind . Out )
144
- {
145
- return $ "out { parameter . Type . ToDisplayString ( ) } { parameter . Name } ";
146
- }
147
-
148
- if ( parameter . RefKind == RefKind . Ref )
149
- {
150
- return $ "ref { parameter . Type . ToDisplayString ( ) } { parameter . Name } ";
151
- }
152
-
153
- if ( methodSymbol . IsExtensionMethod && index == 0 )
154
- {
155
- return $ "this { parameter . Type . ToDisplayString ( ) } { parameter . Name } ";
156
- }
157
-
158
- return $ "{ parameter . Type . ToDisplayString ( ) } { parameter . Name } ";
159
- }
160
-
161
149
private static string GetParameterPassing ( IParameterSymbol parameter )
162
150
{
163
151
var parameterName = NameMapper . MapName ( parameter . Name ) ;
@@ -929,7 +917,7 @@ private void ProcessMethod(
929
917
var originalParameters = methodSymbol . Parameters ;
930
918
931
919
bool hasCustomSql = methodGenerationContext . CustomSqlParameter != null ;
932
- var signature = $ "({ string . Join ( ", " , originalParameters . Select ( ( parameterSymbol , index ) => GetParameterDeclaration ( methodSymbol , parameterSymbol , index ) ) ) } )";
920
+ var signature = $ "({ string . Join ( ", " , originalParameters . Select ( ( parameterSymbol , index ) => this . GetParameterDeclaration ( methodSymbol , parameterSymbol , index ) ) ) } )";
933
921
var itemType = methodGenerationContext . ItemType ;
934
922
var getConnection = this . GetConnectionStatement ( methodGenerationContext ) ;
935
923
var isList = methodGenerationContext . IsList || methodGenerationContext . IsEnumerable ;
0 commit comments