@@ -68,28 +68,31 @@ internal SolutionEvents()
6868 /// <summary>Notifies listening clients that a project has been renamed.</summary>
6969 public event Action < Project ? > ? OnAfterRenameProject ;
7070
71- #if ! VS14
7271 /// <summary>Notifies listening clients that the folder is being closed.</summary>
7372 public event Action < string > ? OnBeforeCloseFolder ;
74-
73+ #if ! VS14
7574 /// <summary>Notifies listening clients that the folder has been closed.</summary>
7675 public event Action < string > ? OnAfterCloseFolder ;
77-
76+ #endif
7877 /// <summary>Notifies listening clients that the folder has been opened.</summary>
7978 public event Action < string > ? OnAfterOpenFolder ;
80- #endif
8179
8280 /// <summary> Fired when the solution load process is fully complete, including all background loading of projects.</summary>
8381 public event Action ? OnAfterBackgroundSolutionLoadComplete ;
8482
85- #region IVsSolutionEvents
83+ #region IVsSolutionEvents
8684 int IVsSolutionEvents . OnAfterOpenProject ( IVsHierarchy pHierarchy , int fAdded )
8785 {
8886 ThreadHelper . ThrowIfNotOnUIThread ( ) ;
8987 if ( OnAfterOpenProject != null )
9088 {
91- Project ? project = SolutionItem . FromHierarchy ( pHierarchy , VSConstants . VSITEMID_ROOT ) as Project ;
92- OnAfterOpenProject ? . Invoke ( project ) ;
89+ SolutionItem ? item = SolutionItem . FromHierarchy ( pHierarchy , VSConstants . VSITEMID_ROOT ) as Project ;
90+ if ( item is Project project )
91+ OnAfterOpenProject ? . Invoke ( project ) ;
92+ #if VS14
93+ else if ( item is SolutionFolder folder && folder. FullPath != null )
94+ OnAfterOpenFolder ? . Invoke ( folder . FullPath ) ;
95+ #endif
9396 }
9497 return VSConstants . S_OK ;
9598 }
@@ -107,6 +110,10 @@ int IVsSolutionEvents.OnBeforeCloseProject(IVsHierarchy pHierarchy, int fRemoved
107110 SolutionItem ? item = SolutionItem . FromHierarchy ( pHierarchy , VSConstants . VSITEMID_ROOT ) ;
108111 if ( item is Project project )
109112 OnBeforeCloseProject ? . Invoke ( project ) ;
113+ #if VS14
114+ else if ( item is SolutionFolder folder && folder. FullPath != null )
115+ OnBeforeCloseFolder ? . Invoke ( folder . FullPath ) ;
116+ #endif
110117 }
111118 return VSConstants . S_OK ;
112119 }
@@ -176,9 +183,9 @@ int IVsSolutionEvents.OnAfterCloseSolution(object pUnkReserved)
176183 OnAfterCloseSolution ? . Invoke ( ) ;
177184 return VSConstants . S_OK ;
178185 }
179- #endregion
186+ #endregion
180187
181- #region IVsSolutionEvents2
188+ #region IVsSolutionEvents2
182189 int IVsSolutionEvents2 . OnAfterOpenProject ( IVsHierarchy pHierarchy , int fAdded )
183190 {
184191 ThreadHelper . ThrowIfNotOnUIThread ( ) ;
@@ -244,9 +251,9 @@ int IVsSolutionEvents2.OnAfterMergeSolution(object pUnkReserved)
244251 OnAfterMergeSolution ? . Invoke ( ) ;
245252 return VSConstants . S_OK ;
246253 }
247- #endregion
254+ #endregion
248255
249- #region IVsSolutionEvents4
256+ #region IVsSolutionEvents4
250257 int IVsSolutionEvents4 . OnAfterRenameProject ( IVsHierarchy pHierarchy )
251258 {
252259 ThreadHelper . ThrowIfNotOnUIThread ( ) ;
@@ -274,16 +281,16 @@ int IVsSolutionEvents4.OnAfterAsynchOpenProject(IVsHierarchy pHierarchy, int fAd
274281 {
275282 return VSConstants . S_OK ;
276283 }
277- #endregion
284+ #endregion
278285
279- #region IVsSolutionEvents5
286+ #region IVsSolutionEvents5
280287 void IVsSolutionEvents5 . OnBeforeOpenProject ( ref Guid guidProjectID , ref Guid guidProjectType , string pszFileName )
281288 {
282289 OnBeforeOpenProject ? . Invoke ( pszFileName ) ;
283290 }
284- #endregion
291+ #endregion
285292
286- #region IVsSolutionEvents7
293+ #region IVsSolutionEvents7
287294#if ! VS14
288295 void IVsSolutionEvents7 . OnAfterOpenFolder ( string folderPath )
289296 {
@@ -306,9 +313,9 @@ void IVsSolutionEvents7.OnAfterCloseFolder(string folderPath)
306313 void IVsSolutionEvents7 . OnAfterLoadAllDeferredProjects ( )
307314 { }
308315#endif
309- #endregion
316+ #endregion
310317
311- #region IVsSolutionLoadEvents
318+ #region IVsSolutionLoadEvents
312319 int IVsSolutionLoadEvents . OnBeforeOpenSolution ( string solutionFilename )
313320 {
314321 OnBeforeOpenSolution ? . Invoke ( solutionFilename ) ;
@@ -341,6 +348,6 @@ int IVsSolutionLoadEvents.OnAfterBackgroundSolutionLoadComplete()
341348 OnAfterBackgroundSolutionLoadComplete ? . Invoke ( ) ;
342349 return VSConstants . S_OK ;
343350 }
344- #endregion
351+ #endregion
345352 }
346353}
0 commit comments