/// <summary> /// When building with only a xsproj in the solution, the SolutionX variables are not /// defined, so we have to define them here. /// </summary> /// <param name="project">The project where the properties are defined.</param> internal static void DefineSolutionProperties(ProjectNode project) { IVsSolution solution = XHelperMethods.GetService <IVsSolution, SVsSolution>(project.Site); object solutionPathObj; ErrorHandler.ThrowOnFailure(solution.GetProperty((int)__VSPROPID.VSPROPID_SolutionFileName, out solutionPathObj)); string solutionPath = (string)solutionPathObj; XPackageSettings settings = XSharpProjectPackage.Instance.Settings; string devEnvDir = XHelperMethods.EnsureTrailingDirectoryChar(Path.GetDirectoryName(settings.DevEnvPath)); string[][] properties = new string[][] { new string[] { XProjectFileConstants.DevEnvDir, devEnvDir }, new string[] { XProjectFileConstants.SolutionPath, solutionPath }, new string[] { XProjectFileConstants.SolutionDir, XHelperMethods.EnsureTrailingDirectoryChar(Path.GetDirectoryName(solutionPath)) }, new string[] { XProjectFileConstants.SolutionExt, Path.GetExtension(solutionPath) }, new string[] { XProjectFileConstants.SolutionFileName, Path.GetFileName(solutionPath) }, new string[] { XProjectFileConstants.SolutionName, Path.GetFileNameWithoutExtension(solutionPath) }, }; foreach (string[] property in properties) { string propertyName = property[0]; string propertyValue = property[1]; project.BuildProject.SetGlobalProperty(propertyName, propertyValue); } }
// XSharpLanguageService _langService = null; #region Overridden Implementation /// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // Give the codemodel a way to talk to the VS Shell oShellLink = new XSharpShellLink(); XSettings.ShellLink = oShellLink; this.RegisterToolWindows(); XSharpProjectPackage.instance = this; this.SolutionListeners.Add(new SolutionEvents(this)); await base.InitializeAsync(cancellationToken, progress); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // The project selector helps to choose between MPF and CPS projects //_projectSelector = new XSharpProjectSelector(); //await _projectSelector.InitAsync(this); this.settings = new XPackageSettings(this); VS.Events.BuildEvents.ProjectConfigurationChanged += BuildEvents_ProjectConfigurationChanged; this.RegisterProjectFactory(new XSharpProjectFactory(this)); // Indicate how to open the different source files : SourceCode or Designer ?? this.RegisterEditorFactory(new XSharpEditorFactory(this)); this.RegisterProjectFactory(new XSharpWPFProjectFactory(this)); // editors for the binaries base.RegisterEditorFactory(new VOFormEditorFactory(this)); base.RegisterEditorFactory(new VOMenuEditorFactory(this)); base.RegisterEditorFactory(new VODBServerEditorFactory(this)); base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this)); //this._documentWatcher = new XSharpDocumentWatcher(this); _errorList = await VS.GetRequiredServiceAsync <SVsErrorList, IErrorList>(); _taskList = await VS.GetRequiredServiceAsync <SVsTaskList, ITaskList>(); var shell = await VS.GetRequiredServiceAsync <SVsShell, IVsShell>(); if (shell != null) { shell.AdviseShellPropertyChanges(this, out shellCookie); } _langservice = await GetServiceAsync(typeof(XSharpLanguageService)) as XSharpLanguageService; await this.RegisterCommandsAsync(); await GetEditorOptionsAsync(); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { // Suspend walking until Solution is opened. base.SolutionListeners.Add(new ModelScannerEvents(this)); base.Initialize(); XSharpProjectPackage.instance = this; XSharpModel.XSolution.OutputWindow = this; this.RegisterProjectFactory(new XSharpProjectFactory(this)); this.settings = new XPackageSettings(this); validateVulcanEditors(); this.RegisterDebuggerEvents(); // Indicate how to open the different source files : SourceCode or Designer ?? this.RegisterEditorFactory(new XSharpEditorFactory(this)); this.RegisterProjectFactory(new XSharpWPFProjectFactory(this)); // editors for the binaries base.RegisterEditorFactory(new VOFormEditorFactory(this)); base.RegisterEditorFactory(new VOMenuEditorFactory(this)); base.RegisterEditorFactory(new VODBServerEditorFactory(this)); base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this)); // Register the language service // Proffer the service. IServiceContainer serviceContainer = this as IServiceContainer; XSharpLanguageService langService = new XSharpLanguageService(); langService.SetSite(this); serviceContainer.AddService(typeof(XSharpLanguageService), langService, true); // Register a timer to call our language service during // idle periods. IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (m_componentID == 0 && mgr != null) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 1000; int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID); } // Initialize Custom Menu Items XSharp.Project.XSharpMenuItems.Initialize(this); // register property changed event handler var shell = this.GetService(typeof(SVsShell)) as IVsShell; shell.AdviseShellPropertyChanges(this, out shellCookie); // // LibraryManager : Offers Object Browser and ClassView // ObjectBrowser : Add the LibraryManager service as a Service provided by that container IServiceContainer container = this as IServiceContainer; ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateService); // container.AddService(typeof(IXSharpLibraryManager), callback, true); this._documentWatcher = new XSharpDocumentWatcher(this); }
// XSharpLanguageService _langService = null; #region Overridden Implementation /// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // Suspend walking until Solution is opened. base.SolutionListeners.Add(new ModelScannerEvents(this)); await base.InitializeAsync(cancellationToken, progress); await JoinableTaskFactory.SwitchToMainThreadAsync(); _uiThread = new UIThread(); XSharpProjectPackage.instance = this; XSharpModel.XSolution.OutputWindow = this; this.RegisterProjectFactory(new XSharpProjectFactory(this)); this.settings = new XPackageSettings(this); validateVulcanEditors(); this.RegisterDebuggerEvents(); // Indicate how to open the different source files : SourceCode or Designer ?? this.RegisterEditorFactory(new XSharpEditorFactory(this)); this.RegisterProjectFactory(new XSharpWPFProjectFactory(this)); // editors for the binaries base.RegisterEditorFactory(new VOFormEditorFactory(this)); base.RegisterEditorFactory(new VOMenuEditorFactory(this)); base.RegisterEditorFactory(new VODBServerEditorFactory(this)); base.RegisterEditorFactory(new VOFieldSpecEditorFactory(this)); XSharp.Project.XSharpMenuItems.Initialize(this); // Register a timer to call our language service during // idle periods. IOleComponentManager mgr = await GetServiceAsync(typeof(SOleComponentManager)) as IOleComponentManager; if (m_componentID == 0 && mgr != null) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 1000; int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID); } // Initialize Custom Menu Items // register property changed event handler var shell = await this.GetServiceAsync(typeof(SVsShell)) as IVsShell; Assumes.Present(shell); shell.AdviseShellPropertyChanges(this, out shellCookie); // // ObjectBrowser : Add the LibraryManager service as a Service provided by that container IServiceContainer container = this as IServiceContainer; ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateLibraryService); // container.AddService(typeof(IXSharpLibraryManager), callback, true); this._documentWatcher = new XSharpDocumentWatcher(this); _txtManager = await GetServiceAsync(typeof(SVsTextManager)) as IVsTextManager4; // determine version of VS object vers; shell.GetProperty((int)__VSSPROPID5.VSSPROPID_ReleaseVersion, out vers); VsVersion = vers.ToString(); _errorList = await GetServiceAsync(typeof(SVsErrorList)) as IErrorList; _taskList = await GetServiceAsync(typeof(SVsTaskList)) as ITaskList; }