File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -58,19 +58,24 @@ public static bool TryGetOperatorSymbol(this ISymbol symbol, out string operator
5858 {
5959 var methodName = symbol . GetName ( useMetadataName : false ) ;
6060
61+ // Most common use-case.
6162 if ( methodToOperator . TryGetValue ( methodName , out operatorName ! ) )
6263 return true ;
6364
64- var match = CheckedRegex ( ) . Match ( methodName ) ;
65- if ( match . Success && methodToOperator . TryGetValue ( $ "op_{ match . Groups [ 1 ] } ", out var uncheckedName ) )
65+ // Attempt to parse using a regexp.
66+ var match = OperatorRegex ( ) . Match ( methodName ) ;
67+ if ( match . Success && methodToOperator . TryGetValue ( $ "op_{ match . Groups [ 2 ] } ", out var rawOperatorName ) )
6668 {
67- operatorName = $ "checked { uncheckedName } ";
69+ var prefix = match . Groups [ 1 ] . Success ? "checked " : "" ;
70+ var postfix = match . Groups [ 3 ] . Success ? "=" : "" ;
71+ operatorName = $ "{ prefix } { rawOperatorName } { postfix } ";
6872 return true ;
6973 }
74+
7075 return false ;
7176 }
7277
73- [ GeneratedRegex ( "^op_Checked(.*) $" ) ]
74- private static partial Regex CheckedRegex ( ) ;
78+ [ GeneratedRegex ( "^op_(Checked)?(.*?)(Assignment)? $" ) ]
79+ private static partial Regex OperatorRegex ( ) ;
7580 }
7681}
You can’t perform that action at this time.
0 commit comments