Question

I want to make a visual studio's add in that has the ability to sort resource files alphabetically every time someone edits a resource file. I'm not looking for a solution, but I have never used the Visual Studio sdk before. I simple want to know if anyone that has experience with the Visual Studio sdk may know if this is possible? Also any suggestions on how to start making an addin are appreciated.

Was it helpful?

Solution

If you have never used visual studio extensibility, I recommend you this page: Make a solution notebook tool window

There is some useful information about how to interact with visual studio for saving data in sln and suo files, and also you can find information about some attributes you can use to tell visual studio what your package (or plugin) needs to do. It's a general knowledge thing although, not directly related to what you want to do.

this link is about how to listen to some specific events visual studio fires, it shows you general way of creating listeners in your plugin

this one is actually about what you need to do (it tells you how to catch the event fired before visual studio saves a file)

and the most important one: the source code for creating a custom source control for visual studio, that's where I found most of the info I needed to understand visual studio extensibility

with all these links you should get something to start with, and of course you have the official msdn documentation about extending visual studio

What you'll need to do is creating a plugin that will listen to events fired when an item is about to be saved in visual studio. I don't think there is a specific event for resx files, so you'll probably have to test which file is saved, but that should be all. Once you have the item, you can find the physical file and sort it.

Another thing, I found out that the events declared in the DTE object don't really work (at least for me it didn't), that's why I recommend you to implement the listener pattern to catch the events you need.

Hope this helps

OTHER TIPS

I actually did exactly that.

You can find the source code for the extension in GitHub. It shows you how the get handles for files from the Solution Explorer, add context menu actions, write to the output menu, etc..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top