0

I'm building a Visual Studio extension and I need to get notification when a project is renamed.

Tried using DTE2.Events2.SolutionEvents and also tried IVsSolutionEvents.

Both of them work fine for C#, VB.NET, and F# projects, but not for C++ projects.

Is there another way to handle project rename events? Or something specific for C++ projects?

Thanks.

omsharp
  • 300
  • 1
  • 13

1 Answers1

1

Have you taken a look at the IVsSolutionEvents4 interface and its OnAfterRenameProject method?

For an implementation you can take a look at my DulcisX framework.

Twenty
  • 5,234
  • 4
  • 32
  • 67
  • I tried using IVsSolutionEvents4. for some reason it works only for C#, VB, and F#. But it won'r work for C++ projects. The event won't fire for C++ projects. – omsharp Jun 26 '20 at 18:00
  • Tbf I have never actually tried it with C++ projects. The big problem here is that all "Project Types" have there own implementation. The only other thing I could think of would be the [`IVsRunningDocTableEvents3`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.shell.interop.ivsrunningdoctableevents3?view=visualstudiosdk-2017) and there `OnAfterAttributeChange` methods. You will also need to call the `IVsRunningDocumentTable.AdviseRunningDocTableEvents` method with the class inheriting the before mentioned interface. – Twenty Jun 26 '20 at 20:22
  • @omsharp if the `grfAttribs` parameter is equal to `4` and `pszMkDocumentOld != pszMkDocumentNew` something got renamed. The RDT should keep track of all sorts of editable files in a solution. An implementation can be found [here](https://github.com/TwentyFourMinutes/DulcisX/blob/master/src/DulcisX/DulcisX/Hierarchy/Events/OpenNodeEvents.cs#L124). – Twenty Jun 26 '20 at 20:27
  • But that's for documents (files), not projects! – omsharp Jun 28 '20 at 01:21
  • @omsharp It still triggers for Projects/Solutions at least for C# ones. – Twenty Jun 28 '20 at 14:01