1+ using System ;
12using System . Linq ;
23using ICSharpCode . CodeConverter . Util . FromRoslyn ;
34using Microsoft . CodeAnalysis ;
@@ -6,19 +7,22 @@ namespace ICSharpCode.CodeConverter.Util
67{
78 internal static class IMethodSymbolExtensions
89 {
9- public static string GetParameterSignature ( this IMethodSymbol methodSymbol )
10- {
11- return string . Join ( " " , methodSymbol . Parameters . Select ( p => p . Type ) ) ;
12- }
10+ public static string GetParameterSignature ( this IMethodSymbol methodSymbol ) => string . Join ( " " , methodSymbol . Parameters . Select ( p => p . Type ) ) ;
11+ public static string GetParameterSignature ( this IPropertySymbol propertySymbol ) => string . Join ( " " , propertySymbol . Parameters . Select ( p => p . Type ) ) ;
1312
14- public static ( string Name , int TypeParameterCount , string ParameterTypes ) GetUnqualifiedMethodSignature ( this IMethodSymbol methodSymbol , bool caseSensitiveName )
15- {
16- return ( caseSensitiveName ? methodSymbol . Name : methodSymbol . Name . ToLowerInvariant ( ) , methodSymbol . TypeParameters . Length , GetParameterSignature ( methodSymbol ) ) ;
17- }
13+ public static ( string Name , int TypeParameterCount , string ParameterTypes ) GetUnqualifiedMethodOrPropertySignature ( this ISymbol s , bool caseSensitiveName ) => s switch {
14+ IMethodSymbol m => m . GetUnqualifiedMethodSignature ( caseSensitiveName ) ,
15+ IPropertySymbol p => p . GetUnqualifiedPropertySignature ( caseSensitiveName ) ,
16+ _ => throw new ArgumentOutOfRangeException ( nameof ( s ) , s , $ "Symbol must be property or method, but was { s . Kind } ")
17+ } ;
1818
19- public static bool ReturnsVoidOrAsyncTask ( this IMethodSymbol enclosingMethodInfo )
20- {
21- return enclosingMethodInfo . ReturnsVoid || enclosingMethodInfo . IsAsync && enclosingMethodInfo . ReturnType . GetArity ( ) == 0 ;
22- }
19+ public static ( string Name , int TypeParameterCount , string ParameterTypes ) GetUnqualifiedMethodSignature ( this IMethodSymbol methodSymbol , bool caseSensitiveName ) =>
20+ ( caseSensitiveName ? methodSymbol . Name : methodSymbol . Name . ToLowerInvariant ( ) , methodSymbol . TypeParameters . Length , GetParameterSignature ( methodSymbol ) ) ;
21+
22+ public static ( string Name , int TypeParameterCount , string ParameterTypes ) GetUnqualifiedPropertySignature ( this IPropertySymbol propertySymbol , bool caseSensitiveName ) =>
23+ ( caseSensitiveName ? propertySymbol . Name : propertySymbol . Name . ToLowerInvariant ( ) , 0 , GetParameterSignature ( propertySymbol ) ) ;
24+
25+ public static bool ReturnsVoidOrAsyncTask ( this IMethodSymbol enclosingMethodInfo ) =>
26+ enclosingMethodInfo . ReturnsVoid || enclosingMethodInfo . IsAsync && enclosingMethodInfo . ReturnType . GetArity ( ) == 0 ;
2327 }
2428}
0 commit comments