WSK
WSK

Reputation: 6138

Does Roslyn provides simple way to find compatible method in ClassDeclarationSyntax?

I need to find a compatible method, if exists, in a class code. Is there some simpler way in Roslyn to do that otherwise I have to compare method names, number and types of arguments. It wouldn't be a big deal if we would not have to deal with arguments' non-fully qualified types and inheritance.

Upvotes: 0

Views: 103

Answers (1)

Jason Malinowski
Jason Malinowski

Reputation: 18976

Roslyn provides all the pieces you need. You might want to look at the SymbolEquivalenceComparer that lives in the Roslyn codebase (but it's not public) for inspiration on how to do the comparison. You'll have to do the comparison checks yourself, but that should be a whopping 20 lines of code or so if you do it right.

As an important note, make sure you're working with the semantic model of Roslyn versus just syntax. You mentioned non-qualified types -- as long as you're working with semantics syntax differences like that are taken care of for you.

Upvotes: 1

Related Questions