/// <summary> /// Common method for handling platform names. /// </summary> /// <param name="celt">Specifies the requested number of platform names. If this number is unknown, celt can be zero.</param> /// <param name="names">On input, an allocated array to hold the number of platform names specified by celt. This parameter can also be null if the celt parameter is zero. On output, names contains platform names</param> /// <param name="actual">A count of the actual number of platform names returned.</param> /// <param name="platforms">An array of available platform names</param> /// <returns>A count of the actual number of platform names returned.</returns> /// <devremark>The platforms array is never null. It is assured by the callers.</devremark> private static int GetPlatforms(uint celt, string[] names, uint[] actual, string[] platforms) { Utilities.ArgumentNotNull("platforms", platforms); if (names == null) { if (actual == null || actual.Length == 0) { throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "actual"); } actual[0] = (uint)platforms.Length; return(VSConstants.S_OK); } //Degenarate case if (celt == 0) { if (actual != null && actual.Length != 0) { actual[0] = (uint)platforms.Length; } return(VSConstants.S_OK); } uint returned = 0; for (int i = 0; i < platforms.Length && names.Length > returned; i++) { names[returned] = platforms[i]; returned++; } if (actual != null && actual.Length != 0) { actual[0] = returned; } if (celt > returned) { return(VSConstants.S_FALSE); } return(VSConstants.S_OK); }
/// <summary> /// Constructor. Copy the base property descriptor and also hold a pointer /// to it for calling its overridden abstract methods. /// </summary> public DesignPropertyDescriptor(PropertyDescriptor prop) : base(prop) { Utilities.ArgumentNotNull("prop", prop); this.property = prop; DisplayNameAttribute attr = prop.Attributes[typeof(DisplayNameAttribute)] as DisplayNameAttribute; if (attr != null) { this.displayName = attr.DisplayName; } else { this.displayName = prop.Name; } }
/// <summary> /// Constructor. Inititialize member data. /// </summary> public IDEBuildLogger(IVsOutputWindowPane output, TaskProvider taskProvider, IVsHierarchy hierarchy) { Utilities.ArgumentNotNull("taskProvider", taskProvider); Utilities.ArgumentNotNull("hierarchy", hierarchy); Trace.WriteLineIf(Thread.CurrentThread.GetApartmentState() != ApartmentState.STA, "WARNING: IDEBuildLogger constructor running on the wrong thread."); IOleServiceProvider site; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hierarchy.GetSite(out site)); this.taskProvider = taskProvider; this.outputWindowPane = output; this.hierarchy = hierarchy; this.serviceProvider = new ServiceProvider(site); serviceProvider.GetUIThread().MustBeCalledFromUIThread(); this.dispatcher = Dispatcher.CurrentDispatcher; }
internal ProjectConfig(ProjectNode project, string configuration) { this.project = project; this.configName = configuration; var flavoredCfgProvider = ProjectMgr.GetOuterInterface <IVsProjectFlavorCfgProvider>(); Utilities.ArgumentNotNull("flavoredCfgProvider", flavoredCfgProvider); ErrorHandler.ThrowOnFailure(flavoredCfgProvider.CreateProjectFlavorCfg(this, out flavoredCfg)); Utilities.ArgumentNotNull("flavoredCfg", flavoredCfg); // if the flavored object support XML fragment, initialize it IPersistXMLFragment persistXML = flavoredCfg as IPersistXMLFragment; if (null != persistXML) { this.project.LoadXmlFragment(persistXML, configName); } }
/// <summary> /// Get reference to IVsUIHierarchyWindow interface from guid persistence slot. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="persistenceSlot">Unique identifier for a tool window created using IVsUIShell::CreateToolWindow. /// The caller of this method can use predefined identifiers that map to tool windows if those tool windows /// are known to the caller. </param> /// <returns>A reference to an IVsUIHierarchyWindow interface.</returns> public static IVsUIHierarchyWindow GetUIHierarchyWindow(IServiceProvider serviceProvider, Guid persistenceSlot) { Utilities.ArgumentNotNull("serviceProvider", serviceProvider); IVsUIShell shell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; Utilities.CheckNotNull(shell, "Could not get the UI shell from the project"); object pvar; IVsWindowFrame frame; if (ErrorHandler.Succeeded(shell.FindToolWindow(0, ref persistenceSlot, out frame)) && ErrorHandler.Succeeded(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out pvar))) { return(pvar as IVsUIHierarchyWindow); } return(null); }
/// <summary> /// Gets the active configuration name. /// </summary> /// <param name="automationObject">The automation object.</param> /// <returns>The name of the active configuartion.</returns> internal static string GetActiveConfigurationName(EnvDTE.Project automationObject) { Utilities.ArgumentNotNull("automationObject", automationObject); string currentConfigName = string.Empty; if (automationObject.ConfigurationManager != null) { try { EnvDTE.Configuration activeConfig = automationObject.ConfigurationManager.ActiveConfiguration; if (activeConfig != null) { currentConfigName = activeConfig.ConfigurationName; } } catch (COMException ex) { Debug.WriteLine("Failed to get active configuration because of {0}", ex); } } return(currentConfigName); }
/// <summary> /// Overridden from the Logger class. /// </summary> public override void Initialize(IEventSource eventSource) { Utilities.ArgumentNotNull("eventSource", eventSource); this.taskQueue = new ConcurrentQueue <Func <ErrorTask> >(); this.outputQueue = new ConcurrentQueue <OutputQueueEntry>(); eventSource.BuildStarted += new BuildStartedEventHandler(BuildStartedHandler); eventSource.BuildFinished += new BuildFinishedEventHandler(BuildFinishedHandler); eventSource.ProjectStarted += new ProjectStartedEventHandler(ProjectStartedHandler); eventSource.ProjectFinished += new ProjectFinishedEventHandler(ProjectFinishedHandler); eventSource.TargetStarted += new TargetStartedEventHandler(TargetStartedHandler); eventSource.TargetFinished += new TargetFinishedEventHandler(TargetFinishedHandler); eventSource.TaskStarted += new TaskStartedEventHandler(TaskStartedHandler); eventSource.TaskFinished += new TaskFinishedEventHandler(TaskFinishedHandler); eventSource.CustomEventRaised += new CustomBuildEventHandler(CustomHandler); eventSource.ErrorRaised += new BuildErrorEventHandler(ErrorRaisedHandler); eventSource.WarningRaised += new BuildWarningEventHandler(WarningHandler); eventSource.MessageRaised += new BuildMessageEventHandler(MessageHandler); }
public int Next(uint elements, IVsDependency[] dependencies, out uint elementsFetched) { elementsFetched = 0; Utilities.ArgumentNotNull("dependencies", dependencies); uint fetched = 0; var count = this.dependencyList.Count; while (this.nextIndex < count && elements > 0 && fetched < count) { dependencies[fetched] = this.dependencyList[(int)this.nextIndex]; this.nextIndex++; fetched++; elements--; } elementsFetched = fetched; // Did we get 'em all? return(elements == 0 ? VSConstants.S_OK : VSConstants.S_FALSE); }
/// <summary> /// Updates the caption for all windows associated to the document. /// </summary> /// <param name="site">The service provider.</param> /// <param name="caption">The new caption.</param> /// <param name="docData">The IUnknown interface to a document data object associated with a registered document.</param> public static void UpdateCaption(IServiceProvider site, string caption, IntPtr docData) { Utilities.ArgumentNotNull("site", site); if (string.IsNullOrEmpty(caption)) { throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty), "caption"); } var uiShell = site.GetService(typeof(SVsUIShell)) as IVsUIShell; // We need to tell the windows to update their captions. IEnumWindowFrames windowFramesEnum; ErrorHandler.ThrowOnFailure(uiShell.GetDocumentWindowEnum(out windowFramesEnum)); var windowFrames = new IVsWindowFrame[1]; uint fetched; while (windowFramesEnum.Next(1, windowFrames, out fetched) == VSConstants.S_OK && fetched == 1) { var windowFrame = windowFrames[0]; object data; ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out data)); var ptr = Marshal.GetIUnknownForObject(data); try { if (ptr == docData) { ErrorHandler.ThrowOnFailure(windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_OwnerCaption, caption)); } } finally { if (ptr != IntPtr.Zero) { Marshal.Release(ptr); } } } }
/// <summary> /// Retrieves the common property pages. The NodeProperties is the BrowseObject and that will be called to support /// configuration independent properties. /// </summary> /// <param name="pages">The pages to return.</param> private void GetCommonPropertyPages(CAUUID[] pages) { // We do not check whether the supportsProjectDesigner is set to false on the ProjectNode. // We rely that the caller knows what to call on us. Utilities.ArgumentNotNull("pages", pages); if (pages.Length == 0) { throw new ArgumentException(SR.GetString(SR.InvalidParameter), "pages"); } // Only the project should show the property page the rest should show the project properties. if (this.node != null && (this.node is ProjectNode)) { // Retrieve the list of guids from hierarchy properties. // Because a flavor could modify that list we must make sure we are calling the outer most implementation of IVsHierarchy string guidsList = String.Empty; IVsHierarchy hierarchy = HierarchyNode.ProjectMgr.GetOuterInterface <IVsHierarchy>(); object variant = null; ErrorHandler.ThrowOnFailure(hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList, out variant)); guidsList = (string)variant; Guid[] guids = Utilities.GuidsArrayFromSemicolonDelimitedStringOfGuids(guidsList); if (guids == null || guids.Length == 0) { pages[0] = new CAUUID(); pages[0].cElems = 0; } else { pages[0] = PackageUtilities.CreateCAUUIDFromGuidArray(guids); } } else { pages[0] = new CAUUID(); pages[0].cElems = 0; } }
int IPropertyPage.TranslateAccelerator(MSG[] pMsg) { Utilities.ArgumentNotNull("pMsg", pMsg); var msg = pMsg[0]; var message = Message.Create(msg.hwnd, (int)msg.message, msg.wParam, msg.lParam); var target = Control.FromChildHandle(message.HWnd); if (target != null && target.PreProcessMessage(ref message)) { // handled the message pMsg[0].message = (uint)message.Msg; pMsg[0].wParam = message.WParam; pMsg[0].lParam = message.LParam; return(VSConstants.S_OK); } return(VSConstants.S_FALSE); }
internal ProjectConfig(ProjectNode project, string configuration) { this.project = project; if (configuration.Contains("|")) { // If configuration is in the form "<Configuration>|<Platform>" string[] configStrArray = configuration.Split('|'); if (2 == configStrArray.Length) { this.configName = configStrArray[0]; this.platformName = configStrArray[1]; } else { throw new Exception(string.Format(CultureInfo.InvariantCulture, "Invalid configuration format: {0}", configuration)); } } else { // If configuration is in the form "<Configuration>" this.configName = configuration; } var flavoredCfgProvider = ProjectMgr.GetOuterInterface <IVsProjectFlavorCfgProvider>(); Utilities.ArgumentNotNull("flavoredCfgProvider", flavoredCfgProvider); ErrorHandler.ThrowOnFailure(flavoredCfgProvider.CreateProjectFlavorCfg(this, out flavoredCfg)); Utilities.ArgumentNotNull("flavoredCfg", flavoredCfg); // if the flavored object support XML fragment, initialize it IPersistXMLFragment persistXML = flavoredCfg as IPersistXMLFragment; if (null != persistXML) { this.project.LoadXmlFragment(persistXML, configName, platformName); } }
/// <summary> /// Builds an ImageHandler object from an ImageList object. /// </summary> public ImageHandler(ImageList list) { Utilities.ArgumentNotNull("list", list); imageList = list; }
/// <summary> /// Builds an ImageHandler object from a Stream providing the bitmap that /// stores the images for the image list. /// </summary> public ImageHandler(Stream resourceStream) { Utilities.ArgumentNotNull("resourceStream", resourceStream); imageList = Utilities.GetImageList(resourceStream); }
public PropertiesEditorLauncher(ServiceProvider serviceProvider) { Utilities.ArgumentNotNull("serviceProvider", serviceProvider); this.serviceProvider = serviceProvider; }
protected DocumentManager(HierarchyNode node) { Utilities.ArgumentNotNull(nameof(node), node); this.node = node; }
internal ProjectElement(ProjectNode project) { Utilities.ArgumentNotNull("project", project); _itemProject = project; }
internal ProjectElement(ProjectNode project) { Utilities.ArgumentNotNull(nameof(project), project); this._itemProject = project; }
/// <summary> /// Builds an ImageHandler object from an ImageList object. /// </summary> public ImageHandler(ImageList list) { Utilities.ArgumentNotNull(nameof(list), list); this.imageList = list; }
internal NodeProperties(HierarchyNode node) { Utilities.ArgumentNotNull("node", node); this.node = node; }
/// <summary> /// Rename document in the running document table from oldName to newName. /// </summary> /// <param name="provider">The service provider.</param> /// <param name="oldName">Full path to the old name of the document.</param> /// <param name="newName">Full path to the new name of the document.</param> /// <param name="newItemId">The new item id of the document</param> public static void RenameDocument(IServiceProvider site, string oldName, string newName, uint newItemId) { Utilities.ArgumentNotNull("site", site); if (String.IsNullOrEmpty(oldName)) { throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "oldName"); } if (String.IsNullOrEmpty(newName)) { throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "newName"); } IVsRunningDocumentTable pRDT = site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; IVsUIShellOpenDocument doc = site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (pRDT == null || doc == null) { return; } IVsHierarchy pIVsHierarchy; uint itemId; IntPtr docData; uint uiVsDocCookie; ErrorHandler.ThrowOnFailure(pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, oldName, out pIVsHierarchy, out itemId, out docData, out uiVsDocCookie)); if (docData != IntPtr.Zero) { try { IntPtr pUnk = Marshal.GetIUnknownForObject(pIVsHierarchy); Guid iid = typeof(IVsHierarchy).GUID; IntPtr pHier; Marshal.QueryInterface(pUnk, ref iid, out pHier); try { ErrorHandler.ThrowOnFailure(pRDT.RenameDocument(oldName, newName, pHier, newItemId)); } catch (Exception) { int i = 0; } finally { if (pHier != IntPtr.Zero) { Marshal.Release(pHier); } if (pUnk != IntPtr.Zero) { Marshal.Release(pUnk); } } } finally { Marshal.Release(docData); } } }
/// <summary> /// Rename document in the running document table from oldName to newName. /// </summary> /// <param name="provider">The service provider.</param> /// <param name="oldName">Full path to the old name of the document.</param> /// <param name="newName">Full path to the new name of the document.</param> /// <param name="newItemId">The new item id of the document</param> public static void RenameDocument(IServiceProvider site, string oldName, string newName, uint newItemId) { Utilities.ArgumentNotNull("site", site); if (string.IsNullOrEmpty(oldName)) { throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty), "oldName"); } if (string.IsNullOrEmpty(newName)) { throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty), "newName"); } if (newItemId == VSConstants.VSITEMID_NIL) { throw new ArgumentNullException("newItemId"); } var pRDT = site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; if (pRDT == null) { return; } IVsHierarchy pIVsHierarchy; uint itemId; IntPtr docData; uint uiVsDocCookie; ErrorHandler.ThrowOnFailure(pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, oldName, out pIVsHierarchy, out itemId, out docData, out uiVsDocCookie)); if (docData != IntPtr.Zero && pIVsHierarchy != null) { try { var pUnk = Marshal.GetIUnknownForObject(pIVsHierarchy); var iid = typeof(IVsHierarchy).GUID; IntPtr pHier; Marshal.QueryInterface(pUnk, ref iid, out pHier); try { ErrorHandler.ThrowOnFailure(pRDT.RenameDocument(oldName, newName, pHier, newItemId)); } finally { if (pHier != IntPtr.Zero) { Marshal.Release(pHier); } if (pUnk != IntPtr.Zero) { Marshal.Release(pUnk); } } } finally { Marshal.Release(docData); } } }
protected virtual int QueryStatusSelection(Guid cmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText, CommandOrigin commandOrigin) { if (IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } if (cmdGroup == Guid.Empty) { return((int)OleConstants.OLECMDERR_E_UNKNOWNGROUP); } Utilities.ArgumentNotNull("prgCmds", prgCmds); uint cmd = prgCmds[0].cmdID; QueryStatusResult queryResult = QueryStatusResult.NOTSUPPORTED; // For now ask this node (that is the project node) to disable or enable a node. // This is an optimization. Why should we ask each node for its current state? They all are in the same state. // Also please note that we return QueryStatusResult.INVISIBLE instead of just QueryStatusResult.SUPPORTED. // The reason is that if the project has nested projects, then providing just QueryStatusResult.SUPPORTED is not enough. // What will happen is that the nested project will show grayed commands that belong to this project and does not belong to the nested project. (like special commands implemented by subclassed projects). // The reason is that a special command comes in that is not handled because we are in debug mode. Then VsCore asks the nested project can you handle it. // The nested project does not know about it, thus it shows it on the nested project as grayed. if (this.DisableCmdInCurrentMode(cmdGroup, cmd)) { queryResult = QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; } else { bool handled = false; if (commandOrigin == CommandOrigin.OleCommandTarget) { queryResult = this.QueryStatusCommandFromOleCommandTarget(cmdGroup, cmd, out handled); } if (!handled) { IList <HierarchyNode> selectedNodes = GetSelectedNodes(); // Want to disable in multiselect case. if (selectedNodes != null && selectedNodes.Count > 1) { queryResult = this.DisableCommandOnNodesThatDoNotSupportMultiSelection(cmdGroup, cmd, selectedNodes, out handled); } // Now go and do the job on the nodes. if (!handled) { queryResult = this.QueryStatusSelectionOnNodes(selectedNodes, cmdGroup, cmd, pCmdText); } } } // Process the results set in the QueryStatusResult if (queryResult != QueryStatusResult.NOTSUPPORTED) { // Set initial value prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_SUPPORTED; if ((queryResult & QueryStatusResult.ENABLED) != 0) { prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_ENABLED; } if ((queryResult & QueryStatusResult.INVISIBLE) != 0) { prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_INVISIBLE; } if ((queryResult & QueryStatusResult.LATCHED) != 0) { prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_LATCHED; } return(VSConstants.S_OK); } return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); }
public ExtensibilityEventsDispatcher(ProjectNode /*!*/ project) { Utilities.ArgumentNotNull("project", project); this._project = project; }
public ExtensibilityEventsDispatcher(ProjectNode project) { Utilities.ArgumentNotNull(nameof(project), project); this._project = project; }
/// <summary> /// Builds an ImageHandler object from a Stream providing the bitmap that /// stores the images for the image list. /// </summary> public ImageHandler(Stream resourceStream) { Utilities.ArgumentNotNull(nameof(resourceStream), resourceStream); this.imageList = Utilities.GetImageList(resourceStream); }