itihonov
itihonov

Reputation: 81

Get all extension methods for type by use roslyn api

I want get all extensions methods for type. For example for type string if I am use semanticmodel method lookupsymbols.

var sourceText = @"string a = "";
a."
var tree= CSharpSyntaxTree.ParseText(sourceTextx...);
....
var members = semanticModel.LookupSymbols(source.IndexOf("a."), someType, includeReducedExtensionMethods: true);
//this return all members with extension methods for type string someExtMethod(this string text)....


//I want get all extension with methods where first param might be one of them 
var interfaces = someType.AllInerfaces;
//for example IEnumerable<out T>, methods like: Select, Where, Aggregate...

Upvotes: 3

Views: 440

Answers (1)

SLaks
SLaks

Reputation: 888077

Call SemanticModel.LookupSymbols to get all valid symbols off of a container.

This is how IntelliSense works.

Upvotes: 2

Related Questions