protected override void Dispose()

in vsintegration/src/FSharp.ProjectSystem.Base/Project/ProjectNode.cs [1501:1581]


        protected override void Dispose(bool disposing)
        {
            if (this.isDisposed)
            {
                return;
            }

            try
            {
                try
                {
                    this.UnRegisterProject();
                }
                finally
                {
                    try
                    {
                        this.RegisterClipboardNotifications(false);
                    }
                    finally
                    {
                        try
                        {
                            if (this.projectEventsProvider != null)
                            {
                                this.projectEventsProvider.AfterProjectFileOpened -= this.OnAfterProjectOpen;
                            }
                            if (projectErrorListProvider != null)
                            {
                                projectErrorListProvider.Dispose();
                                projectErrorListProvider = null;
                            }
                            if (buildLogger != null)
                            {
                               buildLogger = null;
                            }
                            this.site = null;
                        }
                        finally
                        {
                        }
                    }
                }

                if (this.buildProject != null)
                {
                    //this.projectInstance = null;
                    MSBuildProject.FullyUnloadProject(this.buildProject.ProjectCollection, this.buildProject);
                    SetBuildProject(null);
                }

                if (null != imageHandler)
                {
                    imageHandler.Close();
                    imageHandler = null;
                }

                tracker = null;
                itemIdMap.Clear();
                configProvider = null;
                myExtensibilityEventsHelper = null;
                buildActionConverter = null;
                buildDependencyList = null;

                // IMPORTANT: drop references to RCWs so GC can reclaim them.
                // Otherwise cycle CAggregator -> ProjectNode -> RCW that implicitly hold CAggregator will never be collected
                InteropSafeIVsHierarchy = null;
                InteropSafeIVsProject = null;
                InteropSafeIVsSccProject2 = null;
                InteropSafeIVsUIHierarchy = null;
                InteropSafeIVsProjectFlavorCfgProvider = null;
                buildEngine = null;
                buildLogger = null;
                catidMapping.Clear();                
            }
            finally
            {
                base.Dispose(disposing);
                this.isDisposed = true;
            }
        }