Extension method information from Roslyn -


i trying using roslyn extract various method call information give source file. elaborate - want find method invocations happen inside input file.

one problem hitting extension methods. consider linq method aggregate, sum etc. how can figure out invocationexpressionsyntax method being invoked extension method , not simple member method of class.

the source file input can expected compile - meaning getdiagnostics() not have errors.

---- code property mentioned @kevin in answer ----

var methodinfo = model.getsymbolinfo(invocation); if (methodinfo.symbol != null) {     var msymbol = (imethodsymbol)methodinfo.symbol;     if (msymbol.reducedfrom != null)     {         // extension method !     } } 

you can find actual static extension method instance invocation of extension method using imethodsymbol.reducedfrom property.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -