ReSharper SDK - Get currently selected class name.

When creating a new action in the SDK.

How do I enable it only when the cursor is on a class name in C#, and also get the name of that class?

I know it's something like IContextActionDataProvider.GetSelectedElement<T>() but I don't know what the T should be?

2 comments
Comment actions Permalink

You can take a look at what the "Create derived type" context action does (this also only appears when the cursor is on a class declaration name) - check out CreateDerivedTypeAction in dotPeek. It uses GetSelectedElement<ICSharpIdentifier> (you could probably use IIdentifier if you want to work in other files). It then uses ClassLikeDeclarationNavigator.GetNameByIdentifier(identifier) to try and get the class declaration.

0
Comment actions Permalink

oh wow, using dotPeek on the SDK is awesome.

Now I can dig in and see how things work. Thanks. :)

0

Please sign in to leave a comment.