Reputation: 2197
Via Roslyn, C# syntax ,I have IMethodSymbol to clarify my method information,
var symbolMethod = context.SemanticModel.GetSymbolInfo(invocation).Symbol as IMethodSymbol;
if (symbolMethod == null) return;
//-- Here I need to get other signature of the symbolMethod
Notation: the container class maybe has partial class which includes some signature of this method
Upvotes: 5
Views: 1327
Reputation: 2197
var symbolMethod = context.SemanticModel.GetSymbolInfo(invocation).Symbol as IMethodSymbol;
//has several signatures
if (symbolMethod.ContainingType.GetMembers().Count(it => it.Name == symbolMethod.Name) > 1)
Upvotes: 1
Reputation: 13835
You could look into SemtanticModel.GetMemberGroup
:
var overloads = model.GetMemberGroup(invocation.Expression);
It returns a list of overloads of the method
Upvotes: 3
Reputation: 19031
Just do symbolMethod.ContainingType, and from there you can call GetMembers to get all members of the type. You can filter by name or whatever you're looking to get from there.
Upvotes: 4