Reputation: 11
I'm working on Roslyn plugin to Visual Studio. I am trying to subscribe to an event that would be raised after a file is renamed. I am using Workspace.WorkspaceChanged but it doesn't raise DocumentRemoved.
This is the way how I get a workspace:
var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
_myWorkspace = componentModel.GetService<VisualStudioWorkspace>();
Upvotes: 1
Views: 107
Reputation: 140
It has been a couple of years i did something with this. I once wrote a VS plugin that searched through files in a solution. It worked with rename as well if i remember(unfortunate i can't check because it was for VS 2015). I did it with DTE events back than. I created an DteEventHandler and added to the DocumentEvents.DocumentSaved my function.
dte = Package.GetGlobalService(typeof(DTE)) as DTE2;
events = dte.Events;
docEv = events.DocumentEvents;
docEv.DocumentSaved += ScanDocumentForFunction;
The other way is probably to go through the solution file. The solutionfile contains all csproj files and you can get all files from there.
dte = FillIndexListCommandPackage.GetGlobalService(typeof(DTE)) as DTE2;
var solutionnamearr = dte.Solution.FullName.Split('\\');
...
if you use git it would probably the easiest way to just call a git status in a command windows and pipe the result through to your plugin logic.
i hope i was some help or pointed you at least in the right direction.
Upvotes: 2