@@ -2084,36 +2084,29 @@ bool PreserveConvertNode(Expression expression)
20842084 return value ;
20852085 }
20862086
2087- if ( tempParameterName is null )
2087+ parameterName = string . IsNullOrWhiteSpace ( tempParameterName ) ? "p" : tempParameterName ;
2088+
2089+ // The VB compiler prefixes closure member names with $VB$Local_, remove that (#33150)
2090+ if ( parameterName . StartsWith ( "$VB$Local_" , StringComparison . Ordinal ) )
20882091 {
2089- parameterName = "p" ;
2092+ parameterName = parameterName [ "$VB$Local_" . Length .. ] ;
20902093 }
2091- else
2092- {
2093- parameterName = tempParameterName ;
20942094
2095- // The VB compiler prefixes closure member names with $VB$Local_, remove that (#33150)
2096- if ( parameterName . StartsWith ( "$VB$Local_" , StringComparison . Ordinal ) )
2097- {
2098- parameterName = parameterName [ "$VB$Local_" . Length ..] ;
2099- }
2100-
2101- // In many databases, parameter names must start with a letter or underscore.
2102- // The same is true for C# variable names, from which we derive the parameter name, so in principle we shouldn't see an issue;
2103- // but just in case, prepend an underscore if the parameter name doesn't start with a letter or underscore.
2104- if ( ! char . IsLetter ( parameterName [ 0 ] ) && parameterName [ 0 ] != '_' )
2105- {
2106- parameterName = "_" + parameterName ;
2107- }
2095+ // In many databases, parameter names must start with a letter or underscore.
2096+ // The same is true for C# variable names, from which we derive the parameter name, so in principle we shouldn't see an issue;
2097+ // but just in case, prepend an underscore if the parameter name doesn't start with a letter or underscore.
2098+ if ( parameterName . Length > 0 && ! char . IsLetter ( parameterName [ 0 ] ) && parameterName [ 0 ] != '_' )
2099+ {
2100+ parameterName = "_" + parameterName ;
2101+ }
21082102
2109- // Just as a safety guard, if there's any problematic character in the name for any reason, fall back to "p".
2110- foreach ( var c in parameterName )
2103+ // Just as a safety guard, if there's any problematic character in the name for any reason, fall back to "p".
2104+ foreach ( var c in parameterName )
2105+ {
2106+ if ( ! char . IsLetterOrDigit ( c ) && c != '_' )
21112107 {
2112- if ( ! char . IsLetterOrDigit ( c ) && c != '_' )
2113- {
2114- parameterName = "p" ;
2115- break ;
2116- }
2108+ parameterName = "p" ;
2109+ break ;
21172110 }
21182111 }
21192112
0 commit comments