From 50d8be6635093b4b31983e582fcc18a3f00385e5 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 23 Feb 2014 21:47:40 -0600 Subject: [PATCH 1/3] Update to common project system --- .../BuildCompletedEventListener.cs | 8 +- .../Editors/ContentLayoutEditorPane.cs | 18 +- .../Editors/SiteMapEditorPane.cs | 18 +- .../SandcastleBuilderPackage/NativeMethods.cs | 744 ++++++++++++++++++ .../Nodes/DocumentationSourceNode.cs | 13 +- .../DocumentationSourceNodeProperties.cs | 9 +- .../DocumentationSourcesContainerNode.cs | 37 +- .../Nodes/ProjectPropertiesContainerNode.cs | 17 +- .../SandcastleBuilderAssemblyReferenceNode.cs | 7 +- .../SandcastleBuilderComReferenceNode.cs | 7 +- .../Nodes/SandcastleBuilderFileNode.cs | 12 +- .../SandcastleBuilderFileNodeProperties.cs | 18 +- .../Nodes/SandcastleBuilderProjectNode.cs | 80 +- .../SandcastleBuilderProjectNodeProperties.cs | 13 +- .../SandcastleBuilderProjectReferenceNodes.cs | 7 +- ...SandcastleBuilderReferenceContainerNode.cs | 12 +- .../PropertyPages/BasePropertyPage.cs | 8 +- .../BuildPropertiesPageControl.cs | 3 +- .../ComponentPropertiesPageControl.cs | 3 +- .../HelpFilePropertiesPageControl.cs | 5 +- .../MSHelp2PropertiesPageControl.cs | 3 +- .../MissingTagPropertiesPageControl.cs | 6 +- .../PlugInPropertiesPageControl.cs | 3 +- .../SummaryPropertiesPageControl.cs | 3 +- .../TransformArgumentsPageControl.cs | 3 +- .../VisibilityPropertiesPageControl.cs | 5 +- .../SandcastleBuilderPackage.cs | 17 +- .../SandcastleBuilderPackage.csproj | 40 +- .../packages.SandcastleBuilderPackage.config | 4 + .../SandcastleHelpFileBuilder.targets | 12 + 30 files changed, 978 insertions(+), 157 deletions(-) create mode 100644 SHFB/Source/SandcastleBuilderPackage/NativeMethods.cs diff --git a/SHFB/Source/SandcastleBuilderPackage/BuildCompletedEventListener.cs b/SHFB/Source/SandcastleBuilderPackage/BuildCompletedEventListener.cs index d8066288..a34796cb 100644 --- a/SHFB/Source/SandcastleBuilderPackage/BuildCompletedEventListener.cs +++ b/SHFB/Source/SandcastleBuilderPackage/BuildCompletedEventListener.cs @@ -84,7 +84,7 @@ public override int UpdateProjectCfg_Done(IVsHierarchy hierarchy, IVsCfg configP if(cancel == 0 && success != 0) { // Open the help file on a successful build if so requested - projectNode = cfg.ProjectMgr as SandcastleBuilderProjectNode; + projectNode = cfg.ProjectManager as SandcastleBuilderProjectNode; options = SandcastleBuilderPackage.Instance.GeneralOptions; if(projectNode != null && options != null) @@ -93,7 +93,7 @@ public override int UpdateProjectCfg_Done(IVsHierarchy hierarchy, IVsCfg configP else if((action & (uint)VSSOLNBUILDUPDATEFLAGS.SBF_OPERATION_CLEAN) != 0) { - var window = cfg.ProjectMgr.Package.FindToolWindow(typeof(ToolWindows.BuildLogToolWindow), 0, false) as + var window = cfg.ProjectManager.Package.FindToolWindow(typeof(ToolWindows.BuildLogToolWindow), 0, false) as BuildLogToolWindow; if(window != null) @@ -104,7 +104,7 @@ public override int UpdateProjectCfg_Done(IVsHierarchy hierarchy, IVsCfg configP if(cancel == 0 && success == 0) { // Open the build log tool window on a failed build if so requested - projectNode = cfg.ProjectMgr as SandcastleBuilderProjectNode; + projectNode = cfg.ProjectManager as SandcastleBuilderProjectNode; options = SandcastleBuilderPackage.Instance.GeneralOptions; if(projectNode != null && options != null) @@ -114,7 +114,7 @@ public override int UpdateProjectCfg_Done(IVsHierarchy hierarchy, IVsCfg configP { // The user doesn't want it opened. However, if it's already open, refresh the // log file reference so that it shows the correct file when it is displayed. - var window = cfg.ProjectMgr.Package.FindToolWindow(typeof(ToolWindows.BuildLogToolWindow), 0, false) as + var window = cfg.ProjectManager.Package.FindToolWindow(typeof(ToolWindows.BuildLogToolWindow), 0, false) as BuildLogToolWindow; if(window != null && ((IVsWindowFrame)window.Frame).IsVisible() == VSConstants.S_OK) diff --git a/SHFB/Source/SandcastleBuilderPackage/Editors/ContentLayoutEditorPane.cs b/SHFB/Source/SandcastleBuilderPackage/Editors/ContentLayoutEditorPane.cs index 3a7b4695..c43e3a48 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Editors/ContentLayoutEditorPane.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Editors/ContentLayoutEditorPane.cs @@ -244,7 +244,7 @@ private void ucContentLayoutEditor_AssociateTopic(object sender, RoutedEventArgs e.Handled = true; if(thisNode != null) - thisNode.ProjectMgr.RefreshProject(); + thisNode.ProjectManager.RefreshProject(); } } } @@ -312,18 +312,18 @@ private void cmdAddFromTemplate_Executed(object sender, ExecutedRoutedEventArgs // If we have a topic, use it's parent as the parent for the new topic. If not, we'll use the // parent of the content layout file. if(base.UIControl.CurrentTopic != null && base.UIControl.CurrentTopic.TopicFile != null) - topicNode = thisNode.ProjectMgr.FindChild(base.UIControl.CurrentTopic.TopicFile.FullPath) as FileNode; + topicNode = thisNode.ProjectManager.FindChild(base.UIControl.CurrentTopic.TopicFile.FullPath) as FileNode; - project = (IVsProject3)thisNode.ProjectMgr; - strBrowseLocations = Path.GetDirectoryName(thisNode.ProjectMgr.BaseURI.Uri.LocalPath); - projectGuid = thisNode.ProjectMgr.ProjectGuid; + project = (IVsProject3)thisNode.ProjectManager; + strBrowseLocations = Path.GetDirectoryName(thisNode.ProjectManager.BaseUri.Uri.LocalPath); + projectGuid = thisNode.ProjectManager.ProjectGuid; addItemDialog = this.GetService(typeof(IVsAddProjectItemDlg)) as IVsAddProjectItemDlg; uiFlags = (uint)(__VSADDITEMFLAGS.VSADDITEM_AddNewItems | __VSADDITEMFLAGS.VSADDITEM_SuggestTemplateName | __VSADDITEMFLAGS.VSADDITEM_AllowHiddenTreeView); - int hr = addItemDialog.AddProjectItemDlg((topicNode ?? thisNode).ID, ref projectGuid, project, + int hr = addItemDialog.AddProjectItemDlg((topicNode ?? thisNode).Id, ref projectGuid, project, uiFlags, "Conceptual Content|Topics", "Conceptual", ref strBrowseLocations, ref strFilter, out iDontShowAgain); @@ -331,7 +331,7 @@ private void cmdAddFromTemplate_Executed(object sender, ExecutedRoutedEventArgs // to the collection. if(hr == VSConstants.S_OK) { - var node = thisNode.ProjectMgr.GetSelectedNodes().FirstOrDefault(); + var node = thisNode.ProjectManager.GetSelectedNodes().FirstOrDefault(); if(node != null && node.Url.EndsWith(".aml", StringComparison.OrdinalIgnoreCase)) this.AddTopicFile(node.Url, e.Parameter != null); @@ -372,7 +372,7 @@ private void cmdAddExistingFile_Executed(object sender, ExecutedRoutedEventArgs } if(thisNode != null) - thisNode.ProjectMgr.RefreshProject(); + thisNode.ProjectManager.RefreshProject(); } } } @@ -404,7 +404,7 @@ private void cmdAddAllFromFolder_Executed(object sender, ExecutedRoutedEventArgs contentLayoutFile.ProjectElement.Project); if(thisNode != null) - thisNode.ProjectMgr.RefreshProject(); + thisNode.ProjectManager.RefreshProject(); } if(newTopics.Count != 0) diff --git a/SHFB/Source/SandcastleBuilderPackage/Editors/SiteMapEditorPane.cs b/SHFB/Source/SandcastleBuilderPackage/Editors/SiteMapEditorPane.cs index 8de46bcf..4fb39728 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Editors/SiteMapEditorPane.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Editors/SiteMapEditorPane.cs @@ -244,7 +244,7 @@ private void ucSiteMapEditor_AssociateTopic(object sender, RoutedEventArgs e) e.Handled = true; if(thisNode != null) - thisNode.ProjectMgr.RefreshProject(); + thisNode.ProjectManager.RefreshProject(); } } } @@ -312,18 +312,18 @@ private void cmdAddFromTemplate_Executed(object sender, ExecutedRoutedEventArgs // If we have a topic, use it's parent as the parent for the new topic. If not, we'll use the // parent of the content layout file. if(base.UIControl.CurrentTopic != null && base.UIControl.CurrentTopic.SourceFile.Path.Length != 0) - topicNode = thisNode.ProjectMgr.FindChild(base.UIControl.CurrentTopic.SourceFile) as FileNode; + topicNode = thisNode.ProjectManager.FindChild(base.UIControl.CurrentTopic.SourceFile) as FileNode; - project = (IVsProject3)thisNode.ProjectMgr; - strBrowseLocations = Path.GetDirectoryName(thisNode.ProjectMgr.BaseURI.Uri.LocalPath); - projectGuid = thisNode.ProjectMgr.ProjectGuid; + project = (IVsProject3)thisNode.ProjectManager; + strBrowseLocations = Path.GetDirectoryName(thisNode.ProjectManager.BaseUri.Uri.LocalPath); + projectGuid = thisNode.ProjectManager.ProjectGuid; addItemDialog = this.GetService(typeof(IVsAddProjectItemDlg)) as IVsAddProjectItemDlg; uiFlags = (uint)(__VSADDITEMFLAGS.VSADDITEM_AddNewItems | __VSADDITEMFLAGS.VSADDITEM_SuggestTemplateName | __VSADDITEMFLAGS.VSADDITEM_AllowHiddenTreeView); - int hr = addItemDialog.AddProjectItemDlg((topicNode ?? thisNode).ID, ref projectGuid, project, + int hr = addItemDialog.AddProjectItemDlg((topicNode ?? thisNode).Id, ref projectGuid, project, uiFlags, "Other Content", "Html Page", ref strBrowseLocations, ref strFilter, out iDontShowAgain); @@ -331,7 +331,7 @@ private void cmdAddFromTemplate_Executed(object sender, ExecutedRoutedEventArgs // to the collection. if(hr == VSConstants.S_OK) { - var node = thisNode.ProjectMgr.GetSelectedNodes().FirstOrDefault(); + var node = thisNode.ProjectManager.GetSelectedNodes().FirstOrDefault(); if(node != null && node.Url.EndsWith(".htm", StringComparison.OrdinalIgnoreCase) || node.Url.EndsWith(".html", StringComparison.OrdinalIgnoreCase)) @@ -372,7 +372,7 @@ private void cmdAddExistingFile_Executed(object sender, ExecutedRoutedEventArgs } if(thisNode != null) - thisNode.ProjectMgr.RefreshProject(); + thisNode.ProjectManager.RefreshProject(); } } } @@ -404,7 +404,7 @@ private void cmdAddAllFromFolder_Executed(object sender, ExecutedRoutedEventArgs siteMapFile.ProjectElement.Project); if(thisNode != null) - thisNode.ProjectMgr.RefreshProject(); + thisNode.ProjectManager.RefreshProject(); } if(newTopics.Count != 0) diff --git a/SHFB/Source/SandcastleBuilderPackage/NativeMethods.cs b/SHFB/Source/SandcastleBuilderPackage/NativeMethods.cs new file mode 100644 index 00000000..f9241222 --- /dev/null +++ b/SHFB/Source/SandcastleBuilderPackage/NativeMethods.cs @@ -0,0 +1,744 @@ +/******************************************************************************************** + +Copyright (c) Microsoft Corporation +All rights reserved. + +Microsoft Public License: + +This license governs use of the accompanying software. If you use the software, you +accept this license. If you do not accept the license, do not use the software. + +1. Definitions +The terms "reproduce," "reproduction," "derivative works," and "distribution" have the +same meaning here as under U.S. copyright law. +A "contribution" is the original software, or any additions or changes to the software. +A "contributor" is any person that distributes its contribution under this license. +"Licensed patents" are a contributor's patent claims that read directly on its contribution. + +2. Grant of Rights +(A) Copyright Grant- Subject to the terms of this license, including the license conditions +and limitations in section 3, each contributor grants you a non-exclusive, worldwide, +royalty-free copyright license to reproduce its contribution, prepare derivative works of +its contribution, and distribute its contribution or any derivative works that you create. +(B) Patent Grant- Subject to the terms of this license, including the license conditions +and limitations in section 3, each contributor grants you a non-exclusive, worldwide, +royalty-free license under its licensed patents to make, have made, use, sell, offer for +sale, import, and/or otherwise dispose of its contribution in the software or derivative +works of the contribution in the software. + +3. Conditions and Limitations +(A) No Trademark License- This license does not grant you rights to use any contributors' +name, logo, or trademarks. +(B) If you bring a patent claim against any contributor over patents that you claim are +infringed by the software, your patent license from such contributor to the software ends +automatically. +(C) If you distribute any portion of the software, you must retain all copyright, patent, +trademark, and attribution notices that are present in the software. +(D) If you distribute any portion of the software in source code form, you may do so only +under this license by including a complete copy of this license with your distribution. +If you distribute any portion of the software in compiled or object code form, you may only +do so under a license that complies with this license. +(E) The software is licensed "as-is." You bear the risk of using it. The contributors give +no express warranties, guarantees or conditions. You may have additional consumer rights +under your local laws which this license cannot change. To the extent permitted under your +local laws, the contributors exclude the implied warranties of merchantability, fitness for +a particular purpose and non-infringement. + +********************************************************************************************/ + +using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using Microsoft.VisualStudio; +using Microsoft.VisualStudio.OLE.Interop; +using Microsoft.VisualStudio.TextManager.Interop; + +namespace SandcastleBuilder.Package +{ + internal static class NativeMethods + { + // IIDS + public static readonly Guid IID_IUnknown = new Guid("{00000000-0000-0000-C000-000000000046}"); + + public const int + CLSCTX_INPROC_SERVER = 0x1; + + public const int + S_FALSE = 0x00000001, + S_OK = 0x00000000, + + IDOK = 1, + IDCANCEL = 2, + IDABORT = 3, + IDRETRY = 4, + IDIGNORE = 5, + IDYES = 6, + IDNO = 7, + IDCLOSE = 8, + IDHELP = 9, + IDTRYAGAIN = 10, + IDCONTINUE = 11, + + OLECMDERR_E_NOTSUPPORTED = unchecked((int)0x80040100), + OLECMDERR_E_UNKNOWNGROUP = unchecked((int)0x80040104), + + UNDO_E_CLIENTABORT = unchecked((int)0x80044001), + E_OUTOFMEMORY = unchecked((int)0x8007000E), + E_INVALIDARG = unchecked((int)0x80070057), + E_FAIL = unchecked((int)0x80004005), + E_NOINTERFACE = unchecked((int)0x80004002), + E_POINTER = unchecked((int)0x80004003), + E_NOTIMPL = unchecked((int)0x80004001), + E_UNEXPECTED = unchecked((int)0x8000FFFF), + E_HANDLE = unchecked((int)0x80070006), + E_ABORT = unchecked((int)0x80004004), + E_ACCESSDENIED = unchecked((int)0x80070005), + E_PENDING = unchecked((int)0x8000000A); + + public const int + OLECLOSE_SAVEIFDIRTY = 0, + OLECLOSE_NOSAVE = 1, + OLECLOSE_PROMPTSAVE = 2; + + public const int + OLEIVERB_PRIMARY = 0, + OLEIVERB_SHOW = -1, + OLEIVERB_OPEN = -2, + OLEIVERB_HIDE = -3, + OLEIVERB_UIACTIVATE = -4, + OLEIVERB_INPLACEACTIVATE = -5, + OLEIVERB_DISCARDUNDOSTATE = -6, + OLEIVERB_PROPERTIES = -7; + + public const int + OFN_READONLY = unchecked((int)0x00000001), + OFN_OVERWRITEPROMPT = unchecked((int)0x00000002), + OFN_HIDEREADONLY = unchecked((int)0x00000004), + OFN_NOCHANGEDIR = unchecked((int)0x00000008), + OFN_SHOWHELP = unchecked((int)0x00000010), + OFN_ENABLEHOOK = unchecked((int)0x00000020), + OFN_ENABLETEMPLATE = unchecked((int)0x00000040), + OFN_ENABLETEMPLATEHANDLE = unchecked((int)0x00000080), + OFN_NOVALIDATE = unchecked((int)0x00000100), + OFN_ALLOWMULTISELECT = unchecked((int)0x00000200), + OFN_EXTENSIONDIFFERENT = unchecked((int)0x00000400), + OFN_PATHMUSTEXIST = unchecked((int)0x00000800), + OFN_FILEMUSTEXIST = unchecked((int)0x00001000), + OFN_CREATEPROMPT = unchecked((int)0x00002000), + OFN_SHAREAWARE = unchecked((int)0x00004000), + OFN_NOREADONLYRETURN = unchecked((int)0x00008000), + OFN_NOTESTFILECREATE = unchecked((int)0x00010000), + OFN_NONETWORKBUTTON = unchecked((int)0x00020000), + OFN_NOLONGNAMES = unchecked((int)0x00040000), + OFN_EXPLORER = unchecked((int)0x00080000), + OFN_NODEREFERENCELINKS = unchecked((int)0x00100000), + OFN_LONGNAMES = unchecked((int)0x00200000), + OFN_ENABLEINCLUDENOTIFY = unchecked((int)0x00400000), + OFN_ENABLESIZING = unchecked((int)0x00800000), + OFN_USESHELLITEM = unchecked((int)0x01000000), + OFN_DONTADDTORECENT = unchecked((int)0x02000000), + OFN_FORCESHOWHIDDEN = unchecked((int)0x10000000); + + // for READONLYSTATUS + public const int + ROSTATUS_NotReadOnly = 0x0, + ROSTATUS_ReadOnly = 0x1, + ROSTATUS_Unknown = unchecked((int)0xFFFFFFFF); + + public const int + IEI_DoNotLoadDocData = 0x10000000; + + public const int + CB_SETDROPPEDWIDTH = 0x0160, + + GWL_STYLE = (-16), + GWL_EXSTYLE = (-20), + + DWL_MSGRESULT = 0, + + SW_SHOWNORMAL = 1, + + HTMENU = 5, + + WS_POPUP = unchecked((int)0x80000000), + WS_CHILD = 0x40000000, + WS_MINIMIZE = 0x20000000, + WS_VISIBLE = 0x10000000, + WS_DISABLED = 0x08000000, + WS_CLIPSIBLINGS = 0x04000000, + WS_CLIPCHILDREN = 0x02000000, + WS_MAXIMIZE = 0x01000000, + WS_CAPTION = 0x00C00000, + WS_BORDER = 0x00800000, + WS_DLGFRAME = 0x00400000, + WS_VSCROLL = 0x00200000, + WS_HSCROLL = 0x00100000, + WS_SYSMENU = 0x00080000, + WS_THICKFRAME = 0x00040000, + WS_TABSTOP = 0x00010000, + WS_MINIMIZEBOX = 0x00020000, + WS_MAXIMIZEBOX = 0x00010000, + WS_EX_DLGMODALFRAME = 0x00000001, + WS_EX_MDICHILD = 0x00000040, + WS_EX_TOOLWINDOW = 0x00000080, + WS_EX_CLIENTEDGE = 0x00000200, + WS_EX_CONTEXTHELP = 0x00000400, + WS_EX_RIGHT = 0x00001000, + WS_EX_LEFT = 0x00000000, + WS_EX_RTLREADING = 0x00002000, + WS_EX_LEFTSCROLLBAR = 0x00004000, + WS_EX_CONTROLPARENT = 0x00010000, + WS_EX_STATICEDGE = 0x00020000, + WS_EX_APPWINDOW = 0x00040000, + WS_EX_LAYERED = 0x00080000, + WS_EX_TOPMOST = 0x00000008, + WS_EX_NOPARENTNOTIFY = 0x00000004, + + LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54), + + LVS_EX_LABELTIP = 0x00004000, + + // winuser.h + WH_JOURNALPLAYBACK = 1, + WH_GETMESSAGE = 3, + WH_MOUSE = 7, + WSF_VISIBLE = 0x0001, + WM_NULL = 0x0000, + WM_CREATE = 0x0001, + WM_DELETEITEM = 0x002D, + WM_DESTROY = 0x0002, + WM_MOVE = 0x0003, + WM_SIZE = 0x0005, + WM_ACTIVATE = 0x0006, + WA_INACTIVE = 0, + WA_ACTIVE = 1, + WA_CLICKACTIVE = 2, + WM_SETFOCUS = 0x0007, + WM_KILLFOCUS = 0x0008, + WM_ENABLE = 0x000A, + WM_SETREDRAW = 0x000B, + WM_SETTEXT = 0x000C, + WM_GETTEXT = 0x000D, + WM_GETTEXTLENGTH = 0x000E, + WM_PAINT = 0x000F, + WM_CLOSE = 0x0010, + WM_QUERYENDSESSION = 0x0011, + WM_QUIT = 0x0012, + WM_QUERYOPEN = 0x0013, + WM_ERASEBKGND = 0x0014, + WM_SYSCOLORCHANGE = 0x0015, + WM_ENDSESSION = 0x0016, + WM_SHOWWINDOW = 0x0018, + WM_WININICHANGE = 0x001A, + WM_SETTINGCHANGE = 0x001A, + WM_DEVMODECHANGE = 0x001B, + WM_ACTIVATEAPP = 0x001C, + WM_FONTCHANGE = 0x001D, + WM_TIMECHANGE = 0x001E, + WM_CANCELMODE = 0x001F, + WM_SETCURSOR = 0x0020, + WM_MOUSEACTIVATE = 0x0021, + WM_CHILDACTIVATE = 0x0022, + WM_QUEUESYNC = 0x0023, + WM_GETMINMAXINFO = 0x0024, + WM_PAINTICON = 0x0026, + WM_ICONERASEBKGND = 0x0027, + WM_NEXTDLGCTL = 0x0028, + WM_SPOOLERSTATUS = 0x002A, + WM_DRAWITEM = 0x002B, + WM_MEASUREITEM = 0x002C, + WM_VKEYTOITEM = 0x002E, + WM_CHARTOITEM = 0x002F, + WM_SETFONT = 0x0030, + WM_GETFONT = 0x0031, + WM_SETHOTKEY = 0x0032, + WM_GETHOTKEY = 0x0033, + WM_QUERYDRAGICON = 0x0037, + WM_COMPAREITEM = 0x0039, + WM_GETOBJECT = 0x003D, + WM_COMPACTING = 0x0041, + WM_COMMNOTIFY = 0x0044, + WM_WINDOWPOSCHANGING = 0x0046, + WM_WINDOWPOSCHANGED = 0x0047, + WM_POWER = 0x0048, + WM_COPYDATA = 0x004A, + WM_CANCELJOURNAL = 0x004B, + WM_NOTIFY = 0x004E, + WM_INPUTLANGCHANGEREQUEST = 0x0050, + WM_INPUTLANGCHANGE = 0x0051, + WM_TCARD = 0x0052, + WM_HELP = 0x0053, + WM_USERCHANGED = 0x0054, + WM_NOTIFYFORMAT = 0x0055, + WM_CONTEXTMENU = 0x007B, + WM_STYLECHANGING = 0x007C, + WM_STYLECHANGED = 0x007D, + WM_DISPLAYCHANGE = 0x007E, + WM_GETICON = 0x007F, + WM_SETICON = 0x0080, + WM_NCCREATE = 0x0081, + WM_NCDESTROY = 0x0082, + WM_NCCALCSIZE = 0x0083, + WM_NCHITTEST = 0x0084, + WM_NCPAINT = 0x0085, + WM_NCACTIVATE = 0x0086, + WM_GETDLGCODE = 0x0087, + WM_NCMOUSEMOVE = 0x00A0, + WM_NCLBUTTONDOWN = 0x00A1, + WM_NCLBUTTONUP = 0x00A2, + WM_NCLBUTTONDBLCLK = 0x00A3, + WM_NCRBUTTONDOWN = 0x00A4, + WM_NCRBUTTONUP = 0x00A5, + WM_NCRBUTTONDBLCLK = 0x00A6, + WM_NCMBUTTONDOWN = 0x00A7, + WM_NCMBUTTONUP = 0x00A8, + WM_NCMBUTTONDBLCLK = 0x00A9, + WM_NCXBUTTONDOWN = 0x00AB, + WM_NCXBUTTONUP = 0x00AC, + WM_NCXBUTTONDBLCLK = 0x00AD, + WM_KEYFIRST = 0x0100, + WM_KEYDOWN = 0x0100, + WM_KEYUP = 0x0101, + WM_CHAR = 0x0102, + WM_DEADCHAR = 0x0103, + WM_CTLCOLOR = 0x0019, + WM_SYSKEYDOWN = 0x0104, + WM_SYSKEYUP = 0x0105, + WM_SYSCHAR = 0x0106, + WM_SYSDEADCHAR = 0x0107, + WM_KEYLAST = 0x0108, + WM_IME_STARTCOMPOSITION = 0x010D, + WM_IME_ENDCOMPOSITION = 0x010E, + WM_IME_COMPOSITION = 0x010F, + WM_IME_KEYLAST = 0x010F, + WM_INITDIALOG = 0x0110, + WM_COMMAND = 0x0111, + WM_SYSCOMMAND = 0x0112, + WM_TIMER = 0x0113, + WM_HSCROLL = 0x0114, + WM_VSCROLL = 0x0115, + WM_INITMENU = 0x0116, + WM_INITMENUPOPUP = 0x0117, + WM_MENUSELECT = 0x011F, + WM_MENUCHAR = 0x0120, + WM_ENTERIDLE = 0x0121, + WM_CHANGEUISTATE = 0x0127, + WM_UPDATEUISTATE = 0x0128, + WM_QUERYUISTATE = 0x0129, + WM_CTLCOLORMSGBOX = 0x0132, + WM_CTLCOLOREDIT = 0x0133, + WM_CTLCOLORLISTBOX = 0x0134, + WM_CTLCOLORBTN = 0x0135, + WM_CTLCOLORDLG = 0x0136, + WM_CTLCOLORSCROLLBAR = 0x0137, + WM_CTLCOLORSTATIC = 0x0138, + WM_MOUSEFIRST = 0x0200, + WM_MOUSEMOVE = 0x0200, + WM_LBUTTONDOWN = 0x0201, + WM_LBUTTONUP = 0x0202, + WM_LBUTTONDBLCLK = 0x0203, + WM_RBUTTONDOWN = 0x0204, + WM_RBUTTONUP = 0x0205, + WM_RBUTTONDBLCLK = 0x0206, + WM_MBUTTONDOWN = 0x0207, + WM_MBUTTONUP = 0x0208, + WM_MBUTTONDBLCLK = 0x0209, + WM_XBUTTONDOWN = 0x020B, + WM_XBUTTONUP = 0x020C, + WM_XBUTTONDBLCLK = 0x020D, + WM_MOUSEWHEEL = 0x020A, + WM_MOUSELAST = 0x020A, + WM_PARENTNOTIFY = 0x0210, + WM_ENTERMENULOOP = 0x0211, + WM_EXITMENULOOP = 0x0212, + WM_NEXTMENU = 0x0213, + WM_SIZING = 0x0214, + WM_CAPTURECHANGED = 0x0215, + WM_MOVING = 0x0216, + WM_POWERBROADCAST = 0x0218, + WM_DEVICECHANGE = 0x0219, + WM_IME_SETCONTEXT = 0x0281, + WM_IME_NOTIFY = 0x0282, + WM_IME_CONTROL = 0x0283, + WM_IME_COMPOSITIONFULL = 0x0284, + WM_IME_SELECT = 0x0285, + WM_IME_CHAR = 0x0286, + WM_IME_KEYDOWN = 0x0290, + WM_IME_KEYUP = 0x0291, + WM_MDICREATE = 0x0220, + WM_MDIDESTROY = 0x0221, + WM_MDIACTIVATE = 0x0222, + WM_MDIRESTORE = 0x0223, + WM_MDINEXT = 0x0224, + WM_MDIMAXIMIZE = 0x0225, + WM_MDITILE = 0x0226, + WM_MDICASCADE = 0x0227, + WM_MDIICONARRANGE = 0x0228, + WM_MDIGETACTIVE = 0x0229, + WM_MDISETMENU = 0x0230, + WM_ENTERSIZEMOVE = 0x0231, + WM_EXITSIZEMOVE = 0x0232, + WM_DROPFILES = 0x0233, + WM_MDIREFRESHMENU = 0x0234, + WM_MOUSEHOVER = 0x02A1, + WM_MOUSELEAVE = 0x02A3, + WM_CUT = 0x0300, + WM_COPY = 0x0301, + WM_PASTE = 0x0302, + WM_CLEAR = 0x0303, + WM_UNDO = 0x0304, + WM_RENDERFORMAT = 0x0305, + WM_RENDERALLFORMATS = 0x0306, + WM_DESTROYCLIPBOARD = 0x0307, + WM_DRAWCLIPBOARD = 0x0308, + WM_PAINTCLIPBOARD = 0x0309, + WM_VSCROLLCLIPBOARD = 0x030A, + WM_SIZECLIPBOARD = 0x030B, + WM_ASKCBFORMATNAME = 0x030C, + WM_CHANGECBCHAIN = 0x030D, + WM_HSCROLLCLIPBOARD = 0x030E, + WM_QUERYNEWPALETTE = 0x030F, + WM_PALETTEISCHANGING = 0x0310, + WM_PALETTECHANGED = 0x0311, + WM_HOTKEY = 0x0312, + WM_PRINT = 0x0317, + WM_PRINTCLIENT = 0x0318, + WM_HANDHELDFIRST = 0x0358, + WM_HANDHELDLAST = 0x035F, + WM_AFXFIRST = 0x0360, + WM_AFXLAST = 0x037F, + WM_PENWINFIRST = 0x0380, + WM_PENWINLAST = 0x038F, + WM_APP = unchecked((int)0x8000), + WM_USER = 0x0400, + WM_REFLECT = + WM_USER + 0x1C00, + WS_OVERLAPPED = 0x00000000, + WPF_SETMINPOSITION = 0x0001, + WM_CHOOSEFONT_GETLOGFONT = (0x0400 + 1), + + WHEEL_DELTA = 120, + DWLP_MSGRESULT = 0, + PSNRET_NOERROR = 0, + PSNRET_INVALID = 1, + PSNRET_INVALID_NOCHANGEPAGE = 2; + + public const int + PSN_APPLY = ((0 - 200) - 2), + PSN_KILLACTIVE = ((0 - 200) - 1), + PSN_RESET = ((0 - 200) - 3), + PSN_SETACTIVE = ((0 - 200) - 0); + + public const int + GMEM_MOVEABLE = 0x0002, + GMEM_ZEROINIT = 0x0040, + GMEM_DDESHARE = 0x2000; + + public const int + SWP_NOACTIVATE = 0x0010, + SWP_NOZORDER = 0x0004, + SWP_NOSIZE = 0x0001, + SWP_NOMOVE = 0x0002, + SWP_FRAMECHANGED = 0x0020; + + public const int + TVM_SETINSERTMARK = (0x1100 + 26), + TVM_GETEDITCONTROL = (0x1100 + 15); + + public const int + FILE_ATTRIBUTE_READONLY = 0x00000001; + + public const int + PSP_DEFAULT = 0x00000000, + PSP_DLGINDIRECT = 0x00000001, + PSP_USEHICON = 0x00000002, + PSP_USEICONID = 0x00000004, + PSP_USETITLE = 0x00000008, + PSP_RTLREADING = 0x00000010, + PSP_HASHELP = 0x00000020, + PSP_USEREFPARENT = 0x00000040, + PSP_USECALLBACK = 0x00000080, + PSP_PREMATURE = 0x00000400, + PSP_HIDEHEADER = 0x00000800, + PSP_USEHEADERTITLE = 0x00001000, + PSP_USEHEADERSUBTITLE = 0x00002000; + + public const int + PSH_DEFAULT = 0x00000000, + PSH_PROPTITLE = 0x00000001, + PSH_USEHICON = 0x00000002, + PSH_USEICONID = 0x00000004, + PSH_PROPSHEETPAGE = 0x00000008, + PSH_WIZARDHASFINISH = 0x00000010, + PSH_WIZARD = 0x00000020, + PSH_USEPSTARTPAGE = 0x00000040, + PSH_NOAPPLYNOW = 0x00000080, + PSH_USECALLBACK = 0x00000100, + PSH_HASHELP = 0x00000200, + PSH_MODELESS = 0x00000400, + PSH_RTLREADING = 0x00000800, + PSH_WIZARDCONTEXTHELP = 0x00001000, + PSH_WATERMARK = 0x00008000, + PSH_USEHBMWATERMARK = 0x00010000, // user pass in a hbmWatermark instead of pszbmWatermark + PSH_USEHPLWATERMARK = 0x00020000, // + PSH_STRETCHWATERMARK = 0x00040000, // stretchwatermark also applies for the header + PSH_HEADER = 0x00080000, + PSH_USEHBMHEADER = 0x00100000, + PSH_USEPAGELANG = 0x00200000, // use frame dialog template matched to page + PSH_WIZARD_LITE = 0x00400000, + PSH_NOCONTEXTHELP = 0x02000000; + + public const int + PSBTN_BACK = 0, + PSBTN_NEXT = 1, + PSBTN_FINISH = 2, + PSBTN_OK = 3, + PSBTN_APPLYNOW = 4, + PSBTN_CANCEL = 5, + PSBTN_HELP = 6, + PSBTN_MAX = 6; + + public const int + TRANSPARENT = 1, + OPAQUE = 2, + FW_BOLD = 700; + + [StructLayout(LayoutKind.Sequential)] + public struct NMHDR + { + public IntPtr hwndFrom; + public int idFrom; + public int code; + } + + /// + /// Helper class for setting the text parameters to OLECMDTEXT structures. + /// + public static class OLECMDTEXT + { + + /// + /// Flags for the OLE command text + /// + public enum OLECMDTEXTF + { + /// No flag + OLECMDTEXTF_NONE = 0, + /// The name of the command is required. + OLECMDTEXTF_NAME = 1, + /// A description of the status is required. + OLECMDTEXTF_STATUS = 2 + } + } + + /// + /// OLECMDF enums for IOleCommandTarget + /// + public enum tagOLECMDF + { + OLECMDF_SUPPORTED = 1, + OLECMDF_ENABLED = 2, + OLECMDF_LATCHED = 4, + OLECMDF_NINCHED = 8, + OLECMDF_INVISIBLE = 16 + } + + /// + /// This method takes a file URL and converts it to an absolute path. The trick here is that + /// if there is a '#' in the path, everything after this is treated as a fragment. So + /// we need to append the fragment to the end of the path. + /// + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public static string GetAbsolutePath(string fileName) + { + System.Diagnostics.Debug.Assert(fileName != null && fileName.Length > 0, "Cannot get absolute path, fileName is not valid"); + + Uri uri = new Uri(fileName); + return uri.LocalPath + uri.Fragment; + } + + /// + /// Please use this "approved" method to compare file names. + /// + public static bool IsSamePath(string file1, string file2) + { + if(file1 == null || file1.Length == 0) + { + return (file2 == null || file2.Length == 0); + } + + Uri uri1 = null; + Uri uri2 = null; + + try + { + if(!Uri.TryCreate(file1, UriKind.Absolute, out uri1) || !Uri.TryCreate(file2, UriKind.Absolute, out uri2)) + { + return false; + } + + if(uri1 != null && uri1.IsFile && uri2 != null && uri2.IsFile) + { + return 0 == String.Compare(uri1.LocalPath, uri2.LocalPath, StringComparison.OrdinalIgnoreCase); + } + + return file1 == file2; + } + catch(UriFormatException e) + { + Trace.WriteLine("Exception " + e.Message); + } + + return false; + } + + [ComImport(), Guid("9BDA66AE-CA28-4e22-AA27-8A7218A0E3FA"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + public interface IEventHandler + { + + // converts the underlying codefunction into an event handler for the given event + // if the given event is NULL, then the function will handle no events + [PreserveSig] + int AddHandler(string bstrEventName); + + [PreserveSig] + int RemoveHandler(string bstrEventName); + + IVsEnumBSTR GetHandledEvents(); + + bool HandlesEvent(string bstrEventName); + } + + [ComImport(), Guid("A55CCBCC-7031-432d-B30A-A68DE7BDAD75"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + public interface IParameterKind + { + + void SetParameterPassingMode(PARAMETER_PASSING_MODE ParamPassingMode); + void SetParameterArrayDimensions(int uDimensions); + int GetParameterArrayCount(); + int GetParameterArrayDimensions(int uIndex); + int GetParameterPassingMode(); + } + + public enum PARAMETER_PASSING_MODE + { + cmParameterTypeIn = 1, + cmParameterTypeOut = 2, + cmParameterTypeInOut = 3 + } + + [ + ComImport, ComVisible(true), Guid("3E596484-D2E4-461a-A876-254C4F097EBB"), + InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown) + ] + public interface IMethodXML + { + // Generate XML describing the contents of this function's body. + void GetXML(ref string pbstrXML); + + // Parse the incoming XML with respect to the CodeModel XML schema and + // use the result to regenerate the body of the function. + // + [PreserveSig] + int SetXML(string pszXML); + + // This is really a textpoint + [PreserveSig] + int GetBodyPoint([MarshalAs(UnmanagedType.Interface)]out object bodyPoint); + } + + [ComImport(), Guid("EA1A87AD-7BC5-4349-B3BE-CADC301F17A3"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + public interface IVBFileCodeModelEvents + { + + [PreserveSig] + int StartEdit(); + + [PreserveSig] + int EndEdit(); + } + + ///-------------------------------------------------------------------------- + /// ICodeClassBase: + ///-------------------------------------------------------------------------- + [GuidAttribute("23BBD58A-7C59-449b-A93C-43E59EFC080C")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport()] + public interface ICodeClassBase + { + [PreserveSig()] + int GetBaseName(out string pBaseName); + } + + public const ushort CF_HDROP = 15; // winuser.h + public const uint MK_CONTROL = 0x0008; //winuser.h + public const uint MK_SHIFT = 0x0004; + public const int MAX_PATH = 260; // windef.h + + /// + /// Specifies options for a bitmap image associated with a task item. + /// + public enum VSTASKBITMAP + { + BMP_COMPILE = -1, + BMP_SQUIGGLE = -2, + BMP_COMMENT = -3, + BMP_SHORTCUT = -4, + BMP_USER = -5 + }; + + public const int ILD_NORMAL = 0x0000, + ILD_TRANSPARENT = 0x0001, + ILD_MASK = 0x0010, + ILD_ROP = 0x0040; + + /// + /// Defines the values that are not supported by the System.Environment.SpecialFolder enumeration + /// + [ComVisible(true)] + public enum ExtendedSpecialFolder + { + /// + /// Identical to CSIDL_COMMON_STARTUP + /// + CommonStartup = 0x0018, + + /// + /// Identical to CSIDL_WINDOWS + /// + Windows = 0x0024, + } + + + // APIS + + /// + /// Changes the parent window of the specified child window. + /// + /// Handle to the child window. + /// Handle to the new parent window. If this parameter is NULL, the desktop window becomes the new parent window. + /// A handle to the previous parent window indicates success. NULL indicates failure. + [DllImport("User32", ExactSpelling = true, CharSet = CharSet.Auto)] + public static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent); + + [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)] + public static extern bool DestroyIcon(IntPtr handle); + + [DllImport("user32.dll", EntryPoint = "IsDialogMessageA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + public static extern bool IsDialogMessageA(IntPtr hDlg, ref MSG msg); + + /// + /// Indicates whether the file type is binary or not + /// + /// Full path to the file to check + /// If file isbianry the bitness of the app is indicated by lpBinaryType value. + /// True if the file is binary false otherwise + [DllImport("kernel32.dll")] + public static extern bool GetBinaryType([MarshalAs(UnmanagedType.LPWStr)]string lpApplicationName, out uint lpBinaryType); + + } +} + diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourceNode.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourceNode.cs index 123e9814..1b126f3d 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourceNode.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourceNode.cs @@ -27,6 +27,7 @@ using System.Xml.Linq; using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; +using VsMenus = Microsoft.VisualStudio.Shell.VsMenus; using Microsoft.VisualStudio.Project; using Microsoft.VisualStudio.Shell.Interop; @@ -119,10 +120,10 @@ protected override NodeProperties CreatePropertiesObject() /// The automation object for the node public override object GetAutomationObject() { - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) + if(this.ProjectManager == null || this.ProjectManager.IsClosed) return null; - return new OADocumentationSourceItem(this.ProjectMgr.GetAutomationObject() + return new OADocumentationSourceItem(this.ProjectManager.GetAutomationObject() as OASandcastleBuilderProject, this); } @@ -142,7 +143,7 @@ public override string GetEditLabel() /// Returns the handle to the icon to use for the node public override object GetIconHandle(bool open) { - return this.ProjectMgr.ImageHandler.GetIconHandle(this.ProjectMgr.ImageIndex + + return this.ProjectManager.ImageHandler.GetIconHandle(this.ProjectManager.ImageIndex + (int)ProjectImageIndex.DocumentationSource); } @@ -151,7 +152,7 @@ public override object GetIconHandle(bool open) /// to specify the item moniker. /// /// The moniker for this item - public override string GetMkDocument() + public override string GetMKDocument() { return this.Url; } @@ -160,7 +161,7 @@ public override string GetMkDocument() /// This is overridden to prevent the node from being dragged /// /// Always returns null - protected internal override StringBuilder PrepareSelectedNodesForClipBoard() + public override StringBuilder PrepareSelectedNodesForClipboard() { return null; } @@ -191,7 +192,7 @@ protected override bool CanDeleteItem(__VSDELETEITEMOPERATION deleteOperation) /// operations. /// /// The documentation sources parent node - protected internal override HierarchyNode GetDragTargetHandlerNode() + public override HierarchyNode GetDragTargetHandlerNode() { return this.Parent; } diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourceNodeProperties.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourceNodeProperties.cs index 1362888c..d588434d 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourceNodeProperties.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourceNodeProperties.cs @@ -30,6 +30,7 @@ using Microsoft.VisualStudio; using Microsoft.VisualStudio.Project; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; using SandcastleBuilder.Package.Properties; using SandcastleBuilder.Utils; @@ -182,7 +183,7 @@ public bool IncludeSubFolders /// private void CheckProjectIsEditable() { - if(!base.Node.ProjectMgr.QueryEditProjectFile(false)) + if(!base.Node.ProjectManager.QueryEditProjectFile(false)) throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } @@ -228,7 +229,7 @@ private void StoreDocumentationSourceChanges() ((DocumentationSourcesContainerNode)base.Node.Parent).StoreDocumentationSources(); - this.Node.ReDraw(UIHierarchyElement.Caption); + this.Node.Redraw(UIHierarchyElements.Caption); } /// @@ -306,7 +307,7 @@ string IBasePathProvider.BasePath { get { - return Path.GetDirectoryName(this.Node.ProjectMgr.BuildProject.FullPath); + return Path.GetDirectoryName(this.Node.ProjectManager.BuildProject.FullPath); } } @@ -328,7 +329,7 @@ string IBasePathProvider.ResolvePath(string path) /// The string to use as the replacement private string OnBuildVarMatch(Match match) { - return (this.Node.ProjectMgr.GetProjectProperty(match.Groups[1].Value) ?? String.Empty); + return (this.Node.ProjectManager.GetProjectProperty(match.Groups[1].Value, _PersistStorageType.PST_PROJECT_FILE) ?? String.Empty); } #endregion } diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourcesContainerNode.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourcesContainerNode.cs index a185bdba..e74bc421 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourcesContainerNode.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/DocumentationSourcesContainerNode.cs @@ -34,6 +34,9 @@ using Microsoft.VisualStudio.Project; using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; +using vsCommandStatus = EnvDTE.vsCommandStatus; +using VsMenus = Microsoft.VisualStudio.Shell.VsMenus; +using OLECMDEXECOPT = Microsoft.VisualStudio.OLE.Interop.OLECMDEXECOPT; using Microsoft.VisualStudio; @@ -81,7 +84,7 @@ public override int SortPriority /// shows up. public override int MenuCommandId { - get { return Microsoft.VisualStudio.Project.VsMenus.IDM_VS_CTXT_REFERENCE; } + get { return VsMenus.IDM_VS_CTXT_REFERENCE; } } /// @@ -138,12 +141,12 @@ public DocumentationSourcesContainerNode(ProjectNode root) : base(root) public void StoreDocumentationSources() { // Check out the project file if necessary - if(!this.ProjectMgr.QueryEditProjectFile(false)) + if(!this.ProjectManager.QueryEditProjectFile(false)) throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); var reader = documentationSources.CreateReader(); reader.MoveToContent(); - this.ProjectMgr.SetProjectProperty("DocumentationSources", reader.ReadInnerXml()); + this.ProjectManager.SetProjectProperty("DocumentationSources", _PersistStorageType.PST_PROJECT_FILE, reader.ReadInnerXml()); } /// @@ -154,7 +157,7 @@ public void LoadDocSourcesFromBuildProject() ProjectProperty prop; string docSources = null; - prop = prop = this.ProjectMgr.BuildProject.GetProperty("DocumentationSources"); + prop = prop = this.ProjectManager.BuildProject.GetProperty("DocumentationSources"); if(prop != null) docSources = prop.UnevaluatedValue; @@ -165,7 +168,7 @@ public void LoadDocSourcesFromBuildProject() documentationSources = XDocument.Parse("" + docSources + ""); foreach(var ds in documentationSources.Root.Descendants()) - this.AddChild(new DocumentationSourceNode(this.ProjectMgr, ds)); + this.AddChild(new DocumentationSourceNode(this.ProjectManager, ds)); } /// @@ -178,7 +181,7 @@ private void AddDocumentationSources() string ext, otherFile; // Check out the project file if necessary - if(!this.ProjectMgr.QueryEditProjectFile(false)) + if(!this.ProjectManager.QueryEditProjectFile(false)) throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); using(OpenFileDialog dlg = new OpenFileDialog()) @@ -189,7 +192,7 @@ private void AddDocumentationSources() "Library Files (*.dll, *.winmd)|*.dll;*.winmd|Executable Files (*.exe)|*.exe|" + "XML Comments Files (*.xml)|*.xml|Visual Studio Solution Files (*.sln)|*.sln|" + "Visual Studio Project Files (*.*proj)|*.*proj|All Files (*.*)|*.*"; - dlg.InitialDirectory = this.ProjectMgr.ProjectFolder; + dlg.InitialDirectory = this.ProjectManager.ProjectFolder; dlg.DefaultExt = "dll"; dlg.Multiselect = true; @@ -261,7 +264,7 @@ internal void AddDocumentationSource(string filename) { // Default to using a relative path based on the project folder filename = FolderPath.AbsoluteToRelativePath( - Path.GetDirectoryName(this.ProjectMgr.BuildProject.FullPath), filename); + Path.GetDirectoryName(this.ProjectManager.BuildProject.FullPath), filename); XElement docSource = new XElement("DocumentationSource", new XAttribute("sourceFile", filename)); @@ -269,7 +272,7 @@ internal void AddDocumentationSource(string filename) d => d.Attribute("sourceFile").Value.Equals(filename, StringComparison.OrdinalIgnoreCase))) { documentationSources.Root.Add(docSource); - this.AddChild(new DocumentationSourceNode(this.ProjectMgr, docSource)); + this.AddChild(new DocumentationSourceNode(this.ProjectManager, docSource)); } } #endregion @@ -283,10 +286,10 @@ internal void AddDocumentationSource(string filename) /// The automation object for the node public override object GetAutomationObject() { - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) + if(this.ProjectManager == null || this.ProjectManager.IsClosed) return null; - return new OADocSourcesFolderItem(this.ProjectMgr.GetAutomationObject() + return new OADocSourcesFolderItem(this.ProjectManager.GetAutomationObject() as OASandcastleBuilderProject, this); } @@ -307,7 +310,7 @@ public override string GetEditLabel() /// Returns the handle to the icon to use for the node public override object GetIconHandle(bool open) { - return this.ProjectMgr.ImageHandler.GetIconHandle(this.ProjectMgr.ImageIndex + (open ? + return this.ProjectManager.ImageHandler.GetIconHandle(this.ProjectManager.ImageIndex + (open ? (int)ProjectImageIndex.DocumentationSourcesOpen : (int)ProjectImageIndex.DocumentationSourcesClosed)); } @@ -316,7 +319,7 @@ public override object GetIconHandle(bool open) /// This is overridden to prevent the node from being dragged /// /// Always returns null - protected internal override StringBuilder PrepareSelectedNodesForClipBoard() + public override StringBuilder PrepareSelectedNodesForClipboard() { return null; } @@ -347,17 +350,17 @@ protected override int ExcludeFromProject() /// If the method succeeds, it returns S_OK. If it /// fails, it returns an error code. protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, - ref QueryStatusResult result) + ref vsCommandStatus result) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && cmd == PkgCmdIDList.AddDocSource) { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; + result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } if(cmdGroup == VsMenus.guidStandardCommandSet97 && (VsCommands)cmd == VsCommands.PropSheetOrProperties) { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; + result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusInvisible; return VSConstants.S_OK; } @@ -377,7 +380,7 @@ protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdTex /// output. It can be null. /// If the method succeeds, it returns S_OK. If it /// fails, it returns an error code. - protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, + protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && (int)cmd == PkgCmdIDList.AddDocSource) diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/ProjectPropertiesContainerNode.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/ProjectPropertiesContainerNode.cs index 1c0db8de..34378122 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/ProjectPropertiesContainerNode.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/ProjectPropertiesContainerNode.cs @@ -27,8 +27,11 @@ using Microsoft.Build.Evaluation; using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Project; +using OLECMDEXECOPT = Microsoft.VisualStudio.OLE.Interop.OLECMDEXECOPT; using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; +using vsCommandStatus = EnvDTE.vsCommandStatus; +using VsMenus = Microsoft.VisualStudio.Shell.VsMenus; using WindowCommandIds = Microsoft.VisualStudio.VSConstants.VsUIHierarchyWindowCmdIds; using Microsoft.VisualStudio; @@ -73,7 +76,7 @@ public override int SortPriority /// shows up. public override int MenuCommandId { - get { return Microsoft.VisualStudio.Project.VsMenus.IDM_VS_CTXT_REFERENCE; } + get { return VsMenus.IDM_VS_CTXT_REFERENCE; } } /// @@ -138,7 +141,7 @@ public override string GetEditLabel() /// Returns the handle to the icon to use for the node public override object GetIconHandle(bool open) { - return this.ProjectMgr.ImageHandler.GetIconHandle(this.ProjectMgr.ImageIndex + + return this.ProjectManager.ImageHandler.GetIconHandle(this.ProjectManager.ImageIndex + (int)ProjectImageIndex.ProjectProperties); } @@ -146,7 +149,7 @@ public override object GetIconHandle(bool open) /// This is overridden to prevent the node from being dragged /// /// Always returns null - protected internal override StringBuilder PrepareSelectedNodesForClipBoard() + public override StringBuilder PrepareSelectedNodesForClipboard() { return null; } @@ -177,11 +180,11 @@ protected override int ExcludeFromProject() /// If the method succeeds, it returns S_OK. If it /// fails, it returns an error code. protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, - ref QueryStatusResult result) + ref vsCommandStatus result) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && cmd == PkgCmdIDList.AddDocSource) { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; + result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusInvisible; return VSConstants.S_OK; } @@ -201,7 +204,7 @@ protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdTex /// output. It can be null. /// If the method succeeds, it returns S_OK. If it /// fails, it returns an error code. - protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, + protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { // Open the Project Properties window when double-clicked or Properties is selected @@ -211,7 +214,7 @@ protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexeco IntPtr ip = (IntPtr)(-1); IVsWindowFrame frame = null; - ((IVsProject2)this.ProjectMgr).ReopenItem(VSConstants.VSITEMID_ROOT, + ((IVsProject2)this.ProjectManager).ReopenItem(VSConstants.VSITEMID_ROOT, VSConstants.GUID_ProjectDesignerEditor, null, Guid.Empty, ip, out frame); return VSConstants.S_OK; diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderAssemblyReferenceNode.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderAssemblyReferenceNode.cs index 4698edec..eceab953 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderAssemblyReferenceNode.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderAssemblyReferenceNode.cs @@ -25,6 +25,7 @@ using Microsoft.VisualStudio; using Microsoft.VisualStudio.Project; +using vsCommandStatus = EnvDTE.vsCommandStatus; namespace SandcastleBuilder.Package.Nodes { @@ -72,11 +73,11 @@ public override Guid ItemTypeGuid /// protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, - ref QueryStatusResult result) + ref vsCommandStatus result) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && cmd == PkgCmdIDList.AddDocSource) { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; + result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusInvisible; return VSConstants.S_OK; } @@ -88,7 +89,7 @@ protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdTex /// operations. /// /// The documentation sources parent node - protected internal override HierarchyNode GetDragTargetHandlerNode() + public override HierarchyNode GetDragTargetHandlerNode() { return this.Parent; } diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderComReferenceNode.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderComReferenceNode.cs index abf0cbad..dc05c345 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderComReferenceNode.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderComReferenceNode.cs @@ -26,6 +26,7 @@ using Microsoft.VisualStudio; using Microsoft.VisualStudio.Project; using Microsoft.VisualStudio.Shell.Interop; +using vsCommandStatus = EnvDTE.vsCommandStatus; namespace SandcastleBuilder.Package.Nodes { @@ -73,11 +74,11 @@ public override Guid ItemTypeGuid /// protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, - ref QueryStatusResult result) + ref vsCommandStatus result) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && cmd == PkgCmdIDList.AddDocSource) { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; + result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusInvisible; return VSConstants.S_OK; } @@ -89,7 +90,7 @@ protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdTex /// operations. /// /// The documentation sources parent node - protected internal override HierarchyNode GetDragTargetHandlerNode() + public override HierarchyNode GetDragTargetHandlerNode() { return this.Parent; } diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderFileNode.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderFileNode.cs index 61d4b2ae..3c396055 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderFileNode.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderFileNode.cs @@ -27,6 +27,8 @@ using Microsoft.VisualStudio; using Microsoft.VisualStudio.Project; using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; +using vsCommandStatus = EnvDTE.vsCommandStatus; +using VsMenus = Microsoft.VisualStudio.Shell.VsMenus; namespace SandcastleBuilder.Package.Nodes { @@ -63,7 +65,7 @@ public SandcastleBuilderFileNode(SandcastleBuilderProjectNode root, ProjectEleme /// object. protected override NodeProperties CreatePropertiesObject() { - if(this.IsNonMemberItem) + if(this.IsNonmemberItem) return new FileNodeProperties(this); return new SandcastleBuilderFileNodeProperties(this); @@ -109,14 +111,14 @@ public override object GetIconHandle(bool open) break; case ".xamlcfg": // Use the default XML file icon - return this.ProjectMgr.ImageHandler.GetIconHandle((int)ProjectNode.ImageName.XMLFile); + return this.ProjectManager.ImageHandler.GetIconHandle((int)ImageName.XmlFile); default: break; } if(index != HierarchyNode.NoImage) - return this.ProjectMgr.ImageHandler.GetIconHandle(this.ProjectMgr.ImageIndex + index); + return this.ProjectManager.ImageHandler.GetIconHandle(this.ProjectManager.ImageIndex + index); } return base.GetIconHandle(open); @@ -124,11 +126,11 @@ public override object GetIconHandle(bool open) /// protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, - ref QueryStatusResult result) + ref vsCommandStatus result) { if(cmdGroup == VsMenus.guidStandardCommandSet97 && (VsCommands)cmd == VsCommands.ViewCode) { - result |= QueryStatusResult.INVISIBLE | QueryStatusResult.SUPPORTED; + result |= vsCommandStatus.vsCommandStatusInvisible | vsCommandStatus.vsCommandStatusSupported; return VSConstants.S_OK; } diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderFileNodeProperties.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderFileNodeProperties.cs index ce247b5d..25f440c7 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderFileNodeProperties.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderFileNodeProperties.cs @@ -43,19 +43,6 @@ public sealed class SandcastleBuilderFileNodeProperties : FileNodeProperties { #region Hidden properties //===================================================================== - - /// - /// This is overridden to hide the default build action property since the help file builder - /// supports several other build actions. - /// - /// Use instead. - [Browsable(false), AutomationBrowsable(false)] - public override BuildAction BuildAction - { - get { return base.BuildAction; } - set { base.BuildAction = value; } - } - /// /// The URL of the item /// @@ -77,8 +64,7 @@ public string URL /// /// This is used to get or set the Sandcastle Help File Builder build action /// - [Category("Advanced"), DisplayName("Build Action"), Description("The build action for this item"), - RefreshProperties(RefreshProperties.All), PropertyPageTypeConverter(typeof(BuildActionEnumConverter))] + [Browsable(false)] public SandcastleBuildAction SandcastleBuildAction { get @@ -227,7 +213,7 @@ public int SortOrder /// Constructor /// /// The node that contains the properties to expose via the Property Browser. - public SandcastleBuilderFileNodeProperties(HierarchyNode node) : base(node) + public SandcastleBuilderFileNodeProperties(FileNode node) : base(node) { } #endregion diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNode.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNode.cs index e01fd28d..322da0ab 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNode.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNode.cs @@ -38,10 +38,12 @@ using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; using IOleDataObject = Microsoft.VisualStudio.OLE.Interop.IDataObject; +using OLECMDEXECOPT = Microsoft.VisualStudio.OLE.Interop.OLECMDEXECOPT; using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; -using VsMenus = Microsoft.VisualStudio.Project.VsMenus; +using vsCommandStatus = EnvDTE.vsCommandStatus; +using VsMenus = Microsoft.VisualStudio.Shell.VsMenus; using SandcastleBuilder.Package.Automation; using SandcastleBuilder.Package.Properties; @@ -106,7 +108,7 @@ public override int ImageIndex /// /// The drop target node ID /// True if the drop can occur, false if not - protected internal override bool CanTargetNodeAcceptDrop(uint itemId) + public override bool CanTargetNodeAcceptDrop(uint itemId) { HierarchyNode targetNode = NodeFromItemId(itemId); @@ -143,9 +145,8 @@ public SandcastleProject SandcastleProject /// The package to which the project node is /// related. public SandcastleBuilderProjectNode(ProjectPackage package) + : base(package) { - this.Package = package; - // Add the project node images imageIndex = this.ImageHandler.ImageList.Images.Count; @@ -173,22 +174,22 @@ private void InitializeCATIDs() { // The following properties classes are specific to Sandcastle // Builder so we can use their GUIDs directly. - base.AddCATIDMapping(typeof(SandcastleBuilderProjectNodeProperties), + base.AddCatIdMapping(typeof(SandcastleBuilderProjectNodeProperties), typeof(SandcastleBuilderProjectNodeProperties).GUID); - base.AddCATIDMapping(typeof(SandcastleBuilderFileNodeProperties), + base.AddCatIdMapping(typeof(SandcastleBuilderFileNodeProperties), typeof(SandcastleBuilderFileNodeProperties).GUID); - base.AddCATIDMapping(typeof(DocumentationSourceNodeProperties), + base.AddCatIdMapping(typeof(DocumentationSourceNodeProperties), typeof(DocumentationSourceNodeProperties).GUID); // The following are not specific to Sandcastle Builder and as such we need a separate GUID // (we simply used guidgen.exe to create new guids). - base.AddCATIDMapping(typeof(ProjectNodeProperties), new Guid("CD4A4A5D-345C-4faf-9BDC-AB3F04DEE02F")); - base.AddCATIDMapping(typeof(FolderNodeProperties), new Guid("9D0F0FAA-F7B1-43ee-A8CF-046B80F2384B")); - base.AddCATIDMapping(typeof(ReferenceNodeProperties), new Guid("0B6EF0B6-8699-470d-A8A1-16F745810073")); - base.AddCATIDMapping(typeof(ProjectReferencesProperties), new Guid("C67FE7AC-629F-458e-A3B9-597E69C4C41D")); + base.AddCatIdMapping(typeof(ProjectNodeProperties), new Guid("CD4A4A5D-345C-4faf-9BDC-AB3F04DEE02F")); + base.AddCatIdMapping(typeof(FolderNodeProperties), new Guid("9D0F0FAA-F7B1-43ee-A8CF-046B80F2384B")); + base.AddCatIdMapping(typeof(ReferenceNodeProperties), new Guid("0B6EF0B6-8699-470d-A8A1-16F745810073")); + base.AddCatIdMapping(typeof(ProjectReferencesProperties), new Guid("C67FE7AC-629F-458e-A3B9-597E69C4C41D")); // This one we use the same as Sandcastle Builder file nodes since both refer to files - base.AddCATIDMapping(typeof(FileNodeProperties), typeof(SandcastleBuilderFileNodeProperties).GUID); + base.AddCatIdMapping(typeof(FileNodeProperties), typeof(SandcastleBuilderFileNodeProperties).GUID); } /// @@ -198,7 +199,7 @@ private void InitializeCATIDs() /// The command for which to query the status /// An out parameter specifying the QueryStatusResult of the command. /// Returns true if handled, false if not. - private static bool QueryStatusOnCommonCommands(Guid cmdGroup, uint cmd, ref QueryStatusResult result) + private static bool QueryStatusOnCommonCommands(Guid cmdGroup, uint cmd, ref vsCommandStatus result) { if(cmdGroup == VsMenus.guidStandardCommandSet97) { @@ -214,7 +215,7 @@ private static bool QueryStatusOnCommonCommands(Guid cmdGroup, uint cmd, ref Que case VsCommands.ToolboxAddItem: case VsCommands.ToolsDebugProcesses: case VsCommands.ToggleBreakpoint: - result |= QueryStatusResult.INVISIBLE | QueryStatusResult.SUPPORTED; + result |= vsCommandStatus.vsCommandStatusInvisible | vsCommandStatus.vsCommandStatusSupported; return true; } } @@ -225,7 +226,7 @@ private static bool QueryStatusOnCommonCommands(Guid cmdGroup, uint cmd, ref Que { case VsCommands2K.PROJSTARTDEBUG: case VsCommands2K.PROJSTEPINTO: - result |= QueryStatusResult.INVISIBLE | QueryStatusResult.SUPPORTED; + result |= vsCommandStatus.vsCommandStatusInvisible | vsCommandStatus.vsCommandStatusSupported; return true; } } @@ -413,7 +414,7 @@ private DropDataType HandleSelectionDataObject(IOleDataObject dataObject, Hierar targetNode = this; // Try to get it as a directory based project - List filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSSTGPROJECTITEMS, + IList filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSSTGPROJECTITEMS, dataObject, out dropDataType); if(filesDropped.Count == 0) @@ -491,7 +492,7 @@ private DropDataType HandleSelectionDataObject(IOleDataObject dataObject, Hierar string hintPath = f; if(Path.IsPathRooted(hintPath)) - hintPath = PackageUtilities.GetPathDistance(this.ProjectMgr.BaseURI.Uri, + hintPath = PackageUtilities.GetPathDistance(this.ProjectManager.BaseUri.Uri, new Uri(hintPath)); node.ItemNode.SetMetadata(ProjectFileConstants.Name, null); @@ -518,7 +519,7 @@ private DropDataType HandleSelectionDataObject(IOleDataObject dataObject, Hierar VSADDRESULT[] vsaddresults = new VSADDRESULT[1]; vsaddresults[0] = VSADDRESULT.ADDRESULT_Failure; - int addResult = this.AddItem(targetNode.ID, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, + int addResult = this.AddItem(targetNode.Id, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, (uint)filesDropped.Count, filesDroppedAsArray, IntPtr.Zero, vsaddresults); if(addResult != VSConstants.S_OK && addResult != VSConstants.S_FALSE && @@ -576,7 +577,7 @@ protected override void Dispose(bool disposing) public override int UpgradeProject(uint grfUpgradeFlags) { Version schemaVersion; - string propertyValue = base.GetProjectProperty("SHFBSchemaVersion"); + string propertyValue = base.GetProjectProperty("SHFBSchemaVersion", _PersistStorageType.PST_PROJECT_FILE); if(String.IsNullOrEmpty(propertyValue) || !Version.TryParse(propertyValue, out schemaVersion) || schemaVersion > SandcastleProject.SchemaVersion) @@ -626,7 +627,7 @@ protected override NodeProperties CreatePropertiesObject() /// The path to the folder /// The project element /// A reference to the folder node - protected internal override FolderNode CreateFolderNode(string path, ProjectElement element) + public override FolderNode CreateFolderNode(string path, ProjectElement element) { string fullPath = Path.Combine(this.ProjectFolder, path); @@ -700,12 +701,12 @@ public override int GetFormatList(out string ppszFormatList) /// The file to be added /// A ProjectElement describing the newly added file /// Appropriate metadata is added based on the file's extension - protected internal override ProjectElement AddFileToMsBuild(string file) + public override ProjectElement AddFileToMSBuild(string file) { SandcastleBuildAction buildAction = SandcastleProject.DefaultBuildAction(file); string itemPath = PackageUtilities.MakeRelative(base.FileName, file); - ProjectElement newItem = this.CreateMsBuildFileItem(itemPath, buildAction.ToString()); + ProjectElement newItem = this.CreateMSBuildFileItem(itemPath, buildAction.ToString()); // Set the default ID and alternate text if it is an Image element if(buildAction == SandcastleBuildAction.Image) @@ -728,7 +729,7 @@ public override FileNode CreateFileNode(ProjectElement item) /// This is overridden as a convenient place to create and load the project properties and documentation /// sources node. It is also used to set the SHFBROOT environment variable if overridden locally. /// - protected internal override void LoadNonBuildInformation() + public override void LoadNonBuildInformation() { try { @@ -741,7 +742,7 @@ protected internal override void LoadNonBuildInformation() // GUI instead. if(String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("SHFBROOT"))) { - var prop = this.ProjectMgr.BuildProject.GetProperty("SHFBROOT"); + var prop = this.ProjectManager.BuildProject.GetProperty("SHFBROOT"); // This will remain in effect for the duration of the process including for projects loaded // after this one that don't override it locally. A restart will reset it. @@ -752,7 +753,7 @@ protected internal override void LoadNonBuildInformation() if(!String.IsNullOrWhiteSpace(path)) { if(!Path.IsPathRooted(path)) - path = Path.Combine(Path.GetDirectoryName(this.ProjectMgr.BuildProject.FullPath), + path = Path.Combine(Path.GetDirectoryName(this.ProjectManager.BuildProject.FullPath), path); Environment.SetEnvironmentVariable("SHFBROOT", path); @@ -804,9 +805,9 @@ protected internal override void LoadNonBuildInformation() } /// - protected override QueryStatusResult QueryStatusCommandFromOleCommandTarget(Guid cmdGroup, uint cmd, out bool handled) + protected override vsCommandStatus QueryStatusCommandFromOleCommandTarget(Guid cmdGroup, uint cmd, out bool handled) { - QueryStatusResult result = QueryStatusResult.NOTSUPPORTED; + vsCommandStatus result = vsCommandStatus.vsCommandStatusUnsupported; if(QueryStatusOnCommonCommands(cmdGroup, cmd, ref result)) { @@ -819,15 +820,15 @@ protected override QueryStatusResult QueryStatusCommandFromOleCommandTarget(Guid /// protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, - ref QueryStatusResult result) + ref vsCommandStatus result) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && (cmd == PkgCmdIDList.OpenInStandaloneGUI || cmd == PkgCmdIDList.ViewBuildLog)) { - result |= QueryStatusResult.SUPPORTED; + result |= vsCommandStatus.vsCommandStatusSupported; if(!base.BuildInProgress) - result |= QueryStatusResult.ENABLED; + result |= vsCommandStatus.vsCommandStatusEnabled; return VSConstants.S_OK; } @@ -839,7 +840,7 @@ protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdTex } /// - protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, + protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, OLECMDEXECOPT nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet) @@ -864,9 +865,10 @@ protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexeco /// This is overridden to set the Verbose Logging build option /// /// The configuration to use - protected internal override void SetConfiguration(string config) + /// The platform to use + public override void SetConfiguration(string config, string platform) { - base.SetConfiguration(config); + base.SetConfiguration(config, platform); var package = (SandcastleBuilderPackage)this.Package; var options = package.GeneralOptions; @@ -877,14 +879,14 @@ protected internal override void SetConfiguration(string config) } /// - public override MSBuildResult Build(uint vsopts, string config, IVsOutputWindowPane output, string target) + public override MSBuildResult Build(uint vsopts, string config, string platform, IVsOutputWindowPane output, string target) { // TODO: Opening the Tools menu during a build fails because it executes a build for the AllProjectOutputs group. // Don't know why yet. Is this the best workaround? if(base.BuildInProgress) return MSBuildResult.Successful; - return base.Build(vsopts, config, output, target); + return base.Build(vsopts, config, platform, output, target); } /// @@ -932,7 +934,7 @@ public override int AddComponent(VSADDCOMPOPERATION dwAddCompOperation, uint cCo string hintPath = selectorData.bstrFile; if(Path.IsPathRooted(hintPath)) - hintPath = PackageUtilities.GetPathDistance(this.ProjectMgr.BaseURI.Uri, new Uri(hintPath)); + hintPath = PackageUtilities.GetPathDistance(this.ProjectManager.BaseUri.Uri, new Uri(hintPath)); node.ItemNode.SetMetadata(ProjectFileConstants.Name, null); node.ItemNode.SetMetadata(ProjectFileConstants.AssemblyName, null); @@ -948,14 +950,14 @@ public override int AddComponent(VSADDCOMPOPERATION dwAddCompOperation, uint cCo /// This is overridden to handle drop operations correctly in a help file builder project /// /// - public override int Drop(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect) + public override int Drop(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref DropEffects pdwEffect) { DropDataType dropDataType = DropDataType.None; if(pDataObject == null) return VSConstants.E_INVALIDARG; - pdwEffect = (uint)DropEffect.None; + pdwEffect = DropEffects.None; // If the source is within the project, let the base class handle it if(this.SourceDraggedOrCutOrCopied) @@ -973,7 +975,7 @@ public override int Drop(IOleDataObject pDataObject, uint grfKeyState, uint item // Since we can get a mix of files that may not necessarily be moved into the project (i.e. // documentation sources and references), we'll always act as if they were copied. - pdwEffect = (uint)DropEffect.Copy; + pdwEffect = DropEffects.Copy; return (dropDataType != DropDataType.Shell) ? VSConstants.E_FAIL : VSConstants.S_OK; } diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNodeProperties.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNodeProperties.cs index 5320fc46..6420e94f 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNodeProperties.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNodeProperties.cs @@ -25,6 +25,7 @@ using System.Runtime.InteropServices; using Microsoft.VisualStudio.Project; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; namespace SandcastleBuilder.Package.Nodes { @@ -51,11 +52,11 @@ public string TargetFramework { get { - return this.Node.ProjectMgr.GetProjectProperty("TargetFramework"); + return this.Node.ProjectManager.GetProjectProperty("TargetFramework", _PersistStorageType.PST_PROJECT_FILE); } set { - this.Node.ProjectMgr.SetProjectProperty("TargetFramework", value); + this.Node.ProjectManager.SetProjectProperty("TargetFramework", _PersistStorageType.PST_PROJECT_FILE, value); } } @@ -69,11 +70,11 @@ public string AssemblyName { get { - return this.Node.ProjectMgr.GetProjectProperty(ProjectFileConstants.AssemblyName); + return this.Node.ProjectManager.GetProjectProperty(ProjectFileConstants.AssemblyName, _PersistStorageType.PST_PROJECT_FILE); } set { - this.Node.ProjectMgr.SetProjectProperty(ProjectFileConstants.AssemblyName, value); + this.Node.ProjectManager.SetProjectProperty(ProjectFileConstants.AssemblyName, _PersistStorageType.PST_PROJECT_FILE, value); } } @@ -87,11 +88,11 @@ public string RootNamespace { get { - return this.Node.ProjectMgr.GetProjectProperty(ProjectFileConstants.RootNamespace); + return this.Node.ProjectManager.GetProjectProperty(ProjectFileConstants.RootNamespace, _PersistStorageType.PST_PROJECT_FILE); } set { - this.Node.ProjectMgr.SetProjectProperty(ProjectFileConstants.RootNamespace, value); + this.Node.ProjectManager.SetProjectProperty(ProjectFileConstants.RootNamespace, _PersistStorageType.PST_PROJECT_FILE, value); } } #endregion diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectReferenceNodes.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectReferenceNodes.cs index 86f1d69f..526fb9ba 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectReferenceNodes.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectReferenceNodes.cs @@ -25,6 +25,7 @@ using Microsoft.VisualStudio; using Microsoft.VisualStudio.Project; +using vsCommandStatus = EnvDTE.vsCommandStatus; namespace SandcastleBuilder.Package.Nodes { @@ -75,11 +76,11 @@ public override Guid ItemTypeGuid /// protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, - ref QueryStatusResult result) + ref vsCommandStatus result) { if(cmdGroup == GuidList.guidSandcastleBuilderPackageCmdSet && cmd == PkgCmdIDList.AddDocSource) { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; + result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusInvisible; return VSConstants.S_OK; } @@ -91,7 +92,7 @@ protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdTex /// operations. /// /// The documentation sources parent node - protected internal override HierarchyNode GetDragTargetHandlerNode() + public override HierarchyNode GetDragTargetHandlerNode() { return this.Parent; } diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderReferenceContainerNode.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderReferenceContainerNode.cs index 16fb912e..5855f5e3 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderReferenceContainerNode.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderReferenceContainerNode.cs @@ -59,7 +59,7 @@ public SandcastleBuilderReferenceContainerNode(ProjectNode root) : base(root) /// protected override ProjectReferenceNode CreateProjectReferenceNode(ProjectElement element) { - return new SandcastleBuilderProjectReferenceNode(this.ProjectMgr, element); + return new SandcastleBuilderProjectReferenceNode(this.ProjectManager, element); } /// @@ -68,7 +68,7 @@ protected override ProjectReferenceNode CreateProjectReferenceNode(ProjectElemen protected override ProjectReferenceNode CreateProjectReferenceNode( VSCOMPONENTSELECTORDATA selectorData) { - return new SandcastleBuilderProjectReferenceNode(this.ProjectMgr, + return new SandcastleBuilderProjectReferenceNode(this.ProjectManager, selectorData.bstrTitle, selectorData.bstrFile, selectorData.bstrProjRef); } @@ -82,7 +82,7 @@ protected override AssemblyReferenceNode CreateAssemblyReferenceNode(ProjectElem try { - node = new SandcastleBuilderAssemblyReferenceNode(this.ProjectMgr, element); + node = new SandcastleBuilderAssemblyReferenceNode(this.ProjectManager, element); } catch(ArgumentNullException e) { @@ -118,7 +118,7 @@ protected override AssemblyReferenceNode CreateAssemblyReferenceNode(string file try { - node = new SandcastleBuilderAssemblyReferenceNode(this.ProjectMgr, fileName); + node = new SandcastleBuilderAssemblyReferenceNode(this.ProjectManager, fileName); } catch(ArgumentNullException e) { @@ -150,7 +150,7 @@ protected override AssemblyReferenceNode CreateAssemblyReferenceNode(string file /// A COM reference node protected override ComReferenceNode CreateComReferenceNode(ProjectElement reference) { - return new SandcastleBuilderComReferenceNode(this.ProjectMgr, reference); + return new SandcastleBuilderComReferenceNode(this.ProjectManager, reference); } /// @@ -160,7 +160,7 @@ protected override ComReferenceNode CreateComReferenceNode(ProjectElement refere protected override ComReferenceNode CreateComReferenceNode(VSCOMPONENTSELECTORDATA selectorData, string wrapperTool = null) { - return new SandcastleBuilderComReferenceNode(this.ProjectMgr, selectorData); + return new SandcastleBuilderComReferenceNode(this.ProjectManager, selectorData); } #endregion } diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/BasePropertyPage.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/BasePropertyPage.cs index 2cb09091..193a6960 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/BasePropertyPage.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/BasePropertyPage.cs @@ -661,7 +661,7 @@ protected void StoreProperties(Control.ControlCollection controls) if(this.IsEscapedProperty(boundProperty)) propValue = EscapeValueAttribute.Escape(propValue); - this.ProjectMgr.SetProjectProperty(boundProperty, propValue); + this.ProjectMgr.SetProjectProperty(boundProperty, _PersistStorageType.PST_PROJECT_FILE, propValue); } } } @@ -812,7 +812,7 @@ void IPropertyPage.SetObjects(uint cObjects, object[] ppunk) ProjectConfig config = (ProjectConfig)ppunk[i]; if(this.ProjectMgr == null) - this.ProjectMgr = config.ProjectMgr; + this.ProjectMgr = config.ProjectManager; configs.Add(config); } @@ -823,7 +823,7 @@ void IPropertyPage.SetObjects(uint cObjects, object[] ppunk) if(ppunk[0] is NodeProperties) { if(this.ProjectMgr == null) - this.ProjectMgr = (ppunk[0] as NodeProperties).Node.ProjectMgr; + this.ProjectMgr = (ppunk[0] as NodeProperties).Node.ProjectManager; Dictionary configsMap = new Dictionary(); @@ -831,7 +831,7 @@ void IPropertyPage.SetObjects(uint cObjects, object[] ppunk) { NodeProperties property = (NodeProperties)ppunk[i]; IVsCfgProvider provider; - ErrorHandler.ThrowOnFailure(property.Node.ProjectMgr.GetCfgProvider(out provider)); + ErrorHandler.ThrowOnFailure(property.Node.ProjectManager.GetCfgProvider(out provider)); uint[] expected = new uint[1]; ErrorHandler.ThrowOnFailure(provider.GetCfgs(0, null, expected, null)); diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/BuildPropertiesPageControl.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/BuildPropertiesPageControl.cs index 25fe7bd5..9d82217a 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/BuildPropertiesPageControl.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/BuildPropertiesPageControl.cs @@ -37,6 +37,7 @@ #if !STANDALONEGUI using SandcastleBuilder.Package.Nodes; using SandcastleBuilder.Package.Properties; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; #endif namespace SandcastleBuilder.Package.PropertyPages @@ -226,7 +227,7 @@ protected override bool StoreControlValue(System.Windows.Forms.Control control) f => f.Format.ToString()).ToArray()); #if !STANDALONEGUI - this.ProjectMgr.SetProjectProperty("HelpFileFormat", formats); + this.ProjectMgr.SetProjectProperty("HelpFileFormat", _PersistStorageType.PST_PROJECT_FILE, formats); #else this.CurrentProject.MSBuildProject.SetProperty("HelpFileFormat", formats); #endif diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/ComponentPropertiesPageControl.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/ComponentPropertiesPageControl.cs index f6d9eb24..1beb456a 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/ComponentPropertiesPageControl.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/ComponentPropertiesPageControl.cs @@ -37,6 +37,7 @@ #if !STANDALONEGUI using SandcastleBuilder.Package.Nodes; using SandcastleBuilder.Package.Properties; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; #endif using SandcastleBuilder.Utils; @@ -219,7 +220,7 @@ protected override bool StoreControlValue(Control control) if(this.ProjectMgr == null) return false; - this.ProjectMgr.SetProjectProperty("ComponentConfigurations", currentConfigs.ToXml()); + this.ProjectMgr.SetProjectProperty("ComponentConfigurations", _PersistStorageType.PST_PROJECT_FILE, currentConfigs.ToXml()); #else if(base.CurrentProject == null) return false; diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/HelpFilePropertiesPageControl.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/HelpFilePropertiesPageControl.cs index 757c77d2..7f5dbd07 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/HelpFilePropertiesPageControl.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/HelpFilePropertiesPageControl.cs @@ -42,6 +42,7 @@ #if !STANDALONEGUI using SandcastleBuilder.Package.Nodes; using SandcastleBuilder.Package.Properties; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; #endif namespace SandcastleBuilder.Package.PropertyPages @@ -398,7 +399,7 @@ protected override bool StoreControlValue(Control control) if(control.Name == "cblSyntaxFilters") { #if !STANDALONEGUI - this.ProjectMgr.SetProjectProperty("SyntaxFilters", + this.ProjectMgr.SetProjectProperty("SyntaxFilters", _PersistStorageType.PST_PROJECT_FILE, ComponentUtilities.ToRecognizedSyntaxFilterIds(syntaxGenerators, String.Join(", ", cblSyntaxFilters.CheckedItems.Cast().ToArray()))); #else @@ -443,7 +444,7 @@ private void cboPresentationStyle_SelectedIndexChanged(object sender, EventArgs if(cboPresentationStyle.SelectedIndex == -1) { #if !STANDALONEGUI - string prop = base.ProjectMgr.GetProjectProperty("PresentationStyle"); + string prop = base.ProjectMgr.GetProjectProperty("PresentationStyle", _PersistStorageType.PST_PROJECT_FILE); #else string prop = base.CurrentProject.MSBuildProject.GetPropertyValue("PresentationStyle"); #endif diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/MSHelp2PropertiesPageControl.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/MSHelp2PropertiesPageControl.cs index 56183c81..1a3d9946 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/MSHelp2PropertiesPageControl.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/MSHelp2PropertiesPageControl.cs @@ -28,6 +28,7 @@ #if !STANDALONEGUI using SandcastleBuilder.Package.Nodes; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; #endif using SandcastleBuilder.Utils; @@ -169,7 +170,7 @@ protected override bool StoreControlValue(System.Windows.Forms.Control control) attributes.Sort(); #if !STANDALONEGUI - this.ProjectMgr.SetProjectProperty("HelpAttributes", attributes.ToXml()); + this.ProjectMgr.SetProjectProperty("HelpAttributes", _PersistStorageType.PST_PROJECT_FILE, attributes.ToXml()); #else this.CurrentProject.MSBuildProject.SetProperty("HelpAttributes", attributes.ToXml()); #endif diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/MissingTagPropertiesPageControl.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/MissingTagPropertiesPageControl.cs index ab13aa1b..228231e0 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/MissingTagPropertiesPageControl.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/MissingTagPropertiesPageControl.cs @@ -25,6 +25,10 @@ using SandcastleBuilder.Utils; +#if !STANDALONEGUI +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; +#endif + namespace SandcastleBuilder.Package.PropertyPages { /// @@ -148,7 +152,7 @@ protected override bool StoreControlValue(Control control) tags |= MissingTags.Value; #if !STANDALONEGUI - this.ProjectMgr.SetProjectProperty("MissingTags", tags.ToString()); + this.ProjectMgr.SetProjectProperty("MissingTags", _PersistStorageType.PST_PROJECT_FILE, tags.ToString()); #else this.CurrentProject.MSBuildProject.SetProperty("MissingTags", tags.ToString()); #endif diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/PlugInPropertiesPageControl.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/PlugInPropertiesPageControl.cs index a5ddb87f..9446bb33 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/PlugInPropertiesPageControl.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/PlugInPropertiesPageControl.cs @@ -34,6 +34,7 @@ #if !STANDALONEGUI using SandcastleBuilder.Package.Nodes; using SandcastleBuilder.Package.Properties; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; #endif using Sandcastle.Core; @@ -217,7 +218,7 @@ protected override bool StoreControlValue(Control control) if(this.ProjectMgr == null) return false; - this.ProjectMgr.SetProjectProperty("PlugInConfigurations", currentConfigs.ToXml()); + this.ProjectMgr.SetProjectProperty("PlugInConfigurations", _PersistStorageType.PST_PROJECT_FILE, currentConfigs.ToXml()); #else if(base.CurrentProject == null) return false; diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/SummaryPropertiesPageControl.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/SummaryPropertiesPageControl.cs index 56af6cd7..ca9872e5 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/SummaryPropertiesPageControl.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/SummaryPropertiesPageControl.cs @@ -32,6 +32,7 @@ using Microsoft.VisualStudio.OLE.Interop; using SandcastleBuilder.Package.Nodes; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; #endif using SandcastleBuilder.Utils; using SandcastleBuilder.Utils.Design; @@ -155,7 +156,7 @@ protected override bool StoreControlValue(Control control) if(summariesChanged) { #if !STANDALONEGUI - this.ProjectMgr.SetProjectProperty("NamespaceSummaries", namespaceSummaries.ToXml()); + this.ProjectMgr.SetProjectProperty("NamespaceSummaries", _PersistStorageType.PST_PROJECT_FILE, namespaceSummaries.ToXml()); #else this.CurrentProject.MSBuildProject.SetProperty("NamespaceSummaries", namespaceSummaries.ToXml()); #endif diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/TransformArgumentsPageControl.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/TransformArgumentsPageControl.cs index 26cdf568..e7f72dd2 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/TransformArgumentsPageControl.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/TransformArgumentsPageControl.cs @@ -39,6 +39,7 @@ #if !STANDALONEGUI using SandcastleBuilder.Package.Properties; using SandcastleBuilder.Package.Nodes; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; #endif namespace SandcastleBuilder.Package.PropertyPages @@ -311,7 +312,7 @@ protected override bool StoreControlValue(Control control) if(this.ProjectMgr == null) return false; - this.ProjectMgr.SetProjectProperty("TransformComponentArguments", reader.ReadInnerXml()); + this.ProjectMgr.SetProjectProperty("TransformComponentArguments", _PersistStorageType.PST_PROJECT_FILE, reader.ReadInnerXml()); #else if(this.CurrentProject == null) return false; diff --git a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/VisibilityPropertiesPageControl.cs b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/VisibilityPropertiesPageControl.cs index e032553c..cc8aff34 100644 --- a/SHFB/Source/SandcastleBuilderPackage/PropertyPages/VisibilityPropertiesPageControl.cs +++ b/SHFB/Source/SandcastleBuilderPackage/PropertyPages/VisibilityPropertiesPageControl.cs @@ -31,6 +31,7 @@ using Microsoft.VisualStudio.OLE.Interop; using SandcastleBuilder.Package.Nodes; +using _PersistStorageType = Microsoft.VisualStudio.Shell.Interop._PersistStorageType; #endif using SandcastleBuilder.Utils; using SandcastleBuilder.Utils.Design; @@ -180,7 +181,7 @@ protected override bool StoreControlValue(Control control) { if(filterChanged) { - this.ProjectMgr.SetProjectProperty("ApiFilter", apiFilter); + this.ProjectMgr.SetProjectProperty("ApiFilter", _PersistStorageType.PST_PROJECT_FILE, apiFilter); filterChanged = false; } @@ -241,7 +242,7 @@ protected override bool StoreControlValue(Control control) items |= VisibleItems.NoPIATypes; #if !STANDALONEGUI - this.ProjectMgr.SetProjectProperty("VisibleItems", items.ToString()); + this.ProjectMgr.SetProjectProperty("VisibleItems", _PersistStorageType.PST_PROJECT_FILE, items.ToString()); #else this.CurrentProject.MSBuildProject.SetProperty("VisibleItems", items.ToString()); #endif diff --git a/SHFB/Source/SandcastleBuilderPackage/SandcastleBuilderPackage.cs b/SHFB/Source/SandcastleBuilderPackage/SandcastleBuilderPackage.cs index 1f23bc3c..42065b85 100644 --- a/SHFB/Source/SandcastleBuilderPackage/SandcastleBuilderPackage.cs +++ b/SHFB/Source/SandcastleBuilderPackage/SandcastleBuilderPackage.cs @@ -33,6 +33,7 @@ using EnvDTE; using Microsoft.VisualStudio; +using Microsoft.VisualStudio.Project; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; @@ -116,6 +117,10 @@ public sealed class SandcastleBuilderPackage : PackageBase //===================================================================== private BuildCompletedEventListener buildCompletedListener; + + private SingleFileGeneratorNodeExtenderProvider _singleFileGeneratorNodeExtenderProvider; + private int _singleFileGeneratorNodeExtenderCookie; + #endregion #region Properties @@ -226,6 +231,9 @@ protected override void Dispose(bool disposing) { if (disposing) { + ObjectExtenders objectExtenders = (ObjectExtenders)GetService(typeof(ObjectExtenders)); + objectExtenders.UnregisterExtenderProvider(_singleFileGeneratorNodeExtenderCookie); + SandcastleBuilderPackage.Instance = null; if(buildCompletedListener != null) @@ -263,6 +271,13 @@ protected override void Initialize() // Create the update solution event listener for build completed events buildCompletedListener = new BuildCompletedEventListener(this); + + ObjectExtenders objectExtenders = (ObjectExtenders)GetService(typeof(ObjectExtenders)); + _singleFileGeneratorNodeExtenderProvider = new SingleFileGeneratorNodeExtenderProvider(); + string extenderCatId = typeof(SandcastleBuilderFileNodeProperties).GUID.ToString("B"); + string extenderName = SingleFileGeneratorNodeExtenderProvider.Name; + string localizedName = extenderName; + _singleFileGeneratorNodeExtenderCookie = objectExtenders.RegisterExtenderProvider(extenderCatId, extenderName, _singleFileGeneratorNodeExtenderProvider, localizedName); } #endregion @@ -311,7 +326,7 @@ private static void SetViewHelpCommandState(OleMenuCommand command, HelpFileForm StringComparison.OrdinalIgnoreCase)) { SandcastleBuilderProjectNode pn = (SandcastleBuilderProjectNode)p.Object; - string projectHelpFormat = (pn.GetProjectProperty("HelpFileFormat") ?? + string projectHelpFormat = (pn.GetProjectProperty("HelpFileFormat", _PersistStorageType.PST_PROJECT_FILE) ?? HelpFileFormats.HtmlHelp1.ToString()); enabled = (!pn.BuildInProgress && (format == null || projectHelpFormat.IndexOf( diff --git a/SHFB/Source/SandcastleBuilderPackage/SandcastleBuilderPackage.csproj b/SHFB/Source/SandcastleBuilderPackage/SandcastleBuilderPackage.csproj index 17ae8b19..c9be0f98 100644 --- a/SHFB/Source/SandcastleBuilderPackage/SandcastleBuilderPackage.csproj +++ b/SHFB/Source/SandcastleBuilderPackage/SandcastleBuilderPackage.csproj @@ -71,11 +71,18 @@ ..\packages\VSSDK.DTE.8.8.0.2\lib\net20\envdte80.dll + + False ..\packages\VSSDK.CoreUtility.10.10.0.2\lib\net40\Microsoft.VisualStudio.CoreUtility.dll + + False + False + ..\packages\VSSDK.Designer.7.0.2\lib\net20\Microsoft.VisualStudio.Designer.Interfaces.dll + False ..\packages\VSSDK.Editor.10.10.0.2\lib\net40\Microsoft.VisualStudio.Editor.dll @@ -92,6 +99,9 @@ False ..\packages\VSSDK.OLE.Interop.7.0.2\lib\net20\Microsoft.VisualStudio.OLE.Interop.dll + + ..\packages\Microsoft.VisualStudio.Project.10.0.1.0.0-alpha005\lib\net40\Microsoft.VisualStudio.Project.10.0.dll + False ..\packages\VSSDK.Shell.10.10.0.2\lib\net40\Microsoft.VisualStudio.Shell.10.0.dll @@ -162,6 +172,31 @@ + + False + False + ..\packages\VSSDK.VSLangProj.7.0.2\lib\net20\VSLangProj.dll + + + False + False + ..\packages\VSSDK.VSLangProj.10.10.0.0\lib\net20\VSLangProj100.dll + + + False + False + ..\packages\VSSDK.VSLangProj.7.0.2\lib\net20\VSLangProj2.dll + + + False + False + ..\packages\VSSDK.VSLangProj.8.8.0.2\lib\net20\VSLangProj80.dll + + + False + False + ..\packages\VSSDK.VSLangProj.10.10.0.0\lib\net20\VSLangProj90.dll + @@ -201,6 +236,7 @@ + Form @@ -832,10 +868,6 @@ {72331A21-C452-4BE4-BFDB-B8029A6BC1C0} ColorizerLibrary - - {CACB60A9-1E76-4F92-8831-B134A658C695} - Microsoft.VisualStudio.Project - {330DADF7-3AB1-49A0-B3C6-A69D2C4F06A6} SandcastleBuilderUtils diff --git a/SHFB/Source/SandcastleBuilderPackage/packages.SandcastleBuilderPackage.config b/SHFB/Source/SandcastleBuilderPackage/packages.SandcastleBuilderPackage.config index 89179637..dd8e0919 100644 --- a/SHFB/Source/SandcastleBuilderPackage/packages.SandcastleBuilderPackage.config +++ b/SHFB/Source/SandcastleBuilderPackage/packages.SandcastleBuilderPackage.config @@ -1,6 +1,8 @@  + + @@ -20,4 +22,6 @@ + + \ No newline at end of file diff --git a/SHFB/Source/SandcastleBuilderUtils/SandcastleHelpFileBuilder.targets b/SHFB/Source/SandcastleBuilderUtils/SandcastleHelpFileBuilder.targets index a0c330d2..ba9ddaaf 100644 --- a/SHFB/Source/SandcastleBuilderUtils/SandcastleHelpFileBuilder.targets +++ b/SHFB/Source/SandcastleBuilderUtils/SandcastleHelpFileBuilder.targets @@ -33,6 +33,18 @@ + + + + + + + + + + + + From a25ed2c313d14c156145dab699f98400f1879baa Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 18 Mar 2014 13:45:17 -0500 Subject: [PATCH 2/3] Remove the MPFProj source from this repository --- .../MPFProj_VS2010/AssemblyReferenceNode.cs | 542 -- SHFB/Source/MPFProj_VS2010/Attributes.cs | 116 - .../Automation/AutomationScope.cs | 144 - .../MPFProj_VS2010/Automation/OAFileItem.cs | 428 - .../MPFProj_VS2010/Automation/OAFolderItem.cs | 93 - .../Automation/OANavigableProjectItems.cs | 317 - .../Automation/OANestedProjectItem.cs | 111 - .../Automation/OANullProperty.cs | 138 - .../MPFProj_VS2010/Automation/OAProject.cs | 531 -- .../Automation/OAProjectItem.cs | 481 -- .../Automation/OAProjectItems.cs | 323 - .../MPFProj_VS2010/Automation/OAProperties.cs | 328 - .../MPFProj_VS2010/Automation/OAProperty.cs | 217 - .../Automation/OAReferenceFolderItem.cs | 104 - .../Automation/OAReferenceItem.cs | 129 - .../Automation/OASolutionFolder.cs | 168 - .../VSProject/OAAssemblyReference.cs | 209 - .../Automation/VSProject/OABuildManager.cs | 143 - .../Automation/VSProject/OAComReference.cs | 123 - .../VSProject/OAProjectReference.cs | 127 - .../Automation/VSProject/OAReferenceBase.cs | 217 - .../Automation/VSProject/OAReferences.cs | 355 - .../Automation/VSProject/OAVSProject.cs | 251 - .../Automation/VSProject/OAVSProjectItem.cs | 117 - SHFB/Source/MPFProj_VS2010/BuildDependency.cs | 138 - .../MPFProj_VS2010/BuildPropertyPage.cs | 122 - .../Source/MPFProj_VS2010/ComReferenceNode.cs | 398 - SHFB/Source/MPFProj_VS2010/ConfigProvider.cs | 790 -- .../MPFProj_VS2010/ConfigurationProperties.cs | 98 - SHFB/Source/MPFProj_VS2010/DataObject.cs | 630 -- .../MPFProj_VS2010/DependentFileNode.cs | 182 - .../DesignPropertyDescriptor.cs | 249 - .../DesignTimeAssemblyResolution.cs | 645 -- .../Diagrams/AutomationClasses.cd | 90 - .../Diagrams/ConfigurationClasses.cd | 59 - .../Diagrams/DocumentManagerClasses.cd | 39 - .../Diagrams/HierarchyClasses.cd | 78 - .../Diagrams/PropertiesClasses.cd | 69 - .../Diagrams/ReferenceClasses.cd | 77 - SHFB/Source/MPFProj_VS2010/DocumentManager.cs | 383 - .../Source/MPFProj_VS2010/EnumDependencies.cs | 142 - .../MPFProj_VS2010/FileChangeManager.cs | 325 - .../MPFProj_VS2010/FileDocumentManager.cs | 306 - SHFB/Source/MPFProj_VS2010/FileNode.cs | 1252 --- SHFB/Source/MPFProj_VS2010/FolderNode.cs | 573 -- .../MPFProj_VS2010/GlobalSuppressions.cs | 656 -- SHFB/Source/MPFProj_VS2010/HierarchyNode.cs | 3516 -------- SHFB/Source/MPFProj_VS2010/IDEBuildLogger.cs | 658 -- SHFB/Source/MPFProj_VS2010/ImageHandler.cs | 241 - SHFB/Source/MPFProj_VS2010/Interfaces.cs | 202 - SHFB/Source/MPFProj_VS2010/Key.snk | Bin 596 -> 0 bytes .../MPFProj_VS2010/LocalizableProperties.cs | 145 - .../Microsoft.VisualStudio.Project.csproj | 226 - .../Misc/ConnectionPointContainer.cs | 162 - SHFB/Source/MPFProj_VS2010/Misc/ExternDll.cs | 122 - .../MPFProj_VS2010/Misc/NativeMethods.cs | 744 -- .../Misc/UnsafeNativeMethods.cs | 102 - .../NestedProjectBuildDependency.cs | 121 - .../MPFProj_VS2010/NestedProjectNode.cs | 1185 --- SHFB/Source/MPFProj_VS2010/NodeProperties.cs | 969 --- .../MPFProj_VS2010/OleServiceProvider.cs | 297 - SHFB/Source/MPFProj_VS2010/Output.cs | 177 - SHFB/Source/MPFProj_VS2010/OutputGroup.cs | 302 - SHFB/Source/MPFProj_VS2010/ProjectConfig.cs | 1057 --- .../MPFProj_VS2010/ProjectContainerNode.cs | 842 -- .../ProjectDesignerDocumentManager.cs | 115 - .../ProjectDocumentsListener.cs | 234 - SHFB/Source/MPFProj_VS2010/ProjectElement.cs | 456 -- SHFB/Source/MPFProj_VS2010/ProjectFactory.cs | 280 - .../MPFProj_VS2010/ProjectFileConstants.cs | 191 - .../MPFProj_VS2010/ProjectNode.CopyPaste.cs | 1223 --- .../MPFProj_VS2010/ProjectNode.Events.cs | 79 - SHFB/Source/MPFProj_VS2010/ProjectNode.cs | 7044 ----------------- SHFB/Source/MPFProj_VS2010/ProjectOptions.cs | 132 - SHFB/Source/MPFProj_VS2010/ProjectPackage.cs | 130 - .../MPFProj_VS2010/ProjectReferenceNode.cs | 594 -- .../MPFProj_VS2010/Properties/AssemblyInfo.cs | 64 - .../PropertiesEditorLauncher.cs | 98 - .../MPFProj_VS2010/ReferenceContainerNode.cs | 575 -- SHFB/Source/MPFProj_VS2010/ReferenceNode.cs | 377 - .../MPFProj_VS2010/RegisteredProjectType.cs | 194 - .../MPFProj_VS2010/Resources/imagelis.bmp | Bin 39990 -> 0 bytes .../MPFProj_VS2010/SelectionListener.cs | 182 - SHFB/Source/MPFProj_VS2010/SettingsPage.cs | 524 -- .../MPFProj_VS2010/SingleFileGenerator.cs | 554 -- .../SingleFileGeneratorFactory.cs | 398 - .../Source/MPFProj_VS2010/SolutionListener.cs | 278 - ...olutionListenerForBuildDependencyUpdate.cs | 213 - .../SolutionListenerForProjectEvents.cs | 137 - .../SolutionListenerForProjectOpen.cs | 100 - ...lutionListenerForProjectReferenceUpdate.cs | 283 - SHFB/Source/MPFProj_VS2010/StructuresEnums.cs | 572 -- .../MPFProj_VS2010/SuspendFileChanges.cs | 161 - SHFB/Source/MPFProj_VS2010/TokenProcessor.cs | 574 -- SHFB/Source/MPFProj_VS2010/Tracing.cs | 111 - .../MPFProj_VS2010/TrackDocumentsHelper.cs | 211 - SHFB/Source/MPFProj_VS2010/TypeConverters.cs | 315 - SHFB/Source/MPFProj_VS2010/UIThread.cs | 268 - .../UpdateSolutionEventsListener.cs | 319 - SHFB/Source/MPFProj_VS2010/Utilities.cs | 1092 --- .../Source/MPFProj_VS2010/VSShellUtilities.cs | 105 - .../MPFProj_VS2010/VisualStudio.Project.cs | 322 - .../MPFProj_VS2010/VisualStudio.Project.resx | 547 -- SHFB/Source/MPFProj_VS2010/VsCommands.cs | 140 - SHFB/Source/SandcastleBuilderPackage.sln | 6 - 105 files changed, 43279 deletions(-) delete mode 100644 SHFB/Source/MPFProj_VS2010/AssemblyReferenceNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Attributes.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/AutomationScope.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OAFileItem.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OAFolderItem.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OANavigableProjectItems.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OANestedProjectItem.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OANullProperty.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OAProject.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OAProjectItem.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OAProjectItems.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OAProperties.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OAProperty.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OAReferenceFolderItem.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OAReferenceItem.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/OASolutionFolder.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAAssemblyReference.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/VSProject/OABuildManager.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAComReference.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAProjectReference.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAReferenceBase.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAReferences.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAVSProject.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAVSProjectItem.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/BuildDependency.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/BuildPropertyPage.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ComReferenceNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ConfigProvider.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ConfigurationProperties.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/DataObject.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/DependentFileNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/DesignPropertyDescriptor.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/DesignTimeAssemblyResolution.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Diagrams/AutomationClasses.cd delete mode 100644 SHFB/Source/MPFProj_VS2010/Diagrams/ConfigurationClasses.cd delete mode 100644 SHFB/Source/MPFProj_VS2010/Diagrams/DocumentManagerClasses.cd delete mode 100644 SHFB/Source/MPFProj_VS2010/Diagrams/HierarchyClasses.cd delete mode 100644 SHFB/Source/MPFProj_VS2010/Diagrams/PropertiesClasses.cd delete mode 100644 SHFB/Source/MPFProj_VS2010/Diagrams/ReferenceClasses.cd delete mode 100644 SHFB/Source/MPFProj_VS2010/DocumentManager.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/EnumDependencies.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/FileChangeManager.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/FileDocumentManager.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/FileNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/FolderNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/GlobalSuppressions.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/HierarchyNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/IDEBuildLogger.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ImageHandler.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Interfaces.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Key.snk delete mode 100644 SHFB/Source/MPFProj_VS2010/LocalizableProperties.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Microsoft.VisualStudio.Project.csproj delete mode 100644 SHFB/Source/MPFProj_VS2010/Misc/ConnectionPointContainer.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Misc/ExternDll.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Misc/NativeMethods.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Misc/UnsafeNativeMethods.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/NestedProjectBuildDependency.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/NestedProjectNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/NodeProperties.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/OleServiceProvider.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Output.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/OutputGroup.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectConfig.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectContainerNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectDesignerDocumentManager.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectDocumentsListener.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectElement.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectFactory.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectFileConstants.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectNode.CopyPaste.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectNode.Events.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectOptions.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectPackage.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ProjectReferenceNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Properties/AssemblyInfo.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/PropertiesEditorLauncher.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ReferenceContainerNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/ReferenceNode.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/RegisteredProjectType.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Resources/imagelis.bmp delete mode 100644 SHFB/Source/MPFProj_VS2010/SelectionListener.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/SettingsPage.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/SingleFileGenerator.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/SingleFileGeneratorFactory.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/SolutionListener.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/SolutionListenerForBuildDependencyUpdate.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectEvents.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectOpen.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectReferenceUpdate.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/StructuresEnums.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/SuspendFileChanges.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/TokenProcessor.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Tracing.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/TrackDocumentsHelper.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/TypeConverters.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/UIThread.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/UpdateSolutionEventsListener.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/Utilities.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/VSShellUtilities.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/VisualStudio.Project.cs delete mode 100644 SHFB/Source/MPFProj_VS2010/VisualStudio.Project.resx delete mode 100644 SHFB/Source/MPFProj_VS2010/VsCommands.cs diff --git a/SHFB/Source/MPFProj_VS2010/AssemblyReferenceNode.cs b/SHFB/Source/MPFProj_VS2010/AssemblyReferenceNode.cs deleted file mode 100644 index 5f74bef5..00000000 --- a/SHFB/Source/MPFProj_VS2010/AssemblyReferenceNode.cs +++ /dev/null @@ -1,542 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.Diagnostics; -using System.IO; -using System.Reflection; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using MSBuild = Microsoft.Build.Evaluation; -using MSBuildExecution = Microsoft.Build.Execution; -using Microsoft.Build.Evaluation; -using Microsoft.Build.Framework; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false)] - [ComVisible(true)] - public class AssemblyReferenceNode : ReferenceNode - { - #region fieds - /// - /// The name of the assembly this refernce represents - /// - private System.Reflection.AssemblyName assemblyName; - private AssemblyName resolvedAssemblyName; - - private string assemblyPath = String.Empty; - - /// - /// Defines the listener that would listen on file changes on the nested project node. - /// - private FileChangeManager fileChangeListener; - - /// - /// A flag for specifying if the object was disposed. - /// - private bool isDisposed; - #endregion - - #region properties - /// - /// The name of the assembly this reference represents. - /// - /// - internal System.Reflection.AssemblyName AssemblyName - { - get - { - return this.assemblyName; - } - } - - /// - /// Returns the name of the assembly this reference refers to on this specific - /// machine. It can be different from the AssemblyName property because it can - /// be more specific. - /// - internal System.Reflection.AssemblyName ResolvedAssembly - { - get { return resolvedAssemblyName; } - } - - public override string Url - { - get - { - return this.assemblyPath; - } - } - - public override string Caption - { - get - { - return this.assemblyName.Name; - } - } - - private Automation.OAAssemblyReference assemblyRef; - internal override object Object - { - get - { - if(null == assemblyRef) - { - assemblyRef = new Automation.OAAssemblyReference(this); - } - return assemblyRef; - } - } - #endregion - - #region ctors - /// - /// Constructor for the ReferenceNode - /// - public AssemblyReferenceNode(ProjectNode root, ProjectElement element) - : base(root, element) - { - this.GetPathNameFromProjectFile(); - - this.InitializeFileChangeEvents(); - - string include = this.ItemNode.GetMetadata(ProjectFileConstants.Include); - - this.CreateFromAssemblyName(new System.Reflection.AssemblyName(include)); - } - - /// - /// Constructor for the AssemblyReferenceNode - /// - public AssemblyReferenceNode(ProjectNode root, string assemblyPath) - : base(root) - { - // Validate the input parameters. - if(null == root) - { - throw new ArgumentNullException("root"); - } - if(string.IsNullOrEmpty(assemblyPath)) - { - throw new ArgumentNullException("assemblyPath"); - } - - this.InitializeFileChangeEvents(); - - // The assemblyPath variable can be an actual path on disk or a generic assembly name. - if(File.Exists(assemblyPath)) - { - // The assemblyPath parameter is an actual file on disk; try to load it. - this.assemblyName = System.Reflection.AssemblyName.GetAssemblyName(assemblyPath); - this.assemblyPath = assemblyPath; - - // We register with listeningto chnages onteh path here. The rest of teh cases will call into resolving the assembly and registration is done there. - this.fileChangeListener.ObserveItem(this.assemblyPath); - } - else - { - // The file does not exist on disk. This can be because the file / path is not - // correct or because this is not a path, but an assembly name. - // Try to resolve the reference as an assembly name. - this.CreateFromAssemblyName(new System.Reflection.AssemblyName(assemblyPath)); - } - } - #endregion - - #region methods - /// - /// Closes the node. - /// - /// - public override int Close() - { - try - { - this.Dispose(true); - } - finally - { - base.Close(); - } - - return VSConstants.S_OK; - } - - /// - /// Links a reference node to the project and hierarchy. - /// - protected override void BindReferenceData() - { - Debug.Assert(this.assemblyName != null, "The AssemblyName field has not been initialized"); - - // If the item has not been set correctly like in case of a new reference added it now. - // The constructor for the AssemblyReference node will create a default project item. In that case the Item is null. - // We need to specify here the correct project element. - if(this.ItemNode == null || this.ItemNode.Item == null) - { - this.ItemNode = new ProjectElement(this.ProjectMgr, this.assemblyName.FullName, ProjectFileConstants.Reference); - } - - // Set the basic information we know about - this.ItemNode.SetMetadata(ProjectFileConstants.Name, this.assemblyName.Name); - if (!string.IsNullOrEmpty(this.assemblyPath)) - { - this.ItemNode.SetMetadata(ProjectFileConstants.AssemblyName, Path.GetFileName(this.assemblyPath)); - } - else - { - this.ItemNode.SetMetadata(ProjectFileConstants.AssemblyName, null); - } - - this.SetReferenceProperties(); - } - - /// - /// Disposes the node - /// - /// - protected override void Dispose(bool disposing) - { - if(this.isDisposed) - { - return; - } - - try - { - this.UnregisterFromFileChangeService(); - } - finally - { - base.Dispose(disposing); - this.isDisposed = true; - } - } - - private void CreateFromAssemblyName(AssemblyName name) - { - this.assemblyName = name; - - // Use MsBuild to resolve the assemblyname - this.ResolveAssemblyReference(); - - if(String.IsNullOrEmpty(this.assemblyPath) && (null != this.ItemNode.Item)) - { - // Try to get the assembly name from the hintpath. - this.GetPathNameFromProjectFile(); - if(this.assemblyPath == null) - { - // Try to get the assembly name from the path - this.assemblyName = System.Reflection.AssemblyName.GetAssemblyName(this.assemblyPath); - } - } - if(null == resolvedAssemblyName) - { - resolvedAssemblyName = assemblyName; - } - } - - /// - /// Checks if an assembly is already added. The method parses all references and compares the full assemblynames, or the location of the assemblies to decide whether two assemblies are the same. - /// - /// true if the assembly has already been added. - protected internal override bool IsAlreadyAdded(out ReferenceNode existingReference) - { - ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode; - Debug.Assert(referencesFolder != null, "Could not find the References node"); - bool shouldCheckPath = !string.IsNullOrEmpty(this.Url); - - for(HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling) - { - AssemblyReferenceNode assemblyReferenceNode = n as AssemblyReferenceNode; - if(null != assemblyReferenceNode) - { - // We will check if the full assemblynames are the same or if the Url of the assemblies is the same. - if(String.Compare(assemblyReferenceNode.AssemblyName.FullName, this.assemblyName.FullName, StringComparison.OrdinalIgnoreCase) == 0 || - (shouldCheckPath && NativeMethods.IsSamePath(assemblyReferenceNode.Url, this.Url))) - { - existingReference = assemblyReferenceNode; - return true; - } - } - } - - existingReference = null; - return false; - } - - /// - /// Determines if this is node a valid node for painting the default reference icon. - /// - /// - protected override bool CanShowDefaultIcon() - { - if(String.IsNullOrEmpty(this.assemblyPath) || !File.Exists(this.assemblyPath)) - { - return false; - } - - return true; - } - - private void GetPathNameFromProjectFile() - { - string result = this.ItemNode.GetMetadata(ProjectFileConstants.HintPath); - if(String.IsNullOrEmpty(result)) - { - result = this.ItemNode.GetMetadata(ProjectFileConstants.AssemblyName); - if(String.IsNullOrEmpty(result)) - { - this.assemblyPath = String.Empty; - } - else if(!result.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) - { - result += ".dll"; - this.assemblyPath = result; - } - } - else - { - this.assemblyPath = this.GetFullPathFromPath(result); - } - } - - private string GetFullPathFromPath(string path) - { - if(Path.IsPathRooted(path)) - { - return path; - } - else - { - Uri uri = new Uri(this.ProjectMgr.BaseURI.Uri, path); - - if(uri != null) - { - return Microsoft.VisualStudio.Shell.Url.Unescape(uri.LocalPath, true); - } - } - - return String.Empty; - } - - protected override void ResolveReference() - { - this.ResolveAssemblyReference(); - } - - private void SetHintPathAndPrivateValue() - { - // Remove the HintPath, we will re-add it below if it is needed - if(!String.IsNullOrEmpty(this.assemblyPath)) - { - this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, null); - } - - // Get the list of items which require HintPath - IEnumerable references = this.ProjectMgr.BuildProject.GetItems(MsBuildGeneratedItemType.ReferenceCopyLocalPaths); - - // Now loop through the generated References to find the corresponding one - foreach (MSBuild.ProjectItem reference in references) - { - string fileName = Path.GetFileNameWithoutExtension(reference.EvaluatedInclude); - if(String.Compare(fileName, this.assemblyName.Name, StringComparison.OrdinalIgnoreCase) == 0) - { - // We found it, now set some properties based on this. - string hintPath = reference.GetMetadataValue(ProjectFileConstants.HintPath); - this.SetHintPathAndPrivateValue(hintPath); - break; - } - - } - } - - /// - /// Sets the hint path to the provided value. - /// It also sets the private value to true if it has not been already provided through the associated project element. - /// - /// The hint path to set. - private void SetHintPathAndPrivateValue(string hintPath) - { - if (String.IsNullOrEmpty(hintPath)) - { - return; - } - - if (Path.IsPathRooted(hintPath)) - { - hintPath = PackageUtilities.GetPathDistance(this.ProjectMgr.BaseURI.Uri, new Uri(hintPath)); - } - - this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, hintPath); - - // Private means local copy; we want to know if it is already set to not override the default - string privateValue = this.ItemNode != null ? this.ItemNode.GetMetadata(ProjectFileConstants.Private) : null; - - // If this is not already set, we default to true - if (String.IsNullOrEmpty(privateValue)) - { - this.ItemNode.SetMetadata(ProjectFileConstants.Private, true.ToString()); - } - } - - /// - /// This function ensures that some properties of the reference are set. - /// - private void SetReferenceProperties() - { - // If there is an assembly path then just set the hint path - if (!string.IsNullOrEmpty(this.assemblyPath)) - { - this.SetHintPathAndPrivateValue(this.assemblyPath); - return; - } - - // Set a default HintPath for msbuild to be able to resolve the reference. - this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, this.assemblyPath); - - // Resolve assembly referernces. This is needed to make sure that properties like the full path - // to the assembly or the hint path are set. - if(this.ProjectMgr.Build(MsBuildTarget.ResolveAssemblyReferences) != MSBuildResult.Successful) - { - return; - } - - // Check if we have to resolve again the path to the assembly. - this.ResolveReference(); - - // Make sure that the hint path if set (if needed). - this.SetHintPathAndPrivateValue(); - } - - /// - /// Does the actual job of resolving an assembly reference. We need a private method that does not violate - /// calling virtual method from the constructor. - /// - private void ResolveAssemblyReference() - { - if (this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return; - } - - var group = this.ProjectMgr.CurrentConfig.GetItems(ProjectFileConstants.ReferencePath); - foreach (var item in group) - { - string fullPath = this.GetFullPathFromPath(item.EvaluatedInclude); - - System.Reflection.AssemblyName name = System.Reflection.AssemblyName.GetAssemblyName(fullPath); - - // Try with full assembly name and then with weak assembly name. - if (String.Equals(name.FullName, this.assemblyName.FullName, StringComparison.OrdinalIgnoreCase) || String.Equals(name.Name, this.assemblyName.Name, StringComparison.OrdinalIgnoreCase)) - { - if (!NativeMethods.IsSamePath(fullPath, this.assemblyPath)) - { - // set the full path now. - this.assemblyPath = fullPath; - - // We have a new item to listen too, since the assembly reference is resolved from a different place. - this.fileChangeListener.ObserveItem(this.assemblyPath); - } - - this.resolvedAssemblyName = name; - - // No hint path is needed since the assembly path will always be resolved. - return; - } - } - } - - /// - /// Registers with File change events - /// - private void InitializeFileChangeEvents() - { - this.fileChangeListener = new FileChangeManager(this.ProjectMgr.Site); - this.fileChangeListener.FileChangedOnDisk += this.OnAssemblyReferenceChangedOnDisk; - } - - /// - /// Unregisters this node from file change notifications. - /// - private void UnregisterFromFileChangeService() - { - this.fileChangeListener.FileChangedOnDisk -= this.OnAssemblyReferenceChangedOnDisk; - this.fileChangeListener.Dispose(); - } - - /// - /// Event callback. Called when one of the assembly file is changed. - /// - /// The FileChangeManager object. - /// Event args containing the file name that was updated. - private void OnAssemblyReferenceChangedOnDisk(object sender, FileChangedOnDiskEventArgs e) - { - Debug.Assert(e != null, "No event args specified for the FileChangedOnDisk event"); - - // We only care about file deletes, so check for one before enumerating references. - if((e.FileChangeFlag & _VSFILECHANGEFLAGS.VSFILECHG_Del) == 0) - { - return; - } - - - if(NativeMethods.IsSamePath(e.FileName, this.assemblyPath)) - { - this.OnInvalidateItems(this.Parent); - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Attributes.cs b/SHFB/Source/MPFProj_VS2010/Attributes.cs deleted file mode 100644 index 32eae15b..00000000 --- a/SHFB/Source/MPFProj_VS2010/Attributes.cs +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Globalization; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Defines a type converter. - /// - /// This is needed to get rid of the type TypeConverter type that could not give back the Type we were passing to him. - /// We do not want to use reflection to get the type back from the ConverterTypeName. Also the GetType methos does not spwan converters from other assemblies. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments"), AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field)] - public sealed class PropertyPageTypeConverterAttribute : Attribute - { - #region fields - Type converterType; - #endregion - - #region ctors - public PropertyPageTypeConverterAttribute(Type type) - { - this.converterType = type; - } - #endregion - - #region properties - public Type ConverterType - { - get - { - return this.converterType; - } - } - #endregion - } - - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] - internal sealed class LocDisplayNameAttribute : DisplayNameAttribute - { - #region fields - string name; - #endregion - - #region ctors - public LocDisplayNameAttribute(string name) - { - this.name = name; - } - #endregion - - #region properties - public override string DisplayName - { - get - { - string result = SR.GetString(this.name, CultureInfo.CurrentUICulture); - if(result == null) - { - Debug.Assert(false, "String resource '" + this.name + "' is missing"); - result = this.name; - } - return result; - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/AutomationScope.cs b/SHFB/Source/MPFProj_VS2010/Automation/AutomationScope.cs deleted file mode 100644 index 1c5e74fd..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/AutomationScope.cs +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using Microsoft.VisualStudio.Shell.Interop; -using ErrorHandler = Microsoft.VisualStudio.ErrorHandler; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Helper class that handle the scope of an automation function. - /// It should be used inside a "using" directive to define the scope of the - /// automation function and make sure that the ExitAutomation method is called. - /// - internal class AutomationScope : IDisposable - { - private IVsExtensibility3 extensibility; - private bool inAutomation; - private static volatile object Mutex; - private bool isDisposed; - - /// - /// Initializes the class. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] - static AutomationScope() - { - Mutex = new object(); - } - - /// - /// Defines the beginning of the scope of an automation function. This constuctor - /// calls EnterAutomationFunction to signal the Shell that the current function is - /// changing the status of the automation objects. - /// - public AutomationScope(IServiceProvider provider) - { - if(null == provider) - { - throw new ArgumentNullException("provider"); - } - extensibility = provider.GetService(typeof(EnvDTE.IVsExtensibility)) as IVsExtensibility3; - if(null == extensibility) - { - throw new InvalidOperationException(); - } - ErrorHandler.ThrowOnFailure(extensibility.EnterAutomationFunction()); - inAutomation = true; - } - - /// - /// Ends the scope of the automation function. This function is also called by the - /// Dispose method. - /// - public void ExitAutomation() - { - if(inAutomation) - { - ErrorHandler.ThrowOnFailure(extensibility.ExitAutomationFunction()); - inAutomation = false; - } - } - - /// - /// Gets the IVsExtensibility3 interface used in the automation function. - /// - public IVsExtensibility3 Extensibility - { - get { return extensibility; } - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - #region IDisposable Members - private void Dispose(bool disposing) - { - if(!this.isDisposed) - { - lock(Mutex) - { - if(disposing) - { - ExitAutomation(); - } - - this.isDisposed = true; - } - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OAFileItem.cs b/SHFB/Source/MPFProj_VS2010/Automation/OAFileItem.cs deleted file mode 100644 index e82ba0df..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OAFileItem.cs +++ /dev/null @@ -1,428 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using EnvDTE; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; -using VSConstants = Microsoft.VisualStudio.VSConstants; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Represents an automation object for a file in a project - /// - [SuppressMessage("Microsoft.Interoperability", "CA1405:ComVisibleTypeBaseTypesShouldBeComVisible")] - [ComVisible(true), CLSCompliant(false)] - public class OAFileItem : OAProjectItem - { - #region ctors - public OAFileItem(OAProject project, FileNode node) - : base(project, node) - { - } - - #endregion - - #region overridden methods - /// - /// Returns the dirty state of the document. - /// - /// Is thrown if the project is closed or it the service provider attached to the project is invalid. - /// Is thrown if the dirty state cannot be retrived. - public override bool IsDirty - { - get - { - return UIThread.DoOnUIThread(delegate() - { - if (this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed || this.Node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - bool isDirty = false; - - using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) - { - DocumentManager manager = this.Node.GetDocumentManager(); - - if (manager == null) - { - throw new InvalidOperationException(); - } - - bool isOpen, isOpenedByUs; - uint docCookie; - IVsPersistDocData persistDocData; - manager.GetDocInfo(out isOpen, out isDirty, out isOpenedByUs, out docCookie, out persistDocData); - } - - return isDirty; - }); - } - - } - - /// - /// Gets the Document associated with the item, if one exists. - /// - public override EnvDTE.Document Document - { - get - { - return UIThread.DoOnUIThread(delegate() - { - if (this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed || this.Node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - - EnvDTE.Document document = null; - - using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) - { - IVsUIHierarchy hier; - uint itemid; - - IVsWindowFrame windowFrame; - - VsShellUtilities.IsDocumentOpen(this.Node.ProjectMgr.Site, this.Node.Url, VSConstants.LOGVIEWID_Any, out hier, out itemid, out windowFrame); - - if (windowFrame != null) - { - object var; - ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out var)); - object documentAsObject; - ErrorHandler.ThrowOnFailure(scope.Extensibility.GetDocumentFromDocCookie((int)var, out documentAsObject)); - if (documentAsObject == null) - { - throw new InvalidOperationException(); - } - else - { - document = (Document)documentAsObject; - } - } - - } - - return document; - }); - } - } - - - /// - /// Opens the file item in the specified view. - /// - /// Specifies the view kind in which to open the item (file) - /// Window object - public override EnvDTE.Window Open(string viewKind) - { - return UIThread.DoOnUIThread(delegate() - { - if (this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed || this.Node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - - IVsWindowFrame windowFrame = null; - IntPtr docData = IntPtr.Zero; - - using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) - { - try - { - // Validate input params - Guid logicalViewGuid = VSConstants.LOGVIEWID_Primary; - try - { - if (!(String.IsNullOrEmpty(viewKind))) - { - logicalViewGuid = new Guid(viewKind); - } - } - catch (FormatException) - { - // Not a valid guid - throw new ArgumentException(SR.GetString(SR.ParameterMustBeAValidGuid, CultureInfo.CurrentUICulture), "viewKind"); - } - - uint itemid; - IVsHierarchy ivsHierarchy; - uint docCookie; - IVsRunningDocumentTable rdt = this.Node.ProjectMgr.Site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - Debug.Assert(rdt != null, " Could not get running document table from the services exposed by this project"); - if (rdt == null) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, this.Node.Url, out ivsHierarchy, out itemid, out docData, out docCookie)); - - // Open the file using the IVsProject3 interface - ErrorHandler.ThrowOnFailure(this.Node.ProjectMgr.OpenItem(this.Node.ID, ref logicalViewGuid, docData, out windowFrame)); - - } - finally - { - if (docData != IntPtr.Zero) - { - Marshal.Release(docData); - } - } - } - - // Get the automation object and return it - return ((windowFrame != null) ? VsShellUtilities.GetWindowObject(windowFrame) : null); - }); - } - - /// - /// Saves the project item. - /// - /// The name with which to save the project or project item. - /// Is thrown if the save operation failes. - /// Is thrown if fileName is null. - public override void Save(string fileName) - { - this.DoSave(false, fileName); - } - - /// - /// Saves the project item. - /// - /// The file name with which to save the solution, project, or project item. If the file exists, it is overwritten - /// true if the rename was successful. False if Save as failes - public override bool SaveAs(string fileName) - { - try - { - this.DoSave(true, fileName); - } - catch(InvalidOperationException) - { - return false; - } - catch(COMException) - { - return false; - } - return true; - } - - /// - /// Gets a value indicating whether the project item is open in a particular view type. - /// - /// A Constants.vsViewKind* indicating the type of view to check. - /// A Boolean value indicating true if the project is open in the given view type; false if not. - public override bool get_IsOpen(string viewKind) - { - return UIThread.DoOnUIThread(delegate() - { - if (this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed || this.Node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - - // Validate input params - Guid logicalViewGuid = VSConstants.LOGVIEWID_Primary; - try - { - if (!(String.IsNullOrEmpty(viewKind))) - { - logicalViewGuid = new Guid(viewKind); - } - } - catch (FormatException) - { - // Not a valid guid - throw new ArgumentException(SR.GetString(SR.ParameterMustBeAValidGuid, CultureInfo.CurrentUICulture), "viewKind"); - } - - bool isOpen = false; - - using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) - { - IVsUIHierarchy hier; - uint itemid; - - IVsWindowFrame windowFrame; - - isOpen = VsShellUtilities.IsDocumentOpen(this.Node.ProjectMgr.Site, this.Node.Url, logicalViewGuid, out hier, out itemid, out windowFrame); - - } - - return isOpen; - }); - } - - /// - /// Gets the ProjectItems for the object. - /// - public override ProjectItems ProjectItems - { - get - { - return UIThread.DoOnUIThread(delegate() - { - if (this.Project.Project.CanFileNodesHaveChilds) - return new OAProjectItems(this.Project, this.Node); - else - return base.ProjectItems; - }); - } - } - - - #endregion - - #region helpers - /// - /// Saves or Save As the file - /// - /// Flag determining which Save method called , the SaveAs or the Save. - /// The name of the project file. - private void DoSave(bool isCalledFromSaveAs, string fileName) - { - UIThread.DoOnUIThread(delegate() - { - if (fileName == null) - { - throw new ArgumentNullException("fileName"); - } - - if (this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed || this.Node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - - using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) - { - IntPtr docData = IntPtr.Zero; - - try - { - IVsRunningDocumentTable rdt = this.Node.ProjectMgr.Site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - Debug.Assert(rdt != null, " Could not get running document table from the services exposed by this project"); - if (rdt == null) - { - throw new InvalidOperationException(); - } - - // First we see if someone else has opened the requested view of the file. - uint itemid; - IVsHierarchy ivsHierarchy; - uint docCookie; - int canceled; - string url = this.Node.Url; - - ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, url, out ivsHierarchy, out itemid, out docData, out docCookie)); - - // If an empty file name is passed in for Save then make the file name the project name. - if (!isCalledFromSaveAs && fileName.Length == 0) - { - ErrorHandler.ThrowOnFailure(this.Node.ProjectMgr.SaveItem(VSSAVEFLAGS.VSSAVE_SilentSave, url, this.Node.ID, docData, out canceled)); - } - else - { - Utilities.ValidateFileName(this.Node.ProjectMgr.Site, fileName); - - // Compute the fullpath from the directory of the existing Url. - string fullPath = fileName; - if (!Path.IsPathRooted(fileName)) - { - string directory = Path.GetDirectoryName(url); - fullPath = Path.Combine(directory, fileName); - } - - if (!isCalledFromSaveAs) - { - if (!NativeMethods.IsSamePath(this.Node.Url, fullPath)) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(this.Node.ProjectMgr.SaveItem(VSSAVEFLAGS.VSSAVE_SilentSave, fullPath, this.Node.ID, docData, out canceled)); - } - else - { - ErrorHandler.ThrowOnFailure(this.Node.ProjectMgr.SaveItem(VSSAVEFLAGS.VSSAVE_SilentSave, fullPath, this.Node.ID, docData, out canceled)); - } - } - - if (canceled == 1) - { - throw new InvalidOperationException(); - } - } - catch (COMException e) - { - throw new InvalidOperationException(e.Message); - } - finally - { - if (docData != IntPtr.Zero) - { - Marshal.Release(docData); - } - } - } - }); - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OAFolderItem.cs b/SHFB/Source/MPFProj_VS2010/Automation/OAFolderItem.cs deleted file mode 100644 index 1d3059b6..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OAFolderItem.cs +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using EnvDTE; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Represents an automation object for a folder in a project - /// - [SuppressMessage("Microsoft.Interoperability", "CA1405:ComVisibleTypeBaseTypesShouldBeComVisible")] - [ComVisible(true), CLSCompliant(false)] - public class OAFolderItem : OAProjectItem - { - #region ctors - public OAFolderItem(OAProject project, FolderNode node) - : base(project, node) - { - } - - #endregion - - #region overridden methods - public override ProjectItems Collection - { - get - { - return UIThread.DoOnUIThread(delegate() - { - ProjectItems items = new OAProjectItems(this.Project, this.Node); - return items; - }); - } - } - - public override ProjectItems ProjectItems - { - get - { - return this.Collection; - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OANavigableProjectItems.cs b/SHFB/Source/MPFProj_VS2010/Automation/OANavigableProjectItems.cs deleted file mode 100644 index 3beda763..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OANavigableProjectItems.cs +++ /dev/null @@ -1,317 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// This can navigate a collection object only (partial implementation of ProjectItems interface) - /// - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - [ComVisible(true), CLSCompliant(false)] - public class OANavigableProjectItems : EnvDTE.ProjectItems - { - #region fields - private OAProject project; - private IList items; - private HierarchyNode nodeWithItems; - #endregion - - #region properties - /// - /// Defines an internal list of project items - /// - internal IList Items - { - get - { - return this.items; - } - } - - /// - /// Defines a relationship to the associated project. - /// - internal OAProject Project - { - get - { - return this.project; - } - } - - /// - /// Defines the node that contains the items - /// - internal HierarchyNode NodeWithItems - { - get - { - return this.nodeWithItems; - } - } - #endregion - - #region ctor - /// - /// Constructor. - /// - /// The associated project. - /// The node that defines the items. - public OANavigableProjectItems(OAProject project, HierarchyNode nodeWithItems) - { - this.project = project; - this.nodeWithItems = nodeWithItems; - this.items = this.GetListOfProjectItems(); - } - - /// - /// Constructor. - /// - /// The associated project. - /// A list of items that will make up the items defined by this object. - /// The node that defines the items. - public OANavigableProjectItems(OAProject project, IList items, HierarchyNode nodeWithItems) - { - this.items = items; - this.project = project; - this.nodeWithItems = nodeWithItems; - } - #endregion - - #region EnvDTE.ProjectItems - - /// - /// Gets a value indicating the number of objects in the collection. - /// - public virtual int Count - { - get - { - return items.Count; - } - } - - /// - /// Gets the immediate parent object of a ProjectItems collection. - /// - public virtual object Parent - { - get - { - return this.nodeWithItems.GetAutomationObject(); - } - } - - /// - /// Gets an enumeration indicating the type of object. - /// - public virtual string Kind - { - get - { - // TODO: Add OAProjectItems.Kind getter implementation - return null; - } - } - - /// - /// Gets the top-level extensibility object. - /// - public virtual EnvDTE.DTE DTE - { - get - { - return (EnvDTE.DTE)this.project.DTE; - } - } - - /// - /// Gets the project hosting the project item or items. - /// - public virtual EnvDTE.Project ContainingProject - { - get - { - return this.project; - } - } - - /// - /// Adds one or more ProjectItem objects from a directory to the ProjectItems collection. - /// - /// The directory from which to add the project item. - /// A ProjectItem object. - public virtual EnvDTE.ProjectItem AddFromDirectory(string directory) - { - throw new NotImplementedException(); - } - - /// - /// Creates a new project item from an existing item template file and adds it to the project. - /// - /// The full path and file name of the template project file. - /// The file name to use for the new project item. - /// A ProjectItem object. - public virtual EnvDTE.ProjectItem AddFromTemplate(string fileName, string name) - { - throw new NotImplementedException(); - } - - /// - /// Creates a new folder in Solution Explorer. - /// - /// The name of the folder node in Solution Explorer. - /// The type of folder to add. The available values are based on vsProjectItemsKindConstants and vsProjectItemKindConstants - /// A ProjectItem object. - public virtual EnvDTE.ProjectItem AddFolder(string name, string kind) - { - throw new NotImplementedException(); - } - - /// - /// Copies a source file and adds it to the project. - /// - /// The path and file name of the project item to be added. - /// A ProjectItem object. - public virtual EnvDTE.ProjectItem AddFromFileCopy(string filePath) - { - throw new NotImplementedException(); - } - - /// - /// Adds a project item from a file that is installed in a project directory structure. - /// - /// The file name of the item to add as a project item. - /// A ProjectItem object. - public virtual EnvDTE.ProjectItem AddFromFile(string fileName) - { - throw new NotImplementedException(); - } - - /// - /// Get Project Item from index - /// - /// Either index by number (1-based) or by name can be used to get the item - /// Project Item. null is return if invalid index is specified - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] - public virtual EnvDTE.ProjectItem Item(object index) - { - if(index is int) - { - int realIndex = (int)index - 1; - if(realIndex >= 0 && realIndex < this.items.Count) - { - return (EnvDTE.ProjectItem)items[realIndex]; - } - return null; - } - else if(index is string) - { - string name = (string)index; - foreach(EnvDTE.ProjectItem item in items) - { - if(String.Compare(item.Name, name, StringComparison.OrdinalIgnoreCase) == 0) - { - return item; - } - } - } - return null; - } - - /// - /// Returns an enumeration for items in a collection. - /// - /// An IEnumerator for this object. - public virtual IEnumerator GetEnumerator() - { - if(this.items == null) - { - yield return null; - } - - int count = items.Count; - for(int i = 0; i < count; i++) - { - yield return items[i]; - } - } - - #endregion - - #region virtual methods - /// - /// Retrives a list of items associated with the current node. - /// - /// A List of project items - protected IList GetListOfProjectItems() - { - return UIThread.DoOnUIThread(delegate() - { - List list = new List(); - for (HierarchyNode child = this.NodeWithItems.FirstChild; child != null; child = child.NextSibling) - { - EnvDTE.ProjectItem item = child.GetAutomationObject() as EnvDTE.ProjectItem; - if (null != item) - { - list.Add(item); - } - } - - return list; - }); - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OANestedProjectItem.cs b/SHFB/Source/MPFProj_VS2010/Automation/OANestedProjectItem.cs deleted file mode 100644 index b10c99eb..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OANestedProjectItem.cs +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project.Automation -{ - [SuppressMessage("Microsoft.Interoperability", "CA1405:ComVisibleTypeBaseTypesShouldBeComVisible")] - [ComVisible(true), CLSCompliant(false)] - public class OANestedProjectItem : OAProjectItem - { - #region fields - EnvDTE.Project nestedProject; - #endregion - - #region ctors - public OANestedProjectItem(OAProject project, NestedProjectNode node) - : base(project, node) - { - if (node == null) - { - throw new ArgumentNullException("node"); - } - - object nestedproject; - if(ErrorHandler.Succeeded(node.NestedHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out nestedproject))) - { - this.nestedProject = nestedproject as EnvDTE.Project; - } - } - - #endregion - - #region overridden methods - /// - /// Returns the collection of project items defined in the nested project - /// - public override EnvDTE.ProjectItems ProjectItems - { - get - { - if(this.nestedProject != null) - { - return this.nestedProject.ProjectItems; - } - return null; - } - } - - /// - /// Returns the nested project. - /// - public override EnvDTE.Project SubProject - { - get - { - return this.nestedProject; - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OANullProperty.cs b/SHFB/Source/MPFProj_VS2010/Automation/OANullProperty.cs deleted file mode 100644 index d1e5f8cb..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OANullProperty.cs +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// This object defines a so called null object that is returned as instead of null. This is because callers in VSCore usually crash if a null propery is returned for them. - /// - [CLSCompliant(false), ComVisible(true)] - public class OANullProperty : EnvDTE.Property - { - #region fields - private OAProperties parent; - #endregion - - #region ctors - - public OANullProperty(OAProperties parent) - { - this.parent = parent; - } - #endregion - - #region EnvDTE.Property - - public object Application - { - get { return String.Empty; } - } - - public EnvDTE.Properties Collection - { - get - { - //todo: EnvDTE.Property.Collection - return this.parent; - } - } - - public EnvDTE.DTE DTE - { - get { return null; } - } - - public object get_IndexedValue(object index1, object index2, object index3, object index4) - { - return String.Empty; - } - - public void let_Value(object value) - { - //todo: let_Value - } - - public string Name - { - get { return String.Empty; } - } - - public short NumIndices - { - get { return 0; } - } - - public object Object - { - get { return this.parent.Target; } - set - { - } - } - - public EnvDTE.Properties Parent - { - get { return this.parent; } - } - - public void set_IndexedValue(object index1, object index2, object index3, object index4, object value) - { - - } - - public object Value - { - get { return String.Empty; } - set { } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OAProject.cs b/SHFB/Source/MPFProj_VS2010/Automation/OAProject.cs deleted file mode 100644 index a2cee8a0..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OAProject.cs +++ /dev/null @@ -1,531 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using EnvDTE; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project.Automation -{ - [ComVisible(true), CLSCompliant(false)] - public class OAProject : EnvDTE.Project, EnvDTE.ISupportVSProperties - { - #region fields - private ProjectNode project; - EnvDTE.ConfigurationManager configurationManager; - #endregion - - #region properties - public ProjectNode Project - { - get { return this.project; } - } - #endregion - - #region ctor - public OAProject(ProjectNode project) - { - this.project = project; - } - #endregion - - #region EnvDTE.Project - /// - /// Gets or sets the name of the object. - /// - public virtual string Name - { - get - { - return project.Caption; - } - set - { - if(this.project == null || this.project.Site == null || this.project.IsClosed) - { - throw new InvalidOperationException(); - } - - UIThread.DoOnUIThread(delegate() - { - using (AutomationScope scope = new AutomationScope(this.project.Site)) - { - project.SetEditLabel(value); - } - }); - } - } - - /// - /// Microsoft Internal Use Only. Gets the file name of the project. - /// - public virtual string FileName - { - get - { - return project.ProjectFile; - } - } - - /// - /// Microsoft Internal Use Only. Specfies if the project is dirty. - /// - public virtual bool IsDirty - { - get - { - int dirty; - - ErrorHandler.ThrowOnFailure(project.IsDirty(out dirty)); - return dirty != 0; - } - set - { - if(this.project == null || this.project.Site == null || this.project.IsClosed) - { - throw new InvalidOperationException(); - } - - UIThread.DoOnUIThread(delegate() - { - using (AutomationScope scope = new AutomationScope(this.project.Site)) - { - project.SetProjectFileDirty(value); - } - }); - } - } - - /// - /// Gets the Projects collection containing the Project object supporting this property. - /// - public virtual EnvDTE.Projects Collection - { - get { return null; } - } - - /// - /// Gets the top-level extensibility object. - /// - public virtual EnvDTE.DTE DTE - { - get - { - return (EnvDTE.DTE)this.project.Site.GetService(typeof(EnvDTE.DTE)); - } - } - - /// - /// Gets a GUID string indicating the kind or type of the object. - /// - public virtual string Kind - { - get { return project.ProjectGuid.ToString("B"); } - } - - /// - /// Gets a ProjectItems collection for the Project object. - /// - public virtual EnvDTE.ProjectItems ProjectItems - { - get - { - return new OAProjectItems(this, project); - } - } - - /// - /// Gets a collection of all properties that pertain to the Project object. - /// - public virtual EnvDTE.Properties Properties - { - get - { - return new OAProperties(this.project.NodeProperties); - } - } - - /// - /// Returns the name of project as a relative path from the directory containing the solution file to the project file - /// - /// Unique name if project is in a valid state. Otherwise null - public virtual string UniqueName - { - get - { - if(this.project == null || this.project.IsClosed) - { - return null; - } - else - { - return UIThread.DoOnUIThread(delegate() - { - // Get Solution service - IVsSolution solution = this.project.GetService(typeof(IVsSolution)) as IVsSolution; - if (solution == null) - { - throw new InvalidOperationException(); - } - - // Ask solution for unique name of project - string uniqueName = string.Empty; - ErrorHandler.ThrowOnFailure(solution.GetUniqueNameOfProject(this.project.InteropSafeIVsHierarchy, out uniqueName)); - return uniqueName; - }); - } - } - } - - /// - /// Gets an interface or object that can be accessed by name at run time. - /// - public virtual object Object - { - get { return this.project.Object; } - } - - /// - /// Gets the requested Extender object if it is available for this object. - /// - /// The name of the extender object. - /// An Extender object. - public virtual object get_Extender(string name) - { - return null; - } - - /// - /// Gets a list of available Extenders for the object. - /// - public virtual object ExtenderNames - { - get { return null; } - } - - /// - /// Gets the Extender category ID (CATID) for the object. - /// - public virtual string ExtenderCATID - { - get { return String.Empty; } - } - - /// - /// Gets the full path and name of the Project object's file. - /// - public virtual string FullName - { - get - { - return UIThread.DoOnUIThread(delegate() - { - string filename; - uint format; - ErrorHandler.ThrowOnFailure(project.GetCurFile(out filename, out format)); - return filename; - }); - } - } - - /// - /// Gets or sets a value indicatingwhether the object has not been modified since last being saved or opened. - /// - public virtual bool Saved - { - get - { - return !this.IsDirty; - } - set - { - if(this.project == null || this.project.Site == null || this.project.IsClosed) - { - throw new InvalidOperationException(); - } - - UIThread.DoOnUIThread(delegate() - { - using (AutomationScope scope = new AutomationScope(this.project.Site)) - { - project.SetProjectFileDirty(!value); - } - }); - } - } - - /// - /// Gets the ConfigurationManager object for this Project . - /// - public virtual EnvDTE.ConfigurationManager ConfigurationManager - { - get - { - return UIThread.DoOnUIThread(delegate() - { - if (this.configurationManager == null) - { - IVsExtensibility3 extensibility = this.project.Site.GetService(typeof(IVsExtensibility)) as IVsExtensibility3; - - if (extensibility == null) - { - throw new InvalidOperationException(); - } - - object configurationManagerAsObject; - ErrorHandler.ThrowOnFailure(extensibility.GetConfigMgr(this.project.InteropSafeIVsHierarchy, VSConstants.VSITEMID_ROOT, out configurationManagerAsObject)); - - if (configurationManagerAsObject == null) - { - throw new InvalidOperationException(); - } - else - { - this.configurationManager = (ConfigurationManager)configurationManagerAsObject; - } - } - - return this.configurationManager; - }); - } - } - - /// - /// Gets the Globals object containing add-in values that may be saved in the solution (.sln) file, the project file, or in the user's profile data. - /// - public virtual EnvDTE.Globals Globals - { - get { return null; } - } - - /// - /// Gets a ProjectItem object for the nested project in the host project. - /// - public virtual EnvDTE.ProjectItem ParentProjectItem - { - get { return null; } - } - - /// - /// Gets the CodeModel object for the project. - /// - public virtual EnvDTE.CodeModel CodeModel - { - get { return null; } - } - - /// - /// Saves the project. - /// - /// The file name with which to save the solution, project, or project item. If the file exists, it is overwritten - /// Is thrown if the save operation failes. - /// Is thrown if fileName is null. - public virtual void SaveAs(string fileName) - { - this.DoSave(true, fileName); - } - - /// - /// Saves the project - /// - /// The file name of the project - /// Is thrown if the save operation failes. - /// Is thrown if fileName is null. - public virtual void Save(string fileName) - { - this.DoSave(false, fileName); - } - - /// - /// Removes the project from the current solution. - /// - public virtual void Delete() - { - if(this.project == null || this.project.Site == null || this.project.IsClosed) - { - throw new InvalidOperationException(); - } - - UIThread.DoOnUIThread(delegate() - { - using (AutomationScope scope = new AutomationScope(this.project.Site)) - { - this.project.Remove(false); - } - }); - } - #endregion - - #region ISupportVSProperties methods - /// - /// Microsoft Internal Use Only. - /// - public virtual void NotifyPropertiesDelete() - { - } - #endregion - - #region private methods - /// - /// Saves or Save Asthe project. - /// - /// Flag determining which Save method called , the SaveAs or the Save. - /// The name of the project file. - private void DoSave(bool isCalledFromSaveAs, string fileName) - { - if(fileName == null) - { - throw new ArgumentNullException("fileName"); - } - - if(this.project == null || this.project.Site == null || this.project.IsClosed) - { - throw new InvalidOperationException(); - } - - UIThread.DoOnUIThread(delegate() - { - using (AutomationScope scope = new AutomationScope(this.project.Site)) - { - // If an empty file name is passed in for Save then make the file name the project name. - if (!isCalledFromSaveAs && string.IsNullOrEmpty(fileName)) - { - // Use the solution service to save the project file. Note that we have to use the service - // so that all the shell's elements are aware that we are inside a save operation and - // all the file change listenters registered by the shell are suspended. - - // Get the cookie of the project file from the RTD. - IVsRunningDocumentTable rdt = this.project.Site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - if (null == rdt) - { - throw new InvalidOperationException(); - } - - IVsHierarchy hier; - uint itemid; - IntPtr unkData; - uint cookie; - ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, this.project.Url, out hier, - out itemid, out unkData, out cookie)); - if (IntPtr.Zero != unkData) - { - Marshal.Release(unkData); - } - - // Verify that we have a cookie. - if (0 == cookie) - { - // This should never happen because if the project is open, then it must be in the RDT. - throw new InvalidOperationException(); - } - - // Get the IVsHierarchy for the project. - IVsHierarchy prjHierarchy = project.InteropSafeIVsHierarchy; - - // Now get the solution. - IVsSolution solution = this.project.Site.GetService(typeof(SVsSolution)) as IVsSolution; - // Verify that we have both solution and hierarchy. - if ((null == prjHierarchy) || (null == solution)) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(solution.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty, prjHierarchy, cookie)); - } - else - { - - // We need to make some checks before we can call the save method on the project node. - // This is mainly because it is now us and not the caller like in case of SaveAs or Save that should validate the file name. - // The IPersistFileFormat.Save method only does a validation that is necesseray to be performed. Example: in case of Save As the - // file name itself is not validated only the whole path. (thus a file name like file\file is accepted, since as a path is valid) - - // 1. The file name has to be valid. - string fullPath = fileName; - try - { - if (!Path.IsPathRooted(fileName)) - { - fullPath = Path.Combine(this.project.ProjectFolder, fileName); - } - } - // We want to be consistent in the error message and exception we throw. fileName could be for example #�&%"�&"% and that would trigger an ArgumentException on Path.IsRooted. - catch (ArgumentException) - { - throw new InvalidOperationException(SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture)); - } - - // It might be redundant but we validate the file and the full path of the file being valid. The SaveAs would also validate the path. - // If we decide that this is performance critical then this should be refactored. - Utilities.ValidateFileName(this.project.Site, fullPath); - - if (!isCalledFromSaveAs) - { - // 2. The file name has to be the same - if (!NativeMethods.IsSamePath(fullPath, this.project.Url)) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(this.project.Save(fullPath, 1, 0)); - } - else - { - ErrorHandler.ThrowOnFailure(this.project.Save(fullPath, 0, 0)); - } - } - } - }); - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OAProjectItem.cs b/SHFB/Source/MPFProj_VS2010/Automation/OAProjectItem.cs deleted file mode 100644 index 6ad38fda..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OAProjectItem.cs +++ /dev/null @@ -1,481 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project.Automation -{ - [ComVisible(true), CLSCompliant(false)] - public class OAProjectItem : EnvDTE.ProjectItem - where T : HierarchyNode - { - - #region fields - private T node; - private OAProject project; - #endregion - - #region properties - protected T Node - { - get - { - return this.node; - } - } - - /// - /// Returns the automation project - /// - protected OAProject Project - { - get - { - return this.project; - } - } - #endregion - - #region ctors - public OAProjectItem(OAProject project, T node) - { - this.node = node; - this.project = project; - } - #endregion - - #region EnvDTE.ProjectItem - - /// - /// Gets the requested Extender if it is available for this object - /// - /// The name of the extender. - /// The extender object. - public virtual object get_Extender(string extenderName) - { - return null; - } - - /// - /// Gets an object that can be accessed by name at run time. - /// - public virtual object Object - { - get - { - return this.node.Object; - } - } - - /// - /// Gets the Document associated with the item, if one exists. - /// - public virtual EnvDTE.Document Document - { - get - { - return null; - } - } - - /// - /// Gets the number of files associated with a ProjectItem. - /// - public virtual short FileCount - { - get - { - return (short)1; - } - } - - /// - /// Gets a collection of all properties that pertain to the object. - /// - public virtual EnvDTE.Properties Properties - { - get - { - return UIThread.DoOnUIThread(delegate() - { - if (this.node.NodeProperties == null) - { - return null; - } - return new OAProperties(this.node.NodeProperties); - }); - } - } - - - /// - /// Gets the FileCodeModel object for the project item. - /// - public virtual EnvDTE.FileCodeModel FileCodeModel - { - get - { - return null; - } - } - - /// - /// Gets a ProjectItems for the object. - /// - public virtual EnvDTE.ProjectItems ProjectItems - { - get - { - return null; - } - } - - /// - /// Gets a GUID string indicating the kind or type of the object. - /// - public virtual string Kind - { - get - { - Guid guid; - ErrorHandler.ThrowOnFailure(this.node.GetGuidProperty((int)__VSHPROPID.VSHPROPID_TypeGuid, out guid)); - return guid.ToString("B"); - } - } - - /// - /// Saves the project item. - /// - /// The name with which to save the project or project item. - /// Implemented by subclasses. - public virtual void Save(string fileName) - { - throw new NotImplementedException(); - } - - /// - /// Gets the top-level extensibility object. - /// - public virtual EnvDTE.DTE DTE - { - get - { - return (EnvDTE.DTE)this.project.DTE; - } - } - - /// - /// Gets the ProjectItems collection containing the ProjectItem object supporting this property. - /// - public virtual EnvDTE.ProjectItems Collection - { - get - { - return UIThread.DoOnUIThread(delegate() - { - // Get the parent node - HierarchyNode parentNode = this.node.Parent; - Debug.Assert(parentNode != null, "Failed to get the parent node"); - - // Get the ProjectItems object for the parent node - if (parentNode is ProjectNode) - { - // The root node for the project - return ((OAProject)parentNode.GetAutomationObject()).ProjectItems; - } - else if (parentNode is FileNode && parentNode.FirstChild != null) - { - // The item has children - return ((OAProjectItem)parentNode.GetAutomationObject()).ProjectItems; - } - else if (parentNode is FolderNode) - { - return ((OAProjectItem)parentNode.GetAutomationObject()).ProjectItems; - } - else - { - // Not supported. Override this method in derived classes to return appropriate collection object - throw new NotImplementedException(); - } - }); - } - } - /// - /// Gets a list of available Extenders for the object. - /// - public virtual object ExtenderNames - { - get - { - return null; - } - } - - /// - /// Gets the ConfigurationManager object for this ProjectItem. - /// - /// We do not support config management based per item. - public virtual EnvDTE.ConfigurationManager ConfigurationManager - { - get - { - return null; - } - } - - /// - /// Gets the project hosting the ProjectItem. - /// - public virtual EnvDTE.Project ContainingProject - { - get - { - return this.project; - } - } - - /// - /// Gets or sets a value indicating whether or not the object has been modified since last being saved or opened. - /// - public virtual bool Saved - { - get - { - return !this.IsDirty; - - } - set - { - throw new NotImplementedException(); - } - } - - /// - /// Gets the Extender category ID (CATID) for the object. - /// - public virtual string ExtenderCATID - { - get - { - return null; - } - } - - /// - /// If the project item is the root of a subproject, then the SubProject property returns the Project object for the subproject. - /// - public virtual EnvDTE.Project SubProject - { - get - { - return null; - } - } - - /// - /// Microsoft Internal Use Only. Checks if the document associated to this item is dirty. - /// - public virtual bool IsDirty - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } - } - - /// - /// Gets or sets the name of the object. - /// - public virtual string Name - { - get - { - return this.node.Caption; - } - set - { - if(this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed || this.node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - - UIThread.DoOnUIThread(delegate() - { - using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) - { - this.node.SetEditLabel(value); - } - }); - } - } - /// - /// Removes the project item from hierarchy. - /// - public virtual void Remove() - { - if(this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed || this.node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - - UIThread.DoOnUIThread(delegate() - { - using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) - { - this.node.Remove(false); - } - }); - } - - /// - /// Removes the item from its project and its storage. - /// - public virtual void Delete() - { - if(this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed || this.node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - - UIThread.DoOnUIThread(delegate() - { - using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) - { - this.node.Remove(true); - } - }); - } - - /// - /// Saves the project item. - /// - /// The file name with which to save the solution, project, or project item. If the file exists, it is overwritten. - /// true if save was successful - /// This method is implemented on subclasses. - public virtual bool SaveAs(string newFileName) - { - throw new NotImplementedException(); - } - - /// - /// Gets a value indicating whether the project item is open in a particular view type. - /// - /// A Constants.vsViewKind* indicating the type of view to check. - /// A Boolean value indicating true if the project is open in the given view type; false if not. - public virtual bool get_IsOpen(string viewKind) - { - throw new NotImplementedException(); - } - - /// - /// Gets the full path and names of the files associated with a project item. - /// - /// The index of the item - /// The full path of the associated item - /// Is thrown if index is not one - public virtual string get_FileNames(short index) - { - // This method should really only be called with 1 as the parameter, but - // there used to be a bug in VB/C# that would work with 0. To avoid breaking - // existing automation they are still accepting 0. To be compatible with them - // we accept it as well. - Debug.Assert(index > 0, "Index is 1 based."); - if(index < 0) - { - throw new ArgumentOutOfRangeException("index"); - } - return this.node.Url; - } - - /// - /// Expands the view of Solution Explorer to show project items. - /// - public virtual void ExpandView() - { - if(this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed || this.node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - - UIThread.DoOnUIThread(delegate() - { - using (AutomationScope scope = new AutomationScope(this.Node.ProjectMgr.Site)) - { - IVsUIHierarchyWindow uiHierarchy = UIHierarchyUtilities.GetUIHierarchyWindow(this.node.ProjectMgr.Site, HierarchyNode.SolutionExplorer); - if (uiHierarchy == null) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(uiHierarchy.ExpandItem(this.node.ProjectMgr.InteropSafeIVsUIHierarchy, this.node.ID, EXPANDFLAGS.EXPF_ExpandFolder)); - - } - }); - } - - /// - /// Opens the project item in the specified view. Not implemented because this abstract class dont know what to open - /// - /// Specifies the view kind in which to open the item - /// Window object - public virtual EnvDTE.Window Open(string ViewKind) - { - throw new NotImplementedException(); - } - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OAProjectItems.cs b/SHFB/Source/MPFProj_VS2010/Automation/OAProjectItems.cs deleted file mode 100644 index 655a3456..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OAProjectItems.cs +++ /dev/null @@ -1,323 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using EnvDTE; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Contains ProjectItem objects - /// - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - [ComVisible(true), CLSCompliant(false)] - public class OAProjectItems : OANavigableProjectItems - { - #region ctor - public OAProjectItems(OAProject project, HierarchyNode nodeWithItems) - : base(project, nodeWithItems) - { - } - #endregion - - #region EnvDTE.ProjectItems - /// - /// Creates a new project item from an existing item template file and adds it to the project. - /// - /// The full path and file name of the template project file. - /// The file name to use for the new project item. - /// A ProjectItem object. - public override EnvDTE.ProjectItem AddFromTemplate(string fileName, string name) - { - - if(this.Project == null || this.Project.Project == null || this.Project.Project.Site == null || this.Project.Project.IsClosed) - { - throw new InvalidOperationException(); - } - - return UIThread.DoOnUIThread(delegate() - { - ProjectNode proj = this.Project.Project; - EnvDTE.ProjectItem itemAdded = null; - - using (AutomationScope scope = new AutomationScope(this.Project.Project.Site)) - { - string fixedFileName = fileName; - - if (!File.Exists(fileName)) - { - string tempFileName = GetTemplateNoZip(fileName); - if (File.Exists(tempFileName)) - { - fixedFileName = tempFileName; - } - } - - // Determine the operation based on the extension of the filename. - // We should run the wizard only if the extension is vstemplate - // otherwise it's a clone operation - VSADDITEMOPERATION op; - - if(Utilities.IsTemplateFile(fixedFileName)) - { - op = VSADDITEMOPERATION.VSADDITEMOP_RUNWIZARD; - } - else - { - op = VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE; - } - - VSADDRESULT[] result = new VSADDRESULT[1]; - - // It is not a very good idea to throw since the AddItem might return Cancel or Abort. - // The problem is that up in the call stack the wizard code does not check whether it has received a ProjectItem or not and will crash. - // The other problem is that we cannot get add wizard dialog back if a cancel or abort was returned because we throw and that code will never be executed. Typical catch 22. - ErrorHandler.ThrowOnFailure(proj.AddItem(this.NodeWithItems.ID, op, name, 0, new string[1] { fixedFileName }, IntPtr.Zero, result)); - - string fileDirectory = proj.GetBaseDirectoryForAddingFiles(this.NodeWithItems); - string templateFilePath = System.IO.Path.Combine(fileDirectory, name); - itemAdded = this.EvaluateAddResult(result[0], templateFilePath); - } - - return itemAdded; - }); - } - - /// - /// Adds a folder to the collection of ProjectItems with the given name. - /// - /// The kind must be null, empty string, or the string value of vsProjectItemKindPhysicalFolder. - /// Virtual folders are not supported by this implementation. - /// - /// The name of the new folder to add - /// A string representing a Guid of the folder kind. - /// A ProjectItem representing the newly added folder. - public override ProjectItem AddFolder(string name, string kind) - { - if(this.Project == null || this.Project.Project == null || this.Project.Project.Site == null || this.Project.Project.IsClosed) - { - throw new InvalidOperationException(); - } - - return UIThread.DoOnUIThread(delegate() - { - //Verify name is not null or empty - Utilities.ValidateFileName(this.Project.Project.Site, name); - - //Verify that kind is null, empty, or a physical folder - if (!(string.IsNullOrEmpty(kind) || kind.Equals(EnvDTE.Constants.vsProjectItemKindPhysicalFolder))) - { - throw new ArgumentException("Parameter specification for AddFolder was not meet", "kind"); - } - - for (HierarchyNode child = this.NodeWithItems.FirstChild; child != null; child = child.NextSibling) - { - if (child.Caption.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, "Folder already exists with the name '{0}'", name)); - } - } - - ProjectNode proj = this.Project.Project; - - HierarchyNode newFolder = null; - using (AutomationScope scope = new AutomationScope(this.Project.Project.Site)) - { - - //In the case that we are adding a folder to a folder, we need to build up - //the path to the project node. - name = Path.Combine(this.NodeWithItems.VirtualNodeName, name); - - newFolder = proj.CreateFolderNodes(name); - } - - return newFolder.GetAutomationObject() as ProjectItem; - }); - } - - /// - /// Copies a source file and adds it to the project. - /// - /// The path and file name of the project item to be added. - /// A ProjectItem object. - public override EnvDTE.ProjectItem AddFromFileCopy(string filePath) - { - return this.AddItem(filePath, VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE); - } - - /// - /// Adds a project item from a file that is installed in a project directory structure. - /// - /// The file name of the item to add as a project item. - /// A ProjectItem object. - public override EnvDTE.ProjectItem AddFromFile(string fileName) - { - // TODO: VSADDITEMOP_LINKTOFILE - return this.AddItem(fileName, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE); - } - - #endregion - - #region helper methods - /// - /// Adds an item to the project. - /// - /// The full path of the item to add. - /// The VSADDITEMOPERATION to use when adding the item. - /// A ProjectItem object. - protected virtual EnvDTE.ProjectItem AddItem(string path, VSADDITEMOPERATION op) - { - if(this.Project == null || this.Project.Project == null || this.Project.Project.Site == null || this.Project.Project.IsClosed) - { - throw new InvalidOperationException(); - } - - return UIThread.DoOnUIThread(delegate() - { - ProjectNode proj = this.Project.Project; - - EnvDTE.ProjectItem itemAdded = null; - using (AutomationScope scope = new AutomationScope(this.Project.Project.Site)) - { - VSADDRESULT[] result = new VSADDRESULT[1]; - ErrorHandler.ThrowOnFailure(proj.AddItem(this.NodeWithItems.ID, op, path, 0, new string[1] { path }, IntPtr.Zero, result)); - - string fileName = System.IO.Path.GetFileName(path); - string fileDirectory = proj.GetBaseDirectoryForAddingFiles(this.NodeWithItems); - string filePathInProject = System.IO.Path.Combine(fileDirectory, fileName); - - itemAdded = this.EvaluateAddResult(result[0], filePathInProject); - } - - return itemAdded; - }); - } - - /// - /// Evaluates the result of an add operation. - /// - /// The VSADDRESULT returned by the Add methods - /// The full path of the item added. - /// A ProjectItem object. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] - protected virtual EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path) - { - return UIThread.DoOnUIThread(delegate() - { - if (result == VSADDRESULT.ADDRESULT_Success) - { - HierarchyNode nodeAdded = this.NodeWithItems.FindChild(path); - Debug.Assert(nodeAdded != null, "We should have been able to find the new element in the hierarchy"); - if (nodeAdded != null) - { - EnvDTE.ProjectItem item = null; - if (nodeAdded is FileNode) - { - item = new OAFileItem(this.Project, nodeAdded as FileNode); - } - else if (nodeAdded is NestedProjectNode) - { - item = new OANestedProjectItem(this.Project, nodeAdded as NestedProjectNode); - } - else - { - item = new OAProjectItem(this.Project, nodeAdded); - } - - this.Items.Add(item); - return item; - } - } - return null; - }); - } - - /// - /// Removes .zip extensions from the components of a path. - /// - private static string GetTemplateNoZip(string fileName) - { - char[] separators = { '\\' }; - string[] components = fileName.Split(separators); - - for (int i = 0; i < components.Length; i++) - { - string component = components[i]; - - if (Path.GetExtension(component).Equals(".zip", StringComparison.InvariantCultureIgnoreCase)) - { - component = Path.GetFileNameWithoutExtension(component); - components[i] = component; - } - } - - // if first element is a drive, we need to combine the first and second. - // Path.Combine does not add a directory separator between the drive and the - // first directory. - if (components.Length > 1) - { - if (Path.IsPathRooted(components[0])) - { - components[0] = string.Format("{0}{1}{2}", components[0], Path.DirectorySeparatorChar, components[1]); - components[1] = string.Empty; // Path.Combine drops empty strings. - } - } - - return Path.Combine(components); - } - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OAProperties.cs b/SHFB/Source/MPFProj_VS2010/Automation/OAProperties.cs deleted file mode 100644 index 9fdb4682..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OAProperties.cs +++ /dev/null @@ -1,328 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Contains all of the properties of a given object that are contained in a generic collection of properties. - /// - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - [CLSCompliant(false), ComVisible(true)] - public class OAProperties : EnvDTE.Properties - { - #region fields - private NodeProperties target; - private Dictionary properties = new Dictionary(); - #endregion - - #region properties - /// - /// Defines the NodeProperties object that contains the defines the properties. - /// - public NodeProperties Target - { - get - { - return this.target; - } - } - - /// - /// The hierarchy node for the object which properties this item represent - /// - public HierarchyNode Node - { - get - { - return this.Target.Node; - } - } - - /// - /// Defines a dictionary of the properties contained. - /// - public Dictionary Properties - { - get - { - return this.properties; - } - } - #endregion - - #region ctor - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] - public OAProperties(NodeProperties target) - { - System.Diagnostics.Debug.Assert(target != null); - - if (target == null) - { - throw new ArgumentNullException("target"); - } - - this.target = target; - this.AddPropertiesFromType(target.GetType()); - } - #endregion - - #region EnvDTE.Properties - /// - /// Microsoft Internal Use Only. - /// - public virtual object Application - { - get { return null; } - } - - /// - /// Gets a value indicating the number of objects in the collection. - /// - public int Count - { - get { return properties.Count; } - } - - /// - /// Gets the top-level extensibility object. - /// - public virtual EnvDTE.DTE DTE - { - get - { - return UIThread.DoOnUIThread(delegate() - { - if (this.target == null || this.target.Node == null || this.target.Node.ProjectMgr == null || this.target.Node.ProjectMgr.IsClosed || - this.target.Node.ProjectMgr.Site == null) - { - throw new InvalidOperationException(); - } - return this.target.Node.ProjectMgr.Site.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; - }); - } - } - - /// - /// Gets an enumeration for items in a collection. - /// - /// An enumerator. - public IEnumerator GetEnumerator() - { - if(this.properties == null) - { - yield return null; - } - - if(this.properties.Count == 0) - { - yield return new OANullProperty(this); - } - - IEnumerator enumerator = this.properties.Values.GetEnumerator(); - - while(enumerator.MoveNext()) - { - yield return enumerator.Current; - } - } - - /// - /// Returns an indexed member of a Properties collection. - /// - /// The index at which to return a mamber. - /// A Property object. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] - public virtual EnvDTE.Property Item(object index) - { - if(index is string) - { - string indexAsString = (string)index; - if(this.properties.ContainsKey(indexAsString)) - { - return (EnvDTE.Property)this.properties[indexAsString]; - } - } - else if(index is int) - { - int realIndex = (int)index - 1; - if(realIndex >= 0 && realIndex < this.properties.Count) - { - IEnumerator enumerator = this.properties.Values.GetEnumerator(); - - int i = 0; - while(enumerator.MoveNext()) - { - if(i++ == realIndex) - { - return (EnvDTE.Property)enumerator.Current; - } - } - } - } - - // TODO: Check the properties it looks for. Most can be ignored - System.Diagnostics.Debug.WriteLine("WARNING: Project queried for unknown property via automation: {0}", index); - return null; - -// throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "index"); - } - /// - /// Gets the immediate parent object of a Properties collection. - /// - public virtual object Parent - { - get { return null; } - } - #endregion - - #region methods - /// - /// Add properties to the collection of properties filtering only those properties which are com-visible and AutomationBrowsable - /// - /// The type of NodeProperties the we should filter on - protected void AddPropertiesFromType(Type targetType) - { - Debug.Assert(targetType != null); - - if (targetType == null) - { - throw new ArgumentNullException("targetType"); - } - - // If the type is not COM visible, we do not expose any of the properties - if(!IsComVisible(targetType)) - return; - - // Add all properties being ComVisible and AutomationVisible - PropertyInfo[] propertyInfos = targetType.GetProperties(); - foreach(PropertyInfo propertyInfo in propertyInfos) - { - if(!IsInMap(propertyInfo) && IsComVisible(propertyInfo) && IsAutomationVisible(propertyInfo)) - { - AddProperty(propertyInfo); - } - } - } - #endregion - - #region virtual methods - /// - /// Creates a new OAProperty object and adds it to the current list of properties - /// - /// The property to be associated with an OAProperty object - protected virtual void AddProperty(PropertyInfo propertyInfo) - { - if (propertyInfo == null) - { - throw new ArgumentNullException("propertyInfo"); - } - - this.properties.Add(propertyInfo.Name, new OAProperty(this, propertyInfo)); - } - #endregion - - #region helper methods - - private bool IsInMap(PropertyInfo propertyInfo) - { - return this.properties.ContainsKey(propertyInfo.Name); - } - - private static bool IsAutomationVisible(PropertyInfo propertyInfo) - { - object[] customAttributesOnProperty = propertyInfo.GetCustomAttributes(typeof(AutomationBrowsableAttribute), true); - - foreach(AutomationBrowsableAttribute attr in customAttributesOnProperty) - { - if(!attr.Browsable) - { - return false; - } - } - return true; - } - - private static bool IsComVisible(Type targetType) - { - object[] customAttributesOnProperty = targetType.GetCustomAttributes(typeof(ComVisibleAttribute), true); - - foreach(ComVisibleAttribute attr in customAttributesOnProperty) - { - if(!attr.Value) - { - return false; - } - } - return true; - } - - private static bool IsComVisible(PropertyInfo propertyInfo) - { - object[] customAttributesOnProperty = propertyInfo.GetCustomAttributes(typeof(ComVisibleAttribute), true); - - foreach(ComVisibleAttribute attr in customAttributesOnProperty) - { - if(!attr.Value) - { - return false; - } - } - return true; - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OAProperty.cs b/SHFB/Source/MPFProj_VS2010/Automation/OAProperty.cs deleted file mode 100644 index 72c72d9a..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OAProperty.cs +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project.Automation -{ - [CLSCompliant(false), ComVisible(true)] - public class OAProperty : EnvDTE.Property - { - #region fields - private OAProperties parent; - private PropertyInfo pi; - #endregion - - #region ctors - - public OAProperty(OAProperties parent, PropertyInfo pi) - { - this.parent = parent; - this.pi = pi; - } - #endregion - - #region EnvDTE.Property - /// - /// Microsoft Internal Use Only. - /// - public object Application - { - get { return null; } - } - - /// - /// Gets the Collection containing the Property object supporting this property. - /// - public EnvDTE.Properties Collection - { - get - { - //todo: EnvDTE.Property.Collection - return this.parent; - } - } - - /// - /// Gets the top-level extensibility object. - /// - public EnvDTE.DTE DTE - { - get - { - return this.parent.DTE; - } - } - - /// - /// Returns one element of a list. - /// - /// The index of the item to display. - /// The index of the item to display. Reserved for future use. - /// The index of the item to display. Reserved for future use. - /// The index of the item to display. Reserved for future use. - /// The value of a property - public object get_IndexedValue(object index1, object index2, object index3, object index4) - { - ParameterInfo[] par = pi.GetIndexParameters(); - int len = Math.Min(par.Length, 4); - if(len == 0) return this.Value; - object[] index = new object[len]; - Array.Copy(new object[4] { index1, index2, index3, index4 }, index, len); - return this.pi.GetValue(this.parent.Target, index); - } - - /// - /// Setter function to set properties values. - /// - /// - public void let_Value(object value) - { - this.Value = value; - } - - /// - /// Gets the name of the object. - /// - public string Name - { - get - { - return pi.Name; - } - } - - /// - /// Gets the number of indices required to access the value. - /// - public short NumIndices - { - get { return (short)pi.GetIndexParameters().Length; } - } - - /// - /// Sets or gets the object supporting the Property object. - /// - public object Object - { - get - { - return this.parent.Target; - } - set - { - } - } - - /// - /// Microsoft Internal Use Only. - /// - public EnvDTE.Properties Parent - { - get { return this.parent; } - } - - /// - /// Sets the value of the property at the specified index. - /// - /// The index of the item to set. - /// Reserved for future use. - /// Reserved for future use. - /// Reserved for future use. - /// The value to set. - public void set_IndexedValue(object index1, object index2, object index3, object index4, object value) - { - ParameterInfo[] par = pi.GetIndexParameters(); - int len = Math.Min(par.Length, 4); - if(len == 0) - { - this.Value = value; - } - else - { - object[] index = new object[len]; - Array.Copy(new object[4] { index1, index2, index3, index4 }, index, len); - - using(AutomationScope scope = new AutomationScope(this.parent.Target.Node.ProjectMgr.Site)) - { - this.pi.SetValue(this.parent.Target, value, index); - } - } - - } - - /// - /// Gets or sets the value of the property returned by the Property object. - /// - public object Value - { - get { return pi.GetValue(this.parent.Target, null); } - set - { - using(AutomationScope scope = new AutomationScope(this.parent.Target.Node.ProjectMgr.Site)) - { - this.pi.SetValue(this.parent.Target, value, null); - } - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OAReferenceFolderItem.cs b/SHFB/Source/MPFProj_VS2010/Automation/OAReferenceFolderItem.cs deleted file mode 100644 index 43152c38..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OAReferenceFolderItem.cs +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Contains OAReferenceItem objects - /// - [SuppressMessage("Microsoft.Interoperability", "CA1405:ComVisibleTypeBaseTypesShouldBeComVisible")] - [ComVisible(true), CLSCompliant(false)] - public class OAReferenceFolderItem : OAProjectItem - { - #region ctors - public OAReferenceFolderItem(OAProject project, ReferenceContainerNode node) - : base(project, node) - { - } - - #endregion - - #region overridden methods - /// - /// Returns the project items collection of all the references defined for this project. - /// - public override EnvDTE.ProjectItems ProjectItems - { - get - { - return new OANavigableProjectItems(this.Project, this.GetListOfProjectItems(), this.Node); - } - } - - - #endregion - - #region Helper methods - private List GetListOfProjectItems() - { - List list = new List(); - for(HierarchyNode child = this.Node.FirstChild; child != null; child = child.NextSibling) - { - ReferenceNode node = child as ReferenceNode; - - if(node != null) - { - list.Add(new OAReferenceItem(this.Project, node)); - } - } - - return list; - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OAReferenceItem.cs b/SHFB/Source/MPFProj_VS2010/Automation/OAReferenceItem.cs deleted file mode 100644 index d856c710..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OAReferenceItem.cs +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Represents the automation object equivalent to a ReferenceNode object - /// - [SuppressMessage("Microsoft.Interoperability", "CA1405:ComVisibleTypeBaseTypesShouldBeComVisible")] - [ComVisible(true), CLSCompliant(false)] - public class OAReferenceItem : OAProjectItem - { - #region ctors - public OAReferenceItem(OAProject project, ReferenceNode node) - : base(project, node) - { - } - - #endregion - - #region overridden methods - /// - /// Not implemented. If called throws invalid operation exception. - /// - public override void Delete() - { - throw new InvalidOperationException(); - } - - - /// - /// Not implemented. If called throws invalid operation exception. - /// - /// A Constants. vsViewKind indicating the type of view to use. - /// - public override EnvDTE.Window Open(string viewKind) - { - throw new InvalidOperationException(); - } - - /// - /// Gets or sets the name of the object. - /// - public override string Name - { - get - { - return base.Name; - } - set - { - throw new InvalidOperationException(); - } - } - - /// - /// Gets the ProjectItems collection containing the ProjectItem object supporting this property. - /// - public override EnvDTE.ProjectItems Collection - { - get - { - // Get the parent node (ReferenceContainerNode) - ReferenceContainerNode parentNode = this.Node.Parent as ReferenceContainerNode; - Debug.Assert(parentNode != null, "Failed to get the parent node"); - - // Get the ProjectItems object for the parent node - if(parentNode != null) - { - // The root node for the project - return ((OAReferenceFolderItem)parentNode.GetAutomationObject()).ProjectItems; - } - - return null; - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/OASolutionFolder.cs b/SHFB/Source/MPFProj_VS2010/Automation/OASolutionFolder.cs deleted file mode 100644 index c39d2a31..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/OASolutionFolder.cs +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Globalization; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project.Automation -{ - [ComVisible(true), CLSCompliant(false)] - public class OASolutionFolder : EnvDTE80.SolutionFolder - where T : HierarchyNode - { - bool hidden = false; - T node; - - public OASolutionFolder(T associatedNode) - { - if(associatedNode == null) - { - throw new ArgumentNullException("associatedNode"); - } - - Debug.Assert(associatedNode.ProjectMgr is ProjectContainerNode, "Expecting obejct of type" + typeof(ProjectContainerNode).Name); - - if(!(associatedNode.ProjectMgr is ProjectContainerNode)) - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "associatedNode"); - - this.node = associatedNode; - } - - - #region SolutionFolder Members - - public virtual EnvDTE.Project AddFromFile(string fileName) - { - ProjectContainerNode projectContainer = (ProjectContainerNode)this.node.ProjectMgr; - ProjectElement newElement = new ProjectElement(projectContainer, fileName, ProjectFileConstants.SubProject); - NestedProjectNode newNode = projectContainer.AddExistingNestedProject(newElement, __VSCREATEPROJFLAGS.CPF_NOTINSLNEXPLR | __VSCREATEPROJFLAGS.CPF_SILENT | __VSCREATEPROJFLAGS.CPF_OPENFILE); - if(newNode == null) - return null; - // Now that the sub project was created, get its extensibility object so we can return it - object newProject = null; - if(ErrorHandler.Succeeded(newNode.NestedHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out newProject))) - return newProject as EnvDTE.Project; - else - return null; - } - - public virtual EnvDTE.Project AddFromTemplate(string fileName, string destination, string projectName) - { - bool isVSTemplate = Utilities.IsTemplateFile(fileName); - - NestedProjectNode newNode = null; - if(isVSTemplate) - { - // Get the wizard to run, we will get called again and use the alternate code path - ProjectElement newElement = new ProjectElement(this.node.ProjectMgr, System.IO.Path.Combine(destination, projectName), ProjectFileConstants.SubProject); - newElement.SetMetadata(ProjectFileConstants.Template, fileName); - ((ProjectContainerNode)this.node.ProjectMgr).RunVsTemplateWizard(newElement, false); - } - else - { - if((String.IsNullOrEmpty(System.IO.Path.GetExtension(projectName)))) - { - string targetExtension = System.IO.Path.GetExtension(fileName); - projectName = System.IO.Path.ChangeExtension(projectName, targetExtension); - } - - ProjectContainerNode projectContainer = (ProjectContainerNode)this.node.ProjectMgr; - newNode = projectContainer.AddNestedProjectFromTemplate(fileName, destination, projectName, null, __VSCREATEPROJFLAGS.CPF_NOTINSLNEXPLR | __VSCREATEPROJFLAGS.CPF_SILENT | __VSCREATEPROJFLAGS.CPF_CLONEFILE); - } - if(newNode == null) - return null; - - // Now that the sub project was created, get its extensibility object so we can return it - object newProject = null; - if(ErrorHandler.Succeeded(newNode.NestedHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out newProject))) - return newProject as EnvDTE.Project; - else - return null; - } - - public virtual EnvDTE.Project AddSolutionFolder(string Name) - { - throw new NotImplementedException(); - } - - public virtual EnvDTE.Project Parent - { - get - { - throw new NotImplementedException(); - } - } - - public virtual bool Hidden - { - get - { - return hidden; - } - set - { - hidden = value; - } - } - - public virtual EnvDTE.DTE DTE - { - get - { - return (EnvDTE.DTE)this.node.ProjectMgr.Site.GetService(typeof(EnvDTE.DTE)); - } - } - - #endregion - } - -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAAssemblyReference.cs b/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAAssemblyReference.cs deleted file mode 100644 index 2f9dc518..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAAssemblyReference.cs +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System.Diagnostics.CodeAnalysis; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Text; -using VSLangProj; - -namespace Microsoft.VisualStudio.Project.Automation -{ - [SuppressMessage("Microsoft.Interoperability", "CA1405:ComVisibleTypeBaseTypesShouldBeComVisible")] - [ComVisible(true)] - public class OAAssemblyReference : OAReferenceBase - { - public OAAssemblyReference(AssemblyReferenceNode assemblyReference) : - base(assemblyReference) - { - } - - #region Reference override - public override int BuildNumber - { - get - { - if((null == BaseReferenceNode.ResolvedAssembly) || - (null == BaseReferenceNode.ResolvedAssembly.Version)) - { - return 0; - } - return BaseReferenceNode.ResolvedAssembly.Version.Build; - } - } - public override string Culture - { - get - { - if((null == BaseReferenceNode.ResolvedAssembly) || - (null == BaseReferenceNode.ResolvedAssembly.CultureInfo)) - { - return string.Empty; - } - return BaseReferenceNode.ResolvedAssembly.CultureInfo.Name; - } - } - public override string Identity - { - get - { - // Note that in this function we use the assembly name instead of the resolved one - // because the identity of this reference is the assembly name needed by the project, - // not the specific instance found in this machine / environment. - if(null == BaseReferenceNode.AssemblyName) - { - return null; - } - return BaseReferenceNode.AssemblyName.FullName; - } - } - public override int MajorVersion - { - get - { - if((null == BaseReferenceNode.ResolvedAssembly) || - (null == BaseReferenceNode.ResolvedAssembly.Version)) - { - return 0; - } - return BaseReferenceNode.ResolvedAssembly.Version.Major; - } - } - public override int MinorVersion - { - get - { - if((null == BaseReferenceNode.ResolvedAssembly) || - (null == BaseReferenceNode.ResolvedAssembly.Version)) - { - return 0; - } - return BaseReferenceNode.ResolvedAssembly.Version.Minor; - } - } - - public override string PublicKeyToken - { - get - { - if((null == BaseReferenceNode.ResolvedAssembly) || - (null == BaseReferenceNode.ResolvedAssembly.GetPublicKeyToken())) - { - return null; - } - StringBuilder builder = new StringBuilder(); - byte[] publicKeyToken = BaseReferenceNode.ResolvedAssembly.GetPublicKeyToken(); - for(int i = 0; i < publicKeyToken.Length; i++) - { - builder.AppendFormat("{0:x}", publicKeyToken[i]); - } - return builder.ToString(); - } - } - - public override string Name - { - get - { - if(null != BaseReferenceNode.ResolvedAssembly) - { - return BaseReferenceNode.ResolvedAssembly.Name; - } - if(null != BaseReferenceNode.AssemblyName) - { - return BaseReferenceNode.AssemblyName.Name; - } - return null; - } - } - public override int RevisionNumber - { - get - { - if((null == BaseReferenceNode.ResolvedAssembly) || - (null == BaseReferenceNode.ResolvedAssembly.Version)) - { - return 0; - } - return BaseReferenceNode.ResolvedAssembly.Version.Revision; - } - } - public override bool StrongName - { - get - { - if((null == BaseReferenceNode.ResolvedAssembly) || - (0 == (BaseReferenceNode.ResolvedAssembly.Flags & AssemblyNameFlags.PublicKey))) - { - return false; - } - return true; - } - } - public override prjReferenceType Type - { - get - { - return prjReferenceType.prjReferenceTypeAssembly; - } - } - public override string Version - { - get - { - if((null == BaseReferenceNode.ResolvedAssembly) || - (null == BaseReferenceNode.ResolvedAssembly.Version)) - { - return string.Empty; - } - return BaseReferenceNode.ResolvedAssembly.Version.ToString(); - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OABuildManager.cs b/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OABuildManager.cs deleted file mode 100644 index 5be37ae1..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OABuildManager.cs +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using Microsoft.VisualStudio.Shell.Interop; -using VSLangProj; -using Microsoft.VisualStudio; - -namespace Microsoft.VisualStudio.Project.Automation -{ - public class OABuildManager : ConnectionPointContainer, - IEventSource<_dispBuildManagerEvents>, - BuildManager, - BuildManagerEvents - { - private ProjectNode projectManager; - - public OABuildManager(ProjectNode project) - { - projectManager = project; - AddEventSource<_dispBuildManagerEvents>(this as IEventSource<_dispBuildManagerEvents>); - } - - - #region BuildManager Members - - public virtual string BuildDesignTimeOutput(string bstrOutputMoniker) - { - throw new NotImplementedException(); - } - - public virtual EnvDTE.Project ContainingProject - { - get { return projectManager.GetAutomationObject() as EnvDTE.Project; } - } - - public virtual EnvDTE.DTE DTE - { - get { return projectManager.Site.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - public virtual object DesignTimeOutputMonikers - { - get { throw new NotImplementedException(); } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - public virtual object Parent - { - get { throw new NotImplementedException(); } - } - - #endregion - - #region _dispBuildManagerEvents_Event Members - - public event _dispBuildManagerEvents_DesignTimeOutputDeletedEventHandler DesignTimeOutputDeleted; - - public event _dispBuildManagerEvents_DesignTimeOutputDirtyEventHandler DesignTimeOutputDirty; - - #endregion - - #region IEventSource<_dispBuildManagerEvents> Members - - void IEventSource<_dispBuildManagerEvents>.OnSinkAdded(_dispBuildManagerEvents sink) - { - DesignTimeOutputDeleted += new _dispBuildManagerEvents_DesignTimeOutputDeletedEventHandler(sink.DesignTimeOutputDeleted); - DesignTimeOutputDirty += new _dispBuildManagerEvents_DesignTimeOutputDirtyEventHandler(sink.DesignTimeOutputDirty); - } - - void IEventSource<_dispBuildManagerEvents>.OnSinkRemoved(_dispBuildManagerEvents sink) - { - DesignTimeOutputDeleted -= new _dispBuildManagerEvents_DesignTimeOutputDeletedEventHandler(sink.DesignTimeOutputDeleted); - DesignTimeOutputDirty -= new _dispBuildManagerEvents_DesignTimeOutputDirtyEventHandler(sink.DesignTimeOutputDirty); - } - - #endregion - - protected virtual void OnDesignTimeOutputDeleted(string outputMoniker) - { - var handlers = this.DesignTimeOutputDeleted; - if (handlers != null) - { - handlers(outputMoniker); - } - } - - protected virtual void OnDesignTimeOutputDirty(string outputMoniker) - { - var handlers = this.DesignTimeOutputDirty; - if (handlers != null) - { - handlers(outputMoniker); - } - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAComReference.cs b/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAComReference.cs deleted file mode 100644 index b45fa1e1..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAComReference.cs +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project.Automation -{ - [SuppressMessage("Microsoft.Interoperability", "CA1405:ComVisibleTypeBaseTypesShouldBeComVisible")] - [ComVisible(true)] - public class OAComReference : OAReferenceBase - { - public OAComReference(ComReferenceNode comReference) : - base(comReference) - { - } - - #region Reference override - public override string Culture - { - get - { - int locale = 0; - try - { - locale = int.Parse(BaseReferenceNode.LCID, CultureInfo.InvariantCulture); - } - catch(System.FormatException) - { - // Do Nothing - } - if(0 == locale) - { - return string.Empty; - } - CultureInfo culture = new CultureInfo(locale); - return culture.Name; - } - } - public override string Identity - { - get - { - return string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", BaseReferenceNode.TypeGuid.ToString("B"), this.Version); - } - } - public override int MajorVersion - { - get { return BaseReferenceNode.MajorVersionNumber; } - } - public override int MinorVersion - { - get { return BaseReferenceNode.MinorVersionNumber; } - } - public override string Name - { - get { return BaseReferenceNode.Caption; } - } - public override VSLangProj.prjReferenceType Type - { - get - { - return VSLangProj.prjReferenceType.prjReferenceTypeActiveX; - } - } - public override string Version - { - get - { - Version version = new Version(BaseReferenceNode.MajorVersionNumber, BaseReferenceNode.MinorVersionNumber); - return version.ToString(); - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAProjectReference.cs b/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAProjectReference.cs deleted file mode 100644 index 2e400560..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAProjectReference.cs +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using VSLangProj; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Represents a project reference of the solution - /// - [SuppressMessage("Microsoft.Interoperability", "CA1405:ComVisibleTypeBaseTypesShouldBeComVisible")] - [ComVisible(true)] - public class OAProjectReference : OAReferenceBase - { - public OAProjectReference(ProjectReferenceNode projectReference) : - base(projectReference) - { - } - - #region Reference override - public override string Culture - { - get { return string.Empty; } - } - public override string Name - { - get { return BaseReferenceNode.ReferencedProjectName; } - } - public override string Identity - { - get - { - return BaseReferenceNode.Caption; - } - } - public override string Path - { - get - { - return BaseReferenceNode.ReferencedProjectOutputPath; - } - } - public override EnvDTE.Project SourceProject - { - get - { - if(Guid.Empty == BaseReferenceNode.ReferencedProjectGuid) - { - return null; - } - IVsHierarchy hierarchy = VsShellUtilities.GetHierarchy(BaseReferenceNode.ProjectMgr.Site, BaseReferenceNode.ReferencedProjectGuid); - if(null == hierarchy) - { - return null; - } - object extObject; - if(Microsoft.VisualStudio.ErrorHandler.Succeeded( - hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out extObject))) - { - return extObject as EnvDTE.Project; - } - return null; - } - } - public override prjReferenceType Type - { - // TODO: Write the code that finds out the type of the output of the source project. - get { return prjReferenceType.prjReferenceTypeAssembly; } - } - public override string Version - { - get { return string.Empty; } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAReferenceBase.cs b/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAReferenceBase.cs deleted file mode 100644 index 169e00c2..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAReferenceBase.cs +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using VSLangProj; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Represents the automation equivalent of ReferenceNode - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix", MessageId = "T")] - [ComVisible(true)] - public abstract class OAReferenceBase : Reference - where RefType : ReferenceNode - { - #region fields - private RefType referenceNode; - #endregion - - #region ctors - protected OAReferenceBase(RefType referenceNode) - { - this.referenceNode = referenceNode; - } - #endregion - - #region properties - protected RefType BaseReferenceNode - { - get { return referenceNode; } - } - #endregion - - #region Reference Members - public virtual int BuildNumber - { - get { return 0; } - } - - public virtual References Collection - { - get - { - return BaseReferenceNode.Parent.Object as References; - } - } - - public virtual EnvDTE.Project ContainingProject - { - get - { - return BaseReferenceNode.ProjectMgr.GetAutomationObject() as EnvDTE.Project; - } - } - - public virtual bool CopyLocal - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } - } - - public virtual string Culture - { - get { throw new NotImplementedException(); } - } - - public virtual EnvDTE.DTE DTE - { - get - { - return BaseReferenceNode.ProjectMgr.Site.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; - } - } - - public virtual string Description - { - get - { - return this.Name; - } - } - - public virtual string ExtenderCATID - { - get { throw new NotImplementedException(); } - } - - public virtual object ExtenderNames - { - get { throw new NotImplementedException(); } - } - - public virtual string Identity - { - get { throw new NotImplementedException(); } - } - - public virtual int MajorVersion - { - get { return 0; } - } - - public virtual int MinorVersion - { - get { return 0; } - } - - public virtual string Name - { - get { throw new NotImplementedException(); } - } - - public virtual string Path - { - get - { - return BaseReferenceNode.Url; - } - } - - public virtual string PublicKeyToken - { - get { throw new NotImplementedException(); } - } - - public virtual void Remove() - { - BaseReferenceNode.Remove(false); - } - - public virtual int RevisionNumber - { - get { return 0; } - } - - public virtual EnvDTE.Project SourceProject - { - get { return null; } - } - - public virtual bool StrongName - { - get { return false; } - } - - public virtual prjReferenceType Type - { - get { throw new NotImplementedException(); } - } - - public virtual string Version - { - get { return new Version().ToString(); } - } - - public virtual object get_Extender(string ExtenderName) - { - throw new NotImplementedException(); - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAReferences.cs b/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAReferences.cs deleted file mode 100644 index da4cbd68..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAReferences.cs +++ /dev/null @@ -1,355 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio.Shell.Interop; -using VSLangProj; -using ErrorHandler = Microsoft.VisualStudio.ErrorHandler; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Represents the automation object for the equivalent ReferenceContainerNode object - /// - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - [ComVisible(true)] - public class OAReferences : ConnectionPointContainer, - IEventSource<_dispReferencesEvents>, - References, - ReferencesEvents - { - private ReferenceContainerNode container; - public OAReferences(ReferenceContainerNode containerNode) - { - container = containerNode; - AddEventSource<_dispReferencesEvents>(this as IEventSource<_dispReferencesEvents>); - container.OnChildAdded += new EventHandler(OnReferenceAdded); - container.OnChildRemoved += new EventHandler(OnReferenceRemoved); - } - - #region Private Members - private Reference AddFromSelectorData(VSCOMPONENTSELECTORDATA selector, string wrapperTool = null) - { - ReferenceNode refNode = container.AddReferenceFromSelectorData(selector, wrapperTool); - if(null == refNode) - { - return null; - } - - return refNode.Object as Reference; - } - - private Reference FindByName(string stringIndex) - { - foreach(Reference refNode in this) - { - if(0 == string.Compare(refNode.Name, stringIndex, StringComparison.Ordinal)) - { - return refNode; - } - } - return null; - } - #endregion - - #region References Members - - public Reference Add(string bstrPath) - { - if(string.IsNullOrEmpty(bstrPath)) - { - return null; - } - VSCOMPONENTSELECTORDATA selector = new VSCOMPONENTSELECTORDATA(); - selector.type = VSCOMPONENTTYPE.VSCOMPONENTTYPE_File; - selector.bstrFile = bstrPath; - - return AddFromSelectorData(selector); - } - - public Reference AddActiveX(string bstrTypeLibGuid, int lMajorVer, int lMinorVer, int lLocaleId, string bstrWrapperTool) - { - VSCOMPONENTSELECTORDATA selector = new VSCOMPONENTSELECTORDATA(); - selector.type = VSCOMPONENTTYPE.VSCOMPONENTTYPE_Com2; - selector.guidTypeLibrary = new Guid(bstrTypeLibGuid); - selector.lcidTypeLibrary = (uint)lLocaleId; - selector.wTypeLibraryMajorVersion = (ushort)lMajorVer; - selector.wTypeLibraryMinorVersion = (ushort)lMinorVer; - - return AddFromSelectorData(selector, bstrWrapperTool); - } - - public Reference AddProject(EnvDTE.Project project) - { - if(null == project) - { - return null; - } - // Get the soulution. - IVsSolution solution = container.ProjectMgr.Site.GetService(typeof(SVsSolution)) as IVsSolution; - if(null == solution) - { - return null; - } - - // Get the hierarchy for this project. - IVsHierarchy projectHierarchy; - ErrorHandler.ThrowOnFailure(solution.GetProjectOfUniqueName(project.UniqueName, out projectHierarchy)); - - // Create the selector data. - VSCOMPONENTSELECTORDATA selector = new VSCOMPONENTSELECTORDATA(); - selector.type = VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project; - - // Get the project reference string. - ErrorHandler.ThrowOnFailure(solution.GetProjrefOfProject(projectHierarchy, out selector.bstrProjRef)); - - selector.bstrTitle = project.Name; - selector.bstrFile = System.IO.Path.GetDirectoryName(project.FullName); - - return AddFromSelectorData(selector); - } - - public EnvDTE.Project ContainingProject - { - get - { - return container.ProjectMgr.GetAutomationObject() as EnvDTE.Project; - } - } - - public int Count - { - get - { - return container.EnumReferences().Count; - } - } - - public EnvDTE.DTE DTE - { - get - { - return container.ProjectMgr.Site.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; - } - } - - public Reference Find(string bstrIdentity) - { - if(string.IsNullOrEmpty(bstrIdentity)) - { - return null; - } - foreach(Reference refNode in this) - { - if(null != refNode) - { - if(0 == string.Compare(bstrIdentity, refNode.Identity, StringComparison.Ordinal)) - { - return refNode; - } - } - } - return null; - } - - public IEnumerator GetEnumerator() - { - List references = new List(); - IEnumerator baseEnum = container.EnumReferences().GetEnumerator(); - if(null == baseEnum) - { - return references.GetEnumerator(); - } - while(baseEnum.MoveNext()) - { - ReferenceNode refNode = baseEnum.Current as ReferenceNode; - if(null == refNode) - { - continue; - } - Reference reference = refNode.Object as Reference; - if(null != reference) - { - references.Add(reference); - } - } - return references.GetEnumerator(); - } - - public Reference Item(object index) - { - string stringIndex = index as string; - if(null != stringIndex) - { - return FindByName(stringIndex); - } - // Note that this cast will throw if the index is not convertible to int. - int intIndex = (int)index; - IList refs = container.EnumReferences(); - if(null == refs) - { - throw new ArgumentOutOfRangeException("index"); - } - if((intIndex <= 0) || (intIndex > refs.Count)) - { - throw new ArgumentOutOfRangeException("index"); - } - // Let the implementation of IList<> throw in case of index not correct. - return refs[intIndex - 1].Object as Reference; - } - - public object Parent - { - get - { - return container.Parent.Object; - } - } - - #endregion - - #region _dispReferencesEvents_Event Members - public event _dispReferencesEvents_ReferenceAddedEventHandler ReferenceAdded; - public event _dispReferencesEvents_ReferenceChangedEventHandler ReferenceChanged; - public event _dispReferencesEvents_ReferenceRemovedEventHandler ReferenceRemoved; - #endregion - - #region Callbacks for the HierarchyNode events - private void OnReferenceAdded(object sender, HierarchyNodeEventArgs args) - { - // Validate the parameters. - if((container != sender as ReferenceContainerNode) || - (null == args) || (null == args.Child)) - { - return; - } - - // Check if there is any sink for this event. - if(null == ReferenceAdded) - { - return; - } - - // Check that the removed item implements the Reference interface. - Reference reference = args.Child.Object as Reference; - if(null != reference) - { - ReferenceAdded(reference); - } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", - Justification="Support for this has not yet been added")] - private void OnReferenceChanged(object sender, HierarchyNodeEventArgs args) - { - // Validate the parameters. - if ((container != sender as ReferenceContainerNode) || - (null == args) || (null == args.Child)) - { - return; - } - - // Check if there is any sink for this event. - if (null == ReferenceChanged) - { - return; - } - - // Check that the removed item implements the Reference interface. - Reference reference = args.Child.Object as Reference; - if (null != reference) - { - ReferenceChanged(reference); - } - } - - private void OnReferenceRemoved(object sender, HierarchyNodeEventArgs args) - { - // Validate the parameters. - if((container != sender as ReferenceContainerNode) || - (null == args) || (null == args.Child)) - { - return; - } - - // Check if there is any sink for this event. - if(null == ReferenceRemoved) - { - return; - } - - // Check that the removed item implements the Reference interface. - Reference reference = args.Child.Object as Reference; - if(null != reference) - { - ReferenceRemoved(reference); - } - } - #endregion - - #region IEventSource<_dispReferencesEvents> Members - void IEventSource<_dispReferencesEvents>.OnSinkAdded(_dispReferencesEvents sink) - { - ReferenceAdded += new _dispReferencesEvents_ReferenceAddedEventHandler(sink.ReferenceAdded); - ReferenceChanged += new _dispReferencesEvents_ReferenceChangedEventHandler(sink.ReferenceChanged); - ReferenceRemoved += new _dispReferencesEvents_ReferenceRemovedEventHandler(sink.ReferenceRemoved); - } - - void IEventSource<_dispReferencesEvents>.OnSinkRemoved(_dispReferencesEvents sink) - { - ReferenceAdded -= new _dispReferencesEvents_ReferenceAddedEventHandler(sink.ReferenceAdded); - ReferenceChanged -= new _dispReferencesEvents_ReferenceChangedEventHandler(sink.ReferenceChanged); - ReferenceRemoved -= new _dispReferencesEvents_ReferenceRemovedEventHandler(sink.ReferenceRemoved); - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAVSProject.cs b/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAVSProject.cs deleted file mode 100644 index f9ca46c6..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAVSProject.cs +++ /dev/null @@ -1,251 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using EnvDTE; -using VSLangProj; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Represents an automation friendly version of a language-specific project. - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "OAVS")] - [ComVisible(true), CLSCompliant(false)] - public class OAVSProject : VSProject - { - #region fields - private ProjectNode project; - private OAVSProjectEvents events; - #endregion - - #region ctors - public OAVSProject(ProjectNode project) - { - this.project = project; - } - #endregion - - #region VSProject Members - - public virtual ProjectItem AddWebReference(string bstrUrl) - { - throw new NotImplementedException(); - } - - public virtual BuildManager BuildManager - { - get - { - return new OABuildManager(this.project); - } - } - - public virtual void CopyProject(string bstrDestFolder, string bstrDestUNCPath, prjCopyProjectOption copyProjectOption, string bstrUsername, string bstrPassword) - { - throw new NotImplementedException(); - } - - public virtual ProjectItem CreateWebReferencesFolder() - { - throw new NotImplementedException(); - } - - public virtual DTE DTE - { - get - { - return (EnvDTE.DTE)this.project.Site.GetService(typeof(EnvDTE.DTE)); - } - } - - public virtual VSProjectEvents Events - { - get - { - if(events == null) - events = new OAVSProjectEvents(this); - return events; - } - } - - public virtual void Exec(prjExecCommand command, int bSuppressUI, object varIn, out object pVarOut) - { - throw new NotImplementedException(); ; - } - - public virtual void GenerateKeyPairFiles(string strPublicPrivateFile, string strPublicOnlyFile) - { - throw new NotImplementedException(); ; - } - - public virtual string GetUniqueFilename(object pDispatch, string bstrRoot, string bstrDesiredExt) - { - throw new NotImplementedException(); ; - } - - public virtual Imports Imports - { - get - { - throw new NotImplementedException(); - } - } - - public virtual EnvDTE.Project Project - { - get - { - return this.project.GetAutomationObject() as EnvDTE.Project; - } - } - - public virtual References References - { - get - { - ReferenceContainerNode references = project.GetReferenceContainer() as ReferenceContainerNode; - if(null == references) - { - return null; - } - return references.Object as References; - } - } - - public virtual void Refresh() - { - throw new NotImplementedException(); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - public virtual string TemplatePath - { - get - { - throw new NotImplementedException(); - } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - public virtual ProjectItem WebReferencesFolder - { - get - { - throw new NotImplementedException(); - } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - public virtual bool WorkOffline - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } - } - - #endregion - } - - /// - /// Provides access to language-specific project events - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "OAVS")] - [ComVisible(true), CLSCompliant(false)] - public class OAVSProjectEvents : VSProjectEvents - { - #region fields - private OAVSProject vsProject; - #endregion - - #region ctors - public OAVSProjectEvents(OAVSProject vsProject) - { - this.vsProject = vsProject; - } - #endregion - - #region VSProjectEvents Members - - public virtual BuildManagerEvents BuildManagerEvents - { - get - { - return vsProject.BuildManager as BuildManagerEvents; - } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - public virtual ImportsEvents ImportsEvents - { - get - { - throw new NotImplementedException(); - } - } - - public virtual ReferencesEvents ReferencesEvents - { - get - { - return vsProject.References as ReferencesEvents; - } - } - - #endregion - } - -} diff --git a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAVSProjectItem.cs b/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAVSProjectItem.cs deleted file mode 100644 index d65c1774..00000000 --- a/SHFB/Source/MPFProj_VS2010/Automation/VSProject/OAVSProjectItem.cs +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using EnvDTE; -using VSLangProj; - -namespace Microsoft.VisualStudio.Project.Automation -{ - /// - /// Represents a language-specific project item - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "OAVS")] - [ComVisible(true), CLSCompliant(false)] - public class OAVSProjectItem : VSProjectItem - { - #region fields - private FileNode fileNode; - #endregion - - #region ctors - public OAVSProjectItem(FileNode fileNode) - { - this.FileNode = fileNode; - } - #endregion - - #region VSProjectItem Members - - public virtual EnvDTE.Project ContainingProject - { - get { return fileNode.ProjectMgr.GetAutomationObject() as EnvDTE.Project; } - } - - public virtual ProjectItem ProjectItem - { - get { return fileNode.GetAutomationObject() as ProjectItem; } - } - - public virtual DTE DTE - { - get { return (DTE)this.fileNode.ProjectMgr.Site.GetService(typeof(DTE)); } - } - - public virtual void RunCustomTool() - { - this.FileNode.RunGenerator(); - } - - #endregion - - #region public properties - /// - /// File Node property - /// - public FileNode FileNode - { - get - { - return fileNode; - } - set - { - fileNode = value; - } - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/BuildDependency.cs b/SHFB/Source/MPFProj_VS2010/BuildDependency.cs deleted file mode 100644 index 0cf31ef5..00000000 --- a/SHFB/Source/MPFProj_VS2010/BuildDependency.cs +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project -{ - public class BuildDependency : IVsBuildDependency - { - Guid referencedProjectGuid = Guid.Empty; - ProjectNode projectMgr = null; - - [CLSCompliant(false)] - public BuildDependency(ProjectNode projectMgr, Guid projectReference) - { - this.referencedProjectGuid = projectReference; - this.projectMgr = projectMgr; - } - - #region IVsBuildDependency methods - public int get_CanonicalName(out string canonicalName) - { - canonicalName = null; - return VSConstants.S_OK; - } - - public int get_Type(out System.Guid guidType) - { - // All our dependencies are build projects - guidType = VSConstants.GUID_VS_DEPTYPE_BUILD_PROJECT; - return VSConstants.S_OK; - } - - public int get_Description(out string description) - { - description = null; - return VSConstants.S_OK; - } - - [CLSCompliant(false)] - public int get_HelpContext(out uint helpContext) - { - helpContext = 0; - return VSConstants.E_NOTIMPL; - } - - public int get_HelpFile(out string helpFile) - { - helpFile = null; - return VSConstants.E_NOTIMPL; - } - - public int get_MustUpdateBefore(out int mustUpdateBefore) - { - // Must always update dependencies - mustUpdateBefore = 1; - - return VSConstants.S_OK; - } - - public int get_ReferredProject(out object unknownProject) - { - unknownProject = null; - - unknownProject = this.GetReferencedHierarchy(); - - // If we cannot find the referenced hierarchy return S_FALSE. - return (unknownProject == null) ? VSConstants.S_FALSE : VSConstants.S_OK; - } - - #endregion - - #region helper methods - private IVsHierarchy GetReferencedHierarchy() - { - IVsHierarchy hierarchy = null; - - if(this.referencedProjectGuid == Guid.Empty || this.projectMgr == null || this.projectMgr.IsClosed) - { - return hierarchy; - } - - return VsShellUtilities.GetHierarchy(this.projectMgr.Site, this.referencedProjectGuid); - - } - - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/BuildPropertyPage.cs b/SHFB/Source/MPFProj_VS2010/BuildPropertyPage.cs deleted file mode 100644 index 5727c14e..00000000 --- a/SHFB/Source/MPFProj_VS2010/BuildPropertyPage.cs +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Globalization; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Enumerated list of the properties shown on the build property page - /// - internal enum BuildPropertyPageTag - { - OutputPath - } - - /// - /// Defines the properties on the build property page and the logic the binds the properties to project data (load and save) - /// - [CLSCompliant(false), ComVisible(true), Guid("9B3DEA40-7F29-4a17-87A4-00EE08E8241E")] - public class BuildPropertyPage : SettingsPage - { - #region fields - private string outputPath; - - public BuildPropertyPage() - { - this.Name = SR.GetString(SR.BuildCaption, CultureInfo.CurrentUICulture); - } - #endregion - - #region properties - [SRCategoryAttribute(SR.BuildCaption)] - [LocDisplayName(SR.OutputPath)] - [SRDescriptionAttribute(SR.OutputPathDescription)] - public string OutputPath - { - get { return this.outputPath; } - set { this.outputPath = value; this.IsDirty = true; } - } - #endregion - - #region overridden methods - public override string GetClassName() - { - return this.GetType().FullName; - } - - protected override void BindProperties() - { - if(this.ProjectMgr == null) - { - Debug.Assert(false); - return; - } - - this.outputPath = this.GetConfigProperty(BuildPropertyPageTag.OutputPath.ToString()); - } - - protected override int ApplyChanges() - { - if(this.ProjectMgr == null) - { - Debug.Assert(false); - return VSConstants.E_INVALIDARG; - } - - this.SetConfigProperty(BuildPropertyPageTag.OutputPath.ToString(), this.outputPath); - this.IsDirty = false; - return VSConstants.S_OK; - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ComReferenceNode.cs b/SHFB/Source/MPFProj_VS2010/ComReferenceNode.cs deleted file mode 100644 index 033ef637..00000000 --- a/SHFB/Source/MPFProj_VS2010/ComReferenceNode.cs +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.Win32; -using System.Collections.Generic; -using Microsoft.Build.Evaluation; -using Microsoft.Build.Execution; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// This type of node is used for references to COM components. - /// - [CLSCompliant(false)] - [ComVisible(true)] - public class ComReferenceNode : ReferenceNode - { - #region fields - private string typeName; - private Guid typeGuid; - private string projectRelativeFilePath; - private string installedFilePath; - private string minorVersionNumber; - private string majorVersionNumber; - private string lcid; - #endregion - - #region properties - public override string Caption - { - get { return this.typeName; } - } - - public override string Url - { - get - { - return this.projectRelativeFilePath; - } - } - - /// - /// Returns the Guid of the COM object. - /// - public Guid TypeGuid - { - get { return this.typeGuid; } - } - - /// - /// Returns the path where the COM object is installed. - /// - public string InstalledFilePath - { - get { return this.installedFilePath; } - } - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "LCID")] - public string LCID - { - get { return lcid; } - } - - public int MajorVersionNumber - { - get - { - if(string.IsNullOrEmpty(majorVersionNumber)) - { - return 0; - } - return int.Parse(majorVersionNumber, CultureInfo.CurrentCulture); - } - } - - public bool EmbedInteropTypes - { - get - { - bool value; - bool.TryParse(this.ItemNode.GetMetadata(ProjectFileConstants.EmbedInteropTypes), out value); - return value; - } - - set - { - this.ItemNode.SetMetadata(ProjectFileConstants.EmbedInteropTypes, value.ToString()); - } - } - - public string WrapperTool - { - get { return this.ItemNode.GetMetadata(ProjectFileConstants.WrapperTool); } - set { this.ItemNode.SetMetadata(ProjectFileConstants.WrapperTool, value); } - } - - public int MinorVersionNumber - { - get - { - if(string.IsNullOrEmpty(minorVersionNumber)) - { - return 0; - } - return int.Parse(minorVersionNumber, CultureInfo.CurrentCulture); - } - } - private Automation.OAComReference comReference; - internal override object Object - { - get - { - if(null == comReference) - { - comReference = new Automation.OAComReference(this); - } - return comReference; - } - } - #endregion - - #region ctors - /// - /// Constructor for the ComReferenceNode. - /// - public ComReferenceNode(ProjectNode root, ProjectElement element) - : base(root, element) - { - this.typeName = this.ItemNode.GetMetadata(ProjectFileConstants.Include); - string typeGuidAsString = this.ItemNode.GetMetadata(ProjectFileConstants.Guid); - if(typeGuidAsString != null) - { - this.typeGuid = new Guid(typeGuidAsString); - } - - this.majorVersionNumber = this.ItemNode.GetMetadata(ProjectFileConstants.VersionMajor); - this.minorVersionNumber = this.ItemNode.GetMetadata(ProjectFileConstants.VersionMinor); - this.lcid = this.ItemNode.GetMetadata(ProjectFileConstants.Lcid); - this.SetProjectItemsThatRelyOnReferencesToBeResolved(false); - this.SetInstalledFilePath(); - } - - /// - /// Overloaded constructor for creating a ComReferenceNode from selector data - /// - /// The Project node - /// The component selctor data. - /// The wrapper tool - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes")] - public ComReferenceNode(ProjectNode root, VSCOMPONENTSELECTORDATA selectorData, string wrapperTool = null) - : base(root) - { - if(root == null) - { - throw new ArgumentNullException("root"); - } - if(selectorData.type == VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project - || selectorData.type == VSCOMPONENTTYPE.VSCOMPONENTTYPE_ComPlus) - { - throw new ArgumentException("SelectorData cannot be of type VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project or VSCOMPONENTTYPE.VSCOMPONENTTYPE_ComPlus", "selectorData"); - } - - // Initialize private state - this.typeName = selectorData.bstrTitle; - this.typeGuid = selectorData.guidTypeLibrary; - this.majorVersionNumber = selectorData.wTypeLibraryMajorVersion.ToString(CultureInfo.InvariantCulture); - this.minorVersionNumber = selectorData.wTypeLibraryMinorVersion.ToString(CultureInfo.InvariantCulture); - this.lcid = selectorData.lcidTypeLibrary.ToString(CultureInfo.InvariantCulture); - this.WrapperTool = wrapperTool; - - // Check to see if the COM object actually exists. - this.SetInstalledFilePath(); - // If the value cannot be set throw. - if(String.IsNullOrEmpty(this.installedFilePath)) - { - throw new InvalidOperationException(); - } - } - #endregion - - #region methods - protected override NodeProperties CreatePropertiesObject() - { - return new ComReferenceProperties(this); - } - - /// - /// Links a reference node to the project and hierarchy. - /// - protected override void BindReferenceData() - { - Debug.Assert(this.ItemNode != null, "The AssemblyName field has not been initialized"); - - // We need to create the project element at this point if it has not been created. - // We cannot do that from the ctor if input comes from a component selector data, since had we been doing that we would have added a project element to the project file. - // The problem with that approach is that we would need to remove the project element if the item cannot be added to the hierachy (E.g. It already exists). - // It is just safer to update the project file now. This is the intent of this method. - // Call MSBuild to build the target ResolveComReferences - if(this.ItemNode == null || this.ItemNode.Item == null) - { - this.ItemNode = this.GetProjectElementBasedOnInputFromComponentSelectorData(); - } - - this.SetProjectItemsThatRelyOnReferencesToBeResolved(true); - } - - /// - /// Checks if a reference is already added. The method parses all references and compares the the FinalItemSpec and the Guid. - /// - /// true if the assembly has already been added. - protected internal override bool IsAlreadyAdded(out ReferenceNode existingReference) - { - ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode; - Debug.Assert(referencesFolder != null, "Could not find the References node"); - - for(HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling) - { - ComReferenceNode referenceNode = n as ComReferenceNode; - - if(referenceNode != null) - { - // We check if the name and guids are the same - if(referenceNode.TypeGuid == this.TypeGuid && String.Compare(referenceNode.Caption, this.Caption, StringComparison.OrdinalIgnoreCase) == 0) - { - existingReference = referenceNode; - return true; - } - } - } - - existingReference = null; - return false; - } - - /// - /// Determines if this is node a valid node for painting the default reference icon. - /// - /// - protected override bool CanShowDefaultIcon() - { - return !String.IsNullOrEmpty(this.installedFilePath); - } - - /// - /// This is an helper method to convert the VSCOMPONENTSELECTORDATA recieved by the - /// implementer of IVsComponentUser into a ProjectElement that can be used to create - /// an instance of this class. - /// This should not be called for project reference or reference to managed assemblies. - /// - /// ProjectElement corresponding to the COM component passed in - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] - private ProjectElement GetProjectElementBasedOnInputFromComponentSelectorData() - { - - ProjectElement element = new ProjectElement(this.ProjectMgr, this.typeName, ProjectFileConstants.COMReference); - - // Set the basic information regarding this COM component - element.SetMetadata(ProjectFileConstants.Guid, this.typeGuid.ToString("B")); - element.SetMetadata(ProjectFileConstants.VersionMajor, this.majorVersionNumber); - element.SetMetadata(ProjectFileConstants.VersionMinor, this.minorVersionNumber); - element.SetMetadata(ProjectFileConstants.Lcid, this.lcid); - element.SetMetadata(ProjectFileConstants.Isolated, false.ToString()); - - // See if a PIA exist for this component - TypeLibConverter typelib = new TypeLibConverter(); - string assemblyName; - string assemblyCodeBase; - if(typelib.GetPrimaryInteropAssembly(this.typeGuid, Int32.Parse(this.majorVersionNumber, CultureInfo.InvariantCulture), Int32.Parse(this.minorVersionNumber, CultureInfo.InvariantCulture), Int32.Parse(this.lcid, CultureInfo.InvariantCulture), out assemblyName, out assemblyCodeBase)) - { - element.SetMetadata(ProjectFileConstants.WrapperTool, WrapperToolAttributeValue.Primary.ToString().ToLowerInvariant()); - } - else - { - // MSBuild will have to generate an interop assembly - element.SetMetadata(ProjectFileConstants.WrapperTool, WrapperToolAttributeValue.TlbImp.ToString().ToLowerInvariant()); - element.SetMetadata(ProjectFileConstants.EmbedInteropTypes, true.ToString()); - element.SetMetadata(ProjectFileConstants.Private, true.ToString()); - } - return element; - } - - private void SetProjectItemsThatRelyOnReferencesToBeResolved(bool renameItemNode) - { - // Call MSBuild to build the target ResolveComReferences - bool success; - ErrorHandler.ThrowOnFailure(this.ProjectMgr.BuildTarget(MsBuildTarget.ResolveComReferences, out success)); - if(!success) - throw new InvalidOperationException(); - - // Now loop through the generated COM References to find the corresponding one - IEnumerable comReferences = this.ProjectMgr.BuildProject.GetItems(MsBuildGeneratedItemType.ComReferenceWrappers); - foreach (ProjectItem reference in comReferences) - { - if(String.Compare(reference.GetMetadataValue(ProjectFileConstants.Guid), this.typeGuid.ToString("B"), StringComparison.OrdinalIgnoreCase) == 0 - && String.Compare(reference.GetMetadataValue(ProjectFileConstants.VersionMajor), this.majorVersionNumber, StringComparison.OrdinalIgnoreCase) == 0 - && String.Compare(reference.GetMetadataValue(ProjectFileConstants.VersionMinor), this.minorVersionNumber, StringComparison.OrdinalIgnoreCase) == 0 - && String.Compare(reference.GetMetadataValue(ProjectFileConstants.Lcid), this.lcid, StringComparison.OrdinalIgnoreCase) == 0) - { - string name = reference.EvaluatedInclude; - if(Path.IsPathRooted(name)) - { - this.projectRelativeFilePath = name; - } - else - { - this.projectRelativeFilePath = Path.Combine(this.ProjectMgr.ProjectFolder, name); - } - - if(renameItemNode) - { - this.ItemNode.Rename(Path.GetFileNameWithoutExtension(name)); - } - break; - } - } - } - - /// - /// Verify that the TypeLib is registered and set the the installed file path of the com reference. - /// - /// - private void SetInstalledFilePath() - { - string registryPath = string.Format(CultureInfo.InvariantCulture, @"TYPELIB\{0:B}\{1:x}.{2:x}", this.typeGuid, this.MajorVersionNumber, this.MinorVersionNumber); - using(RegistryKey typeLib = Registry.ClassesRoot.OpenSubKey(registryPath)) - { - if(typeLib != null) - { - // Check if we need to set the name for this type. - if(string.IsNullOrEmpty(this.typeName)) - { - this.typeName = typeLib.GetValue(string.Empty) as string; - } - // Now get the path to the file that contains this type library. - using(RegistryKey installKey = typeLib.OpenSubKey(string.Format(CultureInfo.InvariantCulture, @"{0}\win32", this.LCID))) - { - this.installedFilePath = installKey.GetValue(String.Empty) as String; - } - } - } - } - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ConfigProvider.cs b/SHFB/Source/MPFProj_VS2010/ConfigProvider.cs deleted file mode 100644 index 116f10a5..00000000 --- a/SHFB/Source/MPFProj_VS2010/ConfigProvider.cs +++ /dev/null @@ -1,790 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using MSBuild = Microsoft.Build.Evaluation; -using Microsoft.Build.Construction; - -/* This file provides a basefunctionallity for IVsCfgProvider2. - Instead of using the IVsProjectCfgEventsHelper object we have our own little sink and call our own helper methods - similiar to the interface. But there is no real benefit in inheriting from the interface in the first place. - Using the helper object seems to be: - a) undocumented - b) not really wise in the managed world -*/ -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false)] - [ComVisible(true)] - public class ConfigProvider : IVsCfgProvider2, IVsProjectCfgProvider, IVsExtensibleObject - { - #region fields - internal const string configString = " '$(Configuration)' == '{0}' "; - internal const string AnyCPUPlatform = "Any CPU"; - internal const string x86Platform = "x86"; - - private ProjectNode project; - private EventSinkCollection cfgEventSinks = new EventSinkCollection(); - private List, string>> newCfgProps = new List, string>>(); - private Dictionary configurationsList = new Dictionary(); - #endregion - - #region Properties - /// - /// The associated project. - /// - protected ProjectNode ProjectMgr - { - get - { - return this.project; - } - } - /// - /// If the project system wants to add custom properties to the property group then - /// they provide us with this data. - /// - /// Returns/sets the [(<propName, propCondition>) <propValue>] collection - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual List, string>> NewConfigProperties - { - get - { - return newCfgProps; - } - set - { - newCfgProps = value; - } - } - - #endregion - - #region ctors - public ConfigProvider(ProjectNode manager) - { - this.project = manager; - } - #endregion - - #region methods - /// - /// Creates new Project Configuartion objects based on the configuration name. - /// - /// The name of the configuration - /// An instance of a ProjectConfig object. - protected ProjectConfig GetProjectConfiguration(string configName) - { - // if we already created it, return the cached one - if(configurationsList.ContainsKey(configName)) - { - return configurationsList[configName]; - } - - ProjectConfig requestedConfiguration = CreateProjectConfiguration(configName); - configurationsList.Add(configName, requestedConfiguration); - - return requestedConfiguration; - } - - protected virtual ProjectConfig CreateProjectConfiguration(string configName) - { - return new ProjectConfig(this.project, configName); - } - - #endregion - - #region IVsProjectCfgProvider methods - /// - /// Provides access to the IVsProjectCfg interface implemented on a project's configuration object. - /// - /// The canonical name of the configuration to access. - /// The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg) - { - if(projectCfgCanonicalName == null) - { - throw new ArgumentNullException("projectCfgCanonicalName"); - } - - projectCfg = null; - - // Be robust in release - if(projectCfgCanonicalName == null) - { - return VSConstants.E_INVALIDARG; - } - - - Debug.Assert(this.project != null && this.project.BuildProject != null); - - string[] configs = GetPropertiesConditionedOn(ProjectFileConstants.Configuration); - - foreach(string config in configs) - { - if(String.Compare(config, projectCfgCanonicalName, StringComparison.OrdinalIgnoreCase) == 0) - { - projectCfg = this.GetProjectConfiguration(config); - if(projectCfg != null) - { - return VSConstants.S_OK; - } - else - { - return VSConstants.E_FAIL; - } - } - } - - return VSConstants.E_INVALIDARG; - } - - /// - /// Checks whether or not this configuration provider uses independent configurations. - /// - /// true if independent configurations are used, false if they are not used. By default returns true. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int get_UsesIndependentConfigurations(out int usesIndependentConfigurations) - { - usesIndependentConfigurations = 1; - return VSConstants.S_OK; - } - #endregion - - #region IVsCfgProvider2 methods - /// - /// Copies an existing configuration name or creates a new one. - /// - /// The name of the new configuration. - /// the name of the configuration to copy, or a null reference, indicating that AddCfgsOfCfgName should create a new configuration. - /// Flag indicating whether or not the new configuration is private. If fPrivate is set to true, the configuration is private. If set to false, the configuration is public. This flag can be ignored. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int AddCfgsOfCfgName(string name, string cloneName, int fPrivate) - { - // We need to QE/QS the project file - if(!this.ProjectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - // First create the condition that represent the configuration we want to clone - string condition = (cloneName == null ? String.Empty : String.Format(CultureInfo.InvariantCulture, configString, cloneName).Trim()); - - // Get all configs - List configGroup = new List(this.project.BuildProject.Xml.PropertyGroups); - ProjectPropertyGroupElement configToClone = null; - - if(cloneName != null) - { - // Find the configuration to clone - foreach (ProjectPropertyGroupElement currentConfig in configGroup) - { - // Only care about conditional property groups - if(currentConfig.Condition == null || currentConfig.Condition.Length == 0) - continue; - - // Skip if it isn't the group we want - if(String.Compare(currentConfig.Condition.Trim(), condition, StringComparison.OrdinalIgnoreCase) != 0) - continue; - - configToClone = currentConfig; - } - } - - ProjectPropertyGroupElement newConfig = null; - if(configToClone != null) - { - // Clone the configuration settings - newConfig = this.project.ClonePropertyGroup(configToClone); - //Will be added later with the new values to the path - - foreach (ProjectPropertyElement property in newConfig.Properties) - { - if (property.Name.Equals("OutputPath", StringComparison.OrdinalIgnoreCase)) - { - property.Parent.RemoveChild(property); - } - } - } - else - { - // no source to clone from, lets just create a new empty config - newConfig = this.project.BuildProject.Xml.AddPropertyGroup(); - // Get the list of property name, condition value from the config provider - IList, string>> propVals = this.NewConfigProperties; - foreach(KeyValuePair, string> data in propVals) - { - KeyValuePair propData = data.Key; - string value = data.Value; - ProjectPropertyElement newProperty = newConfig.AddProperty(propData.Key, value); - if(!String.IsNullOrEmpty(propData.Value)) - newProperty.Condition = propData.Value; - } - } - - - //add the output path - string outputBasePath = this.ProjectMgr.OutputBaseRelativePath; - if(outputBasePath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) - outputBasePath = Path.GetDirectoryName(outputBasePath); - newConfig.AddProperty("OutputPath", Path.Combine(outputBasePath, name) + Path.DirectorySeparatorChar.ToString()); - - // Set the condition that will define the new configuration - string newCondition = String.Format(CultureInfo.InvariantCulture, configString, name); - newConfig.Condition = newCondition; - - NotifyOnCfgNameAdded(name); - return VSConstants.S_OK; - } - - /// - /// Copies an existing platform name or creates a new one. - /// - /// The name of the new platform. - /// The name of the platform to copy, or a null reference, indicating that AddCfgsOfPlatformName should create a new platform. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int AddCfgsOfPlatformName(string platformName, string clonePlatformName) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Deletes a specified configuration name. - /// - /// The name of the configuration to be deleted. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int DeleteCfgsOfCfgName(string name) - { - // We need to QE/QS the project file - if(!this.ProjectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - if(name == null) - { - Debug.Fail(String.Format(CultureInfo.CurrentCulture, "Name of the configuration should not be null if you want to delete it from project: {0}", this.project.BuildProject.FullPath)); - // The configuration " '$(Configuration)' == " does not exist, so technically the goal - // is achieved so return S_OK - return VSConstants.S_OK; - } - // Verify that this config exist - string[] configs = GetPropertiesConditionedOn(ProjectFileConstants.Configuration); - foreach(string config in configs) - { - if(String.Compare(config, name, StringComparison.OrdinalIgnoreCase) == 0) - { - // Create condition of config to remove - string condition = String.Format(CultureInfo.InvariantCulture, configString, config); - - foreach (ProjectPropertyGroupElement element in this.project.BuildProject.Xml.PropertyGroups) - { - if(String.Equals(element.Condition, condition, StringComparison.OrdinalIgnoreCase)) - { - element.Parent.RemoveChild(element); - } - } - - NotifyOnCfgNameDeleted(name); - } - } - - return VSConstants.S_OK; - } - - /// - /// Deletes a specified platform name. - /// - /// The platform name to delet. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int DeleteCfgsOfPlatformName(string platName) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Returns the existing configurations stored in the project file. - /// - /// Specifies the requested number of property names. If this number is unknown, celt can be zero. - /// On input, an allocated array to hold the number of configuration property names specified by celt. This parameter can also be a null reference if the celt parameter is zero. - /// On output, names contains configuration property names. - /// The actual number of property names returned. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetCfgNames(uint celt, string[] names, uint[] actual) - { - // get's called twice, once for allocation, then for retrieval - int i = 0; - - string[] configList = GetPropertiesConditionedOn(ProjectFileConstants.Configuration); - - if(names != null) - { - foreach(string config in configList) - { - names[i++] = config; - if(i == celt) - break; - } - } - else - i = configList.Length; - - if(actual != null) - { - actual[0] = (uint)i; - } - - return VSConstants.S_OK; - } - - /// - /// Returns the configuration associated with a specified configuration or platform name. - /// - /// The name of the configuration to be returned. - /// The name of the platform for the configuration to be returned. - /// The implementation of the IVsCfg interface. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetCfgOfName(string name, string platName, out IVsCfg cfg) - { - cfg = null; - cfg = this.GetProjectConfiguration(name); - - return VSConstants.S_OK; - } - - /// - /// Returns a specified configuration property. - /// - /// Specifies the property identifier for the property to return. For valid propid values, see __VSCFGPROPID. - /// The value of the property. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetCfgProviderProperty(int propid, out object var) - { - var = false; - switch((__VSCFGPROPID)propid) - { - case __VSCFGPROPID.VSCFGPROPID_SupportsCfgAdd: - var = true; - break; - - case __VSCFGPROPID.VSCFGPROPID_SupportsCfgDelete: - var = true; - break; - - case __VSCFGPROPID.VSCFGPROPID_SupportsCfgRename: - var = true; - break; - - case __VSCFGPROPID.VSCFGPROPID_SupportsPlatformAdd: - var = false; - break; - - case __VSCFGPROPID.VSCFGPROPID_SupportsPlatformDelete: - var = false; - break; - } - return VSConstants.S_OK; - } - - /// - /// Returns the per-configuration objects for this object. - /// - /// Number of configuration objects to be returned or zero, indicating a request for an unknown number of objects. - /// On input, pointer to an interface array or a null reference. On output, this parameter points to an array of IVsCfg interfaces belonging to the requested configuration objects. - /// The number of configuration objects actually returned or a null reference, if this information is not necessary. - /// Flags that specify settings for project configurations, or a null reference (Nothing in Visual Basic) if no additional flag settings are required. For valid prgrFlags values, see __VSCFGFLAGS. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetCfgs(uint celt, IVsCfg[] a, uint[] actual, uint[] flags) - { - if(flags != null) - flags[0] = 0; - - int i = 0; - string[] configList = GetPropertiesConditionedOn(ProjectFileConstants.Configuration); - - if(a != null) - { - foreach(string configName in configList) - { - a[i] = this.GetProjectConfiguration(configName); - - i++; - if(i == celt) - break; - } - } - else - i = configList.Length; - - if(actual != null) - actual[0] = (uint)i; - - return VSConstants.S_OK; - } - - /// - /// Returns one or more platform names. - /// - /// Specifies the requested number of platform names. If this number is unknown, celt can be zero. - /// On input, an allocated array to hold the number of platform names specified by celt. This parameter can also be a null reference if the celt parameter is zero. On output, names contains platform names. - /// The actual number of platform names returned. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetPlatformNames(uint celt, string[] names, uint[] actual) - { - string[] platforms = this.GetPlatformsFromProject(); - return GetPlatforms(celt, names, actual, platforms); - } - - /// - /// Returns the set of platforms that are installed on the user's machine. - /// - /// Specifies the requested number of supported platform names. If this number is unknown, celt can be zero. - /// On input, an allocated array to hold the number of names specified by celt. This parameter can also be a null reference (Nothing in Visual Basic)if the celt parameter is zero. On output, names contains the names of supported platforms - /// The actual number of platform names returned. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetSupportedPlatformNames(uint celt, string[] names, uint[] actual) - { - string[] platforms = this.GetSupportedPlatformsFromProject(); - return GetPlatforms(celt, names, actual, platforms); - } - - /// - /// Assigns a new name to a configuration. - /// - /// The old name of the target configuration. - /// The new name of the target configuration. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int RenameCfgsOfCfgName(string old, string newname) - { - // First create the condition that represent the configuration we want to rename - string condition = String.Format(CultureInfo.InvariantCulture, configString, old).Trim(); - - foreach (ProjectPropertyGroupElement config in this.project.BuildProject.Xml.PropertyGroups) - { - // Only care about conditional property groups - if(config.Condition == null || config.Condition.Length == 0) - continue; - - // Skip if it isn't the group we want - if(String.Compare(config.Condition.Trim(), condition, StringComparison.OrdinalIgnoreCase) != 0) - continue; - - // Change the name - config.Condition = String.Format(CultureInfo.InvariantCulture, configString, newname); - // Update the name in our config list - if(configurationsList.ContainsKey(old)) - { - ProjectConfig configuration = configurationsList[old]; - configurationsList.Remove(old); - configurationsList.Add(newname, configuration); - // notify the configuration of its new name - configuration.ConfigName = newname; - } - - NotifyOnCfgNameRenamed(old, newname); - } - - return VSConstants.S_OK; - } - - /// - /// Cancels a registration for configuration event notification. - /// - /// The cookie used for registration. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int UnadviseCfgProviderEvents(uint cookie) - { - this.cfgEventSinks.RemoveAt(cookie); - return VSConstants.S_OK; - } - - /// - /// Registers the caller for configuration event notification. - /// - /// Reference to the IVsCfgProviderEvents interface to be called to provide notification of configuration events. - /// Reference to a token representing the completed registration - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int AdviseCfgProviderEvents(IVsCfgProviderEvents sink, out uint cookie) - { - cookie = this.cfgEventSinks.Add(sink); - return VSConstants.S_OK; - } - #endregion - - #region IVsExtensibleObject Members - - /// - /// Proved access to an IDispatchable object being a list of configuration properties - /// - /// Combined Name and Platform for the configuration requested - /// The IDispatchcable object - /// S_OK if successful - public virtual int GetAutomationObject(string configurationName, out object configurationProperties) - { - //Init out param - configurationProperties = null; - - string name, platform; - if(!ProjectConfig.TrySplitConfigurationCanonicalName(configurationName, out name, out platform)) - { - return VSConstants.E_INVALIDARG; - } - - // Get the configuration - IVsCfg cfg; - ErrorHandler.ThrowOnFailure(this.GetCfgOfName(name, platform, out cfg)); - - // Get the properties of the configuration - configurationProperties = ((ProjectConfig)cfg).ConfigurationProperties; - - return VSConstants.S_OK; - - } - #endregion - - #region helper methods - /// - /// Called when a new configuration name was added. - /// - /// The name of configuration just added. - private void NotifyOnCfgNameAdded(string name) - { - foreach(IVsCfgProviderEvents sink in this.cfgEventSinks) - { - ErrorHandler.ThrowOnFailure(sink.OnCfgNameAdded(name)); - } - } - - /// - /// Called when a config name was deleted. - /// - /// The name of the configuration. - private void NotifyOnCfgNameDeleted(string name) - { - foreach(IVsCfgProviderEvents sink in this.cfgEventSinks) - { - ErrorHandler.ThrowOnFailure(sink.OnCfgNameDeleted(name)); - } - } - - /// - /// Called when a config name was renamed - /// - /// Old configuration name - /// New configuration name - private void NotifyOnCfgNameRenamed(string oldName, string newName) - { - foreach(IVsCfgProviderEvents sink in this.cfgEventSinks) - { - ErrorHandler.ThrowOnFailure(sink.OnCfgNameRenamed(oldName, newName)); - } - } - - /// - /// Called when a platform name was added - /// - /// The name of the platform. - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - private void NotifyOnPlatformNameAdded(string platformName) - { - foreach(IVsCfgProviderEvents sink in this.cfgEventSinks) - { - ErrorHandler.ThrowOnFailure(sink.OnPlatformNameAdded(platformName)); - } - } - - /// - /// Called when a platform name was deleted - /// - /// The name of the platform. - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - private void NotifyOnPlatformNameDeleted(string platformName) - { - foreach(IVsCfgProviderEvents sink in this.cfgEventSinks) - { - ErrorHandler.ThrowOnFailure(sink.OnPlatformNameDeleted(platformName)); - } - } - - /// - /// Gets all the platforms defined in the project - /// - /// An array of platform names. - private string[] GetPlatformsFromProject() - { - string[] platforms = GetPropertiesConditionedOn(ProjectFileConstants.Platform); - - if(platforms == null || platforms.Length == 0) - { - return new string[] { x86Platform, AnyCPUPlatform }; - } - - for(int i = 0; i < platforms.Length; i++) - { - platforms[i] = ConvertPlatformToVsProject(platforms[i]); - } - - return platforms; - } - - /// - /// Return the supported platform names. - /// - /// An array of supported platform names. - private string[] GetSupportedPlatformsFromProject() - { - string platforms = this.ProjectMgr.BuildProject.GetPropertyValue(ProjectFileConstants.AvailablePlatforms); - - if(platforms == null) - { - return new string[] { }; - } - - if(platforms.Contains(",")) - { - return platforms.Split(','); - } - - return new string[] { platforms }; - } - - /// - /// Helper function to convert AnyCPU to Any CPU. - /// - /// The oldname. - /// The new name. - private static string ConvertPlatformToVsProject(string oldPlatformName) - { - if(String.Compare(oldPlatformName, ProjectFileValues.AnyCPU, StringComparison.OrdinalIgnoreCase) == 0) - { - return AnyCPUPlatform; - } - - return oldPlatformName; - } - - /// - /// Common method for handling platform names. - /// - /// Specifies the requested number of platform names. If this number is unknown, celt can be zero. - /// 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 - /// A count of the actual number of platform names returned. - /// An array of available platform names - /// A count of the actual number of platform names returned. - /// The platforms array is never null. It is assured by the callers. - private static int GetPlatforms(uint celt, string[] names, uint[] actual, string[] platforms) - { - Debug.Assert(platforms != null, "The plaforms array should never be null"); - 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; - } - #endregion - - /// - /// Get all the configurations in the project. - /// - private string[] GetPropertiesConditionedOn(string constant) - { - List configurations = null; - this.project.BuildProject.ReevaluateIfNecessary(); - this.project.BuildProject.ConditionedProperties.TryGetValue(constant, out configurations); - - return (configurations == null) ? new string[] { } : configurations.ToArray(); - } - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ConfigurationProperties.cs b/SHFB/Source/MPFProj_VS2010/ConfigurationProperties.cs deleted file mode 100644 index 707718d7..00000000 --- a/SHFB/Source/MPFProj_VS2010/ConfigurationProperties.cs +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Defines the config dependent properties exposed through automation - /// - [ComVisible(true)] - [Guid("21f73a8f-91d7-4085-9d4f-c48ee235ee5b")] - public interface IProjectConfigProperties - { - string OutputPath { get; set; } - } - - /// - /// Implements the configuration dependent properties interface - /// - [CLSCompliant(false), ComVisible(true)] - [ClassInterface(ClassInterfaceType.None)] - public class ProjectConfigProperties : IProjectConfigProperties - { - #region fields - private ProjectConfig projectConfig; - #endregion - - #region ctors - public ProjectConfigProperties(ProjectConfig projectConfig) - { - this.projectConfig = projectConfig; - } - #endregion - - #region IProjectConfigProperties Members - - public virtual string OutputPath - { - get - { - return this.projectConfig.GetConfigurationProperty(BuildPropertyPageTag.OutputPath.ToString(), true); - } - set - { - this.projectConfig.SetConfigurationProperty(BuildPropertyPageTag.OutputPath.ToString(), value); - } - } - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/DataObject.cs b/SHFB/Source/MPFProj_VS2010/DataObject.cs deleted file mode 100644 index 88e5f52f..00000000 --- a/SHFB/Source/MPFProj_VS2010/DataObject.cs +++ /dev/null @@ -1,630 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security.Permissions; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; - -namespace Microsoft.VisualStudio.Project -{ - internal enum tagDVASPECT - { - DVASPECT_CONTENT = 1, - DVASPECT_THUMBNAIL = 2, - DVASPECT_ICON = 4, - DVASPECT_DOCPRINT = 8 - } - - internal enum tagTYMED - { - TYMED_HGLOBAL = 1, - TYMED_FILE = 2, - TYMED_ISTREAM = 4, - TYMED_ISTORAGE = 8, - TYMED_GDI = 16, - TYMED_MFPICT = 32, - TYMED_ENHMF = 64, - TYMED_NULL = 0 - } - - internal sealed class DataCacheEntry : IDisposable - { - #region fields - /// - /// Defines an object that will be a mutex for this object for synchronizing thread calls. - /// - private static volatile object Mutex = new object(); - - private FORMATETC format; - - private long data; - - private DATADIR dataDir; - - private bool isDisposed; - #endregion - - #region properties - internal FORMATETC Format - { - get - { - return this.format; - } - } - - internal long Data - { - get - { - return this.data; - } - } - - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal DATADIR DataDir - { - get - { - return this.dataDir; - } - } - - #endregion - - /// - /// The IntPtr is data allocated that should be removed. It is allocated by the ProcessSelectionData method. - /// - internal DataCacheEntry(FORMATETC fmt, IntPtr data, DATADIR dir) - { - this.format = fmt; - this.data = (long)data; - this.dataDir = dir; - } - - #region Dispose - ~DataCacheEntry() - { - Dispose(false); - } - - /// - /// The IDispose interface Dispose method for disposing the object determinastically. - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// The method that does the cleanup. - /// - /// - private void Dispose(bool disposing) - { - // Everybody can go here. - if(!this.isDisposed) - { - // Synchronize calls to the Dispose simulteniously. - lock(Mutex) - { - if(disposing && this.data != 0) - { - Marshal.FreeHGlobal((IntPtr)this.data); - this.data = 0; - } - - this.isDisposed = true; - } - } - } - #endregion - } - - /// - /// Unfortunately System.Windows.Forms.IDataObject and - /// Microsoft.VisualStudio.OLE.Interop.IDataObject are different... - /// - internal sealed class DataObject : IDataObject - { - #region fields - internal const int DATA_S_SAMEFORMATETC = 0x00040130; - EventSinkCollection map; - ArrayList entries; - #endregion - - internal DataObject() - { - this.map = new EventSinkCollection(); - this.entries = new ArrayList(); - } - - internal void SetData(FORMATETC format, IntPtr data) - { - this.entries.Add(new DataCacheEntry(format, data, DATADIR.DATADIR_SET)); - } - - #region IDataObject methods - int IDataObject.DAdvise(FORMATETC[] e, uint adv, IAdviseSink sink, out uint cookie) - { - if (e == null) - { - throw new ArgumentNullException("e"); - } - - STATDATA sdata = new STATDATA(); - - sdata.ADVF = adv; - sdata.FORMATETC = e[0]; - sdata.pAdvSink = sink; - cookie = this.map.Add(sdata); - sdata.dwConnection = cookie; - return 0; - } - - void IDataObject.DUnadvise(uint cookie) - { - this.map.RemoveAt(cookie); - } - - int IDataObject.EnumDAdvise(out IEnumSTATDATA e) - { - e = new EnumSTATDATA((IEnumerable)this.map); - return 0; //?? - } - - int IDataObject.EnumFormatEtc(uint direction, out IEnumFORMATETC penum) - { - penum = new EnumFORMATETC((DATADIR)direction, (IEnumerable)this.entries); - return 0; - } - - int IDataObject.GetCanonicalFormatEtc(FORMATETC[] format, FORMATETC[] fmt) - { - throw new System.Runtime.InteropServices.COMException("", DATA_S_SAMEFORMATETC); - } - - void IDataObject.GetData(FORMATETC[] fmt, STGMEDIUM[] m) - { - STGMEDIUM retMedium = new STGMEDIUM(); - - if(fmt == null || fmt.Length < 1) - return; - - foreach(DataCacheEntry e in this.entries) - { - if(e.Format.cfFormat == fmt[0].cfFormat /*|| fmt[0].cfFormat == InternalNativeMethods.CF_HDROP*/) - { - retMedium.tymed = e.Format.tymed; - - // Caller must delete the memory. - retMedium.unionmember = DragDropHelper.CopyHGlobal(new IntPtr(e.Data)); - break; - } - } - - if(m != null && m.Length > 0) - m[0] = retMedium; - } - - void IDataObject.GetDataHere(FORMATETC[] fmt, STGMEDIUM[] m) - { - } - - int IDataObject.QueryGetData(FORMATETC[] fmt) - { - if(fmt == null || fmt.Length < 1) - return VSConstants.S_FALSE; - - foreach(DataCacheEntry e in this.entries) - { - if(e.Format.cfFormat == fmt[0].cfFormat /*|| fmt[0].cfFormat == InternalNativeMethods.CF_HDROP*/) - return VSConstants.S_OK; - } - - return VSConstants.S_FALSE; - } - - void IDataObject.SetData(FORMATETC[] fmt, STGMEDIUM[] m, int fRelease) - { - } - #endregion - } - - [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] - internal static class DragDropHelper - { -#pragma warning disable 414 - internal static readonly ushort CF_VSREFPROJECTITEMS; - internal static readonly ushort CF_VSSTGPROJECTITEMS; - internal static readonly ushort CF_VSPROJECTCLIPDESCRIPTOR; -#pragma warning restore 414 - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] - static DragDropHelper() - { - CF_VSREFPROJECTITEMS = UnsafeNativeMethods.RegisterClipboardFormat("CF_VSREFPROJECTITEMS"); - CF_VSSTGPROJECTITEMS = UnsafeNativeMethods.RegisterClipboardFormat("CF_VSSTGPROJECTITEMS"); - CF_VSPROJECTCLIPDESCRIPTOR = UnsafeNativeMethods.RegisterClipboardFormat("CF_PROJECTCLIPBOARDDESCRIPTOR"); - } - - - public static FORMATETC CreateFormatEtc(ushort iFormat) - { - FORMATETC fmt = new FORMATETC(); - fmt.cfFormat = iFormat; - fmt.ptd = IntPtr.Zero; - fmt.dwAspect = (uint)DVASPECT.DVASPECT_CONTENT; - fmt.lindex = -1; - fmt.tymed = (uint)TYMED.TYMED_HGLOBAL; - return fmt; - } - - public static int QueryGetData(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, ref FORMATETC fmtetc) - { - int returnValue = VSConstants.E_FAIL; - FORMATETC[] af = new FORMATETC[1]; - af[0] = fmtetc; - try - { - int result = ErrorHandler.ThrowOnFailure(pDataObject.QueryGetData(af)); - if(result == VSConstants.S_OK) - { - fmtetc = af[0]; - returnValue = VSConstants.S_OK; - } - } - catch(COMException e) - { - Trace.WriteLine("COMException : " + e.Message); - returnValue = e.ErrorCode; - } - - return returnValue; - } - - public static STGMEDIUM GetData(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, ref FORMATETC fmtetc) - { - FORMATETC[] af = new FORMATETC[1]; - af[0] = fmtetc; - STGMEDIUM[] sm = new STGMEDIUM[1]; - pDataObject.GetData(af, sm); - fmtetc = af[0]; - return sm[0]; - } - - /// - /// Retrives data from a VS format. - /// - public static List GetDroppedFiles(ushort format, Microsoft.VisualStudio.OLE.Interop.IDataObject dataObject, out DropDataType ddt) - { - ddt = DropDataType.None; - List droppedFiles = new List(); - - // try HDROP - FORMATETC fmtetc = CreateFormatEtc(format); - - if(QueryGetData(dataObject, ref fmtetc) == VSConstants.S_OK) - { - STGMEDIUM stgmedium = DragDropHelper.GetData(dataObject, ref fmtetc); - if(stgmedium.tymed == (uint)TYMED.TYMED_HGLOBAL) - { - // We are releasing the cloned hglobal here. - IntPtr dropInfoHandle = stgmedium.unionmember; - if(dropInfoHandle != IntPtr.Zero) - { - ddt = DropDataType.Shell; - try - { - uint numFiles = UnsafeNativeMethods.DragQueryFile(dropInfoHandle, 0xFFFFFFFF, null, 0); - - // We are a directory based project thus a projref string is placed on the clipboard. - // We assign the maximum length of a projref string. - // The format of a projref is : || - uint lenght = (uint)Guid.Empty.ToString().Length + 2 * NativeMethods.MAX_PATH + 2; - char[] moniker = new char[lenght + 1]; - for(uint fileIndex = 0; fileIndex < numFiles; fileIndex++) - { - uint queryFileLength = UnsafeNativeMethods.DragQueryFile(dropInfoHandle, fileIndex, moniker, lenght); - string filename = new String(moniker, 0, (int)queryFileLength); - droppedFiles.Add(filename); - } - } - finally - { - Marshal.FreeHGlobal(dropInfoHandle); - } - } - } - } - - return droppedFiles; - } - - - - public static string GetSourceProjectPath(Microsoft.VisualStudio.OLE.Interop.IDataObject dataObject) - { - string projectPath = null; - FORMATETC fmtetc = CreateFormatEtc(CF_VSPROJECTCLIPDESCRIPTOR); - - if(QueryGetData(dataObject, ref fmtetc) == VSConstants.S_OK) - { - STGMEDIUM stgmedium = DragDropHelper.GetData(dataObject, ref fmtetc); - if(stgmedium.tymed == (uint)TYMED.TYMED_HGLOBAL) - { - // We are releasing the cloned hglobal here. - IntPtr dropInfoHandle = stgmedium.unionmember; - if(dropInfoHandle != IntPtr.Zero) - { - try - { - string path = GetData(dropInfoHandle); - - // Clone the path that we can release our memory. - if(!String.IsNullOrEmpty(path)) - { - projectPath = String.Copy(path); - } - } - finally - { - Marshal.FreeHGlobal(dropInfoHandle); - } - } - } - } - - return projectPath; - } - - /// - /// Returns the data packed after the DROPFILES structure. - /// - /// - /// - internal static string GetData(IntPtr dropHandle) - { - IntPtr data = UnsafeNativeMethods.GlobalLock(dropHandle); - try - { - _DROPFILES df = (_DROPFILES)Marshal.PtrToStructure(data, typeof(_DROPFILES)); - if(df.fWide != 0) - { - IntPtr pdata = new IntPtr((long)data + df.pFiles); - return Marshal.PtrToStringUni(pdata); - } - } - finally - { - if(data != null) - { - UnsafeNativeMethods.GlobalUnLock(data); - } - } - - return null; - } - - internal static IntPtr CopyHGlobal(IntPtr data) - { - IntPtr src = UnsafeNativeMethods.GlobalLock(data); - int size = UnsafeNativeMethods.GlobalSize(data); - IntPtr ptr = Marshal.AllocHGlobal(size); - IntPtr buffer = UnsafeNativeMethods.GlobalLock(ptr); - - try - { - for(int i = 0; i < size; i++) - { - byte val = Marshal.ReadByte(new IntPtr((long)src + i)); - - Marshal.WriteByte(new IntPtr((long)buffer + i), val); - } - } - finally - { - if(buffer != IntPtr.Zero) - { - UnsafeNativeMethods.GlobalUnLock(buffer); - } - - if(src != IntPtr.Zero) - { - UnsafeNativeMethods.GlobalUnLock(src); - } - } - return ptr; - } - - internal static void CopyStringToHGlobal(string s, IntPtr data, int bufferSize) - { - Int16 nullTerminator = 0; - int dwSize = Marshal.SizeOf(nullTerminator); - - if((s.Length + 1) * Marshal.SizeOf(s[0]) > bufferSize) - throw new System.IO.InternalBufferOverflowException(); - // IntPtr memory already locked... - for(int i = 0, len = s.Length; i < len; i++) - { - Marshal.WriteInt16(data, i * dwSize, s[i]); - } - // NULL terminate it - Marshal.WriteInt16(new IntPtr((long)data + (s.Length * dwSize)), nullTerminator); - } - - } // end of dragdrophelper - - internal class EnumSTATDATA : IEnumSTATDATA - { - IEnumerable i; - - IEnumerator e; - - public EnumSTATDATA(IEnumerable i) - { - this.i = i; - this.e = i.GetEnumerator(); - } - - void IEnumSTATDATA.Clone(out IEnumSTATDATA clone) - { - clone = new EnumSTATDATA(i); - } - - int IEnumSTATDATA.Next(uint celt, STATDATA[] d, out uint fetched) - { - uint rc = 0; - //uint size = (fetched != null) ? fetched[0] : 0; - for(uint i = 0; i < celt; i++) - { - if(e.MoveNext()) - { - STATDATA sdata = (STATDATA)e.Current; - - rc++; - if(d != null && d.Length > i) - { - d[i] = sdata; - } - } - } - - fetched = rc; - return 0; - } - - int IEnumSTATDATA.Reset() - { - e.Reset(); - return 0; - } - - int IEnumSTATDATA.Skip(uint celt) - { - for(uint i = 0; i < celt; i++) - { - e.MoveNext(); - } - - return 0; - } - } - - internal class EnumFORMATETC : IEnumFORMATETC - { - IEnumerable cache; // of DataCacheEntrys. - - DATADIR dir; - - IEnumerator e; - - public EnumFORMATETC(DATADIR dir, IEnumerable cache) - { - this.cache = cache; - this.dir = dir; - e = cache.GetEnumerator(); - } - - void IEnumFORMATETC.Clone(out IEnumFORMATETC clone) - { - clone = new EnumFORMATETC(dir, cache); - } - - int IEnumFORMATETC.Next(uint celt, FORMATETC[] d, uint[] fetched) - { - uint rc = 0; - //uint size = (fetched != null) ? fetched[0] : 0; - for(uint i = 0; i < celt; i++) - { - if(e.MoveNext()) - { - DataCacheEntry entry = (DataCacheEntry)e.Current; - - rc++; - if(d != null && d.Length > i) - { - d[i] = entry.Format; - } - } - else - { - return VSConstants.S_FALSE; - } - } - - if(fetched != null && fetched.Length > 0) - fetched[0] = rc; - return VSConstants.S_OK; - } - - int IEnumFORMATETC.Reset() - { - e.Reset(); - return 0; - } - - int IEnumFORMATETC.Skip(uint celt) - { - for(uint i = 0; i < celt; i++) - { - e.MoveNext(); - } - - return 0; - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/DependentFileNode.cs b/SHFB/Source/MPFProj_VS2010/DependentFileNode.cs deleted file mode 100644 index 54ac6a93..00000000 --- a/SHFB/Source/MPFProj_VS2010/DependentFileNode.cs +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Text; -using Microsoft.VisualStudio; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; -using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; -using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Defines the logic for all dependent file nodes (solution explorer icon, commands etc.) - /// - [CLSCompliant(false)] - [ComVisible(true)] - public class DependentFileNode : FileNode - { - #region fields - /// - /// Defines if the node has a name relation to its parent node - /// e.g. Form1.ext and Form1.resx are name related (until first occurence of extention separator) - /// - #endregion - - #region Properties - public override int ImageIndex - { - get { return (this.CanShowDefaultIcon() ? (int)ProjectNode.ImageName.DependentFile : (int)ProjectNode.ImageName.MissingFile); } - } - #endregion - - #region ctor - /// - /// Constructor for the DependentFileNode - /// - /// Root of the hierarchy - /// Associated project element - public DependentFileNode(ProjectNode root, ProjectElement element) - : base(root, element) - { - this.HasParentNodeNameRelation = false; - } - - - #endregion - - #region overridden methods - /// - /// Disable rename - /// - /// E_NOTIMPLE in order to tell the call that we do not support rename - public override string GetEditLabel() - { - throw new NotImplementedException(); - } - - /// - /// Gets a handle to the icon that should be set for this node - /// - /// Whether the folder is open, ignored here. - /// Handle to icon for the node - public override object GetIconHandle(bool open) - { - return this.ProjectMgr.ImageHandler.GetIconHandle(this.ImageIndex); - } - - /// - /// Disable certain commands for dependent file nodes - /// - protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result) - { - if(cmdGroup == VsMenus.guidStandardCommandSet97) - { - switch((VsCommands)cmd) - { - case VsCommands.Copy: - case VsCommands.Paste: - case VsCommands.Cut: - case VsCommands.Rename: - result |= QueryStatusResult.NOTSUPPORTED; - return VSConstants.S_OK; - - case VsCommands.ViewCode: - case VsCommands.Open: - case VsCommands.OpenWith: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } - else if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - if((VsCommands2K)cmd == VsCommands2K.EXCLUDEFROMPROJECT) - { - result |= QueryStatusResult.NOTSUPPORTED; - return VSConstants.S_OK; - } - } - else - { - return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; - } - return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); - } - - /// - /// DependentFileNodes node cannot be dragged. - /// - /// null - protected internal override StringBuilder PrepareSelectedNodesForClipBoard() - { - return null; - } - - protected override NodeProperties CreatePropertiesObject() - { - return new DependentFileNodeProperties(this); - } - - /// - /// Redraws the state icon if the node is not excluded from source control. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - protected internal override void UpdateSccStateIcons() - { - if(!this.ExcludeNodeFromScc) - { - this.Parent.ReDraw(UIHierarchyElement.SccState); - } - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/DesignPropertyDescriptor.cs b/SHFB/Source/MPFProj_VS2010/DesignPropertyDescriptor.cs deleted file mode 100644 index 0f5b69a8..00000000 --- a/SHFB/Source/MPFProj_VS2010/DesignPropertyDescriptor.cs +++ /dev/null @@ -1,249 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.ComponentModel; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// The purpose of DesignPropertyDescriptor is to allow us to customize the - /// display name of the property in the property grid. None of the CLR - /// implementations of PropertyDescriptor allow you to change the DisplayName. - /// - public class DesignPropertyDescriptor : PropertyDescriptor - { - private string displayName; // Custom display name - private PropertyDescriptor property; // Base property descriptor - private Hashtable editors = new Hashtable(); // Type -> editor instance - private TypeConverter converter; - - - /// - /// Delegates to base. - /// - public override string DisplayName - { - get - { - return this.displayName; - } - } - - /// - /// Delegates to base. - /// - public override Type ComponentType - { - get - { - return this.property.ComponentType; - } - } - - /// - /// Delegates to base. - /// - public override bool IsReadOnly - { - get - { - return this.property.IsReadOnly; - } - } - - /// - /// Delegates to base. - /// - public override Type PropertyType - { - get - { - return this.property.PropertyType; - } - } - - - /// - /// Delegates to base. - /// - public override object GetEditor(Type editorBaseType) - { - object editor = this.editors[editorBaseType]; - if(editor == null) - { - for(int i = 0; i < this.Attributes.Count; i++) - { - EditorAttribute attr = Attributes[i] as EditorAttribute; - if(attr == null) - { - continue; - } - Type editorType = Type.GetType(attr.EditorBaseTypeName); - if(editorBaseType == editorType) - { - Type type = GetTypeFromNameProperty(attr.EditorTypeName); - if(type != null) - { - editor = CreateInstance(type); - this.editors[type] = editor; // cache it - break; - } - } - } - } - return editor; - } - - - /// - /// Return type converter for property - /// - public override TypeConverter Converter - { - get - { - if(converter == null) - { - PropertyPageTypeConverterAttribute attr = (PropertyPageTypeConverterAttribute)Attributes[typeof(PropertyPageTypeConverterAttribute)]; - if(attr != null && attr.ConverterType != null) - { - converter = (TypeConverter)CreateInstance(attr.ConverterType); - } - - if(converter == null) - { - converter = TypeDescriptor.GetConverter(this.PropertyType); - } - } - return converter; - } - } - - - - /// - /// Convert name to a Type object. - /// - public virtual Type GetTypeFromNameProperty(string typeName) - { - return Type.GetType(typeName); - } - - - /// - /// Delegates to base. - /// - public override bool CanResetValue(object component) - { - bool result = this.property.CanResetValue(component); - return result; - } - - /// - /// Delegates to base. - /// - public override object GetValue(object component) - { - object value = this.property.GetValue(component); - return value; - } - - /// - /// Delegates to base. - /// - public override void ResetValue(object component) - { - this.property.ResetValue(component); - } - - /// - /// Delegates to base. - /// - public override void SetValue(object component, object value) - { - this.property.SetValue(component, value); - } - - /// - /// Delegates to base. - /// - public override bool ShouldSerializeValue(object component) - { - bool result = this.property.ShouldSerializeValue(component); - return result; - } - - /// - /// Constructor. Copy the base property descriptor and also hold a pointer - /// to it for calling its overridden abstract methods. - /// - public DesignPropertyDescriptor(PropertyDescriptor prop) - : base(prop) - { - if (prop == null) - { - throw new ArgumentNullException("prop"); - } - - this.property = prop; - - DisplayNameAttribute attr = prop.Attributes[typeof(DisplayNameAttribute)] as DisplayNameAttribute; - - if(attr != null) - { - this.displayName = attr.DisplayName; - } - else - { - this.displayName = prop.Name; - } - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/DesignTimeAssemblyResolution.cs b/SHFB/Source/MPFProj_VS2010/DesignTimeAssemblyResolution.cs deleted file mode 100644 index c344cc3f..00000000 --- a/SHFB/Source/MPFProj_VS2010/DesignTimeAssemblyResolution.cs +++ /dev/null @@ -1,645 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Build.Framework; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.Build.Utilities; -using Microsoft.Build.Execution; -using System.IO; -using System.Globalization; - -namespace Microsoft.VisualStudio.Project -{ - public class DesignTimeAssemblyResolution - { - private const string OriginalItemSpec = "originalItemSpec"; - - private const string FoundAssemblyVersion = "Version"; - - private const string HighestVersionInRedistList = "HighestVersionInRedist"; - - private const string OutOfRangeDependencies = "OutOfRangeDependencies"; - - private RarInputs rarInputs; - - public bool EnableLogging { get; set; } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "GetFrameworkPaths")] - public virtual void Initialize(ProjectNode projectNode) - { - if (projectNode == null) - { - throw new ArgumentNullException("projectNode"); - } - - if (projectNode.CallMSBuild("GetFrameworkPaths") != MSBuildResult.Successful) - { - throw new InvalidOperationException("Build of GetFrameworkPaths failed."); - } - - this.rarInputs = new RarInputs(projectNode.CurrentConfig); - } - - public virtual VsResolvedAssemblyPath[] Resolve(IEnumerable assemblies) - { - if (assemblies == null) - { - throw new ArgumentNullException("assemblies"); - } - - // Resolve references WITHOUT invoking MSBuild to avoid re-entrancy problems. - const bool projectDtar = true; - var rar = new Microsoft.Build.Tasks.ResolveAssemblyReference(); - var engine = new MockEngine(EnableLogging); - rar.BuildEngine = engine; - - // first set common properties/items then if projectDtar then set additional projectDtar properties - ITaskItem[] assemblyItems = assemblies.Select(assembly => new TaskItem(assembly)).ToArray(); - rar.Assemblies = assemblyItems; - rar.SearchPaths = rarInputs.PdtarSearchPaths; - - rar.TargetFrameworkDirectories = rarInputs.TargetFrameworkDirectories; - rar.AllowedAssemblyExtensions = rarInputs.AllowedAssemblyExtensions; - rar.TargetProcessorArchitecture = rarInputs.TargetProcessorArchitecture; - rar.TargetFrameworkVersion = rarInputs.TargetFrameworkVersion; - rar.TargetFrameworkMoniker = rarInputs.TargetFrameworkMoniker; - rar.TargetFrameworkMonikerDisplayName = rarInputs.TargetFrameworkMonikerDisplayName; - rar.TargetedRuntimeVersion = rarInputs.TargetedRuntimeVersion; - rar.FullFrameworkFolders = rarInputs.FullFrameworkFolders; - rar.LatestTargetFrameworkDirectories = rarInputs.LatestTargetFrameworkDirectories; - rar.FullTargetFrameworkSubsetNames = rarInputs.FullTargetFrameworkSubsetNames; - rar.FullFrameworkAssemblyTables = rarInputs.FullFrameworkAssemblyTables; - rar.IgnoreDefaultInstalledAssemblySubsetTables = rarInputs.IgnoreDefaultInstalledAssemblySubsetTables; - rar.ProfileName = rarInputs.ProfileName; - - rar.Silent = !this.EnableLogging; - rar.FindDependencies = true; - rar.AutoUnify = false; - rar.FindSatellites = false; - rar.FindSerializationAssemblies = false; - rar.FindRelatedFiles = false; - - // This set needs to be kept in sync with the set of project instance data that - // is populated into RarInputs - if (projectDtar) - { - // set project dtar specific properties - rar.CandidateAssemblyFiles = rarInputs.CandidateAssemblyFiles; - rar.StateFile = rarInputs.StateFile; - rar.InstalledAssemblySubsetTables = rarInputs.InstalledAssemblySubsetTables; - rar.TargetFrameworkSubsets = rarInputs.TargetFrameworkSubsets; - } - - IEnumerable results; - - try - { - rar.Execute(); - results = FilterResults(rar.ResolvedFiles).Select(pair => new VsResolvedAssemblyPath - { - bstrOrigAssemblySpec = pair.Key, - bstrResolvedAssemblyPath = pair.Value, - }); - } - catch (Exception ex) - { - if (ErrorHandler.IsCriticalException(ex)) - { - throw; - } - - engine.RecordRARExecutionException(ex); - results = Enumerable.Empty(); - } - finally - { - if (this.EnableLogging) - { - WriteLogFile(engine, projectDtar, assemblies); - } - } - - return results.ToArray(); - } - - private static IEnumerable> FilterResults(IEnumerable resolvedFiles) - { - foreach (ITaskItem resolvedFile in resolvedFiles) - { - bool bAddResolvedAssemblyToResultList = true; - - // excludeVersionWarningsFromResult - string foundAssemblyVersion = resolvedFile.GetMetadata(FoundAssemblyVersion); - string highestVersionInRedist = resolvedFile.GetMetadata(HighestVersionInRedistList); - - Version asmVersion = null; - bool parsedAsmVersion = Version.TryParse(foundAssemblyVersion, out asmVersion); - - Version redistVersion = null; - bool parsedRedistVersion = Version.TryParse(highestVersionInRedist, out redistVersion); - - if ((parsedAsmVersion && parsedRedistVersion) && asmVersion > redistVersion) - { - // if the version of the assembly is greater than the highest version - for that assembly - found in - // the chained(possibly) redist lists; then the assembly does not belong to the target framework - bAddResolvedAssemblyToResultList = false; - } - - // check outOfRangeDependencies - string outOfRangeDependencies = resolvedFile.GetMetadata(OutOfRangeDependencies); - if (!String.IsNullOrEmpty(outOfRangeDependencies)) - { - // This metadata is a semi-colon delimited list of dependent assembly names which target - // a higher framework. If this metadata is NOT EMPTY then - // the current assembly does have dependencies which are greater than the current target framework - - // so let's exclude this assembly - bAddResolvedAssemblyToResultList = false; - } - - if (bAddResolvedAssemblyToResultList) - { - yield return new KeyValuePair(resolvedFile.GetMetadata(OriginalItemSpec), resolvedFile.ItemSpec); - } - } - } - - private static void WriteLogFile(MockEngine engine, bool projectDtar, IEnumerable assemblies) - { - string logFilePrefix = projectDtar ? "P" : "G"; - - string logFilePath = Path.Combine(Path.GetTempPath(), logFilePrefix + @"Dtar" + (Guid.NewGuid()).ToString("N", CultureInfo.InvariantCulture) + ".log"); - - StringBuilder inputs = new StringBuilder(); - - Array.ForEach(assemblies.ToArray(), assembly => { inputs.Append(assembly); inputs.Append(";"); inputs.Append("\n"); }); - - string logAssemblies = "Inputs: \n" + inputs.ToString() + "\n\n"; - - string finalLog = logAssemblies + engine.Log; - - string[] finalLogLines = finalLog.Split(new char[] { '\n' }); - - File.WriteAllLines(logFilePath, finalLogLines); - } - - /// - /// Engine required by RAR, primarily for collecting logs - /// - private class MockEngine : IBuildEngine - { - private int messages = 0; - private int warnings = 0; - private int errors = 0; - private StringBuilder log = new StringBuilder(); - private readonly bool enableLog = false; - - internal MockEngine(bool enableLog) - { - this.enableLog = enableLog; - } - - public void RecordRARExecutionException(Exception ex) - { - if (!enableLog) return; - - log.Append(String.Format(CultureInfo.InvariantCulture, "{0}", ex.ToString())); - } - - public void LogErrorEvent(BuildErrorEventArgs eventArgs) - { - if (eventArgs == null) - { - throw new ArgumentNullException("eventArgs"); - } - - if (!enableLog) return; - - if (eventArgs.File != null && eventArgs.File.Length > 0) - { - log.Append(String.Format(CultureInfo.InvariantCulture, "{0}({1},{2}): ", eventArgs.File, eventArgs.LineNumber, eventArgs.ColumnNumber)); - } - - log.Append("ERROR "); - log.Append(eventArgs.Code); - log.Append(": "); - ++errors; - - log.AppendLine(eventArgs.Message); - } - - public void LogWarningEvent(BuildWarningEventArgs eventArgs) - { - if (eventArgs == null) - { - throw new ArgumentNullException("eventArgs"); - } - - if (!enableLog) return; - - if (eventArgs.File != null && eventArgs.File.Length > 0) - { - log.Append(String.Format(CultureInfo.InvariantCulture, "{0}({1},{2}): ", eventArgs.File, eventArgs.LineNumber, eventArgs.ColumnNumber)); - } - - log.Append("WARNING "); - log.Append(eventArgs.Code); - log.Append(": "); - ++warnings; - - log.AppendLine(eventArgs.Message); - } - - public void LogCustomEvent(CustomBuildEventArgs eventArgs) - { - if (eventArgs == null) - { - throw new ArgumentNullException("eventArgs"); - } - - if (!enableLog) return; - - log.Append(eventArgs.Message); - log.Append("\n"); - } - - public void LogMessageEvent(BuildMessageEventArgs eventArgs) - { - if (eventArgs == null) - { - throw new ArgumentNullException("eventArgs"); - } - - log.Append(eventArgs.Message); - log.Append("\n"); - - ++messages; - } - - public bool ContinueOnError - { - get { return false; } - } - - public string ProjectFileOfTaskNode - { - get { return String.Empty; } - } - - public int LineNumberOfTaskNode - { - get { return 0; } - } - - public int ColumnNumberOfTaskNode - { - get { return 0; } - } - - internal string Log - { - get { return log.ToString(); } - } - - public bool BuildProjectFile(string projectFileName, string[] targetNames, System.Collections.IDictionary globalProperties, System.Collections.IDictionary targetOutputs) - { - throw new NotImplementedException(); - } - } - - /// - /// Accesssor for RAR related properties in the projectInstance. - /// See ResolveAssemblyReferennce task msdn docs for member descriptions - /// - private class RarInputs - { - #region private fields - - // RAR related property/item names etc - private const string TargetFrameworkDirectory = "TargetFrameworkDirectory"; - private const string RegistrySearchPathFormat = "Registry:{0},{1},{2}{3}"; - private const string FrameworkRegistryBase = "FrameworkRegistryBase"; - private const string TargetFrameworkVersionName = "TargetFrameworkVersion"; - private const string AssemblyFoldersSuffix = "AssemblyFoldersSuffix"; - private const string AssemblyFoldersExConditions = "AssemblyFoldersExConditions"; - private const string AllowedReferenceAssemblyFileExtensions = "AllowedReferenceAssemblyFileExtensions"; - private const string ProcessorArchitecture = "ProcessorArchitecture"; - private const string TargetFrameworkMonikerName = "TargetFrameworkMoniker"; - private const string TargetFrameworkMonikerDisplayNameName = "TargetFrameworkMonikerDisplayName"; - private const string TargetedRuntimeVersionName = "TargetedRuntimeVersion"; - private const string FullFrameworkReferenceAssemblyPaths = "_FullFrameworkReferenceAssemblyPaths"; - private const string TargetFrameworkProfile = "TargetFrameworkProfile"; - - private const string ProjectDesignTimeAssemblyResolutionSearchPaths = "ProjectDesignTimeAssemblyResolutionSearchPaths"; - private const string Content = "Content"; - private const string None = "None"; - private const string RARResolvedReferencePath = "ReferencePath"; - private const string IntermediateOutputPath = "IntermediateOutputPath"; - private const string InstalledAssemblySubsetTablesName = "InstalledAssemblySubsetTables"; - private const string IgnoreInstalledAssemblySubsetTables = "IgnoreInstalledAssemblySubsetTables"; - private const string ReferenceInstalledAssemblySubsets = "_ReferenceInstalledAssemblySubsets"; - private const string FullReferenceAssemblyNames = "FullReferenceAssemblyNames"; - private const string LatestTargetFrameworkDirectoriesName = "LatestTargetFrameworkDirectories"; - private const string FullFrameworkAssemblyTablesName = "FullFrameworkAssemblyTables"; - private const string MSBuildProjectDirectory = "MSBuildProjectDirectory"; - - #endregion //private fields - - public string[] TargetFrameworkDirectories { get; private set; } - public string[] AllowedAssemblyExtensions { get; private set; } - public string TargetProcessorArchitecture { get; private set; } - public string TargetFrameworkVersion { get; private set; } - public string TargetFrameworkMoniker { get; private set; } - public string TargetFrameworkMonikerDisplayName { get; private set; } - public string TargetedRuntimeVersion { get; private set; } - public string[] FullFrameworkFolders { get; private set; } - public string ProfileName { get; private set; } - public string[] PdtarSearchPaths { get; private set; } - public string[] CandidateAssemblyFiles { get; private set; } - public string StateFile { get; private set; } - public ITaskItem[] InstalledAssemblySubsetTables { get; private set; } - public bool IgnoreDefaultInstalledAssemblySubsetTables { get; private set; } - public string[] TargetFrameworkSubsets { get; private set; } - public string[] FullTargetFrameworkSubsetNames { get; private set; } - public ITaskItem[] FullFrameworkAssemblyTables { get; private set; } - public string[] LatestTargetFrameworkDirectories { get; private set; } - - #region constructors - public RarInputs(ProjectInstance projectInstance) - { - // Run through all of the entries we want to extract from the project instance before we discard it to save memory - TargetFrameworkDirectories = GetTargetFrameworkDirectories(projectInstance); - AllowedAssemblyExtensions = GetAllowedAssemblyExtensions(projectInstance); - TargetProcessorArchitecture = GetTargetProcessorArchitecture(projectInstance); - TargetFrameworkVersion = GetTargetFrameworkVersion(projectInstance); - TargetFrameworkMoniker = GetTargetFrameworkMoniker(projectInstance); - TargetFrameworkMonikerDisplayName = GetTargetFrameworkMonikerDisplayName(projectInstance); - TargetedRuntimeVersion = GetTargetedRuntimeVersion(projectInstance); - FullFrameworkFolders = GetFullFrameworkFolders(projectInstance); - LatestTargetFrameworkDirectories = GetLatestTargetFrameworkDirectories(projectInstance); - FullTargetFrameworkSubsetNames = GetFullTargetFrameworkSubsetNames(projectInstance); - FullFrameworkAssemblyTables = GetFullFrameworkAssemblyTables(projectInstance); - IgnoreDefaultInstalledAssemblySubsetTables = GetIgnoreDefaultInstalledAssemblySubsetTables(projectInstance); - ProfileName = GetProfileName(projectInstance); - - /* - * rar.CandidateAssemblyFiles = rarInputs.CandidateAssemblyFiles; - rar.StateFile = rarInputs.StateFile; - rar.InstalledAssemblySubsetTables = rarInputs.InstalledAssemblySubsetTables; - rar.TargetFrameworkSubsets = rarInputs.TargetFrameworkSubsets; - */ - - // This set needs to be kept in sync with the set of project instance data that - // is passed into Rar - PdtarSearchPaths = GetPdtarSearchPaths(projectInstance); - - CandidateAssemblyFiles = GetCandidateAssemblyFiles(projectInstance); - StateFile = GetStateFile(projectInstance); - InstalledAssemblySubsetTables = GetInstalledAssemblySubsetTables(projectInstance); - TargetFrameworkSubsets = GetTargetFrameworkSubsets(projectInstance); - } - #endregion // constructors - - #region public properties - - #region common properties/items - - private string[] GetTargetFrameworkDirectories(ProjectInstance projectInstance) - { - if (TargetFrameworkDirectories == null) - { - string val = projectInstance.GetPropertyValue(TargetFrameworkDirectory).Trim(); - - TargetFrameworkDirectories = val.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries) - .Select(s => s.Trim()) - .Where(s => s.Length > 0) - .ToArray(); - } - - return TargetFrameworkDirectories; - } - - private static string[] GetAllowedAssemblyExtensions(ProjectInstance projectInstance) - { - string[] allowedAssemblyExtensions; - - string val = projectInstance.GetPropertyValue(AllowedReferenceAssemblyFileExtensions).Trim(); - - allowedAssemblyExtensions = val.Split(';').Select(s => s.Trim()).ToArray(); - - return allowedAssemblyExtensions; - } - - private static string GetTargetProcessorArchitecture(ProjectInstance projectInstance) - { - string val = projectInstance.GetPropertyValue(ProcessorArchitecture).Trim(); - - return val; - } - - private static string GetTargetFrameworkVersion(ProjectInstance projectInstance) - { - string val = projectInstance.GetPropertyValue(TargetFrameworkVersionName).Trim(); - - return val; - } - - private static string GetTargetFrameworkMoniker(ProjectInstance projectInstance) - { - string val = projectInstance.GetPropertyValue(TargetFrameworkMonikerName).Trim(); - - return val; - } - - private static string GetTargetFrameworkMonikerDisplayName(ProjectInstance projectInstance) - { - string val = projectInstance.GetPropertyValue(TargetFrameworkMonikerDisplayNameName).Trim(); - - return val; - } - - private static string GetTargetedRuntimeVersion(ProjectInstance projectInstance) - { - string val = projectInstance.GetPropertyValue(TargetedRuntimeVersionName).Trim(); - - return val; - } - - private static string[] GetFullFrameworkFolders(ProjectInstance projectInstance) - { - string val = projectInstance.GetPropertyValue(FullFrameworkReferenceAssemblyPaths).Trim(); - - string[] _fullFrameworkFolders = val.Split(';').Select(s => s.Trim()).ToArray(); - - return _fullFrameworkFolders; - } - - private static string[] GetLatestTargetFrameworkDirectories(ProjectInstance projectInstance) - { - IEnumerable taskItems = projectInstance.GetItems(LatestTargetFrameworkDirectoriesName); - - string[] latestTargetFrameworkDirectory = (taskItems.Select((Func)((item) => { return item.ItemSpec.Trim(); }))).ToArray(); - - return latestTargetFrameworkDirectory; - } - - private static string GetProfileName(ProjectInstance projectInstance) - { - string val = projectInstance.GetPropertyValue(TargetFrameworkProfile).Trim(); - - return val; - } - #endregion //common properties/items - - #region project dtar specific properties/items - - private static string[] GetPdtarSearchPaths(ProjectInstance projectInstance) - { - string val = projectInstance.GetPropertyValue(ProjectDesignTimeAssemblyResolutionSearchPaths).Trim(); - - string[] _pdtarSearchPaths = val.Split(';').Select(s => s.Trim()).ToArray(); - - return _pdtarSearchPaths; - } - - private static string[] GetCandidateAssemblyFiles(ProjectInstance projectInstance) - { - var candidateAssemblyFilesList = new List(); - - candidateAssemblyFilesList.AddRange(projectInstance.GetItems(Content)); - candidateAssemblyFilesList.AddRange(projectInstance.GetItems(None)); - candidateAssemblyFilesList.AddRange(projectInstance.GetItems(RARResolvedReferencePath)); - - string[] candidateAssemblyFiles = candidateAssemblyFilesList.Select((Func)((item) => { return item.GetMetadataValue("FullPath").Trim(); })).ToArray(); - - return candidateAssemblyFiles; - } - - private static string GetStateFile(ProjectInstance projectInstance) - { - string intermediatePath = projectInstance.GetPropertyValue(IntermediateOutputPath).Trim(); - - intermediatePath = GetFullPathInProjectContext(projectInstance, intermediatePath); - - string stateFile = Path.Combine(intermediatePath, "DesignTimeResolveAssemblyReferences.cache"); - - return stateFile; - } - - private static ITaskItem[] GetInstalledAssemblySubsetTables(ProjectInstance projectInstance) - { - return projectInstance.GetItems(InstalledAssemblySubsetTablesName).ToArray(); - } - - private static bool GetIgnoreDefaultInstalledAssemblySubsetTables(ProjectInstance projectInstance) - { - bool ignoreDefaultInstalledAssemblySubsetTables = false; - - string val = projectInstance.GetPropertyValue(IgnoreInstalledAssemblySubsetTables).Trim(); - - if (!String.IsNullOrEmpty(val)) - { - if (val == Boolean.TrueString || val == Boolean.FalseString) - { - ignoreDefaultInstalledAssemblySubsetTables = Convert.ToBoolean(val, CultureInfo.InvariantCulture); - } - } - - return ignoreDefaultInstalledAssemblySubsetTables; - } - - private static string[] GetTargetFrameworkSubsets(ProjectInstance projectInstance) - { - IEnumerable taskItems = projectInstance.GetItems(ReferenceInstalledAssemblySubsets); - - string[] targetFrameworkSubsets = (taskItems.Select((Func)((item) => { return item.ItemSpec.Trim(); }))).ToArray(); - - return targetFrameworkSubsets; - } - - private static string[] GetFullTargetFrameworkSubsetNames(ProjectInstance projectInstance) - { - string val = projectInstance.GetPropertyValue(FullReferenceAssemblyNames).Trim(); - - string[] fullTargetFrameworkSubsetNames = val.Split(';').Select(s => s.Trim()).ToArray(); - - return fullTargetFrameworkSubsetNames; - } - - private static ITaskItem[] GetFullFrameworkAssemblyTables(ProjectInstance projectInstance) - { - return projectInstance.GetItems(FullFrameworkAssemblyTablesName).ToArray(); - } - - #endregion //project dtar specific properties/items - - #endregion // public properties - - #region private methods - static string GetFullPathInProjectContext(ProjectInstance projectInstance, string path) - { - string fullPath = path; - - if (!Path.IsPathRooted(path)) - { - string projectDir = projectInstance.GetPropertyValue(MSBuildProjectDirectory).Trim(); - - fullPath = Path.Combine(projectDir, path); - - fullPath = Path.GetFullPath(fullPath); - } - - return fullPath; - } - #endregion // private methods - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Diagrams/AutomationClasses.cd b/SHFB/Source/MPFProj_VS2010/Diagrams/AutomationClasses.cd deleted file mode 100644 index 579933f3..00000000 --- a/SHFB/Source/MPFProj_VS2010/Diagrams/AutomationClasses.cd +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - AAAAAJAAAAAAMAAAAAAAAAAAAAAAAAACgBABAAAAAAA= - Automation\OAFileItem.cs - - - - - - AEQAAAAAEABACBAAAAgASAQkCAgAIAAAAgAAAAAAACQ= - Automation\OANavigableProjectItems.cs - - - - - - - AAQAAJQAAABEUIIhQAAcCAQAAAkAAAAAIBgFCABCAAA= - Automation\OAProject.cs - - - - - - - - - - AQQAQJAAAABEYAAgQACMDCQBCAkAAAACgBAFAAECAAA= - Automation\OAProjectItem.cs - - - - - - - AEAAAAAAEAAAAAAAAAAgAAAggAAAAAAAAAAAAAAAACA= - Automation\OAProjectItems.cs - - - - - - EAYAAAACABAAABAAIAAAQCQEAAIAAAAIAAAAAAECAAA= - Automation\OAProperties.cs - - - - - - - AQSAAAAAABAAQAJgAAAQQAQAgAAAAAAAAAAgAAAAAAA= - Automation\OAProperty.cs - - - - - - - AAAAABAAAAAAAAAAAAAAACAAAAAACAAAAAAAAAAAAAA= - Automation\OANestedProjectItem.cs - - - - - - AAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ= - Automation\OAReferenceFolderItem.cs - - - - - - AUQAAAAAAAAAAAAAAAAAQAAgAAIAAAAAAAQAAAAEAAA= - Automation\OASolutionFolder.cs - - - - - - - AAAAAAAAAAAAYAAAAAAAAAQAAAEAAAAAAAAAAAAAAAA= - Automation\OAReferenceItem.cs - - - - \ No newline at end of file diff --git a/SHFB/Source/MPFProj_VS2010/Diagrams/ConfigurationClasses.cd b/SHFB/Source/MPFProj_VS2010/Diagrams/ConfigurationClasses.cd deleted file mode 100644 index d8f07338..00000000 --- a/SHFB/Source/MPFProj_VS2010/Diagrams/ConfigurationClasses.cd +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - AAAAAQQAAAAAAAAAAAAAgAAACAgAQBAAAAAAAACAABA= - Output.cs - - - - - - - AAAAIgABgwTAAAAAAAAAiAAAAIgEQAAggAAAEASAABA= - OutputGroup.cs - - - - - - - AAgCEEJABBAAkaSFCGCkAAEAAEiBYEEKACAAGRDJUEA= - ProjectConfig.cs - - - - - - - AABCAAAACgAACAAAAABABAEIAAQAgAAAIABAEABQAAA= - ProjectConfig.cs - - - - - - - gAWAgFQBAAJIAhACAAgCABAEAQ5MAAAABCAEEAAAEQQ= - ConfigProvider.cs - - - - - - - AgAEAEACAAAAAAQApAQAAgAUABAAA4AAQAIAAAAAgiA= - ProjectElement.cs - - - - - - PcP89b7sGr3/n1KfHv7+dr/f9h//71+3/xPdS+fRan4= - ProjectNode.CopyPaste.cs - - - - - \ No newline at end of file diff --git a/SHFB/Source/MPFProj_VS2010/Diagrams/DocumentManagerClasses.cd b/SHFB/Source/MPFProj_VS2010/Diagrams/DocumentManagerClasses.cd deleted file mode 100644 index 112e417f..00000000 --- a/SHFB/Source/MPFProj_VS2010/Diagrams/DocumentManagerClasses.cd +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - FileDocumentManager.cs - AACAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= - - - - - - DocumentManager.cs - AQCAQIQAAAAAIAEAAAAAAAAAIAAAAAAAAAAAACGAAAE= - - - - - - - - - - - - ProjectDesignerDocumentManager.cs - AACAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= - - - - - - HierarchyNode.cs - NKl4a26oCodRuoDQodAKZKQQxKtwgtmAOJLYAHLHccE= - - - - \ No newline at end of file diff --git a/SHFB/Source/MPFProj_VS2010/Diagrams/HierarchyClasses.cd b/SHFB/Source/MPFProj_VS2010/Diagrams/HierarchyClasses.cd deleted file mode 100644 index ecdc3b90..00000000 --- a/SHFB/Source/MPFProj_VS2010/Diagrams/HierarchyClasses.cd +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - BolBCECAAgFAAIEAgBACZAAAAAAAAAAQyAQQAIRGQIA= - FileNode.cs - - - - - - PcP89b7sGr3/n1KfHv7+dr/f9h//71+3/xPdS+fRan4= - ProjectNode.CopyPaste.cs - - - - - - - NKl4K26oqqdRuqD4sdAKZLc0zKtxgtmgOJLYADLHccE= - HierarchyNode.cs - - - - - - - AABFCBAAAAYgAAAgQAAAAAAEQMABAAAATAWAAAABAAE= - ProjectContainerNode.cs - - - - - - - BIAQEAKAAgFAAAAAgIACJAAABAICAAAACAAQAAACAQA= - FolderNode.cs - - - - - - AIBAAGagAAFAAAAAgACiIAAAAAAQAAEAGAAQAABAAAA= - ReferenceNode.cs - - - - - - AABICACgAAUAAIAgggACIABAAAYQQAAAGEIQAABAARA= - ReferenceContainerNode.cs - - - - - - - AACACCIAAAIAACQgQAAEBAQAgACAAAABCAgQAQACIAA= - ComReferenceNode.cs - - - - - - CIACCFYCAgAAgAEgAIACBAQAAAAQABAACAAAAECACgA= - ProjectReferenceNode.cs - - - - - - AAACCCJAACAACAAgEAoAAAACBABACIAIGAAAEACAABw= - AssemblyReferenceNode.cs - - - - \ No newline at end of file diff --git a/SHFB/Source/MPFProj_VS2010/Diagrams/PropertiesClasses.cd b/SHFB/Source/MPFProj_VS2010/Diagrams/PropertiesClasses.cd deleted file mode 100644 index 3e804f2e..00000000 --- a/SHFB/Source/MPFProj_VS2010/Diagrams/PropertiesClasses.cd +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - AAAACAAACAAAAAAgAAAAgAAAABAEIAAAAERAAAAACAA= - LocalizableProperties.cs - - - - - - - CAAAAAAgAAAAAAAAAAAAAAAAAAAAIQAAAAAAAABAAAA= - NodeProperties.cs - - - - - - CAAAAAAAAAAAAAAAAAAAAAQAAAAAIAAAAAAAAAAAAAA= - NodeProperties.cs - - - - - - EQACAAAAAAAAAQAAAAAECAQAAAkgAggAAAhECAEAAAA= - NodeProperties.cs - - - - - - - CAAAAAAgAAAAAAAAAAAAAAAAAAAAIAAAAAAAAABAAAA= - NodeProperties.cs - - - - - - AAABhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAgQAYA= - NodeProperties.cs - - - - - - CAAAAAAAABAAAAAAAAAAAAAAAAAgIAgAAAQAAABAAAA= - NodeProperties.cs - - - - - - CAAAAAAABAAAAAAAAAAAAAAAAAAAIAAAAAAAAABAAAA= - NodeProperties.cs - - - - - - CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= - NodeProperties.cs - - - - \ No newline at end of file diff --git a/SHFB/Source/MPFProj_VS2010/Diagrams/ReferenceClasses.cd b/SHFB/Source/MPFProj_VS2010/Diagrams/ReferenceClasses.cd deleted file mode 100644 index a8dd97e0..00000000 --- a/SHFB/Source/MPFProj_VS2010/Diagrams/ReferenceClasses.cd +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - ReferenceNode.cs - - - - - AIBAAGagAAFAAAAAgACiIAAAAAAQAAEAGAAQAABAAAA= - ReferenceNode.cs - - - - - - - - - - - - - - - CIACCFYCAgAAgAEgAIACBAQAAAAQABAACAAAAECACgA= - ProjectReferenceNode.cs - - - - - - - - - - - - AAAQAAYAAAQAgAAQAEAAAAAAAAAAAAAAEQAAAACAAAA= - BuildDependency.cs - - - - - - - AACACCIAAAIAACQgQAAEBAQAgACAAAABCAgQAQACIAA= - ComReferenceNode.cs - - - - - - AAAAAAAAAAAAAAAAAQAAIAAAAgAAAAAIAAAAgABAAAA= - SolutionListenerForProjectReferenceUpdate.cs - - - - - - AAIACRBQoCAQCCAAEAIAJAAACgQBAAAYAQAiiAIAAAA= - SolutionListener.cs - - - - - - - AAACCCJAACAACAAgEAoAAAACBABACIAIGAAAEACAABw= - AssemblyReferenceNode.cs - - - - \ No newline at end of file diff --git a/SHFB/Source/MPFProj_VS2010/DocumentManager.cs b/SHFB/Source/MPFProj_VS2010/DocumentManager.cs deleted file mode 100644 index cdc141e3..00000000 --- a/SHFB/Source/MPFProj_VS2010/DocumentManager.cs +++ /dev/null @@ -1,383 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Globalization; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// This abstract class handles opening, saving of items in the hierarchy. - /// - [CLSCompliant(false)] - public abstract class DocumentManager - { - #region fields - private HierarchyNode node = null; - #endregion - - #region properties - protected HierarchyNode Node - { - get - { - return this.node; - } - } - #endregion - - #region ctors - protected DocumentManager(HierarchyNode node) - { - this.node = node; - } - #endregion - - #region virtual methods - - /// - /// Open a document using the standard editor. This method has no implementation since a document is abstract in this context - /// - /// In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class - /// IntPtr to the IUnknown interface of the existing document data object - /// A reference to the window frame that is mapped to the document - /// Determine the UI action on the document window - /// NotImplementedException - /// See FileDocumentManager class for an implementation of this method - public virtual int Open(ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction) - { - throw new NotImplementedException(); - } - - /// - /// Open a document using a specific editor. This method has no implementation. - /// - /// Specifies actions to take when opening a specific editor. Possible editor flags are defined in the enumeration Microsoft.VisualStudio.Shell.Interop.__VSOSPEFLAGS - /// Unique identifier of the editor type - /// Name of the physical view. If null, the environment calls MapLogicalView on the editor factory to determine the physical view that corresponds to the logical view. In this case, null does not specify the primary view, but rather indicates that you do not know which view corresponds to the logical view - /// In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class - /// IntPtr to the IUnknown interface of the existing document data object - /// A reference to the window frame that is mapped to the document - /// Determine the UI action on the document window - /// NotImplementedException - /// See FileDocumentManager for an implementation of this method - public virtual int OpenWithSpecific(uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame frame, WindowFrameShowAction windowFrameAction) - { - throw new NotImplementedException(); - } - - /// - /// Close an open document window - /// - /// Decides how to close the document - /// S_OK if successful, otherwise an error is returned - public virtual int Close(__FRAMECLOSE closeFlag) - { - if(this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - // Get info about the document - bool isDirty, isOpen, isOpenedByUs; - uint docCookie; - IVsPersistDocData ppIVsPersistDocData; - this.GetDocInfo(out isOpen, out isDirty, out isOpenedByUs, out docCookie, out ppIVsPersistDocData); - - if(isOpenedByUs) - { - IVsUIShellOpenDocument shell = this.Node.ProjectMgr.Site.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; - Guid logicalView = Guid.Empty; - uint grfIDO = 0; - IVsUIHierarchy pHierOpen; - uint[] itemIdOpen = new uint[1]; - IVsWindowFrame windowFrame; - int fOpen; - ErrorHandler.ThrowOnFailure(shell.IsDocumentOpen(this.Node.ProjectMgr.InteropSafeIVsUIHierarchy, this.Node.ID, this.Node.Url, ref logicalView, grfIDO, out pHierOpen, itemIdOpen, out windowFrame, out fOpen)); - - if(windowFrame != null) - { - docCookie = 0; - return windowFrame.CloseFrame((uint)closeFlag); - } - } - - return VSConstants.S_OK; - } - - /// - /// Silently saves an open document - /// - /// Save the open document only if it is dirty - /// The call to SaveDocData may return Microsoft.VisualStudio.Shell.Interop.PFF_RESULTS.STG_S_DATALOSS to indicate some characters could not be represented in the current codepage - public virtual void Save(bool saveIfDirty) - { - bool isDirty, isOpen, isOpenedByUs; - uint docCookie; - IVsPersistDocData persistDocData; - this.GetDocInfo(out isOpen, out isDirty, out isOpenedByUs, out docCookie, out persistDocData); - if(isDirty && saveIfDirty && persistDocData != null) - { - string name; - int cancelled; - ErrorHandler.ThrowOnFailure(persistDocData.SaveDocData(VSSAVEFLAGS.VSSAVE_SilentSave, out name, out cancelled)); - } - } - - #endregion - - #region helper methods - /// - /// Get document properties from RDT - /// - internal void GetDocInfo( - out bool isOpen, // true if the doc is opened - out bool isDirty, // true if the doc is dirty - out bool isOpenedByUs, // true if opened by our project - out uint docCookie, // VSDOCCOOKIE if open - out IVsPersistDocData persistDocData) - { - isOpen = isDirty = isOpenedByUs = false; - docCookie = (uint)ShellConstants.VSDOCCOOKIE_NIL; - persistDocData = null; - - if(this.node == null || this.node.ProjectMgr == null || this.node.ProjectMgr.IsClosed) - { - return; - } - - IVsHierarchy hierarchy; - uint vsitemid = VSConstants.VSITEMID_NIL; - - VsShellUtilities.GetRDTDocumentInfo(this.node.ProjectMgr.Site, this.node.Url, out hierarchy, out vsitemid, out persistDocData, out docCookie); - - if(hierarchy == null || docCookie == (uint)ShellConstants.VSDOCCOOKIE_NIL) - { - return; - } - - isOpen = true; - // check if the doc is opened by another project - if(Utilities.IsSameComObject(this.node.ProjectMgr.InteropSafeIVsHierarchy, hierarchy)) - { - isOpenedByUs = true; - } - - if(persistDocData != null) - { - int isDocDataDirty; - ErrorHandler.ThrowOnFailure(persistDocData.IsDocDataDirty(out isDocDataDirty)); - isDirty = (isDocDataDirty != 0); - } - } - - protected string GetOwnerCaption() - { - Debug.Assert(this.node != null, "No node has been initialized for the document manager"); - - object pvar; - ErrorHandler.ThrowOnFailure(this.node.GetProperty(this.node.ID, (int)__VSHPROPID.VSHPROPID_Caption, out pvar)); - - return (pvar as string); - } - - protected static void CloseWindowFrame(ref IVsWindowFrame windowFrame) - { - if(windowFrame != null) - { - try - { - ErrorHandler.ThrowOnFailure(windowFrame.CloseFrame(0)); - } - finally - { - windowFrame = null; - } - } - } - - protected string GetFullPathForDocument() - { - string fullPath = String.Empty; - - Debug.Assert(this.node != null, "No node has been initialized for the document manager"); - - // Get the URL representing the item - fullPath = this.node.GetMkDocument(); - - Debug.Assert(!String.IsNullOrEmpty(fullPath), "Could not retrive the fullpath for the node" + this.Node.ID.ToString(CultureInfo.CurrentCulture)); - return fullPath; - } - - #endregion - - #region static methods - /// - /// Updates the caption for all windows associated to the document. - /// - /// The service provider. - /// The new caption. - /// The IUnknown interface to a document data object associated with a registered document. - public static void UpdateCaption(IServiceProvider site, string caption, IntPtr docData) - { - if(site == null) - { - throw new ArgumentNullException("site"); - } - - if(String.IsNullOrEmpty(caption)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "caption"); - } - - IVsUIShell 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)); - IVsWindowFrame[] windowFrames = new IVsWindowFrame[1]; - uint fetched; - while(windowFramesEnum.Next(1, windowFrames, out fetched) == VSConstants.S_OK && fetched == 1) - { - IVsWindowFrame windowFrame = windowFrames[0]; - object data; - ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out data)); - IntPtr 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); - } - } - } - } - - /// - /// Rename document in the running document table from oldName to newName. - /// - /// The service provider. - /// Full path to the old name of the document. - /// Full path to the new name of the document. - /// The new item id of the document - public static void RenameDocument(IServiceProvider site, string oldName, string newName, uint newItemId) - { - if(site == null) - { - throw new ArgumentNullException("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"); - } - - if(newItemId == VSConstants.VSITEMID_NIL) - { - throw new ArgumentNullException("newItemId"); - } - - 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)); - } - finally - { - if(pHier != IntPtr.Zero) - Marshal.Release(pHier); - if(pUnk != IntPtr.Zero) - Marshal.Release(pUnk); - } - } - finally - { - Marshal.Release(docData); - } - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/EnumDependencies.cs b/SHFB/Source/MPFProj_VS2010/EnumDependencies.cs deleted file mode 100644 index 52fdd639..00000000 --- a/SHFB/Source/MPFProj_VS2010/EnumDependencies.cs +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false)] - public class EnumDependencies : IVsEnumDependencies - { - private List dependencyList = new List(); - - private uint nextIndex; - - public EnumDependencies(IList dependencyList) - { - if (dependencyList == null) - { - throw new ArgumentNullException("dependencyList"); - } - - foreach(IVsDependency dependency in dependencyList) - { - this.dependencyList.Add(dependency); - } - } - - public EnumDependencies(IList dependencyList) - { - if (dependencyList == null) - { - throw new ArgumentNullException("dependencyList"); - } - - foreach(IVsBuildDependency dependency in dependencyList) - { - this.dependencyList.Add(dependency); - } - } - - public int Clone(out IVsEnumDependencies enumDependencies) - { - enumDependencies = new EnumDependencies(this.dependencyList); - ErrorHandler.ThrowOnFailure(enumDependencies.Skip(this.nextIndex)); - return VSConstants.S_OK; - } - - public int Next(uint elements, IVsDependency[] dependencies, out uint elementsFetched) - { - elementsFetched = 0; - if (dependencies == null) - { - throw new ArgumentNullException("dependencies"); - } - - uint fetched = 0; - int 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); - } - - public int Reset() - { - this.nextIndex = 0; - return VSConstants.S_OK; - } - - public int Skip(uint elements) - { - this.nextIndex += elements; - uint count = (uint)this.dependencyList.Count; - - if(this.nextIndex > count) - { - this.nextIndex = count; - return VSConstants.S_FALSE; - } - - return VSConstants.S_OK; - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/FileChangeManager.cs b/SHFB/Source/MPFProj_VS2010/FileChangeManager.cs deleted file mode 100644 index 1e6b5928..00000000 --- a/SHFB/Source/MPFProj_VS2010/FileChangeManager.cs +++ /dev/null @@ -1,325 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Globalization; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// This object is in charge of reloading nodes that have file monikers that can be listened to changes - /// - internal class FileChangeManager : IVsFileChangeEvents - { - #region nested objects - /// - /// Defines a data structure that can link a item moniker to the item and its file change cookie. - /// - private struct ObservedItemInfo - { - /// - /// Defines the id of the item that is to be reloaded. - /// - private uint itemID; - - /// - /// Defines the file change cookie that is returned when listening on file changes on the nested project item. - /// - private uint fileChangeCookie; - - /// - /// Defines the nested project item that is to be reloaded. - /// - internal uint ItemID - { - get - { - return this.itemID; - } - - set - { - this.itemID = value; - } - } - - /// - /// Defines the file change cookie that is returned when listenning on file changes on the nested project item. - /// - internal uint FileChangeCookie - { - get - { - return this.fileChangeCookie; - } - - set - { - this.fileChangeCookie = value; - } - } - } - #endregion - - #region Fields - /// - /// Event that is raised when one of the observed file names have changed on disk. - /// - internal event EventHandler FileChangedOnDisk; - - /// - /// Reference to the FileChange service. - /// - private IVsFileChangeEx fileChangeService; - - /// - /// Maps between the observed item identified by its filename (in canonicalized form) and the cookie used for subscribing - /// to the events. - /// - private Dictionary observedItems = new Dictionary(); - - /// - /// Has Disposed already been called? - /// - private bool disposed; - #endregion - - #region Constructor - /// - /// Overloaded ctor. - /// - /// An instance of the service provider. - internal FileChangeManager(IServiceProvider serviceProvider) - { - #region input validation - if(serviceProvider == null) - { - throw new ArgumentNullException("serviceProvider"); - } - #endregion - - this.fileChangeService = (IVsFileChangeEx)serviceProvider.GetService(typeof(SVsFileChangeEx)); - - if(this.fileChangeService == null) - { - // VS is in bad state, since the SVsFileChangeEx could not be proffered. - throw new InvalidOperationException(); - } - } - #endregion - - #region IDisposable Members - /// - /// Disposes resources. - /// - public void Dispose() - { - // Don't dispose more than once - if(this.disposed) - { - return; - } - - this.disposed = true; - - // Unsubscribe from the observed source files. - foreach(ObservedItemInfo info in this.observedItems.Values) - { - ErrorHandler.ThrowOnFailure(this.fileChangeService.UnadviseFileChange(info.FileChangeCookie)); - } - - // Clean the observerItems list - this.observedItems.Clear(); - } - #endregion - - #region IVsFileChangeEvents Members - /// - /// Called when one of the file have changed on disk. - /// - /// Number of files changed. - /// Array of file names. - /// Array of flags indicating the type of changes. See _VSFILECHANGEFLAGS. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - int IVsFileChangeEvents.FilesChanged(uint numberOfFilesChanged, string[] filesChanged, uint[] flags) - { - if (filesChanged == null) - { - throw new ArgumentNullException("filesChanged"); - } - - if (flags == null) - { - throw new ArgumentNullException("flags"); - } - - if(this.FileChangedOnDisk != null) - { - for(int i = 0; i < numberOfFilesChanged; i++) - { - string fullFileName = Utilities.CanonicalizeFileName(filesChanged[i]); - if(this.observedItems.ContainsKey(fullFileName)) - { - ObservedItemInfo info = this.observedItems[fullFileName]; - this.FileChangedOnDisk(this, new FileChangedOnDiskEventArgs(fullFileName, info.ItemID, (_VSFILECHANGEFLAGS)flags[i])); - } - } - } - - return VSConstants.S_OK; - } - - /// - /// Notifies clients of changes made to a directory. - /// - /// Name of the directory that had a change. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - int IVsFileChangeEvents.DirectoryChanged(string directory) - { - return VSConstants.S_OK; - } - #endregion - - #region helpers - /// - /// Observe when the given file is updated on disk. In this case we do not care about the item id that represents the file in the hierarchy. - /// - /// File to observe. - internal void ObserveItem(string fileName) - { - this.ObserveItem(fileName, VSConstants.VSITEMID_NIL); - } - - /// - /// Observe when the given file is updated on disk. - /// - /// File to observe. - /// The item id of the item to observe. - internal void ObserveItem(string fileName, uint id) - { - #region Input validation - if(String.IsNullOrEmpty(fileName)) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "fileName"); - } - #endregion - - string fullFileName = Utilities.CanonicalizeFileName(fileName); - if(!this.observedItems.ContainsKey(fullFileName)) - { - // Observe changes to the file - uint fileChangeCookie; - ErrorHandler.ThrowOnFailure(this.fileChangeService.AdviseFileChange(fullFileName, (uint)(_VSFILECHANGEFLAGS.VSFILECHG_Time | _VSFILECHANGEFLAGS.VSFILECHG_Del), this, out fileChangeCookie)); - - ObservedItemInfo itemInfo = new ObservedItemInfo(); - itemInfo.ItemID = id; - itemInfo.FileChangeCookie = fileChangeCookie; - - // Remember that we're observing this file (used in FilesChanged event handler) - this.observedItems.Add(fullFileName, itemInfo); - } - } - - /// - /// Ignore item file changes for the specified item. - /// - /// File to ignore observing. - /// Flag indicating whether or not to ignore changes (1 to ignore, 0 to stop ignoring). - internal void IgnoreItemChanges(string fileName, bool ignore) - { - #region Input validation - if(String.IsNullOrEmpty(fileName)) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "fileName"); - } - #endregion - - string fullFileName = Utilities.CanonicalizeFileName(fileName); - if(this.observedItems.ContainsKey(fullFileName)) - { - // Call ignore file with the flags specified. - ErrorHandler.ThrowOnFailure(this.fileChangeService.IgnoreFile(0, fileName, ignore ? 1 : 0)); - } - } - - /// - /// Stop observing when the file is updated on disk. - /// - /// File to stop observing. - internal void StopObservingItem(string fileName) - { - #region Input validation - if(String.IsNullOrEmpty(fileName)) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "fileName"); - } - #endregion - - string fullFileName = Utilities.CanonicalizeFileName(fileName); - - if(this.observedItems.ContainsKey(fullFileName)) - { - // Get the cookie that was used for this.observedItems to this file. - ObservedItemInfo itemInfo = this.observedItems[fullFileName]; - - // Remove the file from our observed list. It's important that this is done before the call to - // UnadviseFileChange, because for some reason, the call to UnadviseFileChange can trigger a - // FilesChanged event, and we want to be able to filter that event away. - this.observedItems.Remove(fullFileName); - - // Stop observing the file - ErrorHandler.ThrowOnFailure(this.fileChangeService.UnadviseFileChange(itemInfo.FileChangeCookie)); - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/FileDocumentManager.cs b/SHFB/Source/MPFProj_VS2010/FileDocumentManager.cs deleted file mode 100644 index 29c7f6dc..00000000 --- a/SHFB/Source/MPFProj_VS2010/FileDocumentManager.cs +++ /dev/null @@ -1,306 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// This class handles opening, saving of file items in the hierarchy. - /// - [CLSCompliant(false)] - public class FileDocumentManager : DocumentManager - { - #region ctors - - public FileDocumentManager(FileNode node) - : base(node) - { - } - #endregion - - #region overriden methods - - /// - /// Open a file using the standard editor - /// - /// In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class - /// IntPtr to the IUnknown interface of the existing document data object - /// A reference to the window frame that is mapped to the file - /// Determine the UI action on the document window - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int Open(ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction) - { - bool newFile = false; - bool openWith = false; - return this.Open(newFile, openWith, ref logicalView, docDataExisting, out windowFrame, windowFrameAction); - } - - /// - /// Open a file with a specific editor - /// - /// Specifies actions to take when opening a specific editor. Possible editor flags are defined in the enumeration Microsoft.VisualStudio.Shell.Interop.__VSOSPEFLAGS - /// Unique identifier of the editor type - /// Name of the physical view. If null, the environment calls MapLogicalView on the editor factory to determine the physical view that corresponds to the logical view. In this case, null does not specify the primary view, but rather indicates that you do not know which view corresponds to the logical view - /// In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class - /// IntPtr to the IUnknown interface of the existing document data object - /// A reference to the window frame that is mapped to the file - /// Determine the UI action on the document window - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int OpenWithSpecific(uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction) - { - windowFrame = null; - bool newFile = false; - bool openWith = false; - return this.Open(newFile, openWith, editorFlags, ref editorType, physicalView, ref logicalView, docDataExisting, out windowFrame, windowFrameAction); - } - - #endregion - - #region public methods - /// - /// Open a file in a document window with a std editor - /// - /// Open the file as a new file - /// Use a dialog box to determine which editor to use - /// Determine the UI action on the document window - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public int Open(bool newFile, bool openWith, WindowFrameShowAction windowFrameAction) - { - Guid logicalView = Guid.Empty; - IVsWindowFrame windowFrame = null; - return this.Open(newFile, openWith, logicalView, out windowFrame, windowFrameAction); - } - - /// - /// Open a file in a document window with a std editor - /// - /// Open the file as a new file - /// Use a dialog box to determine which editor to use - /// In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class - /// A reference to the window frame that is mapped to the file - /// Determine the UI action on the document window - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public int Open(bool newFile, bool openWith, Guid logicalView, out IVsWindowFrame frame, WindowFrameShowAction windowFrameAction) - { - frame = null; - IVsRunningDocumentTable rdt = this.Node.ProjectMgr.Site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - Debug.Assert(rdt != null, " Could not get running document table from the services exposed by this project"); - if(rdt == null) - { - return VSConstants.E_FAIL; - } - - // First we see if someone else has opened the requested view of the file. - _VSRDTFLAGS flags = _VSRDTFLAGS.RDT_NoLock; - uint itemid; - IntPtr docData = IntPtr.Zero; - IVsHierarchy ivsHierarchy; - uint docCookie; - string path = this.GetFullPathForDocument(); - int returnValue = VSConstants.S_OK; - - try - { - ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)flags, path, out ivsHierarchy, out itemid, out docData, out docCookie)); - ErrorHandler.ThrowOnFailure(this.Open(newFile, openWith, ref logicalView, docData, out frame, windowFrameAction)); - } - catch(COMException e) - { - Trace.WriteLine("Exception :" + e.Message); - returnValue = e.ErrorCode; - } - finally - { - if(docData != IntPtr.Zero) - { - Marshal.Release(docData); - } - } - - return returnValue; - } - - #endregion - - #region virtual methods - /// - /// Open a file in a document window - /// - /// Open the file as a new file - /// Use a dialog box to determine which editor to use - /// In MultiView case determines view to be activated by IVsMultiViewDocumentView. For a list of logical view GUIDS, see constants starting with LOGVIEWID_ defined in NativeMethods class - /// IntPtr to the IUnknown interface of the existing document data object - /// A reference to the window frame that is mapped to the file - /// Determine the UI action on the document window - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int Open(bool newFile, bool openWith, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction) - { - windowFrame = null; - Guid editorType = Guid.Empty; - return this.Open(newFile, openWith, 0, ref editorType, null, ref logicalView, docDataExisting, out windowFrame, windowFrameAction); - } - - #endregion - - #region helper methods - - private int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction) - { - windowFrame = null; - if(this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - Debug.Assert(this.Node != null, "No node has been initialized for the document manager"); - Debug.Assert(this.Node.ProjectMgr != null, "No project manager has been initialized for the document manager"); - Debug.Assert(this.Node is FileNode, "Node is not FileNode object"); - - int returnValue = VSConstants.S_OK; - string caption = this.GetOwnerCaption(); - string fullPath = this.GetFullPathForDocument(); - - // Make sure that the file is on disk before we open the editor and display message if not found - if(!((FileNode)this.Node).IsFileOnDisk(true)) - { - // Inform clients that we have an invalid item (wrong icon) - this.Node.OnInvalidateItems(this.Node.Parent); - - // Bail since we are not able to open the item - // Do not return an error code otherwise an internal error message is shown. The scenario for this operation - // normally is already a reaction to a dialog box telling that the item has been removed. - return VSConstants.S_FALSE; - } - - IVsUIShellOpenDocument uiShellOpenDocument = this.Node.ProjectMgr.Site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument; - IOleServiceProvider serviceProvider = this.Node.ProjectMgr.Site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider; - - try - { - this.Node.ProjectMgr.OnOpenItem(fullPath); - int result = VSConstants.E_FAIL; - - if(openWith) - { - result = uiShellOpenDocument.OpenStandardEditor((uint)__VSOSEFLAGS.OSE_UseOpenWithDialog, fullPath, ref logicalView, caption, this.Node.ProjectMgr.InteropSafeIVsUIHierarchy, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); - } - else - { - __VSOSEFLAGS openFlags = 0; - if(newFile) - { - openFlags |= __VSOSEFLAGS.OSE_OpenAsNewFile; - } - - //NOTE: we MUST pass the IVsProject in pVsUIHierarchy and the itemid - // of the node being opened, otherwise the debugger doesn't work. - if(editorType != Guid.Empty) - { - result = uiShellOpenDocument.OpenSpecificEditor(editorFlags, fullPath, ref editorType, physicalView, ref logicalView, caption, this.Node.ProjectMgr.InteropSafeIVsUIHierarchy, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); - } - else - { - openFlags |= __VSOSEFLAGS.OSE_ChooseBestStdEditor; - result = uiShellOpenDocument.OpenStandardEditor((uint)openFlags, fullPath, ref logicalView, caption, this.Node.ProjectMgr.InteropSafeIVsUIHierarchy, this.Node.ID, docDataExisting, serviceProvider, out windowFrame); - } - } - - if(result != VSConstants.S_OK && result != VSConstants.S_FALSE && result != VSConstants.OLE_E_PROMPTSAVECANCELLED) - { - ErrorHandler.ThrowOnFailure(result); - } - - if(windowFrame != null) - { - object var; - - if(newFile) - { - ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var)); - IVsPersistDocData persistDocData = (IVsPersistDocData)var; - ErrorHandler.ThrowOnFailure(persistDocData.SetUntitledDocPath(fullPath)); - } - - var = null; - ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocCookie, out var)); - this.Node.DocCookie = (uint)(int)var; - - if(windowFrameAction == WindowFrameShowAction.Show) - { - ErrorHandler.ThrowOnFailure(windowFrame.Show()); - } - else if(windowFrameAction == WindowFrameShowAction.ShowNoActivate) - { - ErrorHandler.ThrowOnFailure(windowFrame.ShowNoActivate()); - } - else if(windowFrameAction == WindowFrameShowAction.Hide) - { - ErrorHandler.ThrowOnFailure(windowFrame.Hide()); - } - } - } - catch(COMException e) - { - Trace.WriteLine("Exception e:" + e.Message); - returnValue = e.ErrorCode; - CloseWindowFrame(ref windowFrame); - } - - return returnValue; - } - - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/FileNode.cs b/SHFB/Source/MPFProj_VS2010/FileNode.cs deleted file mode 100644 index b25f60b9..00000000 --- a/SHFB/Source/MPFProj_VS2010/FileNode.cs +++ /dev/null @@ -1,1252 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//============================================================================= -// File : FileNode.cs -// Updated : 04/18/2011 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// This file has been modified to support "Add as Link" and "Show All Files" in -// the project. Search for "!EFW" to find the changes. Note that these -// changes have not been tested with dependent files so expect bugs. -// -// Date Who Comments -// ============================================================================ -// 06/18/2008 EFW Added support for linked project files -// 06/20/2008 EFW Added support for "Show All Files" -// 03/20/2011 EFW Updated to use MPFProj for VS2010 -//============================================================================= - -// Core Show All Files functionality implemented in the FileNode.cs: -// - Updated ImageIndex property to return the excluded file image for non-member items. -// - Updated MenuCommandId to return an appropriate context menu for non-member items. -// - Updated QueryStatusOnNode() to enable/disable commands as needed for non-member items. - -// Show All Files functionality not implemented in FileNode.cs -// - Derived classes that override CreatePropertiesObject() should return a default -// instance of FileNodeProperties rather than their custom properties if the node -// is a non-member item. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; -using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; -using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; - -// !EFW -using VsPkgMenus = Microsoft.VisualStudio.Project.VsMenus; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false)] - [ComVisible(true)] - public class FileNode : HierarchyNode - { - #region static fiels - private static Dictionary extensionIcons; - #endregion - - #region overriden Properties - /// - /// overwrites of the generic hierarchyitem. - /// - [System.ComponentModel.BrowsableAttribute(false)] - public override string Caption - { - get - { - // Use LinkedIntoProjectAt property if available - string caption = this.ItemNode.GetMetadata(ProjectFileConstants.LinkedIntoProjectAt); - if(caption == null || caption.Length == 0) - { - // Otherwise use filename - caption = this.ItemNode.GetMetadata(ProjectFileConstants.Include); - caption = Path.GetFileName(caption); - } - return caption; - } - } - - /// - /// Get an index into the icon image list that represents the icon to show for this file. - /// - public override int ImageIndex - { - get - { - // !EFW - if(base.IsNonMemberItem) - return (int)ProjectNode.ImageName.ExcludedFile; - - // Check if the file is there. - if(!this.CanShowDefaultIcon()) - { - return (int) ProjectNode.ImageName.MissingFile; - } - - // Check for known extensions - int imageIndex; - string extension = System.IO.Path.GetExtension(this.FileName); - - if((string.IsNullOrEmpty(extension)) || (!extensionIcons.TryGetValue(extension, out imageIndex))) - { - // Missing or unknown extension; let the base class handle this case. - return base.ImageIndex; - } - - // The file type is known and there is an image for it in the image list. - return imageIndex; - } - } - - public override Guid ItemTypeGuid - { - get { return VSConstants.GUID_ItemType_PhysicalFile; } - } - - - /// - /// Get the menu command ID for the file item - /// - public override int MenuCommandId - { - get - { - // !EFW - if(base.IsNonMemberItem) - return VsPkgMenus.IDM_VS_CTXT_XPROJ_MULTIITEM; - - return VsMenus.IDM_VS_CTXT_ITEMNODE; - } - } - - public override string Url - { - get - { - string path = this.ItemNode.GetMetadata(ProjectFileConstants.Include); - if(String.IsNullOrEmpty(path)) - { - return String.Empty; - } - - Url url; - if(Path.IsPathRooted(path)) - { - // Use absolute path - url = new Microsoft.VisualStudio.Shell.Url(path); - } - else - { - // Path is relative, so make it relative to project path - url = new Url(this.ProjectMgr.BaseURI, path); - } - return url.AbsoluteUrl; - - } - } - #endregion - - #region ctor - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] - static FileNode() - { - // Build the dictionary with the mapping between some well known extensions - // and the index of the icons inside the standard image list. - extensionIcons = new Dictionary(StringComparer.OrdinalIgnoreCase); - extensionIcons.Add(".aspx", (int)ProjectNode.ImageName.WebForm); - extensionIcons.Add(".asax", (int)ProjectNode.ImageName.GlobalApplicationClass); - extensionIcons.Add(".asmx", (int)ProjectNode.ImageName.WebService); - extensionIcons.Add(".ascx", (int)ProjectNode.ImageName.WebUserControl); - extensionIcons.Add(".asp", (int)ProjectNode.ImageName.ASPPage); - extensionIcons.Add(".config", (int)ProjectNode.ImageName.WebConfig); - extensionIcons.Add(".htm", (int)ProjectNode.ImageName.HTMLPage); - extensionIcons.Add(".html", (int)ProjectNode.ImageName.HTMLPage); - extensionIcons.Add(".css", (int)ProjectNode.ImageName.StyleSheet); - extensionIcons.Add(".xsl", (int)ProjectNode.ImageName.StyleSheet); - extensionIcons.Add(".vbs", (int)ProjectNode.ImageName.ScriptFile); - extensionIcons.Add(".js", (int)ProjectNode.ImageName.ScriptFile); - extensionIcons.Add(".wsf", (int)ProjectNode.ImageName.ScriptFile); - extensionIcons.Add(".txt", (int)ProjectNode.ImageName.TextFile); - extensionIcons.Add(".resx", (int)ProjectNode.ImageName.Resources); - extensionIcons.Add(".rc", (int)ProjectNode.ImageName.Resources); - extensionIcons.Add(".bmp", (int)ProjectNode.ImageName.Bitmap); - extensionIcons.Add(".ico", (int)ProjectNode.ImageName.Icon); - extensionIcons.Add(".gif", (int)ProjectNode.ImageName.Image); - extensionIcons.Add(".jpg", (int)ProjectNode.ImageName.Image); - extensionIcons.Add(".png", (int)ProjectNode.ImageName.Image); - extensionIcons.Add(".map", (int)ProjectNode.ImageName.ImageMap); - extensionIcons.Add(".wav", (int)ProjectNode.ImageName.Audio); - extensionIcons.Add(".mid", (int)ProjectNode.ImageName.Audio); - extensionIcons.Add(".midi", (int)ProjectNode.ImageName.Audio); - extensionIcons.Add(".avi", (int)ProjectNode.ImageName.Video); - extensionIcons.Add(".mov", (int)ProjectNode.ImageName.Video); - extensionIcons.Add(".mpg", (int)ProjectNode.ImageName.Video); - extensionIcons.Add(".mpeg", (int)ProjectNode.ImageName.Video); - extensionIcons.Add(".cab", (int)ProjectNode.ImageName.CAB); - extensionIcons.Add(".jar", (int)ProjectNode.ImageName.JAR); - extensionIcons.Add(".xslt", (int)ProjectNode.ImageName.XSLTFile); - extensionIcons.Add(".xsd", (int)ProjectNode.ImageName.XMLSchema); - extensionIcons.Add(".xml", (int)ProjectNode.ImageName.XMLFile); - extensionIcons.Add(".pfx", (int)ProjectNode.ImageName.PFX); - extensionIcons.Add(".snk", (int)ProjectNode.ImageName.SNK); - } - - /// - /// Constructor for the FileNode - /// - /// Root of the hierarchy - /// Associated project element - public FileNode(ProjectNode root, ProjectElement element) - : base(root, element) - { - if(this.ProjectMgr.NodeHasDesigner(this.ItemNode.GetMetadata(ProjectFileConstants.Include))) - { - this.HasDesigner = true; - } - } - #endregion - - #region overridden methods - protected override NodeProperties CreatePropertiesObject() - { - ISingleFileGenerator generator = this.CreateSingleFileGenerator(); - - return generator == null ? new FileNodeProperties(this) : new SingleFileGeneratorNodeProperties(this); - } - - public override object GetIconHandle(bool open) - { - int index = this.ImageIndex; - if(NoImage == index) - { - // There is no image for this file; let the base class handle this case. - return base.GetIconHandle(open); - } - // Return the handle for the image. - return this.ProjectMgr.ImageHandler.GetIconHandle(index); - } - - /// - /// Get an instance of the automation object for a FileNode - /// - /// An instance of the Automation.OAFileNode if succeeded - public override object GetAutomationObject() - { - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return null; - } - - return new Automation.OAFileItem(this.ProjectMgr.GetAutomationObject() as Automation.OAProject, this); - } - - // !EFW - /// - /// This is overridden to get the overlay icon for linked items - /// - /// The property ID to get - /// The property ID value - public override object GetProperty(int propId) - { - if((__VSHPROPID)propId == __VSHPROPID.VSHPROPID_OverlayIconIndex && - !String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.Link))) - return VSOVERLAYICON.OVERLAYICON_SHORTCUT; - - return base.GetProperty(propId); - } - - /// - /// Renames a file node. - /// - /// The new name. - /// An errorcode for failure or S_OK. - /// Returned if the file cannot be validated - /// - /// We are going to throw instead of showing messageboxes, since this method is called from various places where a dialog box does not make sense. - /// For example the FileNodeProperties are also calling this method. That should not show directly a messagebox. - /// Also the automation methods are also calling SetEditLabel - /// - public override int SetEditLabel(string label) - { - // IMPORTANT NOTE: This code will be called when a parent folder is renamed. As such, it is - // expected that we can be called with a label which is the same as the current - // label and this should not be considered a NO-OP. - - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - // Validate the filename. - if(String.IsNullOrEmpty(label)) - { - throw new InvalidOperationException(SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture)); - } - else if(label.Length > NativeMethods.MAX_PATH) - { - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.PathTooLong, CultureInfo.CurrentUICulture), label)); - } - else if(Utilities.IsFileNameInvalid(label)) - { - throw new InvalidOperationException(SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture)); - } - - for(HierarchyNode n = this.Parent.FirstChild; n != null; n = n.NextSibling) - { - if(n != this && String.Compare(n.Caption, label, StringComparison.OrdinalIgnoreCase) == 0) - { - //A file or folder with the name '{0}' already exists on disk at this location. Please choose another name. - //If this file or folder does not appear in the Solution Explorer, then it is not currently part of your project. To view files which exist on disk, but are not in the project, select Show All Files from the Project menu. - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.FileOrFolderAlreadyExists, CultureInfo.CurrentUICulture), label)); - } - } - - string fileName = Path.GetFileNameWithoutExtension(label); - - // If there is no filename or it starts with a leading dot issue an error message and quit. - if(String.IsNullOrEmpty(fileName) || fileName[0] == '.') - { - throw new InvalidOperationException(SR.GetString(SR.FileNameCannotContainALeadingPeriod, CultureInfo.CurrentUICulture)); - } - - // Verify that the file extension is unchanged - string strRelPath = Path.GetFileName(this.ItemNode.GetMetadata(ProjectFileConstants.Include)); - if(String.Compare(Path.GetExtension(strRelPath), Path.GetExtension(label), StringComparison.OrdinalIgnoreCase) != 0) - { - // Prompt to confirm that they really want to change the extension of the file - string message = SR.GetString(SR.ConfirmExtensionChange, CultureInfo.CurrentUICulture, new string[] { label }); - IVsUIShell shell = this.ProjectMgr.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; - - Debug.Assert(shell != null, "Could not get the ui shell from the project"); - if(shell == null) - { - return VSConstants.E_FAIL; - } - - if(!VsShellUtilities.PromptYesNo(message, null, OLEMSGICON.OLEMSGICON_INFO, shell)) - { - // The user cancelled the confirmation for changing the extension. - // Return S_OK in order not to show any extra dialog box - return VSConstants.S_OK; - } - } - - - // Build the relative path by looking at folder names above us as one scenarios - // where we get called is when a folder above us gets renamed (in which case our path is invalid) - HierarchyNode parent = this.Parent; - while(parent != null && (parent is FolderNode)) - { - strRelPath = Path.Combine(parent.Caption, strRelPath); - parent = parent.Parent; - } - - return SetEditLabel(label, strRelPath); - } - - // !EFW - /// - /// This is overridden to suppress renaming on linked items - /// - /// Returns the node caption if editing is allowed or null - /// if editing is not allowed - public override string GetEditLabel() - { - if(!String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.Link))) - return null; - - return base.GetEditLabel(); - } - - public override string GetMkDocument() - { - Debug.Assert(this.Url != null, "No url sepcified for this node"); - - return this.Url; - } - - /// - /// Delete the item corresponding to the specified path from storage. - /// - /// - protected internal override void DeleteFromStorage(string path) - { - if(File.Exists(path)) - { - File.SetAttributes(path, FileAttributes.Normal); // make sure it's not readonly. - File.Delete(path); - } - } - - /// - /// Rename the underlying document based on the change the user just made to the edit label. - /// - protected internal override int SetEditLabel(string label, string relativePath) - { - int returnValue = VSConstants.S_OK; - uint oldId = this.ID; - string strSavePath = Path.GetDirectoryName(relativePath); - - if(!Path.IsPathRooted(relativePath)) - { - strSavePath = Path.Combine(Path.GetDirectoryName(this.ProjectMgr.BaseURI.Uri.LocalPath), strSavePath); - } - - string newName = Path.Combine(strSavePath, label); - - if(NativeMethods.IsSamePath(newName, this.Url)) - { - // If this is really a no-op, then nothing to do - if(String.Compare(newName, this.Url, StringComparison.Ordinal) == 0) - return VSConstants.S_FALSE; - } - else - { - // If the renamed file already exists then quit (unless it is the result of the parent having done the move). - if(IsFileOnDisk(newName) - && (IsFileOnDisk(this.Url) - || String.Compare(Path.GetFileName(newName), Path.GetFileName(this.Url), StringComparison.Ordinal) != 0)) - { - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.FileCannotBeRenamedToAnExistingFile, CultureInfo.CurrentUICulture), label)); - } - else if(newName.Length > NativeMethods.MAX_PATH) - { - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.PathTooLong, CultureInfo.CurrentUICulture), label)); - } - - } - - string oldName = this.Url; - // must update the caption prior to calling RenameDocument, since it may - // cause queries of that property (such as from open editors). - string oldrelPath = this.ItemNode.GetMetadata(ProjectFileConstants.Include); - - try - { - if(!RenameDocument(oldName, newName)) - { - this.ItemNode.Rename(oldrelPath); - this.ItemNode.RefreshProperties(); - } - - if(this is DependentFileNode) - { - OnInvalidateItems(this.Parent); - } - - } - catch(Exception e) - { - // Just re-throw the exception so we don't get duplicate message boxes. - Trace.WriteLine("Exception : " + e.Message); - this.RecoverFromRenameFailure(newName, oldrelPath); - returnValue = Marshal.GetHRForException(e); - throw; - } - // Return S_FALSE if the hierarchy item id has changed. This forces VS to flush the stale - // hierarchy item id. - if(returnValue == (int)VSConstants.S_OK || returnValue == (int)VSConstants.S_FALSE || returnValue == VSConstants.OLE_E_PROMPTSAVECANCELLED) - { - return (oldId == this.ID) ? VSConstants.S_OK : (int)VSConstants.S_FALSE; - } - - return returnValue; - } - - /// - /// Returns a specific Document manager to handle files - /// - /// Document manager object - protected internal override DocumentManager GetDocumentManager() - { - return new FileDocumentManager(this); - } - - /// - /// Called by the drag and drop implementation to ask the node - /// which is being dragged/droped over which nodes should - /// process the operation. - ///

This allows for dragging to a node that cannot contain - /// items to let its parent accept the drop, while a reference - /// node delegate to the project and a folder/project node to itself. - ///

- /// - protected internal override HierarchyNode GetDragTargetHandlerNode() - { - Debug.Assert(this.ProjectMgr != null, " The project manager is null for the filenode"); - HierarchyNode handlerNode = this; - while(handlerNode != null && !(handlerNode is ProjectNode || handlerNode is FolderNode)) - handlerNode = handlerNode.Parent; - if(handlerNode == null) - handlerNode = this.ProjectMgr; - return handlerNode; - } - - protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) - { - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - // Exec on special filenode commands - if(cmdGroup == VsMenus.guidStandardCommandSet97) - { - IVsWindowFrame windowFrame = null; - - switch((VsCommands)cmd) - { - case VsCommands.ViewCode: - return ((FileDocumentManager)this.GetDocumentManager()).Open(false, false, VSConstants.LOGVIEWID_Code, out windowFrame, WindowFrameShowAction.Show); - - case VsCommands.ViewForm: - return ((FileDocumentManager)this.GetDocumentManager()).Open(false, false, VSConstants.LOGVIEWID_Designer, out windowFrame, WindowFrameShowAction.Show); - - case VsCommands.Open: - return ((FileDocumentManager)this.GetDocumentManager()).Open(false, false, WindowFrameShowAction.Show); - - case VsCommands.OpenWith: - return ((FileDocumentManager)this.GetDocumentManager()).Open(false, true, VSConstants.LOGVIEWID_UserChooseView, out windowFrame, WindowFrameShowAction.Show); - } - } - - // Exec on special filenode commands - if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - switch((VsCommands2K)cmd) - { - case VsCommands2K.RUNCUSTOMTOOL: - { - try - { - this.RunGenerator(); - return VSConstants.S_OK; - } - catch(Exception e) - { - Trace.WriteLine("Running Custom Tool failed : " + e.Message); - throw; - } - } - } - } - - return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); - } - - protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result) - { - if (cmdGroup == VsMenus.guidStandardCommandSet97) - { - switch ((VsCommands)cmd) - { - case VsCommands.Copy: - case VsCommands.Paste: - case VsCommands.Cut: - case VsCommands.Rename: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - - case VsCommands.ViewCode: - //case VsCommands.Delete: goto case VsCommands.OpenWith; - case VsCommands.Open: - case VsCommands.OpenWith: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - - // !EFW - if(base.IsNonMemberItem && (VsCommands)cmd == VsCommands.ViewCode) - result |= QueryStatusResult.INVISIBLE; - return VSConstants.S_OK; - } - } - else if (cmdGroup == VsMenus.guidStandardCommandSet2K) - { - // !EFW - switch((VsCommands2K)cmd) - { - case VsCommands2K.EXCLUDEFROMPROJECT: - if(!base.IsNonMemberItem) - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - - case VsCommands2K.INCLUDEINPROJECT: - if(base.IsNonMemberItem) - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - - case VsCommands2K.RUNCUSTOMTOOL: - if(string.IsNullOrEmpty(this.ItemNode.GetMetadata( - ProjectFileConstants.DependentUpon)) && ( - this.NodeProperties is SingleFileGeneratorNodeProperties)) - { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - break; - } - } - else - { - return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; - } - return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); - } - - - protected override void DoDefaultAction() - { - CCITracing.TraceCall(); - FileDocumentManager manager = this.GetDocumentManager() as FileDocumentManager; - Debug.Assert(manager != null, "Could not get the FileDocumentManager"); - manager.Open(false, false, WindowFrameShowAction.Show); - } - - /// - /// Performs a SaveAs operation of an open document. Called from SaveItem after the running document table has been updated with the new doc data. - /// - /// A pointer to the document in the rdt - /// The new file path to the document - /// - protected override int AfterSaveItemAs(IntPtr docData, string newFilePath) - { - if(String.IsNullOrEmpty(newFilePath)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "newFilePath"); - } - - int returnCode = VSConstants.S_OK; - newFilePath = newFilePath.Trim(); - - //Identify if Path or FileName are the same for old and new file - string newDirectoryName = Path.GetDirectoryName(newFilePath); - Uri newDirectoryUri = new Uri(newDirectoryName); - string newCanonicalDirectoryName = newDirectoryUri.LocalPath; - newCanonicalDirectoryName = newCanonicalDirectoryName.TrimEnd(Path.DirectorySeparatorChar); - string oldCanonicalDirectoryName = new Uri(Path.GetDirectoryName(this.GetMkDocument())).LocalPath; - oldCanonicalDirectoryName = oldCanonicalDirectoryName.TrimEnd(Path.DirectorySeparatorChar); - string errorMessage = String.Empty; - bool isSamePath = NativeMethods.IsSamePath(newCanonicalDirectoryName, oldCanonicalDirectoryName); - bool isSameFile = NativeMethods.IsSamePath(newFilePath, this.Url); - - // Currently we do not support if the new directory is located outside the project cone - string projectCannonicalDirecoryName = new Uri(this.ProjectMgr.ProjectFolder).LocalPath; - projectCannonicalDirecoryName = projectCannonicalDirecoryName.TrimEnd(Path.DirectorySeparatorChar); - if(!isSamePath && newCanonicalDirectoryName.IndexOf(projectCannonicalDirecoryName, StringComparison.OrdinalIgnoreCase) == -1) - { - errorMessage = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.LinkedItemsAreNotSupported, CultureInfo.CurrentUICulture), Path.GetFileNameWithoutExtension(newFilePath)); - throw new InvalidOperationException(errorMessage); - } - - //Get target container - HierarchyNode targetContainer = null; - if(isSamePath) - { - targetContainer = this.Parent; - } - else if(NativeMethods.IsSamePath(newCanonicalDirectoryName, projectCannonicalDirecoryName)) - { - //the projectnode is the target container - targetContainer = this.ProjectMgr; - } - else - { - //search for the target container among existing child nodes - targetContainer = this.ProjectMgr.FindChild(newDirectoryName); - if(targetContainer != null && (targetContainer is FileNode)) - { - // We already have a file node with this name in the hierarchy. - errorMessage = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.FileAlreadyExistsAndCannotBeRenamed, CultureInfo.CurrentUICulture), Path.GetFileNameWithoutExtension(newFilePath)); - throw new InvalidOperationException(errorMessage); - } - } - - if(targetContainer == null) - { - // Add a chain of subdirectories to the project. - string relativeUri = PackageUtilities.GetPathDistance(this.ProjectMgr.BaseURI.Uri, newDirectoryUri); - Debug.Assert(!String.IsNullOrEmpty(relativeUri) && relativeUri != newDirectoryUri.LocalPath, "Could not make pat distance of " + this.ProjectMgr.BaseURI.Uri.LocalPath + " and " + newDirectoryUri); - targetContainer = this.ProjectMgr.CreateFolderNodes(relativeUri); - } - Debug.Assert(targetContainer != null, "We should have found a target node by now"); - - //Suspend file changes while we rename the document - string oldrelPath = this.ItemNode.GetMetadata(ProjectFileConstants.Include); - string oldName = Path.Combine(this.ProjectMgr.ProjectFolder, oldrelPath); - SuspendFileChanges sfc = new SuspendFileChanges(this.ProjectMgr.Site, oldName); - sfc.Suspend(); - - try - { - // Rename the node. - DocumentManager.UpdateCaption(this.ProjectMgr.Site, Path.GetFileName(newFilePath), docData); - // Check if the file name was actually changed. - // In same cases (e.g. if the item is a file and the user has changed its encoding) this function - // is called even if there is no real rename. - if(!isSameFile || (this.Parent.ID != targetContainer.ID)) - { - // The path of the file is changed or its parent is changed; in both cases we have - // to rename the item. - this.RenameFileNode(oldName, newFilePath, targetContainer.ID); - OnInvalidateItems(this.Parent); - } - } - catch(Exception e) - { - Trace.WriteLine("Exception : " + e.Message); - this.RecoverFromRenameFailure(newFilePath, oldrelPath); - throw; - } - finally - { - sfc.Resume(); - } - - return returnCode; - } - - /// - /// Determines if this is node a valid node for painting the default file icon. - /// - /// - protected override bool CanShowDefaultIcon() - { - string moniker = this.GetMkDocument(); - - if(String.IsNullOrEmpty(moniker) || !File.Exists(moniker)) - { - return false; - } - - return true; - } - #endregion - - #region virtual methods - public virtual string FileName - { - get - { - return this.Caption; - } - set - { - this.SetEditLabel(value); - } - } - - /// - /// Determine if this item is represented physical on disk and shows a messagebox in case that the file is not present and a UI is to be presented. - /// - /// true if user should be presented for UI in case the file is not present - /// true if file is on disk - internal protected virtual bool IsFileOnDisk(bool showMessage) - { - bool fileExist = IsFileOnDisk(this.Url); - - if(!fileExist && showMessage && !Utilities.IsInAutomationFunction(this.ProjectMgr.Site)) - { - string message = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.ItemDoesNotExistInProjectDirectory, CultureInfo.CurrentUICulture), this.Caption); - string title = string.Empty; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(this.ProjectMgr.Site, title, message, icon, buttons, defaultButton); - } - - return fileExist; - } - - /// - /// Determine if the file represented by "path" exist in storage. - /// Override this method if your files are not persisted on disk. - /// - /// Url representing the file - /// True if the file exist - internal protected virtual bool IsFileOnDisk(string path) - { - return File.Exists(path); - } - - /// - /// Renames the file in the hierarchy by removing old node and adding a new node in the hierarchy. - /// - /// The old file name. - /// The new file name - /// The new parent id of the item. - /// The newly added FileNode. - /// While a new node will be used to represent the item, the underlying MSBuild item will be the same and as a result file properties saved in the project file will not be lost. - protected virtual FileNode RenameFileNode(string oldFileName, string newFileName, uint newParentId) - { - if(string.Compare(oldFileName, newFileName, StringComparison.Ordinal) == 0) - { - // We do not want to rename the same file - return null; - } - - this.OnItemDeleted(); - this.Parent.RemoveChild(this); - - // Since this node has been removed all of its state is zombied at this point - // Do not call virtual methods after this point since the object is in a deleted state. - - string[] file = new string[1]; - file[0] = newFileName; - VSADDRESULT[] result = new VSADDRESULT[1]; - Guid emptyGuid = Guid.Empty; - ErrorHandler.ThrowOnFailure(this.ProjectMgr.AddItemWithSpecific(newParentId, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, 0, file, IntPtr.Zero, 0, ref emptyGuid, null, ref emptyGuid, result)); - FileNode childAdded = this.ProjectMgr.FindChild(newFileName) as FileNode; - Debug.Assert(childAdded != null, "Could not find the renamed item in the hierarchy"); - // Update the itemid to the newly added. - this.ID = childAdded.ID; - - // Remove the item created by the add item. We need to do this otherwise we will have two items. - // Please be aware that we have not removed the ItemNode associated to the removed file node from the hierrachy. - // What we want to achieve here is to reuse the existing build item. - // We want to link to the newly created node to the existing item node and addd the new include. - - //temporarily keep properties from new itemnode since we are going to overwrite it - string newInclude = childAdded.ItemNode.Item.EvaluatedInclude; - string dependentOf = childAdded.ItemNode.GetMetadata(ProjectFileConstants.DependentUpon); - childAdded.ItemNode.RemoveFromProjectFile(); - - // Assign existing msbuild item to the new childnode - childAdded.ItemNode = this.ItemNode; - childAdded.ItemNode.Item.ItemType = this.ItemNode.ItemName; - childAdded.ItemNode.Item.Xml.Include = newInclude; - if(!string.IsNullOrEmpty(dependentOf)) - childAdded.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, dependentOf); - childAdded.ItemNode.RefreshProperties(); - - //Update the new document in the RDT. - DocumentManager.RenameDocument(this.ProjectMgr.Site, oldFileName, newFileName, childAdded.ID); - - //Select the new node in the hierarchy - IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, SolutionExplorer); - // This happens in the context of renaming a file. - // Since we are already in solution explorer, it is extremely unlikely that we get a null return. - // If we do, the consequences are minimal: the parent node will be selected instead of the - // renamed node. - if (uiWindow != null) - { - ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this.ProjectMgr.InteropSafeIVsUIHierarchy, this.ID, EXPANDFLAGS.EXPF_SelectItem)); - } - - //Update FirstChild - childAdded.FirstChild = this.FirstChild; - - //Update ChildNodes - SetNewParentOnChildNodes(childAdded); - RenameChildNodes(childAdded); - - return childAdded; - } - - /// - /// Rename all childnodes - /// - /// The newly added Parent node. - protected virtual void RenameChildNodes(FileNode parentNode) - { - foreach(HierarchyNode child in GetChildNodes()) - { - FileNode childNode = child as FileNode; - if(null == childNode) - { - continue; - } - string newfilename; - if(childNode.HasParentNodeNameRelation) - { - string relationalName = childNode.Parent.GetRelationalName(); - string extension = childNode.GetRelationNameExtension(); - newfilename = relationalName + extension; - newfilename = Path.Combine(Path.GetDirectoryName(childNode.Parent.GetMkDocument()), newfilename); - } - else - { - newfilename = Path.Combine(Path.GetDirectoryName(childNode.Parent.GetMkDocument()), childNode.Caption); - } - - childNode.RenameDocument(childNode.GetMkDocument(), newfilename); - - //We must update the DependsUpon property since the rename operation will not do it if the childNode is not renamed - //which happens if the is no name relation between the parent and the child - string dependentOf = childNode.ItemNode.GetMetadata(ProjectFileConstants.DependentUpon); - if(!string.IsNullOrEmpty(dependentOf)) - { - childNode.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, childNode.Parent.ItemNode.GetMetadata(ProjectFileConstants.Include)); - } - } - } - - - /// - /// Tries recovering from a rename failure. - /// - /// The file that failed to be renamed. - /// The original filenamee - protected virtual void RecoverFromRenameFailure(string fileThatFailed, string originalFileName) - { - if(this.ItemNode != null && !String.IsNullOrEmpty(originalFileName)) - { - this.ItemNode.Rename(originalFileName); - } - } - - /// - /// This is overridden to prevent deletion of linked project items. - /// Linked items can still be removed/excluded. - /// - /// The delete operation to perform - /// True if the item can be deleted based on the requested - /// operation or false if it cannot. - protected override bool CanDeleteItem(__VSDELETEITEMOPERATION deleteOperation) - { - if(deleteOperation == __VSDELETEITEMOPERATION.DELITEMOP_DeleteFromStorage) - { - // !EFW - Cannot delete linked items - if(!String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.Link))) - return false; - - return this.ProjectMgr.CanProjectDeleteItems; - } - - // Remove is allowed for linked items - if(deleteOperation == __VSDELETEITEMOPERATION.DELITEMOP_RemoveFromProject) - return !String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.Link)); - - return false; - } - - /// - /// This should be overriden for nodes that are not saved on disk - /// - /// Previous name in storage - /// New name in storage - /// For linked files, the file is copied rather than being - /// moved and the link metadata is removed. If you do not want this - /// behavior, add file node properties to the link that suppresses - /// renaming via the FileName property. - protected virtual void RenameInStorage(string oldName, string newName) - { - // !EFW - if(String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.Link))) - File.Move(oldName, newName); - else - { - // If the filenames are the same, the parent folder got renamed - // so just adjust the link. - if(Path.GetFileName(oldName) != Path.GetFileName(newName)) - { - File.Copy(oldName, newName, true); - this.ItemNode.SetMetadata(ProjectFileConstants.Link, null); - } - else - { - newName = PackageUtilities.MakeRelativeIfRooted(newName, this.ProjectMgr.BaseURI); - this.ItemNode.SetMetadata(ProjectFileConstants.Link, newName); - } - } - } - - /// - /// factory method for creating single file generators. - /// - /// - protected virtual ISingleFileGenerator CreateSingleFileGenerator() - { - return new SingleFileGenerator(this.ProjectMgr); - } - - /// - /// This method should be overridden to provide the list of special files and associated flags for source control. - /// - /// One of the file associated to the node. - /// The list of files to be placed under source control. - /// The flags that are associated to the files. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "scc")] - protected internal override void GetSccSpecialFiles(string sccFile, IList files, IList flags) - { - if(this.ExcludeNodeFromScc) - { - return; - } - - if(files == null) - { - throw new ArgumentNullException("files"); - } - - if(flags == null) - { - throw new ArgumentNullException("flags"); - } - - foreach(HierarchyNode node in this.GetChildNodes()) - { - files.Add(node.GetMkDocument()); - } - } - - #endregion - - #region Helper methods - - /// - /// Get's called to rename the eventually running document this hierarchy item points to - /// - /// returns FALSE if the doc can not be renamed - internal bool RenameDocument(string oldName, string newName) - { - IVsRunningDocumentTable pRDT = this.GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable; - if (pRDT == null) return false; - IntPtr docData = IntPtr.Zero; - IVsHierarchy pIVsHierarchy; - uint itemId; - uint uiVsDocCookie; - - SuspendFileChanges sfc = new SuspendFileChanges(this.ProjectMgr.Site, oldName); - sfc.Suspend(); - - try - { - // Suspend ms build since during a rename operation no msbuild re-evaluation should be performed until we have finished. - // Scenario that could fail if we do not suspend. - // We have a project system relying on MPF that triggers a Compile target build (re-evaluates itself) whenever the project changes. (example: a file is added, property changed.) - // 1. User renames a file in the above project sytem relying on MPF - // 2. Our rename funstionality implemented in this method removes and readds the file and as a post step copies all msbuild entries from the removed file to the added file. - // 3. The project system mentioned will trigger an msbuild re-evaluate with the new item, because it was listening to OnItemAdded. - // The problem is that the item at the "add" time is only partly added to the project, since the msbuild part has not yet been copied over as mentioned in part 2 of the last step of the rename process. - // The result is that the project re-evaluates itself wrongly. - VSRENAMEFILEFLAGS renameflag = VSRENAMEFILEFLAGS.VSRENAMEFILEFLAGS_NoFlags; - try - { - this.ProjectMgr.SuspendMSBuild(); - ErrorHandler.ThrowOnFailure(pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, oldName, out pIVsHierarchy, out itemId, out docData, out uiVsDocCookie)); - - if(pIVsHierarchy != null && !Utilities.IsSameComObject(pIVsHierarchy, this.ProjectMgr.InteropSafeIVsHierarchy)) - { - // Don't rename it if it wasn't opened by us. - return false; - } - - // ask other potentially running packages - if(!this.ProjectMgr.Tracker.CanRenameItem(oldName, newName, renameflag)) - { - return false; - } - // Allow the user to "fix" the project by renaming the item in the hierarchy - // to the real name of the file on disk. - if(IsFileOnDisk(oldName) || !IsFileOnDisk(newName)) - { - RenameInStorage(oldName, newName); - } - - // !EFW - Ignore if it's a linked file - if(String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.Link))) - { - string newFileName = Path.GetFileName(newName); - DocumentManager.UpdateCaption(this.ProjectMgr.Site, newFileName, docData); - bool caseOnlyChange = NativeMethods.IsSamePath(oldName, newName); - if (!caseOnlyChange) - { - // Check out the project file if necessary. - if (!this.ProjectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - this.RenameFileNode(oldName, newName); - } - else - { - this.RenameCaseOnlyChange(newFileName); - } - } - } - finally - { - this.ProjectMgr.ResumeMSBuild(this.ProjectMgr.ReEvaluateProjectFileTargetName); - } - - this.ProjectMgr.Tracker.OnItemRenamed(oldName, newName, renameflag); - } - finally - { - sfc.Resume(); - if(docData != IntPtr.Zero) - { - Marshal.Release(docData); - } - } - - return true; - } - - private FileNode RenameFileNode(string oldFileName, string newFileName) - { - return this.RenameFileNode(oldFileName, newFileName, this.Parent.ID); - } - - /// - /// Renames the file node for a case only change. - /// - /// The new file name. - private void RenameCaseOnlyChange(string newFileName) - { - //Update the include for this item. - string include = this.ItemNode.Item.EvaluatedInclude; - if(String.Compare(include, newFileName, StringComparison.OrdinalIgnoreCase) == 0) - { - this.ItemNode.Item.Xml.Include = newFileName; - } - else - { - string includeDir = Path.GetDirectoryName(include); - this.ItemNode.Item.Xml.Include = Path.Combine(includeDir, newFileName); - } - - this.ItemNode.RefreshProperties(); - - this.ReDraw(UIHierarchyElement.Caption); - this.RenameChildNodes(this); - - // Refresh the property browser. - IVsUIShell shell = this.ProjectMgr.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; - Debug.Assert(shell != null, "Could not get the ui shell from the project"); - if(shell == null) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(shell.RefreshPropertyBrowser(0)); - - //Select the new node in the hierarchy - IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, SolutionExplorer); - // This happens in the context of renaming a file by case only (Table.sql -> table.sql) - // Since we are already in solution explorer, it is extremely unlikely that we get a null return. - if (uiWindow != null) - { - ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this.ProjectMgr.InteropSafeIVsUIHierarchy, this.ID, EXPANDFLAGS.EXPF_SelectItem)); - } - } - - #endregion - - #region SingleFileGenerator Support methods - /// - /// Event handler for the Custom tool property changes - /// - /// FileNode sending it - /// Node event args - internal virtual void OnCustomToolChanged(object sender, HierarchyNodeEventArgs e) - { - this.RunGenerator(); - } - - /// - /// Event handler for the Custom tool namespce property changes - /// - /// FileNode sending it - /// Node event args - internal virtual void OnCustomToolNameSpaceChanged(object sender, HierarchyNodeEventArgs e) - { - this.RunGenerator(); - } - - #endregion - - #region helpers - /// - /// Runs a generator. - /// - internal void RunGenerator() - { - ISingleFileGenerator generator = this.CreateSingleFileGenerator(); - if(generator != null) - { - generator.RunGenerator(this.Url); - } - } - - /// - /// Update the ChildNodes after the parent node has been renamed - /// - /// The new FileNode created as part of the rename of this node - private void SetNewParentOnChildNodes(FileNode newFileNode) - { - foreach(HierarchyNode childNode in GetChildNodes()) - { - childNode.Parent = newFileNode; - } - } - - private List GetChildNodes() - { - List childNodes = new List(); - HierarchyNode childNode = this.FirstChild; - while(childNode != null) - { - childNodes.Add(childNode); - childNode = childNode.NextSibling; - } - return childNodes; - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/FolderNode.cs b/SHFB/Source/MPFProj_VS2010/FolderNode.cs deleted file mode 100644 index e982e52f..00000000 --- a/SHFB/Source/MPFProj_VS2010/FolderNode.cs +++ /dev/null @@ -1,573 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//============================================================================= -// File : FileNode.cs -// Updated : 04/18/2011 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// This file has been modified to support "Show All Files" in the project. -// Search for "!EFW" to find the changes. Note that these changes have not -// been tested with dependent files so expect bugs. -// -// Date Who Comments -// ============================================================================ -// 06/20/2008 EFW Added support for "Show All Files" -// 03/20/2011 EFW Updated to use MPFProj for VS2010 -//============================================================================= - -// Core Show All Files functionality implemented in FolderNode.cs: -// - Updated GetIconHandle() to show excluded folder icon. -// - Updated MenuCommandId to return an appropriate context menu for non-member items. -// - Implemented IncludeInProjectRecursive() for non-member item file nodes. - -// Show All Files functionality not implemented in FolderNode.cs -// - Derived classes that override CreatePropertiesObject() should return a default -// instance of FileNodeProperties rather than their custom properties if the node -// is a non-member item. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; -using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; -using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; - -// !EFW -using VsPkgMenus = Microsoft.VisualStudio.Project.VsMenus; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false)] - [ComVisible(true)] - public class FolderNode : HierarchyNode - { - #region ctors - /// - /// Constructor for the FolderNode - /// - /// Root node of the hierarchy - /// relative path from root i.e.: "NewFolder1\\NewFolder2\\NewFolder3 - /// Associated project element - public FolderNode(ProjectNode root, string relativePath, ProjectElement element) - : base(root, element) - { - if(relativePath == null) - { - throw new ArgumentNullException("relativePath"); - } - - this.VirtualNodeName = relativePath.TrimEnd('\\'); - } - #endregion - - #region overridden properties - public override int SortPriority - { - get { return DefaultSortOrderNode.FolderNode; } - } - - /// - /// This relates to the SCC glyph - /// - public override VsStateIcon StateIconIndex - { - get - { - // The SCC manager does not support being asked for the state icon of a folder (result of the operation is undefined) - return VsStateIcon.STATEICON_NOSTATEICON; - } - } - #endregion - - #region overridden methods - protected override NodeProperties CreatePropertiesObject() - { - return new FolderNodeProperties(this); - } - - protected internal override void DeleteFromStorage(string path) - { - this.DeleteFolder(path); - } - - /// - /// Get the automation object for the FolderNode - /// - /// An instance of the Automation.OAFolderNode type if succeeded - public override object GetAutomationObject() - { - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return null; - } - - return new Automation.OAFolderItem(this.ProjectMgr.GetAutomationObject() as Automation.OAProject, this); - } - - public override object GetIconHandle(bool open) - { - // !EFW - if(base.IsNonMemberItem) - return this.ProjectMgr.ImageHandler.GetIconHandle(open ? - (int)ProjectNode.ImageName.OpenExcludedFolder : (int)ProjectNode.ImageName.ExcludedFolder); - - return this.ProjectMgr.ImageHandler.GetIconHandle(open ? (int)ProjectNode.ImageName.OpenFolder : (int)ProjectNode.ImageName.Folder); - } - - /// - /// Rename Folder - /// - /// new Name of Folder - /// VSConstants.S_OK, if succeeded - public override int SetEditLabel(string label) - { - if(String.Compare(Path.GetFileName(this.Url.TrimEnd('\\')), label, StringComparison.Ordinal) == 0) - { - // Label matches current Name - return VSConstants.S_OK; - } - - string newPath = Path.Combine(new DirectoryInfo(this.Url).Parent.FullName, label); - - // Verify that No Directory/file already exists with the new name among current children - for(HierarchyNode n = Parent.FirstChild; n != null; n = n.NextSibling) - { - if(n != this && String.Compare(n.Caption, label, StringComparison.OrdinalIgnoreCase) == 0) - { - return ShowFileOrFolderAlreadExistsErrorMessage(newPath); - } - } - - // Verify that No Directory/file already exists with the new name on disk - if(Directory.Exists(newPath) || File.Exists(newPath)) - { - return ShowFileOrFolderAlreadExistsErrorMessage(newPath); - } - - try - { - RenameFolder(label); - - //Refresh the properties in the properties window - IVsUIShell shell = this.ProjectMgr.GetService(typeof(SVsUIShell)) as IVsUIShell; - Debug.Assert(shell != null, "Could not get the ui shell from the project"); - ErrorHandler.ThrowOnFailure(shell.RefreshPropertyBrowser(0)); - - // Notify the listeners that the name of this folder is changed. This will - // also force a refresh of the SolutionExplorer's node. - this.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Caption, 0); - } - catch(Exception e) - { - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.RenameFolder, CultureInfo.CurrentUICulture), e.Message)); - } - return VSConstants.S_OK; - } - - /// - /// Get the menu command ID for the file item - /// - public override int MenuCommandId - { - get - { - // !EFW - if(base.IsNonMemberItem) - return VsPkgMenus.IDM_VS_CTXT_XPROJ_MULTIITEM; - - return VsMenus.IDM_VS_CTXT_FOLDERNODE; - } - } - - public override Guid ItemTypeGuid - { - get - { - return VSConstants.GUID_ItemType_PhysicalFolder; - } - } - - public override string Url - { - get - { - return Path.Combine(Path.GetDirectoryName(this.ProjectMgr.Url), this.VirtualNodeName) + "\\"; - } - } - - public override string Caption - { - get - { - // it might have a backslash at the end... - // and it might consist of Grandparent\parent\this\ - string caption = this.VirtualNodeName; - string[] parts; - parts = caption.Split(Path.DirectorySeparatorChar); - caption = parts[parts.GetUpperBound(0)]; - return caption; - } - } - - public override string GetMkDocument() - { - Debug.Assert(this.Url != null, "No url sepcified for this node"); - - return this.Url; - } - - /// - /// Enumerate the files associated with this node. - /// A folder node is not a file and as such no file to enumerate. - /// - /// The list of files to be placed under source control. - /// The flags that are associated to the files. - protected internal override void GetSccFiles(System.Collections.Generic.IList files, System.Collections.Generic.IList flags) - { - return; - } - - /// - /// This method should be overridden to provide the list of special files and associated flags for source control. - /// - /// One of the file associated to the node. - /// The list of files to be placed under source control. - /// The flags that are associated to the files. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "scc")] - protected internal override void GetSccSpecialFiles(string sccFile, IList files, IList flags) - { - if(this.ExcludeNodeFromScc) - { - return; - } - - if(files == null) - { - throw new ArgumentNullException("files"); - } - - if(flags == null) - { - throw new ArgumentNullException("flags"); - } - - if(string.IsNullOrEmpty(sccFile)) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "sccFile"); - } - - // Get the file node for the file passed in. - FileNode node = this.FindChild(sccFile) as FileNode; - - // Dependents do not participate directly in scc. - if(node != null && !(node is DependentFileNode)) - { - node.GetSccSpecialFiles(sccFile, files, flags); - } - } - - /// - /// Recursevily walks the folder nodes and redraws the state icons - /// - protected internal override void UpdateSccStateIcons() - { - for(HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) - { - child.UpdateSccStateIcons(); - } - } - - protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result) - { - if(cmdGroup == VsMenus.guidStandardCommandSet97) - { - switch((VsCommands)cmd) - { - case VsCommands.Copy: - case VsCommands.Paste: - case VsCommands.Cut: - case VsCommands.Rename: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - - case VsCommands.NewFolder: - case VsCommands.AddNewItem: - case VsCommands.AddExistingItem: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } - else if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - // !EFW - switch((VsCommands2K)cmd) - { - case VsCommands2K.EXCLUDEFROMPROJECT: - if(!base.IsNonMemberItem) - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - - case VsCommands2K.INCLUDEINPROJECT: - if(base.IsNonMemberItem) - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } - else - { - return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; - } - return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); - } - - protected override bool CanDeleteItem(__VSDELETEITEMOPERATION deleteOperation) - { - if(deleteOperation == __VSDELETEITEMOPERATION.DELITEMOP_DeleteFromStorage) - { - return this.ProjectMgr.CanProjectDeleteItems; - } - return false; - } - - // !EFW - /// - /// This method converts a non-member folder node into a member node including - /// all of its child nodes. - /// - /// Returns S_OK on success or an error code on failure - protected internal int IncludeInProjectRecursive() - { - int result = this.IncludeInProject(); - - if(result == VSConstants.S_OK) - for(HierarchyNode node = this.FirstChild; node != null; node = node.NextSibling) - { - FolderNode fn = node as FolderNode; - - if(fn != null) - result = fn.IncludeInProjectRecursive(); - else - result = node.IncludeInProject(); - - if(result != VSConstants.S_OK) - break; - } - - return result; - } - #endregion - - #region virtual methods - /// - /// Override if your node is not a file system folder so that - /// it does nothing or it deletes it from your storage location. - /// - /// Path to the folder to delete - public virtual void DeleteFolder(string path) - { - if(Directory.Exists(path)) - Directory.Delete(path, true); - } - - /// - /// creates the physical directory for a folder node - /// Override if your node does not use file system folder - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "e")] - public virtual void CreateDirectory() - { - try - { - if(Directory.Exists(this.Url) == false) - { - Directory.CreateDirectory(this.Url); - } - } - //TODO - this should not digest all exceptions. - catch(System.Exception e) - { - CCITracing.Trace(e); - throw; - } - } - /// - /// Creates a folder nodes physical directory - /// Override if your node does not use file system folder - /// - /// - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "e")] - public virtual void CreateDirectory(string newName) - { - if(String.IsNullOrEmpty(newName)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "newName"); - } - - try - { - // on a new dir && enter, we get called with the same name (so do nothing if name is the same - char[] dummy = new char[1]; - dummy[0] = Path.DirectorySeparatorChar; - string oldDir = this.Url; - oldDir = oldDir.TrimEnd(dummy); - string strNewDir = Path.Combine(Path.GetDirectoryName(oldDir), newName); - - if(String.Compare(strNewDir, oldDir, StringComparison.OrdinalIgnoreCase) != 0) - { - if(Directory.Exists(strNewDir)) - { - throw new InvalidOperationException(SR.GetString(SR.DirectoryExistError, CultureInfo.CurrentUICulture)); - } - Directory.CreateDirectory(strNewDir); - } - } - //TODO - this should not digest all exceptions. - catch(System.Exception e) - { - CCITracing.Trace(e); - throw; - } - } - - /// - /// Rename the physical directory for a folder node - /// Override if your node does not use file system folder - /// - /// - public virtual void RenameDirectory(string newPath) - { - if(Directory.Exists(this.Url)) - { - if(Directory.Exists(newPath)) - { - ShowFileOrFolderAlreadExistsErrorMessage(newPath); - } - - Directory.Move(this.Url, newPath); - } - } - #endregion - - #region helper methods - private void RenameFolder(string newName) - { - // Do the rename (note that we only do the physical rename if the leaf name changed) - string newPath = Path.Combine(this.Parent.VirtualNodeName, newName); - if(String.Compare(Path.GetFileName(VirtualNodeName), newName, StringComparison.Ordinal) != 0) - { - this.RenameDirectory(Path.Combine(this.ProjectMgr.ProjectFolder, newPath)); - } - this.VirtualNodeName = newPath; - - this.ItemNode.Rename(VirtualNodeName); - - // Let all children know of the new path - for(HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) - { - FolderNode node = child as FolderNode; - - if(node == null) - { - child.SetEditLabel(child.Caption); - } - else - { - node.RenameFolder(node.Caption); - } - } - - // Some of the previous operation may have changed the selection so set it back to us - IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, SolutionExplorer); - // This happens in the context of renaming a folder. - // Since we are already in solution explorer, it is extremely unlikely that we get a null return. - // If we do, the consequences are minimal: the parent node will be selected instead of the - // renamed node. - if (uiWindow != null) - { - ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this.ProjectMgr.InteropSafeIVsUIHierarchy, this.ID, EXPANDFLAGS.EXPF_SelectItem)); - } - } - - /// - /// Show error message if not in automation mode, otherwise throw exception - /// - /// path of file or folder already existing on disk - /// S_OK - private int ShowFileOrFolderAlreadExistsErrorMessage(string newPath) - { - //A file or folder with the name '{0}' already exists on disk at this location. Please choose another name. - //If this file or folder does not appear in the Solution Explorer, then it is not currently part of your project. To view files which exist on disk, but are not in the project, select Show All Files from the Project menu. - string errorMessage = (String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.FileOrFolderAlreadyExists, CultureInfo.CurrentUICulture), newPath)); - if(!Utilities.IsInAutomationFunction(this.ProjectMgr.Site)) - { - string title = null; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(this.ProjectMgr.Site, title, errorMessage, icon, buttons, defaultButton); - return VSConstants.S_OK; - } - else - { - throw new InvalidOperationException(errorMessage); - } - } - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/GlobalSuppressions.cs b/SHFB/Source/MPFProj_VS2010/GlobalSuppressions.cs deleted file mode 100644 index cb9975bd..00000000 --- a/SHFB/Source/MPFProj_VS2010/GlobalSuppressions.cs +++ /dev/null @@ -1,656 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System.Diagnostics.CodeAnalysis; - -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. Project-level -// suppressions either have no target or are given a specific target -// and scoped to a namespace, type, member, etc. -// -// To add a suppression to this file, right-click the message in the -// Error List, point to "Suppress Message(s)", and click "In Project -// Suppression File". You do not need to add suppressions to this -// file manually. - -// The below contains suppressions from LinkDemand occurring from calls to the Marshal type's methods. -// Calls to these methods are absolute necessary to do successful VS integration. -// All these methods are called from the VS Kernel, through interface calls that are expanded in the below methods. -// Some of the below methods are non public but their caller's then are methods that are VS Integration interface implementations. -// The methods in which the LinkDemands were suppressed should be revisited though if adding further LinkDemands or directly Demanding UnmanagedCode Permission is a better choice. - -//Interface parameters naming matching suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#AdviseHierarchyEvents(Microsoft.VisualStudio.Shell.Interop.IVsHierarchyEvents,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#AdviseHierarchyEvents(Microsoft.VisualStudio.Shell.Interop.IVsHierarchyEvents,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#AdviseBuildStatusCallback(Microsoft.VisualStudio.Shell.Interop.IVsBuildStatusCallback,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStartBuild(System.UInt32,System.Int32[],System.Int32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStartBuild(System.UInt32,System.Int32[],System.Int32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStartClean(System.UInt32,System.Int32[],System.Int32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStartUpToDateCheck(System.UInt32,System.Int32[],System.Int32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStartClean(System.UInt32,System.Int32[],System.Int32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStartUpToDateCheck(System.UInt32,System.Int32[],System.Int32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStartUpToDateCheck(System.UInt32,System.Int32[],System.Int32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStatus(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#StartBuild(Microsoft.VisualStudio.Shell.Interop.IVsOutputWindowPane,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#StartBuild(Microsoft.VisualStudio.Shell.Interop.IVsOutputWindowPane,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#StartClean(Microsoft.VisualStudio.Shell.Interop.IVsOutputWindowPane,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#UnadviseBuildStatusCallback(System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#Stop(System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#StartUpToDateCheck(Microsoft.VisualStudio.Shell.Interop.IVsOutputWindowPane,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#StartUpToDateCheck(Microsoft.VisualStudio.Shell.Interop.IVsOutputWindowPane,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#StartClean(Microsoft.VisualStudio.Shell.Interop.IVsOutputWindowPane,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildDependency.#get_HelpContext(System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildDependency.#get_Description(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildDependency.#get_CanonicalName(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#Wait(System.UInt32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildDependency.#get_MustUpdateBefore(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildDependency.#get_HelpFile(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterLoadProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterOpeningChildren(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterLoadProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterClosingChildren(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterOpenProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterOpenProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterRenameProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnBeforeCloseProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnBeforeCloseProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnBeforeClosingChildren(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnBeforeOpeningChildren(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnBeforeUnloadProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnBeforeUnloadProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnQueryChangeProjectParent(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnQueryChangeProjectParent(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnQueryChangeProjectParent(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnQueryCloseProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnQueryCloseProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnQueryCloseProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnQueryCloseSolution(System.Object,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnQueryUnloadProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListenerForProjectOpen.#OnAfterOpenSolution(System.Object,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListenerForProjectOpen.#OnAfterOpenSolution(System.Object,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#OnActiveProjectCfgChange(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#OnAfterActiveSolutionCfgChange(Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#OnAfterActiveSolutionCfgChange(Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#OnBeforeActiveSolutionCfgChange(Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#OnBeforeActiveSolutionCfgChange(Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Begin(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Begin(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Begin(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Begin(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Begin(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Done(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Done(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Done(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Done(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Done(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateProjectCfg_Done(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsCfg,System.UInt32,System.Int32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateSolution_Begin(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.UpdateSolutionEventsListener.#UpdateSolution_StartUpdate(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#DeleteItem(System.UInt32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#DeleteItem(System.UInt32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#Exec(System.Guid&,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#Exec(System.Guid&,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#Exec(System.Guid&,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ExecCommand(System.UInt32,System.Guid&,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ExecCommand(System.UInt32,System.Guid&,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ExecCommand(System.UInt32,System.Guid&,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ExecCommand(System.UInt32,System.Guid&,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ExecCommand(System.UInt32,System.Guid&,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ExecCommand(System.UInt32,System.Guid&,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetCanonicalName(System.UInt32,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetCanonicalName(System.UInt32,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetGuidProperty(System.UInt32,System.Int32,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetGuidProperty(System.UInt32,System.Int32,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetNestedHierarchy(System.UInt32,System.Guid&,System.IntPtr&,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetNestedHierarchy(System.UInt32,System.Guid&,System.IntPtr&,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetProperty(System.UInt32,System.Int32,System.Object&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetProperty(System.UInt32,System.Int32,System.Object&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetProperty(System.UInt32,System.Int32,System.Object&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#IgnoreItemFileChanges(System.UInt32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#IgnoreItemFileChanges(System.UInt32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#IsItemDirty(System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#IsItemDirty(System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#IsItemDirty(System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#IsItemReloadable(System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#IsItemReloadable(System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#OnBeforeDropNotify(Microsoft.VisualStudio.OLE.Interop.IDataObject,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ParseCanonicalName(System.String,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ParseCanonicalName(System.String,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryClose(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryDeleteItem(System.UInt32,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryDeleteItem(System.UInt32,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryDeleteItem(System.UInt32,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryStatus(System.Guid&,System.UInt32,Microsoft.VisualStudio.OLE.Interop.OLECMD[],System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryStatusCommand(System.UInt32,System.Guid&,System.UInt32,Microsoft.VisualStudio.OLE.Interop.OLECMD[],System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryStatusCommand(System.UInt32,System.Guid&,System.UInt32,Microsoft.VisualStudio.OLE.Interop.OLECMD[],System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryStatusCommand(System.UInt32,System.Guid&,System.UInt32,Microsoft.VisualStudio.OLE.Interop.OLECMD[],System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ReloadItem(System.UInt32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ReloadItem(System.UInt32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SetGuidProperty(System.UInt32,System.Int32,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SetGuidProperty(System.UInt32,System.Int32,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SetProperty(System.UInt32,System.Int32,System.Object)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SetProperty(System.UInt32,System.Int32,System.Object)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#UnadviseHierarchyEvents(System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems.#AddFolder(System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems.#AddFolder(System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems.#AddFromDirectory(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems.#AddFromFile(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems.#AddFromFileCopy(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems.#AddFromTemplate(System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems.#AddFromTemplate(System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAProjectItem`1.#Save(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAProjectItem`1.#SaveAs(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#EnumOutputs(Microsoft.VisualStudio.Shell.Interop.IVsEnumOutputs&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_BuildableProjectCfg(Microsoft.VisualStudio.Shell.Interop.IVsBuildableProjectCfg&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_CanonicalName(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_DisplayName(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_IsDebugOnly(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_IsPackaged(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_IsReleaseOnly(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_IsSpecifyingOutputSupported(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_Platform(System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_ProjectCfgProvider(Microsoft.VisualStudio.Shell.Interop.IVsProjectCfgProvider&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_RootURL(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_TargetCodePage(System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#get_UpdateSequenceNumber(Microsoft.VisualStudio.OLE.Interop.ULARGE_INTEGER[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#GetCfg(Microsoft.VisualStudio.Shell.Interop.IVsCfg&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#GetPages(Microsoft.VisualStudio.OLE.Interop.CAUUID[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#GetProjectDesignerPages(Microsoft.VisualStudio.OLE.Interop.CAUUID[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#GetProjectItem(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy&,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#GetProjectItem(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy&,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#OpenOutput(System.String,Microsoft.VisualStudio.Shell.Interop.IVsOutput&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#OpenOutput(System.String,Microsoft.VisualStudio.Shell.Interop.IVsOutput&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#QueryDebugLaunch(System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#QueryDebugLaunch(System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterAsynchOpenProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterAsynchOpenProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterChangeProjectParent(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListener.#OnAfterCloseSolution(System.Object)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#AdviseBuildStatusCallback(Microsoft.VisualStudio.Shell.Interop.IVsBuildStatusCallback,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildDependency.#get_ReferredProject(System.Object&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStartClean(System.UInt32,System.Int32[],System.Int32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#QueryStartBuild(System.UInt32,System.Int32[],System.Int32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#get_ProjectCfg(Microsoft.VisualStudio.Shell.Interop.IVsProjectCfg&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildDependency.#get_Type(System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1701:ResourceStringCompoundWordsShouldBeCasedCorrectly", MessageId = "dataset", Scope = "resource", Target = "Microsoft.VisualStudio.Project.resources")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "Intelli", Scope = "resource", Target = "Microsoft.VisualStudio.Project.SecurityWarningDialog.resources")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.FileNode.#AfterSaveItemAs(System.IntPtr,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#IsItemDirty(System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#OnChanged(System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#OnRequestEdit(System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NodeProperties.#GetCfgProvider(Microsoft.VisualStudio.Shell.Interop.IVsCfgProvider&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NodeProperties.#GetPages(Microsoft.VisualStudio.OLE.Interop.CAUUID[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NodeProperties.#GetProjectDesignerPages(Microsoft.VisualStudio.OLE.Interop.CAUUID[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NodeProperties.#GetProjectItem(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy&,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NodeProperties.#GetProjectItem(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy&,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OnBeforeDropNotify(Microsoft.VisualStudio.OLE.Interop.IDataObject,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OnClear(System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OnPaste(System.Int32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OnPaste(System.Int32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#RegisterClipboardNotifications(System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#GetPageInfo(Microsoft.VisualStudio.OLE.Interop.PROPPAGEINFO[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#Help(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#Move(Microsoft.VisualStudio.OLE.Interop.RECT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#SetObjects(System.UInt32,System.Object[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#SetObjects(System.UInt32,System.Object[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#SetPageSite(Microsoft.VisualStudio.OLE.Interop.IPropertyPageSite)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#Show(System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#TranslateAccelerator(Microsoft.VisualStudio.OLE.Interop.MSG[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#CreateGeneratorInstance(System.String,System.Int32&,System.Int32&,System.Int32&,Microsoft.VisualStudio.Shell.Interop.IVsSingleFileGenerator&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#CreateGeneratorInstance(System.String,System.Int32&,System.Int32&,System.Int32&,Microsoft.VisualStudio.Shell.Interop.IVsSingleFileGenerator&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#CreateGeneratorInstance(System.String,System.Int32&,System.Int32&,System.Int32&,Microsoft.VisualStudio.Shell.Interop.IVsSingleFileGenerator&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#CreateGeneratorInstance(System.String,System.Int32&,System.Int32&,System.Int32&,Microsoft.VisualStudio.Shell.Interop.IVsSingleFileGenerator&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#CreateGeneratorInstance(System.String,System.Int32&,System.Int32&,System.Int32&,Microsoft.VisualStudio.Shell.Interop.IVsSingleFileGenerator&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#GetDefaultGenerator(System.String,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#GetDefaultGenerator(System.String,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#GetGeneratorInformation(System.String,System.Int32&,System.Int32&,System.Int32&,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#GetGeneratorInformation(System.String,System.Int32&,System.Int32&,System.Int32&,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#GetGeneratorInformation(System.String,System.Int32&,System.Int32&,System.Int32&,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#GetGeneratorInformation(System.String,System.Int32&,System.Int32&,System.Int32&,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorFactory.#GetGeneratorInformation(System.String,System.Int32&,System.Int32&,System.Int32&,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#IsItemDirty(System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#Activate(System.IntPtr,Microsoft.VisualStudio.OLE.Interop.RECT[],System.Int32)")] - -//Ref arguments suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.TokenProcessor.#ReplaceBetweenTokens(System.String&,Microsoft.VisualStudio.Project.ReplaceBetweenPairToken)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.TokenProcessor.#ReplaceTokens(System.String&,Microsoft.VisualStudio.Project.ReplacePairToken)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryStatusOnNode(System.Guid,System.UInt32,System.IntPtr,Microsoft.VisualStudio.Project.QueryStatusResult&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#OpenWithSpecific(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.FileDocumentManager.#Open(System.Boolean,System.Boolean,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#OpenWithSpecific(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.TokenProcessor.#DeleteTokens(System.String&,Microsoft.VisualStudio.Project.DeleteToken)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#Open(System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#CloseWindowFrame(Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Load(System.String,System.String,System.String,System.UInt32,System.Guid&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#SetGuidProperty(System.Int32,System.Guid&)")] - -//Out arguments suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#Open(System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.FileDocumentManager.#Open(System.Boolean,System.Boolean,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#DisableCommandOnNodesThatDoNotSupportMultiSelection(System.Guid,System.UInt32,System.Collections.Generic.IList`1,System.Boolean&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "6#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ExecCommandIndependentOfSelection(System.Guid,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr,Microsoft.VisualStudio.Project.CommandOrigin,System.Boolean&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "7#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ExecCommandThatDependsOnSelectedNodes(System.Guid,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr,Microsoft.VisualStudio.Project.CommandOrigin,System.Collections.Generic.IList`1,System.Boolean&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#QueryStatusCommandFromOleCommandTarget(System.Guid,System.UInt32,System.Boolean&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetGuidProperty(System.Int32,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#OpenWithSpecific(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.FileDocumentManager.#Open(System.Boolean,System.Boolean,System.Guid,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ReferenceNode.#CanAddReference(Microsoft.VisualStudio.Project.ReferenceNode+CannotAddReferenceErrorMessage&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Load(System.String,System.String,System.String,System.UInt32,System.Guid&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "7#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#ExecCommandThatDependsOnSelectedNodes(System.Guid,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr,Microsoft.VisualStudio.Project.CommandOrigin,System.Collections.Generic.IList`1,System.Boolean&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#DisableCommandOnNodesThatDoNotSupportMultiSelection(System.Guid,System.UInt32,System.Collections.Generic.IList`1,System.Boolean&)")] - -//Default constructors for COM suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.AssemblyReferenceNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ComReferenceNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ConfigProvider")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ConnectionPointContainer")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.DependentFileNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.DependentFileNodeProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.FileNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.FileNodeProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.FolderNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.FolderNodeProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.HierarchyNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.NestedProjectNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.NodeProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAAssemblyReference")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAComReference")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAFileItem")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAFolderItem")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OANestedProjectItem")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OANullProperty")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAProject")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAProjectItems")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAProjectReference")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAProperty")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceFolderItem")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceItem")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAReferences")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAVSProject")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAVSProjectEvents")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.OutputGroup")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ProjectConfig")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ProjectConfigProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ProjectNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ProjectNodeProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ProjectPackage")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ProjectReferenceNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ProjectReferencesProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ReferenceContainerNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ReferenceNode")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.ReferenceNodeProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.SettingsPage")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.SingleFileGeneratorNodeProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1409:ComVisibleTypesShouldBeCreatable", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAVSProjectItem")] - -//PInvoke suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1414:MarkBooleanPInvokeArgumentsWithMarshalAs", Scope = "member", Target = "Microsoft.VisualStudio.Project.NativeMethods.#DestroyIcon(System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1414:MarkBooleanPInvokeArgumentsWithMarshalAs", Scope = "member", Target = "Microsoft.VisualStudio.Project.NativeMethods.#GetBinaryType(System.String,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1414:MarkBooleanPInvokeArgumentsWithMarshalAs", Scope = "member", Target = "Microsoft.VisualStudio.Project.UnsafeNativeMethods.#GlobalUnlock(System.Runtime.InteropServices.HandleRef)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1414:MarkBooleanPInvokeArgumentsWithMarshalAs", Scope = "member", Target = "Microsoft.VisualStudio.Project.UnsafeNativeMethods.#GlobalUnLock(System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1414:MarkBooleanPInvokeArgumentsWithMarshalAs", Scope = "member", Target = "Microsoft.VisualStudio.Project.UnsafeNativeMethods.#ImageList_Draw(System.Runtime.InteropServices.HandleRef,System.Int32,System.Runtime.InteropServices.HandleRef,System.Int32,System.Int32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1414:MarkBooleanPInvokeArgumentsWithMarshalAs", Scope = "member", Target = "Microsoft.VisualStudio.Project.UnsafeNativeMethods.#SHGetPathFromIDList(System.IntPtr,System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1414:MarkBooleanPInvokeArgumentsWithMarshalAs", Scope = "member", Target = "Microsoft.VisualStudio.Project.NativeMethods.#IsDialogMessageA(System.IntPtr,Microsoft.VisualStudio.OLE.Interop.MSG&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable", MessageId = "return", Scope = "member", Target = "Microsoft.VisualStudio.Project.UnsafeNativeMethods.#RegisterClipboardFormat(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable", MessageId = "return", Scope = "member", Target = "Microsoft.VisualStudio.Project.UnsafeNativeMethods.#GlobalSize(System.IntPtr)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable", MessageId = "return", Scope = "member", Target = "Microsoft.VisualStudio.Project.UnsafeNativeMethods.#GlobalSize(System.Runtime.InteropServices.HandleRef)")] - -//'Flags' naming suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "type", Target = "Microsoft.VisualStudio.Project.ModuleKindFlags")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#VirtualProjectFlags")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetQueryRemoveFileFlags(System.String[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetQueryAddFileFlags(System.String[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetAddFileFlags(System.String[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.Utilities.#CreateCADWORD(System.Collections.Generic.IList`1)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Load(System.String,System.String,System.String,System.UInt32,System.Guid&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#AddNestedProjectFromTemplate(System.String,System.String,System.String,Microsoft.VisualStudio.Project.ProjectElement,Microsoft.VisualStudio.Shell.Interop.__VSCREATEPROJFLAGS)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#AddNestedProjectFromTemplate(Microsoft.VisualStudio.Project.ProjectElement,Microsoft.VisualStudio.Shell.Interop.__VSCREATEPROJFLAGS)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#AddExistingNestedProject(Microsoft.VisualStudio.Project.ProjectElement,Microsoft.VisualStudio.Shell.Interop.__VSCREATEPROJFLAGS)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#Init(System.String,System.String,System.String,Microsoft.VisualStudio.Shell.Interop.__VSCREATEPROJFLAGS)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#OnPropertyChanged(Microsoft.VisualStudio.Project.HierarchyNode,System.Int32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flag", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#IgnoreItemFileChanges(System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetSccSpecialFiles(System.String,System.Collections.Generic.IList`1,System.Collections.Generic.IList`1)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetSccFiles(System.Collections.Generic.IList`1,System.Collections.Generic.IList`1)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#OpenWithSpecific(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flag", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#Close(Microsoft.VisualStudio.Shell.Interop.__FRAMECLOSE)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetRemoveFileFlags(System.String[])")] - -//Properties instead of methods suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#GetFullPathForDocument()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.DocumentManager.#GetOwnerCaption()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetAutomationObject()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetDocumentManager()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetDragTargetHandlerNode()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetEditLabel()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetMkDocument()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetRelationalName()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetRelationNameExtension()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.IReferenceContainerProvider.#GetReferenceContainer()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems.#GetListOfProjectItems()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectElement.#GetFullPathForElement()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetCompiler()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetInner()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetOutputGroupNames()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectOptions.#GetOptionHelp()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetSelectedNodes()")] - -//Generic nesting suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.BuildableProjectConfig.#Build(System.UInt32,Microsoft.VisualStudio.Shell.Interop.IVsOutputWindowPane,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetOutputGroupNames()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#NewConfigProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Scope = "member", Target = "Microsoft.VisualStudio.Project.Utilities.#ConvertFromType`1(System.String,System.Globalization.CultureInfo)")] - -//Methods that swallows exceptions suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.CodeBehindCodeGenerator.#GetDesignerItem(Microsoft.VisualStudio.Project.Web.VsHierarchyItem,System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.CodeBehindCodeGenerator.#FindClass(Microsoft.VisualStudio.Project.Web.VsHierarchyItem,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.CodeBehindCodeGenerator.#DisposeGenerateState()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.CodeBehindCodeGenerator.#GetFieldNames(EnvDTE.CodeClass,System.Boolean,System.Boolean,System.Int32,System.Int32,Microsoft.VisualStudio.Project.Web.FieldDataDictionary&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.CodeBehindCodeGenerator.#GetFieldNames(System.String[],System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#Close()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.NativeMethods+ConnectionPointCookie.#.ctor(System.Object,System.Object,System.Type,System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.NativeMethods+DataStreamFromComStream.#Flush()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.VsHierarchyItem.#FullPath()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.VsHierarchyItem.#GetGuidPropHelper(Microsoft.VisualStudio.Shell.Interop.__VSHPROPID)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.VsHierarchyItem.#GetPropHelper(System.UInt32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.VsHierarchyItem.#GetService`1()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.WAUtilities.#CreateInstance`1(System.IServiceProvider,System.Guid)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.Web.WAUtilities.#GetService`1(System.IServiceProvider)")] - -//Local variables names matching instance variable names suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "dropDataType", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#PasteFromClipboard(Microsoft.VisualStudio.Project.HierarchyNode)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "dropDataType", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Drop(Microsoft.VisualStudio.OLE.Interop.IDataObject,System.UInt32,System.UInt32,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "dropDataType", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#ProcessSelectionDataObject(Microsoft.VisualStudio.OLE.Interop.IDataObject,Microsoft.VisualStudio.Project.HierarchyNode)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "filename", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#InitializeForOuter(System.String,System.String,System.String,System.UInt32,System.Guid&,System.IntPtr&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "filename", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SaveCompleted(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "isDirty", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#IsDirty(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "isDirty", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#CleanupSelectionDataObject(System.Boolean,System.Boolean,System.Boolean,System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "isDirty", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#IsFlavorDirty()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "isDirty", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OnBeforeDropNotify(Microsoft.VisualStudio.OLE.Interop.IDataObject,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "name", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#GetTypedConfigProperty(System.String,System.Type)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "name", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#GetTypedProperty(System.String,System.Type)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "name", Scope = "member", Target = "Microsoft.VisualStudio.Project.SettingsPage.#SetConfigProperty(System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "options", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetTargetPlatform(Microsoft.VisualStudio.Project.ProjectOptions)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "options", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetOutputAssembly(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "options", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetProjectOptions(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "options", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#PrepareBuild(System.String,System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "options", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetBuildConfigurationProperties(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "project", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#CreateOutputGroup(Microsoft.VisualStudio.Project.ProjectNode,System.Collections.Generic.KeyValuePair`2)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "projectName", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectNode.#Init(System.String,System.String,System.String,Microsoft.VisualStudio.Shell.Interop.__VSCREATEPROJFLAGS)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "sccAuxPath", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccLocation(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "sccAuxPath", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccSettings(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "sccLocalPath", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccLocation(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "sccLocalPath", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccSettings(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "sccProjectName", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccLocation(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "sccProjectName", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccSettings(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "sccProvider", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccLocation(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "sccProvider", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccSettings(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "site", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "dropDataType", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#QueryDropEffect(Microsoft.VisualStudio.Project.DropDataType,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "i", Scope = "member", Target = "Microsoft.VisualStudio.Project.EnumSTATDATA.#Microsoft.VisualStudio.OLE.Interop.IEnumSTATDATA.Skip(System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "i", Scope = "member", Target = "Microsoft.VisualStudio.Project.EnumSTATDATA.#Microsoft.VisualStudio.OLE.Interop.IEnumSTATDATA.Next(System.UInt32,Microsoft.VisualStudio.OLE.Interop.STATDATA[],System.UInt32&)")] - -//COM Exceptions suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceBase`1.#ExtenderCATID")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceBase`1.#Culture")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceBase`1.#ExtenderNames")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceBase`1.#Identity")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceBase`1.#Name")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceBase`1.#PublicKeyToken")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceBase`1.#Type")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OASolutionFolder`1.#Parent")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAProjectItem`1.#Collection")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAProjectItem`1.#IsDirty")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceBase`1.#CopyLocal")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.DataObject.#Microsoft.VisualStudio.OLE.Interop.IDataObject.GetCanonicalFormatEtc(Microsoft.VisualStudio.OLE.Interop.FORMATETC[],Microsoft.VisualStudio.OLE.Interop.FORMATETC[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#.ctor(Microsoft.VisualStudio.Project.ProjectNode,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#RunVsTemplateWizard(Microsoft.VisualStudio.Project.ProjectElement,System.Boolean)")] - -//IEnumerable implementation suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAReferences")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAProperties")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OANavigableProjectItems")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface", Scope = "type", Target = "Microsoft.VisualStudio.Project.Automation.OAProjectItems")] - -//Other suppressions -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Scope = "type", Target = "Microsoft.VisualStudio.Project.ProjectNode+ImageName")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "trailer", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetProperty(System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "vspropId", Scope = "member", Target = "Microsoft.VisualStudio.Project.HierarchyNode.#GetGuidProperty(System.UInt32,System.Int32,System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1805:DoNotInitializeUnnecessarily", Scope = "member", Target = "Microsoft.VisualStudio.Project.NativeMethods+ConnectionPointCookie.#.ctor(System.Object,System.Object,System.Type,System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConnectionPointContainer.#Microsoft.VisualStudio.OLE.Interop.IConnectionPointContainer.FindConnectionPoint(System.Guid&,Microsoft.VisualStudio.OLE.Interop.IConnectionPoint&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.NodeProperties.#EnvDTE80.IInternalExtenderProvider.CanExtend(System.String,System.String,System.Object)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.NodeProperties.#EnvDTE80.IInternalExtenderProvider.GetExtender(System.String,System.String,System.Object,EnvDTE.IExtenderSite,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.NodeProperties.#EnvDTE80.IInternalExtenderProvider.GetExtenderNames(System.String,System.Object)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#Microsoft.VisualStudio.Shell.Interop.IVsProjectFlavorCfg.Close()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#VisualStudio.Project.IProjectEventsProvider.ProjectEventsProvider")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage.GetItemAttribute(System.UInt32,System.String,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage.GetPropertyValue(System.String,System.String,System.UInt32,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage.RemoveProperty(System.String,System.String,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage.SetItemAttribute(System.UInt32,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage.SetPropertyValue(System.String,System.String,System.UInt32,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Microsoft.VisualStudio.Shell.Interop.IVsProjectFlavorCfgProvider.CreateProjectFlavorCfg(Microsoft.VisualStudio.Shell.Interop.IVsCfg,Microsoft.VisualStudio.Shell.Interop.IVsProjectFlavorCfg&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConnectionPointContainer.#Microsoft.VisualStudio.OLE.Interop.IConnectionPointContainer.EnumConnectionPoints(Microsoft.VisualStudio.OLE.Interop.IEnumConnectionPoints&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Microsoft.VisualStudio.Project.IProjectEventsProvider.ProjectEventsProvider")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetMsBuildProperty(System.String,System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddNodeIfTargetExistInStorage(Microsoft.VisualStudio.Project.HierarchyNode,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddFolderFromOtherProject(System.String,Microsoft.VisualStudio.Project.HierarchyNode)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectElement.#GetMetadataAndThrow(System.String,System.Exception)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#GetRegisteredProject(Microsoft.VisualStudio.Project.ProjectElement)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectConfig.#GetMsBuildProperty(System.String,System.Boolean)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAVSProject.#Imports")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectBuildDependency.#get_CanonicalName(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectBuildDependency.#get_HelpContext(System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.SolutionListenerForProjectReferenceUpdate.#OnBeforeUnloadProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#TransferItem(System.String,System.String,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#TransferItem(System.String,System.String,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#TransferItem(System.String,System.String,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccLocation(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccLocation(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccLocation(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetSccLocation(System.String,System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetInnerProject(System.Object)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetHostObject(System.String,System.String,System.Object)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetHostObject(System.String,System.String,System.Object)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetHostObject(System.String,System.String,System.Object)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SetAggregateProjectTypeGuids(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SccGlyphChanged(System.Int32,System.UInt32[],Microsoft.VisualStudio.Shell.Interop.VsStateIcon[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SccGlyphChanged(System.Int32,System.UInt32[],Microsoft.VisualStudio.Shell.Interop.VsStateIcon[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SccGlyphChanged(System.Int32,System.UInt32[],Microsoft.VisualStudio.Shell.Interop.VsStateIcon[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SccGlyphChanged(System.Int32,System.UInt32[],Microsoft.VisualStudio.Shell.Interop.VsStateIcon[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#SaveCompleted(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Save(System.String,System.Int32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Save(System.String,System.Int32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Save(System.String,System.Int32,System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#ReopenItem(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#ReopenItem(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#ReopenItem(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#ReopenItem(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#ReopenItem(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#ReopenItem(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#RemoveItem(System.UInt32,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#RemoveItem(System.UInt32,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#RemoveItem(System.UInt32,System.UInt32,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItemWithSpecific(System.UInt32,System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItemWithSpecific(System.UInt32,System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItemWithSpecific(System.UInt32,System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "6#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItemWithSpecific(System.UInt32,System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItemWithSpecific(System.UInt32,System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItemWithSpecific(System.UInt32,System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItemWithSpecific(System.UInt32,System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItem(System.UInt32,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItem(System.UInt32,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenItem(System.UInt32,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#OpenDependency(System.String,Microsoft.VisualStudio.Shell.Interop.IVsDependency&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Load(System.String,System.UInt32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Load(System.String,System.UInt32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#Load(System.String,System.UInt32,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#IsDocumentInProject(System.String,System.Int32&,Microsoft.VisualStudio.Shell.Interop.VSDOCUMENTPRIORITY[],System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#IsDocumentInProject(System.String,System.Int32&,Microsoft.VisualStudio.Shell.Interop.VSDOCUMENTPRIORITY[],System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#IsDocumentInProject(System.String,System.Int32&,Microsoft.VisualStudio.Shell.Interop.VSDOCUMENTPRIORITY[],System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#IsDocumentInProject(System.String,System.Int32&,Microsoft.VisualStudio.Shell.Interop.VSDOCUMENTPRIORITY[],System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#IsDirty(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#InitNew(System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#InitializeForOuter(System.String,System.String,System.String,System.UInt32,System.Guid&,System.IntPtr&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#InitializeForOuter(System.String,System.String,System.String,System.UInt32,System.Guid&,System.IntPtr&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#InitializeForOuter(System.String,System.String,System.String,System.UInt32,System.Guid&,System.IntPtr&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#InitializeForOuter(System.String,System.String,System.String,System.UInt32,System.Guid&,System.IntPtr&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#InitializeForOuter(System.String,System.String,System.String,System.UInt32,System.Guid&,System.IntPtr&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#InitializeForOuter(System.String,System.String,System.String,System.UInt32,System.Guid&,System.IntPtr&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "6#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#InitializeForOuter(System.String,System.String,System.String,System.UInt32,System.Guid&,System.IntPtr&,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetSccSpecialFiles(System.UInt32,System.String,Microsoft.VisualStudio.OLE.Interop.CALPOLESTR[],Microsoft.VisualStudio.OLE.Interop.CADWORD[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetSccSpecialFiles(System.UInt32,System.String,Microsoft.VisualStudio.OLE.Interop.CALPOLESTR[],Microsoft.VisualStudio.OLE.Interop.CADWORD[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetSccSpecialFiles(System.UInt32,System.String,Microsoft.VisualStudio.OLE.Interop.CALPOLESTR[],Microsoft.VisualStudio.OLE.Interop.CADWORD[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetSccFiles(System.UInt32,Microsoft.VisualStudio.OLE.Interop.CALPOLESTR[],Microsoft.VisualStudio.OLE.Interop.CADWORD[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetSccFiles(System.UInt32,Microsoft.VisualStudio.OLE.Interop.CALPOLESTR[],Microsoft.VisualStudio.OLE.Interop.CADWORD[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetMkDocument(System.UInt32,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetMkDocument(System.UInt32,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetItemContext(System.UInt32,Microsoft.VisualStudio.OLE.Interop.IServiceProvider&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetItemContext(System.UInt32,Microsoft.VisualStudio.OLE.Interop.IServiceProvider&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetFormatList(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetFile(System.Int32,System.UInt32,System.UInt32&,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetFile(System.Int32,System.UInt32,System.UInt32&,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetFile(System.Int32,System.UInt32,System.UInt32&,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetFile(System.Int32,System.UInt32,System.UInt32&,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetCurFile(System.String&,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetCurFile(System.String&,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetClassID(System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetCfgProvider(Microsoft.VisualStudio.Shell.Interop.IVsCfgProvider&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetBuildSystemKind(System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GetAggregateProjectTypeGuids(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GenerateUniqueItemName(System.UInt32,System.String,System.String,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GenerateUniqueItemName(System.UInt32,System.String,System.String,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GenerateUniqueItemName(System.UInt32,System.String,System.String,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#GenerateUniqueItemName(System.UInt32,System.String,System.String,System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#EnumDependencies(Microsoft.VisualStudio.Shell.Interop.IVsEnumDependencies&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#BuildTarget(System.String,System.Boolean&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#BuildTarget(System.String,System.Boolean&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "10#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "8#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "9#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "7#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "6#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItemWithSpecific(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,System.UInt32,System.Guid&,System.String,System.Guid&,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "6#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItem(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItem(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItem(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItem(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItem(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItem(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddItem(System.UInt32,Microsoft.VisualStudio.Shell.Interop.VSADDITEMOPERATION,System.String,System.UInt32,System.String[],System.IntPtr,Microsoft.VisualStudio.Shell.Interop.VSADDRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectNode.#AddComponent(Microsoft.VisualStudio.Shell.Interop.VSADDCOMPOPERATION,System.UInt32,System.IntPtr[],System.IntPtr,Microsoft.VisualStudio.Shell.Interop.VSADDCOMPRESULT[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "4#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#IsItemDirty(System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ProjectContainerNode.#IsItemDirty(System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OASolutionFolder`1.#AddFromTemplate(System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OASolutionFolder`1.#AddFromTemplate(System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OASolutionFolder`1.#AddFromTemplate(System.String,System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OASolutionFolder`1.#AddFromFile(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAReferenceItem.#Open(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAProject.#SaveAs(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAProject.#Save(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAFileItem.#SaveAs(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.Automation.OAFileItem.#Open(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectBuildDependency.#get_Type(System.Guid&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectBuildDependency.#get_ReferredProject(System.Object&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectBuildDependency.#get_MustUpdateBefore(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectBuildDependency.#get_HelpFile(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.NestedProjectBuildDependency.#get_Description(System.String&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "5#", Scope = "member", Target = "Microsoft.VisualStudio.Project.FileDocumentManager.#OpenWithSpecific(System.UInt32,System.Guid&,System.String,System.Guid&,System.IntPtr,Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame&,Microsoft.VisualStudio.Project.WindowFrameShowAction)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.EnumDependencies.#Skip(System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.EnumDependencies.#Next(System.UInt32,Microsoft.VisualStudio.Shell.Interop.IVsDependency[],System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.EnumDependencies.#Next(System.UInt32,Microsoft.VisualStudio.Shell.Interop.IVsDependency[],System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.EnumDependencies.#Next(System.UInt32,Microsoft.VisualStudio.Shell.Interop.IVsDependency[],System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.EnumDependencies.#Clone(Microsoft.VisualStudio.Shell.Interop.IVsEnumDependencies&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#UnadviseCfgProviderEvents(System.UInt32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#RenameCfgsOfCfgName(System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#RenameCfgsOfCfgName(System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#OpenProjectCfg(System.String,Microsoft.VisualStudio.Shell.Interop.IVsProjectCfg&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#OpenProjectCfg(System.String,Microsoft.VisualStudio.Shell.Interop.IVsProjectCfg&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetSupportedPlatformNames(System.UInt32,System.String[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetSupportedPlatformNames(System.UInt32,System.String[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetPlatformNames(System.UInt32,System.String[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetPlatformNames(System.UInt32,System.String[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "3#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetCfgs(System.UInt32,Microsoft.VisualStudio.Shell.Interop.IVsCfg[],System.UInt32[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetCfgs(System.UInt32,Microsoft.VisualStudio.Shell.Interop.IVsCfg[],System.UInt32[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetCfgs(System.UInt32,Microsoft.VisualStudio.Shell.Interop.IVsCfg[],System.UInt32[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetCfgProviderProperty(System.Int32,System.Object&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetCfgOfName(System.String,System.String,Microsoft.VisualStudio.Shell.Interop.IVsCfg&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetCfgOfName(System.String,System.String,Microsoft.VisualStudio.Shell.Interop.IVsCfg&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetCfgOfName(System.String,System.String,Microsoft.VisualStudio.Shell.Interop.IVsCfg&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetCfgNames(System.UInt32,System.String[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "2#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetCfgNames(System.UInt32,System.String[],System.UInt32[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetAutomationObject(System.String,System.Object&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#GetAutomationObject(System.String,System.Object&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#get_UsesIndependentConfigurations(System.Int32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#DeleteCfgsOfPlatformName(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#DeleteCfgsOfCfgName(System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#AdviseCfgProviderEvents(Microsoft.VisualStudio.Shell.Interop.IVsCfgProviderEvents,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#AdviseCfgProviderEvents(Microsoft.VisualStudio.Shell.Interop.IVsCfgProviderEvents,System.UInt32&)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#AddCfgsOfPlatformName(System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#AddCfgsOfPlatformName(System.String,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "1#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#AddCfgsOfCfgName(System.String,System.String,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1725:ParameterNamesShouldMatchBaseDeclaration", MessageId = "0#", Scope = "member", Target = "Microsoft.VisualStudio.Project.ConfigProvider.#AddCfgsOfCfgName(System.String,System.String,System.Int32)")] diff --git a/SHFB/Source/MPFProj_VS2010/HierarchyNode.cs b/SHFB/Source/MPFProj_VS2010/HierarchyNode.cs deleted file mode 100644 index 998c20f6..00000000 --- a/SHFB/Source/MPFProj_VS2010/HierarchyNode.cs +++ /dev/null @@ -1,3516 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//============================================================================= -// File : HierarchyNode.cs -// Updated : 04/19/2011 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// This file has been modified to support "Add as Link" in the project. Search -// for "!EFW" to find the changes. -// -// NOTE: Other changes added support for linked files. Drag and drop and -// cut/copy/paste do work with the linked files. However, unlike a regular C# -// project, if a linked file is dragged, cut, or copied, when dropped or pasted -// it will become an actual file in the project in the new location rather than -// remaining as a link. I couldn't figure out a way to maintain the link state -// in the drop/paste handling code since that info doesn't carry over in the -// clipboard data. -// -// Date Who Comments -// ============================================================================ -// 06/18/2008 EFW Fixed bug in DragEnter. Added notes on linked files. -// 03/20/2011 EFW Updated to use MPFProj for VS2010 -// 04/04/2011 EFW Added support for "Show All Files" and Refresh Solution -//============================================================================= - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; -using System.Text; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -//#define CCI_TRACING -using Microsoft.VisualStudio.Shell.Interop; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; -using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; -using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// An object that deals with user interaction via a GUI in the form a hierarchy: a parent node with zero or more child nodes, each of which - /// can itself be a hierarchy. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling"), CLSCompliant(false), ComVisible(true)] - public abstract class HierarchyNode : - IVsUIHierarchy, - IVsPersistHierarchyItem2, - Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget, - IVsHierarchyDropDataSource2, - IVsHierarchyDropDataSource, - IVsHierarchyDropDataTarget, - IVsHierarchyDeleteHandler, - IDisposable - //, IVsBuildStatusCallback - { - #region nested types - /// - /// DropEffect as defined in oleidl.h - /// - internal enum DropEffect - { - None, - Copy = 1, - Move = 2, - Link = 4 - }; - #endregion - - #region Events - internal event EventHandler OnChildAdded - { - add { onChildAdded += value; } - remove { onChildAdded -= value; } - } - internal event EventHandler OnChildRemoved - { - add { onChildRemoved += value; } - remove { onChildRemoved -= value; } - } - #endregion - - #region static/const fields - public static readonly Guid SolutionExplorer = new Guid(EnvDTE.Constants.vsWindowKindSolutionExplorer); - public const int NoImage = -1; -#if DEBUG - internal static int LastTracedProperty; -#endif - #endregion - - #region fields - private EventSinkCollection hierarchyEventSinks = new EventSinkCollection(); - private ProjectNode projectMgr; - private ProjectElement itemNode; - private HierarchyNode parentNode; - private HierarchyNode nextSibling; - private HierarchyNode firstChild; - private HierarchyNode lastChild; - private bool isExpanded; - private uint hierarchyId; - private uint docCookie; - private bool hasDesigner; - private string virtualNodeName = String.Empty; // Only used by virtual nodes - private IVsHierarchy parentHierarchy; - private int parentHierarchyItemId; - private NodeProperties nodeProperties; - private OleServiceProvider oleServiceProvider = new OleServiceProvider(); - private bool excludeNodeFromScc; - private EventHandler onChildAdded; - private EventHandler onChildRemoved; - private bool hasParentNodeNameRelation; - private List itemsDraggedOrCutOrCopied; - private bool sourceDraggedOrCutOrCopied; - - /// - /// Has the object been disposed. - /// - /// We will not specify a property for isDisposed, rather it is expected that the a private flag is defined - /// on all subclasses. We do not want get in a situation where the base class's dipose is not called because a child sets the flag through the property. - private bool isDisposed; - #endregion - - #region abstract properties - /// - /// The URL of the node. - /// - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] - public abstract string Url - { - get; - } - - /// - /// The Caption of the node. - /// - /// - public abstract string Caption - { - get; - } - - /// - /// The item type guid associated to a node. - /// - /// - public abstract Guid ItemTypeGuid - { - get; - } - #endregion - - #region virtual properties - /// - /// Defines a string that is used to separate the name relation from the extension - /// - public virtual string NameRelationSeparator - { - get - { - return "."; - } - } - - - public virtual int MenuCommandId - { - get { return VsMenus.IDM_VS_CTXT_NOCOMMANDS; } - } - - - /// - /// Return an imageindex - /// - /// - public virtual int ImageIndex - { - get { return NoImage; } - } - - /// - /// Return an state icon index - /// - /// - /// - /// Sets the state icon for a file. - /// - public virtual VsStateIcon StateIconIndex - { - get - { - if(!this.ExcludeNodeFromScc) - { - IVsSccManager2 sccManager = this.ProjectMgr.Site.GetService(typeof(SVsSccManager)) as IVsSccManager2; - - if(sccManager != null) - { - VsStateIcon[] statIcons = new VsStateIcon[1] { VsStateIcon.STATEICON_NOSTATEICON }; - uint[] sccStatus = new uint[1] { 0 }; - // Get the glyph from the scc manager. Note that it will fail in command line - // scenarios. - if(ErrorHandler.Succeeded(sccManager.GetSccGlyph(1, new string[] { this.GetMkDocument() }, statIcons, sccStatus))) - { - return statIcons[0]; - } - } - } - - return VsStateIcon.STATEICON_NOSTATEICON; - } - } - - /// - /// Defines whether a node can execute a command if in selection. - /// - public virtual bool CanExecuteCommand - { - get - { - return true; - } - } - - /// - /// Used to determine the sort order of different node types - /// in the solution explorer window. - /// Nodes with the same priorities are sorted based on their captions. - /// - public virtual int SortPriority - { - get { return DefaultSortOrderNode.HierarchyNode; } - } - - /// - /// Defines the properties attached to this node. - /// - public virtual NodeProperties NodeProperties - { - get - { - if(null == nodeProperties) - { - nodeProperties = CreatePropertiesObject(); - } - return this.nodeProperties; - } - - } - - /// - /// Returns an object that is a special view over this object; this is the value - /// returned by the Object property of the automation objects. - /// - internal virtual object Object - { - get { return this; } - } - #endregion - - #region properties - - public OleServiceProvider OleServiceProvider - { - get - { - return this.oleServiceProvider; - } - } - - [System.ComponentModel.BrowsableAttribute(false)] - public ProjectNode ProjectMgr - { - get - { - return this.projectMgr; - } - set - { - this.projectMgr = value; - } - } - - - [System.ComponentModel.BrowsableAttribute(false)] - public HierarchyNode NextSibling - { - get - { - return this.nextSibling; - } - set - { - this.nextSibling = value; - } - } - - - [System.ComponentModel.BrowsableAttribute(false)] - public HierarchyNode FirstChild - { - get - { - return this.firstChild; - } - set - { - this.firstChild = value; - } - } - - [System.ComponentModel.BrowsableAttribute(false)] - public HierarchyNode LastChild - { - get - { - return this.lastChild; - } - set - { - this.lastChild = value; - } - } - - - [System.ComponentModel.BrowsableAttribute(false)] - public HierarchyNode Parent - { - get - { - return this.parentNode; - } - set - { - this.parentNode = value; - } - } - - - [System.ComponentModel.BrowsableAttribute(false)] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID")] - public uint ID - { - get - { - return this.hierarchyId; - } - internal set - { - this.hierarchyId = value; - } - } - - - [System.ComponentModel.BrowsableAttribute(false)] - public ProjectElement ItemNode - { - get - { - return itemNode; - } - set - { - itemNode = value; - } - } - - - [System.ComponentModel.BrowsableAttribute(false)] - public bool HasDesigner - { - get - { - return this.hasDesigner; - } - set { this.hasDesigner = value; } - } - - - [System.ComponentModel.BrowsableAttribute(false)] - public bool IsExpanded - { - get - { - return this.isExpanded; - } - set { this.isExpanded = value; } - } - - public string VirtualNodeName - { - get - { - return this.virtualNodeName; - } - set - { - this.virtualNodeName = value; - } - } - - - [System.ComponentModel.BrowsableAttribute(false)] - public HierarchyNode PreviousSibling - { - get - { - if(this.parentNode == null) return null; - HierarchyNode prev = null; - for(HierarchyNode child = this.parentNode.firstChild; child != null; child = child.nextSibling) - { - if(child == this) - break; - prev = child; - } - return prev; - } - } - - public uint DocCookie - { - get - { - return this.docCookie; - } - set - { - this.docCookie = value; - } - } - - /// - /// Specifies if a Node is under source control. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - public bool ExcludeNodeFromScc - { - get - { - // !EFW - if(this.IsNonMemberItem) - return true; - - return this.excludeNodeFromScc; - } - set - { - this.excludeNodeFromScc = value; - } - } - - /// - /// Defines if a node a name relation to its parent node - /// - /// - public bool HasParentNodeNameRelation - { - get - { - return this.hasParentNodeNameRelation; - } - set - { - this.hasParentNodeNameRelation = value; - } - } - - protected bool SourceDraggedOrCutOrCopied - { - get - { - return this.sourceDraggedOrCutOrCopied; - } - set - { - this.sourceDraggedOrCutOrCopied = value; - } - } - - protected IList ItemsDraggedOrCutOrCopied - { - get - { - return this.itemsDraggedOrCutOrCopied; - } - } - #endregion - - #region ctors - - protected HierarchyNode() - { - this.IsExpanded = true; - } - - protected HierarchyNode(ProjectNode root, ProjectElement element) - { - if (root == null) - { - throw new ArgumentNullException("root"); - } - - this.projectMgr = root; - this.itemNode = element; - this.hierarchyId = this.projectMgr.ItemIdMap.Add(this); - this.oleServiceProvider.AddService(typeof(IVsHierarchy), root, false); - } - - /// - /// Overloaded ctor. - /// - /// - protected HierarchyNode(ProjectNode root) - { - if (root == null) - { - throw new ArgumentNullException("root"); - } - - this.projectMgr = root; - this.itemNode = new ProjectElement(this.projectMgr, null, true); - this.hierarchyId = this.projectMgr.ItemIdMap.Add(this); - this.oleServiceProvider.AddService(typeof(IVsHierarchy), root, false); - } - #endregion - - #region virtual methods - /// - /// Creates an object derived from NodeProperties that will be used to expose properties - /// spacific for this object to the property browser. - /// - /// - protected virtual NodeProperties CreatePropertiesObject() - { - return null; - } - - /// - /// Return an iconhandle - /// - /// - /// - public virtual object GetIconHandle(bool open) - { - return null; - } - - /// - /// AddChild - add a node, sorted in the right location. - /// - /// The node to add. - public virtual void AddChild(HierarchyNode node) - { - if(node == null) - { - throw new ArgumentNullException("node"); - } - - // make sure the node is in the map. - Object nodeWithSameID = this.projectMgr.ItemIdMap[node.hierarchyId]; - if(!Object.ReferenceEquals(node, nodeWithSameID as HierarchyNode)) - { - if(nodeWithSameID == null && node.ID <= this.ProjectMgr.ItemIdMap.Count) - { // reuse our hierarchy id if possible. - this.projectMgr.ItemIdMap.SetAt(node.hierarchyId, this); - } - else - { - throw new InvalidOperationException(); - } - } - - HierarchyNode previous = null; - for(HierarchyNode n = this.firstChild; n != null; n = n.nextSibling) - { - if(this.ProjectMgr.CompareNodes(node, n) > 0) break; - previous = n; - } - // insert "node" after "previous". - if(previous != null) - { - node.nextSibling = previous.nextSibling; - previous.nextSibling = node; - if(previous == this.lastChild) - { - this.lastChild = node; - } - } - else - { - if(this.lastChild == null) - { - this.lastChild = node; - } - node.nextSibling = this.firstChild; - this.firstChild = node; - } - node.parentNode = this; - this.OnItemAdded(this, node); - } - - /// - /// Removes a node from the hierarchy. - /// - /// The node to remove. - public virtual void RemoveChild(HierarchyNode node) - { - if(node == null) - { - throw new ArgumentNullException("node"); - } - - this.projectMgr.ItemIdMap.Remove(node); - - HierarchyNode last = null; - for(HierarchyNode n = this.firstChild; n != null; n = n.nextSibling) - { - if(n == node) - { - if(last != null) - { - last.nextSibling = n.nextSibling; - } - if(n == this.lastChild) - { - if(last == this.lastChild) - { - this.lastChild = null; - } - else - { - this.lastChild = last; - } - } - if(n == this.firstChild) - { - this.firstChild = n.nextSibling; - } - return; - } - last = n; - } - throw new InvalidOperationException("Node not found"); - } - - /// - /// Returns an automation object representing this node - /// - /// The automation object - public virtual object GetAutomationObject() - { - return new Automation.OAProjectItem(this.projectMgr.GetAutomationObject() as Automation.OAProject, this); - } - - /// - /// Returns a property object based on a property id - /// - /// the property id of the property requested - /// the property object requested - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - public virtual object GetProperty(int propId) - { - object result = null; - switch((__VSHPROPID)propId) - { - case __VSHPROPID.VSHPROPID_Expandable: - result = (this.firstChild != null); - break; - - case __VSHPROPID.VSHPROPID_Caption: - result = this.Caption; - break; - - case __VSHPROPID.VSHPROPID_Name: - result = this.Caption; - break; - - case __VSHPROPID.VSHPROPID_ExpandByDefault: - result = false; - break; - - case __VSHPROPID.VSHPROPID_IconImgList: - result = this.ProjectMgr.ImageHandler.ImageList.Handle; - break; - - case __VSHPROPID.VSHPROPID_OpenFolderIconIndex: - case __VSHPROPID.VSHPROPID_IconIndex: - int index = this.ImageIndex; - if(index != NoImage) - { - result = index; - } - break; - - case __VSHPROPID.VSHPROPID_StateIconIndex: - result = (int)this.StateIconIndex; - break; - - case __VSHPROPID.VSHPROPID_IconHandle: - result = GetIconHandle(false); - break; - - case __VSHPROPID.VSHPROPID_OpenFolderIconHandle: - result = GetIconHandle(true); - break; - - case __VSHPROPID.VSHPROPID_NextVisibleSibling: - goto case __VSHPROPID.VSHPROPID_NextSibling; - - case __VSHPROPID.VSHPROPID_NextSibling: - result = (int)((this.nextSibling != null) ? this.nextSibling.hierarchyId : VSConstants.VSITEMID_NIL); - break; - - case __VSHPROPID.VSHPROPID_FirstChild: - goto case __VSHPROPID.VSHPROPID_FirstVisibleChild; - - case __VSHPROPID.VSHPROPID_FirstVisibleChild: - result = (int)((this.firstChild != null) ? this.firstChild.hierarchyId : VSConstants.VSITEMID_NIL); - break; - - case __VSHPROPID.VSHPROPID_Parent: - if(null == this.parentNode) - { - unchecked { result = new IntPtr((int)VSConstants.VSITEMID_NIL); } - } - else - { - result = new IntPtr((int)this.parentNode.hierarchyId); // see bug 176470 - } - break; - - case __VSHPROPID.VSHPROPID_ParentHierarchyItemid: - if(parentHierarchy != null) - { - result = (int)parentHierarchyItemId; // VS requires VT_I4 | VT_INT_PTR - } - break; - - case __VSHPROPID.VSHPROPID_ParentHierarchy: - result = parentHierarchy; - break; - - case __VSHPROPID.VSHPROPID_Root: - result = Marshal.GetIUnknownForObject(this.projectMgr); - break; - - case __VSHPROPID.VSHPROPID_Expanded: - result = this.isExpanded; - break; - - case __VSHPROPID.VSHPROPID_BrowseObject: - result = this.NodeProperties; - if(result != null) result = new DispatchWrapper(result); - break; - - case __VSHPROPID.VSHPROPID_EditLabel: - if(this.ProjectMgr != null && !this.ProjectMgr.IsClosed && !this.ProjectMgr.IsCurrentStateASuppressCommandsMode()) - { - result = GetEditLabel(); - } - break; - - case __VSHPROPID.VSHPROPID_SaveName: - //SaveName is the name shown in the Save and the Save Changes dialog boxes. - result = this.Caption; - break; - - case __VSHPROPID.VSHPROPID_ItemDocCookie: - if(this.docCookie != 0) return (IntPtr)this.docCookie; //cast to IntPtr as some callers expect VT_INT - break; - - case __VSHPROPID.VSHPROPID_ExtObject: - result = GetAutomationObject(); - break; - - case __VSHPROPID.VSHPROPID_IsNonMemberItem: // !EFW - result = this.IsNonMemberItem; - break; - } - - __VSHPROPID2 id2 = (__VSHPROPID2)propId; - switch(id2) - { - case __VSHPROPID2.VSHPROPID_NoDefaultNestedHierSorting: - return true; // We are doing the sorting ourselves through VSHPROPID_FirstChild and VSHPROPID_NextSibling - case __VSHPROPID2.VSHPROPID_BrowseObjectCATID: - { - // If there is a browse object and it is a NodeProperties, then get it's CATID - object browseObject = this.GetProperty((int)__VSHPROPID.VSHPROPID_BrowseObject); - if(browseObject != null) - { - if(browseObject is DispatchWrapper) - browseObject = ((DispatchWrapper)browseObject).WrappedObject; - result = this.ProjectMgr.GetCATIDForType(browseObject.GetType()).ToString("B"); - if(String.CompareOrdinal(result as string, Guid.Empty.ToString("B")) == 0) - result = null; - } - break; - } - case __VSHPROPID2.VSHPROPID_ExtObjectCATID: - { - // If there is a extensibility object and it is a NodeProperties, then get it's CATID - object extObject = this.GetProperty((int)__VSHPROPID.VSHPROPID_ExtObject); - if(extObject != null) - { - if(extObject is DispatchWrapper) - extObject = ((DispatchWrapper)extObject).WrappedObject; - result = this.ProjectMgr.GetCATIDForType(extObject.GetType()).ToString("B"); - if(String.CompareOrdinal(result as string, Guid.Empty.ToString("B")) == 0) - result = null; - } - break; - } - } - - __VSHPROPID4 id4 = (__VSHPROPID4)propId; - switch (id4) - { - case __VSHPROPID4.VSHPROPID_TargetFrameworkMoniker: - result = this.ProjectMgr.TargetFrameworkMoniker.FullName; - break; - } - -#if DEBUG - if(propId != LastTracedProperty) - { - string trailer = (result == null) ? "null" : result.ToString(); - CCITracing.TraceCall(this.hierarchyId + "," + propId.ToString() + " = " + trailer); - LastTracedProperty = propId; // some basic filtering here... - } -#endif - return result; - } - - /// - /// Sets the value of a property for a given property id - /// - /// the property id of the property to be set - /// value of the property - /// S_OK if succeeded - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "propid")] - public virtual int SetProperty(int propid, object value) - { - __VSHPROPID id = (__VSHPROPID)propid; - - CCITracing.TraceCall(this.hierarchyId + "," + id.ToString()); - switch(id) - { - case __VSHPROPID.VSHPROPID_Expanded: - this.isExpanded = (bool)value; - break; - - case __VSHPROPID.VSHPROPID_ParentHierarchy: - parentHierarchy = (IVsHierarchy)value; - break; - - case __VSHPROPID.VSHPROPID_ParentHierarchyItemid: - parentHierarchyItemId = (int)value; - break; - - case __VSHPROPID.VSHPROPID_EditLabel: - return SetEditLabel((string)value); - - case __VSHPROPID.VSHPROPID_IsNonMemberItem: // !EFW - bool parsedValue; - - if(Boolean.TryParse(value.ToString(), out parsedValue)) - { - // This also resets the Exclude From Source Control state too - this.ExcludeNodeFromScc = this.IsNonMemberItem = parsedValue; - return (int)VSConstants.S_OK; - } - break; - - default: - CCITracing.TraceCall(" unhandled"); - break; - } - - __VSHPROPID4 id4 = (__VSHPROPID4)propid; - switch (id4) - { - case __VSHPROPID4.VSHPROPID_TargetFrameworkMoniker: - this.ProjectMgr.TargetFrameworkMoniker = new FrameworkName((string)value); - break; - } - - return VSConstants.S_OK; - } - - /// - /// Get a guid property - /// - /// property id for the guid property requested - /// the requested guid - /// S_OK if succeded - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "propid")] - public virtual int GetGuidProperty(int propid, out Guid guid) - { - guid = Guid.Empty; - if(propid == (int)__VSHPROPID.VSHPROPID_TypeGuid) - { - guid = this.ItemTypeGuid; - } - - if(guid.CompareTo(Guid.Empty) == 0) - { - return VSConstants.DISP_E_MEMBERNOTFOUND; - } - - return VSConstants.S_OK; - } - - /// - /// Set a guid property. - /// - /// property id of the guid property to be set - /// the guid to be set - /// E_NOTIMPL - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "propid")] - public virtual int SetGuidProperty(int propid, ref Guid guid) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Called by the shell when a node has been renamed from the GUI - /// - /// - /// E_NOTIMPL - public virtual int SetEditLabel(string label) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Called by the shell to get the node caption when the user tries to rename from the GUI - /// - /// the node cation - public virtual string GetEditLabel() - { - // !EFW - // Supress edit for non-member items - if(this.IsNonMemberItem) - return null; - - return this.Caption; - } - - /// - /// This method is called by the interface method GetMkDocument to specify the item moniker. - /// - /// The moniker for this item - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mk")] - public virtual string GetMkDocument() - { - return String.Empty; - } - - /// - /// Removes items from the hierarchy. Project overwrites this - /// - /// - public virtual void Remove(bool removeFromStorage) - { - string documentToRemove = this.GetMkDocument(); - - // Ask Document tracker listeners if we can remove the item. - string[] filesToBeDeleted = new string[1] { documentToRemove }; - VSQUERYREMOVEFILEFLAGS[] queryRemoveFlags = this.GetQueryRemoveFileFlags(filesToBeDeleted); - if(!this.ProjectMgr.Tracker.CanRemoveItems(filesToBeDeleted, queryRemoveFlags)) - { - return; - } - - // Close the document if it has a manager. - DocumentManager manager = this.GetDocumentManager(); - if(manager != null) - { - if(manager.Close(!removeFromStorage ? __FRAMECLOSE.FRAMECLOSE_PromptSave : __FRAMECLOSE.FRAMECLOSE_NoSave) == VSConstants.E_ABORT) - { - // User cancelled operation in message box. - return; - } - } - - // Check out the project file. - if(!this.ProjectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - // !EFW - Handle exclude from project when Show All Files is toggled on by converting the node - // to a non-member item. - bool isLinked = !String.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.Link)); - bool convertToNonMemberNode = (!removeFromStorage && !isLinked && this.ProjectMgr.ShowingAllFiles && - (File.Exists(this.Url) || Directory.Exists(this.Url))); - - // Notify hierarchy event listeners that the file is going to be removed. - if(!convertToNonMemberNode) - this.OnItemDeleted(); - - // Remove child if any before removing from the hierarchy - for(HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) - { - child.Remove(removeFromStorage); - } - - // Close the document window if opened. - CloseDocumentWindow(this); - - // Notify document tracker listeners that we have removed the item. - VSREMOVEFILEFLAGS[] removeFlags = this.GetRemoveFileFlags(filesToBeDeleted); - Debug.Assert(removeFlags != null, "At least an empty array should be returned for the GetRemoveFileFlags"); - this.ProjectMgr.Tracker.OnItemRemoved(documentToRemove, removeFlags[0]); - - if(!convertToNonMemberNode) - { - // the project node has no parentNode - if(this.parentNode != null) - { - // Remove from the Hierarchy - this.parentNode.RemoveChild(this); - } - - // We save here the path to delete since this.Url might call the Include which will be deleted by the RemoveFromProjectFile call. - string pathToDelete = this.GetMkDocument(); - - this.itemNode.RemoveFromProjectFile(); - - if(removeFromStorage && !isLinked) - { - this.DeleteFromStorage(pathToDelete); - } - - // Notify hierarchy event listeners that we have removed the item - if(null != this.parentNode.onChildRemoved) - { - HierarchyNodeEventArgs args = new HierarchyNodeEventArgs(this); - parentNode.onChildRemoved(parentNode, args); - } - - // Notify hierarchy event listeners that items have been invalidated - OnInvalidateItems(this.parentNode); - - // Dispose the node now that is deleted. - this.Dispose(true); - } - else - if(!this.IsNonMemberItem) - { - // Save the paths - string url = this.Url; - string include = this.itemNode.GetMetadata(ProjectFileConstants.Include); - - // Convert this node to a non-member node - this.IsNonMemberItem = true; - this.itemNode.RemoveFromProjectFile(); - this.itemNode = new ProjectElement(this.ProjectMgr, null, true); - this.itemNode.Rename(include); - this.itemNode.SetMetadata(ProjectFileConstants.Name, url); - - this.ReDraw(UIHierarchyElement.Icon | UIHierarchyElement.SccState); - } - } - - /// - /// Returns the relational name which is defined as the first part of the caption until indexof NameRelationSeparator - /// - public virtual string GetRelationalName() - { - //Get the first part of the caption - string[] partsOfParent = this.Caption.Split(new string[] { this.NameRelationSeparator }, StringSplitOptions.None); - return partsOfParent[0]; - } - - /// - /// Returns the 'extension' of the relational name - /// e.g. form1.resx returns .resx, form1.designer.cs returns .designer.cs - /// - /// The extension - public virtual string GetRelationNameExtension() - { - return this.Caption.Substring(this.Caption.IndexOf(this.NameRelationSeparator, StringComparison.Ordinal)); - } - - /// - /// Close open document frame for a specific node. - /// - protected void CloseDocumentWindow(HierarchyNode node) - { - if (node == null) - { - throw new ArgumentNullException("node"); - } - - // We walk the RDT looking for all running documents attached to this hierarchy and itemid. There - // are cases where there may be two different editors (not views) open on the same document. - IEnumRunningDocuments pEnumRdt; - IVsRunningDocumentTable pRdt = this.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - if(pRdt == null) - { - throw new InvalidOperationException(); - } - if(ErrorHandler.Succeeded(pRdt.GetRunningDocumentsEnum(out pEnumRdt))) - { - uint[] cookie = new uint[1]; - uint fetched; - uint saveOptions = (uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_NoSave; - IVsHierarchy srpOurHier = node.projectMgr.InteropSafeIVsHierarchy; - - ErrorHandler.ThrowOnFailure(pEnumRdt.Reset()); - while(VSConstants.S_OK == pEnumRdt.Next(1, cookie, out fetched)) - { - // Note we can pass NULL for all parameters we don't care about - uint empty; - string emptyStr; - IntPtr ppunkDocData; - IVsHierarchy srpHier; - uint itemid = VSConstants.VSITEMID_NIL; - - ErrorHandler.ThrowOnFailure(pRdt.GetDocumentInfo( - cookie[0], - out empty, - out empty, - out empty, - out emptyStr, - out srpHier, - out itemid, - out ppunkDocData)); - - // Is this one of our documents? - if(Utilities.IsSameComObject(srpOurHier, srpHier) && itemid == node.ID) - { - IVsSolution soln = GetService(typeof(SVsSolution)) as IVsSolution; - ErrorHandler.ThrowOnFailure(soln.CloseSolutionElement(saveOptions, srpOurHier, cookie[0])); - } - if(ppunkDocData != IntPtr.Zero) - Marshal.Release(ppunkDocData); - - } - } - } - - /// - /// Redraws the state icon if the node is not excluded from source control. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - protected internal virtual void UpdateSccStateIcons() - { - if(!this.ExcludeNodeFromScc) - { - this.ReDraw(UIHierarchyElement.SccState); - } - } - - /// - /// To be overwritten by descendants. - /// - protected internal virtual int SetEditLabel(string label, string relativePath) - { - throw new NotImplementedException(); - } - - /// - /// Called by the drag and drop implementation to ask the node - /// which is being dragged/droped over which nodes should - /// process the operation. - /// This allows for dragging to a node that cannot contain - /// items to let its parent accept the drop - /// - /// HierarchyNode that accept the drop handling - protected internal virtual HierarchyNode GetDragTargetHandlerNode() - { - return this; - } - - /// - /// Add a new Folder to the project hierarchy. - /// - /// S_OK if succeeded, otherwise an error - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] - protected virtual int AddNewFolder() - { - // Check out the project file. - if(!this.ProjectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - try - { - // Generate a new folder name - string newFolderName; - ErrorHandler.ThrowOnFailure(this.projectMgr.GenerateUniqueItemName(this.hierarchyId, String.Empty, String.Empty, out newFolderName)); - - // create the project part of it, the project file - HierarchyNode child = this.ProjectMgr.CreateFolderNodes(Path.Combine(this.virtualNodeName, newFolderName)); - - if (child is FolderNode) - { - ((FolderNode)child).CreateDirectory(); - } - - // If we are in automation mode then skip the ui part which is about renaming the folder - if (!Utilities.IsInAutomationFunction(this.projectMgr.Site)) - { - IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.projectMgr.Site, SolutionExplorer); - // This happens in the context of adding a new folder. - // Since we are already in solution explorer, it is extremely unlikely that we get a null return. - // If we do, the newly created folder will not be selected, and we will not attempt the rename - // command (since we are selecting the wrong item). - if (uiWindow != null) - { - // we need to get into label edit mode now... - // so first select the new guy... - ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this.projectMgr.InteropSafeIVsUIHierarchy, child.hierarchyId, EXPANDFLAGS.EXPF_SelectItem)); - // them post the rename command to the shell. Folder verification and creation will - // happen in the setlabel code... - IVsUIShell shell = this.projectMgr.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; - - Debug.Assert(shell != null, "Could not get the ui shell from the project"); - if (shell == null) - { - return VSConstants.E_FAIL; - } - - object dummy = null; - Guid cmdGroup = VsMenus.guidStandardCommandSet97; - ErrorHandler.ThrowOnFailure(shell.PostExecCommand(ref cmdGroup, (uint)VsCommands.Rename, 0, ref dummy)); - } - } - } - catch (COMException e) - { - Trace.WriteLine("Exception : " + e.Message); - return e.ErrorCode; - } - - return VSConstants.S_OK; - } - - // !EFW - /// - /// This is overridden to enable the "Add as Link" functionality in - /// the Add Existing Item dialog. - /// - /// The type of item to add - /// Returns VSConstants.S_OK on success or an error - /// code on failure. - /// Note that this just enables the dropdown on the Add - /// button. The actual support for linked files in the project takes - /// more work and is implemented in the ProjectNode and FileNode - /// classes. - protected virtual int AddItemToHierarchy(HierarchyAddType addType) - { - CCITracing.TraceCall(); - IVsAddProjectItemDlg addItemDialog; - - string strFilter = String.Empty; - int iDontShowAgain; - uint uiFlags; - IVsProject3 project = this.projectMgr.InteropSafeIVsProject3; - - string strBrowseLocations = Path.GetDirectoryName(this.projectMgr.BaseURI.Uri.LocalPath); - - System.Guid projectGuid = this.projectMgr.ProjectGuid; - - addItemDialog = this.GetService(typeof(IVsAddProjectItemDlg)) as IVsAddProjectItemDlg; - - if(addType == HierarchyAddType.AddNewItem) - uiFlags = (uint)(__VSADDITEMFLAGS.VSADDITEM_AddNewItems | - __VSADDITEMFLAGS.VSADDITEM_SuggestTemplateName | - __VSADDITEMFLAGS.VSADDITEM_AllowHiddenTreeView); - else - uiFlags = (uint)(__VSADDITEMFLAGS.VSADDITEM_AddExistingItems | - __VSADDITEMFLAGS.VSADDITEM_ProjectHandlesLinks | // !EFW - The magic value for "Add as Link" - __VSADDITEMFLAGS.VSADDITEM_AllowMultiSelect | - __VSADDITEMFLAGS.VSADDITEM_AllowStickyFilter); - - ErrorHandler.ThrowOnFailure(addItemDialog.AddProjectItemDlg( - this.hierarchyId, ref projectGuid, project, uiFlags, null, - null, ref strBrowseLocations, ref strFilter, - out iDontShowAgain)); /*&fDontShowAgain*/ - - return VSConstants.S_OK; - } - - /// - /// Overwritten in subclasses - /// - protected virtual void DoDefaultAction() - { - CCITracing.TraceCall(); - } - - /// - /// Handles the exclude from project command. - /// - /// - protected virtual int ExcludeFromProject() - { - Debug.Assert(this.ProjectMgr != null, "The project item " + this.ToString() + " has not been initialised correctly. It has a null ProjectMgr"); - this.Remove(false); - return VSConstants.S_OK; - } - - /// - /// Handles the Show in Designer command. - /// - /// - protected virtual int ShowInDesigner(IList selectedNodes) - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - /// - /// Prepares a selected node for clipboard. - /// It takes the the project reference string of this item and adds it to a stringbuilder. - /// - /// A stringbuilder. - /// This method has to be public since seleceted nodes will call it. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "ClipBoard")] - protected internal virtual StringBuilder PrepareSelectedNodesForClipBoard() - { - Debug.Assert(this.ProjectMgr != null, " No project mananager available for this node " + ToString()); - Debug.Assert(this.ProjectMgr.ItemsDraggedOrCutOrCopied != null, " The itemsdragged list should have been initialized prior calling this method"); - StringBuilder sb = new StringBuilder(); - - if(this.hierarchyId == VSConstants.VSITEMID_ROOT) - { - if(this.ProjectMgr.ItemsDraggedOrCutOrCopied != null) - { - this.ProjectMgr.ItemsDraggedOrCutOrCopied.Clear();// abort - } - return sb; - } - - if(this.ProjectMgr.ItemsDraggedOrCutOrCopied != null) - { - this.ProjectMgr.ItemsDraggedOrCutOrCopied.Add(this); - } - - string projref = String.Empty; - IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution; - if(solution != null) - { - ErrorHandler.ThrowOnFailure(solution.GetProjrefOfItem(this.ProjectMgr.InteropSafeIVsHierarchy, this.hierarchyId, out projref)); - if(String.IsNullOrEmpty(projref)) - { - if(this.ProjectMgr.ItemsDraggedOrCutOrCopied != null) - { - this.ProjectMgr.ItemsDraggedOrCutOrCopied.Clear();// abort - } - return sb; - } - } - - // Append the projectref and a null terminator to the string builder - sb.Append(projref); - sb.Append('\0'); - - return sb; - } - - /// - /// Returns the Cannonical Name - /// - /// Cannonical Name - protected virtual string GetCanonicalName() - { - return this.GetMkDocument(); - } - - /// - /// Factory method for the Document Manager object - /// - /// null object, since a hierarchy node does not know its kind of document - /// Must be overriden by derived node classes if a document manager is needed - protected internal virtual DocumentManager GetDocumentManager() - { - return null; - } - - /// - /// Displays the context menu. - /// - /// list of selected nodes. - /// contains the location (x,y) at which to show the menu. - [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "pointer")] - protected virtual int DisplayContextMenu(IList selectedNodes, IntPtr pointerToVariant) - { - if(selectedNodes == null || selectedNodes.Count == 0 || pointerToVariant == IntPtr.Zero) - { - return NativeMethods.OLECMDERR_E_NOTSUPPORTED; - } - - int idmxStoredMenu = 0; - - foreach(HierarchyNode node in selectedNodes) - { - // We check here whether we have a multiple selection of - // nodes of differing type. - if(idmxStoredMenu == 0) - { - // First time through or single node case - idmxStoredMenu = node.MenuCommandId; - } - else if(idmxStoredMenu != node.MenuCommandId) - { - // We have different node types. Check if any of the nodes is - // the project node and set the menu accordingly. - if(node.MenuCommandId == VsMenus.IDM_VS_CTXT_PROJNODE) - { - idmxStoredMenu = VsMenus.IDM_VS_CTXT_XPROJ_PROJITEM; - } - else - { - idmxStoredMenu = VsMenus.IDM_VS_CTXT_XPROJ_MULTIITEM; - } - } - } - - object variant = Marshal.GetObjectForNativeVariant(pointerToVariant); - UInt32 pointsAsUint = (UInt32)variant; - short x = (short)(pointsAsUint & 0x0000ffff); - short y = (short)((pointsAsUint & 0xffff0000) / 0x10000); - - - POINTS points = new POINTS(); - points.x = x; - points.y = y; - return ShowContextMenu(idmxStoredMenu, VsMenus.guidSHLMainMenu, points); - } - - /// - /// Shows the specified context menu at a specified location. - /// - /// The context menu ID. - /// The GUID of the menu group. - /// The location at which to show the menu. - protected virtual int ShowContextMenu(int menuId, Guid menuGroup, POINTS points) - { - IVsUIShell shell = this.projectMgr.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; - - Debug.Assert(shell != null, "Could not get the ui shell from the project"); - if(shell == null) - { - return VSConstants.E_FAIL; - } - POINTS[] pnts = new POINTS[1]; - pnts[0].x = points.x; - pnts[0].y = points.y; - return shell.ShowContextMenu(0, ref menuGroup, menuId, pnts, (IOleCommandTarget)this); - } - - #region initiation of command execution - /// - /// Handles command execution. - /// - /// Unique identifier of the command group - /// The command to be executed. - /// Values describe how the object should execute the command. - /// Pointer to a VARIANTARG structure containing input arguments. Can be NULL - /// VARIANTARG structure to receive command output. Can be NULL. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cmdexecopt")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "n")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "pva")] - protected virtual int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) - { - if(this.projectMgr == null || this.projectMgr.IsClosed) - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - if(cmdGroup == Guid.Empty) - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - else if(cmdGroup == VsMenus.guidVsUIHierarchyWindowCmds) - { - switch(cmd) - { - case (uint)VSConstants.VsUIHierarchyWindowCmdIds.UIHWCMDID_DoubleClick: - case (uint)VSConstants.VsUIHierarchyWindowCmdIds.UIHWCMDID_EnterKey: - this.DoDefaultAction(); - return VSConstants.S_OK; - } - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - else if(cmdGroup == VsMenus.guidStandardCommandSet97) - { - HierarchyNode nodeToAddTo = this.GetDragTargetHandlerNode(); - switch((VsCommands)cmd) - { - case VsCommands.AddNewItem: - return nodeToAddTo.AddItemToHierarchy(HierarchyAddType.AddNewItem); - - case VsCommands.AddExistingItem: - return nodeToAddTo.AddItemToHierarchy(HierarchyAddType.AddExistingItem); - - case VsCommands.NewFolder: - return nodeToAddTo.AddNewFolder(); - - case VsCommands.Paste: - return this.ProjectMgr.PasteFromClipboard(this); - - case VsCommands.Refresh: // !EFW - Added support for Refresh - this.ProjectMgr.RefreshProject(); - return VSConstants.S_OK; - } - } - else if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - switch((VsCommands2K)cmd) - { - case VsCommands2K.INCLUDEINPROJECT: // !EFW - Added support for Include in Project - FolderNode fn = this as FolderNode; - - if(fn != null) - return fn.IncludeInProjectRecursive(); - - return this.IncludeInProject(); - - case VsCommands2K.EXCLUDEFROMPROJECT: - return this.ExcludeFromProject(); - - case VsCommands2K.SLNREFRESH: // !EFW - Added support for Refresh - this.ProjectMgr.RefreshProject(); - return VSConstants.S_OK; - } - } - - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - /// - /// Executes a command that can only be executed once the whole selection is known. - /// - /// Unique identifier of the command group - /// The command to be executed. - /// Values describe how the object should execute the command. - /// Pointer to a VARIANTARG structure containing input arguments. Can be NULL - /// VARIANTARG structure to receive command output. Can be NULL. - /// The origin of the command. From IOleCommandTarget or hierarchy. - /// The list of the selected nodes. - /// An out parameter specifying that the command was handled. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "vaIn")] - protected virtual int ExecCommandThatDependsOnSelectedNodes(Guid cmdGroup, uint cmdId, uint cmdExecOpt, IntPtr vaIn, IntPtr vaOut, CommandOrigin commandOrigin, IList selectedNodes, out bool handled) - { - handled = false; - if(cmdGroup == VsMenus.guidVsUIHierarchyWindowCmds) - { - switch(cmdId) - { - case (uint)VSConstants.VsUIHierarchyWindowCmdIds.UIHWCMDID_RightClick: - // The UIHWCMDID_RightClick is what tells an IVsUIHierarchy in a UIHierarchyWindow - // to put up the context menu. Since the mouse may have moved between the - // mouse down and the mouse up, GetCursorPos won't tell you the right place - // to put the context menu (especially if it came through the keyboard). - // So we pack the proper menu position into pvaIn by - // memcpy'ing a POINTS struct into the VT_UI4 part of the pvaIn variant. The - // code to unpack it looks like this: - // ULONG ulPts = V_UI4(pvaIn); - // POINTS pts; - // memcpy((void*)&pts, &ulPts, sizeof(POINTS)); - // You then pass that POINTS into DisplayContextMenu. - handled = true; - return this.DisplayContextMenu(selectedNodes, vaIn); - default: - break; - } - } - else if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - switch((VsCommands2K)cmdId) - { - case VsCommands2K.ViewInClassDiagram: - handled = true; - return this.ShowInDesigner(selectedNodes); - } - } - - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - /// - /// Executes commands that are independent of a selection. - /// - /// Unique identifier of the command group - /// The command to be executed. - /// Values describe how the object should execute the command. - /// Pointer to a VARIANTARG structure containing input arguments. Can be NULL - /// VARIANTARG structure to receive command output. Can be NULL. - /// The origin of the command. From IOleCommandTarget or hierarchy. - /// An out parameter specifying that the command was handled. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "vaIn")] - protected virtual int ExecCommandIndependentOfSelection(Guid cmdGroup, uint cmdId, uint cmdExecOpt, IntPtr vaIn, IntPtr vaOut, CommandOrigin commandOrigin, out bool handled) - { - handled = false; - - if(this.projectMgr == null || this.projectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - if(cmdGroup == VsMenus.guidStandardCommandSet97) - { - if(commandOrigin == CommandOrigin.OleCommandTarget) - { - switch((VsCommands)cmdId) - { - case VsCommands.Cut: - case VsCommands.Copy: - case VsCommands.Paste: - case VsCommands.Rename: - handled = true; - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - } - - switch((VsCommands)cmdId) - { - case VsCommands.Copy: - handled = true; - return this.ProjectMgr.CopyToClipboard(); - - case VsCommands.Cut: - handled = true; - return this.ProjectMgr.CutToClipboard(); - - case VsCommands.SolutionCfg: - handled = true; - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - - case VsCommands.SearchCombo: - handled = true; - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - - } - } - else if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - // There should only be the project node who handles these and should manifest in the same action regardles of selection. - switch((VsCommands2K)cmdId) - { - case VsCommands2K.SHOWALLFILES: - handled = true; - return this.projectMgr.ShowAllFiles(); - case VsCommands2K.ADDREFERENCE: - handled = true; - return this.projectMgr.AddProjectReference(); - case VsCommands2K.ADDWEBREFERENCE: - handled = true; - return this.projectMgr.AddWebReference(); - } - } - - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - /// - /// The main entry point for command excection. Gets called from the IVsUIHierarchy and IOleCommandTarget methods. - /// - /// Unique identifier of the command group - /// The command to be executed. - /// Values describe how the object should execute the command. - /// Pointer to a VARIANTARG structure containing input arguments. Can be NULL - /// VARIANTARG structure to receive command output. Can be NULL. - /// The origin of the command. From IOleCommandTarget or hierarchy. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "vaIn")] - protected virtual int InternalExecCommand(Guid cmdGroup, uint cmdId, uint cmdExecOpt, IntPtr vaIn, IntPtr vaOut, CommandOrigin commandOrigin) - { - CCITracing.TraceCall(cmdGroup.ToString() + "," + cmdId.ToString()); - if(this.projectMgr == null || this.projectMgr.IsClosed) - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - if(cmdGroup == Guid.Empty) - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - IList selectedNodes = this.projectMgr.GetSelectedNodes(); - - // Check if all nodes can execute a command. If there is at least one that cannot return not handled. - foreach(HierarchyNode node in selectedNodes) - { - if(!node.CanExecuteCommand) - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - } - - // Handle commands that are independent of a selection. - bool handled = false; - int returnValue = this.ExecCommandIndependentOfSelection(cmdGroup, cmdId, cmdExecOpt, vaIn, vaOut, commandOrigin, out handled); - if(handled) - { - return returnValue; - } - - - // Now handle commands that need the selected nodes as input parameter. - returnValue = this.ExecCommandThatDependsOnSelectedNodes(cmdGroup, cmdId, cmdExecOpt, vaIn, vaOut, commandOrigin, selectedNodes, out handled); - if(handled) - { - return returnValue; - } - - returnValue = (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - - // Handle commands iteratively. The same action will be executed for all of the selected items. - foreach(HierarchyNode node in selectedNodes) - { - try - { - returnValue = node.ExecCommandOnNode(cmdGroup, cmdId, cmdExecOpt, vaIn, vaOut); - } - catch(COMException e) - { - Trace.WriteLine("Exception : " + e.Message); - returnValue = e.ErrorCode; - } - if(returnValue != VSConstants.S_OK) - { - break; - } - } - - if(returnValue == VSConstants.E_ABORT || returnValue == VSConstants.OLE_E_PROMPTSAVECANCELLED) - { - returnValue = VSConstants.S_OK; - } - - return returnValue; - } - - #endregion - - #region query command handling - /// - /// Handles menus originating from IOleCommandTarget. - /// - /// Unique identifier of the command group - /// The command to be executed. - /// Specifies whether the menu was handled. - /// A QueryStatusResult describing the status of the menu. - protected virtual QueryStatusResult QueryStatusCommandFromOleCommandTarget(Guid cmdGroup, uint cmd, out bool handled) - { - handled = false; - // NOTE: We only want to support Cut/Copy/Paste/Delete/Rename commands - // if focus is in the project window. This means that we should only - // support these commands if they are dispatched via IVsUIHierarchy - // interface and not if they are dispatch through IOleCommandTarget - // during the command routing to the active project/hierarchy. - if(VsMenus.guidStandardCommandSet97 == cmdGroup) - { - - switch((VsCommands)cmd) - { - case VsCommands.Copy: - case VsCommands.Paste: - case VsCommands.Cut: - case VsCommands.Rename: - handled = true; - return QueryStatusResult.NOTSUPPORTED; - - case VsCommands.Refresh: // !EFW - Added support for Refresh - handled = true; - return QueryStatusResult.ENABLED | QueryStatusResult.SUPPORTED; - } - } - // The reference menu and the web reference menu should always be shown. - else if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - switch((VsCommands2K)cmd) - { - case VsCommands2K.ADDREFERENCE: - case VsCommands2K.SLNREFRESH: // !EFW - Added support for Refresh - handled = true; - return QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - } - } - return QueryStatusResult.NOTSUPPORTED; - } - - /// - /// Specifies which command does not support multiple selection and should be disabled if multi-selected. - /// - /// Unique identifier of the command group - /// The command to be executed. - /// The list of selected nodes. - /// Specifies whether the menu was handled. - /// A QueryStatusResult describing the status of the menu. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi")] - protected virtual QueryStatusResult DisableCommandOnNodesThatDoNotSupportMultiSelection(Guid cmdGroup, uint cmd, IList selectedNodes, out bool handled) - { - handled = false; - QueryStatusResult queryResult = QueryStatusResult.NOTSUPPORTED; - if(selectedNodes == null || selectedNodes.Count == 1) - { - return queryResult; - } - - if(VsMenus.guidStandardCommandSet97 == cmdGroup) - { - switch((VsCommands)cmd) - { - case VsCommands.Cut: - case VsCommands.Copy: - // If the project node is selected then cut and copy is not supported. - if(selectedNodes.Contains(this.projectMgr)) - { - queryResult = QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; - handled = true; - } - break; - - case VsCommands.Paste: - case VsCommands.NewFolder: - queryResult = QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; - handled = true; - break; - } - } - else if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - switch((VsCommands2K)cmd) - { - case VsCommands2K.QUICKOBJECTSEARCH: - case VsCommands2K.SETASSTARTPAGE: - case VsCommands2K.ViewInClassDiagram: - queryResult = QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; - handled = true; - break; - } - } - - return queryResult; - } - - /// - /// Handles command status on a node. Should be overridden by descendant nodes. If a command cannot be handled then the base should be called. - /// - /// A unique identifier of the command group. The pguidCmdGroup parameter can be NULL to specify the standard group. - /// The command to query status for. - /// Pointer to an OLECMDTEXT structure in which to return the name and/or status information of a single command. Can be NULL to indicate that the caller does not require this information. - /// An out parameter specifying the QueryStatusResult of the command. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "p")] - protected virtual int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result) - { - // !EFW - Added support for Refresh - if(cmdGroup == VsMenus.guidStandardCommandSet97 && (VsCommands)cmd == VsCommands.Refresh) - { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - - if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - // !EFW - Added support for Show All Files and Refresh Solution - switch ((VsCommands2K)cmd) - { - case VsCommands2K.SHOWALLFILES: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - - if(this.projectMgr.ShowingAllFiles) - result |= QueryStatusResult.LATCHED; - - return VSConstants.S_OK; - - case VsCommands2K.SLNREFRESH: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } - - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - /// - /// Disables commands when the project is in run/break mode. - /// / - /// Unique identifier of the command group - /// The command to be executed. - /// A QueryStatusResult describing the status of the menu. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "InCurrent")] - protected virtual bool DisableCmdInCurrentMode(Guid commandGroup, uint command) - { - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return false; - } - - // Don't ask if it is not these two commandgroups. - if(commandGroup == VsMenus.guidStandardCommandSet97 || commandGroup == VsMenus.guidStandardCommandSet2K) - { - if(this.ProjectMgr.IsCurrentStateASuppressCommandsMode()) - { - if(commandGroup == VsMenus.guidStandardCommandSet97) - { - switch((VsCommands)command) - { - default: - break; - case VsCommands.AddExistingItem: - case VsCommands.AddNewItem: - case VsCommands.NewFolder: - case VsCommands.Remove: - case VsCommands.Cut: - case VsCommands.Paste: - case VsCommands.Copy: - case VsCommands.EditLabel: - case VsCommands.Rename: - case VsCommands.UnloadProject: - return true; - } - } - else if(commandGroup == VsMenus.guidStandardCommandSet2K) - { - switch((VsCommands2K)command) - { - default: - break; - case VsCommands2K.EXCLUDEFROMPROJECT: - case VsCommands2K.INCLUDEINPROJECT: - case VsCommands2K.ADDWEBREFERENCECTX: - case VsCommands2K.ADDWEBREFERENCE: - case VsCommands2K.ADDREFERENCE: - case VsCommands2K.SETASSTARTPAGE: - return true; - } - } - } - // If we are not in a cut or copy mode then disable the paste command - else if(!this.ProjectMgr.AllowPasteCommand()) - { - if(commandGroup == VsMenus.guidStandardCommandSet97 && (VsCommands)command == VsCommands.Paste) - { - return true; - } - } - } - - return false; - } - - - /// - /// Queries the object for the command status on a list of selected nodes. - /// - /// A unique identifier of the command group. - /// The number of commands in the prgCmds array - /// A caller-allocated array of OLECMD structures that indicate the commands for which the caller requires status information. This method fills the cmdf member of each structure with values taken from the OLECMDF enumeration - /// Pointer to an OLECMDTEXT structure in which to return the name and/or status information of a single command. Can be NULL to indicate that the caller does not require this information. - /// Specifies the origin of the command. Either it was called from the QueryStatusCommand on IVsUIHierarchy or from the IOleCommandTarget - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cmds")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "c")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "p")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "prg")] - protected virtual int QueryStatusSelection(Guid cmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText, CommandOrigin commandOrigin) - { - if(this.projectMgr.IsClosed) - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - if(cmdGroup == Guid.Empty) - { - return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; - } - - if (prgCmds == null) - { - throw new ArgumentNullException("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 selectedNodes = this.projectMgr.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; - } - - /// - /// Queries the selected nodes for the command status. - /// A command is supported iff any nodes supports it. - /// A command is enabled iff all nodes enable it. - /// A command is invisible iff any node sets invisibility. - /// A command is latched only if all are latched. - /// - /// The list of selected nodes. - /// A unique identifier of the command group. - /// The command id to query for. - /// Pointer to an OLECMDTEXT structure in which to return the name and/or status information of a single command. Can be NULL to indicate that the caller does not require this information. - /// Retuns the result of the query on the slected nodes. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "p")] - protected virtual QueryStatusResult QueryStatusSelectionOnNodes(IList selectedNodes, Guid cmdGroup, uint cmd, IntPtr pCmdText) - { - if(selectedNodes == null || selectedNodes.Count == 0) - { - return QueryStatusResult.NOTSUPPORTED; - } - - int result = 0; - bool supported = false; - bool enabled = true; - bool invisible = false; - bool latched = true; - QueryStatusResult tempQueryResult = QueryStatusResult.NOTSUPPORTED; - - foreach(HierarchyNode node in selectedNodes) - { - result = node.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref tempQueryResult); - if(result < 0) - { - break; - } - - // cmd is supported iff any node supports cmd - // cmd is enabled iff all nodes enable cmd - // cmd is invisible iff any node sets invisibility - // cmd is latched only if all are latched. - supported = supported || ((tempQueryResult & QueryStatusResult.SUPPORTED) != 0); - enabled = enabled && ((tempQueryResult & QueryStatusResult.ENABLED) != 0); - invisible = invisible || ((tempQueryResult & QueryStatusResult.INVISIBLE) != 0); - latched = latched && ((tempQueryResult & QueryStatusResult.LATCHED) != 0); - } - - QueryStatusResult queryResult = QueryStatusResult.NOTSUPPORTED; - - if(result >= 0 && supported) - { - queryResult = QueryStatusResult.SUPPORTED; - - if(enabled) - { - queryResult |= QueryStatusResult.ENABLED; - } - - if(invisible) - { - queryResult |= QueryStatusResult.INVISIBLE; - } - - if(latched) - { - queryResult |= QueryStatusResult.LATCHED; - } - } - - return queryResult; - } - - #endregion - protected virtual bool CanDeleteItem(__VSDELETEITEMOPERATION deleteOperation) - { - return this.ProjectMgr.CanProjectDeleteItems; - } - - /// - /// Overwrite this method to tell that you support the default icon for this node. - /// - /// - protected virtual bool CanShowDefaultIcon() - { - return false; - } - - /// - /// Performs save as operation for an item after the save as dialog has been processed. - /// - /// A pointer to the rdt - /// The newName of the item - /// - protected virtual int AfterSaveItemAs(IntPtr docData, string newName) - { - throw new NotImplementedException(); - } - - /// - /// The method that does the cleanup. - /// - /// Is the Dispose called by some internal member, or it is called by from GC. - protected virtual void Dispose(bool disposing) - { - if(this.isDisposed) - { - return; - } - - if(disposing) - { - // This will dispose any subclassed project node that implements IDisposable. - if(this.oleServiceProvider != null) - { - // Dispose the ole service provider object. - this.oleServiceProvider.Dispose(); - } - } - - this.isDisposed = true; - } - - /// - /// Sets the VSADDFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnAddFiles - /// - /// The files to which an array of VSADDFILEFLAGS has to be specified. - /// - protected internal virtual VSADDFILEFLAGS[] GetAddFileFlags(string[] files) - { - if(files == null || files.Length == 0) - { - return new VSADDFILEFLAGS[1] { VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags }; - } - - VSADDFILEFLAGS[] addFileFlags = new VSADDFILEFLAGS[files.Length]; - - for(int i = 0; i < files.Length; i++) - { - addFileFlags[i] = VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags; - } - - return addFileFlags; - } - - /// - /// Sets the VSQUERYADDFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnQueryAddFiles - /// - /// The files to which an array of VSADDFILEFLAGS has to be specified. - /// - protected internal virtual VSQUERYADDFILEFLAGS[] GetQueryAddFileFlags(string[] files) - { - if(files == null || files.Length == 0) - { - return new VSQUERYADDFILEFLAGS[1] { VSQUERYADDFILEFLAGS.VSQUERYADDFILEFLAGS_NoFlags }; - } - - VSQUERYADDFILEFLAGS[] queryAddFileFlags = new VSQUERYADDFILEFLAGS[files.Length]; - - for(int i = 0; i < files.Length; i++) - { - queryAddFileFlags[i] = VSQUERYADDFILEFLAGS.VSQUERYADDFILEFLAGS_NoFlags; - } - - return queryAddFileFlags; - } - - /// - /// Sets the VSREMOVEFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnRemoveFiles - /// - /// The files to which an array of VSREMOVEFILEFLAGS has to be specified. - /// - protected internal virtual VSREMOVEFILEFLAGS[] GetRemoveFileFlags(string[] files) - { - if(files == null || files.Length == 0) - { - return new VSREMOVEFILEFLAGS[1] { VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags }; - } - - VSREMOVEFILEFLAGS[] removeFileFlags = new VSREMOVEFILEFLAGS[files.Length]; - - for(int i = 0; i < files.Length; i++) - { - removeFileFlags[i] = VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags; - } - - return removeFileFlags; - } - - /// - /// Sets the VSQUERYREMOVEFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnQueryRemoveFiles - /// - /// The files to which an array of VSQUERYREMOVEFILEFLAGS has to be specified. - /// - protected internal virtual VSQUERYREMOVEFILEFLAGS[] GetQueryRemoveFileFlags(string[] files) - { - if(files == null || files.Length == 0) - { - return new VSQUERYREMOVEFILEFLAGS[1] { VSQUERYREMOVEFILEFLAGS.VSQUERYREMOVEFILEFLAGS_NoFlags }; - } - - VSQUERYREMOVEFILEFLAGS[] queryRemoveFileFlags = new VSQUERYREMOVEFILEFLAGS[files.Length]; - - for(int i = 0; i < files.Length; i++) - { - queryRemoveFileFlags[i] = VSQUERYREMOVEFILEFLAGS.VSQUERYREMOVEFILEFLAGS_NoFlags; - } - - return queryRemoveFileFlags; - } - - /// - /// This method should be overridden to provide the list of files and associated flags for source control. - /// - /// The list of files to be placed under source control. - /// The flags that are associated to the files. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - protected internal virtual void GetSccFiles(IList files, IList flags) - { - if(this.ExcludeNodeFromScc) - { - return; - } - - if(files == null) - { - throw new ArgumentNullException("files"); - } - - if(flags == null) - { - throw new ArgumentNullException("flags"); - } - - files.Add(this.GetMkDocument()); - - tagVsSccFilesFlags flagsToAdd = (this.firstChild != null && (this.firstChild is DependentFileNode)) ? tagVsSccFilesFlags.SFF_HasSpecialFiles : tagVsSccFilesFlags.SFF_NoFlags; - - flags.Add(flagsToAdd); - } - - /// - /// This method should be overridden to provide the list of special files and associated flags for source control. - /// - /// One of the file associated to the node. - /// The list of files to be placed under source control. - /// The flags that are associated to the files. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "scc")] - protected internal virtual void GetSccSpecialFiles(string sccFile, IList files, IList flags) - { - if(this.ExcludeNodeFromScc) - { - return; - } - - if(files == null) - { - throw new ArgumentNullException("files"); - } - - if(flags == null) - { - throw new ArgumentNullException("flags"); - } - } - - /// - /// Delete the item corresponding to the specified path from storage. - /// - /// Url of the item to delete - internal protected virtual void DeleteFromStorage(string path) - { - } - - /// - /// Determines whether a file change should be ignored or not. - /// - /// Flag indicating whether or not to ignore changes (true to ignore changes). - protected internal virtual void IgnoreItemFileChanges(bool ignoreFlag) - { - } - - /// - /// Called to determine whether a project item is reloadable. - /// - /// True if the project item is reloadable. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Reloadable")] - protected internal virtual bool IsItemReloadable() - { - return true; - } - - /// - /// Reloads an item. - /// - /// Reserved parameter defined at the IVsPersistHierarchyItem2::ReloadItem parameter. - protected internal virtual void ReloadItem(uint reserved) - { - - } - - /// - /// Handle the Copy operation to the clipboard - /// This method is typically overriden on the project node - /// - protected internal virtual int CopyToClipboard() - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Handle the Cut operation to the clipboard - /// This method is typically overriden on the project node - /// - protected internal virtual int CutToClipboard() - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Handle the paste from Clipboard command. - /// This method is typically overriden on the project node - /// - protected internal virtual int PasteFromClipboard(HierarchyNode targetNode) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Determines if the paste command should be allowed. - /// This method is typically overriden on the project node - /// - protected internal virtual bool AllowPasteCommand() - { - return false; ; - } - - /// - /// Register/Unregister for Clipboard events for the UiHierarchyWindow (solution explorer) - /// This method is typically overriden on the project node - /// - /// true for register, false for unregister - protected internal virtual void RegisterClipboardNotifications(bool value) - { - return; - } - #endregion - - #region public methods - - public void OnItemAdded(HierarchyNode parent, HierarchyNode child) - { - if (parent == null) - { - throw new ArgumentNullException("parent"); - } - - if (child == null) - { - throw new ArgumentNullException("child"); - } - - if(null != parent.onChildAdded) - { - HierarchyNodeEventArgs args = new HierarchyNodeEventArgs(child); - parent.onChildAdded(parent, args); - } - - HierarchyNode foo; - foo = this.projectMgr == null ? this : this.projectMgr; - - if(foo == this.projectMgr && (this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerHierarchyEvents) != 0) - { - return; - } - - HierarchyNode prev = child.PreviousSibling; - uint prevId = (prev != null) ? prev.hierarchyId : VSConstants.VSITEMID_NIL; - foreach(IVsHierarchyEvents sink in foo.hierarchyEventSinks) - { - int result = sink.OnItemAdded(parent.hierarchyId, prevId, child.hierarchyId); - if(ErrorHandler.Failed(result) && result != VSConstants.E_NOTIMPL) - { - ErrorHandler.ThrowOnFailure(result); - } - } - } - - - public virtual void OnItemDeleted() - { - HierarchyNode foo; - foo = this.projectMgr == null ? this : this.projectMgr; - - if(foo == this.projectMgr && (this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerHierarchyEvents) != 0) - { - return; - } - - if(foo.hierarchyEventSinks.Count > 0) - { - // Note that in some cases (deletion of project node for example), an Advise - // may be removed while we are iterating over it. To get around this problem we - // take a snapshot of the advise list and walk that. - List clonedSink = new List(); - - foreach(IVsHierarchyEvents anEvent in foo.hierarchyEventSinks) - { - clonedSink.Add(anEvent); - } - - foreach(IVsHierarchyEvents clonedEvent in clonedSink) - { - int result = clonedEvent.OnItemDeleted(this.hierarchyId); - if(ErrorHandler.Failed(result) && result != VSConstants.E_NOTIMPL) - { - ErrorHandler.ThrowOnFailure(result); - } - } - } - } - - public void OnItemsAppended(HierarchyNode parent) - { - if(parent == null) - { - throw new ArgumentNullException("parent"); - } - - HierarchyNode foo; - foo = this.projectMgr == null ? this : this.projectMgr; - - if(foo == this.projectMgr && (this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerHierarchyEvents) != 0) - { - return; - } - - foreach(IVsHierarchyEvents sink in foo.hierarchyEventSinks) - { - int result = sink.OnItemsAppended(parent.hierarchyId); - - if(ErrorHandler.Failed(result) && result != VSConstants.E_NOTIMPL) - { - ErrorHandler.ThrowOnFailure(result); - } - } - } - - - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "propid")] - public void OnPropertyChanged(HierarchyNode node, int propid, uint flags) - { - if(node == null) - { - throw new ArgumentNullException("node"); - } - HierarchyNode foo; - foo = this.projectMgr == null ? this : this.projectMgr; - if(foo == this.projectMgr && (this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerHierarchyEvents) != 0) - { - return; - } - - foreach(IVsHierarchyEvents sink in foo.hierarchyEventSinks) - { - int result = sink.OnPropertyChanged(node.hierarchyId, propid, flags); - - if(ErrorHandler.Failed(result) && result != VSConstants.E_NOTIMPL) - { - ErrorHandler.ThrowOnFailure(result); - } - } - } - - - public void OnInvalidateItems(HierarchyNode parent) - { - if(parent == null) - { - throw new ArgumentNullException("parent"); - } - HierarchyNode foo; - foo = this.projectMgr == null ? this : this.projectMgr; - if(foo == this.projectMgr && (this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerHierarchyEvents) != 0) - { - return; - } - - foreach(IVsHierarchyEvents sink in foo.hierarchyEventSinks) - { - int result = sink.OnInvalidateItems(parent.hierarchyId); - - if(ErrorHandler.Failed(result) && result != VSConstants.E_NOTIMPL) - { - ErrorHandler.ThrowOnFailure(result); - } - } - } - - /// - /// Causes the hierarchy to be redrawn. - /// - /// Used by the hierarchy to decide which element to redraw - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Re")] - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "ReDraw")] - public virtual void ReDraw(UIHierarchyElement element) - { - - foreach(IVsHierarchyEvents sink in this.projectMgr.hierarchyEventSinks) - { - int result; - if((element & UIHierarchyElement.Icon) != 0) - { - result = sink.OnPropertyChanged(this.ID, (int)__VSHPROPID.VSHPROPID_IconIndex, 0); - Debug.Assert(ErrorHandler.Succeeded(result), "Redraw failed for node " + this.GetMkDocument()); - } - - if((element & UIHierarchyElement.Caption) != 0) - { - result = sink.OnPropertyChanged(this.ID, (int)__VSHPROPID.VSHPROPID_Caption, 0); - Debug.Assert(ErrorHandler.Succeeded(result), "Redraw failed for node " + this.GetMkDocument()); - } - - if((element & UIHierarchyElement.SccState) != 0) - { - result = sink.OnPropertyChanged(this.ID, (int)__VSHPROPID.VSHPROPID_StateIconIndex, 0); - Debug.Assert(ErrorHandler.Succeeded(result), "Redraw failed for node " + this.GetMkDocument()); - } - } - - } - - /// - /// Finds a non virtual hierarchy item by its project element. - /// - /// The Project element to find - /// The node found - public HierarchyNode FindChildByProjectElement(ProjectElement node) - { - if(node == null) - { - throw new ArgumentNullException("node"); - } - - for(HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) - { - if(!child.ItemNode.IsVirtual && child.ItemNode == node) - { - return child; - } - } - return null; - } - - public object GetService(Type type) - { - if(type == null) - { - throw new ArgumentNullException("type"); - } - - if(this.projectMgr.Site == null) return null; - return this.projectMgr.Site.GetService(type); - } - - - #endregion - - #region IDisposable - /// - /// The IDispose interface Dispose method for disposing the object determinastically. - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - #region IVsHierarchy methods - - public virtual int AdviseHierarchyEvents(IVsHierarchyEvents sink, out uint cookie) - { - cookie = this.hierarchyEventSinks.Add(sink) + 1; - return VSConstants.S_OK; - } - - - public virtual int Close() - { - DocumentManager manager = this.GetDocumentManager(); - try - { - if(manager != null) - { - manager.Close(__FRAMECLOSE.FRAMECLOSE_PromptSave); - } - - } - catch { } - finally - { - this.Dispose(true); - } - - return VSConstants.S_OK; - } - - - public virtual int GetCanonicalName(uint itemId, out string name) - { - HierarchyNode n = this.projectMgr.NodeFromItemId(itemId); - name = (n != null) ? n.GetCanonicalName() : null; - return VSConstants.S_OK; - } - - - public virtual int GetGuidProperty(uint itemId, int propid, out Guid guid) - { - guid = Guid.Empty; - HierarchyNode n = this.projectMgr.NodeFromItemId(itemId); - if(n != null) - { - int hr = n.GetGuidProperty(propid, out guid); - __VSHPROPID vspropId = (__VSHPROPID)propid; - CCITracing.TraceCall(vspropId.ToString() + "=" + guid.ToString()); - return hr; - } - if(guid == Guid.Empty) - { - return VSConstants.DISP_E_MEMBERNOTFOUND; - } - return VSConstants.S_OK; - } - - - public virtual int GetProperty(uint itemId, int propId, out object propVal) - { - propVal = null; - if(itemId != VSConstants.VSITEMID_ROOT && propId == (int)__VSHPROPID.VSHPROPID_IconImgList) - { - return VSConstants.DISP_E_MEMBERNOTFOUND; - } - - - HierarchyNode n = this.projectMgr.NodeFromItemId(itemId); - if(n != null) - { - propVal = n.GetProperty(propId); - } - if(propVal == null) - { - return VSConstants.DISP_E_MEMBERNOTFOUND; - } - return VSConstants.S_OK; - } - - - public virtual int GetNestedHierarchy(uint itemId, ref Guid iidHierarchyNested, out IntPtr ppHierarchyNested, out uint pItemId) - { - ppHierarchyNested = IntPtr.Zero; - pItemId = 0; - // If itemid is not a nested hierarchy we must return E_FAIL. - return VSConstants.E_FAIL; - } - - - public virtual int GetSite(out Microsoft.VisualStudio.OLE.Interop.IServiceProvider site) - { - site = this.projectMgr.Site.GetService(typeof(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider; - return VSConstants.S_OK; - } - - - /// - /// the canonicalName of an item is it's URL, or better phrased, - /// the persistence data we put into @RelPath, which is a relative URL - /// to the root project - /// returning the itemID from this means scanning the list - /// - /// - /// - public virtual int ParseCanonicalName(string name, out uint itemId) - { - // we always start at the current node and go it's children down, so - // if you want to scan the whole tree, better call - // the root - uint notFoundValue = (uint)VSConstants.VSITEMID.Nil; - itemId = notFoundValue; - - // The default implemenation will check for case insensitive comparision. - if(String.Equals(name, this.Url, StringComparison.OrdinalIgnoreCase)) - { - itemId = this.hierarchyId; - return VSConstants.S_OK; - } - if(this.firstChild != null) - { - this.firstChild.ParseCanonicalName(name, out itemId); - } - if (itemId == notFoundValue && this.nextSibling != null) - { - this.nextSibling.ParseCanonicalName(name, out itemId); - } - - return itemId == notFoundValue ? VSConstants.E_FAIL : VSConstants.S_OK; - } - - - public virtual int QueryClose(out int fCanClose) - { - fCanClose = 1; - return VSConstants.S_OK; - } - - - public virtual int SetGuidProperty(uint itemId, int propid, ref Guid guid) - { - HierarchyNode n = this.projectMgr.NodeFromItemId(itemId); - int rc = VSConstants.E_INVALIDARG; - if(n != null) - { - rc = n.SetGuidProperty(propid, ref guid); - } - return rc; - } - - - public virtual int SetProperty(uint itemId, int propid, object value) - { - HierarchyNode n = this.projectMgr.NodeFromItemId(itemId); - if(n != null) - { - return n.SetProperty(propid, value); - } - else - { - return VSConstants.DISP_E_MEMBERNOTFOUND; - } - } - - - public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site) - { - return VSConstants.E_NOTIMPL; - } - - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId = "cookie-1")] - public virtual int UnadviseHierarchyEvents(uint cookie) - { - this.hierarchyEventSinks.RemoveAt(cookie - 1); - return VSConstants.S_OK; - } - - - public int Unused0() - { - return VSConstants.E_NOTIMPL; - } - - - public int Unused1() - { - return VSConstants.E_NOTIMPL; - } - - - public int Unused2() - { - return VSConstants.E_NOTIMPL; - } - - - public int Unused3() - { - return VSConstants.E_NOTIMPL; - } - - - public int Unused4() - { - return VSConstants.E_NOTIMPL; - } - #endregion - - #region IVsUIHierarchy methods - - public virtual int ExecCommand(uint itemId, ref Guid guidCmdGroup, uint nCmdId, uint nCmdExecOpt, IntPtr pvain, IntPtr p) - { - return this.InternalExecCommand(guidCmdGroup, nCmdId, nCmdExecOpt, pvain, p, CommandOrigin.UiHierarchy); - } - - public virtual int QueryStatusCommand(uint itemId, ref Guid guidCmdGroup, uint cCmds, OLECMD[] cmds, IntPtr pCmdText) - { - return this.QueryStatusSelection(guidCmdGroup, cCmds, cmds, pCmdText, CommandOrigin.UiHierarchy); - } - #endregion - - #region IVsPersistHierarchyItem2 methods - - /// - /// Determines whether the hierarchy item changed. - /// - /// Item identifier of the hierarchy item contained in VSITEMID. - /// Pointer to the IUnknown interface of the hierarchy item. - /// true if the hierarchy item changed. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int IsItemDirty(uint itemId, IntPtr docData, out int isDirty) - { - IVsPersistDocData pd = (IVsPersistDocData)Marshal.GetObjectForIUnknown(docData); - return ErrorHandler.ThrowOnFailure(pd.IsDocDataDirty(out isDirty)); - } - - /// - /// Saves the hierarchy item to disk. - /// - /// Flags whose values are taken from the VSSAVEFLAGS enumeration. - /// New filename when doing silent save as - /// Item identifier of the hierarchy item saved from VSITEMID. - /// Item identifier of the hierarchy item saved from VSITEMID. - /// [out] true if the save action was canceled. - /// [out] true if the save action was canceled. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - public virtual int SaveItem(VSSAVEFLAGS saveFlag, string silentSaveAsName, uint itemid, IntPtr docData, out int cancelled) - { - cancelled = 0; - - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - // Validate itemid - if(itemid == VSConstants.VSITEMID_ROOT || itemid == VSConstants.VSITEMID_SELECTION) - { - return VSConstants.E_INVALIDARG; - } - - HierarchyNode node = this.ProjectMgr.NodeFromItemId(itemid); - if(node == null) - { - return VSConstants.E_FAIL; - } - - string existingFileMoniker = node.GetMkDocument(); - - // We can only perform save if the document is open - if(docData == IntPtr.Zero) - { - string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.GetString(SR.CanNotSaveFileNotOpeneInEditor, CultureInfo.CurrentUICulture), node.Url); - throw new InvalidOperationException(errorMessage); - } - - string docNew = String.Empty; - int returnCode = VSConstants.S_OK; - IPersistFileFormat ff = null; - IVsPersistDocData dd = null; - IVsUIShell shell = this.projectMgr.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; - - if(shell == null) - { - return VSConstants.E_FAIL; - } - - try - { - //Save docdata object. - //For the saveas action a dialog is show in order to enter new location of file. - //In case of a save action and the file is readonly a dialog is also shown - //with a couple of options, SaveAs, Overwrite or Cancel. - ff = Marshal.GetObjectForIUnknown(docData) as IPersistFileFormat; - if(ff == null) - { - return VSConstants.E_FAIL; - } - if(VSSAVEFLAGS.VSSAVE_SilentSave == saveFlag) - { - ErrorHandler.ThrowOnFailure(shell.SaveDocDataToFile(saveFlag, ff, silentSaveAsName, out docNew, out cancelled)); - } - else - { - dd = Marshal.GetObjectForIUnknown(docData) as IVsPersistDocData; - if(dd == null) - { - return VSConstants.E_FAIL; - } - ErrorHandler.ThrowOnFailure(dd.SaveDocData(saveFlag, out docNew, out cancelled)); - } - - // We can be unloaded after the SaveDocData() call if the save caused a designer to add a file and this caused - // the project file to be reloaded (QEQS caused a newer version of the project file to be downloaded). So we check - // here. - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - cancelled = 1; - return (int)OleConstants.OLECMDERR_E_CANCELED; - } - else - { - // if a SaveAs occurred we need to update to the fact our item's name has changed. - // this includes the following: - // 1. call RenameDocument on the RunningDocumentTable - // 2. update the full path name for the item in our hierarchy - // 3. a directory-based project may need to transfer the open editor to the - // MiscFiles project if the new file is saved outside of the project directory. - // This is accomplished by calling IVsExternalFilesManager::TransferDocument - - // we have three options for a saveas action to be performed - // 1. the flag was set (the save as command was triggered) - // 2. a silent save specifying a new document name - // 3. a save command was triggered but was not possible because the file has a read only attrib. Therefore - // the user has chosen to do a save as in the dialog that showed up - bool emptyOrSamePath = String.IsNullOrEmpty(docNew) || NativeMethods.IsSamePath(existingFileMoniker, docNew); - bool saveAs = ((saveFlag == VSSAVEFLAGS.VSSAVE_SaveAs)) || - ((saveFlag == VSSAVEFLAGS.VSSAVE_SilentSave) && !emptyOrSamePath) || - ((saveFlag == VSSAVEFLAGS.VSSAVE_Save) && !emptyOrSamePath); - - if(saveAs) - { - returnCode = node.AfterSaveItemAs(docData, docNew); - - // If it has been cancelled recover the old name. - if((returnCode == (int)OleConstants.OLECMDERR_E_CANCELED || returnCode == VSConstants.E_ABORT)) - { - // Cleanup. - this.DeleteFromStorage(docNew); - if(this is ProjectNode && File.Exists(docNew)) - { - File.Delete(docNew); - } - - if(ff != null) - { - returnCode = shell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SilentSave, ff, existingFileMoniker, out docNew, out cancelled); - } - } - else if(returnCode != VSConstants.S_OK) - { - ErrorHandler.ThrowOnFailure(returnCode); - } - } - } - } - catch(COMException e) - { - Trace.WriteLine("Exception :" + e.Message); - returnCode = e.ErrorCode; - - // Try to recover - if(ff != null) - { - ErrorHandler.ThrowOnFailure(shell.SaveDocDataToFile(VSSAVEFLAGS.VSSAVE_SilentSave, ff, existingFileMoniker, out docNew, out cancelled)); - } - } - - return returnCode; - } - - /// - /// Flag indicating that changes to a file can be ignored when item is saved or reloaded. - /// - /// Specifies the item id from VSITEMID. - /// Flag indicating whether or not to ignore changes (1 to ignore, 0 to stop ignoring). - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int IgnoreItemFileChanges(uint itemId, int ignoreFlag) - { - #region precondition - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - #endregion - - HierarchyNode n = this.ProjectMgr.NodeFromItemId(itemId); - if(n != null) - { - n.IgnoreItemFileChanges(ignoreFlag == 0 ? false : true); - } - - return VSConstants.S_OK; - } - - /// - /// Called to determine whether a project item is reloadable before calling ReloadItem. - /// - /// Item identifier of an item in the hierarchy. Valid values are VSITEMID_NIL, VSITEMID_ROOT and VSITEMID_SELECTION. - /// A flag indicating that the project item is reloadable (1 for reloadable, 0 for non-reloadable). - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Reloadable")] - public virtual int IsItemReloadable(uint itemId, out int isReloadable) - { - isReloadable = 0; - - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - HierarchyNode n = this.ProjectMgr.NodeFromItemId(itemId); - if(n != null) - { - isReloadable = (n.IsItemReloadable()) ? 1 : 0; - } - - return VSConstants.S_OK; - } - - /// - /// Called to reload a project item. - /// - /// Specifies itemid from VSITEMID. - /// Reserved. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int ReloadItem(uint itemId, uint reserved) - { - #region precondition - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - #endregion - - HierarchyNode n = this.ProjectMgr.NodeFromItemId(itemId); - if(n != null) - { - n.ReloadItem(reserved); - } - - return VSConstants.S_OK; - } - #endregion - - #region IOleCommandTarget methods - /// - /// CommandTarget.Exec is called for most major operations if they are NOT UI based. Otherwise IVSUInode::exec is called first - /// - public virtual int Exec(ref Guid guidCmdGroup, uint nCmdId, uint nCmdExecOpt, IntPtr pvaIn, IntPtr pvaOut) - { - return this.InternalExecCommand(guidCmdGroup, nCmdId, nCmdExecOpt, pvaIn, pvaOut, CommandOrigin.OleCommandTarget); - } - - /// - /// Queries the object for the command status - /// - /// we only support one command at a time, i.e. the first member in the OLECMD array - public virtual int QueryStatus(ref Guid guidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) - { - return this.QueryStatusSelection(guidCmdGroup, cCmds, prgCmds, pCmdText, CommandOrigin.OleCommandTarget); - } - #endregion - - #region IVsHierarchyDeleteHandler methods - - public virtual int DeleteItem(uint delItemOp, uint itemId) - { - if(itemId == VSConstants.VSITEMID_SELECTION) - { - return VSConstants.E_INVALIDARG; - } - - HierarchyNode node = this.projectMgr.NodeFromItemId(itemId); - if(node != null) - { - node.Remove((delItemOp & (uint)__VSDELETEITEMOPERATION.DELITEMOP_DeleteFromStorage) != 0); - return VSConstants.S_OK; - } - - return VSConstants.E_FAIL; - } - - - public virtual int QueryDeleteItem(uint delItemOp, uint itemId, out int candelete) - { - candelete = 0; - if(itemId == VSConstants.VSITEMID_SELECTION) - { - return VSConstants.E_INVALIDARG; - } - - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - // We ask the project what state it is. If he is a state that should not allow delete then we return. - if(this.ProjectMgr.IsCurrentStateASuppressCommandsMode()) - { - return VSConstants.S_OK; - } - - HierarchyNode node = this.projectMgr.NodeFromItemId(itemId); - - if(node == null) - { - return VSConstants.E_FAIL; - } - - // Ask the nodes if they can remove the item. - bool canDeleteItem = node.CanDeleteItem((__VSDELETEITEMOPERATION)delItemOp); - if(canDeleteItem) - { - candelete = 1; - } - - return VSConstants.S_OK; - } - #endregion - - #region IVsHierarchyDropDataSource2 methods - - public virtual int GetDropInfo(out uint pdwOKEffects, out Microsoft.VisualStudio.OLE.Interop.IDataObject ppDataObject, out IDropSource ppDropSource) - { - pdwOKEffects = (uint)DropEffect.None; - ppDataObject = null; - ppDropSource = null; - return VSConstants.E_NOTIMPL; - } - - public virtual int OnDropNotify(int fDropped, uint dwEffects) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnBeforeDropNotify(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, uint dwEffect, out int fCancelDrop) - { - pDataObject = null; - fCancelDrop = 0; - return VSConstants.E_NOTIMPL; - } - #endregion - - #region IVsHierarchyDropDataTarget methods - - public virtual int DragEnter(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int DragLeave() - { - return VSConstants.E_NOTIMPL; - } - - public virtual int DragOver(uint grfKeyState, uint itemid, ref uint pdwEffect) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int Drop(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect) - { - return VSConstants.E_NOTIMPL; - } - #endregion - - #region helper methods - internal HierarchyNode FindChild(string name) - { - if(String.IsNullOrEmpty(name)) - { - return null; - } - - HierarchyNode result; - for(HierarchyNode child = this.firstChild; child != null; child = child.NextSibling) - { - if(!String.IsNullOrEmpty(child.VirtualNodeName) && String.Compare(child.VirtualNodeName, name, StringComparison.OrdinalIgnoreCase) == 0) - { - return child; - } - // If it is a foldernode then it has a virtual name but we want to find folder nodes by the document moniker or url - else if((String.IsNullOrEmpty(child.VirtualNodeName) || (child is FolderNode)) && - (NativeMethods.IsSamePath(child.GetMkDocument(), name) || NativeMethods.IsSamePath(child.Url, name))) - { - return child; - } - - result = child.FindChild(name); - if(result != null) - { - return result; - } - } - return null; - } - - /// - /// Recursively find all nodes of type T - /// - /// The type of hierachy node being serched for - /// A list of nodes of type T - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal void FindNodesOfType(List nodes) - where T : HierarchyNode - { - for(HierarchyNode n = this.FirstChild; n != null; n = n.NextSibling) - { - if(n is T) - { - T nodeAsT = (T)n; - nodes.Add(nodeAsT); - } - - n.FindNodesOfType(nodes); - } - } - - /// - /// Adds an item from a project refererence to target node. - /// - /// - /// - internal bool AddFileToNodeFromProjectReference(string projectRef, HierarchyNode targetNode) - { - if(String.IsNullOrEmpty(projectRef)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "projectRef"); - } - - if(targetNode == null) - { - throw new ArgumentNullException("targetNode"); - } - - IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution; - if(solution == null) - { - throw new InvalidOperationException(); - } - - uint itemidLoc; - IVsHierarchy hierarchy; - string str; - VSUPDATEPROJREFREASON[] reason = new VSUPDATEPROJREFREASON[1]; - ErrorHandler.ThrowOnFailure(solution.GetItemOfProjref(projectRef, out hierarchy, out itemidLoc, out str, reason)); - if(hierarchy == null) - { - throw new InvalidOperationException(); - } - - // This will throw invalid cast exception if the hierrachy is not a project. - IVsProject project = (IVsProject)hierarchy; - - string moniker; - ErrorHandler.ThrowOnFailure(project.GetMkDocument(itemidLoc, out moniker)); - string[] files = new String[1] { moniker }; - VSADDRESULT[] vsaddresult = new VSADDRESULT[1]; - vsaddresult[0] = VSADDRESULT.ADDRESULT_Failure; - int addResult = targetNode.ProjectMgr.AddItem(targetNode.ID, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, 0, files, IntPtr.Zero, vsaddresult); - if(addResult != VSConstants.S_OK && addResult != VSConstants.S_FALSE && addResult != (int)OleConstants.OLECMDERR_E_CANCELED) - { - ErrorHandler.ThrowOnFailure(addResult); - return false; - } - return (vsaddresult[0] == VSADDRESULT.ADDRESULT_Success); - } - - internal void InstantiateItemsDraggedOrCutOrCopiedList() - { - this.itemsDraggedOrCutOrCopied = new List(); - } - #endregion - - // !EFW - #region General helper methods - //===================================================================== - - /// - /// This helper method can be used to search for child nodes of the - /// given root node based on the specified criteria. Child nodes are - /// searched recursively. - /// - /// The root node to search - /// An optional predicate used to filter the - /// nodes or null to return them all. - public static IEnumerable FindNodes(HierarchyNode root, - Func predicate) - { - if(root == null) - throw new ArgumentNullException("root"); - - for(HierarchyNode child = root.FirstChild; child != null; child = child.NextSibling) - { - if(predicate == null || predicate(child)) - yield return child; - - if(child.FirstChild != null) - foreach(HierarchyNode n in FindNodes(child, predicate)) - yield return n; - } - } - #endregion - - // !EFW - #region Core Show All Files support - //===================================================================== - - // Core functionality implemented in HierarchyNode.cs: - // - Updated ExcludeNodeFromScc to return true for non-member items. - // - Added support for __VSHPROPID.VSHPROPID_IsNonMemberItem in GetProperty(). - // - Added support for __VSHPROPID.VSHPROPID_IsNonMemberItem in SetProperty(). - // - Updated GetEditLabel() to ignore the request for non-member items. - // - Updated QueryStatusOnNode() to latch the SHOWALLFILES command if toggled on. - // - Updated the Remove() method to handle removal of nodes when Show All Files is enabled. - // - Added the members below to support Show All Files and Include in Project. - - // See ProjectNode.cs for core functionality implemented in there. - // See FolderNode.cs for core functionality implemented in there. - // See FileNode.cs for core functionality implemented in there. - - /// - /// This is used to indicate whether or not the node is a non-member - /// item (the item is not part of the hierarchy). - /// - public bool IsNonMemberItem { get; set; } - - /// - /// This method converts a non-member node into a member node. - /// - /// Returns S_OK on success or an error code on failure - public virtual int IncludeInProject() - { - int result = VSConstants.S_OK; - - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - - // If not a non-member item, just ignore it - if(!this.IsNonMemberItem) - return result; - - if(!this.ProjectMgr.QueryEditProjectFile(false)) - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - - // Include all of the parent folders in the project as needed - result = this.EnsureParentFoldersAreIncluded(); - - if(result == VSConstants.S_OK) - { - // Add the project item - this.IsNonMemberItem = false; - - if(this is FileNode) - { - this.ItemNode = this.ProjectMgr.AddFileToMsBuild(this.Url); - this.ProjectMgr.Tracker.OnItemAdded(this.Url, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags); - } - else - this.ItemNode = this.ProjectMgr.AddFolderToMsBuild(this.Url); - - // Update the icon and source control state overlay - this.ReDraw(UIHierarchyElement.Icon | UIHierarchyElement.SccState); - - // Reset the properties so that they are recreated for the member node - this.ResetProperties(); - } - - return result; - } - - /// - /// Reset the properties so that they are recreated the next time they are requested - /// - protected void ResetProperties() - { - nodeProperties = null; - this.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_BrowseObject, 0); - - IVsUIShell vsuiShell = this.GetService(typeof(SVsUIShell)) as IVsUIShell; - - if(vsuiShell != null) - { - int hr = vsuiShell.RefreshPropertyBrowser(0); - - if(hr != 0) - Marshal.ThrowExceptionForHR(hr); - } - } - - /// - /// This is used to ensure that all parent folder nodes are included in - /// the project as member nodes. - /// - /// Returns S_OK on success or an error code on failure - protected int EnsureParentFoldersAreIncluded() - { - Stack stack = new Stack(); - int result = VSConstants.S_OK; - - // Get all non-member parent nodes if any - FolderNode parentNode = this.Parent as FolderNode; - - while(parentNode != null && parentNode.IsNonMemberItem) - { - stack.Push(parentNode); - parentNode = parentNode.Parent as FolderNode; - } - - // Add them to the project - while(stack.Count > 0 && result == VSConstants.S_OK) - { - parentNode = stack.Pop(); - parentNode.CreateDirectory(); - result = parentNode.IncludeInProject(); - } - - return result; - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/IDEBuildLogger.cs b/SHFB/Source/MPFProj_VS2010/IDEBuildLogger.cs deleted file mode 100644 index c26859b9..00000000 --- a/SHFB/Source/MPFProj_VS2010/IDEBuildLogger.cs +++ /dev/null @@ -1,658 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Windows.Forms.Design; -using System.Collections.Generic; -using System.Collections.Concurrent; -using System.Diagnostics; -using System.Globalization; -using System.Runtime.InteropServices; -using System.Text; -using System.Diagnostics.CodeAnalysis; -using System.Threading; -using System.Windows.Threading; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.TextManager.Interop; -using Microsoft.Win32; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// This class implements an MSBuild logger that output events to VS outputwindow and tasklist. - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDE")] - internal class IDEBuildLogger : Logger - { - #region fields - - // TODO: The buildVerbosityRegistryRoot should probably end in "\11.0" for the default if built for - // VS 2012. The ProjectNode class will set it properly at runtime though. - - // TODO: Remove these constants when we have a version that supports getting the verbosity using automation. - private string buildVerbosityRegistryRoot = @"Software\Microsoft\VisualStudio\10.0"; - private const string buildVerbosityRegistrySubKey = @"General"; - private const string buildVerbosityRegistryKey = "MSBuildLoggerVerbosity"; - - private int currentIndent; - private IVsOutputWindowPane outputWindowPane; - private string errorString = SR.GetString(SR.Error, CultureInfo.CurrentUICulture); - private string warningString = SR.GetString(SR.Warning, CultureInfo.CurrentUICulture); - private TaskProvider taskProvider; - private IVsHierarchy hierarchy; - private IServiceProvider serviceProvider; - private Dispatcher dispatcher; - private bool haveCachedVerbosity = false; - - // Queues to manage Tasks and Error output plus message logging - private ConcurrentQueue> taskQueue; - private ConcurrentQueue outputQueue; - - #endregion - - #region properties - - public IServiceProvider ServiceProvider - { - get { return this.serviceProvider; } - } - - public string WarningString - { - get { return this.warningString; } - set { this.warningString = value; } - } - - public string ErrorString - { - get { return this.errorString; } - set { this.errorString = value; } - } - - /// - /// When the build is not a "design time" (background or secondary) build this is True - /// - /// - /// The only known way to detect an interactive build is to check this.outputWindowPane for null. - /// - protected bool InteractiveBuild - { - get { return this.outputWindowPane != null; } - } - - /// - /// When building from within VS, setting this will - /// enable the logger to retrive the verbosity from - /// the correct registry hive. - /// - internal string BuildVerbosityRegistryRoot - { - get { return this.buildVerbosityRegistryRoot; } - set - { - this.buildVerbosityRegistryRoot = value; - } - } - - /// - /// Set to null to avoid writing to the output window - /// - internal IVsOutputWindowPane OutputWindowPane - { - get { return this.outputWindowPane; } - set { this.outputWindowPane = value; } - } - - #endregion - - #region ctors - - /// - /// Constructor. Inititialize member data. - /// - public IDEBuildLogger(IVsOutputWindowPane output, TaskProvider taskProvider, IVsHierarchy hierarchy) - { - if (taskProvider == null) - throw new ArgumentNullException("taskProvider"); - if (hierarchy == null) - throw new ArgumentNullException("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); - this.dispatcher = Dispatcher.CurrentDispatcher; - } - - #endregion - - #region overridden methods - - /// - /// Overridden from the Logger class. - /// - public override void Initialize(IEventSource eventSource) - { - if (null == eventSource) - { - throw new ArgumentNullException("eventSource"); - } - - this.taskQueue = new ConcurrentQueue>(); - this.outputQueue = new ConcurrentQueue(); - - 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(ErrorHandler); - eventSource.WarningRaised += new BuildWarningEventHandler(WarningHandler); - eventSource.MessageRaised += new BuildMessageEventHandler(MessageHandler); - } - - #endregion - - #region event delegates - - /// - /// This is the delegate for BuildStartedHandler events. - /// - protected virtual void BuildStartedHandler(object sender, BuildStartedEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - ClearCachedVerbosity(); - ClearQueuedOutput(); - ClearQueuedTasks(); - - QueueOutputEvent(MessageImportance.Low, buildEvent); - } - - /// - /// This is the delegate for BuildFinishedHandler events. - /// - /// - /// - protected virtual void BuildFinishedHandler(object sender, BuildFinishedEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - MessageImportance importance = buildEvent.Succeeded ? MessageImportance.Low : MessageImportance.High; - QueueOutputText(importance, Environment.NewLine); - QueueOutputEvent(importance, buildEvent); - - // flush output and error queues - ReportQueuedOutput(); - ReportQueuedTasks(); - } - - /// - /// This is the delegate for ProjectStartedHandler events. - /// - protected virtual void ProjectStartedHandler(object sender, ProjectStartedEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - QueueOutputEvent(MessageImportance.Low, buildEvent); - } - - /// - /// This is the delegate for ProjectFinishedHandler events. - /// - protected virtual void ProjectFinishedHandler(object sender, ProjectFinishedEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - QueueOutputEvent(buildEvent.Succeeded ? MessageImportance.Low : MessageImportance.High, buildEvent); - } - - /// - /// This is the delegate for TargetStartedHandler events. - /// - protected virtual void TargetStartedHandler(object sender, TargetStartedEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - QueueOutputEvent(MessageImportance.Low, buildEvent); - IndentOutput(); - } - - /// - /// This is the delegate for TargetFinishedHandler events. - /// - protected virtual void TargetFinishedHandler(object sender, TargetFinishedEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - UnindentOutput(); - QueueOutputEvent(MessageImportance.Low, buildEvent); - } - - /// - /// This is the delegate for TaskStartedHandler events. - /// - protected virtual void TaskStartedHandler(object sender, TaskStartedEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - QueueOutputEvent(MessageImportance.Low, buildEvent); - IndentOutput(); - } - - /// - /// This is the delegate for TaskFinishedHandler events. - /// - protected virtual void TaskFinishedHandler(object sender, TaskFinishedEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - UnindentOutput(); - QueueOutputEvent(MessageImportance.Low, buildEvent); - } - - /// - /// This is the delegate for CustomHandler events. - /// - /// - /// - protected virtual void CustomHandler(object sender, CustomBuildEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - QueueOutputEvent(MessageImportance.High, buildEvent); - } - - /// - /// This is the delegate for error events. - /// - protected virtual void ErrorHandler(object sender, BuildErrorEventArgs errorEvent) - { - // NOTE: This may run on a background thread! - QueueOutputText(GetFormattedErrorMessage(errorEvent.File, errorEvent.LineNumber, errorEvent.ColumnNumber, false, errorEvent.Code, errorEvent.Message)); - QueueTaskEvent(errorEvent); - } - - /// - /// This is the delegate for warning events. - /// - protected virtual void WarningHandler(object sender, BuildWarningEventArgs warningEvent) - { - // NOTE: This may run on a background thread! - QueueOutputText(MessageImportance.High, GetFormattedErrorMessage(warningEvent.File, warningEvent.LineNumber, warningEvent.ColumnNumber, true, warningEvent.Code, warningEvent.Message)); - QueueTaskEvent(warningEvent); - } - - /// - /// This is the delegate for Message event types - /// - protected virtual void MessageHandler(object sender, BuildMessageEventArgs messageEvent) - { - // NOTE: This may run on a background thread! - QueueOutputEvent(messageEvent.Importance, messageEvent); - } - - #endregion - - #region output queue - - protected void QueueOutputEvent(MessageImportance importance, BuildEventArgs buildEvent) - { - // NOTE: This may run on a background thread! - if (LogAtImportance(importance) && !string.IsNullOrEmpty(buildEvent.Message)) - { - StringBuilder message = new StringBuilder(this.currentIndent + buildEvent.Message.Length); - if (this.currentIndent > 0) - { - message.Append('\t', this.currentIndent); - } - message.AppendLine(buildEvent.Message); - - QueueOutputText(message.ToString()); - } - } - - protected void QueueOutputText(MessageImportance importance, string text) - { - // NOTE: This may run on a background thread! - if (LogAtImportance(importance)) - { - QueueOutputText(text); - } - } - - protected void QueueOutputText(string text) - { - // NOTE: This may run on a background thread! - if (this.OutputWindowPane != null) - { - // Enqueue the output text - this.outputQueue.Enqueue(text); - - // We want to interactively report the output. But we dont want to dispatch - // more than one at a time, otherwise we might overflow the main thread's - // message queue. So, we only report the output if the queue was empty. - if (this.outputQueue.Count == 1) - { - ReportQueuedOutput(); - } - } - } - - private void IndentOutput() - { - // NOTE: This may run on a background thread! - this.currentIndent++; - } - - private void UnindentOutput() - { - // NOTE: This may run on a background thread! - this.currentIndent--; - } - - private void ReportQueuedOutput() - { - // NOTE: This may run on a background thread! - // We need to output this on the main thread. We must use BeginInvoke because the main thread may not be pumping events yet. - BeginInvokeWithErrorMessage(this.serviceProvider, this.dispatcher, () => - { - if (this.OutputWindowPane != null) - { - string outputString; - - while (this.outputQueue.TryDequeue(out outputString)) - { - Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(this.OutputWindowPane.OutputString(outputString)); - } - } - }); - } - - private void ClearQueuedOutput() - { - // NOTE: This may run on a background thread! - this.outputQueue = new ConcurrentQueue(); - } - - #endregion output queue - - #region task queue - - protected void QueueTaskEvent(BuildEventArgs errorEvent) - { - this.taskQueue.Enqueue(() => - { - ErrorTask task = new ErrorTask(); - - if (errorEvent is BuildErrorEventArgs) - { - BuildErrorEventArgs errorArgs = (BuildErrorEventArgs)errorEvent; - task.Document = errorArgs.File; - task.ErrorCategory = TaskErrorCategory.Error; - task.Line = errorArgs.LineNumber - 1; // The task list does +1 before showing this number. - task.Column = errorArgs.ColumnNumber; - task.Priority = TaskPriority.High; - } - else if (errorEvent is BuildWarningEventArgs) - { - BuildWarningEventArgs warningArgs = (BuildWarningEventArgs)errorEvent; - task.Document = warningArgs.File; - task.ErrorCategory = TaskErrorCategory.Warning; - task.Line = warningArgs.LineNumber - 1; // The task list does +1 before showing this number. - task.Column = warningArgs.ColumnNumber; - task.Priority = TaskPriority.Normal; - } - - task.Text = errorEvent.Message; - task.Category = TaskCategory.BuildCompile; - task.HierarchyItem = hierarchy; - - return task; - }); - - // NOTE: Unlike output we dont want to interactively report the tasks. So we never queue - // call ReportQueuedTasks here. We do this when the build finishes. - } - - private void ReportQueuedTasks() - { - // NOTE: This may run on a background thread! - // We need to output this on the main thread. We must use BeginInvoke because the main thread may not be pumping events yet. - BeginInvokeWithErrorMessage(this.serviceProvider, this.dispatcher, () => - { - this.taskProvider.SuspendRefresh(); - try - { - Func taskFunc; - - while (this.taskQueue.TryDequeue(out taskFunc)) - { - // Create the error task - ErrorTask task = taskFunc(); - - // Log the task - this.taskProvider.Tasks.Add(task); - } - } - finally - { - this.taskProvider.ResumeRefresh(); - } - }); - } - - private void ClearQueuedTasks() - { - // NOTE: This may run on a background thread! - this.taskQueue = new ConcurrentQueue>(); - - if (this.InteractiveBuild) - { - // We need to clear this on the main thread. We must use BeginInvoke because the main thread may not be pumping events yet. - BeginInvokeWithErrorMessage(this.serviceProvider, this.dispatcher, () => - { - this.taskProvider.Tasks.Clear(); - }); - } - } - - #endregion task queue - - #region helpers - - /// - /// This method takes a MessageImportance and returns true if messages - /// at importance i should be loggeed. Otherwise return false. - /// - private bool LogAtImportance(MessageImportance importance) - { - // If importance is too low for current settings, ignore the event - bool logIt = false; - - this.SetVerbosity(); - - switch (this.Verbosity) - { - case LoggerVerbosity.Quiet: - logIt = false; - break; - case LoggerVerbosity.Minimal: - logIt = (importance == MessageImportance.High); - break; - case LoggerVerbosity.Normal: - // Falling through... - case LoggerVerbosity.Detailed: - logIt = (importance != MessageImportance.Low); - break; - case LoggerVerbosity.Diagnostic: - logIt = true; - break; - default: - Debug.Fail("Unknown Verbosity level. Ignoring will cause everything to be logged"); - break; - } - - return logIt; - } - - /// - /// Format error messages for the task list - /// - private string GetFormattedErrorMessage( - string fileName, - int line, - int column, - bool isWarning, - string errorNumber, - string errorText) - { - string errorCode = isWarning ? this.WarningString : this.ErrorString; - - StringBuilder message = new StringBuilder(); - if (!string.IsNullOrEmpty(fileName)) - { - message.AppendFormat(CultureInfo.CurrentCulture, "{0}({1},{2}):", fileName, line, column); - } - message.AppendFormat(CultureInfo.CurrentCulture, " {0} {1}: {2}", errorCode, errorNumber, errorText); - message.AppendLine(); - - return message.ToString(); - } - - /// - /// Sets the verbosity level. - /// - private void SetVerbosity() - { - // TODO: This should be replaced when we have a version that supports automation. - if (!this.haveCachedVerbosity) - { - string verbosityKey = String.Format(CultureInfo.InvariantCulture, @"{0}\{1}", BuildVerbosityRegistryRoot, buildVerbosityRegistrySubKey); - using (RegistryKey subKey = Registry.CurrentUser.OpenSubKey(verbosityKey)) - { - if (subKey != null) - { - object valueAsObject = subKey.GetValue(buildVerbosityRegistryKey); - if (valueAsObject != null) - { - this.Verbosity = (LoggerVerbosity)((int)valueAsObject); - } - } - } - - this.haveCachedVerbosity = true; - } - } - - /// - /// Clear the cached verbosity, so that it will be re-evaluated from the build verbosity registry key. - /// - private void ClearCachedVerbosity() - { - this.haveCachedVerbosity = false; - } - - #endregion helpers - - #region exception handling helpers - - /// - /// Call Dispatcher.BeginInvoke, showing an error message if there was a non-critical exception. - /// - /// service provider - /// dispatcher - /// action to invoke - private static void BeginInvokeWithErrorMessage(IServiceProvider serviceProvider, Dispatcher dispatcher, Action action) - { - dispatcher.BeginInvoke(new Action(() => CallWithErrorMessage(serviceProvider, action))); - } - - /// - /// Show error message if exception is caught when invoking a method - /// - /// service provider - /// action to invoke - private static void CallWithErrorMessage(IServiceProvider serviceProvider, Action action) - { - try - { - action(); - } - catch (Exception ex) - { - if (Microsoft.VisualStudio.ErrorHandler.IsCriticalException(ex)) - { - throw; - } - - ShowErrorMessage(serviceProvider, ex); - } - } - - /// - /// Show error window about the exception - /// - /// service provider - /// exception - private static void ShowErrorMessage(IServiceProvider serviceProvider, Exception exception) - { - IUIService UIservice = (IUIService)serviceProvider.GetService(typeof(IUIService)); - if (UIservice != null && exception != null) - { - UIservice.ShowError(exception); - } - } - - #endregion exception handling helpers - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ImageHandler.cs b/SHFB/Source/MPFProj_VS2010/ImageHandler.cs deleted file mode 100644 index 5ce44d51..00000000 --- a/SHFB/Source/MPFProj_VS2010/ImageHandler.cs +++ /dev/null @@ -1,241 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Windows.Forms; -using Microsoft.VisualStudio; - -namespace Microsoft.VisualStudio.Project -{ - public class ImageHandler : IDisposable - { - private ImageList imageList; - private List iconHandles; - private static volatile object Mutex; - private bool isDisposed; - - /// - /// Initializes the class. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] - static ImageHandler() - { - Mutex = new object(); - } - - /// - /// Builds an empty ImageHandler object. - /// - public ImageHandler() - { - } - - /// - /// Builds an ImageHandler object from a Stream providing the bitmap that - /// stores the images for the image list. - /// - public ImageHandler(Stream resourceStream) - { - if(null == resourceStream) - { - throw new ArgumentNullException("resourceStream"); - } - imageList = Utilities.GetImageList(resourceStream); - } - - /// - /// Builds an ImageHandler object from an ImageList object. - /// - public ImageHandler(ImageList list) - { - if(null == list) - { - throw new ArgumentNullException("list"); - } - imageList = list; - } - - /// - /// Closes the ImageHandler object freeing its resources. - /// - public void Close() - { - if(null != iconHandles) - { - foreach(IntPtr hnd in iconHandles) - { - if(hnd != IntPtr.Zero) - { - NativeMethods.DestroyIcon(hnd); - } - } - iconHandles = null; - } - - if(null != imageList) - { - imageList.Dispose(); - imageList = null; - } - } - - /// - /// Add an image to the ImageHandler. - /// - /// the image object to be added. - public void AddImage(Image image) - { - if(null == image) - { - throw new ArgumentNullException("image"); - } - if(null == imageList) - { - imageList = new ImageList(); - } - imageList.Images.Add(image); - if(null != iconHandles) - { - iconHandles.Add(IntPtr.Zero); - } - } - - /// - /// Get or set the ImageList object for this ImageHandler. - /// - public ImageList ImageList - { - get { return imageList; } - set - { - Close(); - imageList = value; - } - } - - /// - /// Returns the handle to an icon build from the image of index - /// iconIndex in the image list. - /// - public IntPtr GetIconHandle(int iconIndex) - { - // Verify that the object is in a consistent state. - if((null == imageList)) - { - throw new InvalidOperationException(); - } - // Make sure that the list of handles is initialized. - if(null == iconHandles) - { - InitHandlesList(); - } - - // Verify that the index is inside the expected range. - if((iconIndex < 0) || (iconIndex >= iconHandles.Count)) - { - throw new ArgumentOutOfRangeException("iconIndex"); - } - - // Check if the icon is in the cache. - if(IntPtr.Zero == iconHandles[iconIndex]) - { - Bitmap bitmap = imageList.Images[iconIndex] as Bitmap; - // If the image is not a bitmap, then we can not build the icon, - // so we have to return a null handle. - if(null == bitmap) - { - return IntPtr.Zero; - } - - iconHandles[iconIndex] = bitmap.GetHicon(); - } - - return iconHandles[iconIndex]; - } - - private void InitHandlesList() - { - iconHandles = new List(imageList.Images.Count); - for(int i = 0; i < imageList.Images.Count; ++i) - { - iconHandles.Add(IntPtr.Zero); - } - } - - #region IDisposable Members - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - #endregion - - private void Dispose(bool disposing) - { - if(!this.isDisposed) - { - lock(Mutex) - { - if(disposing) - { - this.imageList.Dispose(); - } - - this.isDisposed = true; - } - } - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Interfaces.cs b/SHFB/Source/MPFProj_VS2010/Interfaces.cs deleted file mode 100644 index d73e35ab..00000000 --- a/SHFB/Source/MPFProj_VS2010/Interfaces.cs +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio.Shell.Interop; -using MSBuild = Microsoft.Build.Evaluation; - -namespace Microsoft.VisualStudio.Project -{ - - /// - /// This interface defines the rules for handling build dependency on a project container. - /// - /// Normally this should be an internal interface but since it shouldbe available for the aggregator it must be made public. - [ComVisible(true)] - [CLSCompliant(false)] - public interface IBuildDependencyOnProjectContainer - { - /// - /// Defines whether the nested projects should be build with the parent project. - /// - bool BuildNestedProjectsOnBuild - { - get; - set; - } - - /// - /// Enumerates the nested hierachies present that will participate in the build dependency update. - /// - /// A list of hierrachies. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hierachies")] - IVsHierarchy[] EnumNestedHierachiesForBuildDependency(); - } - - /// - /// Interface for manipulating build dependency - /// - /// Normally this should be an internal interface but since it shouldbe available for the aggregator it must be made public. - [ComVisible(true)] - [CLSCompliant(false)] - public interface IBuildDependencyUpdate - { - /// - /// Defines a container for storing BuildDependencies - /// - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - IVsBuildDependency[] BuildDependencies - { - get; - } - - /// - /// Adds a BuildDependency to the container - /// - /// The dependency to add - void AddBuildDependency(IVsBuildDependency dependency); - - /// - /// Removes the builddependency from teh container. - /// - /// The dependency to add - void RemoveBuildDependency(IVsBuildDependency dependency); - - } - - /// - /// Provides access to the reference data container. - /// - /// Normally this should be an internal interface but since it should be available for - /// the aggregator it must be made public. - [ComVisible(true)] - public interface IReferenceContainerProvider - { - IReferenceContainer GetReferenceContainer(); - } - - /// - /// Defines a container for manipulating references - /// - /// Normally this should be an internal interface but since it should be available for - /// the aggregator it must be made public. - [ComVisible(true)] - public interface IReferenceContainer - { - IList EnumReferences(); - ReferenceNode AddReferenceFromSelectorData(VSCOMPONENTSELECTORDATA selectorData, string wrapperTool = null); - void LoadReferencesFromBuildProject(MSBuild.Project buildProject); - } - - /// - /// Defines the events that are internally defined for communication with other subsytems. - /// - [ComVisible(true)] - public interface IProjectEvents - { - /// - /// Event raised just after the project file opened. - /// - [SuppressMessage("Microsoft.Naming", "CA1713:EventsShouldNotHaveBeforeOrAfterPrefix")] - event EventHandler AfterProjectFileOpened; - - /// - /// Event raised before the project file closed. - /// - [SuppressMessage("Microsoft.Naming", "CA1713:EventsShouldNotHaveBeforeOrAfterPrefix")] - event EventHandler BeforeProjectFileClosed; - } - - /// - /// Defines the interface that will specify ehethrr the object is a project events listener. - /// - [ComVisible(true)] - public interface IProjectEventsListener - { - - /// - /// Is the object a project events listener. - /// - /// - bool IsProjectEventsListener - { get; set; } - - } - - /// - /// Enable getting and setting the project events provider - /// - [ComVisible(true)] - public interface IProjectEventsProvider - { - /// - /// Defines the provider for the project events - /// - IProjectEvents ProjectEventsProvider - { - get; - set; - } - } - - /// - /// Defines support for single file generator - /// - public interface ISingleFileGenerator - { - /// - /// Runs the generator on the item represented by the document moniker. - /// - /// - void RunGenerator(string document); - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Key.snk b/SHFB/Source/MPFProj_VS2010/Key.snk deleted file mode 100644 index f55b44f357bfa08e55c1874644605f6926eb0316..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096iEy~b`)z_;oG_6*KMxlLDQV|EwN)yss z_I-V8h`Az{bqd!kOCd^g@|H)GRC$^GoF6A^q}94|T2M7KO^}JAlUy0jFtqB$1JanW zai`iV8*k%5wIW?!os0amB#w*;)^w@ZrTO7b4+msoajv`A`N4C-Pb_llM zTn3sj3ew%Pzd7L2b9|!6Trex{tFR?Llu!zZNs@e{h*Y_8VRu - /// Enables a managed object to expose properties and attributes for COM objects. - ///
- [ComVisible(true)] - public class LocalizableProperties : ICustomTypeDescriptor - { - #region ICustomTypeDescriptor - public virtual AttributeCollection GetAttributes() - { - AttributeCollection col = TypeDescriptor.GetAttributes(this, true); - return col; - } - - public virtual EventDescriptor GetDefaultEvent() - { - EventDescriptor ed = TypeDescriptor.GetDefaultEvent(this, true); - return ed; - } - - public virtual PropertyDescriptor GetDefaultProperty() - { - PropertyDescriptor pd = TypeDescriptor.GetDefaultProperty(this, true); - return pd; - } - - public virtual object GetEditor(Type editorBaseType) - { - object o = TypeDescriptor.GetEditor(this, editorBaseType, true); - return o; - } - - public virtual EventDescriptorCollection GetEvents() - { - EventDescriptorCollection edc = TypeDescriptor.GetEvents(this, true); - return edc; - } - - public virtual EventDescriptorCollection GetEvents(System.Attribute[] attributes) - { - EventDescriptorCollection edc = TypeDescriptor.GetEvents(this, attributes, true); - return edc; - } - - public virtual object GetPropertyOwner(PropertyDescriptor pd) - { - return this; - } - - public virtual PropertyDescriptorCollection GetProperties() - { - PropertyDescriptorCollection pcol = GetProperties(null); - return pcol; - } - - public virtual PropertyDescriptorCollection GetProperties(System.Attribute[] attributes) - { - ArrayList newList = new ArrayList(); - PropertyDescriptorCollection props = TypeDescriptor.GetProperties(this, attributes, true); - - for(int i = 0; i < props.Count; i++) - newList.Add(CreateDesignPropertyDescriptor(props[i])); - - return new PropertyDescriptorCollection((PropertyDescriptor[])newList.ToArray(typeof(PropertyDescriptor))); ; - } - - public virtual DesignPropertyDescriptor CreateDesignPropertyDescriptor(PropertyDescriptor propertyDescriptor) - { - return new DesignPropertyDescriptor(propertyDescriptor); - } - - public virtual string GetComponentName() - { - string name = TypeDescriptor.GetComponentName(this, true); - return name; - } - - public virtual TypeConverter GetConverter() - { - TypeConverter tc = TypeDescriptor.GetConverter(this, true); - return tc; - } - - public virtual string GetClassName() - { - return this.GetType().FullName; - } - - #endregion ICustomTypeDescriptor - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Microsoft.VisualStudio.Project.csproj b/SHFB/Source/MPFProj_VS2010/Microsoft.VisualStudio.Project.csproj deleted file mode 100644 index 4bff113b..00000000 --- a/SHFB/Source/MPFProj_VS2010/Microsoft.VisualStudio.Project.csproj +++ /dev/null @@ -1,226 +0,0 @@ - - - - Debug - AnyCPU - 10.0.20506 - 2.0 - {CACB60A9-1E76-4F92-8831-B134A658C695} - Library - Properties - Microsoft.VisualStudio.Project - Microsoft.VisualStudio.Project - v4.0 - 512 - true - Key.snk - $(AllowedAssemblyPrefix);Microsoft.Internal - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - AllRules.ruleset - bin\Debug\Microsoft.VisualStudio.Project.xml - 1591 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Microsoft.VisualStudio.Project.xml - 1591 - - - - False - $(MSBuildExtensionsPath)\..\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\EnvDTE.dll - - - True - - - - True - - - 4.0 - - - - - 4.0 - - - True - - - - - - - False - - - True - - - False - - - False - - - - - - 3.5 - - - - - - - - - - True - - - False - $(MSBuildExtensionsPath)\..\Program Files\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\VSLangProj80.dll - - - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Microsoft.VisualStudio.Project.resources - Designer - - - - - - \ No newline at end of file diff --git a/SHFB/Source/MPFProj_VS2010/Misc/ConnectionPointContainer.cs b/SHFB/Source/MPFProj_VS2010/Misc/ConnectionPointContainer.cs deleted file mode 100644 index 13b25204..00000000 --- a/SHFB/Source/MPFProj_VS2010/Misc/ConnectionPointContainer.cs +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Class used to identify a source of events of type SinkType. - /// - [ComVisible(false)] - internal interface IEventSource - where SinkType : class - { - void OnSinkAdded(SinkType sink); - void OnSinkRemoved(SinkType sink); - } - - [ComVisible(true)] - public class ConnectionPointContainer : IConnectionPointContainer - { - private Dictionary connectionPoints; - internal ConnectionPointContainer() - { - connectionPoints = new Dictionary(); - } - internal void AddEventSource(IEventSource source) - where SinkType : class - { - if(null == source) - { - throw new ArgumentNullException("source"); - } - if(connectionPoints.ContainsKey(typeof(SinkType).GUID)) - { - throw new ArgumentException("EventSource guid already added to the list of connection points", "source"); - } - connectionPoints.Add(typeof(SinkType).GUID, new ConnectionPoint(this, source)); - } - - #region IConnectionPointContainer Members - void IConnectionPointContainer.EnumConnectionPoints(out IEnumConnectionPoints ppEnum) - { - throw new NotImplementedException(); ; - } - void IConnectionPointContainer.FindConnectionPoint(ref Guid riid, out IConnectionPoint ppCP) - { - ppCP = connectionPoints[riid]; - } - #endregion - } - - internal class ConnectionPoint : IConnectionPoint - where SinkType : class - { - Dictionary sinks; - private uint nextCookie; - private ConnectionPointContainer container; - private IEventSource source; - internal ConnectionPoint(ConnectionPointContainer container, IEventSource source) - { - if(null == container) - { - throw new ArgumentNullException("container"); - } - if(null == source) - { - throw new ArgumentNullException("source"); - } - this.container = container; - this.source = source; - sinks = new Dictionary(); - nextCookie = 1; - } - #region IConnectionPoint Members - public void Advise(object pUnkSink, out uint pdwCookie) - { - SinkType sink = pUnkSink as SinkType; - if(null == sink) - { - Marshal.ThrowExceptionForHR(VSConstants.E_NOINTERFACE); - } - sinks.Add(nextCookie, sink); - pdwCookie = nextCookie; - source.OnSinkAdded(sink); - nextCookie += 1; - } - - public void EnumConnections(out IEnumConnections ppEnum) - { - throw new NotImplementedException(); ; - } - - public void GetConnectionInterface(out Guid pIID) - { - pIID = typeof(SinkType).GUID; - } - - public void GetConnectionPointContainer(out IConnectionPointContainer ppCPC) - { - ppCPC = this.container; - } - - public void Unadvise(uint dwCookie) - { - // This will throw if the cookie is not in the list. - SinkType sink = sinks[dwCookie]; - sinks.Remove(dwCookie); - source.OnSinkRemoved(sink); - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Misc/ExternDll.cs b/SHFB/Source/MPFProj_VS2010/Misc/ExternDll.cs deleted file mode 100644 index 91f1fe35..00000000 --- a/SHFB/Source/MPFProj_VS2010/Misc/ExternDll.cs +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -namespace Microsoft.VisualStudio.Project -{ - internal static class ExternDll - { - -#if FEATURE_PAL - -#if !PLATFORM_UNIX - internal const String DLLPREFIX = ""; - internal const String DLLSUFFIX = ".dll"; -#else // !PLATFORM_UNIX -#if __APPLE__ - internal const String DLLPREFIX = "lib"; - internal const String DLLSUFFIX = ".dylib"; -#elif _AIX - internal const String DLLPREFIX = "lib"; - internal const String DLLSUFFIX = ".a"; -#elif __hppa__ || IA64 - internal const String DLLPREFIX = "lib"; - internal const String DLLSUFFIX = ".sl"; -#else - internal const String DLLPREFIX = "lib"; - internal const String DLLSUFFIX = ".so"; -#endif -#endif // !PLATFORM_UNIX - - public const string Kernel32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX; - public const string User32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX; - public const string Mscoree = DLLPREFIX + "sscoree" + DLLSUFFIX; -#else - public const string Activeds = "activeds.dll"; - public const string Advapi32 = "advapi32.dll"; - public const string Comctl32 = "comctl32.dll"; - public const string Comdlg32 = "comdlg32.dll"; - public const string Gdi32 = "gdi32.dll"; - public const string Gdiplus = "gdiplus.dll"; - public const string Hhctrl = "hhctrl.ocx"; - public const string Imm32 = "imm32.dll"; - public const string Kernel32 = "kernel32.dll"; - public const string Loadperf = "Loadperf.dll"; - public const string Mscoree = "mscoree.dll"; - public const string Mscorwks = "mscorwks.dll"; - public const string Msi = "msi.dll"; - public const string Mqrt = "mqrt.dll"; - public const string Ntdll = "ntdll.dll"; - public const string Ole32 = "ole32.dll"; - public const string Oleacc = "oleacc.dll"; - public const string Oleaut32 = "oleaut32.dll"; - public const string Olepro32 = "olepro32.dll"; - public const string PerfCounter = "perfcounter.dll"; - public const string Powrprof = "Powrprof.dll"; - public const string Psapi = "psapi.dll"; - public const string Shell32 = "shell32.dll"; - public const string Shfolder = "shfolder.dll"; - public const string User32 = "user32.dll"; - public const string Uxtheme = "uxtheme.dll"; - public const string WinMM = "winmm.dll"; - public const string Winspool = "winspool.drv"; - public const string Wtsapi32 = "wtsapi32.dll"; - public const string Version = "version.dll"; - public const string Vsassert = "vsassert.dll"; - public const string Shlwapi = "shlwapi.dll"; - public const string Crypt32 = "crypt32.dll"; - - // system.data specific - internal const string Odbc32 = "odbc32.dll"; - internal const string SNI = "System.Data.dll"; - - // system.data.oracleclient specific - internal const string OciDll = "oci.dll"; - internal const string OraMtsDll = "oramts.dll"; -#endif //!FEATURE_PAL - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Misc/NativeMethods.cs b/SHFB/Source/MPFProj_VS2010/Misc/NativeMethods.cs deleted file mode 100644 index fb335323..00000000 --- a/SHFB/Source/MPFProj_VS2010/Misc/NativeMethods.cs +++ /dev/null @@ -1,744 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.TextManager.Interop; - -namespace Microsoft.VisualStudio.Project -{ - internal static class NativeMethods - { - // IIDS - public static readonly Guid IID_IUnknown = new Guid("{00000000-0000-0000-C000-000000000046}"); - - public const int - CLSCTX_INPROC_SERVER = 0x1; - - public const int - S_FALSE = 0x00000001, - S_OK = 0x00000000, - - IDOK = 1, - IDCANCEL = 2, - IDABORT = 3, - IDRETRY = 4, - IDIGNORE = 5, - IDYES = 6, - IDNO = 7, - IDCLOSE = 8, - IDHELP = 9, - IDTRYAGAIN = 10, - IDCONTINUE = 11, - - OLECMDERR_E_NOTSUPPORTED = unchecked((int)0x80040100), - OLECMDERR_E_UNKNOWNGROUP = unchecked((int)0x80040104), - - UNDO_E_CLIENTABORT = unchecked((int)0x80044001), - E_OUTOFMEMORY = unchecked((int)0x8007000E), - E_INVALIDARG = unchecked((int)0x80070057), - E_FAIL = unchecked((int)0x80004005), - E_NOINTERFACE = unchecked((int)0x80004002), - E_POINTER = unchecked((int)0x80004003), - E_NOTIMPL = unchecked((int)0x80004001), - E_UNEXPECTED = unchecked((int)0x8000FFFF), - E_HANDLE = unchecked((int)0x80070006), - E_ABORT = unchecked((int)0x80004004), - E_ACCESSDENIED = unchecked((int)0x80070005), - E_PENDING = unchecked((int)0x8000000A); - - public const int - OLECLOSE_SAVEIFDIRTY = 0, - OLECLOSE_NOSAVE = 1, - OLECLOSE_PROMPTSAVE = 2; - - public const int - OLEIVERB_PRIMARY = 0, - OLEIVERB_SHOW = -1, - OLEIVERB_OPEN = -2, - OLEIVERB_HIDE = -3, - OLEIVERB_UIACTIVATE = -4, - OLEIVERB_INPLACEACTIVATE = -5, - OLEIVERB_DISCARDUNDOSTATE = -6, - OLEIVERB_PROPERTIES = -7; - - public const int - OFN_READONLY = unchecked((int)0x00000001), - OFN_OVERWRITEPROMPT = unchecked((int)0x00000002), - OFN_HIDEREADONLY = unchecked((int)0x00000004), - OFN_NOCHANGEDIR = unchecked((int)0x00000008), - OFN_SHOWHELP = unchecked((int)0x00000010), - OFN_ENABLEHOOK = unchecked((int)0x00000020), - OFN_ENABLETEMPLATE = unchecked((int)0x00000040), - OFN_ENABLETEMPLATEHANDLE = unchecked((int)0x00000080), - OFN_NOVALIDATE = unchecked((int)0x00000100), - OFN_ALLOWMULTISELECT = unchecked((int)0x00000200), - OFN_EXTENSIONDIFFERENT = unchecked((int)0x00000400), - OFN_PATHMUSTEXIST = unchecked((int)0x00000800), - OFN_FILEMUSTEXIST = unchecked((int)0x00001000), - OFN_CREATEPROMPT = unchecked((int)0x00002000), - OFN_SHAREAWARE = unchecked((int)0x00004000), - OFN_NOREADONLYRETURN = unchecked((int)0x00008000), - OFN_NOTESTFILECREATE = unchecked((int)0x00010000), - OFN_NONETWORKBUTTON = unchecked((int)0x00020000), - OFN_NOLONGNAMES = unchecked((int)0x00040000), - OFN_EXPLORER = unchecked((int)0x00080000), - OFN_NODEREFERENCELINKS = unchecked((int)0x00100000), - OFN_LONGNAMES = unchecked((int)0x00200000), - OFN_ENABLEINCLUDENOTIFY = unchecked((int)0x00400000), - OFN_ENABLESIZING = unchecked((int)0x00800000), - OFN_USESHELLITEM = unchecked((int)0x01000000), - OFN_DONTADDTORECENT = unchecked((int)0x02000000), - OFN_FORCESHOWHIDDEN = unchecked((int)0x10000000); - - // for READONLYSTATUS - public const int - ROSTATUS_NotReadOnly = 0x0, - ROSTATUS_ReadOnly = 0x1, - ROSTATUS_Unknown = unchecked((int)0xFFFFFFFF); - - public const int - IEI_DoNotLoadDocData = 0x10000000; - - public const int - CB_SETDROPPEDWIDTH = 0x0160, - - GWL_STYLE = (-16), - GWL_EXSTYLE = (-20), - - DWL_MSGRESULT = 0, - - SW_SHOWNORMAL = 1, - - HTMENU = 5, - - WS_POPUP = unchecked((int)0x80000000), - WS_CHILD = 0x40000000, - WS_MINIMIZE = 0x20000000, - WS_VISIBLE = 0x10000000, - WS_DISABLED = 0x08000000, - WS_CLIPSIBLINGS = 0x04000000, - WS_CLIPCHILDREN = 0x02000000, - WS_MAXIMIZE = 0x01000000, - WS_CAPTION = 0x00C00000, - WS_BORDER = 0x00800000, - WS_DLGFRAME = 0x00400000, - WS_VSCROLL = 0x00200000, - WS_HSCROLL = 0x00100000, - WS_SYSMENU = 0x00080000, - WS_THICKFRAME = 0x00040000, - WS_TABSTOP = 0x00010000, - WS_MINIMIZEBOX = 0x00020000, - WS_MAXIMIZEBOX = 0x00010000, - WS_EX_DLGMODALFRAME = 0x00000001, - WS_EX_MDICHILD = 0x00000040, - WS_EX_TOOLWINDOW = 0x00000080, - WS_EX_CLIENTEDGE = 0x00000200, - WS_EX_CONTEXTHELP = 0x00000400, - WS_EX_RIGHT = 0x00001000, - WS_EX_LEFT = 0x00000000, - WS_EX_RTLREADING = 0x00002000, - WS_EX_LEFTSCROLLBAR = 0x00004000, - WS_EX_CONTROLPARENT = 0x00010000, - WS_EX_STATICEDGE = 0x00020000, - WS_EX_APPWINDOW = 0x00040000, - WS_EX_LAYERED = 0x00080000, - WS_EX_TOPMOST = 0x00000008, - WS_EX_NOPARENTNOTIFY = 0x00000004, - - LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54), - - LVS_EX_LABELTIP = 0x00004000, - - // winuser.h - WH_JOURNALPLAYBACK = 1, - WH_GETMESSAGE = 3, - WH_MOUSE = 7, - WSF_VISIBLE = 0x0001, - WM_NULL = 0x0000, - WM_CREATE = 0x0001, - WM_DELETEITEM = 0x002D, - WM_DESTROY = 0x0002, - WM_MOVE = 0x0003, - WM_SIZE = 0x0005, - WM_ACTIVATE = 0x0006, - WA_INACTIVE = 0, - WA_ACTIVE = 1, - WA_CLICKACTIVE = 2, - WM_SETFOCUS = 0x0007, - WM_KILLFOCUS = 0x0008, - WM_ENABLE = 0x000A, - WM_SETREDRAW = 0x000B, - WM_SETTEXT = 0x000C, - WM_GETTEXT = 0x000D, - WM_GETTEXTLENGTH = 0x000E, - WM_PAINT = 0x000F, - WM_CLOSE = 0x0010, - WM_QUERYENDSESSION = 0x0011, - WM_QUIT = 0x0012, - WM_QUERYOPEN = 0x0013, - WM_ERASEBKGND = 0x0014, - WM_SYSCOLORCHANGE = 0x0015, - WM_ENDSESSION = 0x0016, - WM_SHOWWINDOW = 0x0018, - WM_WININICHANGE = 0x001A, - WM_SETTINGCHANGE = 0x001A, - WM_DEVMODECHANGE = 0x001B, - WM_ACTIVATEAPP = 0x001C, - WM_FONTCHANGE = 0x001D, - WM_TIMECHANGE = 0x001E, - WM_CANCELMODE = 0x001F, - WM_SETCURSOR = 0x0020, - WM_MOUSEACTIVATE = 0x0021, - WM_CHILDACTIVATE = 0x0022, - WM_QUEUESYNC = 0x0023, - WM_GETMINMAXINFO = 0x0024, - WM_PAINTICON = 0x0026, - WM_ICONERASEBKGND = 0x0027, - WM_NEXTDLGCTL = 0x0028, - WM_SPOOLERSTATUS = 0x002A, - WM_DRAWITEM = 0x002B, - WM_MEASUREITEM = 0x002C, - WM_VKEYTOITEM = 0x002E, - WM_CHARTOITEM = 0x002F, - WM_SETFONT = 0x0030, - WM_GETFONT = 0x0031, - WM_SETHOTKEY = 0x0032, - WM_GETHOTKEY = 0x0033, - WM_QUERYDRAGICON = 0x0037, - WM_COMPAREITEM = 0x0039, - WM_GETOBJECT = 0x003D, - WM_COMPACTING = 0x0041, - WM_COMMNOTIFY = 0x0044, - WM_WINDOWPOSCHANGING = 0x0046, - WM_WINDOWPOSCHANGED = 0x0047, - WM_POWER = 0x0048, - WM_COPYDATA = 0x004A, - WM_CANCELJOURNAL = 0x004B, - WM_NOTIFY = 0x004E, - WM_INPUTLANGCHANGEREQUEST = 0x0050, - WM_INPUTLANGCHANGE = 0x0051, - WM_TCARD = 0x0052, - WM_HELP = 0x0053, - WM_USERCHANGED = 0x0054, - WM_NOTIFYFORMAT = 0x0055, - WM_CONTEXTMENU = 0x007B, - WM_STYLECHANGING = 0x007C, - WM_STYLECHANGED = 0x007D, - WM_DISPLAYCHANGE = 0x007E, - WM_GETICON = 0x007F, - WM_SETICON = 0x0080, - WM_NCCREATE = 0x0081, - WM_NCDESTROY = 0x0082, - WM_NCCALCSIZE = 0x0083, - WM_NCHITTEST = 0x0084, - WM_NCPAINT = 0x0085, - WM_NCACTIVATE = 0x0086, - WM_GETDLGCODE = 0x0087, - WM_NCMOUSEMOVE = 0x00A0, - WM_NCLBUTTONDOWN = 0x00A1, - WM_NCLBUTTONUP = 0x00A2, - WM_NCLBUTTONDBLCLK = 0x00A3, - WM_NCRBUTTONDOWN = 0x00A4, - WM_NCRBUTTONUP = 0x00A5, - WM_NCRBUTTONDBLCLK = 0x00A6, - WM_NCMBUTTONDOWN = 0x00A7, - WM_NCMBUTTONUP = 0x00A8, - WM_NCMBUTTONDBLCLK = 0x00A9, - WM_NCXBUTTONDOWN = 0x00AB, - WM_NCXBUTTONUP = 0x00AC, - WM_NCXBUTTONDBLCLK = 0x00AD, - WM_KEYFIRST = 0x0100, - WM_KEYDOWN = 0x0100, - WM_KEYUP = 0x0101, - WM_CHAR = 0x0102, - WM_DEADCHAR = 0x0103, - WM_CTLCOLOR = 0x0019, - WM_SYSKEYDOWN = 0x0104, - WM_SYSKEYUP = 0x0105, - WM_SYSCHAR = 0x0106, - WM_SYSDEADCHAR = 0x0107, - WM_KEYLAST = 0x0108, - WM_IME_STARTCOMPOSITION = 0x010D, - WM_IME_ENDCOMPOSITION = 0x010E, - WM_IME_COMPOSITION = 0x010F, - WM_IME_KEYLAST = 0x010F, - WM_INITDIALOG = 0x0110, - WM_COMMAND = 0x0111, - WM_SYSCOMMAND = 0x0112, - WM_TIMER = 0x0113, - WM_HSCROLL = 0x0114, - WM_VSCROLL = 0x0115, - WM_INITMENU = 0x0116, - WM_INITMENUPOPUP = 0x0117, - WM_MENUSELECT = 0x011F, - WM_MENUCHAR = 0x0120, - WM_ENTERIDLE = 0x0121, - WM_CHANGEUISTATE = 0x0127, - WM_UPDATEUISTATE = 0x0128, - WM_QUERYUISTATE = 0x0129, - WM_CTLCOLORMSGBOX = 0x0132, - WM_CTLCOLOREDIT = 0x0133, - WM_CTLCOLORLISTBOX = 0x0134, - WM_CTLCOLORBTN = 0x0135, - WM_CTLCOLORDLG = 0x0136, - WM_CTLCOLORSCROLLBAR = 0x0137, - WM_CTLCOLORSTATIC = 0x0138, - WM_MOUSEFIRST = 0x0200, - WM_MOUSEMOVE = 0x0200, - WM_LBUTTONDOWN = 0x0201, - WM_LBUTTONUP = 0x0202, - WM_LBUTTONDBLCLK = 0x0203, - WM_RBUTTONDOWN = 0x0204, - WM_RBUTTONUP = 0x0205, - WM_RBUTTONDBLCLK = 0x0206, - WM_MBUTTONDOWN = 0x0207, - WM_MBUTTONUP = 0x0208, - WM_MBUTTONDBLCLK = 0x0209, - WM_XBUTTONDOWN = 0x020B, - WM_XBUTTONUP = 0x020C, - WM_XBUTTONDBLCLK = 0x020D, - WM_MOUSEWHEEL = 0x020A, - WM_MOUSELAST = 0x020A, - WM_PARENTNOTIFY = 0x0210, - WM_ENTERMENULOOP = 0x0211, - WM_EXITMENULOOP = 0x0212, - WM_NEXTMENU = 0x0213, - WM_SIZING = 0x0214, - WM_CAPTURECHANGED = 0x0215, - WM_MOVING = 0x0216, - WM_POWERBROADCAST = 0x0218, - WM_DEVICECHANGE = 0x0219, - WM_IME_SETCONTEXT = 0x0281, - WM_IME_NOTIFY = 0x0282, - WM_IME_CONTROL = 0x0283, - WM_IME_COMPOSITIONFULL = 0x0284, - WM_IME_SELECT = 0x0285, - WM_IME_CHAR = 0x0286, - WM_IME_KEYDOWN = 0x0290, - WM_IME_KEYUP = 0x0291, - WM_MDICREATE = 0x0220, - WM_MDIDESTROY = 0x0221, - WM_MDIACTIVATE = 0x0222, - WM_MDIRESTORE = 0x0223, - WM_MDINEXT = 0x0224, - WM_MDIMAXIMIZE = 0x0225, - WM_MDITILE = 0x0226, - WM_MDICASCADE = 0x0227, - WM_MDIICONARRANGE = 0x0228, - WM_MDIGETACTIVE = 0x0229, - WM_MDISETMENU = 0x0230, - WM_ENTERSIZEMOVE = 0x0231, - WM_EXITSIZEMOVE = 0x0232, - WM_DROPFILES = 0x0233, - WM_MDIREFRESHMENU = 0x0234, - WM_MOUSEHOVER = 0x02A1, - WM_MOUSELEAVE = 0x02A3, - WM_CUT = 0x0300, - WM_COPY = 0x0301, - WM_PASTE = 0x0302, - WM_CLEAR = 0x0303, - WM_UNDO = 0x0304, - WM_RENDERFORMAT = 0x0305, - WM_RENDERALLFORMATS = 0x0306, - WM_DESTROYCLIPBOARD = 0x0307, - WM_DRAWCLIPBOARD = 0x0308, - WM_PAINTCLIPBOARD = 0x0309, - WM_VSCROLLCLIPBOARD = 0x030A, - WM_SIZECLIPBOARD = 0x030B, - WM_ASKCBFORMATNAME = 0x030C, - WM_CHANGECBCHAIN = 0x030D, - WM_HSCROLLCLIPBOARD = 0x030E, - WM_QUERYNEWPALETTE = 0x030F, - WM_PALETTEISCHANGING = 0x0310, - WM_PALETTECHANGED = 0x0311, - WM_HOTKEY = 0x0312, - WM_PRINT = 0x0317, - WM_PRINTCLIENT = 0x0318, - WM_HANDHELDFIRST = 0x0358, - WM_HANDHELDLAST = 0x035F, - WM_AFXFIRST = 0x0360, - WM_AFXLAST = 0x037F, - WM_PENWINFIRST = 0x0380, - WM_PENWINLAST = 0x038F, - WM_APP = unchecked((int)0x8000), - WM_USER = 0x0400, - WM_REFLECT = - WM_USER + 0x1C00, - WS_OVERLAPPED = 0x00000000, - WPF_SETMINPOSITION = 0x0001, - WM_CHOOSEFONT_GETLOGFONT = (0x0400 + 1), - - WHEEL_DELTA = 120, - DWLP_MSGRESULT = 0, - PSNRET_NOERROR = 0, - PSNRET_INVALID = 1, - PSNRET_INVALID_NOCHANGEPAGE = 2; - - public const int - PSN_APPLY = ((0 - 200) - 2), - PSN_KILLACTIVE = ((0 - 200) - 1), - PSN_RESET = ((0 - 200) - 3), - PSN_SETACTIVE = ((0 - 200) - 0); - - public const int - GMEM_MOVEABLE = 0x0002, - GMEM_ZEROINIT = 0x0040, - GMEM_DDESHARE = 0x2000; - - public const int - SWP_NOACTIVATE = 0x0010, - SWP_NOZORDER = 0x0004, - SWP_NOSIZE = 0x0001, - SWP_NOMOVE = 0x0002, - SWP_FRAMECHANGED = 0x0020; - - public const int - TVM_SETINSERTMARK = (0x1100 + 26), - TVM_GETEDITCONTROL = (0x1100 + 15); - - public const int - FILE_ATTRIBUTE_READONLY = 0x00000001; - - public const int - PSP_DEFAULT = 0x00000000, - PSP_DLGINDIRECT = 0x00000001, - PSP_USEHICON = 0x00000002, - PSP_USEICONID = 0x00000004, - PSP_USETITLE = 0x00000008, - PSP_RTLREADING = 0x00000010, - PSP_HASHELP = 0x00000020, - PSP_USEREFPARENT = 0x00000040, - PSP_USECALLBACK = 0x00000080, - PSP_PREMATURE = 0x00000400, - PSP_HIDEHEADER = 0x00000800, - PSP_USEHEADERTITLE = 0x00001000, - PSP_USEHEADERSUBTITLE = 0x00002000; - - public const int - PSH_DEFAULT = 0x00000000, - PSH_PROPTITLE = 0x00000001, - PSH_USEHICON = 0x00000002, - PSH_USEICONID = 0x00000004, - PSH_PROPSHEETPAGE = 0x00000008, - PSH_WIZARDHASFINISH = 0x00000010, - PSH_WIZARD = 0x00000020, - PSH_USEPSTARTPAGE = 0x00000040, - PSH_NOAPPLYNOW = 0x00000080, - PSH_USECALLBACK = 0x00000100, - PSH_HASHELP = 0x00000200, - PSH_MODELESS = 0x00000400, - PSH_RTLREADING = 0x00000800, - PSH_WIZARDCONTEXTHELP = 0x00001000, - PSH_WATERMARK = 0x00008000, - PSH_USEHBMWATERMARK = 0x00010000, // user pass in a hbmWatermark instead of pszbmWatermark - PSH_USEHPLWATERMARK = 0x00020000, // - PSH_STRETCHWATERMARK = 0x00040000, // stretchwatermark also applies for the header - PSH_HEADER = 0x00080000, - PSH_USEHBMHEADER = 0x00100000, - PSH_USEPAGELANG = 0x00200000, // use frame dialog template matched to page - PSH_WIZARD_LITE = 0x00400000, - PSH_NOCONTEXTHELP = 0x02000000; - - public const int - PSBTN_BACK = 0, - PSBTN_NEXT = 1, - PSBTN_FINISH = 2, - PSBTN_OK = 3, - PSBTN_APPLYNOW = 4, - PSBTN_CANCEL = 5, - PSBTN_HELP = 6, - PSBTN_MAX = 6; - - public const int - TRANSPARENT = 1, - OPAQUE = 2, - FW_BOLD = 700; - - [StructLayout(LayoutKind.Sequential)] - public struct NMHDR - { - public IntPtr hwndFrom; - public int idFrom; - public int code; - } - - /// - /// Helper class for setting the text parameters to OLECMDTEXT structures. - /// - public static class OLECMDTEXT - { - - /// - /// Flags for the OLE command text - /// - public enum OLECMDTEXTF - { - /// No flag - OLECMDTEXTF_NONE = 0, - /// The name of the command is required. - OLECMDTEXTF_NAME = 1, - /// A description of the status is required. - OLECMDTEXTF_STATUS = 2 - } - } - - /// - /// OLECMDF enums for IOleCommandTarget - /// - public enum tagOLECMDF - { - OLECMDF_SUPPORTED = 1, - OLECMDF_ENABLED = 2, - OLECMDF_LATCHED = 4, - OLECMDF_NINCHED = 8, - OLECMDF_INVISIBLE = 16 - } - - /// - /// This method takes a file URL and converts it to an absolute path. The trick here is that - /// if there is a '#' in the path, everything after this is treated as a fragment. So - /// we need to append the fragment to the end of the path. - /// - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - public static string GetAbsolutePath(string fileName) - { - System.Diagnostics.Debug.Assert(fileName != null && fileName.Length > 0, "Cannot get absolute path, fileName is not valid"); - - Uri uri = new Uri(fileName); - return uri.LocalPath + uri.Fragment; - } - - /// - /// Please use this "approved" method to compare file names. - /// - public static bool IsSamePath(string file1, string file2) - { - if(file1 == null || file1.Length == 0) - { - return (file2 == null || file2.Length == 0); - } - - Uri uri1 = null; - Uri uri2 = null; - - try - { - if(!Uri.TryCreate(file1, UriKind.Absolute, out uri1) || !Uri.TryCreate(file2, UriKind.Absolute, out uri2)) - { - return false; - } - - if(uri1 != null && uri1.IsFile && uri2 != null && uri2.IsFile) - { - return 0 == String.Compare(uri1.LocalPath, uri2.LocalPath, StringComparison.OrdinalIgnoreCase); - } - - return file1 == file2; - } - catch(UriFormatException e) - { - Trace.WriteLine("Exception " + e.Message); - } - - return false; - } - - [ComImport(), Guid("9BDA66AE-CA28-4e22-AA27-8A7218A0E3FA"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IEventHandler - { - - // converts the underlying codefunction into an event handler for the given event - // if the given event is NULL, then the function will handle no events - [PreserveSig] - int AddHandler(string bstrEventName); - - [PreserveSig] - int RemoveHandler(string bstrEventName); - - IVsEnumBSTR GetHandledEvents(); - - bool HandlesEvent(string bstrEventName); - } - - [ComImport(), Guid("A55CCBCC-7031-432d-B30A-A68DE7BDAD75"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IParameterKind - { - - void SetParameterPassingMode(PARAMETER_PASSING_MODE ParamPassingMode); - void SetParameterArrayDimensions(int uDimensions); - int GetParameterArrayCount(); - int GetParameterArrayDimensions(int uIndex); - int GetParameterPassingMode(); - } - - public enum PARAMETER_PASSING_MODE - { - cmParameterTypeIn = 1, - cmParameterTypeOut = 2, - cmParameterTypeInOut = 3 - } - - [ - ComImport, ComVisible(true), Guid("3E596484-D2E4-461a-A876-254C4F097EBB"), - InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown) - ] - public interface IMethodXML - { - // Generate XML describing the contents of this function's body. - void GetXML(ref string pbstrXML); - - // Parse the incoming XML with respect to the CodeModel XML schema and - // use the result to regenerate the body of the function. - // - [PreserveSig] - int SetXML(string pszXML); - - // This is really a textpoint - [PreserveSig] - int GetBodyPoint([MarshalAs(UnmanagedType.Interface)]out object bodyPoint); - } - - [ComImport(), Guid("EA1A87AD-7BC5-4349-B3BE-CADC301F17A3"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IVBFileCodeModelEvents - { - - [PreserveSig] - int StartEdit(); - - [PreserveSig] - int EndEdit(); - } - - ///-------------------------------------------------------------------------- - /// ICodeClassBase: - ///-------------------------------------------------------------------------- - [GuidAttribute("23BBD58A-7C59-449b-A93C-43E59EFC080C")] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [ComImport()] - public interface ICodeClassBase - { - [PreserveSig()] - int GetBaseName(out string pBaseName); - } - - public const ushort CF_HDROP = 15; // winuser.h - public const uint MK_CONTROL = 0x0008; //winuser.h - public const uint MK_SHIFT = 0x0004; - public const int MAX_PATH = 260; // windef.h - - /// - /// Specifies options for a bitmap image associated with a task item. - /// - public enum VSTASKBITMAP - { - BMP_COMPILE = -1, - BMP_SQUIGGLE = -2, - BMP_COMMENT = -3, - BMP_SHORTCUT = -4, - BMP_USER = -5 - }; - - public const int ILD_NORMAL = 0x0000, - ILD_TRANSPARENT = 0x0001, - ILD_MASK = 0x0010, - ILD_ROP = 0x0040; - - /// - /// Defines the values that are not supported by the System.Environment.SpecialFolder enumeration - /// - [ComVisible(true)] - public enum ExtendedSpecialFolder - { - /// - /// Identical to CSIDL_COMMON_STARTUP - /// - CommonStartup = 0x0018, - - /// - /// Identical to CSIDL_WINDOWS - /// - Windows = 0x0024, - } - - - // APIS - - /// - /// Changes the parent window of the specified child window. - /// - /// Handle to the child window. - /// Handle to the new parent window. If this parameter is NULL, the desktop window becomes the new parent window. - /// A handle to the previous parent window indicates success. NULL indicates failure. - [DllImport("User32", ExactSpelling = true, CharSet = CharSet.Auto)] - public static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent); - - [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)] - public static extern bool DestroyIcon(IntPtr handle); - - [DllImport("user32.dll", EntryPoint = "IsDialogMessageA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] - public static extern bool IsDialogMessageA(IntPtr hDlg, ref MSG msg); - - /// - /// Indicates whether the file type is binary or not - /// - /// Full path to the file to check - /// If file isbianry the bitness of the app is indicated by lpBinaryType value. - /// True if the file is binary false otherwise - [DllImport("kernel32.dll")] - public static extern bool GetBinaryType([MarshalAs(UnmanagedType.LPWStr)]string lpApplicationName, out uint lpBinaryType); - - } -} - diff --git a/SHFB/Source/MPFProj_VS2010/Misc/UnsafeNativeMethods.cs b/SHFB/Source/MPFProj_VS2010/Misc/UnsafeNativeMethods.cs deleted file mode 100644 index 9cb50f9a..00000000 --- a/SHFB/Source/MPFProj_VS2010/Misc/UnsafeNativeMethods.cs +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project -{ - internal static class UnsafeNativeMethods - { - [DllImport(ExternDll.Kernel32, EntryPoint = "GlobalLock", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] - internal static extern IntPtr GlobalLock(IntPtr h); - - [DllImport(ExternDll.Kernel32, EntryPoint = "GlobalUnlock", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] - internal static extern bool GlobalUnLock(IntPtr h); - - [DllImport(ExternDll.Kernel32, EntryPoint = "GlobalSize", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] - internal static extern int GlobalSize(IntPtr h); - - [DllImport(ExternDll.Ole32, ExactSpelling = true, CharSet = CharSet.Unicode)] - internal static extern int OleSetClipboard(Microsoft.VisualStudio.OLE.Interop.IDataObject dataObject); - - [DllImport(ExternDll.Ole32, ExactSpelling = true, CharSet = CharSet.Unicode)] - internal static extern int OleGetClipboard(out Microsoft.VisualStudio.OLE.Interop.IDataObject dataObject); - - [DllImport(ExternDll.Ole32, ExactSpelling = true, CharSet = CharSet.Unicode)] - internal static extern int OleFlushClipboard(); - - [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Unicode)] - internal static extern int OpenClipboard(IntPtr newOwner); - - [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Unicode)] - internal static extern int EmptyClipboard(); - - [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Unicode)] - internal static extern int CloseClipboard(); - - [DllImport(ExternDll.Comctl32, CharSet = CharSet.Auto)] - internal static extern int ImageList_GetImageCount(HandleRef himl); - - [DllImport(ExternDll.Comctl32, CharSet = CharSet.Auto)] - internal static extern bool ImageList_Draw(HandleRef himl, int i, HandleRef hdcDst, int x, int y, int fStyle); - - [DllImport(ExternDll.Shell32, EntryPoint = "DragQueryFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] - internal static extern uint DragQueryFile(IntPtr hDrop, uint iFile, char[] lpszFile, uint cch); - - [DllImport(ExternDll.User32, EntryPoint = "RegisterClipboardFormatW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] - internal static extern ushort RegisterClipboardFormat(string format); - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode"), DllImport(ExternDll.Shell32, EntryPoint = "SHGetSpecialFolderLocation")] - internal static extern int SHGetSpecialFolderLocation(IntPtr hwnd, int csidl, [Out, MarshalAs(UnmanagedType.LPArray)] IntPtr[] ppidl); - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode"), DllImport(ExternDll.Shell32, EntryPoint = "SHGetPathFromIDList", CharSet = System.Runtime.InteropServices.CharSet.Auto)] - internal static extern bool SHGetPathFromIDList(IntPtr pidl, IntPtr pszPath); - } -} - diff --git a/SHFB/Source/MPFProj_VS2010/NestedProjectBuildDependency.cs b/SHFB/Source/MPFProj_VS2010/NestedProjectBuildDependency.cs deleted file mode 100644 index ab773abe..00000000 --- a/SHFB/Source/MPFProj_VS2010/NestedProjectBuildDependency.cs +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Used for adding a build dependency to nested project (not a real project reference) - /// - public class NestedProjectBuildDependency : IVsBuildDependency - { - IVsHierarchy dependentHierarchy = null; - - #region ctors - [CLSCompliant(false)] - public NestedProjectBuildDependency(IVsHierarchy dependentHierarchy) - { - this.dependentHierarchy = dependentHierarchy; - } - #endregion - - #region IVsBuildDependency methods - public int get_CanonicalName(out string canonicalName) - { - canonicalName = null; - return VSConstants.S_OK; - } - - public int get_Type(out System.Guid guidType) - { - // All our dependencies are build projects - guidType = VSConstants.GUID_VS_DEPTYPE_BUILD_PROJECT; - - return VSConstants.S_OK; - } - - public int get_Description(out string description) - { - description = null; - return VSConstants.S_OK; - } - - [CLSCompliant(false)] - public int get_HelpContext(out uint helpContext) - { - helpContext = 0; - return VSConstants.E_NOTIMPL; - } - - public int get_HelpFile(out string helpFile) - { - helpFile = null; - return VSConstants.E_NOTIMPL; - } - - public int get_MustUpdateBefore(out int mustUpdateBefore) - { - // Must always update dependencies - mustUpdateBefore = 1; - - return VSConstants.S_OK; - } - - public int get_ReferredProject(out object unknownProject) - { - unknownProject = this.dependentHierarchy; - - return (unknownProject == null) ? VSConstants.E_FAIL : VSConstants.S_OK; - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/NestedProjectNode.cs b/SHFB/Source/MPFProj_VS2010/NestedProjectNode.cs deleted file mode 100644 index 3a4ee53e..00000000 --- a/SHFB/Source/MPFProj_VS2010/NestedProjectNode.cs +++ /dev/null @@ -1,1185 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using ErrorHandler = Microsoft.VisualStudio.ErrorHandler; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false), ComVisible(true)] - public class NestedProjectNode : HierarchyNode, IPropertyNotifySink - { - #region fields - private IVsHierarchy nestedHierarchy; - - Guid projectInstanceGuid = Guid.Empty; - - private string projectName = String.Empty; - - private string projectPath = String.Empty; - - private ImageHandler imageHandler; - - /// - /// Defines an object that will be a mutex for this object for synchronizing thread calls. - /// - private static volatile object Mutex = new object(); - - /// - /// Sets the dispose flag on the object. - /// - private bool isDisposed; - - // A cooike retrieved when advising on property chnanged events. - private uint projectPropertyNotifySinkCookie; - #endregion - - #region properties - internal IVsHierarchy NestedHierarchy - { - get - { - return this.nestedHierarchy; - } - } - #endregion - - #region virtual properties - /// - /// Returns the __VSADDVPFLAGS that will be passed in when calling AddVirtualProjectEx - /// - protected virtual uint VirtualProjectFlags - { - get { return 0; } - } - #endregion - - #region overridden properties - /// - /// The path of the nested project. - /// - public override string Url - { - get - { - return this.projectPath; - } - } - - /// - /// The Caption of the nested project. - /// - public override string Caption - { - get - { - return Path.GetFileNameWithoutExtension(this.projectName); - } - } - - public override Guid ItemTypeGuid - { - get - { - return VSConstants.GUID_ItemType_SubProject; - } - } - - /// - /// Defines whether a node can execute a command if in selection. - /// We do this in order to let the nested project to handle the execution of its own commands. - /// - public override bool CanExecuteCommand - { - get - { - return false; - } - } - - public override int SortPriority - { - get { return DefaultSortOrderNode.NestedProjectNode; } - } - - protected bool IsDisposed - { - get { return this.isDisposed; } - set { this.isDisposed = value; } - } - - - - #endregion - - #region ctor - - protected NestedProjectNode() - { - } - - public NestedProjectNode(ProjectNode root, ProjectElement element) - : base(root, element) - { - this.IsExpanded = true; - } - #endregion - - #region IPropertyNotifySink Members - /// - /// Notifies a sink that the [bindable] property specified by dispID has changed. - /// If dispID is DISPID_UNKNOWN, then multiple properties have changed together. - /// The client (owner of the sink) should then retrieve the current value of each property of interest from the object that generated the notification. - /// In our case we will care about the VSLangProj80.VsProjPropId.VBPROJPROPID_FileName and update the changes in the parent project file. - /// - /// Dispatch identifier of the property that is about to change or DISPID_UNKNOWN if multiple properties are about to change. - public virtual void OnChanged(int dispid) - { - if (dispid == (int)VSLangProj80.VsProjPropId.VBPROJPROPID_FileName) - { - // Get the filename of the nested project. Inetead of asking the label on the nested we ask the filename, since the label might not yet been set. - IVsProject3 nestedProject = this.nestedHierarchy as IVsProject3; - - if (nestedProject != null) - { - string document; - ErrorHandler.ThrowOnFailure(nestedProject.GetMkDocument(VSConstants.VSITEMID_ROOT, out document)); - this.RenameNestedProjectInParentProject(Path.GetFileNameWithoutExtension(document)); - - // We need to redraw the caption since for some reason, by intervining to the OnChanged event the Caption is not updated. - this.ReDraw(UIHierarchyElement.Caption); - } - } - } - - /// - /// Notifies a sink that a [requestedit] property is about to change and that the object is asking the sink how to proceed. - /// - /// Dispatch identifier of the property that is about to change or DISPID_UNKNOWN if multiple properties are about to change. - public virtual void OnRequestEdit(int dispid) - { - - } - - #endregion - - #region public methods - #endregion - - #region overridden methods - - /// - /// Get the automation object for the NestedProjectNode - /// - /// An instance of the Automation.OANestedProjectItem type if succeded - public override object GetAutomationObject() - { - //Validate that we are not disposed or the project is closing - if (this.isDisposed || this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return null; - } - - return new Automation.OANestedProjectItem(this.ProjectMgr.GetAutomationObject() as Automation.OAProject, this); - } - - /// - /// Gets properties of a given node or of the hierarchy. - /// - /// Identifier of the hierarchy property - /// It return an object which type is dependent on the propid. - public override object GetProperty(int propId) - { - __VSHPROPID vshPropId = (__VSHPROPID)propId; - switch (vshPropId) - { - default: - return base.GetProperty(propId); - - case __VSHPROPID.VSHPROPID_Expandable: - return true; - - case __VSHPROPID.VSHPROPID_BrowseObject: - case __VSHPROPID.VSHPROPID_HandlesOwnReload: - return this.DelegateGetPropertyToNested(propId); - } - } - - - /// - /// Gets properties whose values are GUIDs. - /// - /// Identifier of the hierarchy property - /// Pointer to a GUID property specified in propid - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int GetGuidProperty(int propid, out Guid guid) - { - guid = Guid.Empty; - switch ((__VSHPROPID)propid) - { - case __VSHPROPID.VSHPROPID_ProjectIDGuid: - guid = this.projectInstanceGuid; - break; - - default: - return base.GetGuidProperty(propid, out guid); - } - - CCITracing.TraceCall(String.Format(CultureInfo.CurrentCulture, "Guid for {0} property", propid)); - if (guid.CompareTo(Guid.Empty) == 0) - { - return VSConstants.DISP_E_MEMBERNOTFOUND; - } - - return VSConstants.S_OK; - } - - - /// - /// Determines whether the hierarchy item changed. - /// - /// Item identifier of the hierarchy item contained in VSITEMID - /// Pointer to the IUnknown interface of the hierarchy item. - /// TRUE if the hierarchy item changed. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int IsItemDirty(uint itemId, IntPtr punkDocData, out int pfDirty) - { - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - Debug.Assert(punkDocData != IntPtr.Zero, "docData intptr was zero"); - - // Get an IPersistFileFormat object from docData object - IPersistFileFormat persistFileFormat = Marshal.GetTypedObjectForIUnknown(punkDocData, typeof(IPersistFileFormat)) as IPersistFileFormat; - Debug.Assert(persistFileFormat != null, "The docData object does not implement the IPersistFileFormat interface"); - - // Call IsDirty on the IPersistFileFormat interface - ErrorHandler.ThrowOnFailure(persistFileFormat.IsDirty(out pfDirty)); - - return VSConstants.S_OK; - } - - /// - /// Saves the hierarchy item to disk. - /// - /// Flags whose values are taken from the VSSAVEFLAGS enumeration. - /// File name to be applied when dwSave is set to VSSAVE_SilentSave. - /// Item identifier of the hierarchy item saved from VSITEMID. - /// Pointer to the IUnknown interface of the hierarchy item saved. - /// TRUE if the save action was canceled. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int SaveItem(VSSAVEFLAGS dwSave, string silentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCancelled) - { - // Don't ignore/unignore file changes - // Use Advise/Unadvise to work around rename situations - try - { - this.StopObservingNestedProjectFile(); - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - Debug.Assert(punkDocData != IntPtr.Zero, "docData intptr was zero"); - - // Get an IPersistFileFormat object from docData object (we don't call release on punkDocData since did not increment its ref count) - IPersistFileFormat persistFileFormat = Marshal.GetTypedObjectForIUnknown(punkDocData, typeof(IPersistFileFormat)) as IPersistFileFormat; - Debug.Assert(persistFileFormat != null, "The docData object does not implement the IPersistFileFormat interface"); - - IVsUIShell uiShell = this.GetService(typeof(SVsUIShell)) as IVsUIShell; - string newName; - ErrorHandler.ThrowOnFailure(uiShell.SaveDocDataToFile(dwSave, persistFileFormat, silentSaveAsName, out newName, out pfCancelled)); - - // When supported do a rename of the nested project here - } - finally - { - // Succeeded or not we must hook to the file change events - // Don't ignore/unignore file changes - // Use Advise/Unadvise to work around rename situations - this.ObserveNestedProjectFile(); - } - - return VSConstants.S_OK; - } - - /// - /// Gets the icon handle. It tries first the nested to get the icon handle. If that is not supported it will get it from - /// the image list of the nested if that is supported. If neither of these is supported a default image will be shown. - /// - /// An object representing the icon. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsHierarchy.GetProperty(System.UInt32,System.Int32,System.Object@)")] - public override object GetIconHandle(bool open) - { - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - - object iconHandle = null; - this.nestedHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_IconHandle, out iconHandle); - if (iconHandle == null) - { - if (null == imageHandler) - { - InitImageHandler(); - } - // Try to get an icon from the nested hierrachy image list. - if (imageHandler.ImageList != null) - { - object imageIndexAsObject = null; - if (this.nestedHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_IconIndex, out imageIndexAsObject) == VSConstants.S_OK && - imageIndexAsObject != null) - { - int imageIndex = (int)imageIndexAsObject; - if (imageIndex < imageHandler.ImageList.Images.Count) - { - iconHandle = imageHandler.GetIconHandle(imageIndex); - } - } - } - - if (null == iconHandle) - { - iconHandle = this.ProjectMgr.ImageHandler.GetIconHandle((int)ProjectNode.ImageName.Application); - } - } - - return iconHandle; - } - - /// - /// Return S_OK. Implementation of Closing a nested project is done in CloseNestedProject which is called by CloseChildren. - /// - /// S_OK - public override int Close() - { - return VSConstants.S_OK; - } - - - /// - /// Returns the moniker of the nested project. - /// - /// - public override string GetMkDocument() - { - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - if (this.isDisposed || this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return String.Empty; - } - - return this.projectPath; - } - - /// - /// Called by the shell when a node has been renamed from the GUI - /// - /// The name of the new label. - /// A success or failure value. - public override int SetEditLabel(string label) - { - int result = this.DelegateSetPropertyToNested((int)__VSHPROPID.VSHPROPID_EditLabel, label); - if (ErrorHandler.Succeeded(result)) - { - this.RenameNestedProjectInParentProject(label); - } - - return result; - } - - /// - /// Called by the shell to get the node caption when the user tries to rename from the GUI - /// - /// the node cation - public override string GetEditLabel() - { - return (string)this.DelegateGetPropertyToNested((int)__VSHPROPID.VSHPROPID_EditLabel); - } - - /// - /// This is temporary until we have support for re-adding a nested item - /// - protected override bool CanDeleteItem(__VSDELETEITEMOPERATION deleteOperation) - { - return false; - } - - /// - /// Delegates the call to the inner hierarchy. - /// - /// Reserved parameter defined at the IVsPersistHierarchyItem2::ReloadItem parameter. - protected internal override void ReloadItem(uint reserved) - { - #region precondition - if (this.isDisposed || this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - throw new InvalidOperationException(); - } - - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - #endregion - - IVsPersistHierarchyItem2 persistHierachyItem = this.nestedHierarchy as IVsPersistHierarchyItem2; - - // We are expecting that if we get called then the nestedhierarchy supports IVsPersistHierarchyItem2, since then hierrachy should support handling its own reload. - // There should be no errormessage to the user since this is an internal error, that it cannot be fixed at user level. - if (persistHierachyItem == null) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(persistHierachyItem.ReloadItem(VSConstants.VSITEMID_ROOT, reserved)); - } - - /// - /// Flag indicating that changes to a file can be ignored when item is saved or reloaded. - /// - /// Flag indicating whether or not to ignore changes (1 to ignore, 0 to stop ignoring). - protected internal override void IgnoreItemFileChanges(bool ignoreFlag) - { - #region precondition - if (this.isDisposed || this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - throw new InvalidOperationException(); - } - - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - #endregion - - this.IgnoreNestedProjectFile(ignoreFlag); - - IVsPersistHierarchyItem2 persistHierachyItem = this.nestedHierarchy as IVsPersistHierarchyItem2; - - // If the IVsPersistHierarchyItem2 is not implemented by the nested just return - if (persistHierachyItem == null) - { - return; - } - - ErrorHandler.ThrowOnFailure(persistHierachyItem.IgnoreItemFileChanges(VSConstants.VSITEMID_ROOT, ignoreFlag ? 1 : 0)); - } - - /// - /// Sets the VSADDFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnAddFiles - /// - /// The files to which an array of VSADDFILEFLAGS has to be specified. - /// - protected internal override VSADDFILEFLAGS[] GetAddFileFlags(string[] files) - { - if (files == null || files.Length == 0) - { - return new VSADDFILEFLAGS[1] { VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags }; - } - - VSADDFILEFLAGS[] addFileFlags = new VSADDFILEFLAGS[files.Length]; - - for (int i = 0; i < files.Length; i++) - { - addFileFlags[i] = VSADDFILEFLAGS.VSADDFILEFLAGS_IsNestedProjectFile; - } - - return addFileFlags; - } - - /// - /// Sets the VSQUERYADDFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnQueryAddFiles - /// - /// The files to which an array of VSADDFILEFLAGS has to be specified. - /// - protected internal override VSQUERYADDFILEFLAGS[] GetQueryAddFileFlags(string[] files) - { - if (files == null || files.Length == 0) - { - return new VSQUERYADDFILEFLAGS[1] { VSQUERYADDFILEFLAGS.VSQUERYADDFILEFLAGS_NoFlags }; - } - - VSQUERYADDFILEFLAGS[] queryAddFileFlags = new VSQUERYADDFILEFLAGS[files.Length]; - - for (int i = 0; i < files.Length; i++) - { - queryAddFileFlags[i] = VSQUERYADDFILEFLAGS.VSQUERYADDFILEFLAGS_IsNestedProjectFile; - } - - return queryAddFileFlags; - } - - /// - /// Sets the VSREMOVEFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnRemoveFiles - /// - /// The files to which an array of VSREMOVEFILEFLAGS has to be specified. - /// - protected internal override VSREMOVEFILEFLAGS[] GetRemoveFileFlags(string[] files) - { - if (files == null || files.Length == 0) - { - return new VSREMOVEFILEFLAGS[1] { VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags }; - } - - VSREMOVEFILEFLAGS[] removeFileFlags = new VSREMOVEFILEFLAGS[files.Length]; - - for (int i = 0; i < files.Length; i++) - { - removeFileFlags[i] = VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_IsNestedProjectFile; - } - - return removeFileFlags; - } - - /// - /// Sets the VSQUERYREMOVEFILEFLAGS that will be used to call the IVsTrackProjectDocumentsEvents2 OnQueryRemoveFiles - /// - /// The files to which an array of VSQUERYREMOVEFILEFLAGS has to be specified. - /// - protected internal override VSQUERYREMOVEFILEFLAGS[] GetQueryRemoveFileFlags(string[] files) - { - if (files == null || files.Length == 0) - { - return new VSQUERYREMOVEFILEFLAGS[1] { VSQUERYREMOVEFILEFLAGS.VSQUERYREMOVEFILEFLAGS_NoFlags }; - } - - VSQUERYREMOVEFILEFLAGS[] queryRemoveFileFlags = new VSQUERYREMOVEFILEFLAGS[files.Length]; - - for (int i = 0; i < files.Length; i++) - { - queryRemoveFileFlags[i] = VSQUERYREMOVEFILEFLAGS.VSQUERYREMOVEFILEFLAGS_IsNestedProjectFile; - } - - return queryRemoveFileFlags; - } - #endregion - - #region virtual methods - /// - /// Initialize the nested hierarhy node. - /// - /// The file name of the nested project. - /// The location of the nested project. - /// The name of the project. - /// The nested project creation flags - /// This methos should be called just after a NestedProjectNode object is created. - public virtual void Init(string fileName, string destination, string projectName, __VSCREATEPROJFLAGS createFlags) - { - if (String.IsNullOrEmpty(fileName)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "fileName"); - } - - if (String.IsNullOrEmpty(destination)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "destination"); - } - - this.projectName = Path.GetFileName(fileName); - this.projectPath = Path.Combine(destination, this.projectName); - - // get the IVsSolution interface from the global service provider - IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution; - Debug.Assert(solution != null, "Could not get the IVsSolution object from the services exposed by this project"); - if (solution == null) - { - throw new InvalidOperationException(); - } - - // Get the project type guid from project element - string typeGuidString = this.ItemNode.GetMetadataAndThrow(ProjectFileConstants.TypeGuid, new InvalidOperationException()); - Guid projectFactoryGuid = Guid.Empty; - if (!String.IsNullOrEmpty(typeGuidString)) - { - projectFactoryGuid = new Guid(typeGuidString); - } - - // Get the project factory. - IVsProjectFactory projectFactory; - ErrorHandler.ThrowOnFailure(solution.GetProjectFactory((uint)0, new Guid[] { projectFactoryGuid }, fileName, out projectFactory)); - - this.CreateProjectDirectory(); - - //Create new project using factory - int cancelled; - Guid refiid = NativeMethods.IID_IUnknown; - IntPtr projectPtr = IntPtr.Zero; - - try - { - ErrorHandler.ThrowOnFailure(projectFactory.CreateProject(fileName, destination, projectName, (uint)createFlags, ref refiid, out projectPtr, out cancelled)); - - if (projectPtr != IntPtr.Zero) - { - this.nestedHierarchy = Marshal.GetTypedObjectForIUnknown(projectPtr, typeof(IVsHierarchy)) as IVsHierarchy; - Debug.Assert(this.nestedHierarchy != null, "Nested hierarchy could not be created"); - Debug.Assert(cancelled == 0); - } - } - finally - { - if (projectPtr != IntPtr.Zero) - { - // We created a new instance of the project, we need to call release to decrement the ref count - // the RCW (this.nestedHierarchy) still has a reference to it which will keep it alive - Marshal.Release(projectPtr); - } - } - - if (cancelled != 0 && this.nestedHierarchy == null) - { - ErrorHandler.ThrowOnFailure(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - // Link into the nested VS hierarchy. - ErrorHandler.ThrowOnFailure(this.nestedHierarchy.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ParentHierarchy, this.ProjectMgr)); - ErrorHandler.ThrowOnFailure(this.nestedHierarchy.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ParentHierarchyItemid, (object)(int)this.ID)); - - this.LockRDTEntry(); - - this.ConnectPropertyNotifySink(); - } - - /// - /// Links a nested project as a virtual project to the solution. - /// - protected internal virtual void AddVirtualProject() - { - // This is the second step in creating and adding a nested project. The inner hierarchy must have been - // already initialized at this point. - #region precondition - if (this.nestedHierarchy == null) - { - throw new InvalidOperationException(); - } - #endregion - // get the IVsSolution interface from the global service provider - IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution; - Debug.Assert(solution != null, "Could not get the IVsSolution object from the services exposed by this project"); - if (solution == null) - { - throw new InvalidOperationException(); - } - - this.InitializeInstanceGuid(); - - // Add virtual project to solution. - ErrorHandler.ThrowOnFailure(solution.AddVirtualProjectEx(this.nestedHierarchy, this.VirtualProjectFlags, ref this.projectInstanceGuid)); - - // Now set up to listen on file changes on the nested project node. - this.ObserveNestedProjectFile(); - } - - /// - /// The method that does the cleanup. - /// - /// - protected override void Dispose(bool disposing) - { - // Everybody can go here. - if (!this.isDisposed) - { - try - { - // Synchronize calls to the Dispose simulteniously. - lock (Mutex) - { - if (disposing) - { - this.DisconnectPropertyNotifySink(); - this.StopObservingNestedProjectFile(); - - // If a project cannot load it may happen that the imagehandler is not instantiated. - if (this.imageHandler != null) - { - this.imageHandler.Close(); - } - } - } - } - finally - { - base.Dispose(disposing); - this.isDisposed = true; - } - } - } - - /// - /// Creates the project directory if it does not exist. - /// - /// - protected virtual void CreateProjectDirectory() - { - string directoryName = Path.GetDirectoryName(this.projectPath); - - if (!Directory.Exists(directoryName)) - { - Directory.CreateDirectory(directoryName); - } - } - - - /// - /// Lock the RDT Entry for the nested project. - /// By default this document is marked as "Dont Save as". That means the menu File->SaveAs is disabled for the - /// nested project node. - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "RDT")] - protected virtual void LockRDTEntry() - { - // Define flags for the nested project document - _VSRDTFLAGS flags = _VSRDTFLAGS.RDT_VirtualDocument | _VSRDTFLAGS.RDT_ProjSlnDocument; ; - - // Request the RDT service - IVsRunningDocumentTable rdt = this.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - Debug.Assert(rdt != null, " Could not get running document table from the services exposed by this project"); - if (rdt == null) - { - throw new InvalidOperationException(); - } - - // First we see if someone else has opened the requested view of the file. - uint itemid; - IntPtr docData = IntPtr.Zero; - IVsHierarchy ivsHierarchy; - uint docCookie; - IntPtr projectPtr = IntPtr.Zero; - - try - { - ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)flags, this.projectPath, out ivsHierarchy, out itemid, out docData, out docCookie)); - flags |= _VSRDTFLAGS.RDT_EditLock; - - if (ivsHierarchy != null && docCookie != (uint)ShellConstants.VSDOCCOOKIE_NIL) - { - if (docCookie != this.DocCookie) - { - this.DocCookie = docCookie; - } - } - else - { - - // get inptr for hierarchy - projectPtr = Marshal.GetIUnknownForObject(this.nestedHierarchy); - Debug.Assert(projectPtr != IntPtr.Zero, " Project pointer for the nested hierarchy has not been initialized"); - ErrorHandler.ThrowOnFailure(rdt.RegisterAndLockDocument((uint)flags, this.projectPath, this.ProjectMgr.InteropSafeIVsHierarchy, this.ID, projectPtr, out docCookie)); - - this.DocCookie = docCookie; - Debug.Assert(this.DocCookie != (uint)ShellConstants.VSDOCCOOKIE_NIL, "Invalid cookie when registering document in the running document table."); - - //we must also set the doc cookie on the nested hier - this.SetDocCookieOnNestedHier(this.DocCookie); - } - } - finally - { - // Release all Inptr's that that were given as out pointers - if (docData != IntPtr.Zero) - { - Marshal.Release(docData); - } - if (projectPtr != IntPtr.Zero) - { - Marshal.Release(projectPtr); - } - } - - } - - /// - /// Unlock the RDT entry for the nested project - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "RDT")] - protected virtual void UnlockRDTEntry() - { - if (this.isDisposed || this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return; - } - // First we see if someone else has opened the requested view of the file. - IVsRunningDocumentTable rdt = this.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - if (rdt != null && this.DocCookie != (int)ShellConstants.VSDOCCOOKIE_NIL) - { - _VSRDTFLAGS flags = _VSRDTFLAGS.RDT_EditLock; - - ErrorHandler.ThrowOnFailure(rdt.UnlockDocument((uint)flags, (uint)this.DocCookie)); - } - - this.DocCookie = (int)ShellConstants.VSDOCCOOKIE_NIL; - } - - /// - /// Renames the project file in the parent project structure. - /// - /// The new label. - protected virtual void RenameNestedProjectInParentProject(string label) - { - string existingLabel = this.Caption; - - if (String.Compare(existingLabel, label, StringComparison.Ordinal) == 0) - { - return; - } - - string oldFileName = this.projectPath; - string oldPath = this.Url; - - try - { - this.StopObservingNestedProjectFile(); - this.ProjectMgr.SuspendMSBuild(); - - // Check out the project file if necessary. - if (!this.ProjectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - - string newFileName = label + Path.GetExtension(oldFileName); - this.SaveNestedProjectItemInProjectFile(newFileName); - - string projectDirectory = Path.GetDirectoryName(oldFileName); - - // update state. - this.projectName = newFileName; - this.projectPath = Path.Combine(projectDirectory, this.projectName); - - // Unload and lock the RDT entries - this.UnlockRDTEntry(); - this.LockRDTEntry(); - - // Since actually this is a rename in our hierarchy notify the tracker that a rename has happened. - this.ProjectMgr.Tracker.OnItemRenamed(oldPath, this.projectPath, VSRENAMEFILEFLAGS.VSRENAMEFILEFLAGS_IsNestedProjectFile); - } - finally - { - this.ObserveNestedProjectFile(); - this.ProjectMgr.ResumeMSBuild(this.ProjectMgr.ReEvaluateProjectFileTargetName); - } - } - /// - /// Saves the nested project information in the project file. - /// - /// - protected virtual void SaveNestedProjectItemInProjectFile(string newFileName) - { - string existingInclude = this.ItemNode.Item.EvaluatedInclude; - string existingRelativePath = Path.GetDirectoryName(existingInclude); - string newRelativePath = Path.Combine(existingRelativePath, newFileName); - this.ItemNode.Rename(newRelativePath); - } - #endregion - - #region helper methods - /// - /// Closes a nested project and releases the nested hierrachy pointer. - /// - internal void CloseNestedProjectNode() - { - if (this.isDisposed || this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return; - } - - uint itemid = VSConstants.VSITEMID_NIL; - try - { - this.DisconnectPropertyNotifySink(); - - IVsUIHierarchy hier; - - IVsWindowFrame windowFrame; - VsShellUtilities.IsDocumentOpen(this.ProjectMgr.Site, this.projectPath, Guid.Empty, out hier, out itemid, out windowFrame); - - - if (itemid == VSConstants.VSITEMID_NIL) - { - this.UnlockRDTEntry(); - } - - IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution; - if (solution == null) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(solution.RemoveVirtualProject(this.nestedHierarchy, 0)); - - } - finally - { - this.StopObservingNestedProjectFile(); - - // if we haven't already release the RDT cookie, do so now. - if (itemid == VSConstants.VSITEMID_NIL) - { - this.UnlockRDTEntry(); - } - - this.Dispose(true); - } - } - - private void InitializeInstanceGuid() - { - if (this.projectInstanceGuid != Guid.Empty) - { - return; - } - - Guid instanceGuid = Guid.Empty; - - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - - // This method should be called from the open children method, then we can safely use the IsNewProject property - if (this.ProjectMgr.IsNewProject) - { - instanceGuid = Guid.NewGuid(); - this.ItemNode.SetMetadata(ProjectFileConstants.InstanceGuid, instanceGuid.ToString("B")); - ErrorHandler.ThrowOnFailure(this.nestedHierarchy.SetGuidProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, ref instanceGuid)); - } - else - { - // Get a guid from the nested hiererachy. - Guid nestedHiererachyInstanceGuid; - ErrorHandler.ThrowOnFailure(this.nestedHierarchy.GetGuidProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, out nestedHiererachyInstanceGuid)); - - // Get instance guid from the project file. If it does not exist then we create one. - string instanceGuidAsString = this.ItemNode.GetMetadata(ProjectFileConstants.InstanceGuid); - - // 1. nestedHiererachyInstanceGuid is empty and instanceGuidAsString is empty then create a new one. - // 2. nestedHiererachyInstanceGuid is empty and instanceGuidAsString not empty use instanceGuidAsString and update the nested project object by calling SetGuidProperty. - // 3. nestedHiererachyInstanceGuid is not empty instanceGuidAsString is empty then use nestedHiererachyInstanceGuid and update the outer project element. - // 4. nestedHiererachyInstanceGuid is not empty instanceGuidAsString is empty then use nestedHiererachyInstanceGuid and update the outer project element. - - if (nestedHiererachyInstanceGuid == Guid.Empty && String.IsNullOrEmpty(instanceGuidAsString)) - { - instanceGuid = Guid.NewGuid(); - } - else if (nestedHiererachyInstanceGuid == Guid.Empty && !String.IsNullOrEmpty(instanceGuidAsString)) - { - instanceGuid = new Guid(instanceGuidAsString); - - ErrorHandler.ThrowOnFailure(this.nestedHierarchy.SetGuidProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, ref instanceGuid)); - } - else if (nestedHiererachyInstanceGuid != Guid.Empty) - { - instanceGuid = nestedHiererachyInstanceGuid; - - // If the instanceGuidAsString is empty then creating a guid out of it would throw an exception. - if (String.IsNullOrEmpty(instanceGuidAsString) || nestedHiererachyInstanceGuid != new Guid(instanceGuidAsString)) - { - this.ItemNode.SetMetadata(ProjectFileConstants.InstanceGuid, instanceGuid.ToString("B")); - } - } - } - - this.projectInstanceGuid = instanceGuid; - } - - private void SetDocCookieOnNestedHier(uint itemDocCookie) - { - object docCookie = (int)itemDocCookie; - - try - { - ErrorHandler.ThrowOnFailure(this.nestedHierarchy.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ItemDocCookie, docCookie)); - } - catch (NotImplementedException) - { - //we swallow this exception on purpose - } - } - - private void InitImageHandler() - { - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - - if (null == imageHandler) - { - imageHandler = new ImageHandler(); - } - object imageListAsPointer = null; - ErrorHandler.ThrowOnFailure(this.nestedHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_IconImgList, out imageListAsPointer)); - if (imageListAsPointer != null) - { - this.imageHandler.ImageList = Utilities.GetImageList(imageListAsPointer); - } - } - - /// - /// Delegates Getproperty calls to the inner nested. - /// - /// The property to delegate. - /// The return of the GetProperty from nested. - private object DelegateGetPropertyToNested(int propID) - { - if (!this.ProjectMgr.IsClosed) - { - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - - object returnValue; - - // Do not throw since some project types will return E_FAIL if they do not support a property. - int result = this.nestedHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, propID, out returnValue); - if (ErrorHandler.Succeeded(result)) - { - return returnValue; - } - } - - return null; - } - - /// - /// Delegates Setproperty calls to the inner nested. - /// - /// The property to delegate. - /// The property to set. - /// The return of the SetProperty from nested. - private int DelegateSetPropertyToNested(int propID, object value) - { - if (this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method"); - - // Do not throw since some project types will return E_FAIL if they do not support a property. - return this.nestedHierarchy.SetProperty(VSConstants.VSITEMID_ROOT, propID, value); - } - - /// - /// Starts observing changes on this file. - /// - private void ObserveNestedProjectFile() - { - ProjectContainerNode parent = this.ProjectMgr as ProjectContainerNode; - Debug.Assert(parent != null, "The parent project for nested projects should be subclassed from ProjectContainerNode"); - parent.NestedProjectNodeReloader.ObserveItem(this.GetMkDocument(), this.ID); - } - - /// - /// Stops observing changes on this file. - /// - private void StopObservingNestedProjectFile() - { - ProjectContainerNode parent = this.ProjectMgr as ProjectContainerNode; - Debug.Assert(parent != null, "The parent project for nested projects should be subclassed from ProjectContainerNode"); - parent.NestedProjectNodeReloader.StopObservingItem(this.GetMkDocument()); - } - - /// - /// Ignores observing changes on this file depending on the boolean flag. - /// - /// Flag indicating whether or not to ignore changes (1 to ignore, 0 to stop ignoring). - private void IgnoreNestedProjectFile(bool ignoreFlag) - { - ProjectContainerNode parent = this.ProjectMgr as ProjectContainerNode; - Debug.Assert(parent != null, "The parent project for nested projects should be subclassed from ProjectContainerNode"); - parent.NestedProjectNodeReloader.IgnoreItemChanges(this.GetMkDocument(), ignoreFlag); - } - - /// - /// We need to advise property notify sink on project properties so that - /// we know when the project file is renamed through a property. - /// - private void ConnectPropertyNotifySink() - { - if (this.projectPropertyNotifySinkCookie != (uint)ShellConstants.VSCOOKIE_NIL) - { - return; - } - - IConnectionPoint connectionPoint = this.GetConnectionPointFromPropertySink(); - if (connectionPoint != null) - { - connectionPoint.Advise(this, out this.projectPropertyNotifySinkCookie); - } - } - - /// - /// Disconnects the propertynotify sink - /// - private void DisconnectPropertyNotifySink() - { - if (this.projectPropertyNotifySinkCookie == (uint)ShellConstants.VSCOOKIE_NIL) - { - return; - } - - IConnectionPoint connectionPoint = this.GetConnectionPointFromPropertySink(); - if (connectionPoint != null) - { - connectionPoint.Unadvise(this.projectPropertyNotifySinkCookie); - this.projectPropertyNotifySinkCookie = (uint)ShellConstants.VSCOOKIE_NIL; - } - } - - /// - /// Gets a ConnectionPoint for the IPropertyNotifySink interface. - /// - /// - private IConnectionPoint GetConnectionPointFromPropertySink() - { - IConnectionPoint connectionPoint = null; - object browseObject = this.GetProperty((int)__VSHPROPID.VSHPROPID_BrowseObject); - IConnectionPointContainer connectionPointContainer = browseObject as IConnectionPointContainer; - - if (connectionPointContainer != null) - { - Guid guid = typeof(IPropertyNotifySink).GUID; - connectionPointContainer.FindConnectionPoint(ref guid, out connectionPoint); - } - - return connectionPoint; - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/NodeProperties.cs b/SHFB/Source/MPFProj_VS2010/NodeProperties.cs deleted file mode 100644 index bd8d67ad..00000000 --- a/SHFB/Source/MPFProj_VS2010/NodeProperties.cs +++ /dev/null @@ -1,969 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//=============================================================================================================== -// File : NodeProperties.cs -// Updated : 12/29/2013 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// This file has been modified to support "Show All Files" in the project. Search for "!EFW" to find the -// changes. -// -// Date Who Comments -// ============================================================================================================== -// 04/17/2011 EFW Added code to FileNodeProperties to hide the BuildAction property for non-member nodes. -// Also added code to it and FolderNodeProperties to prevent editing of the name for non-member -// items. -// 12/29/2013 EFW Added support for ReferenceOutputAssembly metadata -//=============================================================================================================== - -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; - -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - - /// - /// All public properties on Nodeproperties or derived classes are assumed to be used by Automation by default. - /// Set this attribute to false on Properties that should not be visible for Automation. - /// - [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] - public sealed class AutomationBrowsableAttribute : System.Attribute - { - public AutomationBrowsableAttribute(bool browsable) - { - this.browsable = browsable; - } - - public bool Browsable - { - get - { - return this.browsable; - } - } - - private bool browsable; - } - - /// - /// To create your own localizable node properties, subclass this and add public properties - /// decorated with your own localized display name, category and description attributes. - /// - [CLSCompliant(false), ComVisible(true)] - public class NodeProperties : LocalizableProperties, - ISpecifyPropertyPages, - IVsGetCfgProvider, - IVsSpecifyProjectDesignerPages, - EnvDTE80.IInternalExtenderProvider, - IVsBrowseObject - { - #region fields - private HierarchyNode node; - #endregion - - #region properties - [Browsable(false)] - [AutomationBrowsable(false)] - public HierarchyNode Node - { - get { return this.node; } - } - - /// - /// Used by Property Pages Frame to set it's title bar. The Caption of the Hierarchy Node is returned. - /// - [Browsable(false)] - [AutomationBrowsable(false)] - public virtual string Name - { - get { return this.node.Caption; } - } - - #endregion - - #region ctors - public NodeProperties(HierarchyNode node) - { - if(node == null) - { - throw new ArgumentNullException("node"); - } - this.node = node; - } - #endregion - - #region ISpecifyPropertyPages methods - public virtual void GetPages(CAUUID[] pages) - { - this.GetCommonPropertyPages(pages); - } - #endregion - - #region IVsSpecifyProjectDesignerPages - /// - /// Implementation of the IVsSpecifyProjectDesignerPages. It will return the pages that are configuration independent. - /// - /// The pages to return. - /// - public virtual int GetProjectDesignerPages(CAUUID[] pages) - { - this.GetCommonPropertyPages(pages); - return VSConstants.S_OK; - } - #endregion - - #region IVsGetCfgProvider methods - public virtual int GetCfgProvider(out IVsCfgProvider p) - { - p = null; - return VSConstants.E_NOTIMPL; - } - #endregion - - #region IVsBrowseObject methods - /// - /// Maps back to the hierarchy or project item object corresponding to the browse object. - /// - /// Reference to the hierarchy object. - /// Reference to the project item. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetProjectItem(out IVsHierarchy hier, out uint itemid) - { - if(this.node == null) - { - throw new InvalidOperationException(); - } - hier = this.node.ProjectMgr.InteropSafeIVsHierarchy; - itemid = this.node.ID; - return VSConstants.S_OK; - } - #endregion - - #region overridden methods - /// - /// Get the Caption of the Hierarchy Node instance. If Caption is null or empty we delegate to base - /// - /// Caption of Hierarchy node instance - public override string GetComponentName() - { - string caption = this.Node.Caption; - if(string.IsNullOrEmpty(caption)) - { - return base.GetComponentName(); - } - else - { - return caption; - } - } - #endregion - - #region helper methods - protected string GetProperty(string name, string def) - { - string a = this.Node.ItemNode.GetMetadata(name); - return (a == null) ? def : a; - } - - protected void SetProperty(string name, string value) - { - this.Node.ItemNode.SetMetadata(name, value); - } - - /// - /// Retrieves the common property pages. The NodeProperties is the BrowseObject and that will be called to support - /// configuration independent properties. - /// - /// The pages to return. - 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. - if(pages == null) - { - throw new ArgumentNullException("pages"); - } - - if(pages.Length == 0) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "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 = this.Node.ProjectMgr.InteropSafeIVsHierarchy; - 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; - } - } - #endregion - - #region IInternalExtenderProvider Members - - bool EnvDTE80.IInternalExtenderProvider.CanExtend(string extenderCATID, string extenderName, object extendeeObject) - { - EnvDTE80.IInternalExtenderProvider outerHierarchy = this.Node.ProjectMgr.InteropSafeIVsHierarchy as EnvDTE80.IInternalExtenderProvider; - - - if(outerHierarchy != null) - { - return outerHierarchy.CanExtend(extenderCATID, extenderName, extendeeObject); - } - return false; - } - - object EnvDTE80.IInternalExtenderProvider.GetExtender(string extenderCATID, string extenderName, object extendeeObject, EnvDTE.IExtenderSite extenderSite, int cookie) - { - EnvDTE80.IInternalExtenderProvider outerHierarchy = this.Node.ProjectMgr.InteropSafeIVsHierarchy as EnvDTE80.IInternalExtenderProvider; - - if(outerHierarchy != null) - { - return outerHierarchy.GetExtender(extenderCATID, extenderName, extendeeObject, extenderSite, cookie); - } - - return null; - } - - object EnvDTE80.IInternalExtenderProvider.GetExtenderNames(string extenderCATID, object extendeeObject) - { - EnvDTE80.IInternalExtenderProvider outerHierarchy = this.Node.ProjectMgr.InteropSafeIVsHierarchy as EnvDTE80.IInternalExtenderProvider; - - if(outerHierarchy != null) - { - return outerHierarchy.GetExtenderNames(extenderCATID, extendeeObject); - } - - return null; - } - - #endregion - - #region ExtenderSupport - [Browsable(false)] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CATID")] - public virtual string ExtenderCATID - { - get - { - Guid catid = this.Node.ProjectMgr.GetCATIDForType(this.GetType()); - if(Guid.Empty.CompareTo(catid) == 0) - { - return null; - } - return catid.ToString("B"); - } - } - - [Browsable(false)] - public object ExtenderNames() - { - EnvDTE.ObjectExtenders extenderService = (EnvDTE.ObjectExtenders)this.Node.GetService(typeof(EnvDTE.ObjectExtenders)); - Debug.Assert(extenderService != null, "Could not get the ObjectExtenders object from the services exposed by this property object"); - if(extenderService == null) - { - throw new InvalidOperationException(); - } - return extenderService.GetExtenderNames(this.ExtenderCATID, this); - } - - public object Extender(string extenderName) - { - EnvDTE.ObjectExtenders extenderService = (EnvDTE.ObjectExtenders)this.Node.GetService(typeof(EnvDTE.ObjectExtenders)); - Debug.Assert(extenderService != null, "Could not get the ObjectExtenders object from the services exposed by this property object"); - if(extenderService == null) - { - throw new InvalidOperationException(); - } - return extenderService.GetExtender(this.ExtenderCATID, extenderName, this); - } - - #endregion - } - - [CLSCompliant(false), ComVisible(true)] - public class FileNodeProperties : NodeProperties - { - #region properties - [SRCategoryAttribute(SR.Advanced)] - [LocDisplayName(SR.BuildAction)] - [SRDescriptionAttribute(SR.BuildActionDescription)] - public virtual BuildAction BuildAction - { - get - { - string value = this.Node.ItemNode.ItemName; - if(value == null || value.Length == 0) - { - return BuildAction.None; - } - return (BuildAction)Enum.Parse(typeof(BuildAction), value); - } - set - { - this.Node.ItemNode.ItemName = value.ToString(); - } - } - - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.FileName)] - [SRDescriptionAttribute(SR.FileNameDescription)] - public string FileName - { - get - { - return this.Node.Caption; - } - set - { - this.Node.SetEditLabel(value); - } - } - - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.FullPath)] - [SRDescriptionAttribute(SR.FullPathDescription)] - public string FullPath - { - get - { - return this.Node.Url; - } - } - - #region non-browsable properties - used for automation only - [Browsable(false)] - public string Extension - { - get - { - return Path.GetExtension(this.Node.Caption); - } - } - #endregion - - #endregion - - #region ctors - public FileNodeProperties(HierarchyNode node) - : base(node) - { - } - #endregion - - #region overridden methods - public override string GetClassName() - { - return SR.GetString(SR.FileProperties, CultureInfo.CurrentUICulture); - } - - // !EFW - Added to return a read-only property descriptor for non-member items - public override DesignPropertyDescriptor CreateDesignPropertyDescriptor(PropertyDescriptor propertyDescriptor) - { - if(this.Node.IsNonMemberItem) - return new ReadOnlyDesignPropertyDescriptor(propertyDescriptor); - - return base.CreateDesignPropertyDescriptor(propertyDescriptor); - } - - // !EFW - Added to exclude BuildAction for non-member items - public override PropertyDescriptorCollection GetProperties() - { - var props = base.GetProperties(); - - if(this.Node.IsNonMemberItem) - { - var p = props.Find("BuildAction", true); - - if(p != null) - props.Remove(p); - } - - return props; - } - - // !EFW - Added to exclude BuildAction for non-member items - public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) - { - var props = base.GetProperties(attributes); - - if(this.Node.IsNonMemberItem) - { - var p = props.Find("BuildAction", true); - - if(p != null) - props.Remove(p); - } - - return props; - } - #endregion - } - - // !EFW - Added for non-member file items - /// - /// This is a read-only property descriptor used for non-member file items - /// - public class ReadOnlyDesignPropertyDescriptor : DesignPropertyDescriptor - { - #region Constructor - //===================================================================== - - /// - /// Initializes a new instance of the class. - /// - /// The to wrap. - public ReadOnlyDesignPropertyDescriptor(PropertyDescriptor propertyDescriptor) : base(propertyDescriptor) - { - } - #endregion - - #region Overrides - //===================================================================== - - /// - /// Properties are always read-only for non-member items - /// - public override bool IsReadOnly - { - get { return true; } - } - - /// - /// This is overridden to show property values without bolding - /// - /// The component to check. - /// Always returns false - public override bool ShouldSerializeValue(object component) - { - return false; - } - #endregion - } - - [CLSCompliant(false), ComVisible(true)] - public class DependentFileNodeProperties : NodeProperties - { - #region properties - [SRCategoryAttribute(SR.Advanced)] - [LocDisplayName(SR.BuildAction)] - [SRDescriptionAttribute(SR.BuildActionDescription)] - public virtual BuildAction BuildAction - { - get - { - string value = this.Node.ItemNode.ItemName; - if(value == null || value.Length == 0) - { - return BuildAction.None; - } - return (BuildAction)Enum.Parse(typeof(BuildAction), value); - } - set - { - this.Node.ItemNode.ItemName = value.ToString(); - } - } - - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.FileName)] - [SRDescriptionAttribute(SR.FileNameDescription)] - public virtual string FileName - { - get - { - return this.Node.Caption; - } - } - - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.FullPath)] - [SRDescriptionAttribute(SR.FullPathDescription)] - public string FullPath - { - get - { - return this.Node.Url; - } - } - #endregion - - #region ctors - public DependentFileNodeProperties(HierarchyNode node) - : base(node) - { - } - - #endregion - - #region overridden methods - public override string GetClassName() - { - return SR.GetString(SR.FileProperties, CultureInfo.CurrentUICulture); - } - #endregion - } - - [CLSCompliant(false), ComVisible(true)] - public class SingleFileGeneratorNodeProperties : FileNodeProperties - { - #region fields - private EventHandler onCustomToolChanged; - private EventHandler onCustomToolNameSpaceChanged; - #endregion - - #region custom tool events - internal event EventHandler OnCustomToolChanged - { - add { onCustomToolChanged += value; } - remove { onCustomToolChanged -= value; } - } - - internal event EventHandler OnCustomToolNameSpaceChanged - { - add { onCustomToolNameSpaceChanged += value; } - remove { onCustomToolNameSpaceChanged -= value; } - } - - #endregion - - #region properties - [SRCategoryAttribute(SR.Advanced)] - [LocDisplayName(SR.CustomTool)] - [SRDescriptionAttribute(SR.CustomToolDescription)] - public virtual string CustomTool - { - get - { - return this.Node.ItemNode.GetMetadata(ProjectFileConstants.Generator); - } - set - { - if (CustomTool != value) - { - this.Node.ItemNode.SetMetadata(ProjectFileConstants.Generator, value != string.Empty ? value : null); - HierarchyNodeEventArgs args = new HierarchyNodeEventArgs(this.Node); - if (onCustomToolChanged != null) - { - onCustomToolChanged(this.Node, args); - } - } - } - } - - [SRCategoryAttribute(VisualStudio.Project.SR.Advanced)] - [LocDisplayName(SR.CustomToolNamespace)] - [SRDescriptionAttribute(SR.CustomToolNamespaceDescription)] - public virtual string CustomToolNamespace - { - get - { - return this.Node.ItemNode.GetMetadata(ProjectFileConstants.CustomToolNamespace); - } - set - { - if (CustomToolNamespace != value) - { - this.Node.ItemNode.SetMetadata(ProjectFileConstants.CustomToolNamespace, value != String.Empty ? value : null); - HierarchyNodeEventArgs args = new HierarchyNodeEventArgs(this.Node); - if (onCustomToolNameSpaceChanged != null) - { - onCustomToolNameSpaceChanged(this.Node, args); - } - } - } - } - #endregion - - #region ctors - public SingleFileGeneratorNodeProperties(HierarchyNode node) - : base(node) - { - } - #endregion - } - - [CLSCompliant(false), ComVisible(true)] - public class ProjectNodeProperties : NodeProperties - { - #region properties - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.ProjectFolder)] - [SRDescriptionAttribute(SR.ProjectFolderDescription)] - [AutomationBrowsable(false)] - public string ProjectFolder - { - get - { - return this.Node.ProjectMgr.ProjectFolder; - } - } - - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.ProjectFile)] - [SRDescriptionAttribute(SR.ProjectFileDescription)] - [AutomationBrowsable(false)] - public string ProjectFile - { - get - { - return this.Node.ProjectMgr.ProjectFile; - } - set - { - this.Node.ProjectMgr.ProjectFile = value; - } - } - - #region non-browsable properties - used for automation only - [Browsable(false)] - public string FileName - { - get - { - return this.Node.ProjectMgr.ProjectFile; - } - set - { - this.Node.ProjectMgr.ProjectFile = value; - } - } - - - [Browsable(false)] - public string FullPath - { - get - { - string fullPath = this.Node.ProjectMgr.ProjectFolder; - if(!fullPath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) - { - return fullPath + Path.DirectorySeparatorChar; - } - else - { - return fullPath; - } - } - } - #endregion - - #endregion - - #region ctors - public ProjectNodeProperties(ProjectNode node) - : base(node) - { - } - #endregion - - #region overridden methods - public override string GetClassName() - { - return SR.GetString(SR.ProjectProperties, CultureInfo.CurrentUICulture); - } - - /// - /// ICustomTypeDescriptor.GetEditor - /// To enable the "Property Pages" button on the properties browser - /// the browse object (project properties) need to be unmanaged - /// or it needs to provide an editor of type ComponentEditor. - /// - /// Type of the editor - /// Editor - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", - Justification="The service provider is used by the PropertiesEditorLauncher")] - public override object GetEditor(Type editorBaseType) - { - // Override the scenario where we are asked for a ComponentEditor - // as this is how the Properties Browser calls us - if(editorBaseType == typeof(ComponentEditor)) - { - IOleServiceProvider sp; - ErrorHandler.ThrowOnFailure(this.Node.GetSite(out sp)); - return new PropertiesEditorLauncher(new ServiceProvider(sp)); - } - - return base.GetEditor(editorBaseType); - } - - public override int GetCfgProvider(out IVsCfgProvider p) - { - if(this.Node != null && this.Node.ProjectMgr != null) - { - return this.Node.ProjectMgr.GetCfgProvider(out p); - } - - return base.GetCfgProvider(out p); - } - #endregion - } - - [CLSCompliant(false), ComVisible(true)] - public class FolderNodeProperties : NodeProperties - { - #region properties - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.FolderName)] - [SRDescriptionAttribute(SR.FolderNameDescription)] - [AutomationBrowsable(false)] - public string FolderName - { - get - { - return this.Node.Caption; - } - set - { - this.Node.SetEditLabel(value); - this.Node.ReDraw(UIHierarchyElement.Caption); - } - } - - #region properties - used for automation only - [Browsable(false)] - [AutomationBrowsable(true)] - public string FileName - { - get - { - return this.Node.Caption; - } - set - { - this.Node.SetEditLabel(value); - } - } - - [Browsable(false)] - [AutomationBrowsable(true)] - public string FullPath - { - get - { - string fullPath = this.Node.GetMkDocument(); - if(!fullPath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) - { - return fullPath + Path.DirectorySeparatorChar; - } - else - { - return fullPath; - } - } - } - #endregion - - #endregion - - #region ctors - public FolderNodeProperties(HierarchyNode node) - : base(node) - { - } - #endregion - - #region overridden methods - public override string GetClassName() - { - return SR.GetString(SR.FolderProperties, CultureInfo.CurrentUICulture); - } - - // !EFW - Added to return a read-only property descriptor for non-member items - public override DesignPropertyDescriptor CreateDesignPropertyDescriptor(PropertyDescriptor propertyDescriptor) - { - if(this.Node.IsNonMemberItem) - return new ReadOnlyDesignPropertyDescriptor(propertyDescriptor); - - return base.CreateDesignPropertyDescriptor(propertyDescriptor); - } - #endregion - } - - [CLSCompliant(false), ComVisible(true)] - public class ReferenceNodeProperties : NodeProperties - { - #region properties - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.RefName)] - [SRDescriptionAttribute(SR.RefNameDescription)] - [Browsable(true)] - [AutomationBrowsable(true)] - public override string Name - { - get - { - return this.Node.Caption; - } - } - - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.CopyToLocal)] - [SRDescriptionAttribute(SR.CopyToLocalDescription)] - public bool CopyToLocal - { - get - { - string copyLocal = this.GetProperty(ProjectFileConstants.Private, "False"); - if(copyLocal == null || copyLocal.Length == 0) - return true; - return bool.Parse(copyLocal); - } - set - { - this.SetProperty(ProjectFileConstants.Private, value.ToString()); - } - } - - [SRCategoryAttribute(SR.Misc)] - [LocDisplayName(SR.FullPath)] - [SRDescriptionAttribute(SR.FullPathDescription)] - public virtual string FullPath - { - get - { - return this.Node.Url; - } - } - #endregion - - #region ctors - public ReferenceNodeProperties(HierarchyNode node) - : base(node) - { - } - #endregion - - #region overridden methods - public override string GetClassName() - { - return SR.GetString(SR.ReferenceProperties, CultureInfo.CurrentUICulture); - } - #endregion - } - - [ComVisible(true)] - public class ProjectReferencesProperties : ReferenceNodeProperties - { - #region ctors - public ProjectReferencesProperties(ProjectReferenceNode node) - : base(node) - { - } - #endregion - - #region overridden methods - public override string FullPath - { - get - { - return ((ProjectReferenceNode)Node).ReferencedProjectOutputPath; - } - } - #endregion - - // !EFW - Added support for ReferenceOutputAssembly - [SRCategory(SR.Misc)] - [LocDisplayName(SR.ReferenceOutputAssembly)] - [SRDescription(SR.ReferenceOutputAssemblyDescription)] - public virtual bool ReferenceOutputAssembly - { - get { return ((ProjectReferenceNode)this.Node).ReferenceOutputAssembly; } - set { ((ProjectReferenceNode)this.Node).ReferenceOutputAssembly = value; } - } - } - - [ComVisible(true)] - public class ComReferenceProperties : ReferenceNodeProperties - { - public ComReferenceProperties(ComReferenceNode node) - : base(node) - { - } - - [SRCategory(SR.Misc)] - [LocDisplayName(SR.EmbedInteropTypes)] - [SRDescription(SR.EmbedInteropTypesDescription)] - public virtual bool EmbedInteropTypes - { - get { return ((ComReferenceNode)this.Node).EmbedInteropTypes; } - set { ((ComReferenceNode)this.Node).EmbedInteropTypes = value; } - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/OleServiceProvider.cs b/SHFB/Source/MPFProj_VS2010/OleServiceProvider.cs deleted file mode 100644 index dd693dc6..00000000 --- a/SHFB/Source/MPFProj_VS2010/OleServiceProvider.cs +++ /dev/null @@ -1,297 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - public class OleServiceProvider : IOleServiceProvider, IDisposable - { - #region Public Types - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - public delegate object ServiceCreatorCallback(Type serviceType); - #endregion - - #region Private Types - private class ServiceData : IDisposable - { - private Type serviceType; - private object instance; - private ServiceCreatorCallback creator; - private bool shouldDispose; - public ServiceData(Type serviceType, object instance, ServiceCreatorCallback callback, bool shouldDispose) - { - if(null == serviceType) - { - throw new ArgumentNullException("serviceType"); - } - - if((null == instance) && (null == callback)) - { - throw new ArgumentNullException("instance"); - } - - this.serviceType = serviceType; - this.instance = instance; - this.creator = callback; - this.shouldDispose = shouldDispose; - } - - public object ServiceInstance - { - get - { - if(null == instance) - { - instance = creator(serviceType); - } - return instance; - } - } - - public Guid Guid - { - get { return serviceType.GUID; } - } - - public void Dispose() - { - if((shouldDispose) && (null != instance)) - { - IDisposable disp = instance as IDisposable; - if(null != disp) - { - disp.Dispose(); - } - instance = null; - } - creator = null; - GC.SuppressFinalize(this); - } - } - #endregion - - #region fields - - private Dictionary services = new Dictionary(); - private bool isDisposed; - /// - /// Defines an object that will be a mutex for this object for synchronizing thread calls. - /// - private static volatile object Mutex = new object(); - #endregion - - #region ctors - public OleServiceProvider() - { - } - #endregion - - #region IOleServiceProvider Members - - public int QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject) - { - ppvObject = (IntPtr)0; - int hr = VSConstants.S_OK; - - ServiceData serviceInstance = null; - - if(services != null && services.ContainsKey(guidService)) - { - serviceInstance = services[guidService]; - } - - if(serviceInstance == null) - { - return VSConstants.E_NOINTERFACE; - } - - // Now check to see if the user asked for an IID other than - // IUnknown. If so, we must do another QI. - // - if(riid.Equals(NativeMethods.IID_IUnknown)) - { - ppvObject = Marshal.GetIUnknownForObject(serviceInstance.ServiceInstance); - } - else - { - IntPtr pUnk = IntPtr.Zero; - try - { - pUnk = Marshal.GetIUnknownForObject(serviceInstance.ServiceInstance); - hr = Marshal.QueryInterface(pUnk, ref riid, out ppvObject); - } - finally - { - if(pUnk != IntPtr.Zero) - { - Marshal.Release(pUnk); - } - } - } - - return hr; - } - - #endregion - - #region Dispose - - /// - /// The IDispose interface Dispose method for disposing the object determinastically. - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - /// - /// Adds the given service to the service container. - /// - /// The type of the service to add. - /// An instance of the service. - /// true if the Dipose of the service provider is allowed to dispose the sevice instance. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", - Justification = "The services created here will be disposed in the Dispose method of this type.")] - public void AddService(Type serviceType, object serviceInstance, bool shouldDisposeServiceInstance) - { - // Create the description of this service. Note that we don't do any validation - // of the parameter here because the constructor of ServiceData will do it for us. - ServiceData service = new ServiceData(serviceType, serviceInstance, null, shouldDisposeServiceInstance); - - // Now add the service desctription to the dictionary. - AddService(service); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", - Justification="The services created here will be disposed in the Dispose method of this type.")] - public void AddService(Type serviceType, ServiceCreatorCallback callback, bool shouldDisposeServiceInstance) - { - // Create the description of this service. Note that we don't do any validation - // of the parameter here because the constructor of ServiceData will do it for us. - ServiceData service = new ServiceData(serviceType, null, callback, shouldDisposeServiceInstance); - - // Now add the service desctription to the dictionary. - AddService(service); - } - - private void AddService(ServiceData data) - { - // Make sure that the collection of services is created. - if(null == services) - { - services = new Dictionary(); - } - - // Disallow the addition of duplicate services. - if(services.ContainsKey(data.Guid)) - { - throw new InvalidOperationException(); - } - - services.Add(data.Guid, data); - } - - /// - /// Removes the given service type from the service container. - /// - public void RemoveService(Type serviceType) - { - if(serviceType == null) - { - throw new ArgumentNullException("serviceType"); - } - - if(services.ContainsKey(serviceType.GUID)) - { - services.Remove(serviceType.GUID); - } - } - - #region helper methods - /// - /// The method that does the cleanup. - /// - /// - protected virtual void Dispose(bool disposing) - { - // Everybody can go here. - if(!this.isDisposed) - { - // Synchronize calls to the Dispose simulteniously. - lock(Mutex) - { - if(disposing) - { - // Remove all our services - if(services != null) - { - foreach(ServiceData data in services.Values) - { - data.Dispose(); - } - services.Clear(); - services = null; - } - } - - this.isDisposed = true; - } - } - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Output.cs b/SHFB/Source/MPFProj_VS2010/Output.cs deleted file mode 100644 index fc865e56..00000000 --- a/SHFB/Source/MPFProj_VS2010/Output.cs +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.Build.Execution; - -namespace Microsoft.VisualStudio.Project -{ - class Output : IVsOutput2 - { - private ProjectNode project; - private ProjectItemInstance output; - - /// - /// Constructor for IVSOutput2 implementation - /// - /// Project that produce this output - /// MSBuild generated item corresponding to the output assembly (by default, these would be of type MainAssembly - public Output(ProjectNode projectManager, ProjectItemInstance outputAssembly) - { - if(projectManager == null) - throw new ArgumentNullException("projectManager"); - if(outputAssembly == null) - throw new ArgumentNullException("outputAssembly"); - - project = projectManager; - output = outputAssembly; - } - - #region IVsOutput2 Members - - public int get_CanonicalName(out string pbstrCanonicalName) - { - // Get the output assembly path (including the name) - pbstrCanonicalName = output.GetMetadataValue(ProjectFileConstants.FinalOutputPath); - Debug.Assert(!String.IsNullOrEmpty(pbstrCanonicalName), "Output Assembly not defined"); - - // Make sure we have a full path - if(!System.IO.Path.IsPathRooted(pbstrCanonicalName)) - { - pbstrCanonicalName = new Url(project.BaseURI, pbstrCanonicalName).AbsoluteUrl; - } - return VSConstants.S_OK; - } - - /// - /// This path must start with file:/// if it wants other project - /// to be able to reference the output on disk. - /// If the output is not on disk, then this requirement does not - /// apply as other projects probably don't know how to access it. - /// - public virtual int get_DeploySourceURL(out string pbstrDeploySourceURL) - { - string path = output.GetMetadataValue(ProjectFileConstants.FinalOutputPath); - if(string.IsNullOrEmpty(path)) - { - throw new InvalidOperationException(); - } - if(path.Length < 9 || String.Compare(path.Substring(0, 8), "file:///", StringComparison.OrdinalIgnoreCase) != 0) - path = "file:///" + path; // TODO: does not work with '#' char, see e.g. bug 641942 - pbstrDeploySourceURL = path; - return VSConstants.S_OK; - } - - public int get_DisplayName(out string pbstrDisplayName) - { - return this.get_CanonicalName(out pbstrDisplayName); - } - - public virtual int get_Property(string szProperty, out object pvar) - { - if (string.IsNullOrEmpty(szProperty)) - { - pvar = null; - return VSConstants.E_INVALIDARG; - } - - if (string.Equals(szProperty, "OUTPUTLOC", StringComparison.OrdinalIgnoreCase)) - { - szProperty = ProjectFileConstants.FinalOutputPath; - } - - string value = output.GetMetadataValue(szProperty); - pvar = value; - - // If we don't have a value, we are expected to return unimplemented - if (string.IsNullOrEmpty(value)) - { - return VSConstants.E_NOTIMPL; - } - - // Special hack for COM2REG property: it's a bool rather than a string, and always true, for some reason. - if (string.Equals(szProperty, "COM2REG", StringComparison.OrdinalIgnoreCase)) - { - pvar = true; - } - - return VSConstants.S_OK; - } - - public int get_RootRelativeURL(out string pbstrRelativePath) - { - pbstrRelativePath = String.Empty; - object variant; - // get the corresponding property - - if(ErrorHandler.Succeeded(this.get_Property("TargetPath", out variant))) - { - string var = variant as String; - - if(var != null) - { - pbstrRelativePath = var; - } - } - - return VSConstants.S_OK; - } - - public virtual int get_Type(out Guid pguidType) - { - pguidType = Guid.Empty; - throw new NotImplementedException(); - } - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/OutputGroup.cs b/SHFB/Source/MPFProj_VS2010/OutputGroup.cs deleted file mode 100644 index 5e22bb17..00000000 --- a/SHFB/Source/MPFProj_VS2010/OutputGroup.cs +++ /dev/null @@ -1,302 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using MSBuild = Microsoft.Build.Evaluation; -using MSBuildExecution = Microsoft.Build.Execution; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Allows projects to group outputs according to usage. - /// - [CLSCompliant(false), ComVisible(true)] - public class OutputGroup : IVsOutputGroup2 - { - #region fields - private ProjectConfig projectCfg; - private ProjectNode project; - - private List outputs = new List(); - private Output keyOutput; - private string name; - private string targetName; - #endregion - - #region properties - /// - /// Get the project configuration object associated with this output group - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cfg")] - protected ProjectConfig ProjectCfg - { - get { return projectCfg; } - } - - /// - /// Get the project object that produces this output group. - /// - protected ProjectNode Project - { - get { return project; } - } - - /// - /// Gets the msbuild target name which is assciated to the outputgroup. - /// ProjectNode defines a static collection of output group names and their associated MsBuild target - /// - protected string TargetName - { - get { return targetName; } - } - #endregion - - #region ctors - - /// - /// Constructor for IVSOutputGroup2 implementation - /// - /// Name of the output group. See VS_OUTPUTGROUP_CNAME_Build in vsshell.idl for the list of standard values - /// MSBuild target name - /// Project that produce this output - /// Configuration that produce this output - public OutputGroup(string outputName, string msBuildTargetName, ProjectNode projectManager, ProjectConfig configuration) - { - if(outputName == null) - throw new ArgumentNullException("outputName"); - if(msBuildTargetName == null) - throw new ArgumentNullException("outputName"); - if(projectManager == null) - throw new ArgumentNullException("projectManager"); - if(configuration == null) - throw new ArgumentNullException("configuration"); - - name = outputName; - targetName = msBuildTargetName; - project = projectManager; - projectCfg = configuration; - } - #endregion - - #region virtual methods - protected virtual void Refresh() - { - // Let MSBuild know which configuration we are working with - project.SetConfiguration(projectCfg.ConfigName); - - // Generate dependencies if such a task exist - const string generateDependencyList = "AllProjectOutputGroups"; - if(project.BuildProject.Targets.ContainsKey(generateDependencyList)) - { - bool succeeded = false; - project.BuildTarget(generateDependencyList, out succeeded); - Debug.Assert(succeeded, "Failed to build target: " + generateDependencyList); - } - - // Rebuild the content of our list of output - string outputType = this.targetName + "Output"; - this.outputs.Clear(); - foreach (MSBuildExecution.ProjectItemInstance assembly in project.CurrentConfig.GetItems(outputType)) - { - Output output = new Output(project, assembly); - this.outputs.Add(output); - - // See if it is our key output - if(String.Compare(assembly.GetMetadataValue("IsKeyOutput"), true.ToString(), StringComparison.OrdinalIgnoreCase) == 0) - keyOutput = output; - } - - project.SetCurrentConfiguration(); - - // Now that the group is built we have to check if it is invalidated by a property - // change on the project. - project.OnProjectPropertyChanged += new EventHandler(OnProjectPropertyChanged); - } - - public virtual void InvalidateGroup() - { - // Set keyOutput to null so that a refresh will be performed the next time - // a property getter is called. - if(null != keyOutput) - { - // Once the group is invalidated there is no more reason to listen for events. - project.OnProjectPropertyChanged -= new EventHandler(OnProjectPropertyChanged); - } - keyOutput = null; - } - #endregion - - #region event handlers - private void OnProjectPropertyChanged(object sender, ProjectPropertyChangedArgs args) - { - // In theory here we should decide if we have to invalidate the group according with the kind of property - // that is changed. - InvalidateGroup(); - } - #endregion - - #region IVsOutputGroup2 Members - - public virtual int get_CanonicalName(out string pbstrCanonicalName) - { - pbstrCanonicalName = this.name; - return VSConstants.S_OK; - } - - public virtual int get_DeployDependencies(uint celt, IVsDeployDependency[] rgpdpd, uint[] pcActual) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int get_Description(out string pbstrDescription) - { - pbstrDescription = null; - - string description; - int hr = this.get_CanonicalName(out description); - if(ErrorHandler.Succeeded(hr)) - pbstrDescription = this.Project.GetOutputGroupDescription(description); - return hr; - } - - public virtual int get_DisplayName(out string pbstrDisplayName) - { - pbstrDisplayName = null; - - string displayName; - int hr = this.get_CanonicalName(out displayName); - if(ErrorHandler.Succeeded(hr)) - pbstrDisplayName = this.Project.GetOutputGroupDisplayName(displayName); - return hr; - } - - public virtual int get_KeyOutput(out string pbstrCanonicalName) - { - pbstrCanonicalName = null; - if(keyOutput == null) - Refresh(); - if(keyOutput == null) - { - pbstrCanonicalName = String.Empty; - return VSConstants.S_FALSE; - } - return keyOutput.get_CanonicalName(out pbstrCanonicalName); - } - - public virtual int get_KeyOutputObject(out IVsOutput2 ppKeyOutput) - { - if(keyOutput == null) - Refresh(); - ppKeyOutput = keyOutput; - if(ppKeyOutput == null) - return VSConstants.S_FALSE; - return VSConstants.S_OK; - } - - public virtual int get_Outputs(uint celt, IVsOutput2[] rgpcfg, uint[] pcActual) - { - // Ensure that we are refreshed. This is somewhat of a hack that enables project to - // project reference scenarios to work. Normally, output groups are populated as part - // of build. However, in the project to project reference case, what ends up happening - // is that the referencing projects requests the referenced project's output group - // before a build is done on the referenced project. - // - // Furthermore, the project auto toolbox manager requires output groups to be populated - // on project reopen as well... - // - // In the end, this is probably the right thing to do, though -- as it keeps the output - // groups always up to date. - Refresh(); - - // See if only the caller only wants to know the count - if(celt == 0 || rgpcfg == null) - { - if(pcActual != null && pcActual.Length > 0) - pcActual[0] = (uint)outputs.Count; - return VSConstants.S_OK; - } - - // Fill the array with our outputs - uint count = 0; - foreach(Output output in outputs) - { - if(rgpcfg.Length > count && celt > count && output != null) - { - rgpcfg[count] = output; - ++count; - } - } - - if(pcActual != null && pcActual.Length > 0) - pcActual[0] = count; - - // If the number asked for does not match the number returned, return S_FALSE - return (count == celt) ? VSConstants.S_OK : VSConstants.S_FALSE; - } - - public virtual int get_ProjectCfg(out IVsProjectCfg2 ppIVsProjectCfg2) - { - ppIVsProjectCfg2 = (IVsProjectCfg2)this.projectCfg; - return VSConstants.S_OK; - } - - public virtual int get_Property(string pszProperty, out object pvar) - { - pvar = project.GetProjectProperty(pszProperty); - return VSConstants.S_OK; - } - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectConfig.cs b/SHFB/Source/MPFProj_VS2010/ProjectConfig.cs deleted file mode 100644 index 7153a756..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectConfig.cs +++ /dev/null @@ -1,1057 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -//#define ConfigTrace -using Microsoft.VisualStudio.Shell.Interop; -using MSBuild = Microsoft.Build.Evaluation; -using MSBuildExecution = Microsoft.Build.Execution; -using MSBuildConstruction = Microsoft.Build.Construction; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false), ComVisible(true)] - public class ProjectConfig : - IVsCfg, - IVsProjectCfg, - IVsProjectCfg2, - IVsProjectFlavorCfg, - IVsDebuggableProjectCfg, - ISpecifyPropertyPages, - IVsSpecifyProjectDesignerPages, - IVsCfgBrowseObject - { - #region constants - internal const string Debug = "Debug"; - internal const string Release = "Release"; - internal const string AnyCPU = "AnyCPU"; - #endregion - - #region fields - private ProjectNode project; - private string configName; - private MSBuildExecution.ProjectInstance currentConfig; - private List outputGroups; - private IProjectConfigProperties configurationProperties; - private IVsProjectFlavorCfg flavoredCfg; - private BuildableProjectConfig buildableCfg; - #endregion - - #region properties - public ProjectNode ProjectMgr - { - get - { - return this.project; - } - } - - public string ConfigName - { - get - { - return this.configName; - } - set - { - this.configName = value; - } - } - - public virtual object ConfigurationProperties - { - get - { - if(this.configurationProperties == null) - { - this.configurationProperties = new ProjectConfigProperties(this); - } - return this.configurationProperties; - } - } - - protected IList OutputGroups - { - get - { - if(null == this.outputGroups) - { - // Initialize output groups - this.outputGroups = new List(); - - // Get the list of group names from the project. - // The main reason we get it from the project is to make it easier for someone to modify - // it by simply overriding that method and providing the correct MSBuild target(s). - IList> groupNames = project.GetOutputGroupNames(); - - if(groupNames != null) - { - // Populate the output array - foreach(KeyValuePair group in groupNames) - { - OutputGroup outputGroup = CreateOutputGroup(project, group); - this.outputGroups.Add(outputGroup); - } - } - - } - return this.outputGroups; - } - } - #endregion - - #region ctors - public ProjectConfig(ProjectNode project, string configuration) - { - this.project = project; - this.configName = configuration; - - // Because the project can be aggregated by a flavor, we need to make sure - // we get the outer most implementation of that interface (hence: project --> IUnknown --> Interface) - IntPtr projectUnknown = Marshal.GetIUnknownForObject(this.ProjectMgr); - try - { - IVsProjectFlavorCfgProvider flavorCfgProvider = (IVsProjectFlavorCfgProvider)Marshal.GetTypedObjectForIUnknown(projectUnknown, typeof(IVsProjectFlavorCfgProvider)); - ErrorHandler.ThrowOnFailure(flavorCfgProvider.CreateProjectFlavorCfg(this, out flavoredCfg)); - if(flavoredCfg == null) - throw new COMException(); - } - finally - { - if(projectUnknown != IntPtr.Zero) - Marshal.Release(projectUnknown); - } - // if the flavored object support XML fragment, initialize it - IPersistXMLFragment persistXML = flavoredCfg as IPersistXMLFragment; - if(null != persistXML) - { - this.project.LoadXmlFragment(persistXML, this.DisplayName); - } - } - #endregion - - #region methods - protected virtual OutputGroup CreateOutputGroup(ProjectNode project, KeyValuePair group) - { - OutputGroup outputGroup = new OutputGroup(group.Key, group.Value, project, this); - return outputGroup; - } - - public void PrepareBuild(bool clean) - { - project.PrepareBuild(this.configName, clean); - } - - public virtual string GetConfigurationProperty(string propertyName, bool resetCache) - { - MSBuildExecution.ProjectPropertyInstance property = GetMsBuildProperty(propertyName, resetCache); - if (property == null) - return null; - - return property.EvaluatedValue; - } - - public virtual void SetConfigurationProperty(string propertyName, string propertyValue) - { - if(!this.project.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - string condition = String.Format(CultureInfo.InvariantCulture, ConfigProvider.configString, this.ConfigName); - - SetPropertyUnderCondition(propertyName, propertyValue, condition); - - // property cache will need to be updated - this.currentConfig = null; - - // Signal the output groups that something is changed - foreach(OutputGroup group in this.OutputGroups) - { - group.InvalidateGroup(); - } - this.project.SetProjectFileDirty(true); - - return; - } - - /// - /// Emulates the behavior of SetProperty(name, value, condition) on the old MSBuild object model. - /// This finds a property group with the specified condition (or creates one if necessary) then sets the property in there. - /// - private void SetPropertyUnderCondition(string propertyName, string propertyValue, string condition) - { - string conditionTrimmed = (condition == null) ? String.Empty : condition.Trim(); - - if (conditionTrimmed.Length == 0) - { - this.project.BuildProject.SetProperty(propertyName, propertyValue); - return; - } - - // New OM doesn't have a convenient equivalent for setting a property with a particular property group condition. - // So do it ourselves. - MSBuildConstruction.ProjectPropertyGroupElement newGroup = null; - - foreach (MSBuildConstruction.ProjectPropertyGroupElement group in this.project.BuildProject.Xml.PropertyGroups) - { - if (String.Equals(group.Condition.Trim(), conditionTrimmed, StringComparison.OrdinalIgnoreCase)) - { - newGroup = group; - break; - } - } - - if (newGroup == null) - { - newGroup = this.project.BuildProject.Xml.AddPropertyGroup(); // Adds after last existing PG, else at start of project - newGroup.Condition = condition; - } - - foreach (MSBuildConstruction.ProjectPropertyElement property in newGroup.PropertiesReversed) // If there's dupes, pick the last one so we win - { - if (String.Equals(property.Name, propertyName, StringComparison.OrdinalIgnoreCase) && property.Condition.Length == 0) - { - property.Value = propertyValue; - return; - } - } - - newGroup.AddProperty(propertyName, propertyValue); - } - - /// - /// If flavored, and if the flavor config can be dirty, ask it if it is dirty - /// - /// Project file or user file - /// 0 = not dirty - internal int IsFlavorDirty(_PersistStorageType storageType) - { - int isDirty = 0; - if(this.flavoredCfg != null && this.flavoredCfg is IPersistXMLFragment) - { - ErrorHandler.ThrowOnFailure(((IPersistXMLFragment)this.flavoredCfg).IsFragmentDirty((uint)storageType, out isDirty)); - } - return isDirty; - } - - /// - /// If flavored, ask the flavor if it wants to provide an XML fragment - /// - /// Guid of the flavor - /// Project file or user file - /// Fragment that the flavor wants to save - /// HRESULT - internal int GetXmlFragment(Guid flavor, _PersistStorageType storageType, out string fragment) - { - fragment = null; - int hr = VSConstants.S_OK; - if(this.flavoredCfg != null && this.flavoredCfg is IPersistXMLFragment) - { - Guid flavorGuid = flavor; - hr = ((IPersistXMLFragment)this.flavoredCfg).Save(ref flavorGuid, (uint)storageType, out fragment, 1); - } - return hr; - } - #endregion - - #region IVsSpecifyPropertyPages - public void GetPages(CAUUID[] pages) - { - this.GetCfgPropertyPages(pages); - } - #endregion - - #region IVsSpecifyProjectDesignerPages - /// - /// Implementation of the IVsSpecifyProjectDesignerPages. It will retun the pages that are configuration dependent. - /// - /// The pages to return. - /// VSConstants.S_OK - public virtual int GetProjectDesignerPages(CAUUID[] pages) - { - this.GetCfgPropertyPages(pages); - return VSConstants.S_OK; - } - #endregion - - #region IVsCfg methods - /// - /// The display name is a two part item - /// first part is the config name, 2nd part is the platform name - /// - public virtual int get_DisplayName(out string name) - { - name = DisplayName; - return VSConstants.S_OK; - } - - private string DisplayName - { - get - { - string name; - string[] platform = new string[1]; - uint[] actual = new uint[1]; - name = this.configName; - // currently, we only support one platform, so just add it.. - IVsCfgProvider provider; - ErrorHandler.ThrowOnFailure(project.GetCfgProvider(out provider)); - ErrorHandler.ThrowOnFailure(((IVsCfgProvider2)provider).GetPlatformNames(1, platform, actual)); - if(!string.IsNullOrEmpty(platform[0])) - { - name += "|" + platform[0]; - } - return name; - } - } - public virtual int get_IsDebugOnly(out int fDebug) - { - fDebug = 0; - if(this.configName == "Debug") - { - fDebug = 1; - } - return VSConstants.S_OK; - } - public virtual int get_IsReleaseOnly(out int fRelease) - { - CCITracing.TraceCall(); - fRelease = 0; - if(this.configName == "Release") - { - fRelease = 1; - } - return VSConstants.S_OK; - } - #endregion - - #region IVsProjectCfg methods - public virtual int EnumOutputs(out IVsEnumOutputs eo) - { - CCITracing.TraceCall(); - eo = null; - return VSConstants.E_NOTIMPL; - } - - public virtual int get_BuildableProjectCfg(out IVsBuildableProjectCfg pb) - { - CCITracing.TraceCall(); - if(buildableCfg == null) - buildableCfg = new BuildableProjectConfig(this); - pb = buildableCfg; - return VSConstants.S_OK; - } - - public virtual int get_CanonicalName(out string name) - { - return ((IVsCfg)this).get_DisplayName(out name); - } - - public virtual int get_IsPackaged(out int pkgd) - { - CCITracing.TraceCall(); - pkgd = 0; - return VSConstants.S_OK; - } - - public virtual int get_IsSpecifyingOutputSupported(out int f) - { - CCITracing.TraceCall(); - f = 1; - return VSConstants.S_OK; - } - - public virtual int get_Platform(out Guid platform) - { - CCITracing.TraceCall(); - platform = Guid.Empty; - return VSConstants.E_NOTIMPL; - } - - public virtual int get_ProjectCfgProvider(out IVsProjectCfgProvider p) - { - CCITracing.TraceCall(); - p = null; - IVsCfgProvider cfgProvider = null; - this.project.GetCfgProvider(out cfgProvider); - if(cfgProvider != null) - { - p = cfgProvider as IVsProjectCfgProvider; - } - - return (null == p) ? VSConstants.E_NOTIMPL : VSConstants.S_OK; - } - - public virtual int get_RootURL(out string root) - { - CCITracing.TraceCall(); - root = null; - return VSConstants.S_OK; - } - - public virtual int get_TargetCodePage(out uint target) - { - CCITracing.TraceCall(); - target = (uint)System.Text.Encoding.Default.CodePage; - return VSConstants.S_OK; - } - - public virtual int get_UpdateSequenceNumber(ULARGE_INTEGER[] li) - { - if (li == null) - { - throw new ArgumentNullException("li"); - } - - CCITracing.TraceCall(); - li[0] = new ULARGE_INTEGER(); - li[0].QuadPart = 0; - return VSConstants.S_OK; - } - - public virtual int OpenOutput(string name, out IVsOutput output) - { - CCITracing.TraceCall(); - output = null; - return VSConstants.E_NOTIMPL; - } - #endregion - - #region IVsDebuggableProjectCfg methods - /// - /// Called by the vs shell to start debugging (managed or unmanaged). - /// Override this method to support other debug engines. - /// - /// A flag that determines the conditions under which to start the debugger. For valid grfLaunch values, see __VSDBGLAUNCHFLAGS - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code - public virtual int DebugLaunch(uint grfLaunch) - { - CCITracing.TraceCall(); - - try - { - VsDebugTargetInfo info = new VsDebugTargetInfo(); - info.cbSize = (uint)Marshal.SizeOf(info); - info.dlo = Microsoft.VisualStudio.Shell.Interop.DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; - - // On first call, reset the cache, following calls will use the cached values - string property = GetConfigurationProperty("StartProgram", true); - if(string.IsNullOrEmpty(property)) - { - info.bstrExe = this.project.GetOutputAssembly(this.ConfigName); - } - else - { - info.bstrExe = property; - } - - property = GetConfigurationProperty("WorkingDirectory", false); - if(string.IsNullOrEmpty(property)) - { - info.bstrCurDir = Path.GetDirectoryName(info.bstrExe); - } - else - { - info.bstrCurDir = property; - } - - property = GetConfigurationProperty("CmdArgs", false); - if(!string.IsNullOrEmpty(property)) - { - info.bstrArg = property; - } - - property = GetConfigurationProperty("RemoteDebugMachine", false); - if(property != null && property.Length > 0) - { - info.bstrRemoteMachine = property; - } - - info.fSendStdoutToOutputWindow = 0; - - property = GetConfigurationProperty("EnableUnmanagedDebugging", false); - if(property != null && string.Compare(property, "true", StringComparison.OrdinalIgnoreCase) == 0) - { - //Set the unmanged debugger - //TODO change to vsconstant when it is available in VsConstants (guidNativeOnlyEng was the old name, maybe it has got a new name) - info.clsidCustom = new Guid("{3B476D35-A401-11D2-AAD4-00C04F990171}"); - } - else - { - //Set the managed debugger - info.clsidCustom = VSConstants.CLSID_ComPlusOnlyDebugEngine; - } - info.grfLaunch = grfLaunch; - VsShellUtilities.LaunchDebugger(this.project.Site, info); - } - catch(Exception e) - { - Trace.WriteLine("Exception : " + e.Message); - - return Marshal.GetHRForException(e); - } - - return VSConstants.S_OK; - } - - /// - /// Determines whether the debugger can be launched, given the state of the launch flags. - /// - /// Flags that determine the conditions under which to launch the debugger. - /// For valid grfLaunch values, see __VSDBGLAUNCHFLAGS or __VSDBGLAUNCHFLAGS2. - /// true if the debugger can be launched, otherwise false - /// S_OK if the method succeeds, otherwise an error code - public virtual int QueryDebugLaunch(uint flags, out int fCanLaunch) - { - CCITracing.TraceCall(); - string assembly = this.project.GetAssemblyName(this.ConfigName); - fCanLaunch = (assembly != null && assembly.ToUpperInvariant().EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) ? 1 : 0; - if(fCanLaunch == 0) - { - string property = GetConfigurationProperty("StartProgram", true); - fCanLaunch = (property != null && property.Length > 0) ? 1 : 0; - } - return VSConstants.S_OK; - } - #endregion - - #region IVsProjectCfg2 Members - - public virtual int OpenOutputGroup(string szCanonicalName, out IVsOutputGroup ppIVsOutputGroup) - { - ppIVsOutputGroup = null; - // Search through our list of groups to find the one they are looking forgroupName - foreach(OutputGroup group in OutputGroups) - { - string groupName; - group.get_CanonicalName(out groupName); - if(String.Compare(groupName, szCanonicalName, StringComparison.OrdinalIgnoreCase) == 0) - { - ppIVsOutputGroup = group; - break; - } - } - return (ppIVsOutputGroup != null) ? VSConstants.S_OK : VSConstants.E_FAIL; - } - - public virtual int OutputsRequireAppRoot(out int pfRequiresAppRoot) - { - pfRequiresAppRoot = 0; - return VSConstants.E_NOTIMPL; - } - - public virtual int get_CfgType(ref Guid iidCfg, out IntPtr ppCfg) - { - // Delegate to the flavored configuration (to enable a flavor to take control) - // Since we can be asked for Configuration we don't support, avoid throwing and return the HRESULT directly - int hr = flavoredCfg.get_CfgType(ref iidCfg, out ppCfg); - - return hr; - } - - public virtual int get_IsPrivate(out int pfPrivate) - { - pfPrivate = 0; - return VSConstants.S_OK; - } - - public virtual int get_OutputGroups(uint celt, IVsOutputGroup[] rgpcfg, uint[] pcActual) - { - // Are they only asking for the number of groups? - if(celt == 0) - { - if((null == pcActual) || (0 == pcActual.Length)) - { - throw new ArgumentNullException("pcActual"); - } - pcActual[0] = (uint)OutputGroups.Count; - return VSConstants.S_OK; - } - - // Check that the array of output groups is not null - if((null == rgpcfg) || (rgpcfg.Length == 0)) - { - throw new ArgumentNullException("rgpcfg"); - } - - // Fill the array with our output groups - uint count = 0; - foreach(OutputGroup group in OutputGroups) - { - if(rgpcfg.Length > count && celt > count && group != null) - { - rgpcfg[count] = group; - ++count; - } - } - - if(pcActual != null && pcActual.Length > 0) - pcActual[0] = count; - - // If the number asked for does not match the number returned, return S_FALSE - return (count == celt) ? VSConstants.S_OK : VSConstants.S_FALSE; - } - - public virtual int get_VirtualRoot(out string pbstrVRoot) - { - pbstrVRoot = null; - return VSConstants.E_NOTIMPL; - } - - #endregion - - #region IVsCfgBrowseObject - /// - /// Maps back to the configuration corresponding to the browse object. - /// - /// The IVsCfg object represented by the browse object - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetCfg(out IVsCfg cfg) - { - cfg = this; - return VSConstants.S_OK; - } - - /// - /// Maps back to the hierarchy or project item object corresponding to the browse object. - /// - /// Reference to the hierarchy object. - /// Reference to the project item. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetProjectItem(out IVsHierarchy hier, out uint itemid) - { - if(this.project == null || this.project.NodeProperties == null) - { - throw new InvalidOperationException(); - } - return this.project.NodeProperties.GetProjectItem(out hier, out itemid); - } - #endregion - - #region helper methods - /// - /// Splits the canonical configuration name into platform and configuration name. - /// - /// The canonicalName name. - /// The name of the configuration. - /// The name of the platform. - /// true if successfull. - internal static bool TrySplitConfigurationCanonicalName(string canonicalName, out string configName, out string platformName) - { - configName = String.Empty; - platformName = String.Empty; - - if(String.IsNullOrEmpty(canonicalName)) - { - return false; - } - - string[] splittedCanonicalName = canonicalName.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); - - if(splittedCanonicalName == null || (splittedCanonicalName.Length != 1 && splittedCanonicalName.Length != 2)) - { - return false; - } - - configName = splittedCanonicalName[0]; - if(splittedCanonicalName.Length == 2) - { - platformName = splittedCanonicalName[1]; - } - - return true; - } - - private MSBuildExecution.ProjectPropertyInstance GetMsBuildProperty(string propertyName, bool resetCache) - { - if (resetCache || this.currentConfig == null) - { - // Get properties for current configuration from project file and cache it - this.project.SetConfiguration(this.ConfigName); - this.project.BuildProject.ReevaluateIfNecessary(); - // Create a snapshot of the evaluated project in its current state - this.currentConfig = this.project.BuildProject.CreateProjectInstance(); - - // Restore configuration - project.SetCurrentConfiguration(); - } - - if (this.currentConfig == null) - throw new Exception("Failed to retrieve properties"); - - // return property asked for - return this.currentConfig.GetProperty(propertyName); - } - - /// - /// Retrieves the configuration dependent property pages. - /// - /// The pages to return. - private void GetCfgPropertyPages(CAUUID[] pages) - { - // We do not check whether the supportsProjectDesigner is set to true on the ProjectNode. - // We rely that the caller knows what to call on us. - if(pages == null) - { - throw new ArgumentNullException("pages"); - } - - if(pages.Length == 0) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "pages"); - } - - // Retrive 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 = this.project.InteropSafeIVsHierarchy; - object variant = null; - ErrorHandler.ThrowOnFailure(hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID2.VSHPROPID_CfgPropertyPagesCLSIDList, out variant), new int[] { VSConstants.DISP_E_MEMBERNOTFOUND, VSConstants.E_NOTIMPL }); - 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); - } - } - #endregion - - #region IVsProjectFlavorCfg Members - /// - /// This is called to let the flavored config let go - /// of any reference it may still be holding to the base config - /// - /// - int IVsProjectFlavorCfg.Close() - { - // This is used to release the reference the flavored config is holding - // on the base config, but in our scenario these 2 are the same object - // so we have nothing to do here. - return VSConstants.S_OK; - } - - /// - /// Actual implementation of get_CfgType. - /// When not flavored or when the flavor delegate to use - /// we end up creating the requested config if we support it. - /// - /// IID representing the type of config object we should create - /// Config object that the method created - /// HRESULT - int IVsProjectFlavorCfg.get_CfgType(ref Guid iidCfg, out IntPtr ppCfg) - { - ppCfg = IntPtr.Zero; - - // See if this is an interface we support - if(iidCfg == typeof(IVsDebuggableProjectCfg).GUID) - ppCfg = Marshal.GetComInterfaceForObject(this, typeof(IVsDebuggableProjectCfg)); - else if(iidCfg == typeof(IVsBuildableProjectCfg).GUID) - { - IVsBuildableProjectCfg buildableConfig; - this.get_BuildableProjectCfg(out buildableConfig); - ppCfg = Marshal.GetComInterfaceForObject(buildableConfig, typeof(IVsBuildableProjectCfg)); - } - - // If not supported - if(ppCfg == IntPtr.Zero) - return VSConstants.E_NOINTERFACE; - - return VSConstants.S_OK; - } - - #endregion - } - - //============================================================================= - // NOTE: advises on out of proc build execution to maximize - // future cross-platform targeting capabilities of the VS tools. - - [CLSCompliant(false)] - [ComVisible(true)] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Buildable")] - public class BuildableProjectConfig : IVsBuildableProjectCfg - { - #region fields - ProjectConfig config = null; - EventSinkCollection callbacks = new EventSinkCollection(); - #endregion - - #region ctors - public BuildableProjectConfig(ProjectConfig config) - { - this.config = config; - } - #endregion - - #region IVsBuildableProjectCfg methods - - public virtual int AdviseBuildStatusCallback(IVsBuildStatusCallback callback, out uint cookie) - { - CCITracing.TraceCall(); - - cookie = callbacks.Add(callback); - return VSConstants.S_OK; - } - - public virtual int get_ProjectCfg(out IVsProjectCfg p) - { - CCITracing.TraceCall(); - - p = config; - return VSConstants.S_OK; - } - - public virtual int QueryStartBuild(uint options, int[] supported, int[] ready) - { - CCITracing.TraceCall(); - if(supported != null && supported.Length > 0) - supported[0] = 1; - if(ready != null && ready.Length > 0) - ready[0] = (this.config.ProjectMgr.BuildInProgress) ? 0 : 1; - return VSConstants.S_OK; - } - - public virtual int QueryStartClean(uint options, int[] supported, int[] ready) - { - CCITracing.TraceCall(); - config.PrepareBuild(false); - if(supported != null && supported.Length > 0) - supported[0] = 1; - if(ready != null && ready.Length > 0) - ready[0] = (this.config.ProjectMgr.BuildInProgress) ? 0 : 1; - return VSConstants.S_OK; - } - - public virtual int QueryStartUpToDateCheck(uint options, int[] supported, int[] ready) - { - CCITracing.TraceCall(); - config.PrepareBuild(false); - if(supported != null && supported.Length > 0) - supported[0] = 0; // TODO: - if(ready != null && ready.Length > 0) - ready[0] = (this.config.ProjectMgr.BuildInProgress) ? 0 : 1; - return VSConstants.S_OK; - } - - public virtual int QueryStatus(out int done) - { - CCITracing.TraceCall(); - - done = (this.config.ProjectMgr.BuildInProgress) ? 0 : 1; - return VSConstants.S_OK; - } - - public virtual int StartBuild(IVsOutputWindowPane pane, uint options) - { - CCITracing.TraceCall(); - config.PrepareBuild(false); - - // Current version of MSBuild wish to be called in an STA - uint flags = VSConstants.VS_BUILDABLEPROJECTCFGOPTS_REBUILD; - - // If we are not asked for a rebuild, then we build the default target (by passing null) - this.Build(options, pane, ((options & flags) != 0) ? MsBuildTarget.Rebuild : null); - - return VSConstants.S_OK; - } - - public virtual int StartClean(IVsOutputWindowPane pane, uint options) - { - CCITracing.TraceCall(); - config.PrepareBuild(true); - // Current version of MSBuild wish to be called in an STA - this.Build(options, pane, MsBuildTarget.Clean); - return VSConstants.S_OK; - } - - public virtual int StartUpToDateCheck(IVsOutputWindowPane pane, uint options) - { - CCITracing.TraceCall(); - - return VSConstants.E_NOTIMPL; - } - - public virtual int Stop(int fsync) - { - CCITracing.TraceCall(); - - return VSConstants.S_OK; - } - - public virtual int UnadviseBuildStatusCallback(uint cookie) - { - CCITracing.TraceCall(); - - - callbacks.RemoveAt(cookie); - return VSConstants.S_OK; - } - - public virtual int Wait(uint ms, int fTickWhenMessageQNotEmpty) - { - CCITracing.TraceCall(); - - return VSConstants.E_NOTIMPL; - } - #endregion - - #region helpers - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - private bool NotifyBuildBegin() - { - int shouldContinue = 1; - foreach (IVsBuildStatusCallback cb in callbacks) - { - try - { - ErrorHandler.ThrowOnFailure(cb.BuildBegin(ref shouldContinue)); - if (shouldContinue == 0) - { - return false; - } - } - catch (Exception e) - { - // If those who ask for status have bugs in their code it should not prevent the build/notification from happening - Debug.Fail(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.BuildEventError, CultureInfo.CurrentUICulture), e.Message)); - } - } - - return true; - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - private void NotifyBuildEnd(MSBuildResult result, string buildTarget) - { - int success = ((result == MSBuildResult.Successful) ? 1 : 0); - - foreach (IVsBuildStatusCallback cb in callbacks) - { - try - { - ErrorHandler.ThrowOnFailure(cb.BuildEnd(success)); - } - catch (Exception e) - { - // If those who ask for status have bugs in their code it should not prevent the build/notification from happening - Debug.Fail(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.BuildEventError, CultureInfo.CurrentUICulture), e.Message)); - } - finally - { - // We want to refresh the references if we are building with the Build or Rebuild target or if the project was opened for browsing only. - bool shouldRepaintReferences = (buildTarget == null || buildTarget == MsBuildTarget.Build || buildTarget == MsBuildTarget.Rebuild); - - // Now repaint references if that is needed. - // We hardly rely here on the fact the ResolveAssemblyReferences target has been run as part of the build. - // One scenario to think at is when an assembly reference is renamed on disk thus becomming unresolvable, - // but msbuild can actually resolve it. - // Another one if the project was opened only for browsing and now the user chooses to build or rebuild. - if (shouldRepaintReferences && (result == MSBuildResult.Successful)) - { - this.RefreshReferences(); - } - } - } - } - - private void Build(uint options, IVsOutputWindowPane output, string target) - { - if (!this.NotifyBuildBegin()) - { - return; - } - - try - { - config.ProjectMgr.BuildAsync(options, this.config.ConfigName, output, target, (result, buildTarget) => this.NotifyBuildEnd(result, buildTarget)); - } - catch(Exception e) - { - Trace.WriteLine("Exception : " + e.Message); - ErrorHandler.ThrowOnFailure(output.OutputStringThreadSafe("Unhandled Exception:" + e.Message + "\n")); - this.NotifyBuildEnd(MSBuildResult.Failed, target); - throw; - } - finally - { - ErrorHandler.ThrowOnFailure(output.FlushToTaskList()); - } - } - - /// - /// Refreshes references and redraws them correctly. - /// - private void RefreshReferences() - { - // Refresh the reference container node for assemblies that could be resolved. - IReferenceContainer referenceContainer = this.config.ProjectMgr.GetReferenceContainer(); - foreach(ReferenceNode referenceNode in referenceContainer.EnumReferences()) - { - referenceNode.RefreshReference(); - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectContainerNode.cs b/SHFB/Source/MPFProj_VS2010/ProjectContainerNode.cs deleted file mode 100644 index c2216583..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectContainerNode.cs +++ /dev/null @@ -1,842 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio.Project.Automation; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using MSBuild = Microsoft.Build.Evaluation; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false), ComVisible(true)] - public abstract class ProjectContainerNode : ProjectNode, - IVsParentProject, - IBuildDependencyOnProjectContainer - { - #region fields - - /// - /// Setting this flag to true will build all nested project when building this project - /// - private bool buildNestedProjectsOnBuild = true; - - private ProjectElement nestedProjectElement; - - /// - /// Defines the listener that would listen on file changes on the nested project node. - /// - /// - ///This might need a refactoring when nested projects can be added and removed by demand. - /// - private FileChangeManager nestedProjectNodeReloader; - #endregion - - #region ctors - protected ProjectContainerNode() - { - } - #endregion - - #region properties - /// - /// Returns teh object that handles listening to file changes on the nested project files. - /// - internal FileChangeManager NestedProjectNodeReloader - { - get - { - if(this.nestedProjectNodeReloader == null) - { - this.nestedProjectNodeReloader = new FileChangeManager(this.Site); - this.nestedProjectNodeReloader.FileChangedOnDisk += this.OnNestedProjectFileChangedOnDisk; - } - - return this.nestedProjectNodeReloader; - } - } - #endregion - - #region overridden properties - /// - /// This is the object that will be returned by EnvDTE.Project.Object for this project - /// - internal override object Object - { - get { return new OASolutionFolder(this); } - } - - #endregion - - #region public overridden methods - /// - /// Gets the nested hierarchy. - /// - /// The item id. - /// Identifier of the interface to be returned in ppHierarchyNested. - /// Pointer to the interface whose identifier was passed in iidHierarchyNested. - /// Pointer to an item identifier of the root node of the nested hierarchy. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. If ITEMID is not a nested hierarchy, this method returns E_FAIL. - [CLSCompliant(false)] - public override int GetNestedHierarchy(UInt32 itemId, ref Guid iidHierarchyNested, out IntPtr ppHierarchyNested, out uint pItemId) - { - pItemId = VSConstants.VSITEMID_ROOT; - ppHierarchyNested = IntPtr.Zero; - if(this.FirstChild != null) - { - for(HierarchyNode n = this.FirstChild; n != null; n = n.NextSibling) - { - NestedProjectNode p = n as NestedProjectNode; - - if(p != null && p.ID == itemId) - { - if(p.NestedHierarchy != null) - { - IntPtr iunknownPtr = IntPtr.Zero; - int returnValue = VSConstants.S_OK; - try - { - iunknownPtr = Marshal.GetIUnknownForObject(p.NestedHierarchy); - Marshal.QueryInterface(iunknownPtr, ref iidHierarchyNested, out ppHierarchyNested); - } - catch(COMException e) - { - returnValue = e.ErrorCode; - } - finally - { - if(iunknownPtr != IntPtr.Zero) - { - Marshal.Release(iunknownPtr); - } - } - - return returnValue; - } - break; - } - } - } - - return VSConstants.E_FAIL; - } - - public override int IsItemDirty(uint itemId, IntPtr punkDocData, out int pfDirty) - { - HierarchyNode hierNode = this.NodeFromItemId(itemId); - Debug.Assert(hierNode != null, "Hierarchy node not found"); - if(hierNode != this) - { - return ErrorHandler.ThrowOnFailure(hierNode.IsItemDirty(itemId, punkDocData, out pfDirty)); - } - else - { - return ErrorHandler.ThrowOnFailure(base.IsItemDirty(itemId, punkDocData, out pfDirty)); - } - } - - public override int SaveItem(VSSAVEFLAGS dwSave, string silentSaveAsName, uint itemid, IntPtr punkDocData, out int pfCancelled) - { - HierarchyNode hierNode = this.NodeFromItemId(itemid); - Debug.Assert(hierNode != null, "Hierarchy node not found"); - if(hierNode != this) - { - return ErrorHandler.ThrowOnFailure(hierNode.SaveItem(dwSave, silentSaveAsName, itemid, punkDocData, out pfCancelled)); - } - else - { - return ErrorHandler.ThrowOnFailure(base.SaveItem(dwSave, silentSaveAsName, itemid, punkDocData, out pfCancelled)); - } - } - - protected override bool FilterItemTypeToBeAddedToHierarchy(string itemType) - { - if(String.Compare(itemType, ProjectFileConstants.SubProject, StringComparison.OrdinalIgnoreCase) == 0) - { - return true; - } - return base.FilterItemTypeToBeAddedToHierarchy(itemType); - } - - /// - /// Called to reload a project item. - /// Reloads a project and its nested project nodes. - /// - /// Specifies itemid from VSITEMID. - /// Reserved. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int ReloadItem(uint itemId, uint reserved) - { - #region precondition - if(this.IsClosed) - { - return VSConstants.E_FAIL; - } - #endregion - - NestedProjectNode node = this.NodeFromItemId(itemId) as NestedProjectNode; - - if(node != null) - { - object propertyAsObject = node.GetProperty((int)__VSHPROPID.VSHPROPID_HandlesOwnReload); - - if(propertyAsObject != null && (bool)propertyAsObject) - { - node.ReloadItem(reserved); - } - else - { - this.ReloadNestedProjectNode(node); - } - - return VSConstants.S_OK; - } - - return base.ReloadItem(itemId, reserved); - } - - /// - /// Reloads a project and its nested project nodes. - /// - protected override void Reload() - { - base.Reload(); - this.CreateNestedProjectNodes(); - } - #endregion - - #region IVsParentProject - public virtual int OpenChildren() - { - IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution; - - Debug.Assert(solution != null, "Could not retrieve the solution from the services provided by this project"); - if(solution == null) - { - return VSConstants.E_FAIL; - } - - IntPtr iUnKnownForSolution = IntPtr.Zero; - int returnValue = VSConstants.S_OK; // be optimistic. - - try - { - this.DisableQueryEdit = true; - this.EventTriggeringFlag = ProjectNode.EventTriggering.DoNotTriggerHierarchyEvents | ProjectNode.EventTriggering.DoNotTriggerTrackerEvents; - iUnKnownForSolution = Marshal.GetIUnknownForObject(solution); - - // notify SolutionEvents listeners that we are about to add children - IVsFireSolutionEvents fireSolutionEvents = Marshal.GetTypedObjectForIUnknown(iUnKnownForSolution, typeof(IVsFireSolutionEvents)) as IVsFireSolutionEvents; - ErrorHandler.ThrowOnFailure(fireSolutionEvents.FireOnBeforeOpeningChildren(this)); - - this.AddVirtualProjects(); - - ErrorHandler.ThrowOnFailure(fireSolutionEvents.FireOnAfterOpeningChildren(this)); - } - catch(Exception e) - { - // Exceptions are digested by the caller but we want then to be shown if not a ComException and if not in automation. - if(!(e is COMException) && !Utilities.IsInAutomationFunction(this.Site)) - { - string title = null; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(this.Site, title, e.Message, icon, buttons, defaultButton); - } - - Trace.WriteLine("Exception : " + e.Message); - throw; - } - finally - { - this.DisableQueryEdit = false; - - if(iUnKnownForSolution != IntPtr.Zero) - { - Marshal.Release(iUnKnownForSolution); - } - - this.EventTriggeringFlag = ProjectNode.EventTriggering.TriggerAll; - } - - return returnValue; - } - - public virtual int CloseChildren() - { - int returnValue = VSConstants.S_OK; // be optimistic. - - IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution; - Debug.Assert(solution != null, "Could not retrieve the solution from the services provided by this project"); - - if(solution == null) - { - return VSConstants.E_FAIL; - } - - IntPtr iUnKnownForSolution = IntPtr.Zero; - - try - { - iUnKnownForSolution = Marshal.GetIUnknownForObject(solution); - - // notify SolutionEvents listeners that we are about to close children - IVsFireSolutionEvents fireSolutionEvents = Marshal.GetTypedObjectForIUnknown(iUnKnownForSolution, typeof(IVsFireSolutionEvents)) as IVsFireSolutionEvents; - ErrorHandler.ThrowOnFailure(fireSolutionEvents.FireOnBeforeClosingChildren(this)); - - // If the removal crashes we never fire the close children event. IS that a problem? - this.RemoveNestedProjectNodes(); - - ErrorHandler.ThrowOnFailure(fireSolutionEvents.FireOnAfterClosingChildren(this)); - } - finally - { - if(iUnKnownForSolution != IntPtr.Zero) - { - Marshal.Release(iUnKnownForSolution); - } - } - - return returnValue; - } - #endregion - - #region IBuildDependencyOnProjectContainerNode - /// - /// Defines whether nested projects should be build with the parent project - /// - public virtual bool BuildNestedProjectsOnBuild - { - get { return this.buildNestedProjectsOnBuild; } - set { this.buildNestedProjectsOnBuild = value; } - } - - /// - /// Enumerates the nested hierachies that should be added to the build dependency list. - /// - /// - public virtual IVsHierarchy[] EnumNestedHierachiesForBuildDependency() - { - List nestedProjectList = new List(); - // Add all nested project among projectContainer child nodes - for(HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) - { - NestedProjectNode nestedProjectNode = child as NestedProjectNode; - if(nestedProjectNode != null) - { - nestedProjectList.Add(nestedProjectNode.NestedHierarchy); - } - } - - return nestedProjectList.ToArray(); - } - #endregion - - #region helper methods - - internal protected void RemoveNestedProjectNodes() - { - for(HierarchyNode n = this.FirstChild; n != null; n = n.NextSibling) - { - NestedProjectNode p = n as NestedProjectNode; - if(p != null) - { - p.CloseNestedProjectNode(); - } - } - - // We do not care of file changes after this. - this.NestedProjectNodeReloader.FileChangedOnDisk -= this.OnNestedProjectFileChangedOnDisk; - this.NestedProjectNodeReloader.Dispose(); - } - - /// - /// This is used when loading the project to loop through all the items - /// and for each SubProject it finds, it create the project and a node - /// in our Hierarchy to hold the project. - /// - internal protected void CreateNestedProjectNodes() - { - // 1. Create a ProjectElement with the found item and then Instantiate a new Nested project with this ProjectElement. - // 2. Link into the hierarchy. - // Read subprojects from from msbuildmodel - __VSCREATEPROJFLAGS creationFlags = __VSCREATEPROJFLAGS.CPF_NOTINSLNEXPLR | __VSCREATEPROJFLAGS.CPF_SILENT; - - if(this.IsNewProject) - { - creationFlags |= __VSCREATEPROJFLAGS.CPF_CLONEFILE; - } - else - { - creationFlags |= __VSCREATEPROJFLAGS.CPF_OPENFILE; - } - - foreach (MSBuild.ProjectItem item in this.BuildProject.Items) - { - if(String.Compare(item.ItemType, ProjectFileConstants.SubProject, StringComparison.OrdinalIgnoreCase) == 0) - { - this.nestedProjectElement = new ProjectElement(this, item, false); - - if(!this.IsNewProject) - { - AddExistingNestedProject(null, creationFlags); - } - else - { - // If we are creating the subproject from a vstemplate/vsz file - bool isVsTemplate = Utilities.IsTemplateFile(GetProjectTemplatePath(null)); - if(isVsTemplate) - { - RunVsTemplateWizard(null, true); - } - else - { - // We are cloning the specified project file - AddNestedProjectFromTemplate(null, creationFlags); - } - } - } - } - - this.nestedProjectElement = null; - } - /// - /// Add an existing project as a nested node of our hierarchy. - /// This is used while loading the project and can also be used - /// to add an existing project to our hierarchy. - /// - protected internal virtual NestedProjectNode AddExistingNestedProject(ProjectElement element, __VSCREATEPROJFLAGS creationFlags) - { - ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element; - - if(elementToUse == null) - { - throw new ArgumentNullException("element"); - } - - string filename = elementToUse.GetFullPathForElement(); - // Delegate to AddNestedProjectFromTemplate. Because we pass flags that specify open project rather then clone, this will works. - Debug.Assert((creationFlags & __VSCREATEPROJFLAGS.CPF_OPENFILE) == __VSCREATEPROJFLAGS.CPF_OPENFILE, "__VSCREATEPROJFLAGS.CPF_OPENFILE should have been specified, did you mean to call AddNestedProjectFromTemplate?"); - return AddNestedProjectFromTemplate(filename, Path.GetDirectoryName(filename), Path.GetFileName(filename), elementToUse, creationFlags); - } - - /// - /// Let the wizard code execute and provide us the information we need. - /// Our SolutionFolder automation object should be called back with the - /// details at which point it will call back one of our method to add - /// a nested project. - /// If you are trying to add a new subproject this is probably the - /// method you want to call. If you are just trying to clone a template - /// project file, then AddNestedProjectFromTemplate is what you want. - /// - /// The project item to use as the base of the nested project. - /// true if the wizard should run silently, otherwise false. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Vs")] - protected internal void RunVsTemplateWizard(ProjectElement element, bool silent) - { - ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element; - - if(elementToUse == null) - { - throw new ArgumentNullException("element"); - } - this.nestedProjectElement = elementToUse; - - Automation.OAProject oaProject = GetAutomationObject() as Automation.OAProject; - if(oaProject == null || oaProject.ProjectItems == null) - throw new System.InvalidOperationException(SR.GetString(SR.InvalidAutomationObject, CultureInfo.CurrentUICulture)); - Debug.Assert(oaProject.Object != null, "The project automation object should have set the Object to the SolutionFolder"); - Automation.OASolutionFolder folder = oaProject.Object as Automation.OASolutionFolder; - - // Prepare the parameters to pass to RunWizardFile - string destination = elementToUse.GetFullPathForElement(); - string template = this.GetProjectTemplatePath(elementToUse); - - object[] wizParams = new object[7]; - wizParams[0] = EnvDTE.Constants.vsWizardAddSubProject; - wizParams[1] = Path.GetFileNameWithoutExtension(destination); - wizParams[2] = oaProject.ProjectItems; - wizParams[3] = Path.GetDirectoryName(destination); - wizParams[4] = Path.GetFileNameWithoutExtension(destination); - wizParams[5] = Path.GetDirectoryName(folder.DTE.FullName); //VS install dir - wizParams[6] = silent; - - IVsDetermineWizardTrust wizardTrust = this.GetService(typeof(SVsDetermineWizardTrust)) as IVsDetermineWizardTrust; - if(wizardTrust != null) - { - Guid guidProjectAdding = Guid.Empty; - - // In case of a project template an empty guid should be added as the guid parameter. See env\msenv\core\newtree.h IsTrustedTemplate method definition. - ErrorHandler.ThrowOnFailure(wizardTrust.OnWizardInitiated(template, ref guidProjectAdding)); - } - - try - { - // Make the call to execute the wizard. This should cause AddNestedProjectFromTemplate to be - // called back with the correct set of parameters. - EnvDTE.IVsExtensibility extensibilityService = (EnvDTE.IVsExtensibility)GetService(typeof(EnvDTE.IVsExtensibility)); - EnvDTE.wizardResult result = extensibilityService.RunWizardFile(template, 0, ref wizParams); - if(result == EnvDTE.wizardResult.wizardResultFailure) - throw new COMException(); - } - finally - { - if(wizardTrust != null) - { - ErrorHandler.ThrowOnFailure(wizardTrust.OnWizardCompleted()); - } - } - } - - /// - /// This will clone a template project file and add it as a - /// subproject to our hierarchy. - /// If you want to create a project for which there exist a - /// vstemplate, consider using RunVsTemplateWizard instead. - /// - protected internal virtual NestedProjectNode AddNestedProjectFromTemplate(ProjectElement element, __VSCREATEPROJFLAGS creationFlags) - { - ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element; - - if(elementToUse == null) - { - throw new ArgumentNullException("element"); - } - string destination = elementToUse.GetFullPathForElement(); - string template = this.GetProjectTemplatePath(elementToUse); - - return this.AddNestedProjectFromTemplate(template, Path.GetDirectoryName(destination), Path.GetFileName(destination), elementToUse, creationFlags); - } - - /// - /// This can be called directly or through RunVsTemplateWizard. - /// This will clone a template project file and add it as a - /// subproject to our hierarchy. - /// If you want to create a project for which there exist a - /// vstemplate, consider using RunVsTemplateWizard instead. - /// - protected internal virtual NestedProjectNode AddNestedProjectFromTemplate(string fileName, string destination, string projectName, ProjectElement element, __VSCREATEPROJFLAGS creationFlags) - { - // If this is project creation and the template specified a subproject in its project file, this.nestedProjectElement will be used - ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element; - - if(elementToUse == null) - { - // If this is null, this means MSBuild does not know anything about our subproject so add an MSBuild item for it - elementToUse = new ProjectElement(this, fileName, ProjectFileConstants.SubProject); - } - - NestedProjectNode node = CreateNestedProjectNode(elementToUse); - node.Init(fileName, destination, projectName, creationFlags); - - // In case that with did not have an existing element, or the nestedProjectelement was null - // and since Init computes the final path, set the MSBuild item to that path - if(this.nestedProjectElement == null) - { - string relativePath = node.Url; - if(Path.IsPathRooted(relativePath)) - { - relativePath = this.ProjectFolder; - if(!relativePath.EndsWith("/\\", StringComparison.Ordinal)) - { - relativePath += Path.DirectorySeparatorChar; - } - - relativePath = new Url(relativePath).MakeRelative(new Url(node.Url)); - } - - elementToUse.Rename(relativePath); - } - - this.AddChild(node); - return node; - } - - /// - /// Override this method if you want to provide your own type of nodes. - /// This would be the case if you derive a class from NestedProjectNode - /// - protected virtual NestedProjectNode CreateNestedProjectNode(ProjectElement element) - { - return new NestedProjectNode(this, element); - } - - /// - /// Links the nested project nodes to the solution. The default implementation parses all nested project nodes and calles AddVirtualProjectEx on them. - /// - protected virtual void AddVirtualProjects() - { - for(HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling) - { - NestedProjectNode nestedProjectNode = child as NestedProjectNode; - if(nestedProjectNode != null) - { - nestedProjectNode.AddVirtualProject(); - } - } - } - - /// - /// Based on the Template and TypeGuid properties of the - /// element, generate the full template path. - /// - /// TypeGuid should be the Guid of a registered project factory. - /// Template can be a full path, a project template (for projects - /// that support VsTemplates) or a relative path (for other projects). - /// - protected virtual string GetProjectTemplatePath(ProjectElement element) - { - ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element; - - if(elementToUse == null) - { - throw new ArgumentNullException("element"); - } - - string templateFile = elementToUse.GetMetadata(ProjectFileConstants.Template); - Debug.Assert(!String.IsNullOrEmpty(templateFile), "No template file has been specified in the template attribute in the project file"); - - string fullPath = templateFile; - if(!Path.IsPathRooted(templateFile)) - { - RegisteredProjectType registeredProjectType = this.GetRegisteredProject(elementToUse); - - // This is not a full path - Debug.Assert(registeredProjectType != null && (!String.IsNullOrEmpty(registeredProjectType.DefaultProjectExtensionValue) || !String.IsNullOrEmpty(registeredProjectType.WizardTemplatesDirValue)), " Registered wizard directory value not set in the registry."); - - // See if this specify a VsTemplate file - fullPath = registeredProjectType.GetVsTemplateFile(templateFile); - if(String.IsNullOrEmpty(fullPath)) - { - // Default to using the WizardTemplateDir to calculate the absolute path - fullPath = Path.Combine(registeredProjectType.WizardTemplatesDirValue, templateFile); - } - } - - return fullPath; - } - - /// - /// Get information from the registry based for the project - /// factory corresponding to the TypeGuid of the element - /// - private RegisteredProjectType GetRegisteredProject(ProjectElement element) - { - ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element; - - if(elementToUse == null) - { - throw new ArgumentNullException("element"); - } - - // Get the project type guid from project elementToUse - string typeGuidString = elementToUse.GetMetadataAndThrow(ProjectFileConstants.TypeGuid, new Exception()); - Guid projectFactoryGuid = new Guid(typeGuidString); - - EnvDTE.DTE dte = this.ProjectMgr.Site.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; - Debug.Assert(dte != null, "Could not get the automation object from the services exposed by this project"); - - if(dte == null) - throw new InvalidOperationException(); - - RegisteredProjectType registeredProjectType = RegisteredProjectType.CreateRegisteredProjectType(projectFactoryGuid); - Debug.Assert(registeredProjectType != null, "Could not read the registry setting associated to this project."); - if(registeredProjectType == null) - { - throw new InvalidOperationException(); - } - return registeredProjectType; - } - - /// - /// Reloads a nested project node by deleting it and readding it. - /// - /// The node to reload. - protected virtual void ReloadNestedProjectNode(NestedProjectNode node) - { - if(node == null) - { - throw new ArgumentNullException("node"); - } - - IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution; - - if(solution == null) - { - throw new InvalidOperationException(); - } - - NestedProjectNode newNode = null; - try - { - // (VS 2005 UPDATE) When deleting and re-adding the nested project, - // we do not want SCC to see this as a delete and add operation. - this.EventTriggeringFlag = ProjectNode.EventTriggering.DoNotTriggerTrackerEvents; - - // notify SolutionEvents listeners that we are about to add children - IVsFireSolutionEvents fireSolutionEvents = solution as IVsFireSolutionEvents; - - if(fireSolutionEvents == null) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(fireSolutionEvents.FireOnBeforeUnloadProject(node.NestedHierarchy)); - - int isDirtyAsInt = 0; - this.IsDirty(out isDirtyAsInt); - - bool isDirty = (isDirtyAsInt == 0) ? false : true; - - ProjectElement element = node.ItemNode; - node.CloseNestedProjectNode(); - - // Remove from the solution - this.RemoveChild(node); - - // Now readd it - try - { - __VSCREATEPROJFLAGS flags = __VSCREATEPROJFLAGS.CPF_NOTINSLNEXPLR | __VSCREATEPROJFLAGS.CPF_SILENT | __VSCREATEPROJFLAGS.CPF_OPENFILE; - newNode = this.AddExistingNestedProject(element, flags); - newNode.AddVirtualProject(); - } - catch(Exception e) - { - // We get a System.Exception if anything failed, thus we have no choice but catch it. - // Exceptions are digested by VS. Show the error if not in automation. - if(!Utilities.IsInAutomationFunction(this.Site)) - { - string message = (String.IsNullOrEmpty(e.Message)) ? SR.GetString(SR.NestedProjectFailedToReload, CultureInfo.CurrentUICulture) : e.Message; - string title = string.Empty; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton); - } - - // Do not digest exception. let the caller handle it. If in a later stage this exception is not digested then the above messagebox is not needed. - throw; - } - -#if DEBUG - IVsHierarchy nestedHierarchy; - ErrorHandler.ThrowOnFailure(solution.GetProjectOfUniqueName(newNode.GetMkDocument(), out nestedHierarchy)); - Debug.Assert(nestedHierarchy != null && Utilities.IsSameComObject(nestedHierarchy, newNode.NestedHierarchy), "The nested hierrachy was not reloaded correctly."); -#endif - this.SetProjectFileDirty(isDirty); - - ErrorHandler.ThrowOnFailure(fireSolutionEvents.FireOnAfterLoadProject(newNode.NestedHierarchy)); - } - finally - { - // In this scenario the nested project failed to unload or reload the nested project. We will unload the whole project, otherwise the nested project is lost. - // This is similar to the scenario when one wants to open a project and the nested project cannot be loaded because for example the project file has xml errors. - // We should note that we rely here that if the unload fails then exceptions are not digested and are shown to the user. - if(newNode == null || newNode.NestedHierarchy == null) - { - ErrorHandler.ThrowOnFailure(solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject | (uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave, this.InteropSafeIVsHierarchy, 0)); - } - else - { - this.EventTriggeringFlag = ProjectNode.EventTriggering.TriggerAll; - } - } - } - - /// - /// Event callback. Called when one of the nested project files is changed. - /// - /// The FileChangeManager object. - /// Event args containing the file name that was updated. - private void OnNestedProjectFileChangedOnDisk(object sender, FileChangedOnDiskEventArgs e) - { - #region Pre-condition validation - Debug.Assert(e != null, "No event args specified for the FileChangedOnDisk event"); - - // We care only about time change for reload. - if((e.FileChangeFlag & _VSFILECHANGEFLAGS.VSFILECHG_Time) == 0) - { - return; - } - - // test if we actually have a document for this id. - string moniker; - this.GetMkDocument(e.ItemID, out moniker); - Debug.Assert(NativeMethods.IsSamePath(moniker, e.FileName), " The file + " + e.FileName + " has changed but we could not retrieve the path for the item id associated to the path."); - #endregion - - bool reload = true; - if(!Utilities.IsInAutomationFunction(this.Site)) - { - // Prompt to reload the nested project file. We use the moniker here since the filename from the event arg is canonicalized. - string message = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.QueryReloadNestedProject, CultureInfo.CurrentUICulture), moniker); - string title = string.Empty; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_INFO; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_YESNO; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - reload = (VsShellUtilities.ShowMessageBox(this.Site, message, title, icon, buttons, defaultButton) == NativeMethods.IDYES); - } - - if(reload) - { - // We have to use here the interface method call, since it might be that specialized project nodes like the project container item - // is owerwriting the default functionality. - this.ReloadItem(e.ItemID, 0); - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectDesignerDocumentManager.cs b/SHFB/Source/MPFProj_VS2010/ProjectDesignerDocumentManager.cs deleted file mode 100644 index cb558527..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectDesignerDocumentManager.cs +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - class ProjectDesignerDocumentManager : DocumentManager - { - #region ctors - public ProjectDesignerDocumentManager(ProjectNode node) - : base(node) - { - } - #endregion - - #region overriden methods - - public override int Open(ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame windowFrame, WindowFrameShowAction windowFrameAction) - { - Guid editorGuid = VSConstants.GUID_ProjectDesignerEditor; - return this.OpenWithSpecific(0, ref editorGuid, String.Empty, ref logicalView, docDataExisting, out windowFrame, windowFrameAction); - } - - public override int OpenWithSpecific(uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame frame, WindowFrameShowAction windowFrameAction) - { - frame = null; - Debug.Assert(editorType == VSConstants.GUID_ProjectDesignerEditor, "Cannot open project designer with guid " + editorType.ToString()); - - - if(this.Node == null || this.Node.ProjectMgr == null || this.Node.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - IVsUIShellOpenDocument uiShellOpenDocument = this.Node.ProjectMgr.Site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument; - IOleServiceProvider serviceProvider = this.Node.ProjectMgr.Site.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider; - - if(serviceProvider != null && uiShellOpenDocument != null) - { - string fullPath = this.GetFullPathForDocument(); - string caption = this.GetOwnerCaption(); - - IVsUIHierarchy parentHierarchy = this.Node.ProjectMgr.GetProperty((int)__VSHPROPID.VSHPROPID_ParentHierarchy) as IVsUIHierarchy; - - int parentHierarchyItemId = (int)this.Node.ProjectMgr.GetProperty((int)__VSHPROPID.VSHPROPID_ParentHierarchyItemid); - - ErrorHandler.ThrowOnFailure(uiShellOpenDocument.OpenSpecificEditor(editorFlags, fullPath, - ref editorType, physicalView, ref logicalView, caption, parentHierarchy, - (uint)parentHierarchyItemId, docDataExisting, serviceProvider, out frame)); - - if(frame != null) - { - if(windowFrameAction == WindowFrameShowAction.Show) - { - ErrorHandler.ThrowOnFailure(frame.Show()); - } - } - } - - return VSConstants.S_OK; - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectDocumentsListener.cs b/SHFB/Source/MPFProj_VS2010/ProjectDocumentsListener.cs deleted file mode 100644 index 7f43493d..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectDocumentsListener.cs +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; -using System.Diagnostics.CodeAnalysis; - -namespace Microsoft.VisualStudio.Project -{ - - [CLSCompliant(false)] - public abstract class ProjectDocumentsListener : IVsTrackProjectDocumentsEvents2, IDisposable - { - #region fields - private uint eventsCookie; - private IVsTrackProjectDocuments2 projectDocTracker; - private ServiceProvider serviceProvider; - private bool isDisposed; - /// - /// Defines an object that will be a mutex for this object for synchronizing thread calls. - /// - private static volatile object Mutex = new object(); - #endregion - - #region ctors - protected ProjectDocumentsListener(ServiceProvider serviceProviderParameter) - { - if (serviceProviderParameter == null) - { - throw new ArgumentNullException("serviceProviderParameter"); - } - - this.serviceProvider = serviceProviderParameter; - this.projectDocTracker = this.serviceProvider.GetService(typeof(SVsTrackProjectDocuments)) as IVsTrackProjectDocuments2; - - Debug.Assert(this.projectDocTracker != null, "Could not get the IVsTrackProjectDocuments2 object from the services exposed by this project"); - - if(this.projectDocTracker == null) - { - throw new InvalidOperationException(); - } - } - #endregion - - #region properties - protected uint EventsCookie - { - get - { - return this.eventsCookie; - } - } - - protected IVsTrackProjectDocuments2 ProjectDocumentTracker2 - { - get - { - return this.projectDocTracker; - } - } - - protected ServiceProvider ServiceProvider - { - get - { - return this.serviceProvider; - } - } - #endregion - - #region IVsTrackProjectDocumentsEvents2 Members - - public virtual int OnAfterAddDirectoriesEx(int cProjects, int cDirectories, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDDIRECTORYFLAGS[] rgFlags) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterAddFilesEx(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSADDFILEFLAGS[] rgFlags) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterRemoveDirectories(int cProjects, int cDirectories, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEDIRECTORYFLAGS[] rgFlags) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterRemoveFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, VSREMOVEFILEFLAGS[] rgFlags) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterRenameDirectories(int cProjects, int cDirs, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgszMkOldNames, string[] rgszMkNewNames, VSRENAMEDIRECTORYFLAGS[] rgFlags) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterRenameFiles(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgszMkOldNames, string[] rgszMkNewNames, VSRENAMEFILEFLAGS[] rgFlags) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterSccStatusChanged(int cProjects, int cFiles, IVsProject[] rgpProjects, int[] rgFirstIndices, string[] rgpszMkDocuments, uint[] rgdwSccStatus) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnQueryAddDirectories(IVsProject pProject, int cDirectories, string[] rgpszMkDocuments, VSQUERYADDDIRECTORYFLAGS[] rgFlags, VSQUERYADDDIRECTORYRESULTS[] pSummaryResult, VSQUERYADDDIRECTORYRESULTS[] rgResults) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnQueryAddFiles(IVsProject pProject, int cFiles, string[] rgpszMkDocuments, VSQUERYADDFILEFLAGS[] rgFlags, VSQUERYADDFILERESULTS[] pSummaryResult, VSQUERYADDFILERESULTS[] rgResults) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnQueryRemoveDirectories(IVsProject pProject, int cDirectories, string[] rgpszMkDocuments, VSQUERYREMOVEDIRECTORYFLAGS[] rgFlags, VSQUERYREMOVEDIRECTORYRESULTS[] pSummaryResult, VSQUERYREMOVEDIRECTORYRESULTS[] rgResults) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnQueryRemoveFiles(IVsProject pProject, int cFiles, string[] rgpszMkDocuments, VSQUERYREMOVEFILEFLAGS[] rgFlags, VSQUERYREMOVEFILERESULTS[] pSummaryResult, VSQUERYREMOVEFILERESULTS[] rgResults) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnQueryRenameDirectories(IVsProject pProject, int cDirs, string[] rgszMkOldNames, string[] rgszMkNewNames, VSQUERYRENAMEDIRECTORYFLAGS[] rgFlags, VSQUERYRENAMEDIRECTORYRESULTS[] pSummaryResult, VSQUERYRENAMEDIRECTORYRESULTS[] rgResults) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnQueryRenameFiles(IVsProject pProject, int cFiles, string[] rgszMkOldNames, string[] rgszMkNewNames, VSQUERYRENAMEFILEFLAGS[] rgFlags, VSQUERYRENAMEFILERESULTS[] pSummaryResult, VSQUERYRENAMEFILERESULTS[] rgResults) - { - return VSConstants.E_NOTIMPL; - } - - #endregion - - #region IDisposable Members - /// - /// The IDispose interface Dispose method for disposing the object determinastically. - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - #endregion - - #region methods - public void Init() - { - if(this.ProjectDocumentTracker2 != null) - { - ErrorHandler.ThrowOnFailure(this.ProjectDocumentTracker2.AdviseTrackProjectDocumentsEvents(this, out this.eventsCookie)); - } - } - - /// - /// The method that does the cleanup. - /// - /// - [SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsTrackProjectDocuments2.UnadviseTrackProjectDocumentsEvents(System.UInt32)")] - protected virtual void Dispose(bool disposing) - { - // Everybody can go here. - if(!this.isDisposed) - { - // Synchronize calls to the Dispose simulteniously. - lock(Mutex) - { - if(disposing && this.eventsCookie != (uint)ShellConstants.VSCOOKIE_NIL && this.ProjectDocumentTracker2 != null) - { - this.ProjectDocumentTracker2.UnadviseTrackProjectDocumentsEvents((uint)this.eventsCookie); - this.eventsCookie = (uint)ShellConstants.VSCOOKIE_NIL; - } - - this.isDisposed = true; - } - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectElement.cs b/SHFB/Source/MPFProj_VS2010/ProjectElement.cs deleted file mode 100644 index 0400ca42..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectElement.cs +++ /dev/null @@ -1,456 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using MSBuild = Microsoft.Build.Evaluation; -using Microsoft.Build.Evaluation; - -namespace Microsoft.VisualStudio.Project -{ - - /// - /// This class represent a project item (usualy a file) and allow getting and - /// setting attribute on it. - /// This class allow us to keep the internal details of our items hidden from - /// our derived classes. - /// While the class itself is public so it can be manipulated by derived classes, - /// its internal constructors make sure it can only be created from within the assembly. - /// - public sealed class ProjectElement - { - #region fields - private MSBuild.ProjectItem item; - private ProjectNode itemProject; - private bool deleted; - private bool isVirtual; - private Dictionary virtualProperties; - #endregion - - #region properties - public string ItemName - { - get - { - if(this.HasItemBeenDeleted()) - { - return String.Empty; - } - else - { - return this.item.ItemType; - } - } - set - { - if(!this.HasItemBeenDeleted()) - { - // Check out the project file. - if(!this.itemProject.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - this.item.ItemType = value; - } - } - } - - internal MSBuild.ProjectItem Item - { - get - { - return this.item; - } - } - - internal bool IsVirtual - { - get - { - return this.isVirtual; - } - } - #endregion - - #region ctors - /// - /// Constructor to create a new MSBuild.ProjectItem and add it to the project - /// Only have internal constructors as the only one who should be creating - /// such object is the project itself (see Project.CreateFileNode()). - /// - internal ProjectElement(ProjectNode project, string itemPath, string itemType) - { - if(project == null) - { - throw new ArgumentNullException("project"); - } - - if(String.IsNullOrEmpty(itemPath)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemPath"); - } - - - if(String.IsNullOrEmpty(itemType)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "itemType"); - } - - this.itemProject = project; - - // create and add the item to the project - - this.item = project.BuildProject.AddItem(itemType, Microsoft.Build.Evaluation.ProjectCollection.Escape(itemPath))[0]; - this.itemProject.SetProjectFileDirty(true); - this.RefreshProperties(); - } - - /// - /// Constructor to Wrap an existing MSBuild.ProjectItem - /// Only have internal constructors as the only one who should be creating - /// such object is the project itself (see Project.CreateFileNode()). - /// - /// Project that owns this item - /// an MSBuild.ProjectItem; can be null if virtualFolder is true - /// Is this item virtual (such as reference folder) - internal ProjectElement(ProjectNode project, MSBuild.ProjectItem existingItem, bool virtualFolder) - { - if(project == null) - throw new ArgumentNullException("project"); - if(!virtualFolder && existingItem == null) - throw new ArgumentNullException("existingItem"); - - // Keep a reference to project and item - this.itemProject = project; - this.item = existingItem; - this.isVirtual = virtualFolder; - - if(this.isVirtual) - this.virtualProperties = new Dictionary(); - } - #endregion - - #region public methods - /// - /// Calling this method remove this item from the project file. - /// Once the item is delete, you should not longer be using it. - /// Note that the item should be removed from the hierarchy prior to this call. - /// - public void RemoveFromProjectFile() - { - if(!deleted && item != null) - { - deleted = true; - itemProject.BuildProject.RemoveItem(item); - } - itemProject = null; - item = null; - } - - /// - /// Set an attribute on the project element - /// - /// Name of the attribute to set - /// Value to give to the attribute. Use null to delete the metadata definition. - public void SetMetadata(string attributeName, string attributeValue) - { - Debug.Assert(String.Compare(attributeName, ProjectFileConstants.Include, StringComparison.OrdinalIgnoreCase) != 0, "Use rename as this won't work"); - - if(this.IsVirtual) - { - // For virtual node, use our virtual property collection - if(virtualProperties.ContainsKey(attributeName)) - virtualProperties.Remove(attributeName); - virtualProperties.Add(attributeName, attributeValue); - return; - } - - // Build Action is the type, not a property, so intercept - if(String.Equals(attributeName, ProjectFileConstants.BuildAction, StringComparison.OrdinalIgnoreCase)) - { - item.ItemType = attributeValue; - return; - } - - // Check out the project file. - if(!this.itemProject.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - if(attributeValue == null) - item.RemoveMetadata(attributeName); - else - item.SetMetadataValue(attributeName, attributeValue); - itemProject.SetProjectFileDirty(true); - } - - public string GetEvaluatedMetadata(string attributeName) - { - if(this.IsVirtual) - { - // For virtual items, use our virtual property collection - if(!virtualProperties.ContainsKey(attributeName)) - { - return String.Empty; - } - return virtualProperties[attributeName]; - } - - // cannot ask MSBuild for Include, so intercept it and return the corresponding property - if(String.Compare(attributeName, ProjectFileConstants.Include, StringComparison.OrdinalIgnoreCase) == 0) - { - return item.EvaluatedInclude; - } - - // Build Action is the type, not a property, so intercept this one as well - if(String.Compare(attributeName, ProjectFileConstants.BuildAction, StringComparison.OrdinalIgnoreCase) == 0) - { - return item.ItemType; - } - - return item.GetMetadataValue(attributeName); - } - - /// - /// Get the value of an attribute on a project element - /// - /// Name of the attribute to get the value for - /// Value of the attribute - public string GetMetadata(string attributeName) - { - if(this.IsVirtual) - { - // For virtual items, use our virtual property collection - if(!virtualProperties.ContainsKey(attributeName)) - return String.Empty; - return virtualProperties[attributeName]; - } - - // cannot ask MSBuild for Include, so intercept it and return the corresponding property - if(String.Compare(attributeName, ProjectFileConstants.Include, StringComparison.OrdinalIgnoreCase) == 0) - return item.EvaluatedInclude; - - // Build Action is the type, not a property, so intercept this one as well - if(String.Compare(attributeName, ProjectFileConstants.BuildAction, StringComparison.OrdinalIgnoreCase) == 0) - return item.ItemType; - - return item.GetMetadataValue(attributeName); - } - - /// - /// Gets the attribute and throws the handed exception if the exception if the attribute is empty or null. - /// - /// The name of the attribute to get. - /// The exception to be thrown if not found or empty. - /// The attribute if found - /// The method will throw an Exception and neglect the passed in exception if the attribute is deleted - public string GetMetadataAndThrow(string attributeName, Exception exception) - { - Debug.Assert(!String.IsNullOrEmpty(attributeName), "Cannot retrieve an attribute for a null or empty attribute name"); - string attribute = GetMetadata(attributeName); - - if(String.IsNullOrEmpty(attributeName) && exception != null) - { - if(String.IsNullOrEmpty(exception.Message)) - { - Debug.Assert(!String.IsNullOrEmpty(this.itemProject.BaseURI.AbsoluteUrl), "Cannot retrieve an attribute for a project that does not have a name"); - string message = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.AttributeLoad, CultureInfo.CurrentUICulture), attributeName, this.itemProject.BaseURI.AbsoluteUrl); - throw new Exception(message, exception); - } - throw exception; - } - - return attribute; - } - - - public void Rename(string newPath) - { - string escapedPath = Microsoft.Build.Evaluation.ProjectCollection.Escape(newPath); - if(this.IsVirtual) - { - virtualProperties[ProjectFileConstants.Include] = escapedPath; - return; - } - - item.Rename(escapedPath); - this.RefreshProperties(); - } - - - /// - /// Reevaluate all properties for the current item - /// This should be call if you believe the property for this item - /// may have changed since it was created/refreshed, or global properties - /// this items depends on have changed. - /// Be aware that there is a perf cost in calling this function. - /// - public void RefreshProperties() - { - if(this.IsVirtual) - return; - - itemProject.BuildProject.ReevaluateIfNecessary(); - - IEnumerable items = itemProject.BuildProject.GetItems(item.ItemType); - foreach (ProjectItem projectItem in items) - { - if(projectItem!= null && projectItem.UnevaluatedInclude.Equals(item.UnevaluatedInclude)) - { - item = projectItem; - return; - } - } - } - - /// - /// Return an absolute path for the passed in element. - /// If the element is already an absolute path, it is returned. - /// Otherwise, it is unrelativized using the project directory - /// as the base. - /// Note that any ".." in the paths will be resolved. - /// - /// For non-file system based project, it may make sense to override. - /// - /// FullPath - public string GetFullPathForElement() - { - string path = this.GetMetadata(ProjectFileConstants.Include); - if(!Path.IsPathRooted(path)) - path = Path.Combine(this.itemProject.ProjectFolder, path); - - // If any part of the path used relative paths, resolve this now - path = Path.GetFullPath(path); - return path; - } - - #endregion - - #region helper methods - /// - /// Has the item been deleted - /// - private bool HasItemBeenDeleted() - { - return (this.deleted || this.item == null); - } - #endregion - - #region overridden from System.Object - public static bool operator ==(ProjectElement element1, ProjectElement element2) - { - // Do they reference the same element? - if(Object.ReferenceEquals(element1, element2)) - return true; - - // Verify that they are not null (cast to object first to avoid stack overflow) - if(element1 as object == null || element2 as object == null) - { - return false; - } - - Debug.Assert(!element1.IsVirtual || !element2.IsVirtual, "Cannot compare virtual nodes"); - - // Cannot compare vitual items. - if(element1.IsVirtual || element2.IsVirtual) - { - return false; - } - - // Do they reference the same project? - if(!element1.itemProject.Equals(element2.itemProject)) - return false; - - // Do they have the same include? - string include1 = element1.GetMetadata(ProjectFileConstants.Include); - string include2 = element2.GetMetadata(ProjectFileConstants.Include); - - // Unfortunately the checking for nulls have to be done again, since neither String.Equals nor String.Compare can handle nulls. - // Virtual folders should not be handled here. - if(include1 == null || include2 == null) - { - return false; - } - - return String.Equals(include1, include2, StringComparison.CurrentCultureIgnoreCase); - } - - - public static bool operator !=(ProjectElement element1, ProjectElement element2) - { - return !(element1 == element2); - } - - - public override bool Equals(object obj) - { - ProjectElement element2 = obj as ProjectElement; - if(element2 == null) - return false; - - return this == element2; - } - - - public override int GetHashCode() - { - return base.GetHashCode(); - } - #endregion - - - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectFactory.cs b/SHFB/Source/MPFProj_VS2010/ProjectFactory.cs deleted file mode 100644 index e26b6936..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectFactory.cs +++ /dev/null @@ -1,280 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using MSBuild = Microsoft.Build.Evaluation; -using MSBuildExecution = Microsoft.Build.Execution; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Creates projects within the solution - /// - [CLSCompliant(false)] - public abstract class ProjectFactory : Microsoft.VisualStudio.Shell.Flavor.FlavoredProjectFactoryBase //, IVsAsynchronousProjectCreate - { - #region fields - private Microsoft.VisualStudio.Shell.Package package; - private System.IServiceProvider site; -// TODO: Not supported in VS 2010 -// private static readonly Lazy taskSchedulerService = new Lazy(() => Package.GetGlobalService(typeof(SVsTaskSchedulerService)) as IVsTaskSchedulerService); - - /// - /// The msbuild engine that we are going to use. - /// - private MSBuild.ProjectCollection buildEngine; - - /// - /// The msbuild project for the project file. - /// - private MSBuild.Project buildProject; - #endregion - - #region properties - protected Microsoft.VisualStudio.Shell.Package Package - { - get - { - return this.package; - } - } - - protected System.IServiceProvider Site - { - get - { - return this.site; - } - } - - /// - /// The msbuild engine that we are going to use. - /// - protected MSBuild.ProjectCollection BuildEngine - { - get - { - return this.buildEngine; - } - } - - /// - /// The msbuild project for the temporary project file. - /// - protected MSBuild.Project BuildProject - { - get - { - return this.buildProject; - } - set - { - this.buildProject = value; - } - } - #endregion - - #region ctor - protected ProjectFactory(Microsoft.VisualStudio.Shell.Package package) - { - this.package = package; - this.site = package; - - // Please be aware that this methods needs that ServiceProvider is valid, thus the ordering of calls in the ctor matters. - this.buildEngine = Utilities.InitializeMsBuildEngine(this.buildEngine, this.site); - } - #endregion - - #region methods - - public virtual bool CanCreateProjectAsynchronously(ref Guid rguidProjectID, string filename, uint flags) - { - // TODO: Not supported in VS 2012 - return false; // true; - } - - public void OnBeforeCreateProjectAsync(ref Guid rguidProjectID, string filename, string location, string pszName, uint flags) - { - } - -/* TODO: Not supported in VS 2010 - public virtual IVsTask CreateProjectAsync(ref Guid rguidProjectID, string filename, string location, string pszName, uint flags) - { - Guid iid = typeof(IVsHierarchy).GUID; - return VsTaskLibraryHelper.CreateAndStartTask(taskSchedulerService.Value, VsTaskRunContext.UIThreadBackgroundPriority, VsTaskLibraryHelper.CreateTaskBody(() => - { - IntPtr project; - int cancelled; - CreateProject(filename, location, pszName, flags, ref iid, out project, out cancelled); - if (cancelled != 0) - { - throw new OperationCanceledException(); - } - - return Marshal.GetObjectForIUnknown(project); - })); - } -*/ - #endregion - - #region abstract methods - protected abstract ProjectNode CreateProject(); - #endregion - - #region overriden methods - /// - /// Rather than directly creating the project, ask VS to initate the process of - /// creating an aggregated project in case we are flavored. We will be called - /// on the IVsAggregatableProjectFactory to do the real project creation. - /// - /// Project file - /// Path of the project - /// Project Name - /// Creation flags - /// Guid of the project - /// Project that end up being created by this method - /// Was the project creation canceled - protected override void CreateProject(string fileName, string location, string name, uint flags, ref Guid projectGuid, out IntPtr project, out int canceled) - { - project = IntPtr.Zero; - canceled = 0; - - // Get the list of GUIDs from the project/template - string guidsList = this.ProjectTypeGuids(fileName); - - // Launch the aggregate creation process (we should be called back on our IVsAggregatableProjectFactoryCorrected implementation) - IVsCreateAggregateProject aggregateProjectFactory = (IVsCreateAggregateProject)this.Site.GetService(typeof(SVsCreateAggregateProject)); - int hr = aggregateProjectFactory.CreateAggregateProject(guidsList, fileName, location, name, flags, ref projectGuid, out project); - if(hr == VSConstants.E_ABORT) - canceled = 1; - ErrorHandler.ThrowOnFailure(hr); - - // This needs to be done after the aggregation is completed (to avoid creating a non-aggregated CCW) and as a result we have to go through the interface - IProjectEventsProvider eventsProvider = (IProjectEventsProvider)Marshal.GetTypedObjectForIUnknown(project, typeof(IProjectEventsProvider)); - eventsProvider.ProjectEventsProvider = this.GetProjectEventsProvider(); - - this.buildProject = null; - } - - - /// - /// Instantiate the project class, but do not proceed with the - /// initialization just yet. - /// Delegate to CreateProject implemented by the derived class. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", - Justification="The global property handles is instantiated here and used in the project node that will Dispose it")] - protected override object PreCreateForOuter(IntPtr outerProjectIUnknown) - { - Debug.Assert(this.buildProject != null, "The build project should have been initialized before calling PreCreateForOuter."); - - // Please be very carefull what is initialized here on the ProjectNode. Normally this should only instantiate and return a project node. - // The reason why one should very carefully add state to the project node here is that at this point the aggregation has not yet been created and anything that would cause a CCW for the project to be created would cause the aggregation to fail - // Our reasoning is that there is no other place where state on the project node can be set that is known by the Factory and has to execute before the Load method. - ProjectNode node = this.CreateProject(); - Debug.Assert(node != null, "The project failed to be created"); - node.BuildEngine = this.buildEngine; - node.BuildProject = this.buildProject; - node.Package = this.package as ProjectPackage; - return node; - } - - /// - /// Retrives the list of project guids from the project file. - /// If you don't want your project to be flavorable, override - /// to only return your project factory Guid: - /// return this.GetType().GUID.ToString("B"); - /// - /// Project file to look into to find the Guid list - /// List of semi-colon separated GUIDs - protected override string ProjectTypeGuids(string file) - { - // Load the project so we can extract the list of GUIDs - - this.buildProject = Utilities.ReinitializeMsBuildProject(this.buildEngine, file, this.buildProject); - - // Retrieve the list of GUIDs, if it is not specify, make it our GUID - string guids = buildProject.GetPropertyValue(ProjectFileConstants.ProjectTypeGuids); - if(String.IsNullOrEmpty(guids)) - guids = this.GetType().GUID.ToString("B"); - - return guids; - } - #endregion - - #region helpers - private IProjectEvents GetProjectEventsProvider() - { - ProjectPackage projectPackage = this.package as ProjectPackage; - Debug.Assert(projectPackage != null, "Package not inherited from framework"); - if(projectPackage != null) - { - foreach(SolutionListener listener in projectPackage.SolutionListeners) - { - IProjectEvents projectEvents = listener as IProjectEvents; - if(projectEvents != null) - { - return projectEvents; - } - } - } - - return null; - } - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectFileConstants.cs b/SHFB/Source/MPFProj_VS2010/ProjectFileConstants.cs deleted file mode 100644 index c8b91d3e..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectFileConstants.cs +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//=============================================================================================================== -// File : ProjectReferenceNode.cs -// Updated : 12/29/2013 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// Search for "!EFW" to find the changes -// -// Date Who Comments -// ============================================================================================================== -// 12/29/2013 EFW Added support for ReferenceOutputAssembly metadata -//=============================================================================================================== - -using System.Diagnostics.CodeAnalysis; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Defines the constant strings for various msbuild targets - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ms")] - public static class MsBuildTarget - { - public const string ResolveProjectReferences = "ResolveProjectReferences"; - public const string ResolveAssemblyReferences = "ResolveAssemblyReferences"; - public const string ResolveComReferences = "ResolveComReferences"; - public const string Build = "Build"; - public const string Rebuild = "ReBuild"; - public const string Clean = "Clean"; - } - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ms")] - public static class MsBuildGeneratedItemType - { - public const string ReferenceCopyLocalPaths = "ReferenceCopyLocalPaths"; - public const string ComReferenceWrappers = "ComReferenceWrappers"; - } - - /// - /// Defines the constant strings used with project files. - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "COM")] - public static class ProjectFileConstants - { - public const string Include = "Include"; - public const string Name = "Name"; - public const string HintPath = "HintPath"; - public const string AssemblyName = "AssemblyName"; - public const string FinalOutputPath = "FinalOutputPath"; - public const string Project = "Project"; - public const string LinkedIntoProjectAt = "LinkedIntoProjectAt"; - public const string TypeGuid = "TypeGuid"; - public const string InstanceGuid = "InstanceGuid"; - public const string Private = "Private"; - public const string EmbedInteropTypes = "EmbedInteropTypes"; - public const string ProjectReference = "ProjectReference"; - // !EFW - Added support for ReferenceOutputAssembly - public const string ReferenceOutputAssembly = "ReferenceOutputAssembly"; - public const string Reference = "Reference"; - public const string WebReference = "WebReference"; - public const string WebReferenceFolder = "WebReferenceFolder"; - public const string Folder = "Folder"; - public const string Content = "Content"; - public const string EmbeddedResource = "EmbeddedResource"; - public const string RootNamespace = "RootNamespace"; - public const string OutputType = "OutputType"; - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "SubType")] - public const string SubType = "SubType"; - public const string DependentUpon = "DependentUpon"; - public const string Compile = "Compile"; - public const string ReferencePath = "ReferencePath"; - public const string ResolvedProjectReferencePaths = "ResolvedProjectReferencePaths"; - public const string Configuration = "Configuration"; - public const string Platform = "Platform"; - public const string AvailablePlatforms = "AvailablePlatforms"; - public const string BuildVerbosity = "BuildVerbosity"; - public const string Template = "Template"; - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "SubProject")] - public const string SubProject = "SubProject"; - public const string BuildAction = "BuildAction"; - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "COM")] - public const string COMReference = "COMReference"; - public const string Guid = "Guid"; - public const string VersionMajor = "VersionMajor"; - public const string VersionMinor = "VersionMinor"; - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lcid")] - public const string Lcid = "Lcid"; - public const string Isolated = "Isolated"; - public const string WrapperTool = "WrapperTool"; - public const string BuildingInsideVisualStudio = "BuildingInsideVisualStudio"; - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - public const string SccProjectName = "SccProjectName"; - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - public const string SccLocalPath = "SccLocalPath"; - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - public const string SccAuxPath = "SccAuxPath"; - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - public const string SccProvider = "SccProvider"; - public const string ProjectGuid = "ProjectGuid"; - public const string ProjectTypeGuids = "ProjectTypeGuids"; - public const string Generator = "Generator"; - public const string CustomToolNamespace = "CustomToolNamespace"; - public const string FlavorProperties = "FlavorProperties"; - public const string VisualStudio = "VisualStudio"; - public const string User = "User"; - public const string ApplicationDefinition = "ApplicationDefinition"; - public const string Link = "Link"; - public const string Page = "Page"; - public const string Resource = "Resource"; - public const string None = "None"; - } - - public static class ProjectFileAttributeValue - { - public const string Code = "Code"; - public const string Form = "Form"; - public const string Component = "Component"; - public const string Designer = "Designer"; - public const string UserControl = "UserControl"; - } - - internal static class ProjectFileValues - { - internal const string AnyCPU = "AnyCPU"; - } - - public enum WrapperToolAttributeValue - { - Primary, - TlbImp - } - - /// - /// A set of constants that specify the default sort order for different types of hierarchy nodes. - /// - public static class DefaultSortOrderNode - { - public const int HierarchyNode = 1000; - public const int FolderNode = 500; - public const int NestedProjectNode = 200; - public const int ReferenceContainerNode = 300; - } - -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectNode.CopyPaste.cs b/SHFB/Source/MPFProj_VS2010/ProjectNode.CopyPaste.cs deleted file mode 100644 index e1a0e07f..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectNode.CopyPaste.cs +++ /dev/null @@ -1,1223 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//============================================================================= -// File : ProjectNode.CopyPaste.cs -// Updated : 01/01/2012 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// This file has been modified to fix a bug in DragEnter that prevented drag -// and drop from happening at all in a custom project. Search for "!EFW" to -// find the changes. -// -// Date Who Comments -// ============================================================================ -// 06/18/2008 EFW Added support for linked project files -// 03/20/2011 EFW Updated to use MPFProj for VS2010 -// 01/01/2012 EFW Fixed a bug in WalkSourceProjectAndAdd() that caused -// a crash due to incorrectly copying sibling items -// recursively. -//============================================================================= - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security.Permissions; -using System.Text; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using IOleDataObject = Microsoft.VisualStudio.OLE.Interop.IDataObject; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Manages the CopyPaste and Drag and Drop scenarios for a Project. - /// - /// This is a partial class. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")] - public partial class ProjectNode : IVsUIHierWinClipboardHelperEvents - { - #region fields - private uint copyPasteCookie; - private DropDataType dropDataType; - #endregion - - #region override of IVsHierarchyDropDataTarget methods - // !EFW - /// - /// Called as soon as the mouse drags an item over a new hierarchy or hierarchy window - /// - /// reference to interface IDataObject of the item being dragged - /// Current state of the keyboard and the mouse modifier keys. See docs for a list of possible values - /// Item identifier for the item currently being dragged - /// On entry, a pointer to the current DropEffect. On return, must contain the new valid DropEffect - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int DragEnter(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect) - { - pdwEffect = (uint)DropEffect.None; - - this.dropDataType = QueryDropDataType(pDataObject); - - if (this.dropDataType != DropDataType.None) - pdwEffect = (uint)this.QueryDropEffect(this.dropDataType, grfKeyState); - - return VSConstants.S_OK; - } - - /// - /// Called when one or more items are dragged out of the hierarchy or hierarchy window, or when the drag-and-drop operation is cancelled or completed. - /// - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int DragLeave() - { - this.dropDataType = DropDataType.None; - return VSConstants.S_OK; - } - - /// - /// Called when one or more items are dragged over the target hierarchy or hierarchy window. - /// - /// Current state of the keyboard keys and the mouse modifier buttons. See - /// Item identifier of the drop data target over which the item is being dragged - /// On entry, reference to the value of the pdwEffect parameter of the IVsHierarchy object, identifying all effects that the hierarchy supports. - /// On return, the pdwEffect parameter must contain one of the effect flags that indicate the result of the drop operation. For a list of pwdEffects values, see - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int DragOver(uint grfKeyState, uint itemid, ref uint pdwEffect) - { - pdwEffect = (uint)DropEffect.None; - - // Dragging items to a project that is being debugged is not supported - // (see VSWhidbey 144785) - DBGMODE dbgMode = VsShellUtilities.GetDebugMode(this.Site) & ~DBGMODE.DBGMODE_EncMask; - if(dbgMode == DBGMODE.DBGMODE_Run || dbgMode == DBGMODE.DBGMODE_Break) - { - return VSConstants.S_OK; - } - - if(this.isClosed || this.site == null) - { - return VSConstants.E_UNEXPECTED; - } - - // We should also analyze if the node being dragged over can accept the drop. - if(!this.CanTargetNodeAcceptDrop(itemid)) - { - return VSConstants.E_NOTIMPL; - } - - if(this.dropDataType != DropDataType.None) - { - pdwEffect = (uint)this.QueryDropEffect(this.dropDataType, grfKeyState); - } - - return VSConstants.S_OK; - } - - /// - /// Called when one or more items are dropped into the target hierarchy or hierarchy window when the mouse button is released. - /// - /// Reference to the IDataObject interface on the item being dragged. This data object contains the data being transferred in the drag-and-drop operation. - /// If the drop occurs, then this data object (item) is incorporated into the target hierarchy or hierarchy window. - /// Current state of the keyboard and the mouse modifier keys. See - /// Item identifier of the drop data target over which the item is being dragged - /// Visual effects associated with the drag-and drop-operation, such as a cursor, bitmap, and so on. - /// The value of dwEffects passed to the source object via the OnDropNotify method is the value of pdwEffects returned by the Drop method - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int Drop(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref uint pdwEffect) - { - if(pDataObject == null) - { - return VSConstants.E_INVALIDARG; - } - - pdwEffect = (uint)DropEffect.None; - - // Get the node that is being dragged over and ask it which node should handle this call - HierarchyNode targetNode = NodeFromItemId(itemid); - if(targetNode != null) - { - targetNode = targetNode.GetDragTargetHandlerNode(); - } - else - { - // There is no target node. The drop can not be completed. - return VSConstants.S_FALSE; - } - - int returnValue; - try - { - DropDataType dropDataType = DropDataType.None; - dropDataType = ProcessSelectionDataObject(pDataObject, targetNode); - pdwEffect = (uint)this.QueryDropEffect(dropDataType, grfKeyState); - - // If it is a drop from windows and we get any kind of error we return S_FALSE and dropeffect none. This - // prevents bogus messages from the shell from being displayed - returnValue = (dropDataType != DropDataType.Shell) ? VSConstants.E_FAIL : VSConstants.S_OK; - } - catch(System.IO.FileNotFoundException e) - { - Trace.WriteLine("Exception : " + e.Message); - - if(!Utilities.IsInAutomationFunction(this.Site)) - { - string message = e.Message; - string title = string.Empty; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton); - } - - returnValue = VSConstants.E_FAIL; - } - - return returnValue; - } - #endregion - - #region override of IVsHierarchyDropDataSource2 methods - /// - /// Returns information about one or more of the items being dragged - /// - /// Pointer to a DWORD value describing the effects displayed while the item is being dragged, - /// such as cursor icons that change during the drag-and-drop operation. - /// For example, if the item is dragged over an invalid target point - /// (such as the item's original location), the cursor icon changes to a circle with a line through it. - /// Similarly, if the item is dragged over a valid target point, the cursor icon changes to a file or folder. - /// Pointer to the IDataObject interface on the item being dragged. - /// This data object contains the data being transferred in the drag-and-drop operation. - /// If the drop occurs, then this data object (item) is incorporated into the target hierarchy or hierarchy window. - /// Pointer to the IDropSource interface of the item being dragged. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int GetDropInfo(out uint pdwOKEffects, out IOleDataObject ppDataObject, out IDropSource ppDropSource) - { - //init out params - pdwOKEffects = (uint)DropEffect.None; - ppDataObject = null; - ppDropSource = null; - - IOleDataObject dataObject = PackageSelectionDataObject(false); - if(dataObject == null) - { - return VSConstants.E_NOTIMPL; - } - - this.SourceDraggedOrCutOrCopied = true; - - pdwOKEffects = (uint)(DropEffect.Move | DropEffect.Copy); - - ppDataObject = dataObject; - return VSConstants.S_OK; - } - - /// - /// Notifies clients that the dragged item was dropped. - /// - /// If true, then the dragged item was dropped on the target. If false, then the drop did not occur. - /// Visual effects associated with the drag-and-drop operation, such as cursors, bitmaps, and so on. - /// The value of dwEffects passed to the source object via OnDropNotify method is the value of pdwEffects returned by Drop method. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int OnDropNotify(int fDropped, uint dwEffects) - { - if(!this.SourceDraggedOrCutOrCopied) - { - return VSConstants.S_FALSE; - } - - this.CleanupSelectionDataObject(fDropped != 0, false, dwEffects == (uint)DropEffect.Move); - - this.SourceDraggedOrCutOrCopied = false; - - return VSConstants.S_OK; - } - - /// - /// Allows the drag source to prompt to save unsaved items being dropped. - /// Notifies the source hierarchy that information dragged from it is about to be dropped on a target. - /// This method is called immediately after the mouse button is released on a drop. - /// - /// Reference to the IDataObject interface on the item being dragged. - /// This data object contains the data being transferred in the drag-and-drop operation. - /// If the drop occurs, then this data object (item) is incorporated into the hierarchy window of the new hierarchy. - /// Current state of the keyboard and the mouse modifier keys. - /// If true, then the drop is cancelled by the source hierarchy. If false, then the drop can continue. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public override int OnBeforeDropNotify(IOleDataObject o, uint dwEffect, out int fCancelDrop) - { - // If there is nothing to be dropped just return that drop should be cancelled. - if(this.ItemsDraggedOrCutOrCopied == null) - { - fCancelDrop = 1; - return VSConstants.S_OK; - } - - fCancelDrop = 0; - bool dirty = false; - foreach(HierarchyNode node in this.ItemsDraggedOrCutOrCopied) - { - bool isDirty, isOpen, isOpenedByUs; - uint docCookie; - IVsPersistDocData ppIVsPersistDocData; - DocumentManager manager = node.GetDocumentManager(); - if(manager != null) - { - manager.GetDocInfo(out isOpen, out isDirty, out isOpenedByUs, out docCookie, out ppIVsPersistDocData); - if(isDirty && isOpenedByUs) - { - dirty = true; - break; - } - } - } - - // if there are no dirty docs we are ok to proceed - if(!dirty) - { - return VSConstants.S_OK; - } - - // Prompt to save if there are dirty docs - string message = SR.GetString(SR.SaveModifiedDocuments, CultureInfo.CurrentUICulture); - string title = string.Empty; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_WARNING; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - int result = VsShellUtilities.ShowMessageBox(Site, title, message, icon, buttons, defaultButton); - switch(result) - { - case NativeMethods.IDYES: - break; - - case NativeMethods.IDNO: - return VSConstants.S_OK; - - case NativeMethods.IDCANCEL: goto default; - - default: - fCancelDrop = 1; - return VSConstants.S_OK; - } - - // Save all dirty documents - foreach(HierarchyNode node in this.ItemsDraggedOrCutOrCopied) - { - DocumentManager manager = node.GetDocumentManager(); - if(manager != null) - { - manager.Save(true); - } - } - - return VSConstants.S_OK; - } - - #endregion - - #region IVsUIHierWinClipboardHelperEvents Members - /// - /// Called after your cut/copied items has been pasted - /// - ///If true, then the IDataObject has been successfully pasted into a target hierarchy. - /// If false, then the cut or copy operation was cancelled. - /// Visual effects associated with the drag and drop operation, such as cursors, bitmaps, and so on. - /// These should be the same visual effects used in OnDropNotify - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int OnPaste(int wasCut, uint dropEffect) - { - if(!this.SourceDraggedOrCutOrCopied) - { - return VSConstants.S_FALSE; - } - - if(dropEffect == (uint)DropEffect.None) - { - return OnClear(wasCut); - } - - this.CleanupSelectionDataObject(false, wasCut != 0, dropEffect == (uint)DropEffect.Move); - this.SourceDraggedOrCutOrCopied = false; - return VSConstants.S_OK; - } - - /// - /// Called when your cut/copied operation is canceled - /// - /// This flag informs the source that the Cut method was called (true), - /// rather than Copy (false), so the source knows whether to "un-cut-highlight" the items that were cut. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int OnClear(int wasCut) - { - if(!this.SourceDraggedOrCutOrCopied) - { - return VSConstants.S_FALSE; - } - - this.CleanupSelectionDataObject(false, wasCut != 0, false, true); - this.SourceDraggedOrCutOrCopied = false; - return VSConstants.S_OK; - } - #endregion - - #region virtual methods - /// - /// Determines if a node can accept drop opertaion. - /// - /// The id of the node. - /// true if the node accepts drag operation. - protected internal virtual bool CanTargetNodeAcceptDrop(uint itemId) - { - HierarchyNode targetNode = NodeFromItemId(itemId); - if(targetNode is ReferenceContainerNode || targetNode is ReferenceNode) - { - return false; - } - else - { - return true; - } - } - - /// - /// Returns a dataobject from selected nodes - /// - /// boolean that defines if the selected items must be cut - /// data object for selected items - internal virtual DataObject PackageSelectionDataObject(bool cutHighlightItems) - { - this.CleanupSelectionDataObject(false, false, false); - StringBuilder sb = new StringBuilder(); - - DataObject dataObject = null; - - try - { - IList selectedNodes = this.GetSelectedNodes(); - if(selectedNodes != null) - { - this.InstantiateItemsDraggedOrCutOrCopiedList(); - - StringBuilder selectionContent = null; - - // If there is a selection package the data - if(selectedNodes.Count > 1) - { - foreach(HierarchyNode node in selectedNodes) - { - selectionContent = node.PrepareSelectedNodesForClipBoard(); - if(selectionContent != null) - { - sb.Append(selectionContent); - } - } - } - else if(selectedNodes.Count == 1) - { - HierarchyNode selectedNode = selectedNodes[0]; - selectionContent = selectedNode.PrepareSelectedNodesForClipBoard(); - if(selectionContent != null) - { - sb.Append(selectionContent); - } - } - } - - // Add the project items first. - IntPtr ptrToItems = this.PackageSelectionData(sb, false); - if(ptrToItems == IntPtr.Zero) - { - return null; - } - - FORMATETC fmt = DragDropHelper.CreateFormatEtc(DragDropHelper.CF_VSSTGPROJECTITEMS); - dataObject = new DataObject(); - dataObject.SetData(fmt, ptrToItems); - - // Now add the project path that sourced data. We just write the project file path. - IntPtr ptrToProjectPath = this.PackageSelectionData(new StringBuilder(this.GetMkDocument()), true); - - if(ptrToProjectPath != IntPtr.Zero) - { - dataObject.SetData(DragDropHelper.CreateFormatEtc(DragDropHelper.CF_VSPROJECTCLIPDESCRIPTOR), ptrToProjectPath); - } - - if (cutHighlightItems) - { - bool first = true; - IVsUIHierarchyWindow w = UIHierarchyUtilities.GetUIHierarchyWindow(this.site, HierarchyNode.SolutionExplorer); - - // This happens in the context of cutting multiple items from the project. - // Since we are already in solution explorer, it is extremely unlikely that we get a null return. - // If we do, the icons for the cut items will not fade. The cut operation will still succeed. - if (w != null) - { - foreach (HierarchyNode node in this.ItemsDraggedOrCutOrCopied) - { - ErrorHandler.ThrowOnFailure(w.ExpandItem(this.InteropSafeIVsUIHierarchy, node.ID, first ? EXPANDFLAGS.EXPF_CutHighlightItem : EXPANDFLAGS.EXPF_AddCutHighlightItem)); - first = false; - } - } - } - } - catch(COMException e) - { - Trace.WriteLine("Exception : " + e.Message); - - dataObject = null; - } - - return dataObject; - } - - - /// - /// This is used to recursively add a folder from an other project. - /// Note that while we copy the folder content completely, we only - /// add to the project items which are part of the source project. - /// - /// Project reference (from data object) using the format: {Guid}|project|folderPath - /// Node to add the new folder to - protected internal virtual void AddFolderFromOtherProject(string folderToAdd, HierarchyNode targetNode) - { - if(String.IsNullOrEmpty(folderToAdd)) - throw new ArgumentNullException("folderToAdd"); - if(targetNode == null) - throw new ArgumentNullException("targetNode"); - - // Split the reference in its 3 parts - int index1 = Guid.Empty.ToString("B").Length; - if(index1 + 1 >= folderToAdd.Length) - throw new ArgumentOutOfRangeException("folderToAdd"); - - // Get the Guid - string guidString = folderToAdd.Substring(1, index1 - 2); - Guid projectInstanceGuid = new Guid(guidString); - - // Get the project path - int index2 = folderToAdd.IndexOf('|', index1 + 1); - if(index2 < 0 || index2 + 1 >= folderToAdd.Length) - throw new ArgumentOutOfRangeException("folderToAdd"); - - // Finally get the source path - string folder = folderToAdd.Substring(index2 + 1); - - // Get the target path - string folderName = Path.GetFileName(Path.GetDirectoryName(folder)); - string targetPath = Path.Combine(GetBaseDirectoryForAddingFiles(targetNode), folderName); - - // Recursively copy the directory to the new location - Utilities.RecursivelyCopyDirectory(folder, targetPath); - - // Retrieve the project from which the items are being copied - IVsHierarchy sourceHierarchy; - IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution)); - ErrorHandler.ThrowOnFailure(solution.GetProjectOfGuid(ref projectInstanceGuid, out sourceHierarchy)); - - // Then retrieve the item ID of the item to copy - uint itemID = VSConstants.VSITEMID_ROOT; - ErrorHandler.ThrowOnFailure(sourceHierarchy.ParseCanonicalName(folder, out itemID)); - - // Ensure we don't end up in an endless recursion - if(Utilities.IsSameComObject(this.InteropSafeIVsHierarchy, sourceHierarchy)) - { - HierarchyNode cursorNode = targetNode; - while(cursorNode != null) - { - if(String.Compare(folder, cursorNode.GetMkDocument(), StringComparison.OrdinalIgnoreCase) == 0) - throw new Exception(); - cursorNode = cursorNode.Parent; - } - } - - // Now walk the source project hierarchy to see which node needs to be added. - WalkSourceProjectAndAdd(sourceHierarchy, itemID, targetNode, false); - } - - /// - /// Recursive method that walk a hierarchy and add items it find to our project. - /// Note that this is meant as an helper to the Copy and Paste/Drag and Drop functionality. - /// - /// Hierarchy to walk - /// Item ID where to start walking the hierarchy - /// Node to start adding to - /// Typically false on first call and true after that - protected virtual void WalkSourceProjectAndAdd(IVsHierarchy sourceHierarchy, uint itemId, HierarchyNode targetNode, bool addSiblings) - { - if (sourceHierarchy == null) - { - throw new ArgumentNullException("sourceHierarchy"); - } - - // Before we start the walk, add the current node - object variant = null; - HierarchyNode newNode = targetNode; - if(itemId != VSConstants.VSITEMID_NIL) - { - // Calculate the corresponding path in our project - string source; - ErrorHandler.ThrowOnFailure(((IVsProject)sourceHierarchy).GetMkDocument(itemId, out source)); - string name = Path.GetFileName(source.TrimEnd(new char[] { '/', '\\' })); - string targetPath = Path.Combine(GetBaseDirectoryForAddingFiles(targetNode), name); - - // See if this is a linked item (file can be linked, not folders) - ErrorHandler.ThrowOnFailure(sourceHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_BrowseObject, out variant), VSConstants.E_NOTIMPL); - VSLangProj.FileProperties fileProperties = variant as VSLangProj.FileProperties; - if(fileProperties != null && fileProperties.IsLink) - { - // Since we don't support linked item, we make a copy of the file into our storage where it would have been linked - File.Copy(source, targetPath, true); - } - - newNode = AddNodeIfTargetExistInStorage(targetNode, name, targetPath); - - - // Start with child nodes (depth first) - variant = null; - ErrorHandler.ThrowOnFailure(sourceHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_FirstVisibleChild, out variant)); - uint currentItemID = (uint)(int)variant; - WalkSourceProjectAndAdd(sourceHierarchy, currentItemID, newNode, true); - - if(addSiblings) - { - // Then look at siblings - currentItemID = itemId; - while(currentItemID != VSConstants.VSITEMID_NIL) - { - variant = null; - ErrorHandler.ThrowOnFailure(sourceHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_NextVisibleSibling, out variant)); - currentItemID = (uint)(int)variant; - - // !EFW - Do not add siblings, we're doing that here. Instead get the next sibling from the current ID. - WalkSourceProjectAndAdd(sourceHierarchy, currentItemID, targetNode, false); - itemId = currentItemID; - } - } - } - } - - /// - /// Add an existing item (file/folder) to the project if it already exist in our storage. - /// - /// Node to that this item to - /// Name of the item being added - /// Path of the item being added - /// Node that was added - protected virtual HierarchyNode AddNodeIfTargetExistInStorage(HierarchyNode parentNode, string name, string targetPath) - { - if (parentNode == null) - { - return null; - } - - HierarchyNode newNode = parentNode; - // If the file/directory exist, add a node for it - if(File.Exists(targetPath)) - { - VSADDRESULT[] result = new VSADDRESULT[1]; - ErrorHandler.ThrowOnFailure(this.AddItem(parentNode.ID, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, name, 1, new string[] { targetPath }, IntPtr.Zero, result)); - if(result[0] != VSADDRESULT.ADDRESULT_Success) - throw new Exception(); - newNode = this.FindChild(targetPath); - if(newNode == null) - throw new Exception(); - } - else if(Directory.Exists(targetPath)) - { - newNode = this.CreateFolderNodes(targetPath); - } - return newNode; - } - #endregion - - #region non-virtual methods - /// - /// Handle the Cut operation to the clipboard - /// - protected internal override int CutToClipboard() - { - int returnValue = (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - try - { - this.RegisterClipboardNotifications(true); - - // Create our data object and change the selection to show item(s) being cut - IOleDataObject dataObject = this.PackageSelectionDataObject(true); - if(dataObject != null) - { - this.SourceDraggedOrCutOrCopied = true; - - // Add our cut item(s) to the clipboard - ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleSetClipboard(dataObject)); - - // Inform VS (UiHierarchyWindow) of the cut - IVsUIHierWinClipboardHelper clipboardHelper = (IVsUIHierWinClipboardHelper)GetService(typeof(SVsUIHierWinClipboardHelper)); - if(clipboardHelper == null) - { - return VSConstants.E_FAIL; - } - - returnValue = ErrorHandler.ThrowOnFailure(clipboardHelper.Cut(dataObject)); - } - } - catch(COMException e) - { - Trace.WriteLine("Exception : " + e.Message); - returnValue = e.ErrorCode; - } - - return returnValue; - } - - /// - /// Handle the Copy operation to the clipboard - /// - protected internal override int CopyToClipboard() - { - int returnValue = (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - try - { - this.RegisterClipboardNotifications(true); - - // Create our data object and change the selection to show item(s) being copy - IOleDataObject dataObject = this.PackageSelectionDataObject(false); - if(dataObject != null) - { - this.SourceDraggedOrCutOrCopied = true; - - // Add our copy item(s) to the clipboard - ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleSetClipboard(dataObject)); - - // Inform VS (UiHierarchyWindow) of the copy - IVsUIHierWinClipboardHelper clipboardHelper = (IVsUIHierWinClipboardHelper)GetService(typeof(SVsUIHierWinClipboardHelper)); - if(clipboardHelper == null) - { - return VSConstants.E_FAIL; - } - returnValue = ErrorHandler.ThrowOnFailure(clipboardHelper.Copy(dataObject)); - } - } - catch(COMException e) - { - Trace.WriteLine("Exception : " + e.Message); - returnValue = e.ErrorCode; - } - catch(ArgumentException e) - { - Trace.WriteLine("Exception : " + e.Message); - returnValue = Marshal.GetHRForException(e); - } - - return returnValue; - } - - /// - /// Handle the Paste operation to a targetNode - /// - protected internal override int PasteFromClipboard(HierarchyNode targetNode) - { - int returnValue = (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - - if (targetNode == null) - { - return VSConstants.E_INVALIDARG; - } - - //Get the clipboardhelper service and use it after processing dataobject - IVsUIHierWinClipboardHelper clipboardHelper = (IVsUIHierWinClipboardHelper)GetService(typeof(SVsUIHierWinClipboardHelper)); - if(clipboardHelper == null) - { - return VSConstants.E_FAIL; - } - - try - { - //Get dataobject from clipboard - IOleDataObject dataObject = null; - ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleGetClipboard(out dataObject)); - if(dataObject == null) - { - return VSConstants.E_UNEXPECTED; - } - - DropEffect dropEffect = DropEffect.None; - DropDataType dropDataType = DropDataType.None; - try - { - dropDataType = this.ProcessSelectionDataObject(dataObject, targetNode.GetDragTargetHandlerNode()); - dropEffect = this.QueryDropEffect(dropDataType, 0); - } - catch(ExternalException e) - { - Trace.WriteLine("Exception : " + e.Message); - - // If it is a drop from windows and we get any kind of error ignore it. This - // prevents bogus messages from the shell from being displayed - if(dropDataType != DropDataType.Shell) - { - throw; - } - } - finally - { - // Inform VS (UiHierarchyWindow) of the paste - returnValue = clipboardHelper.Paste(dataObject, (uint)dropEffect); - } - } - catch(COMException e) - { - Trace.WriteLine("Exception : " + e.Message); - - returnValue = e.ErrorCode; - } - - return returnValue; - } - - /// - /// Determines if the paste command should be allowed. - /// - /// - protected internal override bool AllowPasteCommand() - { - IOleDataObject dataObject = null; - try - { - ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleGetClipboard(out dataObject)); - if(dataObject == null) - { - return false; - } - - // First see if this is a set of storage based items - FORMATETC format = DragDropHelper.CreateFormatEtc((ushort)DragDropHelper.CF_VSSTGPROJECTITEMS); - if(dataObject.QueryGetData(new FORMATETC[] { format }) == VSConstants.S_OK) - return true; - // Try reference based items - format = DragDropHelper.CreateFormatEtc((ushort)DragDropHelper.CF_VSREFPROJECTITEMS); - if(dataObject.QueryGetData(new FORMATETC[] { format }) == VSConstants.S_OK) - return true; - // Try windows explorer files format - format = DragDropHelper.CreateFormatEtc((ushort)NativeMethods.CF_HDROP); - return (dataObject.QueryGetData(new FORMATETC[] { format }) == VSConstants.S_OK); - } - // We catch External exceptions since it might be that it is not our data on the clipboard. - catch(ExternalException e) - { - Trace.WriteLine("Exception :" + e.Message); - return false; - } - } - - /// - /// Register/Unregister for Clipboard events for the UiHierarchyWindow (solution explorer) - /// - /// true for register, false for unregister - protected internal override void RegisterClipboardNotifications(bool register) - { - // Get the UiHierarchy window clipboard helper service - IVsUIHierWinClipboardHelper clipboardHelper = (IVsUIHierWinClipboardHelper)GetService(typeof(SVsUIHierWinClipboardHelper)); - if(clipboardHelper == null) - { - return; - } - - if(register && this.copyPasteCookie == 0) - { - // Register - ErrorHandler.ThrowOnFailure(clipboardHelper.AdviseClipboardHelperEvents(this.InteropSafeIVsUIHierWinClipboardHelperEvents, out this.copyPasteCookie)); - Debug.Assert(this.copyPasteCookie != 0, "AdviseClipboardHelperEvents returned an invalid cookie"); - } - else if(!register && this.copyPasteCookie != 0) - { - // Unregister - ErrorHandler.ThrowOnFailure(clipboardHelper.UnadviseClipboardHelperEvents(this.copyPasteCookie)); - this.copyPasteCookie = 0; - } - } - - /// - /// Process dataobject from Drag/Drop/Cut/Copy/Paste operation - /// - /// The targetNode is set if the method is called from a drop operation, otherwise it is null - internal DropDataType ProcessSelectionDataObject(IOleDataObject dataObject, HierarchyNode targetNode) - { - DropDataType dropDataType = DropDataType.None; - bool isWindowsFormat = false; - - // Try to get it as a directory based project. - List filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSSTGPROJECTITEMS, dataObject, out dropDataType); - if(filesDropped.Count == 0) - { - filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSREFPROJECTITEMS, dataObject, out dropDataType); - } - if(filesDropped.Count == 0) - { - filesDropped = DragDropHelper.GetDroppedFiles(NativeMethods.CF_HDROP, dataObject, out dropDataType); - isWindowsFormat = (filesDropped.Count > 0); - } - - if(dropDataType != DropDataType.None && filesDropped.Count > 0) - { - string[] filesDroppedAsArray = filesDropped.ToArray(); - - HierarchyNode node = (targetNode == null) ? this : targetNode; - - // For directory based projects the content of the clipboard is a double-NULL terminated list of Projref strings. - if(isWindowsFormat) - { - // This is the code path when source is windows explorer - VSADDRESULT[] vsaddresults = new VSADDRESULT[1]; - vsaddresults[0] = VSADDRESULT.ADDRESULT_Failure; - int addResult = AddItem(node.ID, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, (uint)filesDropped.Count, filesDroppedAsArray, IntPtr.Zero, vsaddresults); - if(addResult != VSConstants.S_OK && addResult != VSConstants.S_FALSE && addResult != (int)OleConstants.OLECMDERR_E_CANCELED - && vsaddresults[0] != VSADDRESULT.ADDRESULT_Success) - { - ErrorHandler.ThrowOnFailure(addResult); - } - - return dropDataType; - } - else - { - if(AddFilesFromProjectReferences(node, filesDroppedAsArray)) - { - return dropDataType; - } - } - } - - // If we reached this point then the drop data must be set to None. - // Otherwise the OnPaste will be called with a valid DropData and that would actually delete the item. - return DropDataType.None; - } - - /// - /// Get the dropdatatype from the dataobject - /// - /// The dataobject to be analysed for its format - /// dropdatatype or none if dataobject does not contain known format - internal static DropDataType QueryDropDataType(IOleDataObject pDataObject) - { - if(pDataObject == null) - { - return DropDataType.None; - } - - // known formats include File Drops (as from WindowsExplorer), - // VSProject Reference Items and VSProject Storage Items. - FORMATETC fmt = DragDropHelper.CreateFormatEtc(NativeMethods.CF_HDROP); - - if(DragDropHelper.QueryGetData(pDataObject, ref fmt) == VSConstants.S_OK) - { - return DropDataType.Shell; - } - - fmt.cfFormat = DragDropHelper.CF_VSREFPROJECTITEMS; - if(DragDropHelper.QueryGetData(pDataObject, ref fmt) == VSConstants.S_OK) - { - // Data is from a Ref-based project. - return DropDataType.VsRef; - } - - fmt.cfFormat = DragDropHelper.CF_VSSTGPROJECTITEMS; - if(DragDropHelper.QueryGetData(pDataObject, ref fmt) == VSConstants.S_OK) - { - return DropDataType.VsStg; - } - - return DropDataType.None; - } - - /// - /// Returns the drop effect. - /// - /// - /// // A directory based project should perform as follow: - /// NO MODIFIER - /// - COPY if not from current hierarchy, - /// - MOVE if from current hierarchy - /// SHIFT DRAG - MOVE - /// CTRL DRAG - COPY - /// CTRL-SHIFT DRAG - NO DROP (used for reference based projects only) - /// - internal DropEffect QueryDropEffect(DropDataType dropDataType, uint grfKeyState) - { - //Validate the dropdatatype - if((dropDataType != DropDataType.Shell) && (dropDataType != DropDataType.VsRef) && (dropDataType != DropDataType.VsStg)) - { - return DropEffect.None; - } - - // CTRL-SHIFT - if((grfKeyState & NativeMethods.MK_CONTROL) != 0 && (grfKeyState & NativeMethods.MK_SHIFT) != 0) - { - // Because we are not referenced base, we don't support link - return DropEffect.None; - } - - // CTRL - if((grfKeyState & NativeMethods.MK_CONTROL) != 0) - return DropEffect.Copy; - - // SHIFT - if((grfKeyState & NativeMethods.MK_SHIFT) != 0) - return DropEffect.Move; - - // no modifier - if(this.SourceDraggedOrCutOrCopied) - { - return DropEffect.Move; - } - else - { - return DropEffect.Copy; - } - } - - internal void CleanupSelectionDataObject(bool dropped, bool cut, bool moved) - { - this.CleanupSelectionDataObject(dropped, cut, moved, false); - } - - /// - /// After a drop or paste, will use the dwEffects - /// to determine whether we need to clean up the source nodes or not. If - /// justCleanup is set, it only does the cleanup work. - /// - internal void CleanupSelectionDataObject(bool dropped, bool cut, bool moved, bool justCleanup) - { - if(this.ItemsDraggedOrCutOrCopied == null || this.ItemsDraggedOrCutOrCopied.Count == 0) - { - return; - } - - try - { - IVsUIHierarchyWindow w = UIHierarchyUtilities.GetUIHierarchyWindow(this.site, HierarchyNode.SolutionExplorer); - foreach(HierarchyNode node in this.ItemsDraggedOrCutOrCopied) - { - if((moved && (cut || dropped) && !justCleanup)) - { - // do not close it if the doc is dirty or we do not own it - bool isDirty, isOpen, isOpenedByUs; - uint docCookie; - IVsPersistDocData ppIVsPersistDocData; - DocumentManager manager = node.GetDocumentManager(); - if(manager != null) - { - manager.GetDocInfo(out isOpen, out isDirty, out isOpenedByUs, out docCookie, out ppIVsPersistDocData); - if(isDirty || (isOpen && !isOpenedByUs)) - { - continue; - } - - // close it if opened - if(isOpen) - { - manager.Close(__FRAMECLOSE.FRAMECLOSE_NoSave); - } - } - - node.Remove(true); - } - else if(w != null) - { - ErrorHandler.ThrowOnFailure(w.ExpandItem(this.InteropSafeIVsUIHierarchy, node.ID, EXPANDFLAGS.EXPF_UnCutHighlightItem)); - } - } - } - finally - { - try - { - // Now delete the memory allocated by the packaging of datasources. - // If we just did a cut, or we are told to cleanup, then we need to free the data object. Otherwise, we leave it - // alone so that you can continue to paste the data in new locations. - if(moved || cut || justCleanup) - { - this.ItemsDraggedOrCutOrCopied.Clear(); - this.CleanAndFlushClipboard(); - } - } - finally - { - this.dropDataType = DropDataType.None; - } - } - } - - /// - /// Moves files from one part of our project to another. - /// - /// the targetHandler node - /// List of projectref string - /// true if succeeded - internal bool AddFilesFromProjectReferences(HierarchyNode targetNode, string[] projectReferences) - { - //Validate input - if(projectReferences == null) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "projectReferences"); - } - if(targetNode == null) - { - throw new InvalidOperationException(); - } - - //Iteratively add files from projectref - foreach(string projectReference in projectReferences) - { - if(projectReference == null) - { - // bad projectref, bail out - return false; - } - if(projectReference.EndsWith("/", StringComparison.Ordinal) || projectReference.EndsWith("\\", StringComparison.Ordinal)) - { - AddFolderFromOtherProject(projectReference, targetNode); - } - else if(!AddFileToNodeFromProjectReference(projectReference, targetNode)) - { - return false; - } - } - - return true; - } - - #endregion - - #region private helper methods - /// - /// Empties all the data structures added to the clipboard and flushes the clipboard. - /// - private void CleanAndFlushClipboard() - { - IOleDataObject oleDataObject = null; - ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleGetClipboard(out oleDataObject)); - if(oleDataObject == null) - { - return; - } - - - string sourceProjectPath = DragDropHelper.GetSourceProjectPath(oleDataObject); - - if(!String.IsNullOrEmpty(sourceProjectPath) && NativeMethods.IsSamePath(sourceProjectPath, this.GetMkDocument())) - { - ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleFlushClipboard()); - int clipboardOpened = 0; - try - { - ErrorHandler.ThrowOnFailure(clipboardOpened = UnsafeNativeMethods.OpenClipboard(IntPtr.Zero)); - ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.EmptyClipboard()); - } - finally - { - if(clipboardOpened == 1) - { - ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.CloseClipboard()); - } - } - } - } - - private IntPtr PackageSelectionData(StringBuilder sb, bool addEndFormatDelimiter) - { - if(sb == null || sb.ToString().Length == 0 || this.ItemsDraggedOrCutOrCopied.Count == 0) - { - return IntPtr.Zero; - } - - // Double null at end. - if(addEndFormatDelimiter) - { - if(sb.ToString()[sb.Length - 1] != '\0') - { - sb.Append('\0'); - } - } - - // We request unmanaged permission to execute the below. - new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); - - _DROPFILES df = new _DROPFILES(); - int dwSize = Marshal.SizeOf(df); - Int16 wideChar = 0; - int dwChar = Marshal.SizeOf(wideChar); - int structSize = dwSize + ((sb.Length + 1) * dwChar); - IntPtr ptr = Marshal.AllocHGlobal(structSize); - df.pFiles = dwSize; - df.fWide = 1; - IntPtr data = IntPtr.Zero; - try - { - data = UnsafeNativeMethods.GlobalLock(ptr); - Marshal.StructureToPtr(df, data, false); - IntPtr strData = new IntPtr((long)data + dwSize); - DragDropHelper.CopyStringToHGlobal(sb.ToString(), strData, structSize); - } - finally - { - if(data != IntPtr.Zero) - UnsafeNativeMethods.GlobalUnLock(data); - } - - return ptr; - } - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectNode.Events.cs b/SHFB/Source/MPFProj_VS2010/ProjectNode.Events.cs deleted file mode 100644 index a67c2d93..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectNode.Events.cs +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; - -namespace Microsoft.VisualStudio.Project -{ - public partial class ProjectNode - { - #region fields - private EventHandler projectPropertiesListeners; - #endregion - - #region events - public event EventHandler OnProjectPropertyChanged - { - add { projectPropertiesListeners += value; } - remove { projectPropertiesListeners -= value; } - } - #endregion - - #region methods - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")] - protected void RaiseProjectPropertyChanged(string propertyName, string oldValue, string newValue) - { - if(null != projectPropertiesListeners) - { - projectPropertiesListeners(this, new ProjectPropertyChangedArgs(propertyName, oldValue, newValue)); - } - } - #endregion - } - -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectNode.cs b/SHFB/Source/MPFProj_VS2010/ProjectNode.cs deleted file mode 100644 index e0f707f5..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectNode.cs +++ /dev/null @@ -1,7044 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//=============================================================================================================== -// File : ProjectNode.cs -// Updated : 02/15/2012 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// This file has been modified to support "Add as Link" and "Show All Files" in the project. Search for "!EFW" -// to find the changes. -// -// Date Who Comments -// ============================================================================================================== -// 06/18/2008 EFW Added support for linked project files -// 06/20/2008 EFW Added support for "Show All Files" -// 03/20/2011 EFW Updated to use MPFProj for VS2010 -// 04/17/2011 EFW Made UpgradeProject() virtual -// 03/20/2012 EFW Fixed odd bug related to adding new items to deeply nested collapsed nodes. -//=============================================================================================================== - -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; -using System.Text; -using System.Xml; - -using EnvDTE; -using Microsoft.Build.Evaluation; -using Microsoft.Build.Execution; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; - -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; -using IServiceProvider = System.IServiceProvider; -using MSBuild = Microsoft.Build.Evaluation; -using MSBuildConstruction = Microsoft.Build.Construction; -using MSBuildExecution = Microsoft.Build.Execution; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; -using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; -using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Manages the persistent state of the project (References, options, files, etc.) and deals with user interaction via a GUI in the form a hierarchy. - /// - [CLSCompliant(false)] - [ComVisible(true)] - public abstract partial class ProjectNode : HierarchyNode, - IVsGetCfgProvider, - IVsProject3, - IVsAggregatableProject, - IVsProjectFlavorCfgProvider, - IPersistFileFormat, - IVsProjectBuildSystem, - IVsBuildPropertyStorage, - IVsComponentUser, - IVsDependencyProvider, - IVsSccProject2, - IBuildDependencyUpdate, - IProjectEventsListener, - IProjectEventsProvider, - IReferenceContainerProvider, - IVsProjectSpecialFiles, - IVsProjectUpgrade, - IVsDesignTimeAssemblyResolution, - IVsSetTargetFrameworkWorkerCallback - { - #region nested types - - public enum ImageName - { - OfflineWebApp = 0, - WebReferencesFolder = 1, - OpenReferenceFolder = 2, - ReferenceFolder = 3, - Reference = 4, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SDL")] - SDLWebReference = 5, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "DISCO")] - DISCOWebReference = 6, - Folder = 7, - OpenFolder = 8, - ExcludedFolder = 9, - OpenExcludedFolder = 10, - ExcludedFile = 11, - DependentFile = 12, - MissingFile = 13, - WindowsForm = 14, - WindowsUserControl = 15, - WindowsComponent = 16, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "XML")] - XMLSchema = 17, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "XML")] - XMLFile = 18, - WebForm = 19, - WebService = 20, - WebUserControl = 21, - WebCustomUserControl = 22, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ASP")] - ASPPage = 23, - GlobalApplicationClass = 24, - WebConfig = 25, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "HTML")] - HTMLPage = 26, - StyleSheet = 27, - ScriptFile = 28, - TextFile = 29, - SettingsFile = 30, - Resources = 31, - Bitmap = 32, - Icon = 33, - Image = 34, - ImageMap = 35, - XWorld = 36, - Audio = 37, - Video = 38, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CAB")] - CAB = 39, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "JAR")] - JAR = 40, - DataEnvironment = 41, - PreviewFile = 42, - DanglingReference = 43, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "XSLT")] - XSLTFile = 44, - Cursor = 45, - AppDesignerFolder = 46, - Data = 47, - Application = 48, - DataSet = 49, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "PFX")] - PFX = 50, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SNK")] - SNK = 51, - - ImageLast = 51 - } - - /// - /// Flags for specifying which events to stop triggering. - /// - [Flags] - internal enum EventTriggering - { - TriggerAll = 0, - DoNotTriggerHierarchyEvents = 1, - DoNotTriggerTrackerEvents = 2 - } - - #endregion - - #region constants - /// - /// The user file extension. - /// - internal const string PerUserFileExtension = ".user"; - - private Guid GUID_MruPage = new Guid("{19B97F03-9594-4c1c-BE28-25FF030113B3}"); - - /// - /// The VS command that allows projects to open Windows Explorer to the project directory. - /// - private const VsCommands2K ExploreFolderInWindowsCommand = (VsCommands2K)1635; - - #endregion - - #region fields - - private static readonly FrameworkName DefaultTargetFrameworkMoniker = new FrameworkName(".NETFramework", new Version(4, 0)); - - private static Guid addComponentLastActiveTab = VSConstants.GUID_SolutionPage; - - private static uint addComponentDialogSizeX = 0; - - private static uint addComponentDialogSizeY = 0; - - /// - /// List of output groups names and their associated target - /// - private static KeyValuePair[] outputGroupNames = - { // Name Target (MSBuild) - new KeyValuePair("Built", "BuiltProjectOutputGroup"), - new KeyValuePair("ContentFiles", "ContentFilesProjectOutputGroup"), - new KeyValuePair("LocalizedResourceDlls", "SatelliteDllsProjectOutputGroup"), - new KeyValuePair("Documentation", "DocumentationProjectOutputGroup"), - new KeyValuePair("Symbols", "DebugSymbolsProjectOutputGroup"), - new KeyValuePair("SourceFiles", "SourceFilesProjectOutputGroup"), - new KeyValuePair("XmlSerializer", "SGenFilesOutputGroup"), - }; - - /// A project will only try to build if it can obtain a lock on this object - private volatile static object BuildLock = new object(); - - /// Maps integer ids to project item instances - private EventSinkCollection itemIdMap = new EventSinkCollection(); - - /// A service provider call back object provided by the IDE hosting the project manager - private ServiceProvider site; - - public static ServiceProvider ServiceProvider { get; set; } - - private TrackDocumentsHelper tracker; - - /// - /// A cached copy of project options. - /// - private ProjectOptions options; - - /// - /// This property returns the time of the last change made to this project. - /// It is not the time of the last change on the project file, but actually of - /// the in memory project settings. In other words, it is the last time that - /// SetProjectDirty was called. - /// - private DateTime lastModifiedTime; - - /// - /// MSBuild engine we are going to use - /// - private MSBuild.ProjectCollection buildEngine; - - private Microsoft.Build.Utilities.Logger buildLogger; - - private bool useProvidedLogger; - - private MSBuild.Project buildProject; - - private MSBuildExecution.ProjectInstance currentConfig; - - private DesignTimeAssemblyResolution designTimeAssemblyResolution; - - private ConfigProvider configProvider; - - private TaskProvider taskProvider; - - private string filename; - - private Microsoft.VisualStudio.Shell.Url baseUri; - - private bool isDirty; - - private bool isNewProject; - - private bool projectOpened; - - private bool buildIsPrepared; - - private ImageHandler imageHandler; - - private string errorString; - - private string warningString; - - private Guid projectIdGuid; - - private bool isClosed; - - private EventTriggering eventTriggeringFlag = EventTriggering.TriggerAll; - - private bool invokeMSBuildWhenResumed; - - private uint suspendMSBuildCounter; - - private bool canFileNodesHaveChilds; - - private bool isProjectEventsListener = true; - - /// - /// The build dependency list passed to IVsDependencyProvider::EnumDependencies - /// - private List buildDependencyList = new List(); - - /// - /// Defines if Project System supports Project Designer - /// - private bool supportsProjectDesigner; - - private bool showProjectInSolutionPage = true; - - private bool buildInProcess; - - /// - /// Field for determining whether sourcecontrol should be disabled. - /// - private bool disableScc; - - private string sccProjectName; - - private string sccLocalPath; - - private string sccAuxPath; - - private string sccProvider; - - /// - /// Flag for controling how many times we register with the Scc manager. - /// - private bool isRegisteredWithScc; - - /// - /// Flag for controling query edit should communicate with the scc manager. - /// - private bool disableQueryEdit; - - /// - /// Control if command with potential destructive behavior such as delete should - /// be enabled for nodes of this project. - /// - private bool canProjectDeleteItems; - - /// - /// Token processor used by the project sample. - /// - private TokenProcessor tokenProcessor; - - /// - /// Member to store output base relative path. Used by OutputBaseRelativePath property - /// - private string outputBaseRelativePath = "bin"; - - private IProjectEvents projectEventsProvider; - - /// - /// Used for flavoring to hold the XML fragments - /// - private XmlDocument xmlFragments; - - /// - /// Used to map types to CATID. This provide a generic way for us to do this - /// and make it simpler for a project to provide it's CATIDs for the different type of objects - /// for which it wants to support extensibility. This also enables us to have multiple - /// type mapping to the same CATID if we choose to. - /// - private Dictionary catidMapping = new Dictionary(); - - /// - /// The internal package implementation. - /// - private ProjectPackage package; - - // Has the object been disposed. - private bool isDisposed; - - #endregion - - #region abstract properties - /// - /// This Guid must match the Guid you registered under - /// HKLM\Software\Microsoft\VisualStudio\%version%\Projects. - /// Among other things, the Project framework uses this - /// guid to find your project and item templates. - /// - public abstract Guid ProjectGuid - { - get; - } - - /// - /// Returns a caption for VSHPROPID_TypeName. - /// - /// - public abstract string ProjectType - { - get; - } - #endregion - - #region virtual properties - /// - /// This is the project instance guid that is peristed in the project file - /// - [System.ComponentModel.BrowsableAttribute(false)] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID")] - public virtual Guid ProjectIDGuid - { - get - { - return this.projectIdGuid; - } - set - { - if (this.projectIdGuid != value) - { - this.projectIdGuid = value; - if (this.buildProject != null) - { - this.SetProjectProperty("ProjectGuid", this.projectIdGuid.ToString("B")); - } - } - } - } - #endregion - - #region properties - - #region overridden properties - public override int MenuCommandId - { - get - { - return VsMenus.IDM_VS_CTXT_PROJNODE; - } - } - - public override string Url - { - get - { - return this.GetMkDocument(); - } - } - - public override string Caption - { - get - { - // Default to file name - string caption = this.buildProject.FullPath; - if (String.IsNullOrEmpty(caption)) - { - if (this.buildProject.GetProperty(ProjectFileConstants.Name) != null) - { - caption = this.buildProject.GetProperty(ProjectFileConstants.Name).EvaluatedValue; - if (caption == null || caption.Length == 0) - { - caption = this.ItemNode.GetMetadata(ProjectFileConstants.Include); - } - } - } - else - { - caption = Path.GetFileNameWithoutExtension(caption); - } - - return caption; - } - } - - public override Guid ItemTypeGuid - { - get - { - return this.ProjectGuid; - } - } - - public override int ImageIndex - { - get - { - return (int)ProjectNode.ImageName.Application; - } - } - - - #endregion - - #region virtual properties - - public virtual string ErrorString - { - get - { - if (this.errorString == null) - { - this.errorString = SR.GetString(SR.Error, CultureInfo.CurrentUICulture); - } - - return this.errorString; - } - } - - public virtual string WarningString - { - get - { - if (this.warningString == null) - { - this.warningString = SR.GetString(SR.Warning, CultureInfo.CurrentUICulture); - } - - return this.warningString; - } - } - - /// - /// The target name that will be used for evaluating the project file (i.e., pseudo-builds). - /// This target is used to trigger a build with when the project system changes. - /// Example: The language projrcts are triggering a build with the Compile target whenever - /// the project system changes. - /// - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "ReEvaluate")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Re")] - protected internal virtual string ReEvaluateProjectFileTargetName - { - get - { - return null; - } - } - - /// - /// This is the object that will be returned by EnvDTE.Project.Object for this project - /// - protected internal virtual object ProjectObject - { - get - { - return null; - } - } - - /// - /// Override this property to specify when the project file is dirty. - /// - protected virtual bool IsProjectFileDirty - { - get - { - string document = this.GetMkDocument(); - - if (String.IsNullOrEmpty(document)) - { - return this.isDirty; - } - - return (this.isDirty || !File.Exists(document)); - } - } - - /// - /// True if the project uses the Project Designer Editor instead of the property page frame to edit project properties. - /// - protected virtual bool SupportsProjectDesigner - { - get - { - return this.supportsProjectDesigner; - } - set - { - this.supportsProjectDesigner = value; - } - - } - - protected virtual Guid ProjectDesignerEditor - { - get - { - return VSConstants.GUID_ProjectDesignerEditor; - } - } - - /// - /// Defines the flag that supports the VSHPROPID.ShowProjInSolutionPage - /// - protected virtual bool ShowProjectInSolutionPage - { - get - { - return this.showProjectInSolutionPage; - } - set - { - this.showProjectInSolutionPage = value; - } - } - - #endregion - - /// - /// Gets or sets the ability of a project filenode to have child nodes (sub items). - /// Example would be C#/VB forms having resx and designer files. - /// - protected internal bool CanFileNodesHaveChilds - { - get - { - return canFileNodesHaveChilds; - } - set - { - canFileNodesHaveChilds = value; - } - } - - /// - /// Get and set the Token processor. - /// - public TokenProcessor FileTemplateProcessor - { - get - { - if (tokenProcessor == null) - tokenProcessor = new TokenProcessor(); - return tokenProcessor; - } - set - { - tokenProcessor = value; - } - } - - /// - /// Gets a service provider object provided by the IDE hosting the project - /// - [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] - public IServiceProvider Site - { - get - { - return this.site; - } - } - - /// - /// Gets an ImageHandler for the project node. - /// - public ImageHandler ImageHandler - { - get - { - if (null == imageHandler) - { - imageHandler = new ImageHandler(typeof(ProjectNode).Assembly.GetManifestResourceStream("Microsoft.VisualStudio.Project.Resources.imagelis.bmp")); - } - return imageHandler; - } - } - - /// - /// This property returns the time of the last change made to this project. - /// It is not the time of the last change on the project file, but actually of - /// the in memory project settings. In other words, it is the last time that - /// SetProjectDirty was called. - /// - public DateTime LastModifiedTime - { - get - { - return this.lastModifiedTime; - } - } - - /// - /// Determines whether this project is a new project. - /// - public bool IsNewProject - { - get - { - return this.isNewProject; - } - } - - /// - /// Gets the path to the folder containing the project. - /// - public string ProjectFolder - { - get - { - return Path.GetDirectoryName(this.filename); - } - } - - /// - /// Gets or sets the project filename. - /// - public string ProjectFile - { - get - { - return Path.GetFileName(this.filename); - } - set - { - this.SetEditLabel(value); - } - } - - /// - /// Gets the Base Uniform Resource Identifier (URI). - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "URI")] - public Microsoft.VisualStudio.Shell.Url BaseURI - { - get - { - if (baseUri == null && this.buildProject != null) - { - string path = System.IO.Path.GetDirectoryName(this.buildProject.FullPath); - // Uri/Url behave differently when you have trailing slash and when you dont - if (!path.EndsWith("\\", StringComparison.Ordinal) && !path.EndsWith("/", StringComparison.Ordinal)) - path += "\\"; - baseUri = new Url(path); - } - - Debug.Assert(baseUri != null, "Base URL should not be null. Did you call BaseURI before loading the project?"); - return baseUri; - } - } - - /// - /// Gets whether or not the project is closed. - /// - public bool IsClosed - { - get - { - return this.isClosed; - } - } - - /// - /// Gets whether or not the project is being built. - /// - public bool BuildInProgress - { - get - { - return buildInProcess; - } - } - - /// - /// Gets or set the relative path to the folder containing the project ouput. - /// - public virtual string OutputBaseRelativePath - { - get - { - return this.outputBaseRelativePath; - } - set - { - if (Path.IsPathRooted(value)) - { - throw new ArgumentException("Path must not be rooted."); - } - - this.outputBaseRelativePath = value; - } - } - - public FrameworkName TargetFrameworkMoniker - { - get - { - if (this.options == null) - { - GetProjectOptions(); - } - if (this.options != null) - { - return this.options.TargetFrameworkMoniker ?? DefaultTargetFrameworkMoniker; - } - else - { - return DefaultTargetFrameworkMoniker; - } - } - - set - { - if (this.options == null) - { - GetProjectOptions(); - } - - if (value == null) - { - value = DefaultTargetFrameworkMoniker; - } - - if (this.options.TargetFrameworkMoniker != value) - { - this.OnTargetFrameworkMonikerChanged(this.options, this.options.TargetFrameworkMoniker, value); - } - } - } - - /// - /// Version of this node as an IVsHierarchy that can be safely passed to native code from a background thread. - /// - public IVsHierarchy InteropSafeIVsHierarchy - { - get; - protected set; - } - - /// - /// Version of this node as an IVsUIHierarchy that can be safely passed to native code from a background thread. - /// - public IVsUIHierarchy InteropSafeIVsUIHierarchy - { - get; - protected set; - } - - /// - /// Version of this node as an IVsProject3 that can be safely passed to native code from a background thread. - /// - public IVsProject3 InteropSafeIVsProject3 - { - get; - protected set; - } - - /// - /// Version of this node as an IVsSccProject2 that can be safely passed to native code from a background thread. - /// - public IVsSccProject2 InteropSafeIVsSccProject2 - { - get; - protected set; - } - - /// - /// Version of this node as an IVsUIHierWinClipboardHelperEvents that can be safely passed to native code from a background thread. - /// - public IVsUIHierWinClipboardHelperEvents InteropSafeIVsUIHierWinClipboardHelperEvents - { - get; - protected set; - } - - public IVsComponentUser InteropSafeIVsComponentUser - { - get; - protected set; - } - - /// - /// Gets or sets the flag whether query edit should communicate with the scc manager. - /// - protected bool DisableQueryEdit - { - get - { - return this.disableQueryEdit; - } - set - { - this.disableQueryEdit = value; - } - } - - /// - /// Gets a collection of integer ids that maps to project item instances - /// - internal EventSinkCollection ItemIdMap - { - get - { - return this.itemIdMap; - } - } - - /// - /// Get the helper object that track document changes. - /// - internal TrackDocumentsHelper Tracker - { - get - { - return this.tracker; - } - } - - /// - /// Gets or sets the build logger. - /// - protected Microsoft.Build.Utilities.Logger BuildLogger - { - get - { - return this.buildLogger; - } - set - { - this.buildLogger = value; - this.useProvidedLogger = true; - } - } - - /// - /// Gets the taskprovider. - /// - protected TaskProvider TaskProvider - { - get - { - return this.taskProvider; - } - } - - /// - /// Gets the project file name. - /// - protected string FileName - { - get - { - return this.filename; - } - } - - protected bool IsIdeInCommandLineMode - { - get - { - bool cmdline = false; - var shell = this.site.GetService(typeof(SVsShell)) as IVsShell; - if (shell != null) - { - object obj; - Marshal.ThrowExceptionForHR(shell.GetProperty((int)__VSSPROPID.VSSPROPID_IsInCommandLineMode, out obj)); - cmdline = (bool)obj; - } - return cmdline; - } - } - - /// - /// Gets the configuration provider. - /// - protected ConfigProvider ConfigProvider - { - get - { - if (this.configProvider == null) - { - this.configProvider = CreateConfigProvider(); - } - - return this.configProvider; - } - } - - /// - /// Gets or sets whether or not source code control is disabled for this project. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - protected bool IsSccDisabled - { - get - { - return this.disableScc; - } - set - { - this.disableScc = value; - } - } - - /// - /// Gets or set whether items can be deleted for this project. - /// Enabling this feature can have the potential destructive behavior such as deleting files from disk. - /// - protected internal bool CanProjectDeleteItems - { - get - { - return canProjectDeleteItems; - } - set - { - canProjectDeleteItems = value; - } - } - - /// - /// Determines whether the project was fully opened. This is set when the OnAfterOpenProject has triggered. - /// - protected internal bool HasProjectOpened - { - get - { - return this.projectOpened; - } - } - - /// - /// Gets or sets event triggering flags. - /// - internal EventTriggering EventTriggeringFlag - { - get - { - return this.eventTriggeringFlag; - } - set - { - this.eventTriggeringFlag = value; - } - } - - /// - /// Defines the build project that has loaded the project file. - /// - protected internal MSBuild.Project BuildProject - { - get - { - return this.buildProject; - } - set - { - SetBuildProject(value); - } - } - - /// - /// Gets the current config. - /// - /// The current config. - protected internal Microsoft.Build.Execution.ProjectInstance CurrentConfig - { - get { return this.currentConfig; } - } - - /// - /// Defines the build engine that is used to build the project file. - /// - internal MSBuild.ProjectCollection BuildEngine - { - get - { - return this.buildEngine; - } - set - { - this.buildEngine = value; - } - } - - /// - /// The internal package implementation. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal ProjectPackage Package - { - get - { - return this.package; - } - set - { - this.package = value; - } - } - - // !EFW - /// - /// This returns a flag indicating whether or not all files are showing - /// - public bool ShowingAllFiles { get; private set; } - - #endregion - - #region ctor - - protected ProjectNode() - { - this.Initialize(); - } - #endregion - - #region overridden methods - protected override NodeProperties CreatePropertiesObject() - { - return new ProjectNodeProperties(this); - } - - /// - /// Sets the properties for the project node. - /// - /// Identifier of the hierarchy property. For a list of propid values, - /// The value to set. - /// A success or failure value. - public override int SetProperty(int propid, object value) - { - __VSHPROPID id = (__VSHPROPID)propid; - - switch (id) - { - case __VSHPROPID.VSHPROPID_ShowProjInSolutionPage: - this.ShowProjectInSolutionPage = (bool)value; - return VSConstants.S_OK; - } - - return base.SetProperty(propid, value); - } - - /// - /// Renames the project node. - /// - /// The new name - /// A success or failure value. - public override int SetEditLabel(string label) - { - // Validate the filename. - if (String.IsNullOrEmpty(label)) - { - throw new InvalidOperationException(SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture)); - } - else if (this.ProjectFolder.Length + label.Length + 1 > NativeMethods.MAX_PATH) - { - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.PathTooLong, CultureInfo.CurrentUICulture), label)); - } - else if (Utilities.IsFileNameInvalid(label)) - { - throw new InvalidOperationException(SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture)); - } - - string fileName = Path.GetFileNameWithoutExtension(label); - - // if there is no filename or it starts with a leading dot issue an error message and quit. - if (String.IsNullOrEmpty(fileName) || fileName[0] == '.') - { - throw new InvalidOperationException(SR.GetString(SR.FileNameCannotContainALeadingPeriod, CultureInfo.CurrentUICulture)); - } - - // Nothing to do if the name is the same - string oldFileName = Path.GetFileNameWithoutExtension(this.Url); - if (String.Compare(oldFileName, label, StringComparison.Ordinal) == 0) - { - return VSConstants.S_FALSE; - } - - // Now check whether the original file is still there. It could have been renamed. - if (!File.Exists(this.Url)) - { - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.FileOrFolderCannotBeFound, CultureInfo.CurrentUICulture), this.ProjectFile)); - } - - // Get the full file name and then rename the project file. - string newFile = Path.Combine(this.ProjectFolder, label); - string extension = Path.GetExtension(this.Url); - - // Make sure it has the correct extension - if (String.Compare(Path.GetExtension(newFile), extension, StringComparison.OrdinalIgnoreCase) != 0) - { - newFile += extension; - } - - this.RenameProjectFile(newFile); - return VSConstants.S_OK; - } - - /// - /// Gets the automation object for the project node. - /// - /// An instance of an EnvDTE.Project implementation object representing the automation object for the project. - public override object GetAutomationObject() - { - return new Automation.OAProject(this); - } - - /// - /// Closes the project node. - /// - /// A success or failure value. - public override int Close() - { - int hr = VSConstants.S_OK; - try - { - // Walk the tree and close all nodes. - // This has to be done before the project closes, since we want still state available for the ProjectMgr on the nodes - // when nodes are closing. - try - { - CloseAllNodes(this); - } - finally - { - this.Dispose(true); - } - } - catch (COMException e) - { - hr = e.ErrorCode; - } - finally - { - ErrorHandler.ThrowOnFailure(base.Close()); - } - - this.isClosed = true; - - return hr; - } - - /// - /// Sets the service provider from which to access the services. - /// - /// An instance to an Microsoft.VisualStudio.OLE.Interop object - /// A success or failure value. - public override int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site) - { - CCITracing.TraceCall(); - this.site = new ServiceProvider(site); - ServiceProvider = this.site; - - if (taskProvider != null) - { - taskProvider.Dispose(); - } - taskProvider = new TaskProvider(this.site); - - return VSConstants.S_OK; - } - - /// - /// Gets the properties of the project node. - /// - /// The __VSHPROPID of the property. - /// A property dependent value. See: for details. - public override object GetProperty(int propId) - { - switch ((__VSHPROPID)propId) - { - case __VSHPROPID.VSHPROPID_ConfigurationProvider: - return this.ConfigProvider; - - case __VSHPROPID.VSHPROPID_ProjectName: - return this.Caption; - - case __VSHPROPID.VSHPROPID_ProjectDir: - return this.ProjectFolder; - - case __VSHPROPID.VSHPROPID_TypeName: - return this.ProjectType; - - case __VSHPROPID.VSHPROPID_ShowProjInSolutionPage: - return this.ShowProjectInSolutionPage; - - case __VSHPROPID.VSHPROPID_ExpandByDefault: - return true; - - // Use the same icon as if the folder was closed - case __VSHPROPID.VSHPROPID_OpenFolderIconIndex: - return GetProperty((int)__VSHPROPID.VSHPROPID_IconIndex); - } - - switch ((__VSHPROPID2)propId) - { - case __VSHPROPID2.VSHPROPID_SupportsProjectDesigner: - return this.SupportsProjectDesigner; - - case __VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList: - return Utilities.CreateSemicolonDelimitedListOfStringFromGuids(this.GetConfigurationIndependentPropertyPages()); - - case __VSHPROPID2.VSHPROPID_CfgPropertyPagesCLSIDList: - return Utilities.CreateSemicolonDelimitedListOfStringFromGuids(this.GetConfigurationDependentPropertyPages()); - - case __VSHPROPID2.VSHPROPID_PriorityPropertyPagesCLSIDList: - return Utilities.CreateSemicolonDelimitedListOfStringFromGuids(this.GetPriorityProjectDesignerPages()); - - case __VSHPROPID2.VSHPROPID_Container: - return true; - default: - break; - } - - return base.GetProperty(propId); - } - - /// - /// Gets the GUID value of the node. - /// - /// A __VSHPROPID or __VSHPROPID2 value of the guid property - /// The guid to return for the property. - /// A success or failure value. - public override int GetGuidProperty(int propid, out Guid guid) - { - guid = Guid.Empty; - if ((__VSHPROPID)propid == __VSHPROPID.VSHPROPID_ProjectIDGuid) - { - guid = this.ProjectIDGuid; - } - else if (propid == (int)__VSHPROPID.VSHPROPID_CmdUIGuid) - { - guid = this.ProjectGuid; - } - else if ((__VSHPROPID2)propid == __VSHPROPID2.VSHPROPID_ProjectDesignerEditor && this.SupportsProjectDesigner) - { - guid = this.ProjectDesignerEditor; - } - else - { - base.GetGuidProperty(propid, out guid); - } - - if (guid.CompareTo(Guid.Empty) == 0) - { - return VSConstants.DISP_E_MEMBERNOTFOUND; - } - - return VSConstants.S_OK; - } - - /// - /// Sets Guid properties for the project node. - /// - /// A __VSHPROPID or __VSHPROPID2 value of the guid property - /// The guid value to set. - /// A success or failure value. - public override int SetGuidProperty(int propid, ref Guid guid) - { - switch ((__VSHPROPID)propid) - { - case __VSHPROPID.VSHPROPID_ProjectIDGuid: - this.ProjectIDGuid = guid; - return VSConstants.S_OK; - } - CCITracing.TraceCall(String.Format(CultureInfo.CurrentCulture, "Property {0} not found", propid)); - return VSConstants.DISP_E_MEMBERNOTFOUND; - } - - /// - /// Removes items from the hierarchy. - /// - /// Project overwrites this. - public override void Remove(bool removeFromStorage) - { - // the project will not be deleted from disk, just removed - if (removeFromStorage) - { - return; - } - - // Remove the entire project from the solution - IVsSolution solution = this.Site.GetService(typeof(SVsSolution)) as IVsSolution; - uint iOption = 1; // SLNSAVEOPT_PromptSave - ErrorHandler.ThrowOnFailure(solution.CloseSolutionElement(iOption, this.InteropSafeIVsHierarchy, 0)); - } - - /// - /// Gets the moniker for the project node. That is the full path of the project file. - /// - /// The moniker for the project file. - public override string GetMkDocument() - { - Debug.Assert(!String.IsNullOrEmpty(this.filename)); - Debug.Assert(this.BaseURI != null && !String.IsNullOrEmpty(this.BaseURI.AbsoluteUrl)); - return Path.Combine(this.BaseURI.AbsoluteUrl, this.filename); - } - - /// - /// Disposes the project node object. - /// - /// Flag determining ehether it was deterministic or non deterministic clean up. - 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 (this.taskProvider != null) - { - taskProvider.Tasks.Clear(); - this.taskProvider.Dispose(); - this.taskProvider = null; - } - - if (this.buildLogger != null) - { - this.buildLogger.Shutdown(); - buildLogger = null; - } - - if (this.site != null) - { - this.site.Dispose(); - } - } - finally - { - this.buildEngine = null; - } - } - } - - if (this.buildProject != null) - { - this.buildProject.ProjectCollection.UnloadProject(this.buildProject); - this.buildProject.ProjectCollection.UnloadProject(this.buildProject.Xml); - this.buildProject = null; - } - - if (null != imageHandler) - { - imageHandler.Close(); - imageHandler = null; - } - } - finally - { - base.Dispose(disposing); - this.isDisposed = true; - } - } - - /// - /// Handles command status on the project node. If a command cannot be handled then the base should be called. - /// - /// A unique identifier of the command group. The pguidCmdGroup parameter can be NULL to specify the standard group. - /// The command to query status for. - /// Pointer to an OLECMDTEXT structure in which to return the name and/or status information of a single command. Can be NULL to indicate that the caller does not require this information. - /// An out parameter specifying the QueryStatusResult of the command. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result) - { - if (cmdGroup == VsMenus.guidStandardCommandSet97) - { - switch ((VsCommands)cmd) - { - case VsCommands.BuildSln: // !EFW - Don't allow if building already - result |= QueryStatusResult.SUPPORTED; - - if(!this.buildInProcess) - result |= QueryStatusResult.ENABLED; - else - result |= QueryStatusResult.INVISIBLE; - - return VSConstants.S_OK; - - case VsCommands.Copy: - case VsCommands.Paste: - case VsCommands.Cut: - case VsCommands.Rename: - case VsCommands.Exit: - case VsCommands.ProjectSettings: - case VsCommands.UnloadProject: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - - case VsCommands.ViewForm: - if (this.HasDesigner) - { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - break; - - case VsCommands.CancelBuild: - result |= QueryStatusResult.SUPPORTED; - if (this.buildInProcess) - result |= QueryStatusResult.ENABLED; - else - result |= QueryStatusResult.INVISIBLE; - return VSConstants.S_OK; - - case VsCommands.NewFolder: - case VsCommands.AddNewItem: - case VsCommands.AddExistingItem: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - - case VsCommands.SetStartupProject: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } - else if (cmdGroup == VsMenus.guidStandardCommandSet2K) - { - switch ((VsCommands2K)cmd) - { - case VsCommands2K.ADDREFERENCE: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - - case VsCommands2K.EXCLUDEFROMPROJECT: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; - return VSConstants.S_OK; - - case ExploreFolderInWindowsCommand: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } - else - { - return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; - } - - return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); - } - - /// - /// Handles command execution. - /// - /// Unique identifier of the command group - /// The command to be executed. - /// Values describe how the object should execute the command. - /// Pointer to a VARIANTARG structure containing input arguments. Can be NULL - /// VARIANTARG structure to receive command output. Can be NULL. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) - { - if (cmdGroup == VsMenus.guidStandardCommandSet97) - { - switch ((VsCommands)cmd) - { - - case VsCommands.UnloadProject: - return this.UnloadProject(); - case VsCommands.CleanSel: - case VsCommands.CleanCtx: - return this.CleanProject(); - } - } - else if (cmdGroup == VsMenus.guidStandardCommandSet2K) - { - switch ((VsCommands2K)cmd) - { - case VsCommands2K.ADDREFERENCE: - return this.AddProjectReference(); - - case VsCommands2K.ADDWEBREFERENCE: - case VsCommands2K.ADDWEBREFERENCECTX: - return this.AddWebReference(); - - case ExploreFolderInWindowsCommand: - string explorerPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe"); - System.Diagnostics.Process.Start(explorerPath, this.ProjectFolder); - return VSConstants.S_OK; - } - } - - return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); - } - - /// - /// Get the boolean value for the deletion of a project item - /// - /// A flag that specifies the type of delete operation (delete from storage or remove from project) - /// true if item can be deleted from project - protected override bool CanDeleteItem(__VSDELETEITEMOPERATION deleteOperation) - { - if (deleteOperation == __VSDELETEITEMOPERATION.DELITEMOP_RemoveFromProject) - { - return true; - } - return false; - } - - /// - /// Returns a specific Document manager to handle opening and closing of the Project(Application) Designer if projectdesigner is supported. - /// - /// Document manager object - protected internal override DocumentManager GetDocumentManager() - { - if (this.SupportsProjectDesigner) - { - return new ProjectDesignerDocumentManager(this); - } - return null; - } - - #endregion - - #region virtual methods - - /// - /// Executes a wizard. - /// - /// The node to which the wizard should add item(s). - /// The name of the file that the user typed in. - /// The name of the wizard to run. - /// The owner of the dialog box. - /// A VSADDRESULT enum value describing success or failure. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily"), SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dlg")] - public virtual VSADDRESULT RunWizard(HierarchyNode parentNode, string itemName, string wizardToRun, IntPtr dlgOwner) - { - Debug.Assert(!String.IsNullOrEmpty(itemName), "The Add item dialog was passing in a null or empty item to be added to the hierrachy."); - Debug.Assert(!String.IsNullOrEmpty(this.ProjectFolder), "The Project Folder is not specified for this project."); - - if (parentNode == null) - { - throw new ArgumentNullException("parentNode"); - } - - if (String.IsNullOrEmpty(itemName)) - { - throw new ArgumentNullException("itemName"); - } - - // We just validate for length, since we assume other validation has been performed by the dlgOwner. - if (this.ProjectFolder.Length + itemName.Length + 1 > NativeMethods.MAX_PATH) - { - string errorMessage = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.PathTooLong, CultureInfo.CurrentUICulture), itemName); - if (!Utilities.IsInAutomationFunction(this.Site)) - { - string title = null; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(this.Site, title, errorMessage, icon, buttons, defaultButton); - return VSADDRESULT.ADDRESULT_Failure; - } - else - { - throw new InvalidOperationException(errorMessage); - } - } - - - // Build up the ContextParams safearray - // [0] = Wizard type guid (bstr) - // [1] = Project name (bstr) - // [2] = ProjectItems collection (bstr) - // [3] = Local Directory (bstr) - // [4] = Filename the user typed (bstr) - // [5] = Product install Directory (bstr) - // [6] = Run silent (bool) - - object[] contextParams = new object[7]; - contextParams[0] = EnvDTE.Constants.vsWizardAddItem; - contextParams[1] = this.Caption; - object automationObject = parentNode.GetAutomationObject(); - if (automationObject is EnvDTE.Project) - { - EnvDTE.Project project = (EnvDTE.Project)automationObject; - contextParams[2] = project.ProjectItems; - } - else - { - // This would normally be a folder unless it is an item with subitems - EnvDTE.ProjectItem item = (EnvDTE.ProjectItem)automationObject; - contextParams[2] = item.ProjectItems; - } - - contextParams[3] = this.ProjectFolder; - - contextParams[4] = itemName; - - object objInstallationDir = null; - IVsShell shell = (IVsShell)this.GetService(typeof(IVsShell)); - ErrorHandler.ThrowOnFailure(shell.GetProperty((int)__VSSPROPID.VSSPROPID_InstallDirectory, out objInstallationDir)); - string installDir = (string)objInstallationDir; - - // append a '\' to the install dir to mimic what the shell does (though it doesn't add one to destination dir) - if (!installDir.EndsWith("\\", StringComparison.Ordinal)) - { - installDir += "\\"; - } - - contextParams[5] = installDir; - - contextParams[6] = true; - - IVsExtensibility3 ivsExtensibility = this.GetService(typeof(IVsExtensibility)) as IVsExtensibility3; - Debug.Assert(ivsExtensibility != null, "Failed to get IVsExtensibility3 service"); - if (ivsExtensibility == null) - { - return VSADDRESULT.ADDRESULT_Failure; - } - - // Determine if we have the trust to run this wizard. - IVsDetermineWizardTrust wizardTrust = this.GetService(typeof(SVsDetermineWizardTrust)) as IVsDetermineWizardTrust; - if (wizardTrust != null) - { - Guid guidProjectAdding = Guid.Empty; - ErrorHandler.ThrowOnFailure(wizardTrust.OnWizardInitiated(wizardToRun, ref guidProjectAdding)); - } - - int wizResultAsInt; - try - { - Array contextParamsAsArray = contextParams; - - int result = ivsExtensibility.RunWizardFile(wizardToRun, (int)dlgOwner, ref contextParamsAsArray, out wizResultAsInt); - - if (!ErrorHandler.Succeeded(result) && result != VSConstants.OLE_E_PROMPTSAVECANCELLED) - { - ErrorHandler.ThrowOnFailure(result); - } - } - finally - { - if (wizardTrust != null) - { - ErrorHandler.ThrowOnFailure(wizardTrust.OnWizardCompleted()); - } - } - - EnvDTE.wizardResult wizardResult = (EnvDTE.wizardResult)wizResultAsInt; - - switch (wizardResult) - { - default: - return VSADDRESULT.ADDRESULT_Cancel; - case wizardResult.wizardResultSuccess: - return VSADDRESULT.ADDRESULT_Success; - case wizardResult.wizardResultFailure: - return VSADDRESULT.ADDRESULT_Failure; - } - } - - /// - /// Override this method if you want to modify the behavior of the Add Reference dialog - /// By example you could change which pages are visible and which is visible by default. - /// - /// - public virtual int AddProjectReference() - { - CCITracing.TraceCall(); - - IVsComponentSelectorDlg4 componentDialog; - string strBrowseLocations = Path.GetDirectoryName(this.BaseURI.Uri.LocalPath); - var tabInitList = new List() - { - new VSCOMPONENTSELECTORTABINIT { - guidTab = VSConstants.GUID_COMPlusPage, - varTabInitInfo = GetComponentPickerDirectories(), - }, - new VSCOMPONENTSELECTORTABINIT { - guidTab = VSConstants.GUID_COMClassicPage, - }, - new VSCOMPONENTSELECTORTABINIT { - // Tell the Add Reference dialog to call hierarchies GetProperty with the following - // propID to enablefiltering out ourself from the Project to Project reference - varTabInitInfo = (int)__VSHPROPID.VSHPROPID_ShowProjInSolutionPage, - guidTab = VSConstants.GUID_SolutionPage, - }, - // Add the Browse for file page - new VSCOMPONENTSELECTORTABINIT { - varTabInitInfo = 0, - guidTab = VSConstants.GUID_BrowseFilePage, - }, - new VSCOMPONENTSELECTORTABINIT { - guidTab = GUID_MruPage, - }, - }; - tabInitList.ForEach(tab => tab.dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT))); - - componentDialog = this.GetService(typeof(IVsComponentSelectorDlg)) as IVsComponentSelectorDlg4; - try - { - // call the container to open the add reference dialog. - if (componentDialog != null) - { - // Let the project know not to show itself in the Add Project Reference Dialog page - this.ShowProjectInSolutionPage = false; - // call the container to open the add reference dialog. - string browseFilters = "Component Files (*.exe;*.dll)\0*.exe;*.dll\0"; - ErrorHandler.ThrowOnFailure(componentDialog.ComponentSelectorDlg5( - (System.UInt32)(__VSCOMPSELFLAGS.VSCOMSEL_MultiSelectMode | __VSCOMPSELFLAGS.VSCOMSEL_IgnoreMachineName), - this.InteropSafeIVsComponentUser, - 0, - null, - SR.GetString(SR.AddReferenceDialogTitle, CultureInfo.CurrentUICulture), // Title - "VS.AddReference", // Help topic - addComponentDialogSizeX, - addComponentDialogSizeY, - (uint)tabInitList.Count, - tabInitList.ToArray(), - ref addComponentLastActiveTab, - browseFilters, - ref strBrowseLocations, - this.TargetFrameworkMoniker.FullName)); - } - } - catch (COMException e) - { - Trace.WriteLine("Exception : " + e.Message); - return e.ErrorCode; - } - finally - { - // Let the project know it can show itself in the Add Project Reference Dialog page - this.ShowProjectInSolutionPage = true; - } - return VSConstants.S_OK; - } - - /// - /// Returns the Compiler associated to the project - /// - /// Null - public virtual ICodeCompiler GetCompiler() - { - - return null; - } - - /// - /// Override this method if you have your own project specific - /// subclass of ProjectOptions - /// - /// This method returns a new instance of the ProjectOptions base class. - public virtual ProjectOptions CreateProjectOptions() - { - return new ProjectOptions(); - } - - /// - /// Loads a project file. Called from the factory CreateProject to load the project. - /// - /// File name of the project that will be created. - /// Location where the project will be created. - /// If applicable, the name of the template to use when cloning a new project. - /// Set of flag values taken from the VSCREATEPROJFLAGS enumeration. - /// Identifier of the interface that the caller wants returned. - /// An out parameter specifying if the project creation was canceled - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "iid")] - public virtual void Load(string fileName, string location, string name, uint flags, ref Guid iidProject, out int canceled) - { - try - { - this.disableQueryEdit = true; - - // set up internal members and icons - canceled = 0; - - this.ProjectMgr = this; - this.isNewProject = false; - - if ((flags & (uint)__VSCREATEPROJFLAGS.CPF_CLONEFILE) == (uint)__VSCREATEPROJFLAGS.CPF_CLONEFILE) - { - // we need to generate a new guid for the project - this.projectIdGuid = Guid.NewGuid(); - } - else - { - this.SetProjectGuidFromProjectFile(); - } - - // This is almost a No op if the engine has already been instantiated in the factory. - this.buildEngine = Utilities.InitializeMsBuildEngine(this.buildEngine, this.Site); - - // based on the passed in flags, this either reloads/loads a project, or tries to create a new one - // now we create a new project... we do that by loading the template and then saving under a new name - // we also need to copy all the associated files with it. - if ((flags & (uint)__VSCREATEPROJFLAGS.CPF_CLONEFILE) == (uint)__VSCREATEPROJFLAGS.CPF_CLONEFILE) - { - Debug.Assert(!String.IsNullOrEmpty(fileName) && File.Exists(fileName), "Invalid filename passed to load the project. A valid filename is expected"); - - this.isNewProject = true; - - // This should be a very fast operation if the build project is already initialized by the Factory. - SetBuildProject(Utilities.ReinitializeMsBuildProject(this.buildEngine, fileName, this.buildProject)); - - // Compute the file name - // We try to solve two problems here. When input comes from a wizard in case of zipped based projects - // the parameters are different. - // In that case the filename has the new filename in a temporay path. - - // First get the extension from the template. - // Then get the filename from the name. - // Then create the new full path of the project. - string extension = Path.GetExtension(fileName); - - string tempName = String.Empty; - - // We have to be sure that we are not going to loose data here. If the project name is a.b.c then for a project that was based on a zipped template(the wizard calls us) GetFileNameWithoutExtension will suppress "c". - // We are going to check if the parameter "name" is extension based and the extension is the same as the one from the "filename" parameter. - string tempExtension = Path.GetExtension(name); - if (!String.IsNullOrEmpty(tempExtension)) - { - bool isSameExtension = (String.Compare(tempExtension, extension, StringComparison.OrdinalIgnoreCase) == 0); - - if (isSameExtension) - { - tempName = Path.GetFileNameWithoutExtension(name); - } - // If the tempExtension is not the same as the extension that the project name comes from then assume that the project name is a dotted name. - else - { - tempName = Path.GetFileName(name); - } - } - else - { - tempName = Path.GetFileName(name); - } - - Debug.Assert(!String.IsNullOrEmpty(tempName), "Could not compute project name"); - string tempProjectFileName = tempName + extension; - this.filename = Path.Combine(location, tempProjectFileName); - - // Initialize the common project properties. - this.InitializeProjectProperties(); - - ErrorHandler.ThrowOnFailure(this.Save(this.filename, 1, 0)); - - // now we do have the project file saved. we need to create embedded files. - foreach (MSBuild.ProjectItem item in this.BuildProject.Items) - { - // Ignore the item if it is a reference or folder - if (this.FilterItemTypeToBeAddedToHierarchy(item.ItemType)) - { - continue; - } - - // MSBuilds tasks/targets can create items (such as object files), - // such items are not part of the project per se, and should not be displayed - // so ignore those items. - if (!this.IsItemTypeFileType(item.ItemType)) - { - continue; - } - - string strRelFilePath = item.EvaluatedInclude; - string basePath = Path.GetDirectoryName(fileName); - string strPathToFile; - string newFileName; - // taking the base name from the project template + the relative pathname, - // and you get the filename - strPathToFile = Path.Combine(basePath, strRelFilePath); - // the new path should be the base dir of the new project (location) + the rel path of the file - newFileName = Path.Combine(location, strRelFilePath); - // now the copy file - AddFileFromTemplate(strPathToFile, newFileName); - } - } - else - { - this.filename = fileName; - } - - // now reload to fix up references - this.Reload(); - } - finally - { - this.disableQueryEdit = false; - } - } - - /// - /// Called to add a file to the project from a template. - /// Override to do it yourself if you want to customize the file - /// - /// Full path of template file - /// Full path of file once added to the project - public virtual void AddFileFromTemplate(string source, string target) - { - if (String.IsNullOrEmpty(source)) - { - throw new ArgumentNullException("source"); - } - if (String.IsNullOrEmpty(target)) - { - throw new ArgumentNullException("target"); - } - - try - { - string directory = Path.GetDirectoryName(target); - if (!String.IsNullOrEmpty(directory) && !Directory.Exists(directory)) - { - Directory.CreateDirectory(directory); - } - - FileInfo fiOrg = new FileInfo(source); - FileInfo fiNew = fiOrg.CopyTo(target, true); - - fiNew.Attributes = FileAttributes.Normal; // remove any read only attributes. - } - catch (IOException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (UnauthorizedAccessException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (ArgumentException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (NotSupportedException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - } - - /// - /// Called when the project opens an editor window for the given file - /// - public virtual void OnOpenItem(string fullPathToSourceFile) - { - } - - /// - /// This add methos adds the "key" item to the hierarchy, potentially adding other subitems in the process - /// This method may recurse if the parent is an other subitem - /// - /// - /// List of subitems not yet added to the hierarchy - /// Key to retrieve the target item from the subitems list - /// Newly added node - /// If the parent node was found we add the dependent item to it otherwise we add the item ignoring the "DependentUpon" metatdata - protected virtual HierarchyNode AddDependentFileNode(IDictionary subitems, string key) - { - if (subitems == null) - { - throw new ArgumentNullException("subitems"); - } - - MSBuild.ProjectItem item = subitems[key]; - subitems.Remove(key); - - HierarchyNode newNode; - HierarchyNode parent = null; - - string dependentOf = item.GetMetadataValue(ProjectFileConstants.DependentUpon); - Debug.Assert(String.Compare(dependentOf, key, StringComparison.OrdinalIgnoreCase) != 0, "File dependent upon itself is not valid. Ignoring the DependentUpon metadata"); - if (subitems.ContainsKey(dependentOf)) - { - // The parent item is an other subitem, so recurse into this method to add the parent first - parent = AddDependentFileNode(subitems, dependentOf); - } - else - { - // See if the parent node already exist in the hierarchy - uint parentItemID; - string path = Path.Combine(this.ProjectFolder, dependentOf); - ErrorHandler.ThrowOnFailure(this.ParseCanonicalName(path, out parentItemID)); - if (parentItemID != (uint)VSConstants.VSITEMID.Nil) - parent = this.NodeFromItemId(parentItemID); - Debug.Assert(parent != null, "File dependent upon a non existing item or circular dependency. Ignoring the DependentUpon metadata"); - } - - // If the parent node was found we add the dependent item to it otherwise we add the item ignoring the "DependentUpon" metatdata - if (parent != null) - newNode = this.AddDependentFileNodeToNode(item, parent); - else - newNode = this.AddIndependentFileNode(item); - - return newNode; - } - - /// - /// This is called from the main thread before the background build starts. - /// cleanBuild is not part of the vsopts, but passed down as the callpath is differently - /// PrepareBuild mainly creates directories and cleans house if cleanBuild is true - /// - /// - /// - public virtual void PrepareBuild(string config, bool cleanBuild) - { - if (this.buildIsPrepared && !cleanBuild) return; - - ProjectOptions options = this.GetProjectOptions(config); - string outputPath = Path.GetDirectoryName(options.OutputAssembly); - - if (cleanBuild && this.currentConfig.Targets.ContainsKey(MsBuildTarget.Clean)) - { - this.InvokeMsBuild(MsBuildTarget.Clean); - } - - PackageUtilities.EnsureOutputPath(outputPath); - if (!String.IsNullOrEmpty(options.XmlDocFileName)) - { - PackageUtilities.EnsureOutputPath(Path.GetDirectoryName(options.XmlDocFileName)); - } - - this.buildIsPrepared = true; - } - - /// - /// Do the build by invoking msbuild - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "vsopts")] - public virtual MSBuildResult Build(uint vsopts, string config, IVsOutputWindowPane output, string target) - { - lock (ProjectNode.BuildLock) - { - bool engineLogOnlyCritical = this.BuildPrelude(output); - - MSBuildResult result = MSBuildResult.Failed; - - try - { - this.SetBuildConfigurationProperties(config); - - result = this.InvokeMsBuild(target); - } - finally - { - // Unless someone specifically request to use an output window pane, we should not output to it - if (null != output) - { - this.SetOutputLogger(null); - BuildEngine.OnlyLogCriticalEvents = engineLogOnlyCritical; - } - } - - return result; - } - } - - - /// - /// Do the build by invoking msbuild - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "vsopts")] - internal virtual void BuildAsync(uint vsopts, string config, IVsOutputWindowPane output, string target, Action uiThreadCallback) - { - this.BuildPrelude(output); - this.SetBuildConfigurationProperties(config); - this.DoMSBuildSubmission(BuildKind.Async, target, uiThreadCallback); - } - - /// - /// Return the value of a project property - /// - /// Name of the property to get - /// True to avoid using the cache - /// null if property does not exist, otherwise value of the property - public virtual string GetProjectProperty(string propertyName, bool resetCache) - { - MSBuildExecution.ProjectPropertyInstance property = GetMsBuildProperty(propertyName, resetCache); - if (property == null) - return null; - - return property.EvaluatedValue; - } - - /// - /// Set value of project property - /// - /// Name of property - /// Value of property - public virtual void SetProjectProperty(string propertyName, string propertyValue) - { - if (propertyName == null) - throw new ArgumentNullException("propertyName", "Cannot set a null project property"); - - string oldValue = null; - ProjectPropertyInstance oldProp = GetMsBuildProperty(propertyName, true); - if (oldProp != null) - oldValue = oldProp.EvaluatedValue; - if (propertyValue == null) - { - // if property already null, do nothing - if (oldValue == null) - return; - // otherwise, set it to empty - propertyValue = String.Empty; - } - - // Only do the work if this is different to what we had before - if (String.Compare(oldValue, propertyValue, StringComparison.Ordinal) != 0) - { - // Check out the project file. - if (!this.ProjectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - this.buildProject.SetProperty(propertyName, propertyValue); - RaiseProjectPropertyChanged(propertyName, oldValue, propertyValue); - - // property cache will need to be updated - this.currentConfig = null; - this.SetProjectFileDirty(true); - } - return; - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] - public virtual ProjectOptions GetProjectOptions(string config = null) - { - if (string.IsNullOrEmpty(config)) - { - EnvDTE.Project automationObject = this.GetAutomationObject() as EnvDTE.Project; - try - { - config = Utilities.GetActiveConfigurationName(automationObject); - } - catch (InvalidOperationException) - { - // Can't figure out the active configuration. Perhaps during solution load, or in a unit test. - } - catch (COMException) - { - // We may be in solution load and don't have an active config yet. - } - } - - // Even though the options are the same, when this config was originally set, it may have been before - // the project system was ready to set up its configuration, so go ahead and call through to SetConfiguration - // anyway -- it should do effectively nothing if the config is the same and all the initialization has - // already occurred. - if (this.options != null && String.Equals(this.options.Config, config, StringComparison.OrdinalIgnoreCase)) - { - if (config != null) - { - // Fancy dance with the options required because SetConfiguration nulls out this.options - // even if the configuration itself has not changed; whereas we're only calling SetConfiguration - // for purposes of initializing some other fields here; since we know the config is the same, it - // should be perfectly safe to keep the same options as before. - ProjectOptions currentOptions = this.options; - this.SetConfiguration(config); - this.options = currentOptions; - } - - return this.options; - } - - ProjectOptions options = CreateProjectOptions(); - options.Config = config; - - string targetFrameworkMoniker = GetProjectProperty("TargetFrameworkMoniker", false); - - if (!string.IsNullOrEmpty(targetFrameworkMoniker)) - { - try - { - options.TargetFrameworkMoniker = new FrameworkName(targetFrameworkMoniker); - } - catch (ArgumentException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - } - - if (config == null) - { - this.options = options; - return options; - } - - options.GenerateExecutable = true; - - this.SetConfiguration(config); - - string outputPath = this.GetOutputPath(this.currentConfig); - if (!String.IsNullOrEmpty(outputPath)) - { - // absolutize relative to project folder location - outputPath = Path.Combine(this.ProjectFolder, outputPath); - } - - // Set some default values - options.OutputAssembly = outputPath + this.Caption + ".exe"; - options.ModuleKind = ModuleKindFlags.ConsoleApplication; - - options.RootNamespace = GetProjectProperty(ProjectFileConstants.RootNamespace, false); - options.OutputAssembly = outputPath + this.GetAssemblyName(config); - - string outputtype = GetProjectProperty(ProjectFileConstants.OutputType, false); - if (!string.IsNullOrEmpty(outputtype)) - { - outputtype = outputtype.ToLower(CultureInfo.InvariantCulture); - } - - if (outputtype == "library") - { - options.ModuleKind = ModuleKindFlags.DynamicallyLinkedLibrary; - options.GenerateExecutable = false; // DLL's have no entry point. - } - else if (outputtype == "winexe") - options.ModuleKind = ModuleKindFlags.WindowsApplication; - else - options.ModuleKind = ModuleKindFlags.ConsoleApplication; - - options.Win32Icon = GetProjectProperty("ApplicationIcon", false); - options.MainClass = GetProjectProperty("StartupObject", false); - - // other settings from CSharp we may want to adopt at some point... - // AssemblyKeyContainerName = "" //This is the key file used to sign the interop assembly generated when importing a com object via add reference - // AssemblyOriginatorKeyFile = "" - // DelaySign = "false" - // DefaultClientScript = "JScript" - // DefaultHTMLPageLayout = "Grid" - // DefaultTargetSchema = "IE50" - // PreBuildEvent = "" - // PostBuildEvent = "" - // RunPostBuildEvent = "OnBuildSuccess" - - // transfer all config build options... - if (GetBoolAttr(this.currentConfig, "AllowUnsafeBlocks")) - { - options.AllowUnsafeCode = true; - } - - if (GetProjectProperty("BaseAddress", false) != null) - { - try - { - options.BaseAddress = Int64.Parse(GetProjectProperty("BaseAddress", false), CultureInfo.InvariantCulture); - } - catch (ArgumentNullException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (ArgumentException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (FormatException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (OverflowException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - } - - if (GetBoolAttr(this.currentConfig, "CheckForOverflowUnderflow")) - { - options.CheckedArithmetic = true; - } - - if (GetProjectProperty("DefineConstants", false) != null) - { - options.DefinedPreprocessorSymbols = new StringCollection(); - foreach (string s in GetProjectProperty("DefineConstants", false).Replace(" \t\r\n", "").Split(';')) - { - options.DefinedPreprocessorSymbols.Add(s); - } - } - - string docFile = GetProjectProperty("DocumentationFile", false); - if (!String.IsNullOrEmpty(docFile)) - { - options.XmlDocFileName = Path.Combine(this.ProjectFolder, docFile); - } - - if (GetBoolAttr(this.currentConfig, "DebugSymbols")) - { - options.IncludeDebugInformation = true; - } - - if (GetProjectProperty("FileAlignment", false) != null) - { - try - { - options.FileAlignment = Int32.Parse(GetProjectProperty("FileAlignment", false), CultureInfo.InvariantCulture); - } - catch (ArgumentNullException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (ArgumentException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (FormatException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (OverflowException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - } - - if (GetBoolAttr(this.currentConfig, "IncrementalBuild")) - { - options.IncrementalCompile = true; - } - - if (GetBoolAttr(this.currentConfig, "Optimize")) - { - options.Optimize = true; - } - - if (GetBoolAttr(this.currentConfig, "RegisterForComInterop")) - { - } - - if (GetBoolAttr(this.currentConfig, "RemoveIntegerChecks")) - { - } - - if (GetBoolAttr(this.currentConfig, "TreatWarningsAsErrors")) - { - options.TreatWarningsAsErrors = true; - } - - if (GetProjectProperty("WarningLevel", false) != null) - { - try - { - options.WarningLevel = Int32.Parse(GetProjectProperty("WarningLevel", false), CultureInfo.InvariantCulture); - } - catch (ArgumentNullException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (ArgumentException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (FormatException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch (OverflowException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - } - - this.options = options; // do this AFTER setting configuration so it doesn't clear it. - return options; - } - - public virtual void OnTargetFrameworkMonikerChanged(ProjectOptions options, FrameworkName currentTargetFramework, FrameworkName newTargetFramework) - { - if (currentTargetFramework == null) - { - throw new ArgumentNullException("currentTargetFramework"); - } - if (newTargetFramework == null) - { - throw new ArgumentNullException("newTargetFramework"); - } - - var retargetingService = this.site.GetService(typeof(SVsTrackProjectRetargeting)) as IVsTrackProjectRetargeting; - if (retargetingService == null) - { - // Probably in a unit test. - ////throw new InvalidOperationException("Unable to acquire the SVsTrackProjectRetargeting service."); - Marshal.ThrowExceptionForHR(UpdateTargetFramework(this.InteropSafeIVsHierarchy, currentTargetFramework.FullName, newTargetFramework.FullName)); - } - else - { - Marshal.ThrowExceptionForHR(retargetingService.OnSetTargetFramework(this.InteropSafeIVsHierarchy, currentTargetFramework.FullName, newTargetFramework.FullName, this, true)); - } - } - - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Attr")] - [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "bool")] - public virtual bool GetBoolAttr(string config, string name) - { - this.SetConfiguration(config); - return this.GetBoolAttr(this.currentConfig, name); - } - - /// - /// Get the assembly name for a give configuration - /// - /// the matching configuration in the msbuild file - /// assembly name - public virtual string GetAssemblyName(string config) - { - this.SetConfiguration(config); - return GetAssemblyName(this.currentConfig); - } - - /// - /// Determines whether a file is a code file. - /// - /// Name of the file to be evaluated - /// false by default for any fileName - public virtual bool IsCodeFile(string fileName) - { - return false; - } - - /// - /// Determines whether the given file is a resource file (resx file). - /// - /// Name of the file to be evaluated. - /// true if the file is a resx file, otherwise false. - public virtual bool IsEmbeddedResource(string fileName) - { - if (String.Compare(Path.GetExtension(fileName), ".ResX", StringComparison.OrdinalIgnoreCase) == 0) - return true; - return false; - } - - /// - /// Create a file node based on an msbuild item. - /// - /// msbuild item - /// FileNode added - public virtual FileNode CreateFileNode(ProjectElement item) - { - return new FileNode(this, item); - } - - /// - /// Create a file node based on a string. - /// - /// filename of the new filenode - /// File node added - public virtual FileNode CreateFileNode(string file) - { - ProjectElement item = this.AddFileToMsBuild(file); - return this.CreateFileNode(item); - } - - /// - /// Create dependent file node based on an msbuild item - /// - /// msbuild item - /// dependent file node - public virtual DependentFileNode CreateDependentFileNode(ProjectElement item) - { - return new DependentFileNode(this, item); - } - - /// - /// Create a dependent file node based on a string. - /// - /// filename of the new dependent file node - /// Dependent node added - public virtual DependentFileNode CreateDependentFileNode(string file) - { - ProjectElement item = this.AddFileToMsBuild(file); - return this.CreateDependentFileNode(item); - } - - /// - /// Walks the subpaths of a project relative path and checks if the folder nodes hierarchy is already there, if not creates it. - /// - /// Path of the folder, can be relative to project or absolute - public virtual HierarchyNode CreateFolderNodes(string path) - { - if (String.IsNullOrEmpty(path)) - { - throw new ArgumentNullException("path"); - } - - if (Path.IsPathRooted(path)) - { - // Ensure we are using a relative path - if (String.Compare(this.ProjectFolder, 0, path, 0, this.ProjectFolder.Length, StringComparison.OrdinalIgnoreCase) != 0) - throw new ArgumentException("The path is not relative", "path"); - - path = path.Substring(this.ProjectFolder.Length); - } - - string[] parts; - HierarchyNode curParent; - - parts = path.Split(Path.DirectorySeparatorChar); - path = String.Empty; - curParent = this; - - // now we have an array of subparts.... - for (int i = 0; i < parts.Length; i++) - { - if (parts[i].Length > 0) - { - path += parts[i] + "\\"; - curParent = VerifySubFolderExists(path, curParent); - } - } - return curParent; - } - - /// - /// Defines if Node has Designer. By default we do not support designers for nodes - /// - /// Path to item to query for designer support - /// true if node has designer - public virtual bool NodeHasDesigner(string itemPath) - { - return false; - } - - /// - /// List of Guids of the config independent property pages. It is called by the GetProperty for VSHPROPID_PropertyPagesCLSIDList property. - /// - /// - protected virtual Guid[] GetConfigurationIndependentPropertyPages() - { - return new Guid[] { Guid.Empty }; - } - - /// - /// Returns a list of Guids of the configuration dependent property pages. It is called by the GetProperty for VSHPROPID_CfgPropertyPagesCLSIDList property. - /// - /// - protected virtual Guid[] GetConfigurationDependentPropertyPages() - { - return new Guid[0]; - } - - /// - /// An ordered list of guids of the prefered property pages. See __VSHPROPID.VSHPROPID_PriorityPropertyPagesCLSIDList" - /// - /// An array of guids. - protected virtual Guid[] GetPriorityProjectDesignerPages() - { - return new Guid[] { Guid.Empty }; - } - - /// - /// Takes a path and verifies that we have a node with that name. - /// It is meant to be a helper method for CreateFolderNodes(). - /// For some scenario it may be useful to override. - /// - /// full path to the subfolder we want to verify. - /// the parent node where to add the subfolder if it does not exist. - /// the foldernode correcsponding to the path. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "SubFolder")] - protected virtual FolderNode VerifySubFolderExists(string path, HierarchyNode parent) - { - FolderNode folderNode = null; - uint uiItemId; - Url url = new Url(this.BaseURI, path); - string strFullPath = url.AbsoluteUrl; - // Folders end in our storage with a backslash, so add one... - this.ParseCanonicalName(strFullPath, out uiItemId); - if (uiItemId != (uint)VSConstants.VSITEMID.Nil) - { - Debug.Assert(this.NodeFromItemId(uiItemId) is FolderNode, "Not a FolderNode"); - folderNode = (FolderNode)this.NodeFromItemId(uiItemId); - } - - if (folderNode == null && path != null && parent != null) - { - // folder does not exist yet... - // We could be in the process of loading so see if msbuild knows about it - ProjectElement item = null; - foreach (MSBuild.ProjectItem folder in buildProject.GetItems(ProjectFileConstants.Folder)) - { - if (String.Compare(folder.EvaluatedInclude.TrimEnd('\\'), path.TrimEnd('\\'), StringComparison.OrdinalIgnoreCase) == 0) - { - item = new ProjectElement(this, folder, false); - break; - } - } - // If MSBuild did not know about it, create a new one - if (item == null) - item = this.AddFolderToMsBuild(path); - folderNode = this.CreateFolderNode(path, item); - parent.AddChild(folderNode); - } - - return folderNode; - } - - /// - /// To support virtual folders, override this method to return your own folder nodes - /// - /// Path to store for this folder - /// Element corresponding to the folder - /// A FolderNode that can then be added to the hierarchy - protected internal virtual FolderNode CreateFolderNode(string path, ProjectElement element) - { - FolderNode folderNode = new FolderNode(this, path, element); - return folderNode; - } - - /// - /// Gets the list of selected HierarchyNode objects - /// - /// A list of HierarchyNode objects - protected internal virtual IList GetSelectedNodes() - { - // Retrieve shell interface in order to get current selection - IVsMonitorSelection monitorSelection = this.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection; - - if (monitorSelection == null) - { - throw new InvalidOperationException(); - } - - List selectedNodes = new List(); - IntPtr hierarchyPtr = IntPtr.Zero; - IntPtr selectionContainer = IntPtr.Zero; - try - { - // Get the current project hierarchy, project item, and selection container for the current selection - // If the selection spans multiple hierachies, hierarchyPtr is Zero - uint itemid; - IVsMultiItemSelect multiItemSelect = null; - ErrorHandler.ThrowOnFailure(monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainer)); - - // We only care if there are one ore more nodes selected in the tree - if (itemid != VSConstants.VSITEMID_NIL && hierarchyPtr != IntPtr.Zero) - { - IVsHierarchy hierarchy = Marshal.GetObjectForIUnknown(hierarchyPtr) as IVsHierarchy; - - if (itemid != VSConstants.VSITEMID_SELECTION) - { - // This is a single selection. Compare hirarchy with our hierarchy and get node from itemid - if (Utilities.IsSameComObject(this.InteropSafeIVsHierarchy, hierarchy)) - { - HierarchyNode node = this.NodeFromItemId(itemid); - if (node != null) - { - selectedNodes.Add(node); - } - } - else - { - NestedProjectNode node = this.GetNestedProjectForHierarchy(hierarchy); - if (node != null) - { - selectedNodes.Add(node); - } - } - } - else if (multiItemSelect != null) - { - // This is a multiple item selection. - - //Get number of items selected and also determine if the items are located in more than one hierarchy - uint numberOfSelectedItems; - int isSingleHierarchyInt; - ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectionInfo(out numberOfSelectedItems, out isSingleHierarchyInt)); - bool isSingleHierarchy = (isSingleHierarchyInt != 0); - - // Now loop all selected items and add to the list only those that are selected within this hierarchy - if (!isSingleHierarchy || (isSingleHierarchy && Utilities.IsSameComObject(this.InteropSafeIVsHierarchy, hierarchy))) - { - Debug.Assert(numberOfSelectedItems > 0, "Bad number of selected itemd"); - VSITEMSELECTION[] vsItemSelections = new VSITEMSELECTION[numberOfSelectedItems]; - uint flags = (isSingleHierarchy) ? (uint)__VSGSIFLAGS.GSI_fOmitHierPtrs : 0; - ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectedItems(flags, numberOfSelectedItems, vsItemSelections)); - foreach (VSITEMSELECTION vsItemSelection in vsItemSelections) - { - if (isSingleHierarchy || Utilities.IsSameComObject(this.InteropSafeIVsHierarchy, vsItemSelection.pHier)) - { - HierarchyNode node = this.NodeFromItemId(vsItemSelection.itemid); - if (node != null) - { - selectedNodes.Add(node); - } - } - } - } - } - } - } - finally - { - if (hierarchyPtr != IntPtr.Zero) - { - Marshal.Release(hierarchyPtr); - } - if (selectionContainer != IntPtr.Zero) - { - Marshal.Release(selectionContainer); - } - } - - return selectedNodes; - } - - /// - /// Recursevily walks the hierarchy nodes and redraws the state icons - /// - protected internal override void UpdateSccStateIcons() - { - if (this.FirstChild == null) - { - return; - } - - for (HierarchyNode n = this.FirstChild; n != null; n = n.NextSibling) - { - n.UpdateSccStateIcons(); - } - } - - // !EFW - /// - /// Handles the Shows All Files command. - /// - /// Returns S_OK if successful or an error code if not - protected internal virtual int ShowAllFiles() - { - return this.ToggleShowAllFiles(); - } - - /// - /// Handles the Add web reference command. - /// - /// - protected internal virtual int AddWebReference() - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - /// - /// Unloads the project. - /// - /// - protected internal virtual int UnloadProject() - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - /// - /// Handles the clean project command. - /// - /// - protected virtual int CleanProject() - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - /// - /// Reload project from project file - /// - protected virtual void Reload() - { - Debug.Assert(this.buildEngine != null, "There is no build engine defined for this project"); - - try - { - this.disableQueryEdit = true; - - this.isClosed = false; - this.eventTriggeringFlag = ProjectNode.EventTriggering.DoNotTriggerHierarchyEvents | ProjectNode.EventTriggering.DoNotTriggerTrackerEvents; - - SetBuildProject(Utilities.ReinitializeMsBuildProject(this.buildEngine, this.filename, this.buildProject)); - - // Load the guid - this.SetProjectGuidFromProjectFile(); - - this.ProcessReferences(); - - this.ProcessFiles(); - - this.ProcessFolders(); - - this.LoadNonBuildInformation(); - - this.InitSccInfo(); - - this.RegisterSccProject(); - } - finally - { - this.SetProjectFileDirty(false); - this.eventTriggeringFlag = ProjectNode.EventTriggering.TriggerAll; - this.disableQueryEdit = false; - } - } - - /// - /// Renames the project file - /// - /// The full path of the new project file. - protected virtual void RenameProjectFile(string newFile) - { - IVsUIShell shell = this.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; - Debug.Assert(shell != null, "Could not get the ui shell from the project"); - if (shell == null) - { - throw new InvalidOperationException(); - } - - // Do some name validation - if (Microsoft.VisualStudio.Project.Utilities.ContainsInvalidFileNameChars(newFile)) - { - throw new InvalidOperationException(SR.GetString(SR.ErrorInvalidProjectName, CultureInfo.CurrentUICulture)); - } - - // Figure out what the new full name is - string oldFile = this.Url; - - int canContinue = 0; - IVsSolution vsSolution = (IVsSolution)this.GetService(typeof(SVsSolution)); - if (ErrorHandler.Succeeded(vsSolution.QueryRenameProject(this.InteropSafeIVsProject3, oldFile, newFile, 0, out canContinue)) - && canContinue != 0) - { - bool isFileSame = NativeMethods.IsSamePath(oldFile, newFile); - - // If file already exist and is not the same file with different casing - if (!isFileSame && File.Exists(newFile)) - { - // Prompt the user for replace - string message = SR.GetString(SR.FileAlreadyExists, newFile); - - if (!Utilities.IsInAutomationFunction(this.Site)) - { - if (!VsShellUtilities.PromptYesNo(message, null, OLEMSGICON.OLEMSGICON_WARNING, shell)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - } - else - { - throw new InvalidOperationException(message); - } - - // Delete the destination file after making sure it is not read only - File.SetAttributes(newFile, FileAttributes.Normal); - File.Delete(newFile); - } - - SuspendFileChanges fileChanges = new SuspendFileChanges(this.Site, this.filename); - fileChanges.Suspend(); - try - { - // Actual file rename - this.SaveMSBuildProjectFileAs(newFile); - - this.SetProjectFileDirty(false); - - if (!isFileSame) - { - // Now that the new file name has been created delete the old one. - // TODO: Handle source control issues. - File.SetAttributes(oldFile, FileAttributes.Normal); - File.Delete(oldFile); - } - - this.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Caption, 0); - - // Update solution - ErrorHandler.ThrowOnFailure(vsSolution.OnAfterRenameProject(this.InteropSafeIVsProject3, oldFile, newFile, 0)); - - ErrorHandler.ThrowOnFailure(shell.RefreshPropertyBrowser(0)); - } - finally - { - fileChanges.Resume(); - } - } - else - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - } - - /// - /// Called by the project to know if the item is a file (that is part of the project) - /// or an intermediate file used by the MSBuild tasks/targets - /// Override this method if your project has more types or different ones - /// - /// Type name - /// True = items of this type should be included in the project - protected virtual bool IsItemTypeFileType(string type) - { - if (String.Compare(type, BuildAction.Compile.ToString(), StringComparison.OrdinalIgnoreCase) == 0 - || String.Compare(type, BuildAction.Content.ToString(), StringComparison.OrdinalIgnoreCase) == 0 - || String.Compare(type, BuildAction.EmbeddedResource.ToString(), StringComparison.OrdinalIgnoreCase) == 0 - || String.Compare(type, BuildAction.None.ToString(), StringComparison.OrdinalIgnoreCase) == 0) - return true; - - // we don't know about this type, so ignore it. - return false; - } - - /// - /// Filter items that should not be processed as file items. Example: Folders and References. - /// - protected virtual bool FilterItemTypeToBeAddedToHierarchy(string itemType) - { - return (String.Compare(itemType, ProjectFileConstants.Reference, StringComparison.OrdinalIgnoreCase) == 0 - || String.Compare(itemType, ProjectFileConstants.ProjectReference, StringComparison.OrdinalIgnoreCase) == 0 - || String.Compare(itemType, ProjectFileConstants.COMReference, StringComparison.OrdinalIgnoreCase) == 0 - || String.Compare(itemType, ProjectFileConstants.Folder, StringComparison.OrdinalIgnoreCase) == 0 - || String.Compare(itemType, ProjectFileConstants.WebReference, StringComparison.OrdinalIgnoreCase) == 0 - || String.Compare(itemType, ProjectFileConstants.WebReferenceFolder, StringComparison.OrdinalIgnoreCase) == 0); - } - - /// - /// Associate window output pane to the build logger - /// - /// - protected virtual void SetOutputLogger(IVsOutputWindowPane output) - { - // Create our logger, if it was not specified - if (!this.useProvidedLogger || this.buildLogger == null) - { - // Because we may be aggregated, we need to make sure to get the outer IVsHierarchy - IntPtr unknown = IntPtr.Zero; - IVsHierarchy hierarchy = null; - try - { - unknown = Marshal.GetIUnknownForObject(this); - hierarchy = Marshal.GetTypedObjectForIUnknown(unknown, typeof(IVsHierarchy)) as IVsHierarchy; - } - finally - { - if (unknown != IntPtr.Zero) - Marshal.Release(unknown); - } - // Create the logger - this.BuildLogger = new IDEBuildLogger(output, this.TaskProvider, hierarchy); - - // To retrive the verbosity level, the build logger depends on the registry root - // (otherwise it will used an hardcoded default) - ILocalRegistry2 registry = this.GetService(typeof(SLocalRegistry)) as ILocalRegistry2; - if (null != registry) - { - string registryRoot; - ErrorHandler.ThrowOnFailure(registry.GetLocalRegistryRoot(out registryRoot)); - IDEBuildLogger logger = this.BuildLogger as IDEBuildLogger; - if (!String.IsNullOrEmpty(registryRoot) && (null != logger)) - { - logger.BuildVerbosityRegistryRoot = registryRoot; - logger.ErrorString = this.ErrorString; - logger.WarningString = this.WarningString; - } - } - } - else - { - ((IDEBuildLogger)this.BuildLogger).OutputWindowPane = output; - } - } - - /// - /// Set configuration properties for a specific configuration - /// - /// configuration name - protected virtual void SetBuildConfigurationProperties(string config) - { - ProjectOptions options = null; - - if (!String.IsNullOrEmpty(config)) - { - options = this.GetProjectOptions(config); - } - - if (options != null && this.buildProject != null) - { - // Make sure the project configuration is set properly - this.SetConfiguration(config); - } - } - - /// - /// This execute an MSBuild target for a design-time build. - /// - /// Name of the MSBuild target to execute - /// Result from executing the target (success/failure) - /// - /// If you depend on the items/properties generated by the target - /// you should be aware that any call to BuildTarget on any project - /// will reset the list of generated items/properties - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ms")] - protected virtual MSBuildResult InvokeMsBuild(string target) - { - MSBuildResult result = MSBuildResult.Failed; - const bool designTime = true; - bool requiresUIThread = UIThread.Instance.IsUIThread; // we don't run tasks that require calling the STA thread, so unless we're ON it, we don't need it. - - IVsBuildManagerAccessor accessor = this.Site.GetService(typeof(SVsBuildManagerAccessor)) as IVsBuildManagerAccessor; - BuildSubmission submission = null; - - if (this.buildProject != null) - { - if (!TryBeginBuild(designTime, requiresUIThread)) - { - throw new InvalidOperationException("A build is already in progress."); - } - - try - { - // Do the actual Build - string[] targetsToBuild = new string[target != null ? 1 : 0]; - if (target != null) - { - targetsToBuild[0] = target; - } - - currentConfig = BuildProject.CreateProjectInstance(); - - BuildRequestData requestData = new BuildRequestData(currentConfig, targetsToBuild, this.BuildProject.ProjectCollection.HostServices, BuildRequestDataFlags.ReplaceExistingProjectInstance); - submission = BuildManager.DefaultBuildManager.PendBuildRequest(requestData); - if (accessor != null) - { - ErrorHandler.ThrowOnFailure(accessor.RegisterLogger(submission.SubmissionId, this.buildLogger)); - } - - BuildResult buildResult = submission.Execute(); - - result = (buildResult.OverallResult == BuildResultCode.Success) ? MSBuildResult.Successful : MSBuildResult.Failed; - } - finally - { - EndBuild(submission, designTime, requiresUIThread); - } - } - - return result; - } - - /// - /// Start MSBuild build submission - /// - /// If buildKind is ASync, this method starts the submission and returns. uiThreadCallback will be called on UI thread once submissions completes. - /// if buildKind is Sync, this method executes the submission and runs uiThreadCallback - /// Is it a Sync or ASync build - /// target to build - /// callback to be run UI thread - /// A Build submission instance. - protected virtual BuildSubmission DoMSBuildSubmission(BuildKind buildKind, string target, Action uiThreadCallback) - { - const bool designTime = false; - bool requiresUIThread = buildKind == BuildKind.Sync && UIThread.Instance.IsUIThread; // we don't run tasks that require calling the STA thread, so unless we're ON it, we don't need it. - - IVsBuildManagerAccessor accessor = (IVsBuildManagerAccessor)this.Site.GetService(typeof(SVsBuildManagerAccessor)); - if (accessor == null) - { - throw new InvalidOperationException(); - } - - if (!TryBeginBuild(designTime, requiresUIThread)) - { - if (uiThreadCallback != null) - { - uiThreadCallback(MSBuildResult.Failed, target); - } - - return null; - } - - string[] targetsToBuild = new string[target != null ? 1 : 0]; - if (target != null) - { - targetsToBuild[0] = target; - } - - MSBuildExecution.ProjectInstance projectInstance = BuildProject.CreateProjectInstance(); - - projectInstance.SetProperty(GlobalProperty.VisualStudioStyleErrors.ToString(), "true"); - projectInstance.SetProperty("UTFOutput", "true"); - projectInstance.SetProperty(GlobalProperty.BuildingInsideVisualStudio.ToString(), "true"); - - this.BuildProject.ProjectCollection.HostServices.SetNodeAffinity(projectInstance.FullPath, NodeAffinity.InProc); - BuildRequestData requestData = new BuildRequestData(projectInstance, targetsToBuild, this.BuildProject.ProjectCollection.HostServices, BuildRequestDataFlags.ReplaceExistingProjectInstance); - BuildSubmission submission = BuildManager.DefaultBuildManager.PendBuildRequest(requestData); - try - { - if (useProvidedLogger && buildLogger != null) - { - ErrorHandler.ThrowOnFailure(accessor.RegisterLogger(submission.SubmissionId, buildLogger)); - } - - if (buildKind == BuildKind.Async) - { - submission.ExecuteAsync(sub => - { - UIThread.Instance.Run(() => - { - this.FlushBuildLoggerContent(); - EndBuild(sub, designTime, requiresUIThread); - uiThreadCallback((sub.BuildResult.OverallResult == BuildResultCode.Success) ? MSBuildResult.Successful : MSBuildResult.Failed, target); - }); - }, null); - } - else - { - submission.Execute(); - EndBuild(submission, designTime, requiresUIThread); - MSBuildResult msbuildResult = (submission.BuildResult.OverallResult == BuildResultCode.Success) ? MSBuildResult.Successful : MSBuildResult.Failed; - if (uiThreadCallback != null) - { - uiThreadCallback(msbuildResult, target); - } - } - } - catch (Exception e) - { - Debug.Fail(e.ToString()); - EndBuild(submission, designTime, requiresUIThread); - if (uiThreadCallback != null) - { - uiThreadCallback(MSBuildResult.Failed, target); - } - - throw; - } - - return submission; - } - - /// - /// Initialize common project properties with default value if they are empty - /// - /// The following common project properties are defaulted to projectName (if empty): - /// AssemblyName, Name and RootNamespace. - /// If the project filename is not set then no properties are set - protected virtual void InitializeProjectProperties() - { - // Get projectName from project filename. Return if not set - string projectName = Path.GetFileNameWithoutExtension(this.filename); - if (String.IsNullOrEmpty(projectName)) - { - return; - } - - if (String.IsNullOrEmpty(GetProjectProperty(ProjectFileConstants.AssemblyName))) - { - SetProjectProperty(ProjectFileConstants.AssemblyName, projectName); - } - if (String.IsNullOrEmpty(GetProjectProperty(ProjectFileConstants.Name))) - { - SetProjectProperty(ProjectFileConstants.Name, projectName); - } - if (String.IsNullOrEmpty(GetProjectProperty(ProjectFileConstants.RootNamespace))) - { - SetProjectProperty(ProjectFileConstants.RootNamespace, projectName); - } - } - - /// - /// Factory method for configuration provider - /// - /// Configuration provider created - protected virtual ConfigProvider CreateConfigProvider() - { - return new ConfigProvider(this); - } - - /// - /// Factory method for reference container node - /// - /// ReferenceContainerNode created - protected virtual ReferenceContainerNode CreateReferenceContainerNode() - { - return new ReferenceContainerNode(this); - } - - /// - /// Saves the project file on a new name. - /// - /// The new name of the project file. - /// Success value or an error code. - protected virtual int SaveAs(string newFileName) - { - Debug.Assert(!String.IsNullOrEmpty(newFileName), "Cannot save project file for an empty or null file name"); - if (String.IsNullOrEmpty(newFileName)) - { - throw new ArgumentNullException("newFileName"); - } - - newFileName = newFileName.Trim(); - - string errorMessage = String.Empty; - - if (newFileName.Length > NativeMethods.MAX_PATH) - { - errorMessage = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.PathTooLong, CultureInfo.CurrentUICulture), newFileName); - } - else - { - string fileName = String.Empty; - - try - { - fileName = Path.GetFileNameWithoutExtension(newFileName); - } - // We want to be consistent in the error message and exception we throw. fileName could be for example #�&%"�&"% and that would trigger an ArgumentException on Path.IsRooted. - catch (ArgumentException) - { - errorMessage = SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture); - } - - if (errorMessage.Length == 0) - { - // If there is no filename or it starts with a leading dot issue an error message and quit. - // For some reason the save as dialog box allows to save files like "......ext" - if (String.IsNullOrEmpty(fileName) || fileName[0] == '.') - { - errorMessage = SR.GetString(SR.FileNameCannotContainALeadingPeriod, CultureInfo.CurrentUICulture); - } - else if (Utilities.ContainsInvalidFileNameChars(newFileName)) - { - errorMessage = SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture); - } - else - { - string url = Path.GetDirectoryName(newFileName); - string oldUrl = Path.GetDirectoryName(this.Url); - - if (!NativeMethods.IsSamePath(oldUrl, url)) - { - errorMessage = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.SaveOfProjectFileOutsideCurrentDirectory, CultureInfo.CurrentUICulture), this.ProjectFolder); - } - } - } - } - if (errorMessage.Length > 0) - { - // If it is not called from an automation method show a dialog box. - if (!Utilities.IsInAutomationFunction(this.Site)) - { - string title = null; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(this.Site, title, errorMessage, icon, buttons, defaultButton); - return VSConstants.OLE_E_PROMPTSAVECANCELLED; - } - - throw new InvalidOperationException(errorMessage); - } - - string oldName = this.filename; - - IVsSolution solution = this.Site.GetService(typeof(IVsSolution)) as IVsSolution; - Debug.Assert(solution != null, "Could not retrieve the solution form the service provider"); - if (solution == null) - { - throw new InvalidOperationException(); - } - - int canRenameContinue = 0; - ErrorHandler.ThrowOnFailure(solution.QueryRenameProject(this.InteropSafeIVsProject3, this.filename, newFileName, 0, out canRenameContinue)); - - if (canRenameContinue == 0) - { - return VSConstants.OLE_E_PROMPTSAVECANCELLED; - } - - SuspendFileChanges fileChanges = new SuspendFileChanges(this.Site, oldName); - fileChanges.Suspend(); - try - { - // Save the project file and project file related properties. - this.SaveMSBuildProjectFileAs(newFileName); - - this.SetProjectFileDirty(false); - - - // TODO: If source control is enabled check out the project file. - - //Redraw. - this.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Caption, 0); - - ErrorHandler.ThrowOnFailure(solution.OnAfterRenameProject(this.InteropSafeIVsProject3, oldName, this.filename, 0)); - - IVsUIShell shell = this.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; - Debug.Assert(shell != null, "Could not get the ui shell from the project"); - if (shell == null) - { - throw new InvalidOperationException(); - } - ErrorHandler.ThrowOnFailure(shell.RefreshPropertyBrowser(0)); - } - finally - { - fileChanges.Resume(); - } - - return VSConstants.S_OK; - } - - /// - /// Saves project file related information to the new file name. It also calls msbuild API to save the project file. - /// It is called by the SaveAs method and the SetEditLabel before the project file rename related events are triggered. - /// An implementer can override this method to provide specialized semantics on how the project file is renamed in the msbuild file. - /// - /// The new full path of the project file - protected virtual void SaveMSBuildProjectFileAs(string newFileName) - { - Debug.Assert(!String.IsNullOrEmpty(newFileName), "Cannot save project file for an empty or null file name"); - - this.buildProject.FullPath = newFileName; - - this.filename = newFileName; - - string newFileNameWithoutExtension = Path.GetFileNameWithoutExtension(newFileName); - - // Refresh solution explorer - this.SetProjectProperty(ProjectFileConstants.Name, newFileNameWithoutExtension); - - // Saves the project file on disk. - this.buildProject.Save(newFileName); - - } - - // !EFW - Added "internal" to allow calling for Include in Project - /// - /// Adds a file to the msbuild project. - /// - /// The file to be added. - /// A ProjectElement describing the newly added file. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "ToMs")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ms")] - protected internal virtual ProjectElement AddFileToMsBuild(string file) - { - ProjectElement newItem; - - // !EFW - Just make it relative to the project file to support linked files - string itemPath = PackageUtilities.MakeRelative(this.FileName, file); - - if (this.IsCodeFile(itemPath)) - { - newItem = this.CreateMsBuildFileItem(itemPath, ProjectFileConstants.Compile); - newItem.SetMetadata(ProjectFileConstants.SubType, ProjectFileAttributeValue.Code); - } - else if (this.IsEmbeddedResource(itemPath)) - { - newItem = this.CreateMsBuildFileItem(itemPath, ProjectFileConstants.EmbeddedResource); - } - else - { - newItem = this.CreateMsBuildFileItem(itemPath, ProjectFileConstants.Content); - newItem.SetMetadata(ProjectFileConstants.SubType, ProjectFileConstants.Content); - } - - return newItem; - } - - // !EFW - Added "internal" to allow calling for Include in Project - /// - /// Adds a folder to the msbuild project. - /// - /// The folder to be added. - /// A Projectelement describing the newly added folder. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "ToMs")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ms")] - protected internal virtual ProjectElement AddFolderToMsBuild(string folder) - { - ProjectElement newItem; - - string itemPath = PackageUtilities.MakeRelativeIfRooted(folder, this.BaseURI); - Debug.Assert(!Path.IsPathRooted(itemPath), "Cannot add item with full path."); - - newItem = this.CreateMsBuildFileItem(itemPath, ProjectFileConstants.Folder); - - return newItem; - } - - /// - /// Determines whether an item can be owerwritten in the hierarchy. - /// - /// The orginal filname. - /// The computed new file name, that will be copied to the project directory or into the folder . - /// S_OK for success, or an error message - protected virtual int CanOverwriteExistingItem(string originalFileName, string computedNewFileName) - { - if (String.IsNullOrEmpty(originalFileName) || String.IsNullOrEmpty(computedNewFileName)) - { - return VSConstants.E_INVALIDARG; - } - - string message = String.Empty; - string title = String.Empty; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - - // If the document is open then return error message. - IVsUIHierarchy hier; - IVsWindowFrame windowFrame; - uint itemid = VSConstants.VSITEMID_NIL; - - bool isOpen = VsShellUtilities.IsDocumentOpen(this.Site, computedNewFileName, Guid.Empty, out hier, out itemid, out windowFrame); - - if (isOpen) - { - message = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.CannotAddFileThatIsOpenInEditor, CultureInfo.CurrentUICulture), Path.GetFileName(computedNewFileName)); - VsShellUtilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton); - return VSConstants.E_ABORT; - } - - - // File already exists in project... message box - message = SR.GetString(SR.FileAlreadyInProject, CultureInfo.CurrentUICulture); - icon = OLEMSGICON.OLEMSGICON_QUERY; - buttons = OLEMSGBUTTON.OLEMSGBUTTON_YESNO; - int msgboxResult = VsShellUtilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton); - if (msgboxResult != NativeMethods.IDYES) - { - return (int)OleConstants.OLECMDERR_E_CANCELED; - } - - return VSConstants.S_OK; - } - - /// - /// Handle owerwriting of an existing item in the hierarchy. - /// - /// The node that exists. - protected virtual void OverwriteExistingItem(HierarchyNode existingNode) - { - - } - - /// - /// Adds a new file node to the hierarchy. - /// - /// The parent of the new fileNode - /// The file name - protected virtual void AddNewFileNodeToHierarchy(HierarchyNode parentNode, string fileName) - { - if (parentNode == null) - { - throw new ArgumentNullException("parentNode"); - } - - HierarchyNode child; - - // In the case of subitem, we want to create dependent file node - // and set the DependentUpon property - if (this.canFileNodesHaveChilds && (parentNode is FileNode || parentNode is DependentFileNode)) - { - child = this.CreateDependentFileNode(fileName); - child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include)); - - // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name - if (!child.HasParentNodeNameRelation && string.Compare(child.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0) - { - child.HasParentNodeNameRelation = true; - } - } - else - { - //Create and add new filenode to the project - child = this.CreateFileNode(fileName); - } - - parentNode.AddChild(child); - - // TODO : Revisit the VSADDFILEFLAGS here. Can it be a nested project? - this.tracker.OnItemAdded(fileName, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags); - } - - // !EFW - /// - /// Adds a new linked file node to the hierarchy. - /// - /// The parent of the new fileNode - /// The linked filename - /// The file name in the project heirarchy - protected virtual void AddNewLinkedFileNodeToHierarchy( - HierarchyNode parentNode, string linkedFileName, string fileName) - { - // NOTE: The general process should match that of - // AddNewFileNodeToHierarchy with the exception of the filename - // used and the addition of the Link metadata. - HierarchyNode child; - - // In the case of subitem, we want to create dependent file node - // and set the DependentUpon property - if(this.canFileNodesHaveChilds && (parentNode is FileNode || parentNode is DependentFileNode)) - { - child = this.CreateDependentFileNode(linkedFileName); - child.ItemNode.SetMetadata(ProjectFileConstants.Link, - PackageUtilities.MakeRelative(base.ProjectMgr.FileName, fileName)); - child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, - parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include)); - - // Make sure to set the HasNameRelation flag on the dependent - // node if it is related to the parent by name - if(!child.HasParentNodeNameRelation && string.Compare(child.GetRelationalName(), - parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0) - { - child.HasParentNodeNameRelation = true; - } - } - else - { - //Create and add new filenode to the project - child = this.CreateFileNode(linkedFileName); - child.ItemNode.SetMetadata(ProjectFileConstants.Link, - PackageUtilities.MakeRelative(base.ProjectMgr.FileName, fileName)); - } - - parentNode.AddChild(child); - - // TODO : Revisit the VSADDFILEFLAGS here. Can it be a nested project? - this.tracker.OnItemAdded(fileName, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags); - } - - /// - /// Defines whther the current mode of the project is in a supress command mode. - /// - /// - protected internal virtual bool IsCurrentStateASuppressCommandsMode() - { - if (VsShellUtilities.IsSolutionBuilding(this.Site)) - { - return true; - } - - DBGMODE dbgMode = VsShellUtilities.GetDebugMode(this.Site) & ~DBGMODE.DBGMODE_EncMask; - if (dbgMode == DBGMODE.DBGMODE_Run || dbgMode == DBGMODE.DBGMODE_Break) - { - return true; - } - - return false; - - } - - - /// - /// This is the list of output groups that the configuration object should - /// provide. - /// The first string is the name of the group. - /// The second string is the target name (MSBuild) for that group. - /// - /// To add/remove OutputGroups, simply override this method and edit the list. - /// - /// To get nice display names and description for your groups, override: - /// - GetOutputGroupDisplayName - /// - GetOutputGroupDescription - /// - /// List of output group name and corresponding MSBuild target - protected internal virtual IList> GetOutputGroupNames() - { - return new List>(outputGroupNames); - } - - /// - /// Get the display name of the given output group. - /// - /// Canonical name of the output group - /// Display name - protected internal virtual string GetOutputGroupDisplayName(string canonicalName) - { - string result = SR.GetString(String.Format(CultureInfo.InvariantCulture, "Output{0}", canonicalName), CultureInfo.CurrentUICulture); - if (String.IsNullOrEmpty(result)) - result = canonicalName; - return result; - } - - /// - /// Get the description of the given output group. - /// - /// Canonical name of the output group - /// Description - protected internal virtual string GetOutputGroupDescription(string canonicalName) - { - string result = SR.GetString(String.Format(CultureInfo.InvariantCulture, "Output{0}Description", canonicalName), CultureInfo.CurrentUICulture); - if (String.IsNullOrEmpty(result)) - result = canonicalName; - return result; - } - - /// - /// Set the configuration in MSBuild. - /// This does not get persisted and is used to evaluate msbuild conditions - /// which are based on the $(Configuration) property. - /// - protected internal virtual void SetCurrentConfiguration() - { - if (this.BuildInProgress) - { - // we are building so this should already be the current configuration - return; - } - - // Can't ask for the active config until the project is opened, so do nothing in that scenario - if (!this.projectOpened) - return; - - EnvDTE.Project automationObject = this.GetAutomationObject() as EnvDTE.Project; - - this.SetConfiguration(Utilities.GetActiveConfigurationName(automationObject)); - } - - /// - /// Set the configuration property in MSBuild. - /// This does not get persisted and is used to evaluate msbuild conditions - /// which are based on the $(Configuration) property. - /// - /// Configuration name - protected internal virtual void SetConfiguration(string config) - { - if (config == null) - { - throw new ArgumentNullException("config"); - } - - // Can't ask for the active config until the project is opened, so do nothing in that scenario - if (!projectOpened) - return; - - // We cannot change properties during the build so if the config - // we want to set is the current, we do nothing otherwise we fail. - if (this.BuildInProgress) - { - EnvDTE.Project automationObject = this.GetAutomationObject() as EnvDTE.Project; - string currentConfigName = Utilities.GetActiveConfigurationName(automationObject); - bool configsAreEqual = String.Compare(currentConfigName, config, StringComparison.OrdinalIgnoreCase) == 0; - - if (configsAreEqual) - { - return; - } - throw new InvalidOperationException(); - } - - bool propertiesChanged = this.buildProject.SetGlobalProperty(ProjectFileConstants.Configuration, config); - if (this.currentConfig == null || propertiesChanged) - { - this.currentConfig = this.buildProject.CreateProjectInstance(); - } - - if (propertiesChanged || this.designTimeAssemblyResolution == null) - { - if (this.designTimeAssemblyResolution == null) - { - this.designTimeAssemblyResolution = new DesignTimeAssemblyResolution(); - } - - this.designTimeAssemblyResolution.Initialize(this); - } - - this.options = null; - } - - /// - /// Loads reference items from the project file into the hierarchy. - /// - protected internal virtual void ProcessReferences() - { - IReferenceContainer container = GetReferenceContainer(); - if (null == container) - { - // Process References - ReferenceContainerNode referencesFolder = CreateReferenceContainerNode(); - if (null == referencesFolder) - { - // This project type does not support references or there is a problem - // creating the reference container node. - // In both cases there is no point to try to process references, so exit. - return; - } - this.AddChild(referencesFolder); - container = referencesFolder; - } - - // Load the referernces. - container.LoadReferencesFromBuildProject(buildProject); - } - - /// - /// Loads folders from the project file into the hierarchy. - /// - protected internal virtual void ProcessFolders() - { - // Process Folders (useful to persist empty folder) - foreach (MSBuild.ProjectItem folder in this.buildProject.GetItems(ProjectFileConstants.Folder)) - { - string strPath = folder.EvaluatedInclude; - - // We do not need any special logic for assuring that a folder is only added once to the ui hierarchy. - // The below method will only add once the folder to the ui hierarchy - this.CreateFolderNodes(strPath); - } - } - - /// - /// Loads file items from the project file into the hierarchy. - /// - protected internal virtual void ProcessFiles() - { - List subitemsKeys = new List(); - Dictionary subitems = new Dictionary(); - - // Define a set for our build items. The value does not really matter here. - Dictionary items = new Dictionary(); - - // !EFW Converted to list. If a new folder is found and added to the project, it alters - // the underlying collection. - - // Process Files - foreach (MSBuild.ProjectItem item in this.buildProject.Items.ToList()) - { - // Ignore the item if it is a reference or folder - if (this.FilterItemTypeToBeAddedToHierarchy(item.ItemType)) - continue; - - // MSBuilds tasks/targets can create items (such as object files), - // such items are not part of the project per se, and should not be displayed - // so ignore those items. - if (!this.IsItemTypeFileType(item.ItemType)) - continue; - - // If the item is already contained do nothing. - // TODO: possibly report in the error list that the the item is already contained in the project file similar to Language projects. - if (items.ContainsKey(item.EvaluatedInclude.ToUpperInvariant())) - continue; - - // Make sure that we do not want to add the item, dependent, or independent twice to the ui hierarchy - items.Add(item.EvaluatedInclude.ToUpperInvariant(), item); - - string dependentOf = item.GetMetadataValue(ProjectFileConstants.DependentUpon); - - if (!this.CanFileNodesHaveChilds || String.IsNullOrEmpty(dependentOf)) - { - AddIndependentFileNode(item); - } - else - { - // We will process dependent items later. - // Note that we use 2 lists as we want to remove elements from - // the collection as we loop through it - subitemsKeys.Add(item.EvaluatedInclude); - subitems.Add(item.EvaluatedInclude, item); - } - } - - // Now process the dependent items. - if (this.CanFileNodesHaveChilds) - { - ProcessDependentFileNodes(subitemsKeys, subitems); - } - - } - - /// - /// Processes dependent filenodes from list of subitems. Multi level supported, but not circular dependencies. - /// - /// List of sub item keys - /// - protected internal virtual void ProcessDependentFileNodes(IList subitemsKeys, Dictionary subitems) - { - if (subitemsKeys == null || subitems == null) - { - return; - } - - foreach (string key in subitemsKeys) - { - // A previous pass could have removed the key so make sure it still needs to be added - if (!subitems.ContainsKey(key)) - continue; - - AddDependentFileNode(subitems, key); - } - } - - /// - /// For flavored projects which implement IPersistXMLFragment, load the information now - /// - protected internal virtual void LoadNonBuildInformation() - { - IPersistXMLFragment outerHierarchy = this.InteropSafeIVsHierarchy as IPersistXMLFragment; - if (outerHierarchy != null) - { - this.LoadXmlFragment(outerHierarchy, null); - } - } - - /// - /// Used to sort nodes in the hierarchy. - /// - protected internal virtual int CompareNodes(HierarchyNode node1, HierarchyNode node2) - { - Debug.Assert(node1 != null && node2 != null); - if (node1 == null) - { - throw new ArgumentNullException("node1"); - } - - if (node2 == null) - { - throw new ArgumentNullException("node2"); - } - - if (node1.SortPriority == node2.SortPriority) - { - return String.Compare(node2.Caption, node1.Caption, true, CultureInfo.CurrentCulture); - } - else - { - return node2.SortPriority - node1.SortPriority; - } - } - - /// - /// Handles global properties related to configuration and platform changes invoked by a change in the active configuration. - /// - /// The sender of the event. - /// The event args - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers", - Justification = "This method will give the opportunity to update global properties based on active configuration change. " + - "There is no security threat that could otherwise not be reached by listening to configuration chnage events.")] - protected virtual void OnHandleConfigurationRelatedGlobalProperties(object sender, ActiveConfigurationChangedEventArgs eventArgs) - { - Debug.Assert(eventArgs != null, "Wrong hierarchy passed as event arg for the configuration change listener."); - - // If (eventArgs.Hierarchy == NULL) then we received this event because the solution configuration - // was changed. - // If it is not null we got the event because a project in teh configuration manager has changed its active configuration. - // We care only about our project in the default implementation. - if (eventArgs == null || eventArgs.Hierarchy == null || !Utilities.IsSameComObject(eventArgs.Hierarchy, this.InteropSafeIVsHierarchy)) - { - return; - } - - string name, platform; - if (!Utilities.TryGetActiveConfigurationAndPlatform(this.Site, this.InteropSafeIVsHierarchy, out name, out platform)) - { - throw new InvalidOperationException(); - } - - this.buildProject.SetGlobalProperty(GlobalProperty.Configuration.ToString(), name); - - // If the platform is "Any CPU" then it should be set to AnyCPU, since that is the property value in MsBuild terms. - if (String.Compare(platform, ConfigProvider.AnyCPUPlatform, StringComparison.Ordinal) == 0) - { - platform = ProjectFileValues.AnyCPU; - } - - this.buildProject.SetGlobalProperty(GlobalProperty.Platform.ToString(), platform); - } - - /// - /// Flush any remaining content from build logger. - /// This method is called as part of the callback method passed to the buildsubmission during async build - /// so that results can be printed the the build is finished. - /// - protected virtual void FlushBuildLoggerContent() - { - } - #endregion - - #region non-virtual methods - - /// - /// Suspends MSBuild - /// - public void SuspendMSBuild() - { - this.suspendMSBuildCounter++; - } - - /// - /// Resumes MSBuild. - /// - public void ResumeMSBuild(string config, IVsOutputWindowPane output, string target) - { - this.suspendMSBuildCounter--; - - if (this.suspendMSBuildCounter == 0 && this.invokeMSBuildWhenResumed) - { - try - { - this.Build(config, output, target); - } - finally - { - this.invokeMSBuildWhenResumed = false; - } - } - } - - /// - /// Resumes MSBuild. - /// - public void ResumeMSBuild(string config, string target) - { - this.ResumeMSBuild(config, null, target); - } - - /// - /// Resumes MSBuild. - /// - public void ResumeMSBuild(string target) - { - this.ResumeMSBuild(String.Empty, null, target); - } - - /// - /// Calls MSBuild if it is not suspended. If it is suspended then it will remember to call when msbuild is resumed. - /// - public MSBuildResult CallMSBuild(string config, IVsOutputWindowPane output, string target) - { - if (this.suspendMSBuildCounter > 0) - { - // remember to invoke MSBuild - this.invokeMSBuildWhenResumed = true; - return MSBuildResult.Suspended; - } - else - { - return this.Build(config, output, target); - } - } - - /// - /// Overloaded method. Calls MSBuild if it is not suspended. Does not log on the outputwindow. If it is suspended then it will remeber to call when msbuild is resumed. - /// - public MSBuildResult CallMSBuild(string config, string target) - { - return this.CallMSBuild(config, null, target); - } - - /// - /// Calls MSBuild if it is not suspended. Does not log and uses current configuration. If it is suspended then it will remeber to call when msbuild is resumed. - /// - public MSBuildResult CallMSBuild(string target) - { - return this.CallMSBuild(String.Empty, null, target); - } - - /// - /// Calls MSBuild if it is not suspended. Uses current configuration. If it is suspended then it will remeber to call when msbuild is resumed. - /// - public MSBuildResult CallMSBuild(string target, IVsOutputWindowPane output) - { - return this.CallMSBuild(String.Empty, output, target); - } - - /// - /// Overloaded method to invoke MSBuild - /// - public MSBuildResult Build(string config, IVsOutputWindowPane output, string target) - { - return this.Build(0, config, output, target); - } - - /// - /// Overloaded method to invoke MSBuild. Does not log build results to the output window pane. - /// - public MSBuildResult Build(string config, string target) - { - return this.Build(0, config, null, target); - } - - /// - /// Overloaded method. Invokes MSBuild using the default configuration and does without logging on the output window pane. - /// - public MSBuildResult Build(string target) - { - return this.Build(0, String.Empty, null, target); - } - - /// - /// Overloaded method. Invokes MSBuild using the default configuration. - /// - public MSBuildResult Build(string target, IVsOutputWindowPane output) - { - return this.Build(0, String.Empty, output, target); - } - - /// - /// Get the output path for a specific configuration name - /// - /// name of configuration - /// Output path - public string GetOutputPath(string config) - { - this.SetConfiguration(config); - return this.GetOutputPath(this.currentConfig); - } - - /// - /// Get value of Project property - /// - /// Name of Property to retrieve - /// Evaluated value of property. - public string GetProjectProperty(string propertyName) - { - return this.GetProjectProperty(propertyName, true); - } - - /// - /// Gets the unevaluated value of a project property. - /// - /// The name of the property to retrieve. - /// Unevaluated value of the property. - public string GetProjectPropertyUnevaluated(string propertyName) - { - return this.buildProject.GetProperty(propertyName).UnevaluatedValue; - } - - /// - /// Set dirty state of project - /// - /// boolean value indicating dirty state - public void SetProjectFileDirty(bool value) - { - this.isDirty = value; - if (this.isDirty) - { - this.lastModifiedTime = DateTime.Now; - this.buildIsPrepared = false; - } - } - - /// - /// Get output assembly for a specific configuration name - /// - /// Name of configuration - /// Name of output assembly - public string GetOutputAssembly(string config) - { - ProjectOptions options = this.GetProjectOptions(config); - - return options.OutputAssembly; - } - - /// - /// Get Node from ItemID. - /// - /// ItemID for the requested node - /// Node if found - public HierarchyNode NodeFromItemId(uint itemId) - { - if (VSConstants.VSITEMID_ROOT == itemId) - { - return this; - } - else if (VSConstants.VSITEMID_NIL == itemId) - { - return null; - } - else if (VSConstants.VSITEMID_SELECTION == itemId) - { - throw new NotImplementedException(); - } - - return (HierarchyNode)this.ItemIdMap[itemId]; - } - - /// - /// This method return new project element, and add new MSBuild item to the project/build hierarchy - /// - /// file name - /// MSBuild item type - /// new project element - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ms")] - public ProjectElement CreateMsBuildFileItem(string file, string itemType) - { - return new ProjectElement(this, file, itemType); - } - - /// - /// This method returns new project element based on existing MSBuild item. It does not modify/add project/build hierarchy at all. - /// - /// MSBuild item instance - /// wrapping project element - public ProjectElement GetProjectElement(MSBuild.ProjectItem item) - { - return new ProjectElement(this, item, false); - } - - /// - /// Create FolderNode from Path - /// - /// Path to folder - /// FolderNode created that can be added to the hierarchy - protected internal FolderNode CreateFolderNode(string path) - { - ProjectElement item = this.AddFolderToMsBuild(path); - FolderNode folderNode = CreateFolderNode(path, item); - return folderNode; - } - - /// - /// Verify if the file can be written to. - /// Return false if the file is read only and/or not checked out - /// and the user did not give permission to change it. - /// Note that exact behavior can also be affected based on the SCC - /// settings under Tools->Options. - /// - internal bool QueryEditProjectFile(bool suppressUI) - { - bool result = true; - if (this.site == null) - { - // We're already zombied. Better return FALSE. - result = false; - } - else if (this.disableQueryEdit) - { - return true; - } - else - { - IVsQueryEditQuerySave2 queryEditQuerySave = this.GetService(typeof(SVsQueryEditQuerySave)) as IVsQueryEditQuerySave2; - if (queryEditQuerySave != null) - { // Project path dependends on server/client project - string path = this.filename; - - tagVSQueryEditFlags qef = tagVSQueryEditFlags.QEF_AllowInMemoryEdits; - if (suppressUI) - qef |= tagVSQueryEditFlags.QEF_SilentMode; - - // If we are debugging, we want to prevent our project from being reloaded. To - // do this, we pass the QEF_NoReload flag - if (!Utilities.IsVisualStudioInDesignMode(this.Site)) - qef |= tagVSQueryEditFlags.QEF_NoReload; - - uint verdict; - uint moreInfo; - string[] files = new string[1]; - files[0] = path; - uint[] flags = new uint[1]; - VSQEQS_FILE_ATTRIBUTE_DATA[] attributes = new VSQEQS_FILE_ATTRIBUTE_DATA[1]; - int hr = queryEditQuerySave.QueryEditFiles( - (uint)qef, - 1, // 1 file - files, // array of files - flags, // no per file flags - attributes, // no per file file attributes - out verdict, - out moreInfo /* ignore additional results */); - - tagVSQueryEditResult qer = (tagVSQueryEditResult)verdict; - if (ErrorHandler.Failed(hr) || (qer != tagVSQueryEditResult.QER_EditOK)) - { - if (!suppressUI && !Utilities.IsInAutomationFunction(this.Site)) - { - string message = SR.GetString(SR.CancelQueryEdit, path); - string title = string.Empty; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton); - } - result = false; - } - } - } - return result; - } - - /// - /// Checks whether a hierarchy is a nested project. - /// - /// - /// - internal NestedProjectNode GetNestedProjectForHierarchy(IVsHierarchy hierarchy) - { - IVsProject3 project = hierarchy as IVsProject3; - - if (project != null) - { - string mkDocument = String.Empty; - ErrorHandler.ThrowOnFailure(project.GetMkDocument(VSConstants.VSITEMID_ROOT, out mkDocument)); - - if (!String.IsNullOrEmpty(mkDocument)) - { - HierarchyNode node = this.FindChild(mkDocument); - - return node as NestedProjectNode; - } - } - - return null; - } - - /// - /// Given a node determines what is the directory that can accept files. - /// If the node is a FoldeNode than it is the Url of the Folder. - /// If the node is a ProjectNode it is the project folder. - /// Otherwise (such as FileNode subitem) it delegate the resolution to the parent node. - /// - internal string GetBaseDirectoryForAddingFiles(HierarchyNode nodeToAddFile) - { - string baseDir = String.Empty; - - if (nodeToAddFile is FolderNode) - { - baseDir = nodeToAddFile.Url; - } - else if (nodeToAddFile is ProjectNode) - { - baseDir = this.ProjectFolder; - } - else if (nodeToAddFile != null) - { - baseDir = GetBaseDirectoryForAddingFiles(nodeToAddFile.Parent); - } - - return baseDir; - } - - /// - /// For internal use only. - /// This creates a copy of an existing configuration and add it to the project. - /// Caller should change the condition on the PropertyGroup. - /// If derived class want to accomplish this, they should call ConfigProvider.AddCfgsOfCfgName() - /// It is expected that in the future MSBuild will have support for this so we don't have to - /// do it manually. - /// - /// PropertyGroup to clone - /// - internal MSBuildConstruction.ProjectPropertyGroupElement ClonePropertyGroup(MSBuildConstruction.ProjectPropertyGroupElement group) - { - // Create a new (empty) PropertyGroup - MSBuildConstruction.ProjectPropertyGroupElement newPropertyGroup = this.buildProject.Xml.AddPropertyGroup(); - - // Now copy everything from the group we are trying to clone to the group we are creating - if (!String.IsNullOrEmpty(group.Condition)) - newPropertyGroup.Condition = group.Condition; - foreach (MSBuildConstruction.ProjectPropertyElement prop in group.Properties) - { - MSBuildConstruction.ProjectPropertyElement newProperty = newPropertyGroup.AddProperty(prop.Name, prop.Value); - if (!String.IsNullOrEmpty(prop.Condition)) - newProperty.Condition = prop.Condition; - } - - return newPropertyGroup; - } - - /// - /// Get the project extensions - /// - /// - internal MSBuildConstruction.ProjectExtensionsElement GetProjectExtensions() - { - var extensionsElement = this.buildProject.Xml.ChildrenReversed.OfType().FirstOrDefault(); - - if (extensionsElement == null) - { - extensionsElement = this.buildProject.Xml.CreateProjectExtensionsElement(); - this.buildProject.Xml.AppendChild(extensionsElement); - } - - return extensionsElement; - } - - /// - /// Set the xmlText as a project extension element with the id passed. - /// - /// The id of the project extension element. - /// The value to set for a project extension. - internal void SetProjectExtensions(string id, string xmlText) - { - MSBuildConstruction.ProjectExtensionsElement element = this.GetProjectExtensions(); - - // If it doesn't already have a value and we're asked to set it to - // nothing, don't do anything. Same as old OM. Keeps project neat. - if (element == null) - { - if (xmlText.Length == 0) - { - return; - } - - element = this.buildProject.Xml.CreateProjectExtensionsElement(); - this.buildProject.Xml.AppendChild(element); - } - - element[id] = xmlText; - } - - /// - /// Register the project with the Scc manager. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - protected void RegisterSccProject() - { - - if (this.IsSccDisabled || this.isRegisteredWithScc || String.IsNullOrEmpty(this.sccProjectName)) - { - return; - } - - IVsSccManager2 sccManager = this.Site.GetService(typeof(SVsSccManager)) as IVsSccManager2; - - if (sccManager != null) - { - ErrorHandler.ThrowOnFailure(sccManager.RegisterSccProject(this.InteropSafeIVsSccProject2, this.sccProjectName, this.sccAuxPath, this.sccLocalPath, this.sccProvider)); - - this.isRegisteredWithScc = true; - } - } - - /// - /// Unregisters us from the SCC manager - /// - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "UnRegister")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Un")] - protected void UnRegisterProject() - { - if (this.IsSccDisabled || !this.isRegisteredWithScc) - { - return; - } - - IVsSccManager2 sccManager = this.Site.GetService(typeof(SVsSccManager)) as IVsSccManager2; - - if (sccManager != null) - { - ErrorHandler.ThrowOnFailure(sccManager.UnregisterSccProject(this.InteropSafeIVsSccProject2)); - this.isRegisteredWithScc = false; - } - } - - /// - /// Get the CATID corresponding to the specified type. - /// - /// Type of the object for which you want the CATID - /// CATID - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CATID")] - protected internal Guid GetCATIDForType(Type type) - { - if (type == null) - throw new ArgumentNullException("type"); - - if (catidMapping.ContainsKey(type)) - return catidMapping[type]; - // If you get here and you want your object to be extensible, then add a call to AddCATIDMapping() in your project constructor - return Guid.Empty; - } - - /// - /// This is used to specify a CATID corresponding to a BrowseObject or an ExtObject. - /// The CATID can be any GUID you choose. For types which are your owns, you could use - /// their type GUID, while for other types (such as those provided in the MPF) you should - /// provide a different GUID. - /// - /// Type of the extensible object - /// GUID that extender can use to uniquely identify your object type - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "catid")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CATID")] - protected void AddCATIDMapping(Type type, Guid catid) - { - catidMapping.Add(type, catid); - } - - /// - /// Initialize an object with an XML fragment. - /// - /// Object that support being initialized with an XML fragment - /// Name of the configuration being initialized, null if it is the project - protected internal void LoadXmlFragment(IPersistXMLFragment persistXmlFragment, string configName) - { - if (persistXmlFragment == null) - { - throw new ArgumentNullException("persistXmlFragment"); - } - - if (xmlFragments == null) - { - // Retrieve the xml fragments from MSBuild - xmlFragments = new XmlDocument(); - - string fragments = GetProjectExtensions()[ProjectFileConstants.VisualStudio]; - fragments = String.Format(CultureInfo.InvariantCulture, "{0}", fragments); - xmlFragments.LoadXml(fragments); - } - - // We need to loop through all the flavors - string flavorsGuid; - ErrorHandler.ThrowOnFailure(((IVsAggregatableProject)this).GetAggregateProjectTypeGuids(out flavorsGuid)); - foreach (Guid flavor in Utilities.GuidsArrayFromSemicolonDelimitedStringOfGuids(flavorsGuid)) - { - // Look for a matching fragment - string flavorGuidString = flavor.ToString("B"); - string fragment = null; - XmlNode node = null; - foreach (XmlNode child in xmlFragments.FirstChild.ChildNodes) - { - if (child.Attributes.Count > 0) - { - string guid = String.Empty; - string configuration = String.Empty; - if (child.Attributes[ProjectFileConstants.Guid] != null) - guid = child.Attributes[ProjectFileConstants.Guid].Value; - if (child.Attributes[ProjectFileConstants.Configuration] != null) - configuration = child.Attributes[ProjectFileConstants.Configuration].Value; - - if (String.Compare(child.Name, ProjectFileConstants.FlavorProperties, StringComparison.OrdinalIgnoreCase) == 0 - && String.Compare(guid, flavorGuidString, StringComparison.OrdinalIgnoreCase) == 0 - && ((String.IsNullOrEmpty(configName) && String.IsNullOrEmpty(configuration)) - || (String.Compare(configuration, configName, StringComparison.OrdinalIgnoreCase) == 0))) - { - // we found the matching fragment - fragment = child.InnerXml; - node = child; - break; - } - } - } - - Guid flavorGuid = flavor; - if (String.IsNullOrEmpty(fragment)) - { - // the fragment was not found so init with default values - ErrorHandler.ThrowOnFailure(persistXmlFragment.InitNew(ref flavorGuid, (uint)_PersistStorageType.PST_PROJECT_FILE)); - // While we don't yet support user files, our flavors might, so we will store that in the project file until then - // TODO: Refactor this code when we support user files - ErrorHandler.ThrowOnFailure(persistXmlFragment.InitNew(ref flavorGuid, (uint)_PersistStorageType.PST_USER_FILE)); - } - else - { - ErrorHandler.ThrowOnFailure(persistXmlFragment.Load(ref flavorGuid, (uint)_PersistStorageType.PST_PROJECT_FILE, fragment)); - // While we don't yet support user files, our flavors might, so we will store that in the project file until then - // TODO: Refactor this code when we support user files - if (node.NextSibling != null && node.NextSibling.Attributes[ProjectFileConstants.User] != null) - ErrorHandler.ThrowOnFailure(persistXmlFragment.Load(ref flavorGuid, (uint)_PersistStorageType.PST_USER_FILE, node.NextSibling.InnerXml)); - } - } - } - - /// - /// Retrieve all XML fragments that need to be saved from the flavors and store the information in msbuild. - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "XML")] - protected void PersistXMLFragments() - { - if (this.IsFlavorDirty() != 0) - { - XmlDocument doc = new XmlDocument(); - XmlElement root = doc.CreateElement("ROOT"); - - // We will need the list of configuration inside the loop, so get it before entering the loop - uint[] count = new uint[1]; - IVsCfg[] configs = null; - int hr = this.ConfigProvider.GetCfgs(0, null, count, null); - if (ErrorHandler.Succeeded(hr) && count[0] > 0) - { - configs = new IVsCfg[count[0]]; - hr = this.ConfigProvider.GetCfgs((uint)configs.Length, configs, count, null); - if (ErrorHandler.Failed(hr)) - count[0] = 0; - } - if (count[0] == 0) - configs = new IVsCfg[0]; - - // We need to loop through all the flavors - string flavorsGuid; - ErrorHandler.ThrowOnFailure(((IVsAggregatableProject)this).GetAggregateProjectTypeGuids(out flavorsGuid)); - foreach (Guid flavor in Utilities.GuidsArrayFromSemicolonDelimitedStringOfGuids(flavorsGuid)) - { - IPersistXMLFragment outerHierarchy = this.InteropSafeIVsHierarchy as IPersistXMLFragment; - // First check the project - if (outerHierarchy != null) - { - // Retrieve the XML fragment - string fragment = string.Empty; - Guid flavorGuid = flavor; - ErrorHandler.ThrowOnFailure((outerHierarchy).Save(ref flavorGuid, (uint)_PersistStorageType.PST_PROJECT_FILE, out fragment, 1)); - if (!String.IsNullOrEmpty(fragment)) - { - // Add the fragment to our XML - WrapXmlFragment(doc, root, flavor, null, fragment); - } - // While we don't yet support user files, our flavors might, so we will store that in the project file until then - // TODO: Refactor this code when we support user files - fragment = String.Empty; - ErrorHandler.ThrowOnFailure((outerHierarchy).Save(ref flavorGuid, (uint)_PersistStorageType.PST_USER_FILE, out fragment, 1)); - if (!String.IsNullOrEmpty(fragment)) - { - // Add the fragment to our XML - XmlElement node = WrapXmlFragment(doc, root, flavor, null, fragment); - node.Attributes.Append(doc.CreateAttribute(ProjectFileConstants.User)); - } - } - - // Then look at the configurations - foreach (IVsCfg config in configs) - { - // Get the fragment for this flavor/config pair - string fragment; - ErrorHandler.ThrowOnFailure(((ProjectConfig)config).GetXmlFragment(flavor, _PersistStorageType.PST_PROJECT_FILE, out fragment)); - if (!String.IsNullOrEmpty(fragment)) - { - string configName; - ErrorHandler.ThrowOnFailure(config.get_DisplayName(out configName)); - WrapXmlFragment(doc, root, flavor, configName, fragment); - } - } - } - if (root.ChildNodes != null && root.ChildNodes.Count > 0) - { - // Save our XML (this is only the non-build information for each flavor) in msbuild - SetProjectExtensions(ProjectFileConstants.VisualStudio, root.InnerXml.ToString()); - } - } - } - - #endregion - - #region IVsGetCfgProvider Members - //================================================================================= - - public virtual int GetCfgProvider(out IVsCfgProvider p) - { - CCITracing.TraceCall(); - // Be sure to call the property here since that is doing a polymorhic ProjectConfig creation. - p = this.ConfigProvider; - return (p == null ? VSConstants.E_NOTIMPL : VSConstants.S_OK); - } - #endregion - - #region IPersist Members - - public int GetClassID(out Guid clsid) - { - clsid = this.ProjectGuid; - return VSConstants.S_OK; - } - #endregion - - #region IPersistFileFormat Members - - int IPersistFileFormat.GetClassID(out Guid clsid) - { - clsid = this.ProjectGuid; - return VSConstants.S_OK; - } - - public virtual int GetCurFile(out string name, out uint formatIndex) - { - name = this.filename; - formatIndex = 0; - return VSConstants.S_OK; - } - - public virtual int GetFormatList(out string formatlist) - { - formatlist = String.Empty; - return VSConstants.S_OK; - } - - public virtual int InitNew(uint formatIndex) - { - return VSConstants.S_OK; - } - - public virtual int IsDirty(out int isDirty) - { - isDirty = 0; - if (this.buildProject.Xml.HasUnsavedChanges || this.IsProjectFileDirty) - { - isDirty = 1; - return VSConstants.S_OK; - } - - isDirty = IsFlavorDirty(); - - return VSConstants.S_OK; - } - - protected int IsFlavorDirty() - { - int isDirty = 0; - // See if one of our flavor consider us dirty - IPersistXMLFragment outerHierarchy = this.InteropSafeIVsHierarchy as IPersistXMLFragment; - if (outerHierarchy != null) - { - // First check the project - ErrorHandler.ThrowOnFailure(outerHierarchy.IsFragmentDirty((uint)_PersistStorageType.PST_PROJECT_FILE, out isDirty)); - // While we don't yet support user files, our flavors might, so we will store that in the project file until then - // TODO: Refactor this code when we support user files - if (isDirty == 0) - ErrorHandler.ThrowOnFailure(outerHierarchy.IsFragmentDirty((uint)_PersistStorageType.PST_USER_FILE, out isDirty)); - } - if (isDirty == 0) - { - // Then look at the configurations - uint[] count = new uint[1]; - int hr = this.ConfigProvider.GetCfgs(0, null, count, null); - if (ErrorHandler.Succeeded(hr) && count[0] > 0) - { - // We need to loop through the configurations - IVsCfg[] configs = new IVsCfg[count[0]]; - hr = this.ConfigProvider.GetCfgs((uint)configs.Length, configs, count, null); - Debug.Assert(ErrorHandler.Succeeded(hr), "failed to retrieve configurations"); - foreach (IVsCfg config in configs) - { - isDirty = ((ProjectConfig)config).IsFlavorDirty(_PersistStorageType.PST_PROJECT_FILE); - if (isDirty != 0) - break; - } - } - } - return isDirty; - } - - public virtual int Load(string fileName, uint mode, int readOnly) - { - this.filename = fileName; - this.Reload(); - return VSConstants.S_OK; - } - - public virtual int Save(string fileToBeSaved, int remember, uint formatIndex) - { - - // The file name can be null. Then try to use the Url. - string tempFileToBeSaved = fileToBeSaved; - if (String.IsNullOrEmpty(tempFileToBeSaved) && !String.IsNullOrEmpty(this.Url)) - { - tempFileToBeSaved = this.Url; - } - - if (String.IsNullOrEmpty(tempFileToBeSaved)) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "fileToBeSaved"); - } - - bool setProjectFileDirtyAfterSave = false; - if (remember == 0) - { - setProjectFileDirtyAfterSave = this.IsProjectFileDirty; - } - - // Update the project with the latest flavor data (if needed) - PersistXMLFragments(); - - int result = VSConstants.S_OK; - bool saveAs = true; - if (NativeMethods.IsSamePath(tempFileToBeSaved, this.filename)) - { - saveAs = false; - } - if (!saveAs) - { - SuspendFileChanges fileChanges = new SuspendFileChanges(this.Site, this.filename); - fileChanges.Suspend(); - try - { - // Ensure the directory exist - string saveFolder = Path.GetDirectoryName(tempFileToBeSaved); - if (!Directory.Exists(saveFolder)) - Directory.CreateDirectory(saveFolder); - // Save the project - this.buildProject.Save(tempFileToBeSaved); - this.SetProjectFileDirty(false); - } - finally - { - fileChanges.Resume(); - } - } - else - { - result = this.SaveAs(tempFileToBeSaved); - if (result != VSConstants.OLE_E_PROMPTSAVECANCELLED) - { - ErrorHandler.ThrowOnFailure(result); - } - - } - - if (setProjectFileDirtyAfterSave) - { - this.SetProjectFileDirty(true); - } - - return result; - } - - public virtual int SaveCompleted(string filename) - { - // TODO: turn file watcher back on. - return VSConstants.S_OK; - } - #endregion - - #region IVsProject3 Members - - /// - /// Callback from the additem dialog. Deals with adding new and existing items - /// - public virtual int GetMkDocument(uint itemId, out string mkDoc) - { - mkDoc = null; - if (itemId == VSConstants.VSITEMID_SELECTION) - { - return VSConstants.E_UNEXPECTED; - } - - HierarchyNode n = this.NodeFromItemId(itemId); - if (n == null) - { - return VSConstants.E_INVALIDARG; - } - - mkDoc = n.GetMkDocument(); - - if (String.IsNullOrEmpty(mkDoc)) - { - return VSConstants.E_FAIL; - } - - return VSConstants.S_OK; - } - - - public virtual int AddItem(uint itemIdLoc, VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, IntPtr dlgOwner, VSADDRESULT[] result) - { - Guid empty = Guid.Empty; - - return AddItemWithSpecific(itemIdLoc, op, itemName, filesToOpen, files, dlgOwner, 0, ref empty, null, ref empty, result); - } - - /// - /// Creates new items in a project, adds existing files to a project, or causes Add Item wizards to be run - /// - /// - /// - /// - /// - /// Array of file names. - /// If dwAddItemOperation is VSADDITEMOP_CLONEFILE the first item in the array is the name of the file to clone. - /// If dwAddItemOperation is VSADDITEMOP_OPENDIRECTORY, the first item in the array is the directory to open. - /// If dwAddItemOperation is VSADDITEMOP_RUNWIZARD, the first item is the name of the wizard to run, - /// and the second item is the file name the user supplied (same as itemName). - /// - /// - /// - /// - /// - /// - /// S_OK if it succeeds - /// The result array is initalized to failure. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - public virtual int AddItemWithSpecific(uint itemIdLoc, VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, IntPtr dlgOwner, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, VSADDRESULT[] result) - { - if (files == null || result == null || files.Length == 0 || result.Length == 0) - { - return VSConstants.E_INVALIDARG; - } - - // Locate the node to be the container node for the file(s) being added - // only projectnode or foldernode and file nodes are valid container nodes - // We need to locate the parent since the item wizard expects the parent to be passed. - HierarchyNode n = this.NodeFromItemId(itemIdLoc); - if (n == null) - { - return VSConstants.E_INVALIDARG; - } - - while ((!(n is ProjectNode)) && (!(n is FolderNode)) && (!this.CanFileNodesHaveChilds || !(n is FileNode))) - { - n = n.Parent; - } - Debug.Assert(n != null, "We should at this point have either a ProjectNode or FolderNode or a FileNode as a container for the new file nodes"); - - // !EFW - // Handle runwizard operations at this point - if(op == VSADDITEMOPERATION.VSADDITEMOP_RUNWIZARD) - { - result[0] = this.RunWizard(n, itemName, files[0], dlgOwner); - return VSConstants.S_OK; - } - - string[] actualFiles = new string[files.Length]; - - VSQUERYADDFILEFLAGS[] flags = this.GetQueryAddFileFlags(files); - - string baseDir = this.GetBaseDirectoryForAddingFiles(n); - // If we did not get a directory for node that is the parent of the item then fail. - if (String.IsNullOrEmpty(baseDir)) - { - return VSConstants.E_FAIL; - } - - // Pre-calculates some paths that we can use when calling CanAddItems - List filesToAdd = new List(); - for (int index = 0; index < files.Length; index++) - { - string newFileName = String.Empty; - - string file = files[index]; - - switch(op) - { - case VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE: - { - // New item added. Need to copy template to new location and then add new location - string fileName = Path.GetFileName(itemName); - newFileName = Path.Combine(baseDir, fileName); - } - break; - - case VSADDITEMOPERATION.VSADDITEMOP_OPENFILE: - case VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE: // !EFW - { - string fileName = Path.GetFileName(file); - newFileName = Path.Combine(baseDir, fileName); - } - break; - } - filesToAdd.Add(newFileName); - } - - // Ask tracker objects if we can add files - if(!this.tracker.CanAddItems(filesToAdd.ToArray(), flags)) - { - // We were not allowed to add the files - return VSConstants.E_FAIL; - } - - if(!this.ProjectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - // Add the files to the hierarchy - int actualFilesAddedIndex = 0; - for(int index = 0; index < filesToAdd.Count; index++) - { - HierarchyNode child; - bool overwrite = false; - string newFileName = filesToAdd[index]; - - string file = files[index]; - result[0] = VSADDRESULT.ADDRESULT_Failure; - - child = this.FindChild(newFileName); - if (child != null) - { - // If the file to be added is an existing file part of the hierarchy then continue. - if (NativeMethods.IsSamePath(file, newFileName)) - { - // !EFW - if(child.IsNonMemberItem) - result[0] = child.IncludeInProject() == VSConstants.S_OK ? - VSADDRESULT.ADDRESULT_Success : VSADDRESULT.ADDRESULT_Cancel; - else - result[0] = VSADDRESULT.ADDRESULT_Cancel; - - continue; - } - - int canOverWriteExistingItem = this.CanOverwriteExistingItem(file, newFileName); - - if (canOverWriteExistingItem == (int)OleConstants.OLECMDERR_E_CANCELED) - { - result[0] = VSADDRESULT.ADDRESULT_Cancel; - return canOverWriteExistingItem; - } - else if (canOverWriteExistingItem == VSConstants.S_OK) - { - overwrite = true; - } - else - { - return canOverWriteExistingItem; - } - } - - // !EFW - // If the file to be added is not in the same path copy it unless we are creating a link to it - if(op != VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE && - NativeMethods.IsSamePath(file, newFileName) == false) - { - if (!overwrite && File.Exists(newFileName)) - { - string message = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.FileAlreadyExists, CultureInfo.CurrentUICulture), newFileName); - string title = string.Empty; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_QUERY; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_YESNO; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - int messageboxResult = VsShellUtilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton); - if (messageboxResult == NativeMethods.IDNO) - { - result[0] = VSADDRESULT.ADDRESULT_Cancel; - return (int)OleConstants.OLECMDERR_E_CANCELED; - } - } - - // Copy the file to the correct location. - // We will suppress the file change events to be triggered to this item, since we are going to copy over the existing file and thus we will trigger a file change event. - // We do not want the filechange event to ocur in this case, similar that we do not want a file change event to occur when saving a file. - IVsFileChangeEx fileChange = this.site.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx; - if (fileChange == null) - { - throw new InvalidOperationException(); - } - - try - { - ErrorHandler.ThrowOnFailure(fileChange.IgnoreFile(VSConstants.VSCOOKIE_NIL, newFileName, 1)); - if (op == VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE) - { - this.AddFileFromTemplate(file, newFileName); - } - else - { - PackageUtilities.CopyUrlToLocal(new Uri(file), newFileName); - } - } - finally - { - ErrorHandler.ThrowOnFailure(fileChange.IgnoreFile(VSConstants.VSCOOKIE_NIL, newFileName, 0)); - } - } - - if (overwrite) - { - this.OverwriteExistingItem(child); - } - else - { - // !EFW - // Add new file node/dependent file node - if(op != VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE) - this.AddNewFileNodeToHierarchy(n, newFileName); - else - this.AddNewLinkedFileNodeToHierarchy(n, file, newFileName); - } - - result[0] = VSADDRESULT.ADDRESULT_Success; - actualFiles[actualFilesAddedIndex++] = newFileName; - } - - // Notify listeners that items were appended. - if(actualFilesAddedIndex > 0) - { - // !EFW - Really odd bug. In release builds, if the new item is added to a collapsed node and - // is nested deeply enough, the OnItemsAppended call will fail somewhere and kill Visual Studio. - // Expanding the parent nodes first appears to work around the issue. - IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, - SolutionExplorer); - - if(uiWindow != null) - ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this.ProjectMgr.InteropSafeIVsUIHierarchy, - n.ID, EXPANDFLAGS.EXPF_ExpandParentsToShowItem)); - - n.OnItemsAppended(n); - } - - //Open files if this was requested through the editorFlags - bool openFiles = (editorFlags & (uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_DoOpen) != 0; - if (openFiles && actualFiles.Length <= filesToOpen) - { - for (int i = 0; i < filesToOpen; i++) - { - if (!String.IsNullOrEmpty(actualFiles[i])) - { - string name = actualFiles[i]; - HierarchyNode child = this.FindChild(name); - Debug.Assert(child != null, "We should have been able to find the new element in the hierarchy"); - if (child != null) - { - IVsWindowFrame frame; - if (editorType == Guid.Empty) - { - Guid view = Guid.Empty; - ErrorHandler.ThrowOnFailure(this.OpenItem(child.ID, ref view, IntPtr.Zero, out frame)); - } - else - { - ErrorHandler.ThrowOnFailure(this.OpenItemWithSpecific(child.ID, editorFlags, ref editorType, physicalView, ref logicalView, IntPtr.Zero, out frame)); - } - - // Show the window frame in the UI and make it the active window - if (frame != null) - { - ErrorHandler.ThrowOnFailure(frame.Show()); - } - } - } - } - } - - return VSConstants.S_OK; - } - - /// - /// for now used by add folder. Called on the ROOT, as only the project should need - /// to implement this. - /// for folders, called with parent folder, blank extension and blank suggested root - /// - public virtual int GenerateUniqueItemName(uint itemIdLoc, string ext, string suggestedRoot, out string itemName) - { - string rootName = String.Empty; - string extToUse = String.Empty; - itemName = String.Empty; - - //force new items to have a number - int cb = 1; - bool found = false; - bool fFolderCase = false; - HierarchyNode parent = this.NodeFromItemId(itemIdLoc); - - if (!String.IsNullOrEmpty(ext)) - { - extToUse = ext.Trim(); - } - - if (!String.IsNullOrEmpty(suggestedRoot)) - { - suggestedRoot = suggestedRoot.Trim(); - } - - if (suggestedRoot == null || suggestedRoot.Length == 0) - { - // foldercase, we assume... - suggestedRoot = "NewFolder"; - fFolderCase = true; - } - - while (!found) - { - rootName = suggestedRoot; - if (cb > 0) - rootName += cb.ToString(CultureInfo.CurrentCulture); - - if (extToUse.Length > 0) - { - rootName += extToUse; - } - - cb++; - found = true; - for (HierarchyNode n = parent.FirstChild; n != null; n = n.NextSibling) - { - if (rootName == n.GetEditLabel()) - { - found = false; - break; - } - - //if parent is a folder, we need the whole url - string parentFolder = parent.Url; - if (parent is ProjectNode) - parentFolder = Path.GetDirectoryName(parent.Url); - - string checkFile = Path.Combine(parentFolder, rootName); - - if (fFolderCase) - { - if (Directory.Exists(checkFile)) - { - found = false; - break; - } - } - else - { - if (File.Exists(checkFile)) - { - found = false; - break; - } - } - } - } - - itemName = rootName; - return VSConstants.S_OK; - } - - - public virtual int GetItemContext(uint itemId, out Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp) - { - CCITracing.TraceCall(); - psp = null; - HierarchyNode child = this.NodeFromItemId(itemId); - if (child != null) - { - psp = child.OleServiceProvider as IOleServiceProvider; - } - return VSConstants.S_OK; - } - - - public virtual int IsDocumentInProject(string mkDoc, out int found, VSDOCUMENTPRIORITY[] pri, out uint itemId) - { - CCITracing.TraceCall(); - if (pri != null && pri.Length >= 1) - { - pri[0] = VSDOCUMENTPRIORITY.DP_Unsupported; - } - found = 0; - itemId = 0; - - // If it is the project file just return. - if (NativeMethods.IsSamePath(mkDoc, this.GetMkDocument())) - { - found = 1; - itemId = VSConstants.VSITEMID_ROOT; - } - else - { - HierarchyNode child = this.FindChild(mkDoc); - if (child != null) - { - found = 1; - itemId = child.ID; - } - } - - if (found == 1) - { - if (pri != null && pri.Length >= 1) - { - pri[0] = VSDOCUMENTPRIORITY.DP_Standard; - } - } - - return VSConstants.S_OK; - - } - - - public virtual int OpenItem(uint itemId, ref Guid logicalView, IntPtr punkDocDataExisting, out IVsWindowFrame frame) - { - // Init output params - frame = null; - - HierarchyNode n = this.NodeFromItemId(itemId); - if (n == null) - { - throw new ArgumentException(SR.GetString(SR.ParameterMustBeAValidItemId, CultureInfo.CurrentUICulture), "itemId"); - } - - // Delegate to the document manager object that knows how to open the item - DocumentManager documentManager = n.GetDocumentManager(); - if (documentManager != null) - { - return documentManager.Open(ref logicalView, punkDocDataExisting, out frame, WindowFrameShowAction.DoNotShow); - } - - // This node does not have an associated document manager and we must fail - return VSConstants.E_FAIL; - } - - - public virtual int OpenItemWithSpecific(uint itemId, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame frame) - { - // Init output params - frame = null; - - HierarchyNode n = this.NodeFromItemId(itemId); - if (n == null) - { - throw new ArgumentException(SR.GetString(SR.ParameterMustBeAValidItemId, CultureInfo.CurrentUICulture), "itemId"); - } - - // Delegate to the document manager object that knows how to open the item - DocumentManager documentManager = n.GetDocumentManager(); - if (documentManager != null) - { - return documentManager.OpenWithSpecific(editorFlags, ref editorType, physicalView, ref logicalView, docDataExisting, out frame, WindowFrameShowAction.DoNotShow); - } - - // This node does not have an associated document manager and we must fail - return VSConstants.E_FAIL; - } - - - public virtual int RemoveItem(uint reserved, uint itemId, out int result) - { - HierarchyNode n = this.NodeFromItemId(itemId); - if (n == null) - { - throw new ArgumentException(SR.GetString(SR.ParameterMustBeAValidItemId, CultureInfo.CurrentUICulture), "itemId"); - } - n.Remove(true); - result = 1; - return VSConstants.S_OK; - } - - - public virtual int ReopenItem(uint itemId, ref Guid editorType, string physicalView, ref Guid logicalView, IntPtr docDataExisting, out IVsWindowFrame frame) - { - // Init output params - frame = null; - - HierarchyNode n = this.NodeFromItemId(itemId); - if (n == null) - { - throw new ArgumentException(SR.GetString(SR.ParameterMustBeAValidItemId, CultureInfo.CurrentUICulture), "itemId"); - } - - // Delegate to the document manager object that knows how to open the item - DocumentManager documentManager = n.GetDocumentManager(); - if (documentManager != null) - { - return documentManager.OpenWithSpecific(0, ref editorType, physicalView, ref logicalView, docDataExisting, out frame, WindowFrameShowAction.DoNotShow); - } - - // This node does not have an associated document manager and we must fail - return VSConstants.E_FAIL; - } - - - /// - /// Implements IVsProject3::TransferItem - /// This function is called when an open miscellaneous file is being transferred - /// to our project. The sequence is for the shell to call AddItemWithSpecific and - /// then use TransferItem to transfer the open document to our project. - /// - /// Old document name - /// New document name - /// Optional frame if the document is open - /// - public virtual int TransferItem(string oldMkDoc, string newMkDoc, IVsWindowFrame frame) - { - // Fail if hierarchy already closed - if (this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - //Fail if the document names passed are null. - if (oldMkDoc == null || newMkDoc == null) - return VSConstants.E_INVALIDARG; - - int hr = VSConstants.S_OK; - VSDOCUMENTPRIORITY[] priority = new VSDOCUMENTPRIORITY[1]; - uint itemid = VSConstants.VSITEMID_NIL; - uint cookie = 0; - uint grfFlags = 0; - - IVsRunningDocumentTable pRdt = GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable; - if (pRdt == null) - return VSConstants.E_ABORT; - - string doc; - int found; - IVsHierarchy pHier; - uint id, readLocks, editLocks; - IntPtr docdataForCookiePtr = IntPtr.Zero; - IntPtr docDataPtr = IntPtr.Zero; - IntPtr hierPtr = IntPtr.Zero; - - // We get the document from the running doc table so that we can see if it is transient - try - { - ErrorHandler.ThrowOnFailure(pRdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, oldMkDoc, out pHier, out id, out docdataForCookiePtr, out cookie)); - } - finally - { - if (docdataForCookiePtr != IntPtr.Zero) - Marshal.Release(docdataForCookiePtr); - } - - //Get the document info - try - { - ErrorHandler.ThrowOnFailure(pRdt.GetDocumentInfo(cookie, out grfFlags, out readLocks, out editLocks, out doc, out pHier, out id, out docDataPtr)); - } - finally - { - if (docDataPtr != IntPtr.Zero) - Marshal.Release(docDataPtr); - } - - // Now see if the document is in the project. If not, we fail - try - { - ErrorHandler.ThrowOnFailure(IsDocumentInProject(newMkDoc, out found, priority, out itemid)); - Debug.Assert(itemid != VSConstants.VSITEMID_NIL && itemid != VSConstants.VSITEMID_ROOT); - hierPtr = Marshal.GetComInterfaceForObject(this, typeof(IVsUIHierarchy)); - // Now rename the document - ErrorHandler.ThrowOnFailure(pRdt.RenameDocument(oldMkDoc, newMkDoc, hierPtr, itemid)); - } - finally - { - if (hierPtr != IntPtr.Zero) - Marshal.Release(hierPtr); - } - - //Change the caption if we are passed a window frame - if (frame != null) - { - string caption = "%2"; - hr = frame.SetProperty((int)(__VSFPROPID.VSFPROPID_OwnerCaption), caption); - } - return hr; - } - - #endregion - - #region IVsProjectBuidSystem Members - public virtual int SetHostObject(string targetName, string taskName, object hostObject) - { - Debug.Assert(targetName != null && taskName != null && this.buildProject != null && this.buildProject.Targets != null); - - if (targetName == null || taskName == null || this.buildProject == null || this.buildProject.Targets == null) - { - return VSConstants.E_INVALIDARG; - } - - this.buildProject.ProjectCollection.HostServices.RegisterHostObject(this.buildProject.FullPath, targetName, taskName, (Microsoft.Build.Framework.ITaskHost)hostObject); - - return VSConstants.S_OK; - } - - public int BuildTarget(string targetName, out bool success) - { - success = false; - - MSBuildResult result = this.Build(targetName); - - if (result == MSBuildResult.Successful) - { - success = true; - } - - return VSConstants.S_OK; - } - - public virtual int CancelBatchEdit() - { - return VSConstants.E_NOTIMPL; - } - - public virtual int EndBatchEdit() - { - return VSConstants.E_NOTIMPL; - } - - public virtual int StartBatchEdit() - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Used to determine the kind of build system, in VS 2005 there's only one defined kind: MSBuild - /// - /// - /// - public virtual int GetBuildSystemKind(out uint kind) - { - kind = (uint)_BuildSystemKindFlags2.BSK_MSBUILD_VS10; - return VSConstants.S_OK; - } - - #endregion - - #region IVsComponentUser methods - - /// - /// Add Components to the Project. - /// Used by the environment to add components specified by the user in the Component Selector dialog - /// to the specified project - /// - /// The component operation to be performed. - /// Number of components to be added - /// array of component selector data - /// Handle to the component picker dialog - /// Result to be returned to the caller - public virtual int AddComponent(VSADDCOMPOPERATION dwAddCompOperation, uint cComponents, System.IntPtr[] rgpcsdComponents, System.IntPtr hwndDialog, VSADDCOMPRESULT[] pResult) - { - if (rgpcsdComponents == null || pResult == null) - { - return VSConstants.E_FAIL; - } - - //initalize the out parameter - pResult[0] = VSADDCOMPRESULT.ADDCOMPRESULT_Success; - - IReferenceContainer references = GetReferenceContainer(); - if (null == references) - { - // This project does not support references or the reference container was not created. - // In both cases this operation is not supported. - return VSConstants.E_NOTIMPL; - } - for (int cCount = 0; cCount < cComponents; cCount++) - { - VSCOMPONENTSELECTORDATA selectorData = new VSCOMPONENTSELECTORDATA(); - IntPtr ptr = rgpcsdComponents[cCount]; - selectorData = (VSCOMPONENTSELECTORDATA)Marshal.PtrToStructure(ptr, typeof(VSCOMPONENTSELECTORDATA)); - if (null == references.AddReferenceFromSelectorData(selectorData)) - { - //Skip further proccessing since a reference has to be added - pResult[0] = VSADDCOMPRESULT.ADDCOMPRESULT_Failure; - return VSConstants.S_OK; - } - } - return VSConstants.S_OK; - } - #endregion - - #region IVsDependencyProvider Members - public int EnumDependencies(out IVsEnumDependencies enumDependencies) - { - enumDependencies = new EnumDependencies(this.buildDependencyList); - return VSConstants.S_OK; - } - - public int OpenDependency(string szDependencyCanonicalName, out IVsDependency dependency) - { - dependency = null; - return VSConstants.S_OK; - } - - #endregion - - #region IVsSccProject2 Members - /// - /// This method is called to determine which files should be placed under source control for a given VSITEMID within this hierarchy. - /// - /// Identifier for the VSITEMID being queried. - /// Pointer to an array of CALPOLESTR strings containing the file names for this item. - /// Pointer to a CADWORD array of flags stored in DWORDs indicating that some of the files have special behaviors. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int GetSccFiles(uint itemid, CALPOLESTR[] stringsOut, CADWORD[] flagsOut) - { - if (itemid == VSConstants.VSITEMID_SELECTION) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "itemid"); - } - - HierarchyNode n = this.NodeFromItemId(itemid); - if (n == null) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "itemid"); - } - - List files = new List(); - List flags = new List(); - - n.GetSccFiles(files, flags); - - if (stringsOut != null && stringsOut.Length > 0) - { - stringsOut[0] = Utilities.CreateCALPOLESTR(files); - } - - if (flagsOut != null && flagsOut.Length > 0) - { - flagsOut[0] = Utilities.CreateCADWORD(flags); - } - - return VSConstants.S_OK; - } - - /// - /// This method is called to discover special (hidden files) associated with a given VSITEMID within this hierarchy. - /// - /// Identifier for the VSITEMID being queried. - /// One of the files associated with the node - /// Pointer to an array of CALPOLESTR strings containing the file names for this item. - /// Pointer to a CADWORD array of flags stored in DWORDs indicating that some of the files have special behaviors. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - /// This method is called to discover any special or hidden files associated with an item in the project hierarchy. It is called when GetSccFiles returns with the SFF_HasSpecialFiles flag set for any of the files associated with the node. - public virtual int GetSccSpecialFiles(uint itemid, string sccFile, CALPOLESTR[] stringsOut, CADWORD[] flagsOut) - { - if (itemid == VSConstants.VSITEMID_SELECTION) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "itemid"); - } - - HierarchyNode n = this.NodeFromItemId(itemid); - if (n == null) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "itemid"); - } - - List files = new List(); - - List flags = new List(); - - n.GetSccSpecialFiles(sccFile, files, flags); - - if (stringsOut != null && stringsOut.Length > 0) - { - stringsOut[0] = Utilities.CreateCALPOLESTR(files); - } - - if (flagsOut != null && flagsOut.Length > 0) - { - flagsOut[0] = Utilities.CreateCADWORD(flags); - } - - return VSConstants.S_OK; - - } - - /// - /// This method is called by the source control portion of the environment to inform the project of changes to the source control glyph on various nodes. - /// - /// Count of changed nodes. - /// An array of VSITEMID identifiers of the changed nodes. - /// An array of VsStateIcon glyphs representing the new state of the corresponding item in rgitemidAffectedNodes. - /// An array of status flags from SccStatus corresponding to rgitemidAffectedNodes. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int SccGlyphChanged(int affectedNodes, uint[] itemidAffectedNodes, VsStateIcon[] newGlyphs, uint[] newSccStatus) - { - // if all the paramaters are null adn the count is 0, it means scc wants us to updated everything - if (affectedNodes == 0 && itemidAffectedNodes == null && newGlyphs == null && newSccStatus == null) - { - this.ReDraw(UIHierarchyElement.SccState); - this.UpdateSccStateIcons(); - } - else if (affectedNodes > 0 && itemidAffectedNodes != null && newGlyphs != null && newSccStatus != null) - { - for (int i = 0; i < affectedNodes; i++) - { - HierarchyNode n = this.NodeFromItemId(itemidAffectedNodes[i]); - if (n == null) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "itemidAffectedNodes"); - } - - n.ReDraw(UIHierarchyElement.SccState); - } - } - return VSConstants.S_OK; - } - - /// - /// This method is called by the source control portion of the environment when a project is initially added to source control, or to change some of the project's settings. - /// - /// String, opaque to the project, that identifies the project location on the server. Persist this string in the project file. - /// String, opaque to the project, that identifies the path to the server. Persist this string in the project file. - /// String, opaque to the project, that identifies the local path to the project. Persist this string in the project file. - /// String, opaque to the project, that identifies the source control package. Persist this string in the project file. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int SetSccLocation(string sccProjectName, string sccAuxPath, string sccLocalPath, string sccProvider) - { - if (this.IsSccDisabled) - { - throw new NotImplementedException(); - } - - if (sccProjectName == null) - { - throw new ArgumentNullException("sccProjectName"); - } - - if (sccAuxPath == null) - { - throw new ArgumentNullException("sccAuxPath"); - } - - if (sccLocalPath == null) - { - throw new ArgumentNullException("sccLocalPath"); - } - - if (sccProvider == null) - { - throw new ArgumentNullException("sccProvider"); - } - - // Save our settings (returns true if something changed) - if (!this.SetSccSettings(sccProjectName, sccLocalPath, sccAuxPath, sccProvider)) - { - return VSConstants.S_OK; - } - - bool unbinding = (sccProjectName.Length == 0 && sccProvider.Length == 0); - - if (unbinding || this.QueryEditProjectFile(false)) - { - this.buildProject.SetProperty(ProjectFileConstants.SccProjectName, sccProjectName); - this.buildProject.SetProperty(ProjectFileConstants.SccProvider, sccProvider); - this.buildProject.SetProperty(ProjectFileConstants.SccAuxPath, sccAuxPath); - this.buildProject.SetProperty(ProjectFileConstants.SccLocalPath, sccLocalPath); - } - - this.isRegisteredWithScc = true; - - return VSConstants.S_OK; - } - #endregion - - #region IVsProjectSpecialFiles Members - /// - /// Allows you to query the project for special files and optionally create them. - /// - /// __PSFFILEID of the file - /// __PSFFLAGS flags for the file - /// The itemid of the node in the hierarchy - /// The file name of the special file. - /// - public virtual int GetFile(int fileId, uint flags, out uint itemid, out string fileName) - { - itemid = VSConstants.VSITEMID_NIL; - fileName = String.Empty; - - // We need to return S_OK, otherwise the property page tabs will not be shown. - return VSConstants.E_NOTIMPL; - } - #endregion - - #region IAggregatedHierarchy Members - - /// - /// Get the inner object of an aggregated hierarchy - /// - /// A HierarchyNode - public virtual HierarchyNode GetInner() - { - return this; - } - - #endregion - - #region IBuildDependencyUpdate Members - - public virtual IVsBuildDependency[] BuildDependencies - { - get - { - return this.buildDependencyList.ToArray(); - } - } - - public virtual void AddBuildDependency(IVsBuildDependency dependency) - { - if (this.isClosed || dependency == null) - { - return; - } - - if (!this.buildDependencyList.Contains(dependency)) - { - this.buildDependencyList.Add(dependency); - } - } - - public virtual void RemoveBuildDependency(IVsBuildDependency dependency) - { - if (this.isClosed || dependency == null) - { - return; - } - - if (this.buildDependencyList.Contains(dependency)) - { - this.buildDependencyList.Remove(dependency); - } - } - - #endregion - - #region IReferenceDataProvider Members - /// - /// Returns the reference container node. - /// - /// - public IReferenceContainer GetReferenceContainer() - { - return this.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as IReferenceContainer; - } - - #endregion - - #region IProjectEventsListener Members - public bool IsProjectEventsListener - { - get { return this.isProjectEventsListener; } - set { this.isProjectEventsListener = value; } - } - #endregion - - #region IProjectEventsProvider Members - - /// - /// Defines the provider for the project events - /// - IProjectEvents IProjectEventsProvider.ProjectEventsProvider - { - get - { - return this.projectEventsProvider; - } - set - { - if (null != this.projectEventsProvider) - { - this.projectEventsProvider.AfterProjectFileOpened -= this.OnAfterProjectOpen; - } - this.projectEventsProvider = value; - if (null != this.projectEventsProvider) - { - this.projectEventsProvider.AfterProjectFileOpened += this.OnAfterProjectOpen; - } - } - } - - #endregion - - #region IVsAggregatableProject Members - - /// - /// Retrieve the list of project GUIDs that are aggregated together to make this project. - /// - /// Semi colon separated list of Guids. Typically, the last GUID would be the GUID of the base project factory - /// HResult - public int GetAggregateProjectTypeGuids(out string projectTypeGuids) - { - projectTypeGuids = this.GetProjectProperty(ProjectFileConstants.ProjectTypeGuids); - // In case someone manually removed this from our project file, default to our project without flavors - if (String.IsNullOrEmpty(projectTypeGuids)) - projectTypeGuids = this.ProjectGuid.ToString("B"); - return VSConstants.S_OK; - } - - /// - /// This is where the initialization occurs. - /// - public virtual int InitializeForOuter(string filename, string location, string name, uint flags, ref Guid iid, out IntPtr projectPointer, out int canceled) - { - canceled = 0; - projectPointer = IntPtr.Zero; - - // Initialize the interop-safe versions of this node's implementations of various VS interfaces, - // which point to the outer object. The project node itself should never be passed to unmanaged - // code -- we should always use these properties instead. - this.InteropSafeIVsHierarchy = Utilities.GetOuterAs(this); - this.InteropSafeIVsUIHierarchy = Utilities.GetOuterAs(this); - this.InteropSafeIVsProject3 = Utilities.GetOuterAs(this); - this.InteropSafeIVsSccProject2 = Utilities.GetOuterAs(this); - this.InteropSafeIVsUIHierWinClipboardHelperEvents = Utilities.GetOuterAs(this); - this.InteropSafeIVsComponentUser = Utilities.GetOuterAs(this); - - // Initialize the project - this.Load(filename, location, name, flags, ref iid, out canceled); - - if (canceled != 1) - { - // Set ourself as the project - return Marshal.QueryInterface(Marshal.GetIUnknownForObject(this), ref iid, out projectPointer); - } - - return VSConstants.OLE_E_PROMPTSAVECANCELLED; - } - - /// - /// This is called after the project is done initializing the different layer of the aggregations - /// - /// HResult - public virtual int OnAggregationComplete() - { - return VSConstants.S_OK; - } - - /// - /// Set the list of GUIDs that are aggregated together to create this project. - /// - /// Semi-colon separated list of GUIDs, the last one is usually the project factory of the base project factory - /// HResult - public int SetAggregateProjectTypeGuids(string projectTypeGuids) - { - this.SetProjectProperty(ProjectFileConstants.ProjectTypeGuids, projectTypeGuids); - return VSConstants.S_OK; - } - - /// - /// We are always the inner most part of the aggregation - /// and as such we don't support setting an inner project - /// - public int SetInnerProject(object innerProject) - { - return VSConstants.E_NOTIMPL; - } - - #endregion - - #region IVsProjectFlavorCfgProvider Members - - int IVsProjectFlavorCfgProvider.CreateProjectFlavorCfg(IVsCfg pBaseProjectCfg, out IVsProjectFlavorCfg ppFlavorCfg) - { - // Our config object is also our IVsProjectFlavorCfg object - ppFlavorCfg = pBaseProjectCfg as IVsProjectFlavorCfg; - - return VSConstants.S_OK; - } - - #endregion - - #region IVsBuildPropertyStorage Members - - /// - /// Get the property of an item - /// - /// ItemID - /// Name of the property - /// Value of the property (out parameter) - /// HRESULT - int IVsBuildPropertyStorage.GetItemAttribute(uint item, string attributeName, out string attributeValue) - { - attributeValue = null; - - HierarchyNode node = NodeFromItemId(item); - if (node == null) - throw new ArgumentException("Invalid item id", "item"); - - attributeValue = node.ItemNode.GetMetadata(attributeName); - return VSConstants.S_OK; - } - - /// - /// Get the value of the property in the project file - /// - /// Name of the property to remove - /// Configuration for which to remove the property - /// Project or user file (_PersistStorageType) - /// Value of the property (out parameter) - /// HRESULT - int IVsBuildPropertyStorage.GetPropertyValue(string propertyName, string configName, uint storage, out string propertyValue) - { - // TODO: when adding support for User files, we need to update this method - propertyValue = null; - if (string.IsNullOrEmpty(configName)) - { - propertyValue = this.GetProjectProperty(propertyName); - } - else - { - IVsCfg configurationInterface; - ErrorHandler.ThrowOnFailure(this.ConfigProvider.GetCfgOfName(configName, string.Empty, out configurationInterface)); - ProjectConfig config = (ProjectConfig)configurationInterface; - propertyValue = config.GetConfigurationProperty(propertyName, true); - } - return VSConstants.S_OK; - } - - /// - /// Delete a property - /// In our case this simply mean defining it as null - /// - /// Name of the property to remove - /// Configuration for which to remove the property - /// Project or user file (_PersistStorageType) - /// HRESULT - int IVsBuildPropertyStorage.RemoveProperty(string propertyName, string configName, uint storage) - { - return ((IVsBuildPropertyStorage)this).SetPropertyValue(propertyName, configName, storage, null); - } - - /// - /// Set a property on an item - /// - /// ItemID - /// Name of the property - /// New value for the property - /// HRESULT - int IVsBuildPropertyStorage.SetItemAttribute(uint item, string attributeName, string attributeValue) - { - HierarchyNode node = NodeFromItemId(item); - - if (node == null) - throw new ArgumentException("Invalid item id", "item"); - - node.ItemNode.SetMetadata(attributeName, attributeValue); - return VSConstants.S_OK; - } - - /// - /// Set a project property - /// - /// Name of the property to set - /// Configuration for which to set the property - /// Project file or user file (_PersistStorageType) - /// New value for that property - /// HRESULT - int IVsBuildPropertyStorage.SetPropertyValue(string propertyName, string configName, uint storage, string propertyValue) - { - // TODO: when adding support for User files, we need to update this method - if (string.IsNullOrEmpty(configName)) - { - this.SetProjectProperty(propertyName, propertyValue); - } - else - { - IVsCfg configurationInterface; - ErrorHandler.ThrowOnFailure(this.ConfigProvider.GetCfgOfName(configName, string.Empty, out configurationInterface)); - ProjectConfig config = (ProjectConfig)configurationInterface; - config.SetConfigurationProperty(propertyName, propertyValue); - } - return VSConstants.S_OK; - } - - #endregion - - #region IVsDesignTimeAssemblyResolution methods - - public int GetTargetFramework(out string ppTargetFramework) - { - ppTargetFramework = this.ProjectMgr.TargetFrameworkMoniker.FullName; - return VSConstants.S_OK; - } - - public int ResolveAssemblyPathInTargetFx(string[] prgAssemblySpecs, uint cAssembliesToResolve, VsResolvedAssemblyPath[] prgResolvedAssemblyPaths, out uint pcResolvedAssemblyPaths) - { - if (prgAssemblySpecs == null || cAssembliesToResolve == 0 || prgResolvedAssemblyPaths == null) - { - throw new ArgumentException("One or more of the arguments are invalid."); - } - - pcResolvedAssemblyPaths = 0; - - try - { - var results = designTimeAssemblyResolution.Resolve(prgAssemblySpecs.Take((int)cAssembliesToResolve)); - results.CopyTo(prgResolvedAssemblyPaths, 0); - pcResolvedAssemblyPaths = (uint)results.Length; - } - catch (Exception ex) - { - return Marshal.GetHRForException(ex); - } - - return VSConstants.S_OK; - } - - #endregion - - #region private helper methods - - /// - /// Initialize projectNode - /// - private void Initialize() - { - this.ID = VSConstants.VSITEMID_ROOT; - this.tracker = new TrackDocumentsHelper(this); - } - - /// - /// Add an item to the hierarchy based on the item path - /// - /// Item to add - /// Added node - private HierarchyNode AddIndependentFileNode(MSBuild.ProjectItem item) - { - HierarchyNode currentParent = GetItemParentNode(item); - return AddFileNodeToNode(item, currentParent); - } - - /// - /// Add a dependent file node to the hierarchy - /// - /// msbuild item to add - /// Parent Node - /// Added node - private HierarchyNode AddDependentFileNodeToNode(MSBuild.ProjectItem item, HierarchyNode parentNode) - { - FileNode node = this.CreateDependentFileNode(new ProjectElement(this, item, false)); - parentNode.AddChild(node); - - // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name - if (!node.HasParentNodeNameRelation && string.Compare(node.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0) - { - node.HasParentNodeNameRelation = true; - } - - return node; - } - - /// - /// Add a file node to the hierarchy - /// - /// msbuild item to add - /// Parent Node - /// Added node - private HierarchyNode AddFileNodeToNode(MSBuild.ProjectItem item, HierarchyNode parentNode) - { - FileNode node = this.CreateFileNode(new ProjectElement(this, item, false)); - parentNode.AddChild(node); - return node; - } - - /// - /// Get the parent node of an msbuild item - /// - /// msbuild item - /// parent node - private HierarchyNode GetItemParentNode(MSBuild.ProjectItem item) - { - HierarchyNode currentParent = this; - string strPath; - - // !EFW - // If it's a link, use the linked path for the node - strPath = item.GetMetadataValue(ProjectFileConstants.Link); - - if(String.IsNullOrEmpty(strPath)) - strPath = item.EvaluatedInclude; - - strPath = Path.GetDirectoryName(strPath); - if(strPath.Length > 0) - { - // Use the relative to verify the folders... - currentParent = this.CreateFolderNodes(strPath); - } - return currentParent; - } - - private MSBuildExecution.ProjectPropertyInstance GetMsBuildProperty(string propertyName, bool resetCache) - { - if (resetCache || this.currentConfig == null) - { - // Get properties from project file and cache it - this.SetCurrentConfiguration(); - this.currentConfig = this.buildProject.CreateProjectInstance(); - } - - if (this.currentConfig == null) - throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.FailedToRetrieveProperties, CultureInfo.CurrentUICulture), propertyName)); - - // return property asked for - return this.currentConfig.GetProperty(propertyName); - } - - private string GetOutputPath(MSBuildExecution.ProjectInstance properties) - { - this.currentConfig = properties; - string outputPath = GetProjectProperty("OutputPath"); - - if (!String.IsNullOrEmpty(outputPath)) - { - outputPath = outputPath.Replace('/', Path.DirectorySeparatorChar); - if (outputPath[outputPath.Length - 1] != Path.DirectorySeparatorChar) - outputPath += Path.DirectorySeparatorChar; - } - - return outputPath; - } - - private bool GetBoolAttr(MSBuildExecution.ProjectInstance properties, string name) - { - this.currentConfig = properties; - string s = GetProjectProperty(name); - - return (s != null && s.ToUpperInvariant().Trim() == "TRUE"); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] - private string GetAssemblyName(MSBuildExecution.ProjectInstance properties) - { - this.currentConfig = properties; - string name = null; - - name = GetProjectProperty(ProjectFileConstants.AssemblyName); - if (name == null) - name = this.Caption; - - string outputtype = GetProjectProperty(ProjectFileConstants.OutputType, false); - - if (outputtype == "library") - { - outputtype = outputtype.ToLowerInvariant(); - name += ".dll"; - } - else - { - name += ".exe"; - } - - return name; - } - - /// - /// Updates our scc project settings. - /// - /// String, opaque to the project, that identifies the project location on the server. Persist this string in the project file. - /// String, opaque to the project, that identifies the path to the server. Persist this string in the project file. - /// String, opaque to the project, that identifies the local path to the project. Persist this string in the project file. - /// String, opaque to the project, that identifies the source control package. Persist this string in the project file. - /// Returns true if something changed. - private bool SetSccSettings(string sccProjectName, string sccLocalPath, string sccAuxPath, string sccProvider) - { - bool changed = false; - Debug.Assert(sccProjectName != null && sccLocalPath != null && sccAuxPath != null && sccProvider != null); - if (String.Compare(sccProjectName, this.sccProjectName, StringComparison.OrdinalIgnoreCase) != 0 || - String.Compare(sccLocalPath, this.sccLocalPath, StringComparison.OrdinalIgnoreCase) != 0 || - String.Compare(sccAuxPath, this.sccAuxPath, StringComparison.OrdinalIgnoreCase) != 0 || - String.Compare(sccProvider, this.sccProvider, StringComparison.OrdinalIgnoreCase) != 0) - { - changed = true; - this.sccProjectName = sccProjectName; - this.sccLocalPath = sccLocalPath; - this.sccAuxPath = sccAuxPath; - this.sccProvider = sccProvider; - } - - - return changed; - } - - /// - /// Sets the scc info from the project file. - /// - private void InitSccInfo() - { - this.sccProjectName = this.GetProjectProperty(ProjectFileConstants.SccProjectName); - this.sccLocalPath = this.GetProjectProperty(ProjectFileConstants.SccLocalPath); - this.sccProvider = this.GetProjectProperty(ProjectFileConstants.SccProvider); - this.sccAuxPath = this.GetProjectProperty(ProjectFileConstants.SccAuxPath); - } - - private void OnAfterProjectOpen(object sender, AfterProjectFileOpenedEventArgs e) - { - this.projectOpened = true; - } - - private static XmlElement WrapXmlFragment(XmlDocument document, XmlElement root, Guid flavor, string configuration, string fragment) - { - XmlElement node = document.CreateElement(ProjectFileConstants.FlavorProperties); - XmlAttribute attribute = document.CreateAttribute(ProjectFileConstants.Guid); - attribute.Value = flavor.ToString("B"); - node.Attributes.Append(attribute); - if (!String.IsNullOrEmpty(configuration)) - { - attribute = document.CreateAttribute(ProjectFileConstants.Configuration); - attribute.Value = configuration; - node.Attributes.Append(attribute); - } - node.InnerXml = fragment; - root.AppendChild(node); - return node; - } - - /// - /// Sets the project guid from the project file. If no guid is found a new one is created and assigne for the instance project guid. - /// - private void SetProjectGuidFromProjectFile() - { - string projectGuid = this.GetProjectProperty(ProjectFileConstants.ProjectGuid); - if (String.IsNullOrEmpty(projectGuid)) - { - this.projectIdGuid = Guid.NewGuid(); - } - else - { - Guid guid = new Guid(projectGuid); - if (guid != this.projectIdGuid) - { - this.projectIdGuid = guid; - } - } - } - - /// - /// Helper for sharing common code between Build() and BuildAsync() - /// - /// - /// - private bool BuildPrelude(IVsOutputWindowPane output) - { - bool engineLogOnlyCritical = false; - // If there is some output, then we can ask the build engine to log more than - // just the critical events. - if (null != output) - { - engineLogOnlyCritical = BuildEngine.OnlyLogCriticalEvents; - BuildEngine.OnlyLogCriticalEvents = false; - } - - this.SetOutputLogger(output); - return engineLogOnlyCritical; - } - - /// - /// Recusively parses the tree and closes all nodes. - /// - /// The subtree to close. - private static void CloseAllNodes(HierarchyNode node) - { - for (HierarchyNode n = node.FirstChild; n != null; n = n.NextSibling) - { - if (n.FirstChild != null) - { - CloseAllNodes(n); - } - - n.Close(); - } - } - - /// - /// Set the build project with the new project instance value - /// - /// The new build project instance - private void SetBuildProject(MSBuild.Project project) - { - this.buildProject = project; - if (this.buildProject != null) - { - SetupProjectGlobalPropertiesThatAllProjectSystemsMustSet(); - } - } - - /// - /// Setup the global properties for project instance. - /// - private void SetupProjectGlobalPropertiesThatAllProjectSystemsMustSet() - { - string solutionDirectory = null; - string solutionFile = null; - string userOptionsFile = null; - - IVsSolution solution = this.Site.GetService(typeof(SVsSolution)) as IVsSolution; - if (solution != null) - { - // We do not want to throw. If we cannot set the solution related constants we set them to empty string. - solution.GetSolutionInfo(out solutionDirectory, out solutionFile, out userOptionsFile); - } - - if (solutionDirectory == null) - { - solutionDirectory = String.Empty; - } - - if (solutionFile == null) - { - solutionFile = String.Empty; - } - - string solutionFileName = (solutionFile.Length == 0) ? String.Empty : Path.GetFileName(solutionFile); - - string solutionName = (solutionFile.Length == 0) ? String.Empty : Path.GetFileNameWithoutExtension(solutionFile); - - string solutionExtension = String.Empty; - if (solutionFile.Length > 0 && Path.HasExtension(solutionFile)) - { - solutionExtension = Path.GetExtension(solutionFile); - } - - this.buildProject.SetGlobalProperty(GlobalProperty.SolutionDir.ToString(), solutionDirectory); - this.buildProject.SetGlobalProperty(GlobalProperty.SolutionPath.ToString(), solutionFile); - this.buildProject.SetGlobalProperty(GlobalProperty.SolutionFileName.ToString(), solutionFileName); - this.buildProject.SetGlobalProperty(GlobalProperty.SolutionName.ToString(), solutionName); - this.buildProject.SetGlobalProperty(GlobalProperty.SolutionExt.ToString(), solutionExtension); - - // Other misc properties - this.buildProject.SetGlobalProperty(GlobalProperty.BuildingInsideVisualStudio.ToString(), "true"); - this.buildProject.SetGlobalProperty(GlobalProperty.Configuration.ToString(), ProjectConfig.Debug); - this.buildProject.SetGlobalProperty(GlobalProperty.Platform.ToString(), ProjectConfig.AnyCPU); - - // DevEnvDir property - object installDirAsObject = null; - - IVsShell shell = this.Site.GetService(typeof(SVsShell)) as IVsShell; - if (shell != null) - { - // We do not want to throw. If we cannot set the solution related constants we set them to empty string. - shell.GetProperty((int)__VSSPROPID.VSSPROPID_InstallDirectory, out installDirAsObject); - } - - string installDir = ((string)installDirAsObject); - - if (String.IsNullOrEmpty(installDir)) - { - installDir = String.Empty; - } - else - { - // Ensure that we have traimnling backslash as this is done for the langproj macros too. - if (installDir[installDir.Length - 1] != Path.DirectorySeparatorChar) - { - installDir += Path.DirectorySeparatorChar; - } - } - - this.buildProject.SetGlobalProperty(GlobalProperty.DevEnvDir.ToString(), installDir); - } - - /// - /// Attempts to lock in the privilege of running a build in Visual Studio. - /// - /// false if this build was called for by the Solution Build Manager; true otherwise. - /// - /// Need to claim the UI thread for build under the following conditions: - /// 1. The build must use a resource that uses the UI thread, such as - /// - you set HostServices and you have a host object which requires (even indirectly) the UI thread (VB and C# compilers do this for instance.) - /// or, - /// 2. The build requires the in-proc node AND waits on the UI thread for the build to complete, such as: - /// - you use a ProjectInstance to build, or - /// - you have specified a host object, whether or not it requires the UI thread, or - /// - you set HostServices and you have specified a node affinity. - /// - In addition to the above you also call submission.Execute(), or you call submission.ExecuteAsync() and then also submission.WaitHandle.Wait*(). - /// - /// A value indicating whether a build may proceed. - /// - /// This method must be called on the UI thread. - /// - private bool TryBeginBuild(bool designTime, bool requiresUIThread = false) - { - IVsBuildManagerAccessor accessor = null; - - if (this.Site != null) - { - accessor = this.Site.GetService(typeof(SVsBuildManagerAccessor)) as IVsBuildManagerAccessor; - } - - bool releaseUIThread = false; - - try - { - // If the SVsBuildManagerAccessor service is absent, we're not running within Visual Studio. - if (accessor != null) - { - if (requiresUIThread) - { - int result = accessor.ClaimUIThreadForBuild(); - if (result < 0) - { - // Not allowed to claim the UI thread right now. Try again later. - return false; - } - - releaseUIThread = true; // assume we need to release this immediately until we get through the whole gauntlet. - } - - if (designTime) - { - int result = accessor.BeginDesignTimeBuild(); - if (result < 0) - { - // Not allowed to begin a design-time build at this time. Try again later. - return false; - } - } - - // We obtained all the resources we need. So don't release the UI thread until after the build is finished. - releaseUIThread = false; - } - else - { - BuildParameters buildParameters = new BuildParameters(this.buildEngine ?? ProjectCollection.GlobalProjectCollection); - BuildManager.DefaultBuildManager.BeginBuild(buildParameters); - } - - this.buildInProcess = true; - return true; - } - finally - { - // If we were denied the privilege of starting a design-time build, - // we need to release the UI thread. - if (releaseUIThread) - { - Debug.Assert(accessor != null, "We think we need to release the UI thread for an accessor we don't have!"); - Marshal.ThrowExceptionForHR(accessor.ReleaseUIThreadForBuild()); - } - } - } - - /// - /// Lets Visual Studio know that we're done with our design-time build so others can use the build manager. - /// - /// The build submission that built, if any. - /// This must be the same value as the one passed to . - /// This must be the same value as the one passed to . - /// - /// This method must be called on the UI thread. - /// - private void EndBuild(BuildSubmission submission, bool designTime, bool requiresUIThread = false) - { - IVsBuildManagerAccessor accessor = null; - - if (this.Site != null) - { - accessor = this.Site.GetService(typeof(SVsBuildManagerAccessor)) as IVsBuildManagerAccessor; - } - - if (accessor != null) - { - // It's very important that we try executing all three end-build steps, even if errors occur partway through. - try - { - if (submission != null) - { - Marshal.ThrowExceptionForHR(accessor.UnregisterLoggers(submission.SubmissionId)); - } - } - catch (Exception ex) - { - if (ErrorHandler.IsCriticalException(ex)) - { - throw; - } - - Trace.TraceError(ex.ToString()); - } - - try - { - if (designTime) - { - Marshal.ThrowExceptionForHR(accessor.EndDesignTimeBuild()); - } - } - catch (Exception ex) - { - if (ErrorHandler.IsCriticalException(ex)) - { - throw; - } - - Trace.TraceError(ex.ToString()); - } - - - try - { - if (requiresUIThread) - { - Marshal.ThrowExceptionForHR(accessor.ReleaseUIThreadForBuild()); - } - } - catch (Exception ex) - { - if (ErrorHandler.IsCriticalException(ex)) - { - throw; - } - - Trace.TraceError(ex.ToString()); - } - } - else - { - BuildManager.DefaultBuildManager.EndBuild(); - } - - this.buildInProcess = false; - } - - private string GetComponentPickerDirectories() - { - IVsComponentEnumeratorFactory4 enumFactory = this.site.GetService(typeof(SCompEnumService)) as IVsComponentEnumeratorFactory4; - if (enumFactory == null) - { - throw new InvalidOperationException("Missing the SCompEnumService service."); - } - - IEnumComponents enumerator; - Marshal.ThrowExceptionForHR(enumFactory.GetReferencePathsForTargetFramework(this.TargetFrameworkMoniker.FullName, out enumerator)); - if (enumerator == null) - { - throw new ApplicationException("IVsComponentEnumeratorFactory4.GetReferencePathsForTargetFramework returned null."); - } - - StringBuilder paths = new StringBuilder(); - VSCOMPONENTSELECTORDATA[] data = new VSCOMPONENTSELECTORDATA[1]; - uint fetchedCount; - while (enumerator.Next(1, data, out fetchedCount) == VSConstants.S_OK && fetchedCount == 1) - { - Debug.Assert(data[0].type == VSCOMPONENTTYPE.VSCOMPONENTTYPE_Path); - paths.Append(data[0].bstrFile); - paths.Append(";"); - } - - // Trim off the last semicolon. - if (paths.Length > 0) - { - paths.Length -= 1; - } - - return paths.ToString(); - } - - #endregion - - #region Upgrade and retargeting members - //===================================================================== - - public int UpdateTargetFramework(IVsHierarchy pHier, string currentTargetFramework, string newTargetFramework) - { - FrameworkName moniker = new FrameworkName(newTargetFramework); - SetProjectProperty("TargetFrameworkIdentifier", moniker.Identifier); - SetProjectProperty("TargetFrameworkVersion", "v" + moniker.Version); - SetProjectProperty("TargetFrameworkProfile", moniker.Profile); - return VSConstants.S_OK; - } - - // !EFW - This should be virtual so that we can override it and handle project upgrade tasks - /// - /// Handle project upgrades - /// - /// The upgrade flags - /// S_OK if successful or no upgrade needed; otherwise, an error code. - public virtual int UpgradeProject(uint grfUpgradeFlags) - { - int hr = VSConstants.S_OK; - - if (!PerformTargetFrameworkCheck()) - { - // Just return OLE_E_PROMPTSAVECANCELLED here which will cause the shell - // to leave the project in an unloaded state. - hr = VSConstants.OLE_E_PROMPTSAVECANCELLED; - } - - return hr; - } - - private bool PerformTargetFrameworkCheck() - { - if (this.IsFrameworkOnMachine()) - { - // Nothing to do since the framework is present. - return true; - } - - return ShowRetargetingDialog(); - } - - /// - /// - /// - /// - /// true if the project will be retargeted. false to load project in unloaded state. - /// - private bool ShowRetargetingDialog() - { - var retargetDialog = this.site.GetService(typeof(SVsFrameworkRetargetingDlg)) as IVsFrameworkRetargetingDlg; - if (retargetDialog == null) - { - throw new InvalidOperationException("Missing SVsFrameworkRetargetingDlg service."); - } - - // We can only display the retargeting dialog if the IDE is not in command-line mode. - if (IsIdeInCommandLineMode) - { - string message = SR.GetString(SR.CannotLoadUnknownTargetFrameworkProject, this.FileName, this.TargetFrameworkMoniker); - var outputWindow = this.site.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; - if (outputWindow != null) - { - IVsOutputWindowPane outputPane; - Guid outputPaneGuid = VSConstants.GUID_BuildOutputWindowPane; - if (outputWindow.GetPane(ref outputPaneGuid, out outputPane) >= 0 && outputPane != null) - { - Marshal.ThrowExceptionForHR(outputPane.OutputString(message)); - } - } - - throw new InvalidOperationException(message); - } - else - { - uint outcome; - int dontShowAgain; - Marshal.ThrowExceptionForHR(retargetDialog.ShowFrameworkRetargetingDlg( - this.Package.ProductUserContext, - this.FileName, - this.TargetFrameworkMoniker.FullName, - (uint)__FRD_FLAGS.FRDF_DEFAULT, - out outcome, - out dontShowAgain)); - switch ((__FRD_OUTCOME)outcome) - { - case __FRD_OUTCOME.FRDO_GOTO_DOWNLOAD_SITE: - Marshal.ThrowExceptionForHR(retargetDialog.NavigateToFrameworkDownloadUrl()); - return false; - case __FRD_OUTCOME.FRDO_LEAVE_UNLOADED: - return false; - case __FRD_OUTCOME.FRDO_RETARGET_TO_40: - // If we are retargeting to 4.0, then set the flag to set the appropriate Target Framework. - // This will dirty the project file, so we check it out of source control now -- so that - // the user can associate getting the checkout prompt with the "No Framework" dialog. - if (QueryEditProjectFile(false /* bSuppressUI */)) - { - var retargetingService = this.site.GetService(typeof(SVsTrackProjectRetargeting)) as IVsTrackProjectRetargeting; - if (retargetingService != null) - { - // We surround our batch retargeting request with begin/end because in individual project load - // scenarios the solution load context hasn't done it for us. - Marshal.ThrowExceptionForHR(retargetingService.BeginRetargetingBatch()); - Marshal.ThrowExceptionForHR(retargetingService.BatchRetargetProject(this.InteropSafeIVsHierarchy, DefaultTargetFrameworkMoniker.FullName, true)); - Marshal.ThrowExceptionForHR(retargetingService.EndRetargetingBatch()); - } - else - { - // Just setting the moniker to null will allow the default framework (.NETFX 4.0) to assert itself. - this.TargetFrameworkMoniker = null; - } - - return true; - } - else - { - return false; - } - default: - throw new ArgumentException("Unexpected outcome from retargeting dialog."); - } - } - } - - private bool IsFrameworkOnMachine() - { - var multiTargeting = this.site.GetService(typeof(SVsFrameworkMultiTargeting)) as IVsFrameworkMultiTargeting; - Array frameworks; - Marshal.ThrowExceptionForHR(multiTargeting.GetSupportedFrameworks(out frameworks)); - foreach (string fx in frameworks) - { - uint compat; - int hr = multiTargeting.CheckFrameworkCompatibility(this.TargetFrameworkMoniker.FullName, fx, out compat); - if (hr < 0) - { - break; - } - - if ((__VSFRAMEWORKCOMPATIBILITY)compat == __VSFRAMEWORKCOMPATIBILITY.VSFRAMEWORKCOMPATIBILITY_COMPATIBLE) - { - return true; - } - } - - return false; - } - #endregion - - // !EFW - #region Core Show All Files/Refresh support - //===================================================================== - - // Core functionality implemented in the ProjectNode.cs: - // - Added ShowingAllFiles property. - // - Updated the ShowAllFiles() method to call ToggleShowAllFiles(). - // - Added RefreshProject() method. - - // Additional functionality not implemented in ProjectNode.cs (handle in derived class): - // - Override ShowAllFiles() to persist toggle state if so desired. - // - Override Reload() to restore the toggle state if so desired. - // - Override IsItemTypeFileType() if necessary to handle custom file item types. - - /// - /// Refresh the project by toggling the Show All Files state - /// - public void RefreshProject() - { - this.ToggleShowAllFiles(); - this.ToggleShowAllFiles(); - } - - /// - /// Toggles the state of Show All Files - /// - /// S_OK if it is possible to toggle the state, OLECMDERR_E_NOTSUPPORTED if not - protected internal int ToggleShowAllFiles() - { - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - - this.ShowingAllFiles = !this.ShowingAllFiles; - - // Set the wait cursor as this may take a while if there are a lot of files - IVsUIShell shell = (IVsUIShell)((System.IServiceProvider)package).GetService(typeof(SVsUIShell)); - - if(shell != null) - shell.SetWaitCursor(); - - if(!this.ShowingAllFiles) - { - // Find all non-member items and reverse the list so that we remove children first - // followed by their parent nodes. - foreach(var n in HierarchyNode.FindNodes(this, n => n.IsNonMemberItem).Reverse()) - { - n.OnItemDeleted(); - n.Parent.RemoveChild(n); - } - } - else - { - this.AddMissingProjectMembers(); - this.AddNonMemberItems(); - } - - return NativeMethods.S_OK; - } - - /// - /// Add non-member items to the hierarchy - /// - private void AddNonMemberItems() - { - string path; - - // Get a list of the folders and files in the project folder excluding those that - // are hidden. Hash sets are used so that we can do case-insensitive comparisons - // when excluding existing project items from the lists. - HashSet folders = new HashSet(Directory.EnumerateDirectories( - this.ProjectFolder, "*", SearchOption.AllDirectories).Where(p => - { - DirectoryInfo di = new DirectoryInfo(p); - - return !((di.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden); - }).Select(p => PackageUtilities.MakeRelative(this.ProjectFolder, p)), - StringComparer.OrdinalIgnoreCase); - - HashSet files = new HashSet(Directory.EnumerateFiles( - this.ProjectFolder, "*", SearchOption.AllDirectories).Where(f => - { - FileInfo fi = new FileInfo(f); - - return !((fi.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden); - }).Select(f => PackageUtilities.MakeRelative(this.ProjectFolder, f)), - StringComparer.OrdinalIgnoreCase); - - // Remove the folders and files that are already in the project - foreach(Microsoft.Build.Evaluation.ProjectItem item in this.BuildProject.Items) - if(folders.Count != 0 && item.ItemType.Equals(ProjectFileConstants.Folder, - StringComparison.OrdinalIgnoreCase)) - { - path = item.EvaluatedInclude; - - // It should be relative already but check it just in case - if(Path.IsPathRooted(path)) - path = PackageUtilities.MakeRelative(this.ProjectFolder, path); - - if(folders.Contains(path)) - folders.Remove(path); - } - else - if(files.Count != 0 && this.IsItemTypeFileType(item.ItemType)) - { - path = item.EvaluatedInclude; - - // It should be relative already but check it just in case - if(Path.IsPathRooted(path)) - path = PackageUtilities.MakeRelative(this.ProjectFolder, path); - - if(files.Contains(path)) - files.Remove(path); - } - - // Add the remaining items to the project - this.AddNonMemberFolderItems(folders); - this.AddNonMemberFileItems(files); - } - - /// - /// Add non-member folder items to the hierarchy - /// - /// An enumerable list of the folders to add - private void AddNonMemberFolderItems(IEnumerable foldersToAdd) - { - IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.Site, SolutionExplorer); - HierarchyNode parent, child, first; - string[] pathParts; - string childId; - - foreach(string relativePath in foldersToAdd) - { - parent = this; - first = null; - pathParts = relativePath.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); - - // Add folder items for each part of the path - foreach(string name in pathParts) - { - childId = Path.Combine(parent.VirtualNodeName, name); - child = parent.FindChild(childId); - - if(child == null) - { - // Note the first folder so that we can collapse it when done if necessary - if(first == null) - { - first = parent as FolderNode; - - if(first != null && !first.IsNonMemberItem && first.IsExpanded) - first = null; - } - - child = this.CreateFolderNode(childId, new ProjectElement(this, null, true)); - child.IsNonMemberItem = true; - parent.AddChild(child); - } - - parent = child; - } - - if(first != null && uiWindow != null) - { - first.IsExpanded = false; - first.SetProperty((int)__VSHPROPID.VSHPROPID_Expanded, false); - ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this, first.ID, EXPANDFLAGS.EXPF_CollapseFolder)); - } - } - } - - /// - /// Add non-member file items to the hierarchy - /// - /// An enumerable list of the files to add - private void AddNonMemberFileItems(IEnumerable filesToAdd) - { - IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.Site, SolutionExplorer); - HierarchyNode parent, child, first; - ProjectElement element; - string[] pathParts; - string childId; - - foreach(string relativePath in filesToAdd) - { - // TODO: Probably should exclude the .user file too. Any others? - // Don't add the project file itself - if(String.Equals(relativePath, this.ProjectFile, StringComparison.OrdinalIgnoreCase)) - continue; - - parent = this; - first = null; - pathParts = relativePath.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); - - // Find the parent folder item - foreach(string name in pathParts) - { - childId = Path.Combine(parent.VirtualNodeName, name); - child = parent.FindChild(childId); - - if(child == null) - { - // Note the first folder so that we can collapse it when done if necessary - if(first == null) - { - first = parent as FolderNode; - - if(first != null && !first.IsNonMemberItem && first.IsExpanded) - first = null; - } - - element = new ProjectElement(this, null, true); - element.Rename(childId); - element.SetMetadata(ProjectFileConstants.Name, childId); - child = this.CreateFileNode(element); - child.IsNonMemberItem = true; - parent.AddChild(child); - break; - } - - parent = child; - } - - if(first != null) - { - first.IsExpanded = false; - first.SetProperty((int)__VSHPROPID.VSHPROPID_Expanded, false); - ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this, first.ID, EXPANDFLAGS.EXPF_CollapseFolder)); - } - } - } - - /// - /// This will scan the project looking for file items that don't exist in the hierarchy. - /// If any are found, they are added as proper hierarchy members. - /// - /// This is similar to but it filters out items - /// already in the hierarchy. - private void AddMissingProjectMembers() - { - List subitemsKeys = new List(); - Dictionary subitems = new Dictionary(); - HashSet items = new HashSet(); - string fullPath; - - foreach(MSBuild.ProjectItem item in this.buildProject.Items.ToList()) - { - // Ignore the item if it is a reference or folder - if (this.FilterItemTypeToBeAddedToHierarchy(item.ItemType)) - continue; - - // MSBuilds tasks/targets can create items (such as object files), such items are not part - // of the project per se, and should not be displayed so ignore those items. - if(!this.IsItemTypeFileType(item.ItemType)) - continue; - - fullPath = item.EvaluatedInclude; - - if(!Path.IsPathRooted(fullPath)) - fullPath = Path.Combine(this.ProjectFolder, fullPath); - - // If the item is already contained do nothing - if(items.Contains(item.EvaluatedInclude.ToUpperInvariant()) || - base.FindChild(fullPath) != null) - continue; - - // Make sure that we do not want to add the item, dependent, or independent twice to - // the UI hierarchy. - items.Add(item.EvaluatedInclude.ToUpperInvariant()); - - string dependentOf = item.GetMetadataValue(ProjectFileConstants.DependentUpon); - - if(!this.CanFileNodesHaveChilds || String.IsNullOrEmpty(dependentOf)) - this.AddIndependentFileNode(item); - else - { - // We will process dependent items later. Note that we use 2 lists as we want to - // remove elements from the collection as we loop through it. - subitemsKeys.Add(item.EvaluatedInclude); - subitems.Add(item.EvaluatedInclude, item); - } - } - - // Now process the dependent items - if(this.CanFileNodesHaveChilds) - this.ProcessDependentFileNodes(subitemsKeys, subitems); - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectOptions.cs b/SHFB/Source/MPFProj_VS2010/ProjectOptions.cs deleted file mode 100644 index acf32126..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectOptions.cs +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System.Collections.Specialized; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.Versioning; - -namespace Microsoft.VisualStudio.Project -{ - public class ProjectOptions : System.CodeDom.Compiler.CompilerParameters - { - public string Config { get; set; } - - public ModuleKindFlags ModuleKind { get; set; } - - public bool EmitManifest { get; set; } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public StringCollection DefinedPreprocessorSymbols { get; set; } - - public string XmlDocFileName { get; set; } - - public string RecursiveWildcard { get; set; } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public StringCollection ReferencedModules { get; set; } - - public string Win32Icon { get; set; } - - public bool PdbOnly { get; set; } - - public bool Optimize { get; set; } - - public bool IncrementalCompile { get; set; } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public int[] SuppressedWarnings { get; set; } - - public bool CheckedArithmetic { get; set; } - - public bool AllowUnsafeCode { get; set; } - - public bool DisplayCommandLineHelp { get; set; } - - public bool SuppressLogo { get; set; } - - public long BaseAddress { get; set; } - - public string BugReportFileName { get; set; } - - /// must be an int if not null - public object CodePage { get; set; } - - public bool EncodeOutputInUtf8 { get; set; } - - public bool FullyQualifyPaths { get; set; } - - public int FileAlignment { get; set; } - - public bool NoStandardLibrary { get; set; } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public StringCollection AdditionalSearchPaths { get; set; } - - public bool HeuristicReferenceResolution { get; set; } - - public string RootNamespace { get; set; } - - public bool CompileAndExecute { get; set; } - - /// must be an int if not null. - public object UserLocaleId { get; set; } - - public FrameworkName TargetFrameworkMoniker { get; set; } - - public ProjectOptions() - { - EmitManifest = true; - ModuleKind = ModuleKindFlags.ConsoleApplication; - } - - public virtual string GetOptionHelp() - { - return null; - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectPackage.cs b/SHFB/Source/MPFProj_VS2010/ProjectPackage.cs deleted file mode 100644 index 1fa3c731..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectPackage.cs +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Defines abstract package. - /// - [ComVisible(true)] - [CLSCompliant(false)] - public abstract class ProjectPackage : Microsoft.VisualStudio.Shell.Package - { - #region fields - /// - /// This is the place to register all the solution listeners. - /// - private List solutionListeners = new List(); - #endregion - - #region properties - /// - /// Add your listener to this list. They should be added in the overridden Initialize befaore calling the base. - /// - protected internal IList SolutionListeners - { - get - { - return this.solutionListeners; - } - } - - public abstract string ProductUserContext { get; } - - #endregion - - #region methods - protected override void Initialize() - { - base.Initialize(); - - // Subscribe to the solution events - this.solutionListeners.Add(new SolutionListenerForProjectReferenceUpdate(this)); - this.solutionListeners.Add(new SolutionListenerForProjectOpen(this)); - this.solutionListeners.Add(new SolutionListenerForBuildDependencyUpdate(this)); - this.solutionListeners.Add(new SolutionListenerForProjectEvents(this)); - - foreach(SolutionListener solutionListener in this.solutionListeners) - { - solutionListener.Init(); - } - } - - protected override void Dispose(bool disposing) - { - // Unadvise solution listeners. - try - { - if(disposing) - { - foreach(SolutionListener solutionListener in this.solutionListeners) - { - solutionListener.Dispose(); - } - - // Dispose the UIThread singleton. - UIThread.Instance.Dispose(); - } - } - finally - { - - base.Dispose(disposing); - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ProjectReferenceNode.cs b/SHFB/Source/MPFProj_VS2010/ProjectReferenceNode.cs deleted file mode 100644 index 375d80c9..00000000 --- a/SHFB/Source/MPFProj_VS2010/ProjectReferenceNode.cs +++ /dev/null @@ -1,594 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//=============================================================================================================== -// File : ProjectReferenceNode.cs -// Updated : 12/29/2013 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// Search for "!EFW" to find the changes -// -// Date Who Comments -// ============================================================================================================== -// 12/29/2013 EFW Added support for ReferenceOutputAssembly metadata -//=============================================================================================================== - -using System; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; - -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false), ComVisible(true)] - public class ProjectReferenceNode : ReferenceNode - { - #region fields - /// - /// The name of the assembly this reference represents - /// - private Guid referencedProjectGuid; - - private string referencedProjectName = String.Empty; - - private string referencedProjectRelativePath = String.Empty; - - private string referencedProjectFullPath = String.Empty; - - private BuildDependency buildDependency; - - /// - /// This is a reference to the automation object for the referenced project. - /// - private EnvDTE.Project referencedProject; - - /// - /// This state is controlled by the solution events. - /// The state is set to false by OnBeforeUnloadProject. - /// The state is set to true by OnBeforeCloseProject event. - /// - private bool canRemoveReference = true; - - /// - /// Possibility for solution listener to update the state on the dangling reference. - /// It will be set in OnBeforeUnloadProject then the node is invalidated then it is reset to false. - /// - private bool isNodeValid; - - #endregion - - #region properties - - public override string Url - { - get - { - return this.referencedProjectFullPath; - } - } - - public override string Caption - { - get - { - return this.referencedProjectName; - } - } - - internal Guid ReferencedProjectGuid - { - get - { - return this.referencedProjectGuid; - } - } - - /// - /// Possibility to shortcut and set the dangling project reference icon. - /// It is usually manipulated by solution listeners who handle reference updates. - /// - internal protected bool IsNodeValid - { - get - { - return this.isNodeValid; - } - set - { - this.isNodeValid = value; - } - } - - /// - /// Controls the state whether this reference can be removed or not. Think of the project unload scenario where the project reference should not be deleted. - /// - internal bool CanRemoveReference - { - get - { - return this.canRemoveReference; - } - set - { - this.canRemoveReference = value; - } - } - - internal string ReferencedProjectName - { - get { return this.referencedProjectName; } - } - - /// - /// Gets the automation object for the referenced project. - /// - internal EnvDTE.Project ReferencedProjectObject - { - get - { - // If the referenced project is null then re-read. - if (this.referencedProject == null) - { - - // Search for the project in the collection of the projects in the - // current solution. - EnvDTE.DTE dte = (EnvDTE.DTE)this.ProjectMgr.GetService(typeof(EnvDTE.DTE)); - if ((null == dte) || (null == dte.Solution)) - { - return null; - } - foreach (EnvDTE.Project prj in dte.Solution.Projects) - { - //Skip this project if it is an unmodeled project (unloaded) - if (string.Compare(EnvDTE.Constants.vsProjectKindUnmodeled, prj.Kind, StringComparison.OrdinalIgnoreCase) == 0) - { - continue; - } - - // Get the full path of the current project. - EnvDTE.Property pathProperty = null; - try - { - if (prj.Properties == null) - { - continue; - } - - pathProperty = prj.Properties.Item("FullPath"); - if (null == pathProperty) - { - // The full path should alway be available, but if this is not the - // case then we have to skip it. - continue; - } - } - catch (ArgumentException) - { - continue; - } - string prjPath = pathProperty.Value.ToString(); - EnvDTE.Property fileNameProperty = null; - // Get the name of the project file. - try - { - fileNameProperty = prj.Properties.Item("FileName"); - if (null == fileNameProperty) - { - // Again, this should never be the case, but we handle it anyway. - continue; - } - } - catch (ArgumentException) - { - continue; - } - prjPath = System.IO.Path.Combine(prjPath, fileNameProperty.Value.ToString()); - - // If the full path of this project is the same as the one of this - // reference, then we have found the right project. - if (NativeMethods.IsSamePath(prjPath, referencedProjectFullPath)) - { - this.referencedProject = prj; - break; - } - } - } - - return this.referencedProject; - } - set - { - this.referencedProject = value; - } - } - - /// - /// Gets the full path to the assembly generated by this project. - /// - internal string ReferencedProjectOutputPath - { - get - { - // Make sure that the referenced project implements the automation object. - if(null == this.ReferencedProjectObject) - { - return null; - } - - // Get the configuration manager from the project. - EnvDTE.ConfigurationManager confManager = this.ReferencedProjectObject.ConfigurationManager; - if(null == confManager) - { - return null; - } - - // Get the active configuration. - EnvDTE.Configuration config = confManager.ActiveConfiguration; - if(null == config) - { - return null; - } - - // Get the output path for the current configuration. - EnvDTE.Property outputPathProperty = config.Properties.Item("OutputPath"); - if(null == outputPathProperty) - { - return null; - } - - string outputPath = outputPathProperty.Value.ToString(); - - // Usually the output path is relative to the project path, but it is possible - // to set it as an absolute path. If it is not absolute, then evaluate its value - // based on the project directory. - if(!System.IO.Path.IsPathRooted(outputPath)) - { - string projectDir = System.IO.Path.GetDirectoryName(referencedProjectFullPath); - outputPath = System.IO.Path.Combine(projectDir, outputPath); - } - - // Now get the name of the assembly from the project. - // Some project system throw if the property does not exist. We expect an ArgumentException. - EnvDTE.Property assemblyNameProperty = null; - try - { - assemblyNameProperty = this.ReferencedProjectObject.Properties.Item("OutputFileName"); - } - catch(ArgumentException) - { - } - - if(null == assemblyNameProperty) - { - return null; - } - // build the full path adding the name of the assembly to the output path. - outputPath = System.IO.Path.Combine(outputPath, assemblyNameProperty.Value.ToString()); - - return outputPath; - } - } - - private Automation.OAProjectReference projectReference; - internal override object Object - { - get - { - if(null == projectReference) - { - projectReference = new Automation.OAProjectReference(this); - } - return projectReference; - } - } - - /// - /// This is used to get or set whether or not to use the project as a reference or just for MSBuild - /// dependency determination. - /// - public bool ReferenceOutputAssembly - { - get - { - bool value; - - // If not present or valid, default to true - if(!Boolean.TryParse(this.ItemNode.GetMetadata(ProjectFileConstants.ReferenceOutputAssembly), out value)) - value = true; - - return value; - } - set - { - this.ItemNode.SetMetadata(ProjectFileConstants.ReferenceOutputAssembly, value.ToString().ToLowerInvariant()); - } - } - #endregion - - #region ctors - /// - /// Constructor for the ReferenceNode. It is called when the project is reloaded, when the project element representing the reference exists. - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings")] - public ProjectReferenceNode(ProjectNode root, ProjectElement element) - : base(root, element) - { - this.referencedProjectRelativePath = this.ItemNode.GetMetadata(ProjectFileConstants.Include); - Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectRelativePath), "Could not retrieve referenced project path form project file"); - - string guidString = this.ItemNode.GetMetadata(ProjectFileConstants.Project); - - // Continue even if project settings cannot be read. - try - { - this.referencedProjectGuid = new Guid(guidString); - - this.buildDependency = new BuildDependency(this.ProjectMgr, this.referencedProjectGuid); - this.ProjectMgr.AddBuildDependency(this.buildDependency); - } - finally - { - Debug.Assert(this.referencedProjectGuid != Guid.Empty, "Could not retrieve referenced project guidproject file"); - - this.referencedProjectName = this.ItemNode.GetMetadata(ProjectFileConstants.Name); - - Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectName), "Could not retrieve referenced project name form project file"); - } - - Uri uri = new Uri(this.ProjectMgr.BaseURI.Uri, this.referencedProjectRelativePath); - - if(uri != null) - { - this.referencedProjectFullPath = Microsoft.VisualStudio.Shell.Url.Unescape(uri.LocalPath, true); - } - } - - /// - /// constructor for the ProjectReferenceNode - /// - public ProjectReferenceNode(ProjectNode root, string referencedProjectName, string projectPath, string projectReference) - : base(root) - { - Debug.Assert(root != null && !String.IsNullOrEmpty(referencedProjectName) && !String.IsNullOrEmpty(projectReference) - && !String.IsNullOrEmpty(projectPath), "Can not add a reference because the input for adding one is invalid."); - - if (projectReference == null) - { - throw new ArgumentNullException("projectReference"); - } - - this.referencedProjectName = referencedProjectName; - - int indexOfSeparator = projectReference.IndexOf('|'); - - - string fileName = String.Empty; - - // Unfortunately we cannot use the path part of the projectReference string since it is not resolving correctly relative paths. - if(indexOfSeparator != -1) - { - string projectGuid = projectReference.Substring(0, indexOfSeparator); - this.referencedProjectGuid = new Guid(projectGuid); - if(indexOfSeparator + 1 < projectReference.Length) - { - string remaining = projectReference.Substring(indexOfSeparator + 1); - indexOfSeparator = remaining.IndexOf('|'); - - if(indexOfSeparator == -1) - { - fileName = remaining; - } - else - { - fileName = remaining.Substring(0, indexOfSeparator); - } - } - } - - Debug.Assert(!String.IsNullOrEmpty(fileName), "Can not add a project reference because the input for adding one is invalid."); - - // Did we get just a file or a relative path? - Uri uri = new Uri(projectPath); - - string referenceDir = PackageUtilities.GetPathDistance(this.ProjectMgr.BaseURI.Uri, uri); - - Debug.Assert(!String.IsNullOrEmpty(referenceDir), "Can not add a project reference because the input for adding one is invalid."); - - string justTheFileName = Path.GetFileName(fileName); - this.referencedProjectRelativePath = Path.Combine(referenceDir, justTheFileName); - - this.referencedProjectFullPath = Path.Combine(projectPath, justTheFileName); - - this.buildDependency = new BuildDependency(this.ProjectMgr, this.referencedProjectGuid); - - } - #endregion - - #region methods - protected override NodeProperties CreatePropertiesObject() - { - return new ProjectReferencesProperties(this); - } - - /// - /// The node is added to the hierarchy and then updates the build dependency list. - /// - public override void AddReference() - { - if(this.ProjectMgr == null) - { - return; - } - base.AddReference(); - this.ProjectMgr.AddBuildDependency(this.buildDependency); - return; - } - - /// - /// Overridden method. The method updates the build dependency list before removing the node from the hierarchy. - /// - public override void Remove(bool removeFromStorage) - { - if(this.ProjectMgr == null || !this.CanRemoveReference) - { - return; - } - this.ProjectMgr.RemoveBuildDependency(this.buildDependency); - base.Remove(removeFromStorage); - return; - } - - /// - /// Links a reference node to the project file. - /// - protected override void BindReferenceData() - { - Debug.Assert(!String.IsNullOrEmpty(this.referencedProjectName), "The referencedProjectName field has not been initialized"); - Debug.Assert(this.referencedProjectGuid != Guid.Empty, "The referencedProjectName field has not been initialized"); - - this.ItemNode = new ProjectElement(this.ProjectMgr, this.referencedProjectRelativePath, ProjectFileConstants.ProjectReference); - - this.ItemNode.SetMetadata(ProjectFileConstants.Name, this.referencedProjectName); - this.ItemNode.SetMetadata(ProjectFileConstants.Project, this.referencedProjectGuid.ToString("B")); - this.ItemNode.SetMetadata(ProjectFileConstants.Private, true.ToString()); - } - - /// - /// Defines whether this node is valid node for painting the reference icon. - /// - /// - protected override bool CanShowDefaultIcon() - { - if(this.referencedProjectGuid == Guid.Empty || this.ProjectMgr == null || this.ProjectMgr.IsClosed || this.isNodeValid) - { - return false; - } - - IVsHierarchy hierarchy = null; - - hierarchy = VsShellUtilities.GetHierarchy(this.ProjectMgr.Site, this.referencedProjectGuid); - - if(hierarchy == null) - { - return false; - } - - //If the Project is unloaded return false - if(this.ReferencedProjectObject == null) - { - return false; - } - - return (!String.IsNullOrEmpty(this.referencedProjectFullPath) && File.Exists(this.referencedProjectFullPath)); - } - - /// - /// Checks if a project reference can be added to the hierarchy. It calls base to see if the reference is not already there, then checks for circular references. - /// - /// The error handler delegate to return - /// - protected override bool CanAddReference(out CannotAddReferenceErrorMessage errorHandler) - { - // When this method is called this reference has not yet been added to the hierarchy, only instantiated. - if(!base.CanAddReference(out errorHandler)) - { - return false; - } - - errorHandler = null; - if(this.IsThisProjectReferenceInCycle()) - { - errorHandler = new CannotAddReferenceErrorMessage(ShowCircularReferenceErrorMessage); - return false; - } - - return true; - } - - private bool IsThisProjectReferenceInCycle() - { - return IsReferenceInCycle(this.referencedProjectGuid); - } - - private void ShowCircularReferenceErrorMessage() - { - string message = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.ProjectContainsCircularReferences, CultureInfo.CurrentUICulture), this.referencedProjectName); - string title = string.Empty; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(this.ProjectMgr.Site, title, message, icon, buttons, defaultButton); - } - - /// - /// Checks whether a reference added to a given project would introduce a circular dependency. - /// - private bool IsReferenceInCycle(Guid projectGuid) - { - IVsHierarchy referencedHierarchy = VsShellUtilities.GetHierarchy(this.ProjectMgr.Site, projectGuid); - - var solutionBuildManager = this.ProjectMgr.Site.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2; - if (solutionBuildManager == null) - { - throw new InvalidOperationException("Cannot find the IVsSolutionBuildManager2 service."); - } - - int circular; - Marshal.ThrowExceptionForHR(solutionBuildManager.CalculateProjectDependencies()); - Marshal.ThrowExceptionForHR(solutionBuildManager.QueryProjectDependency(referencedHierarchy, this.ProjectMgr.InteropSafeIVsHierarchy, out circular)); - - return circular != 0; - } - #endregion - } - -} diff --git a/SHFB/Source/MPFProj_VS2010/Properties/AssemblyInfo.cs b/SHFB/Source/MPFProj_VS2010/Properties/AssemblyInfo.cs deleted file mode 100644 index 4a2c87b2..00000000 --- a/SHFB/Source/MPFProj_VS2010/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,64 +0,0 @@ -//=============================================================================================================== -// System : Microsoft Managed Package Framework for Projects (MPFProj) -// File : AssemblyInfo.cs -// Author : Microsoft Corporation -// Updated : 01/16/2014 -// Note : Copyright 2009-2014, Microsoft Corporation, All rights reserved -// Compiler: Microsoft Visual C# -// -// Managed Package Framework for Projects assembly attributes. -// -// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be -// distributed with the code. It can also be found at the project website: http://MPFProj10.CodePlex.com. This -// notice, the author's name, and all copyright notices must remain intact in all applications, documentation, -// and source files. -// -// Version Date Who Comments -// ============================================================================================================== -// 1.0.0.0 03/20/2011 EFW Merged project into SHFB project to create a package for Visual Studio integration -// 1.1.0.0 03/06/2013 EFW Merged changes from the MPF 2012 project into this one so that this version can run -// under both VS 2010 and VS 2012. -//=============================================================================================================== - -using System; -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Resources contained within the assembly are English -[assembly: NeutralResourcesLanguageAttribute("en")] - -// General assembly information -[assembly: AssemblyProduct("Microsoft Managed Package Framework for Projects")] -[assembly: AssemblyTitle("Microsoft Managed Package Framework for Projects")] -[assembly: AssemblyDescription("The base managed package framework used to create packages for Visual Studio " + - "Integration")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft Corporation")] -[assembly: AssemblyCopyright("Copyright \xA9 2008-2014, Microsoft Corporation, All Rights Reserved")] -[assembly: AssemblyTrademark("Microsoft Corporation, All Rights Reserved")] -[assembly: AssemblyCulture("")] - -[assembly: CLSCompliant(false)] - -[assembly: ComVisible(false)] - -[assembly: Guid("084954ec-af04-4ea3-b166-b1fced604dc8")] - -[assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] - -// Expose the internal members to the types in the SandcastleBuilder.Package assembly -// -// sn.exe -p SandcastleTools.snk PublicKey.key -// sn.exe -tp PublicKey.key -// -// Cut and paste the public key below. -// -[assembly: InternalsVisibleTo("SandcastleBuilder.Package, PublicKey=" + - "00240000048000009400000006020000002400005253413100040000010001002f5b57e5c28270" + - "f49518ff41c8842759d9262f1cb9f50adf4d89a9fbcbffd17201be3da944edb7e8cf3bdc19b5fa" + - "0de57f4f3231b1fa861124c6bbea5bc1216b5e361bfaa0c0fde01c9302d06146543d7e2477a740" + - "e5279dd8fa7d0e5afe6acb0a2e552e770b63847cf68b47f49dff68375a38791e4cabe0639516df" + - "e2ce348d")] diff --git a/SHFB/Source/MPFProj_VS2010/PropertiesEditorLauncher.cs b/SHFB/Source/MPFProj_VS2010/PropertiesEditorLauncher.cs deleted file mode 100644 index f88dc181..00000000 --- a/SHFB/Source/MPFProj_VS2010/PropertiesEditorLauncher.cs +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.ComponentModel; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using ErrorHandler = Microsoft.VisualStudio.ErrorHandler; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// This class is used to enable launching the project properties - /// editor from the Properties Browser. - /// - [CLSCompliant(false)] - public class PropertiesEditorLauncher : ComponentEditor - { - private ServiceProvider serviceProvider; - - #region ctor - public PropertiesEditorLauncher(ServiceProvider serviceProvider) - { - if(serviceProvider == null) - throw new ArgumentNullException("serviceProvider"); - - this.serviceProvider = serviceProvider; - } - #endregion - #region overridden methods - /// - /// Launch the Project Properties Editor (properties pages) - /// - /// If we succeeded or not - public override bool EditComponent(ITypeDescriptorContext context, object component) - { - if(component is ProjectNodeProperties) - { - IVsPropertyPageFrame propertyPageFrame = (IVsPropertyPageFrame)serviceProvider.GetService((typeof(SVsPropertyPageFrame))); - - int hr = propertyPageFrame.ShowFrame(Guid.Empty); - if(ErrorHandler.Succeeded(hr)) - return true; - else - ErrorHandler.ThrowOnFailure(propertyPageFrame.ReportError(hr)); - } - - return false; - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ReferenceContainerNode.cs b/SHFB/Source/MPFProj_VS2010/ReferenceContainerNode.cs deleted file mode 100644 index 7205adb0..00000000 --- a/SHFB/Source/MPFProj_VS2010/ReferenceContainerNode.cs +++ /dev/null @@ -1,575 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Text; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using MSBuild = Microsoft.Build.Evaluation; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; -using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; -using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false), ComVisible(true)] - public class ReferenceContainerNode : HierarchyNode, IReferenceContainer - { - #region fields - internal const string ReferencesNodeVirtualName = "References"; - #endregion - - #region ctor - public ReferenceContainerNode(ProjectNode root) - : base(root) - { - this.VirtualNodeName = ReferencesNodeVirtualName; - this.ExcludeNodeFromScc = true; - } - #endregion - - #region Properties - private static string[] supportedReferenceTypes = new string[] { - ProjectFileConstants.ProjectReference, - ProjectFileConstants.Reference, - ProjectFileConstants.COMReference - }; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - protected virtual string[] SupportedReferenceTypes - { - get { return supportedReferenceTypes; } - } - #endregion - - #region overridden properties - public override int SortPriority - { - get - { - return DefaultSortOrderNode.ReferenceContainerNode; - } - } - - public override int MenuCommandId - { - get { return VsMenus.IDM_VS_CTXT_REFERENCEROOT; } - } - - - public override Guid ItemTypeGuid - { - get { return VSConstants.GUID_ItemType_VirtualFolder; } - } - - - public override string Url - { - get { return this.VirtualNodeName; } - } - - public override string Caption - { - get - { - return SR.GetString(SR.ReferencesNodeName, CultureInfo.CurrentUICulture); - } - } - - - private Automation.OAReferences references; - internal override object Object - { - get - { - if(null == references) - { - references = new Automation.OAReferences(this); - } - return references; - } - } - - #endregion - - #region overridden methods - /// - /// Returns an instance of the automation object for ReferenceContainerNode - /// - /// An intance of the Automation.OAReferenceFolderItem type if succeeeded - public override object GetAutomationObject() - { - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return null; - } - - return new Automation.OAReferenceFolderItem(this.ProjectMgr.GetAutomationObject() as Automation.OAProject, this); - } - - /// - /// Disable inline editing of Caption of a ReferendeContainerNode - /// - /// null - public override string GetEditLabel() - { - return null; - } - - - public override object GetIconHandle(bool open) - { - return this.ProjectMgr.ImageHandler.GetIconHandle(open ? (int)ProjectNode.ImageName.OpenReferenceFolder : (int)ProjectNode.ImageName.ReferenceFolder); - } - - - /// - /// References node cannot be dragged. - /// - /// A stringbuilder. - protected internal override StringBuilder PrepareSelectedNodesForClipBoard() - { - return null; - } - - /// - /// Not supported. - /// - protected override int ExcludeFromProject() - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result) - { - if(cmdGroup == VsMenus.guidStandardCommandSet97) - { - switch((VsCommands)cmd) - { - case VsCommands.AddNewItem: - case VsCommands.AddExistingItem: - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } - else if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - if((VsCommands2K)cmd == VsCommands2K.ADDREFERENCE) - { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } - else - { - return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; - } - return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); - } - - protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) - { - if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - switch((VsCommands2K)cmd) - { - case VsCommands2K.ADDREFERENCE: - return this.ProjectMgr.AddProjectReference(); - case VsCommands2K.ADDWEBREFERENCE: - return this.ProjectMgr.AddWebReference(); - } - } - - return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); - } - - protected override bool CanDeleteItem(__VSDELETEITEMOPERATION deleteOperation) - { - return false; - } - - /// - /// Defines whether this node is valid node for painting the refererences icon. - /// - /// - protected override bool CanShowDefaultIcon() - { - if(!String.IsNullOrEmpty(this.VirtualNodeName)) - { - return true; - } - return false; - } - - #endregion - - #region IReferenceContainer - public IList EnumReferences() - { - List refs = new List(); - for(HierarchyNode node = this.FirstChild; node != null; node = node.NextSibling) - { - ReferenceNode refNode = node as ReferenceNode; - if(refNode != null) - { - refs.Add(refNode); - } - } - - return refs; - } - /// - /// Adds references to this container from a MSBuild project. - /// - public void LoadReferencesFromBuildProject(MSBuild.Project buildProject) - { - foreach(string referenceType in SupportedReferenceTypes) - { - IEnumerable refererncesGroup = this.ProjectMgr.BuildProject.GetItems(referenceType); - - bool isAssemblyReference = referenceType == ProjectFileConstants.Reference; - // If the project was loaded for browsing we should still create the nodes but as not resolved. - if(isAssemblyReference && this.ProjectMgr.Build(MsBuildTarget.ResolveAssemblyReferences) != MSBuildResult.Successful) - { - continue; - } - - foreach (MSBuild.ProjectItem item in refererncesGroup) - { - ProjectElement element = new ProjectElement(this.ProjectMgr, item, false); - - ReferenceNode node = CreateReferenceNode(referenceType, element); - - if(node != null) - { - // Make sure that we do not want to add the item twice to the ui hierarchy - // We are using here the UI representation of the Node namely the Caption to find that out, in order to - // avoid different representation problems. - // Example : - // - bool found = false; - for(HierarchyNode n = this.FirstChild; n != null && !found; n = n.NextSibling) - { - if(String.Compare(n.Caption, node.Caption, StringComparison.OrdinalIgnoreCase) == 0) - { - found = true; - } - } - - if(!found) - { - this.AddChild(node); - } - } - } - } - } - - /// - /// Adds a reference to this container using the selector data structure to identify it. - /// - /// data describing selected component - /// Wrapper tool - /// Reference in case of a valid reference node has been created. Otherwise null - public ReferenceNode AddReferenceFromSelectorData(VSCOMPONENTSELECTORDATA selectorData, string wrapperTool = null) - { - //Make sure we can edit the project file - if(!this.ProjectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - - //Create the reference node - ReferenceNode node = null; - try - { - node = CreateReferenceNode(selectorData, wrapperTool); - } - catch(ArgumentException) - { - // Some selector data was not valid. - } - - // Does such a reference already exist in the project? - ReferenceNode existingNode; - if (node.IsAlreadyAdded(out existingNode)) - { - return existingNode; - } - - //Add the reference node to the project if we have a valid reference node - if(node != null) - { - // This call will find if the reference is in the project and, in this case - // will not add it again, so the parent node will not be set. - node.AddReference(); - if(null == node.Parent) - { - // The reference was not added, so we can not return this item because it - // is not inside the project. - return null; - } - } - - return node; - } - #endregion - - #region virtual methods - protected virtual ReferenceNode CreateReferenceNode(string referenceType, ProjectElement element) - { - ReferenceNode node = null; - if(referenceType == ProjectFileConstants.COMReference) - { - node = this.CreateComReferenceNode(element); - } - else if(referenceType == ProjectFileConstants.Reference) - { - node = this.CreateAssemblyReferenceNode(element); - } - else if(referenceType == ProjectFileConstants.ProjectReference) - { - node = this.CreateProjectReferenceNode(element); - } - - return node; - } - - protected virtual ReferenceNode CreateReferenceNode(VSCOMPONENTSELECTORDATA selectorData, string wrapperTool = null) - { - ReferenceNode node = null; - switch(selectorData.type) - { - case VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project: - node = this.CreateProjectReferenceNode(selectorData); - break; - case VSCOMPONENTTYPE.VSCOMPONENTTYPE_File: - // This is the case for managed assembly - case VSCOMPONENTTYPE.VSCOMPONENTTYPE_ComPlus: - node = this.CreateFileComponent(selectorData, wrapperTool); - break; - case VSCOMPONENTTYPE.VSCOMPONENTTYPE_Com2: - node = this.CreateComReferenceNode(selectorData, wrapperTool); - break; - } - - return node; - } - #endregion - - #region Helper functions to add references - /// - /// Creates a project reference node given an existing project element. - /// - protected virtual ProjectReferenceNode CreateProjectReferenceNode(ProjectElement element) - { - return new ProjectReferenceNode(this.ProjectMgr, element); - } - /// - /// Create a Project to Project reference given a VSCOMPONENTSELECTORDATA structure - /// - protected virtual ProjectReferenceNode CreateProjectReferenceNode(VSCOMPONENTSELECTORDATA selectorData) - { - return new ProjectReferenceNode(this.ProjectMgr, selectorData.bstrTitle, selectorData.bstrFile, selectorData.bstrProjRef); - } - - /// - /// Creates an assemby or com reference node given a selector data. - /// - protected virtual ReferenceNode CreateFileComponent(VSCOMPONENTSELECTORDATA selectorData, string wrapperTool = null) - { - if(null == selectorData.bstrFile) - { - throw new ArgumentNullException("selectorData"); - } - - // We have a path to a file, it could be anything - // First see if it is a managed assembly - bool tryToCreateAnAssemblyReference = true; - if(File.Exists(selectorData.bstrFile)) - { - try - { - // We should not load the assembly in the current appdomain. - // If we do not do it like that and we load the assembly in the current appdomain then the assembly cannot be unloaded again. - // The following problems might arose in that case. - // 1. Assume that a user is extending the MPF and his project is creating a managed assembly dll. - // 2. The user opens VS and creates a project and builds it. - // 3. Then the user opens VS creates another project and adds a reference to the previously built assembly. This will load the assembly in the appdomain had we been using Assembly.ReflectionOnlyLoadFrom. - // 4. Then he goes back to the first project modifies it an builds it. A build error is issued that the assembly is used. - - // GetAssemblyName is assured not to load the assembly. - tryToCreateAnAssemblyReference = (AssemblyName.GetAssemblyName(selectorData.bstrFile) != null); - } - catch(BadImageFormatException) - { - // We have found the file and it is not a .NET assembly; no need to try to - // load it again. - tryToCreateAnAssemblyReference = false; - } - catch(FileLoadException) - { - // We must still try to load from here because this exception is thrown if we want - // to add the same assembly refererence from different locations. - tryToCreateAnAssemblyReference = true; - } - } - - ReferenceNode node = null; - - if(tryToCreateAnAssemblyReference) - { - // This might be a candidate for an assembly reference node. Try to load it. - // CreateAssemblyReferenceNode will suppress BadImageFormatException if the node cannot be created. - node = this.CreateAssemblyReferenceNode(selectorData.bstrFile); - } - - // If no node has been created try to create a com reference node. - if(node == null) - { - if(!File.Exists(selectorData.bstrFile)) - { - return null; - } - node = this.CreateComReferenceNode(selectorData, wrapperTool); - } - - return node; - } - - /// - /// Creates an assembly refernce node from a project element. - /// - protected virtual AssemblyReferenceNode CreateAssemblyReferenceNode(ProjectElement element) - { - AssemblyReferenceNode node = null; - try - { - node = new AssemblyReferenceNode(this.ProjectMgr, element); - } - catch(ArgumentNullException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch(FileNotFoundException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch(BadImageFormatException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch(FileLoadException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch(System.Security.SecurityException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - - return node; - } - /// - /// Creates an assembly reference node from a file path. - /// - protected virtual AssemblyReferenceNode CreateAssemblyReferenceNode(string fileName) - { - AssemblyReferenceNode node = null; - try - { - node = new AssemblyReferenceNode(this.ProjectMgr, fileName); - } - catch(ArgumentNullException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch(FileNotFoundException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch(BadImageFormatException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch(FileLoadException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - catch(System.Security.SecurityException e) - { - Trace.WriteLine("Exception : " + e.Message); - } - - return node; - } - - /// - /// Creates a com reference node from the project element. - /// - protected virtual ComReferenceNode CreateComReferenceNode(ProjectElement reference) - { - return new ComReferenceNode(this.ProjectMgr, reference); - } - /// - /// Creates a com reference node from a selector data. - /// - protected virtual ComReferenceNode CreateComReferenceNode(Microsoft.VisualStudio.Shell.Interop.VSCOMPONENTSELECTORDATA selectorData, string wrapperTool = null) - { - ComReferenceNode node = new ComReferenceNode(this.ProjectMgr, selectorData); - return node; - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/ReferenceNode.cs b/SHFB/Source/MPFProj_VS2010/ReferenceNode.cs deleted file mode 100644 index 67b821ae..00000000 --- a/SHFB/Source/MPFProj_VS2010/ReferenceNode.cs +++ /dev/null @@ -1,377 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security.Permissions; -using System.Text; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; -using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false), ComVisible(true)] - public abstract class ReferenceNode : HierarchyNode - { - protected delegate void CannotAddReferenceErrorMessage(); - - #region ctors - /// - /// constructor for the ReferenceNode - /// - protected ReferenceNode(ProjectNode root, ProjectElement element) - : base(root, element) - { - this.ExcludeNodeFromScc = true; - } - - /// - /// constructor for the ReferenceNode - /// - protected ReferenceNode(ProjectNode root) - : base(root) - { - this.ExcludeNodeFromScc = true; - } - - #endregion - - #region overridden properties - public override int MenuCommandId - { - get { return VsMenus.IDM_VS_CTXT_REFERENCE; } - } - - public override Guid ItemTypeGuid - { - get { return Guid.Empty; } - } - - public override string Url - { - get - { - return String.Empty; - } - } - - public override string Caption - { - get - { - return String.Empty; - } - } - #endregion - - #region overridden methods - protected override NodeProperties CreatePropertiesObject() - { - return new ReferenceNodeProperties(this); - } - - /// - /// Get an instance of the automation object for ReferenceNode - /// - /// An instance of Automation.OAReferenceItem type if succeeded - public override object GetAutomationObject() - { - if(this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return null; - } - - return new Automation.OAReferenceItem(this.ProjectMgr.GetAutomationObject() as Automation.OAProject, this); - } - - /// - /// Disable inline editing of Caption of a ReferendeNode - /// - /// null - public override string GetEditLabel() - { - return null; - } - - - public override object GetIconHandle(bool open) - { - int offset = (this.CanShowDefaultIcon() ? (int)ProjectNode.ImageName.Reference : (int)ProjectNode.ImageName.DanglingReference); - return this.ProjectMgr.ImageHandler.GetIconHandle(offset); - } - - /// - /// This method is called by the interface method GetMkDocument to specify the item moniker. - /// - /// The moniker for this item - public override string GetMkDocument() - { - return this.Url; - } - - /// - /// Not supported. - /// - protected override int ExcludeFromProject() - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - /// - /// References node cannot be dragged. - /// - /// A stringbuilder. - protected internal override StringBuilder PrepareSelectedNodesForClipBoard() - { - return null; - } - - protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result) - { - if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - if((VsCommands2K)cmd == VsCommands2K.QUICKOBJECTSEARCH) - { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } - else - { - return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP; - } - return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result); - } - - protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) - { - if(cmdGroup == VsMenus.guidStandardCommandSet2K) - { - if((VsCommands2K)cmd == VsCommands2K.QUICKOBJECTSEARCH) - { - return this.ShowObjectBrowser(); - } - } - - return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); - } - - #endregion - - #region methods - - - /// - /// Links a reference node to the project and hierarchy. - /// - public virtual void AddReference() - { - ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode; - Debug.Assert(referencesFolder != null, "Could not find the References node"); - - CannotAddReferenceErrorMessage referenceErrorMessageHandler = null; - - if(!this.CanAddReference(out referenceErrorMessageHandler)) - { - if(referenceErrorMessageHandler != null) - { - referenceErrorMessageHandler.DynamicInvoke(new object[] { }); - } - return; - } - - // Link the node to the project file. - this.BindReferenceData(); - - // At this point force the item to be refreshed - this.ItemNode.RefreshProperties(); - - referencesFolder.AddChild(this); - - return; - } - - /// - /// Refreshes a reference by re-resolving it and redrawing the icon. - /// - internal virtual void RefreshReference() - { - this.ResolveReference(); - this.ReDraw(UIHierarchyElement.Icon); - } - - /// - /// Resolves references. - /// - protected virtual void ResolveReference() - { - - } - - /// - /// Validates that a reference can be added. - /// - /// A CannotAddReferenceErrorMessage delegate to show the error message. - /// true if the reference can be added. - protected virtual bool CanAddReference(out CannotAddReferenceErrorMessage errorHandler) - { - // When this method is called this refererence has not yet been added to the hierarchy, only instantiated. - errorHandler = null; - if(this.IsAlreadyAdded()) - { - return false; - } - - return true; - } - - /// - /// Checks if a reference is already added. The method parses all references and compares the Url. - /// - /// true if the assembly has already been added. - protected bool IsAlreadyAdded() - { - ReferenceNode existingReference; - return IsAlreadyAdded(out existingReference); - } - - /// - /// Checks if a reference is already added. The method parses all references and compares the Url. - /// - /// The existing reference, if one is found. - /// true if the assembly has already been added. - protected internal virtual bool IsAlreadyAdded(out ReferenceNode existingEquivalentNode) - { - ReferenceContainerNode referencesFolder = this.ProjectMgr.FindChild(ReferenceContainerNode.ReferencesNodeVirtualName) as ReferenceContainerNode; - Debug.Assert(referencesFolder != null, "Could not find the References node"); - - for(HierarchyNode n = referencesFolder.FirstChild; n != null; n = n.NextSibling) - { - ReferenceNode referenceNode = n as ReferenceNode; - if(null != referenceNode) - { - // We check if the Url of the assemblies is the same. - if(NativeMethods.IsSamePath(referenceNode.Url, this.Url)) - { - existingEquivalentNode = referenceNode; - return true; - } - } - } - - existingEquivalentNode = null; - return false; - } - - - /// - /// Shows the Object Browser - /// - /// - protected virtual int ShowObjectBrowser() - { - if(String.IsNullOrEmpty(this.Url) || !File.Exists(this.Url)) - { - return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED; - } - - // Request unmanaged code permission in order to be able to creaet the unmanaged memory representing the guid. - new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); - - Guid guid = VSConstants.guidCOMPLUSLibrary; - IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(guid.ToByteArray().Length); - - System.Runtime.InteropServices.Marshal.StructureToPtr(guid, ptr, false); - int returnValue = VSConstants.S_OK; - try - { - VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1]; - - objInfo[0].pguidLib = ptr; - objInfo[0].pszLibName = this.Url; - - IVsObjBrowser objBrowser = this.ProjectMgr.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser; - - ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0)); - } - catch(COMException e) - { - Trace.WriteLine("Exception" + e.ErrorCode); - returnValue = e.ErrorCode; - } - finally - { - if(ptr != IntPtr.Zero) - { - System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr); - } - } - - return returnValue; - } - - protected override bool CanDeleteItem(__VSDELETEITEMOPERATION deleteOperation) - { - if(deleteOperation == __VSDELETEITEMOPERATION.DELITEMOP_RemoveFromProject) - { - return true; - } - return false; - } - - protected abstract void BindReferenceData(); - - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/RegisteredProjectType.cs b/SHFB/Source/MPFProj_VS2010/RegisteredProjectType.cs deleted file mode 100644 index e3517878..00000000 --- a/SHFB/Source/MPFProj_VS2010/RegisteredProjectType.cs +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.Win32; -using VSRegistry = Microsoft.VisualStudio.Shell.VSRegistry; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Gets registry settings from for a project. - /// - internal class RegisteredProjectType - { - private string defaultProjectExtension; - - private string projectTemplatesDir; - - private string wizardTemplatesDir; - - private Guid packageGuid; - - internal const string DefaultProjectExtension = "DefaultProjectExtension"; - internal const string WizardsTemplatesDir = "WizardsTemplatesDir"; - internal const string ProjectTemplatesDir = "ProjectTemplatesDir"; - internal const string Package = "Package"; - - - - internal string DefaultProjectExtensionValue - { - get - { - return this.defaultProjectExtension; - } - set - { - this.defaultProjectExtension = value; - } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal string ProjectTemplatesDirValue - { - get - { - return this.projectTemplatesDir; - } - set - { - this.projectTemplatesDir = value; - } - } - - internal string WizardTemplatesDirValue - { - get - { - return this.wizardTemplatesDir; - } - set - { - this.wizardTemplatesDir = value; - } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Guid PackageGuidValue - { - get - { - return this.packageGuid; - } - set - { - this.packageGuid = value; - } - } - - /// - /// If the project support VsTemplates, returns the path to - /// the vstemplate file corresponding to the requested template - /// - /// You can pass in a string such as: "Windows\Console Application" - /// - internal string GetVsTemplateFile(string templateFile) - { - // First see if this use the vstemplate model - if(!String.IsNullOrEmpty(DefaultProjectExtensionValue)) - { - EnvDTE80.DTE2 dte = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2; - if(dte != null) - { - EnvDTE80.Solution2 solution = dte.Solution as EnvDTE80.Solution2; - if(solution != null) - { - string fullPath = solution.GetProjectTemplate(templateFile, DefaultProjectExtensionValue); - // The path returned by GetProjectTemplate can be in the format "path|FrameworkVersion=x.y|Language=xxx" - // where the framework version and language sections are optional. - // Here we are interested only in the full path, so we have to remove all the other sections. - int pipePos = fullPath.IndexOf('|'); - if(0 == pipePos) - { - return null; - } - if(pipePos > 0) - { - fullPath = fullPath.Substring(0, pipePos); - } - return fullPath; - } - } - - } - return null; - } - - internal static RegisteredProjectType CreateRegisteredProjectType(Guid projectTypeGuid) - { - RegisteredProjectType registederedProjectType = null; - - using(RegistryKey rootKey = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration)) - { - if(rootKey == null) - { - return null; - } - - string projectPath = "Projects\\" + projectTypeGuid.ToString("B"); - using(RegistryKey projectKey = rootKey.OpenSubKey(projectPath)) - { - if(projectKey == null) - { - return null; - } - - registederedProjectType = new RegisteredProjectType(); - registederedProjectType.DefaultProjectExtensionValue = projectKey.GetValue(DefaultProjectExtension) as string; - registederedProjectType.ProjectTemplatesDirValue = projectKey.GetValue(ProjectTemplatesDir) as string; - registederedProjectType.WizardTemplatesDirValue = projectKey.GetValue(WizardsTemplatesDir) as string; - registederedProjectType.PackageGuidValue = new Guid(projectKey.GetValue(Package) as string); - } - } - - return registederedProjectType; - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Resources/imagelis.bmp b/SHFB/Source/MPFProj_VS2010/Resources/imagelis.bmp deleted file mode 100644 index 43cb71c75bdb4a2145001a33f4bd0a343bfdd81e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 39990 zcmeI5J!m6cn(uwN8+3332OBupU zbn#W+-Ktq@HGkCz4&491nE#8Ts(MrJ{$f&)@UY$f zB%asZ&&t0Z+duyLj~e(NR|DZ~*gNjE_FL|j+gxkf-)x@FhU4ve!Bz18r8xdW@?op} zVY@BQY3E#oI!lA2w*9d-w(5*LQk$XV||Py+5A+0?FD&>;0)L6sG4ierwFT_eYCl zdOb+@EN{oC?5)`Awf?udb7cQi4F7$ED;G)sIR(PaXK7(~)xCFK{(tD3U+K z{l=GOSQjE|P_tBI@q(y0A)?EX@({iUw+^PVKMu=4zDke`(&mG=i3Tu1fw zma*0{zInA(oLl|sR=?!#v%_C!GT%SxdpjP_;l&Uj7v6+}^MT*>+XwB|Udv)PbkLp& z@>BWo553l&bq{<&`aX4HPI)qbf}{#>y)CPSF`m(NBY?vkbJ zWa%#Xu-C6143=(_rAzs`ayZcWp<1#ejvq(yL&SP9x(Vn5`mZw{#z?m4lcs6>6ptQ8 zaU5qq3JHH_DnBz(z4Fz&2+jSzbu@IZqV_}VJ*4J!QaKqd9|V=1er>(o><(WE{>q9{nfqn01pZL}gk=d)lYNg~H%B>Mgp9RObn<128{uP6yPU-chf8D4j}e6U@(M z{nxtj7o+;e>S*5{?pWr5(LAaSw(Hh6qqbE+-tS01WFO&fyKE@zRhv+akB#~-_1d3n zwLgh_GkzsD^VFe!hbOw~wGJGA!yIllhI>wM*3*%U9wOr^1;4?<>6h9=ckRcSbl3a5 zyWR$)o8jnc5S;etx6W>>x#ijGj`@|z%4AZi{Gqn|FO?6=EAx&xk+*kR_LgU^yN%Um z{j+U+G^>RAV{PSMtII2dS|*@Q9r^HngnW1xAs^g?$PX_AdvFu5LxyXtGna(UBuv@qxDWjP3=ILNZrQ|djX?qljar1pJk z-KFMj+PF#U*D3u+%S&eB(dbrYw&-dYUJkGtP`ZIF=k1 z8Ot-NgXqZdEOc5@W$FF$NM_IJ=rJl5Q#CtXtJ%pY7f|~tOLM~}#W$VK4C{6FUAYl$ zfurxGPq?TUcaM=Sg0E3wb$=mML7R5YF~t{v%otUx<^CjaA5EEt8;1{z#B7m|5WfBPnKgASzfYe z;#fU_aJr=0BW?X7onMJYm;KR2FFcp^2;uOzN_^UiuLtpMAj0$w?H;6`hzb(_sOjMQeXO>Ej?t*aZ=s&r?T;!NSBC5(S^)xq$@zKnb;jvLW|HQEKpRcnXKL`9z* zUJg}PlqcPCN3fi@Epc>Cl2ds`eqsC&%POo61!#P!n6JNQ*v2OAXNy?Ld+7(Dl;Dy%{}~{^}lESQ`UY=!S*cQEDbEmw6e3??y;cXCXI`@ zb~>t_j4DS_r4v;4hbue%mF@oWc7J8lU)g8_>WCcq)=|HC7A@_EV;6kb8-CasXvxY) z%ReplJJCIB@4G&O3)x~I5A1n8K<~H@#+xZA{M##`7@ITle3kh`eST!=bCSk!!bEWw z#y3MXMrMM%Q=SzN{1(MY#PfTCf8O!Fe>tT7RT9KZD|_pfw`RJlru(%~_5}=viY0GIwv*ce`_1IPzwavW1B%n&N5P(6mf?VKaB(^_Yw-fotC8XQvCTGrSbzX1H2hs)7Wa%*6Y=;waTX&@J8idKWFgUJRZ)@ zTG3&%d1`uB_3*%ScdbUp7@_Xjba=KtnamHvy%zXw@Y%$vn(?y?SGz3mTUmbCX$J%! z%cu9H`YGjKx=mivYy#0mGPxZx1-YA5>^FK0=grBIM-UBA%gr>C8QmH1=u~FfE8cDl z*9^5;E6W!_#{C}-fo15WA@EYMN^D&7)znJFt&(*B#pUOM{EWni>c%`mz%N z&7S(fv5#kncC6FFLl4*TEIPwD=sykG_dWLp243;ANOxZJ`~VJ=$!@babBf|1GqRHr}D70 zv7W-2fL@@X6#u563*hZF{KlT^&}(lsY4pOAB!j~iZzlNdn;)Ms2-XTdP)iu2-wys^LulBUjFt`qFb;SOvdu6ZMF7^jWHA&^Xix9Bl$bWC|3n9)N_V}%c+ z`d$Nn@DQ*SQo_M~h>WpOXO49?9bg-E2!sPW$%ig<8-m~HS8N2}a&@yJk02t{YIHAr z9TkWGeXM`#)o+^4EnU%#5A1f=Fi#BR5dgv=kFZqum3)=$23Qd`@1WgWZ<2~iVqyHi zKax-z6JeDP+n_#pKb@ZE3H}xzC#H_pej)GOeE{wUeZJ99KH9xDgPp z@^4kLjl6pqwT}DlV`klE=1tbP&gz$G?JTXHB$cChc|WRr^Q^UkNk)Fs|6lc0{wVlC z$qSZy^`nH#)kvXU385=2boHOkxa*W8YOH7r{xiw zfo+4XiyM|4hz>eVCm}KCD;JwVW(@b6$ttG(Gx$x-mfmJ_aMBwb0Q^xN9k+6)RMp;`Pkhlk^?W1U&frIj2t(?h#?R&Sh3myUM5c)x|(w0{@TDB*fj z@Y{1*22L7$mgPs+L3BP)^0Ju1D30mVa{lxBjMFKwDw4@rTiI_^_Y3=t!AUWz5M;g@ z$&aeZa%RYna(ODUB$Xhsq>>$2KsdEolgvNH^{rNI)v11NDp&c`tbKK=Ut~$8OVjZd zc4_Gkb46I#*+@lY<~{Pm6ImanFa5|F;Ag?fEN8)wz<=yDuf6)IMJI7LEYz1pNxLnk zEdMEK-^buLqbvB$ISZVV02C+4P2AMxh|DvZ+B;3QMGHNkechk!gI@1(5G4^1u66Ib zuyE(X!c`9&jgK{1^|qQU+_U)Y-Ss2L>#_dpHstLkhSK_UDylLREPHgMgvW_gXYnq)#gC;nr*AME|wQ6`hi{D7g zxQ*Q(nZb5%+pB(UEQ}`|KpK4_RZ-5E_8&E(R zzwuS;PkZ3EoLS@_3t~H92=B3M%oeody z+~H}SHRX9Q=HE73{%t?J8&N+nT0kRqi)H=|hzowB+bF&Z$V3GaKcEXqh4eIp17Gpp z1BE{J!ZaAhgZ622xM%clTD&JJ02?(-{R?u=F*8AUsUR8Lnx^3992;o=Z1Clg>mz4Cv9)eJk0wf*rH5Wz;$=wY^Gntp?2K zACe8Df6=FyWycI$=IazCU0x{GLr9+^s;khK6uQ@yg){ zZms&~9AEAG?p*?YYh8uTLuTKNQQTE#T!7*dP~7rv2nEMdNUkDU;eDTBN&ZdL*E{Kt z7&xVZ|4sax$|3y2cPKa%%^_n%O(xDw{9)T)&YgI63O{cu2mOS_Zd#r!NreN?SY>F< zT?Z^T?0V%o0Lbxja6OIR^7-HY(-P|oEF5beES&PANL863^2WYd#ytJCriMK%E2K!e ztg1Tys*2d^N;90g0x)iez25}CmA|4(ox*RBA<7l2lCUCWMr%eNr{Wigs306Dw4~xx zKu9Ms;oqK<`mvSIMHvuId4O;;`3IOmtyWF+=tIX8AE>E*Q|On=^4@2Y zgA7`}TtDUdm-+TNQ5ZOjg$QB=0RX2RN7--KCHsw{z1VYQ8D$L8Bs%xqtww*-9Cp0^ z)2N&ogyT51zVw#=+3jH=BNSHB+8%uP;4UpWjbGYh;xtg3HRO%WR_}f^h|_+Ys%P&p zsc*IGN0G55`OJqvR2~9^QbkBQj^Ozn@O(YT^8!L<8cXLtFS3ZKB8&1J-RoTEgbFK$ zhFX$@i%Vd@>Sxw434l+v?Ru}%c2-T}mx63ze4%6NC20@6*yeKmsImO@Lv!D9&qL=l zXdV|R&iYu|k36%Y^`RYra0@+ zTbLWm6_#?ag}J5N!tzo-EOx|}-TKNc@74T|6)OCt{zDLJzgO)BE40yW&p8>kuR?df zu()99hbt)eH`N3br|g7dWJ`GBV>zRC8Ra0DSH;gMDuc$?CJ@g2*0k0fjB32o00>u` zGs{u>)A#Ui_F>;Vi@f`UCR4zvpxrbP2M?Ara?w>mnMTycc8=eES+P%S+&qMXh=YH# zzD+1=RcepUe3vZ$$jnbRZs{pmJ`3#5)Do$?ob+n6s3oViIc5AtjTQYWUAFs(Zn2IBeA*yWr>) zMJ7lumlOyGDu#v2t>y%bo%CCW-teLCKVa(MwRUC8fV_gu05&D8e-tO^QhK1s=5c2aI;Pljn#T>Yq`}CrmKAZbcU~E)WoUGz(6>jnuQ}3 z;`a{x0k|&7fN-s+F$*__aK@RiaFuSnyfZNJ{V(ziM)x{y9S^)m_`1x#FHoE!;*9gO zcA8YyJoiv6^pKzQt5<#4#g*j;7qUdZ@=@}t8hK7_?&g9~QZ1=HDoE?s3S$BOEgJK0 z?1iZ)6{KtvyZp(vzdB``SQ?IwT9%ibocPRyKsb7=JO#f^k#BsJm)COCLS;sVWZwS; zCOt-=dKO~s2XSdh)QAe_@YI+GKd=WDj=iK>vUUE8_&Y7ZZ|AM-#LYT3I|8ZP(pR>A z4Bkm*WNR#L0sofkQUR7aON2rRMf_qH*J**`_^V)#6Q8eibp{1ksGI~rgnvs@Xbn{y zAer(2M_FIW`B(UjRZm6=x{15c*ltMtV~7Y=T!7!^@UXXIxrrZUVemZYUAfUwBY5x= zhB;Km#V}zuam&VOuNkL)dL@Sb`jsu@y z9oMnnh{yIDx(O5*POtjWPQ%z;u{LV`)q0N;aG4lOlq)~FN1Nk>*CAR+Y+R%3Xyu>X z5C6wi`DuKLjK4-|vqt2yo}#STZkv0)x!05DjxXw)(~+_5v#HOgquDO~QV|w*Ht7#9 z6nS2ru0l_g;;3gTMdK7+_B2w=+mL+_h9ajeJ>Kb8?rFe6Q~k1R92nMxUE8UC__WmA z^P9VEdmHQAmc5C7e;U7C43z$q8F)s2%9|(NS*HkOuf=uaWvtj`TfEqyHC?-yph7Xz99pOfWfw|_LG0|e)R8YWZt?Ns`w z`VgP`03LXQA8f$VF9pdz%yohaa#I8aOA5$wA0>NcvfW4@!(huCZ8Zp3rYK*;Z@K*& z6JWj61Twf@|CI6DqM0A?Km_%Je&bHsW$7TKJMjk79ZVnD)|tnl8w>x&(|HnyCrDEB zC=eyxLsq>?KxNdYc`W>!S}e*a4$H0?;r{&){*C$pcY&j*CFO_UQc7n9-hj2>H!6p( z%El5&smxr9S`eEh2nQOZH-h)Dh?Aaw+6OZuMiMAe6$M9aD-_2YrA}3ljIXM_m;qR% zI9ANSp)7(b!DGy&mjmjA9D?6~e8kTR%ajF#v)~!>ceT2o1AdSXay|z=S?l0H(LEnoo>{Z1kOCh+T>49XPT@8I898eki!OduTdr;G{O4hrr`&IPFPK4la8 z#j1R4Xq(vDt}ksjEl&}sa0S~$i#oP~oAra=ZozNG5+gH7nwD+e%6{~Tdh*eP6}?(x z9{j+bf`99@n4fk2$qx=Hfc+JY%B9OGYykej=1mc0m_#Z=N)cA}A-Oe$49sG0B^#@J zi4laU`JDOq6@H^O)hM9DGc-s=C!zVbGP7j;=2ri$Sy{1HmaUomGkvkeMUBe8i8K$_!7L;uhiI_%RsX`F`AMTs23xlU;dy+#hxQXvYn=-Ql`ZjvV}k zW9igQK>RcEd0JETQ?7qipTb#f)R>8wJXu(25x>*S?KfJ=e#7q==yr?xgu=~_Y{1bu zTZVO58EhNoMy;_Ytl&&$Xd-*HU-=i;{@TMCe}N!!ysbXFO4_Tr5u0B|Xoz(F*)qE) z!`6LbU5RU4B#pBeV#nUgw_4*NKn`^fRfNU-+gxX(2$LeizdcKl0bRmJ&2>(Q0vUJu zldtJmvWYz^hL@r-A33`LCIt203YDC!K56P-wK2A_FPqj?)4H^)TNNN&2EF_cWY`u$ zS&!{GB{Rb~keChrJqljg@xzl#PXE-e1ns>>N z7T+x_E~J*`nt*y<`ePE_L<0EPvv;K_TN@St1J8UAc(%#;g>!v=VW7@0a5PnCTY28Z zZyKDKIY?;5VwNA~Sbdg%`%xIeY5X?&Qp2DHz!QC{HqRV^aHq2@Ty0(Oo4qm7(yEM6 zM)0likTkX&W20%D4vn2Qwq8s@INiibSh%$`4K5=E;TScF(|85H!2+?AGeiJyEbD*= z&;nmo|1Izvb`D=^%zMgo0i7vCkcb_~#yQ@%L8ssfg$Gnlus>YPzb(RV(w|@d{7AJj znohW2=Fjn4qZ<_Xtux|;0#OQny9k-UX)NnJY8;34ZlGN6F6J<4>mdQWS(hUm5YF6e zMNcvN5wW{tKfYziK-*}<*TdHF0%5z;gn3iQswjbscN#%H05;T`95n^P;W#m>Xx>5~ zXX-%9We5itlXDI5WBF-QDwD4W&`dC#BqTLI<8r+=a86mo@g#l*J1ZI}4BAa+j46mw zi5e7)r{jmQp=A+P4M&Sh?iWEgRBzJXjyX4B8Ao;Vtlnaue%Pb~jCM^XF(wLnCaX4L zn8c{_r}KPWF=}W>#lnqk;pn9V^g2E88x$O_mupeyARH82{9zws10nj5Z$F8?)w>=k z3eJPI)9x{ce-Dr?nRybmIz8lz3VG{47<(1J7UZ;x_Am6PAgU&3H+RzkW=3vu7Y@Hx zl}ni@atKF=V6!n;Z?N#``E$x9_Ayzyji+p4Wve9zAGAD~p~4k@<0-JM;NQG43nw1l z57~l^w}dR{LVc8M-lqKb6a1zLD|#J^1yAKr|6vX%S{Px0CiqiT4um-nNDX9m87yS2 z4I5?{&P}mcaxV32VP7Pf$v@BnMBcw>n_Jb^Mk8e9`X2L=_{(^JBvkyY8aRLldlLl_ z6%bMov77`!6th(8e6V*a0akfzeDbnX{>7fj|5BHpo1b6EjpZY-* zf%Dj&*l+9`gPX$sjUZGbu6JlHAJtm>4d@8_u+lgZ!@rr#ke}XBC=}dH>>ol9Ijlz` z4guv1q{`3CB?)Lz>pGw#w;_)T?*q6n`QR@LWpkzbSNEWB7B zL5_{j$kG2eeY+BD6YM+5X(xazMKya(n<=2naLrQwuA#jNs= zIeK`-@hjijLEkjOI2P4a@+5aFfo+2P%-Vbxg=c%^{6c;1zAqM87QR>XrxW~kH~=IR z_-zKOkNaCbE>g;_iV&|FNhh~S{#t9EI~u|%TR1bfg{y7U!rQ>vap*bBIm~IQV%u9b zt1z2xgSyJH>VB_xJ^+=`9~R)Zyd#miK)8Q)tAA`Qz;8L`R5=B+DG%Kb%mCP^{A*>3 zf7^Ej59p5!CE;cY-5(GRW!aUFH570TlPcXA=t8gKw?+v<7lTWuGVcLIjg`?0XMWVg z1Zo_O@!LV&-kl4TZ#%*Zu|hweX+oMG9%?5smU1@ZhSle zAdOWU^@%(!LWRrVy2{zM-0}^|ls^e((}!Mj-fupBx(dT&c#2hdn|`JEIvu}mGUXAz zE}s?WAsk`p&&he)?wIv!OSbA5?R1;bp$&xV9n|Va6{EZ2oXegal?o6}&Y#Zlb$W+e zuyD`0EnI#gRR(o;g5MMi2VPeYPIRNUsd<&MLtp8H_J;H~04YjFz;A2*Y4V$yq9_5Pl`7Sp9MkHAoOY&IR!LaFP|9nX5um^B}nAP#*P7+m( zJQ*kRaq2haEmiUmVoI8xc*>!ko*DBlDCRbUI=xK9}6Q`;iGA}o-jKOxfmZXLx+xbM7Gk!GOO#W4UVvjAx zU_a0zjmfAk3``K*_q`jgRB}0RG@qH?oo_z6y+?o0wR`(D|JqxanFJ-sk~4Zt6p(AK z^~WbV6Z#2vUvL|Y&OgRf&QYH!8Y11jPn*}VvE?UY4nazkcj+>IQ$;BFx9RgNGleZz zjxv**De_D5j0l|C@}L{dD^_YXyieV3Jh~rYnx!I_)dvHoPSwBjD;q2JMHA+&vi_lc z;dAeS^}tM+tbE~qn}Xby%%>?mR_Rai@TPqJls6hYkOay^NnL$tS!vc7t#sv6xbi88 z&iX*O@OXmXSgIHoK)4cHIOO6u;omS6pBs$2idc+Lq+$h!7L`*BkN|3Ym4mcy;|S}B z%c##ziqY}WY8(dx%*eM}ddpCjm#x`WQx3%8##cLHKSt|w-z@l6y1`r*MO8}8zjS_~ zfnj7$hZDbtd>NIcXK{*h{*u;v$r)G~TSo8%DS)x};>So*ubr*NMLw z?xp8kxK57ZnwTJt)v3mo5#5E}zFX+CI7EEbW5oodv68kP;@W*u{hrkKd}e-R0A};} zO;{Ah`1OdfQ~Og(Mo>OXs3PUajBFOhp9y};-|&^ypRqFjJIAzyl5QPxtNoYR`)wX;R zJ6J3*MQ_^et4NI8PIK_KUX9ia#*TE$B;jCklwv}kLc!sn?-(iYZ>>AwtWds>y58W6 z5gd9fpgug_w6L5IKXL$UN}E}J0@YA}iXt^XECBeY{{Z3eD14=s2AE_{>)vZU`QDT7-?jTk zc5-O53N(%@K)C+>95Kr*0Ec7jsHf@L(7&A>lF*_&4na=u$Ni z2buPeId>Tchb`_0Q~2$uPm7DPHHUBrX#J`70NZpiiN7e|TmLngk-&%VkXMpA3FXl+ zbzwR(YmKKM&~M6B5}S49q(b)0!Kzr`s1M++jNg<^Ec~*;EqU0)W?U4R+r+*g&-hZy zkbdUO8z&2}f`fb$4}ao0(u76#h z6G?Sl2EgF^Y)k3LRc1y%lJGlsS@g_nC%W)C&af~ugt9)h{7$GW--64LhLqsmTE_(X z>in}|)i&GaabT=_#+oZRRG&00s2nY?z?&K} za(M-o^T$J=5!3_aw-&y>Y zUuy<l^!`92@k)?ES+wd>1m72b+Xxb3BT2M>Xfc^*rL*C zP_56BV&+S{c^g~T5z9BaX$9fG(z8$j-^Y7LCy4>^lu^zWFk6>Go>=EO|HkxwA44B4?M6!* z{t$ywEV8a6?`Yt5`pttr++F`+2>(_PZZKnta~m^n^e8F>{*5lg{T>R!@eh_ee$@o!Cr|-RXmKSAyC<$>S+^iV zv_8vuXrpHdl0ozwVqrRnd)}cP9m@Gr?`qZnV4km&!Ln%7sPO_`nsVJf9GB92LZ*3# z6UR-wWE){leiim|IfTQYks!ISpEGYlyXgW#pkZMPtEQev#@~|}8Z9T&dWuXFleX#4 zynLB<(+Mr)->6%KG&icyq?oL^u(0tn^&LVboS zBmOdeE2g-g!o%kRaW#Y^evRUUs(PBkZ_~AuH-u6*%+|kZ+?FSWDpqhXY${6yTbK{q zoGnZWwou;8b_QJvRYfWR#lmrm2utL`AV4^*$LZwOVXtu!aVQ>ThiYGr5SDupm_%aE zO%UaM{;N-L;6qHFP;!BCMa3|iD}JGg%)WGf0r0G|tvu*Y75OFr=_zK3WI1N-Q}_)C zr}d{+cPRSPF@Bq(;Dm{C#w?r#K@9~b@iRGt?#^1=t^x54Cp=tORW1HZMgR+vA|3na2H<3jJyd^Kh~E~1HzFYQ_uv5qUCJyFaA+}p zQ}%D2k-0f3X}RZ&bDhJjyayIrfUz>VJTvQ=U*WglDM4Gxab`NO=s?H#%{sI3V;Q@2 zo-G}Ym~vtBayOLalG{1%CclryRWofEB)GfVc;zZxI?I+e<)$?{8`Vxi^1KP82{_$+ zP*4P_70{)E(7A01yg&cD&my4ic`50k+teZ8t~0J zT)3IyPy=0vkx2j1F^u+Xe$jxhDu^&|T**HEV1A>52y;H392m~n#G0LUWv#h4kA<%;O75}ErFIX4F`2__LHOitCQ}|7Tt9RpJ zO0Do`88{K`!t$#6pRS#J3SCq`3+gkk$s8aRw+!i)(oOJFnNj(v{-O2ZpPb-o+?ii! zFGe>rcA4F(eRFWSI7N|vn`~iTD#G7hIYq%mN1)i4DIGz$E*F*0R1PL{MOLv_d>mFc zmaT&Z&_ud)Zp=@|E}I-k=DGHtbp%7Zb2#cLkM7KPR6eJsDZ8fZcl83Uua)lUF9Tn zjV;U-H}|p-tCOd2ENIFgOoRnJ;R@g3Jbq(MM1>0Jfd?Qb$SpVK=cPIc$a|Fyt_!Q* z7T3~Zw^{tAKzCHzm;e%;;lgu(kyx%XI&3QZMw8*-**JSbK{%1h(UsAC=ySR5c#2jY z@T!zFAN9ij=M~GYR)SBf43G!E;aCL(^m4cJS$@Ma&)fh^^@n-<_7Zp_S%u$7^Zj^3 zWgC-ADu*2|`mf+e?sA44+{=xu#zidMXKf%UJ`cm1w0^Z2g&&tCWl_SUh3i#2b{vDnu3Bx4tpL*6~ z%f9u(n*v>^V}ttqDKWpu*X`Hl`8t>}AX(YHp8ubfhg&1^vKd=YGFqFj2d1$Zc~YDg zn|~u)*SQZw2g8uTTb2*=i(+`QaQ~%(l);+{3kBC0+r$n_KPoXV&-ls-&jp%-^d#35 zbR7&?wZ4G($3b4uEOZ^EStyr+Ij6Z97dpp}k@?AI-e9C?JlQ*#*vC#N3#zDeZ3v1~ z1%W{0nEtBx6|9}B%i@KOzg$Hse%>&Da_*)Kfi%P_CqY6lr7|DC!f)mLC~PwW;mY{! z%_&Y<+RW6aN$Nm5|7J;N`e(Uv-kBK{1mxCS8*uEMf&c^5b3Q-1)DgRw zMIRkRXY9=)lsiK?|1;6+m}lhYbObG>Su2kboo&|fNwoP&tvQF%-Nh4qv1DGLPH{oK zT2181jKRHdu;uv{PiM(JE5$!aDUU%^qC)fm;kffnXX(xQkzX4bufNLkW)PhpEgwH; z?$wCwxkm%kqbh4JR_V_SF_Hkn6*q?{{C2K?f?@K@1-b~>-h2jrV4fq9>ao({8|L~a?yl+?IPxWPupHtXp)#r)ZIolDO;=Ki70uvmiGC zZ#N{arytpi!`N3~Ex;^L)TYczpjycG+ zW(RUn3}?D2QR_Yh!ZmOCK?lxea`(;vVL^l6<);=@wt0@868~YsX6UMzc=BBaqfhv^ z&Lp6U0e%ep4}Jrc0o#Cc;5WJuI|6D_r}Fphnfd+GSNJ*%m;PR>0x$-In>>?*EfpIu zy$0!mM@Ov~=6t;WB8YO#sA?C6v5*$lp7v9sY+?;;V#gb|h4K^dpzL*_)X)@Qj+>ty zj`z%Xhue*~pi)eBRs2&ylzdsUz>TS6Nu3|^Fc~8ypTd)6@J5iC4VOX%Jj)OW;|CS_ zOEIfN=JDz~<7ZaXNl1`a^Iu-P0A}xWD*rs+oZ{y3a5+Ea`dL`spUOX~hf@1Yyej7T z{y7u*donWSY_ zImVLzW*lo1gbWM`rIRBGTv5VLxOU|bG?!Fhj5I0cco8X3Tuun&5Kb<&ps?lo5rC9a zYOqgemxQQ<9>Ee1OCF5z4sv_Ey&l)T>5RQz-g)pwz}JJ6^D`+$xsk^Hmzv;rBq7(n zy#u@vGu#NsZNk5u$&c3q=hWr-Ks%huHYA?^n9P6^u8igv8I-{Mb96M`{~o)o+qQSz z!ns#o*%pr9)oO7;U#=;hkKuQ`(T4&UZfeW95WfN5WH0c-N37Y$gX^a}z1tD0O#gP& ze@uo+$_WD8ki(u2F$QV$!}j?^W%>4Ek^g#yS~7lW=2v-E_-(3)YVVWpci6v_VHm;y zGaww#wtC+C__=voo_B4Y-mN^jW`v*CT39WRZzw$ha`YmUr;uO^#r}?8PR^f>`_D^! z-QRH~yuWDSUV&BK9|TG3F0t?ayKD-W|7V=WpPRS7E8Otku|j(;BCz9)Xvg*pim($Q+qEAh`1=gqHgPjQRzu+E9{yq=#KVZOd3 zuO+E`5i3hhGsC)EI*9hX6#3sCMCI!BjOlD>&+GZoV%qb%ye`FmhDYaN#`7PTrJ0!d zsw0QxSXii6g3OOEV)$A4-xp+IRu{fx!Nq<_Su0_A4tb(L9dsOYN;wEe8U+Rm2JQ<6 zJ{kb($^!HL_`HXOVRYQ;9eG~YaroKdgJzTGe$(Ew?Ok#0)0Y{%@gg`M^Gk1pk5c#8 zs9(rE@fH4;9lCPo^5eO3%MH_}o;hX9AiD-8H+a9_jo-)>_qPa&y9niHXFIZ4z$lJi zv+^%Pc+r=#{pS1k%*^F!nFxVoWrv28Lki-~Z0poAPb{u*(dlBXiZIG|`@-glFqYv6 Tqs2oW*hUciT=N?~#030*gz - /// Defines an object that will be a mutex for this object for synchronizing thread calls. - ///
- private static volatile object Mutex = new object(); - #endregion - - #region ctors - protected SelectionListener(ServiceProvider serviceProviderParameter) - { - if (serviceProviderParameter == null) - { - throw new ArgumentNullException("serviceProviderParameter"); - } - - this.serviceProvider = serviceProviderParameter; - this.monSel = this.serviceProvider.GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection; - - if(this.monSel == null) - { - throw new InvalidOperationException(); - } - } - #endregion - - #region properties - protected uint EventsCookie - { - get - { - return this.eventsCookie; - } - } - - protected IVsMonitorSelection SelectionMonitor - { - get - { - return this.monSel; - } - } - - protected ServiceProvider ServiceProvider - { - get - { - return this.serviceProvider; - } - } - #endregion - - #region IVsSelectionEvents Members - - public virtual int OnCmdUIContextChanged(uint dwCmdUICookie, int fActive) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnElementValueChanged(uint elementid, object varValueOld, object varValueNew) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) - { - return VSConstants.E_NOTIMPL; - } - - #endregion - - #region IDisposable Members - /// - /// The IDispose interface Dispose method for disposing the object determinastically. - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - #endregion - - #region methods - public void Init() - { - if(this.SelectionMonitor != null) - { - ErrorHandler.ThrowOnFailure(this.SelectionMonitor.AdviseSelectionEvents(this, out this.eventsCookie)); - } - } - - /// - /// The method that does the cleanup. - /// - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsMonitorSelection.UnadviseSelectionEvents(System.UInt32)")] - protected virtual void Dispose(bool disposing) - { - // Everybody can go here. - if(!this.isDisposed) - { - // Synchronize calls to the Dispose simulteniously. - lock(Mutex) - { - if(disposing && this.eventsCookie != (uint)ShellConstants.VSCOOKIE_NIL && this.SelectionMonitor != null) - { - this.SelectionMonitor.UnadviseSelectionEvents((uint)this.eventsCookie); - this.eventsCookie = (uint)ShellConstants.VSCOOKIE_NIL; - } - - this.isDisposed = true; - } - } - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/SettingsPage.cs b/SHFB/Source/MPFProj_VS2010/SettingsPage.cs deleted file mode 100644 index 959e18eb..00000000 --- a/SHFB/Source/MPFProj_VS2010/SettingsPage.cs +++ /dev/null @@ -1,524 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.ComponentModel; -using System.Drawing; -using System.Globalization; -using System.Runtime.InteropServices; -using System.Security.Permissions; -using System.Windows.Forms; -using Microsoft.VisualStudio.Designer.Interfaces; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project -{ - - /// - /// The base class for property pages. - /// - [CLSCompliant(false), ComVisible(true)] - public abstract class SettingsPage : - LocalizableProperties, - IPropertyPage, - IDisposable - { - #region fields - private Panel panel; - private bool active; - private bool dirty; - private IPropertyPageSite site; - private ProjectNode project; - private ProjectConfig[] projectConfigs; - private IVSMDPropertyGrid grid; - private string name; - private static volatile object Mutex = new object(); - private bool isDisposed; - #endregion - - #region properties - - [Browsable(false)] - [AutomationBrowsable(false)] - public string Name - { - get - { - return this.name; - } - set - { - this.name = value; - } - } - - [Browsable(false)] - [AutomationBrowsable(false)] - public ProjectNode ProjectMgr - { - get - { - return this.project; - } - } - - protected IVSMDPropertyGrid Grid - { - get { return this.grid; } - } - - protected bool IsDirty - { - get - { - return this.dirty; - } - set - { - if(this.dirty != value) - { - this.dirty = value; - if(this.site != null) - site.OnStatusChange((uint)(this.dirty ? PropPageStatus.Dirty : PropPageStatus.Clean)); - } - } - } - protected Panel ThePanel - { - get - { - return this.panel; - } - } - #endregion - - #region abstract methods - protected abstract void BindProperties(); - protected abstract int ApplyChanges(); - #endregion - - #region public methods - public object GetTypedConfigProperty(string name, Type type) - { - string value = GetConfigProperty(name); - if(string.IsNullOrEmpty(value)) return null; - - TypeConverter tc = TypeDescriptor.GetConverter(type); - return tc.ConvertFromInvariantString(value); - } - - public object GetTypedProperty(string name, Type type) - { - string value = GetProperty(name); - if(string.IsNullOrEmpty(value)) return null; - - TypeConverter tc = TypeDescriptor.GetConverter(type); - return tc.ConvertFromInvariantString(value); - } - - public string GetProperty(string propertyName) - { - if(this.ProjectMgr != null) - { - string property; - bool found = this.ProjectMgr.BuildProject.GlobalProperties.TryGetValue(propertyName, out property); - - if(found) - { - return property; - } - } - - return String.Empty; - } - - // relative to active configuration. - public string GetConfigProperty(string propertyName) - { - if(this.ProjectMgr != null) - { - string unifiedResult = null; - bool cacheNeedReset = true; - - for(int i = 0; i < this.projectConfigs.Length; i++) - { - ProjectConfig config = projectConfigs[i]; - string property = config.GetConfigurationProperty(propertyName, cacheNeedReset); - cacheNeedReset = false; - - if(property != null) - { - string text = property.Trim(); - - if(i == 0) - unifiedResult = text; - else if(unifiedResult != text) - return ""; // tristate value is blank then - } - } - - return unifiedResult; - } - - return String.Empty; - } - - /// - /// Sets the value of a configuration dependent property. - /// If the attribute does not exist it is created. - /// If value is null it will be set to an empty string. - /// - /// property name. - /// value of property - public void SetConfigProperty(string name, string value) - { - CCITracing.TraceCall(); - if(value == null) - { - value = String.Empty; - } - - if(this.ProjectMgr != null) - { - for(int i = 0, n = this.projectConfigs.Length; i < n; i++) - { - ProjectConfig config = projectConfigs[i]; - - config.SetConfigurationProperty(name, value); - } - - this.ProjectMgr.SetProjectFileDirty(true); - } - } - - #endregion - - #region IPropertyPage methods. - public virtual void Activate(IntPtr parent, RECT[] pRect, int bModal) - { - if(this.panel == null) - { - if (pRect == null) - { - throw new ArgumentNullException("pRect"); - } - - this.panel = new Panel(); - this.panel.Size = new Size(pRect[0].right - pRect[0].left, pRect[0].bottom - pRect[0].top); - this.panel.Text = SR.GetString(SR.Settings, CultureInfo.CurrentUICulture); - this.panel.Visible = false; - this.panel.Size = new Size(550, 300); - this.panel.CreateControl(); - NativeMethods.SetParent(this.panel.Handle, parent); - } - - if(this.grid == null && this.project != null && this.project.Site != null) - { - IVSMDPropertyBrowser pb = this.project.Site.GetService(typeof(IVSMDPropertyBrowser)) as IVSMDPropertyBrowser; - this.grid = pb.CreatePropertyGrid(); - } - - if(this.grid != null) - { - this.active = true; - - - Control cGrid = Control.FromHandle(new IntPtr(this.grid.Handle)); - - cGrid.Parent = Control.FromHandle(parent);//this.panel; - cGrid.Size = new Size(544, 294); - cGrid.Location = new Point(3, 3); - cGrid.Visible = true; - this.grid.SetOption(_PROPERTYGRIDOPTION.PGOPT_TOOLBAR, false); - this.grid.GridSort = _PROPERTYGRIDSORT.PGSORT_CATEGORIZED | _PROPERTYGRIDSORT.PGSORT_ALPHABETICAL; - NativeMethods.SetParent(new IntPtr(this.grid.Handle), this.panel.Handle); - UpdateObjects(); - } - } - - public virtual int Apply() - { - if(IsDirty) - { - return this.ApplyChanges(); - } - return VSConstants.S_OK; - } - - public virtual void Deactivate() - { - if(null != this.panel) - { - this.panel.Dispose(); - this.panel = null; - } - this.active = false; - } - - public virtual void GetPageInfo(PROPPAGEINFO[] arrInfo) - { - if (arrInfo == null) - { - throw new ArgumentNullException("arrInfo"); - } - - PROPPAGEINFO info = new PROPPAGEINFO(); - - info.cb = (uint)Marshal.SizeOf(typeof(PROPPAGEINFO)); - info.dwHelpContext = 0; - info.pszDocString = null; - info.pszHelpFile = null; - info.pszTitle = this.name; - info.SIZE.cx = 550; - info.SIZE.cy = 300; - arrInfo[0] = info; - } - - public virtual void Help(string helpDir) - { - } - - public virtual int IsPageDirty() - { - // Note this returns an HRESULT not a Bool. - return (IsDirty ? (int)VSConstants.S_OK : (int)VSConstants.S_FALSE); - } - - public virtual void Move(RECT[] arrRect) - { - if (arrRect == null) - { - throw new ArgumentNullException("arrRect"); - } - - RECT r = arrRect[0]; - - this.panel.Location = new Point(r.left, r.top); - this.panel.Size = new Size(r.right - r.left, r.bottom - r.top); - } - - public virtual void SetObjects(uint count, object[] punk) - { - if (punk == null) - { - return; - } - - if(count > 0) - { - if(punk[0] is ProjectConfig) - { - ArrayList configs = new ArrayList(); - - for(int i = 0; i < count; i++) - { - ProjectConfig config = (ProjectConfig)punk[i]; - - if(this.project == null || (this.project != (punk[0] as ProjectConfig).ProjectMgr)) - { - this.project = config.ProjectMgr; - } - - configs.Add(config); - } - - this.projectConfigs = (ProjectConfig[])configs.ToArray(typeof(ProjectConfig)); - } - else if(punk[0] is NodeProperties) - { - if (this.project == null || (this.project != (punk[0] as NodeProperties).Node.ProjectMgr)) - { - this.project = (punk[0] as NodeProperties).Node.ProjectMgr; - } - - System.Collections.Generic.Dictionary configsMap = new System.Collections.Generic.Dictionary(); - - for(int i = 0; i < count; i++) - { - NodeProperties property = (NodeProperties)punk[i]; - IVsCfgProvider provider; - ErrorHandler.ThrowOnFailure(property.Node.ProjectMgr.GetCfgProvider(out provider)); - uint[] expected = new uint[1]; - ErrorHandler.ThrowOnFailure(provider.GetCfgs(0, null, expected, null)); - if(expected[0] > 0) - { - ProjectConfig[] configs = new ProjectConfig[expected[0]]; - uint[] actual = new uint[1]; - ErrorHandler.ThrowOnFailure(provider.GetCfgs(expected[0], configs, actual, null)); - - foreach(ProjectConfig config in configs) - { - if(!configsMap.ContainsKey(config.ConfigName)) - { - configsMap.Add(config.ConfigName, config); - } - } - } - } - - if(configsMap.Count > 0) - { - if(this.projectConfigs == null) - { - this.projectConfigs = new ProjectConfig[configsMap.Keys.Count]; - } - configsMap.Values.CopyTo(this.projectConfigs, 0); - } - } - } - else - { - this.project = null; - } - - if(this.active && this.project != null) - { - UpdateObjects(); - } - } - - - public virtual void SetPageSite(IPropertyPageSite theSite) - { - this.site = theSite; - } - - public virtual void Show(uint cmd) - { - this.panel.Visible = true; // TODO: pass SW_SHOW* flags through - this.panel.Show(); - } - - public virtual int TranslateAccelerator(MSG[] arrMsg) - { - if (arrMsg == null) - { - throw new ArgumentNullException("arrMsg"); - } - - MSG msg = arrMsg[0]; - - if((msg.message < NativeMethods.WM_KEYFIRST || msg.message > NativeMethods.WM_KEYLAST) && (msg.message < NativeMethods.WM_MOUSEFIRST || msg.message > NativeMethods.WM_MOUSELAST)) - return 1; - - return (NativeMethods.IsDialogMessageA(this.panel.Handle, ref msg)) ? 0 : 1; - } - - #endregion - - #region helper methods - - protected ProjectConfig[] GetProjectConfigurations() - { - return this.projectConfigs; - } - - protected void UpdateObjects() - { - if(this.projectConfigs != null && this.project != null) - { - // Demand unmanaged permissions in order to access unmanaged memory. - new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); - - IntPtr p = Marshal.GetIUnknownForObject(this); - IntPtr ppUnk = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr))); - try - { - Marshal.WriteIntPtr(ppUnk, p); - this.BindProperties(); - // BUGBUG -- this is really bad casting a pointer to "int"... - this.grid.SetSelectedObjects(1, ppUnk.ToInt32()); - this.grid.Refresh(); - } - finally - { - if(ppUnk != IntPtr.Zero) - { - Marshal.FreeCoTaskMem(ppUnk); - } - if(p != IntPtr.Zero) - { - Marshal.Release(p); - } - } - } - } - #endregion - - #region IDisposable Members - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - private void Dispose(bool disposing) - { - if(!this.isDisposed) - { - lock(Mutex) - { - if(disposing) - { - this.panel.Dispose(); - } - - this.isDisposed = true; - } - } - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/SingleFileGenerator.cs b/SHFB/Source/MPFProj_VS2010/SingleFileGenerator.cs deleted file mode 100644 index 3542e9b3..00000000 --- a/SHFB/Source/MPFProj_VS2010/SingleFileGenerator.cs +++ /dev/null @@ -1,554 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.TextManager.Interop; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Provides support for single file generator. - /// - internal class SingleFileGenerator : ISingleFileGenerator, IVsGeneratorProgress - { - - #region fields - private bool gettingCheckoutStatus; - private bool runningGenerator; - private ProjectNode projectMgr; - #endregion - - #region ctors - /// - /// Overloadde ctor. - /// - /// The associated project - internal SingleFileGenerator(ProjectNode projectMgr) - { - this.projectMgr = projectMgr; - } - #endregion - - #region IVsGeneratorProgress Members - - public virtual int GeneratorError(int warning, uint level, string err, uint line, uint col) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int Progress(uint complete, uint total) - { - return VSConstants.E_NOTIMPL; - } - - #endregion - - #region ISingleFileGenerator - /// - /// Runs the generator on the current project item. - /// - /// - /// - public virtual void RunGenerator(string document) - { - // Go run the generator on that node, but only if the file is dirty - // in the running document table. Otherwise there is no need to rerun - // the generator because if the original document is not dirty then - // the generated output should be already up to date. - uint itemid = VSConstants.VSITEMID_NIL; - IVsHierarchy hier = (IVsHierarchy)this.projectMgr; - if(document != null && hier != null && ErrorHandler.Succeeded(hier.ParseCanonicalName((string)document, out itemid))) - { - IVsHierarchy rdtHier; - IVsPersistDocData perDocData; - uint cookie; - if(this.VerifyFileDirtyInRdt((string)document, out rdtHier, out perDocData, out cookie)) - { - // Run the generator on the indicated document - FileNode node = (FileNode)this.projectMgr.NodeFromItemId(itemid); - this.InvokeGenerator(node); - } - } - } - #endregion - - #region virtual methods - /// - /// Invokes the specified generator - /// - /// The node on which to invoke the generator. - protected internal virtual void InvokeGenerator(FileNode fileNode) - { - if(fileNode == null) - { - throw new ArgumentNullException("fileNode"); - } - - SingleFileGeneratorNodeProperties nodeproperties = fileNode.NodeProperties as SingleFileGeneratorNodeProperties; - if(nodeproperties == null) - { - throw new InvalidOperationException(); - } - - string customToolProgID = nodeproperties.CustomTool; - if(string.IsNullOrEmpty(customToolProgID)) - { - return; - } - - string customToolNamespace = nodeproperties.CustomToolNamespace; - - try - { - if(!this.runningGenerator) - { - //Get the buffer contents for the current node - string moniker = fileNode.GetMkDocument(); - - this.runningGenerator = true; - - //Get the generator - IVsSingleFileGenerator generator; - int generateDesignTimeSource; - int generateSharedDesignTimeSource; - int generateTempPE; - SingleFileGeneratorFactory factory = new SingleFileGeneratorFactory(this.projectMgr.ProjectGuid, this.projectMgr.Site); - ErrorHandler.ThrowOnFailure(factory.CreateGeneratorInstance(customToolProgID, out generateDesignTimeSource, out generateSharedDesignTimeSource, out generateTempPE, out generator)); - - //Check to see if the generator supports siting - IObjectWithSite objWithSite = generator as IObjectWithSite; - if(objWithSite != null) - { - objWithSite.SetSite(fileNode.OleServiceProvider); - } - - //Determine the namespace - if(string.IsNullOrEmpty(customToolNamespace)) - { - customToolNamespace = this.ComputeNamespace(moniker); - } - - //Run the generator - IntPtr[] output = new IntPtr[1]; - output[0] = IntPtr.Zero; - uint outPutSize; - string extension; - ErrorHandler.ThrowOnFailure(generator.DefaultExtension(out extension)); - - //Find if any dependent node exists - string dependentNodeName = Path.GetFileNameWithoutExtension(fileNode.FileName) + extension; - HierarchyNode dependentNode = fileNode.FirstChild; - while(dependentNode != null) - { - if(string.Compare(dependentNode.ItemNode.GetMetadata(ProjectFileConstants.DependentUpon), fileNode.FileName, StringComparison.OrdinalIgnoreCase) == 0) - { - dependentNodeName = ((FileNode)dependentNode).FileName; - break; - } - - dependentNode = dependentNode.NextSibling; - } - - //If you found a dependent node. - if(dependentNode != null) - { - //Then check out the node and dependent node from SCC - if(!this.CanEditFile(dependentNode.GetMkDocument())) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - } - else //It is a new node to be added to the project - { - // Check out the project file if necessary. - if(!this.projectMgr.QueryEditProjectFile(false)) - { - throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); - } - } - IVsTextStream stream; - string inputFileContents = this.GetBufferContents(moniker, out stream); - - ErrorHandler.ThrowOnFailure(generator.Generate(moniker, inputFileContents, customToolNamespace, output, out outPutSize, this)); - byte[] data = new byte[outPutSize]; - - if(output[0] != IntPtr.Zero) - { - Marshal.Copy(output[0], data, 0, (int)outPutSize); - Marshal.FreeCoTaskMem(output[0]); - } - - //Todo - Create a file and add it to the Project - this.UpdateGeneratedCodeFile(fileNode, data, (int)outPutSize, dependentNodeName); - } - } - finally - { - this.runningGenerator = false; - } - } - - /// - /// Computes the names space based on the folder for the ProjectItem. It just replaces DirectorySeparatorCharacter - /// with "." for the directory in which the file is located. - /// - /// Returns the computed name space - protected virtual string ComputeNamespace(string projectItemPath) - { - if(String.IsNullOrEmpty(projectItemPath)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "projectItemPath"); - } - - - string nspace = ""; - string filePath = Path.GetDirectoryName(projectItemPath); - string[] toks = filePath.Split(new char[] { ':', '\\' }); - foreach(string tok in toks) - { - if(!String.IsNullOrEmpty(tok)) - { - string temp = tok.Replace(" ", ""); - nspace += (temp + "."); - } - } - nspace = nspace.Remove(nspace.LastIndexOf(".", StringComparison.Ordinal), 1); - return nspace; - } - - /// - /// This is called after the single file generator has been invoked to create or update the code file. - /// - /// The node associated to the generator - /// data to update the file with - /// size of the data - /// Name of the file to update or create - /// full path of the file - protected virtual string UpdateGeneratedCodeFile(FileNode fileNode, byte[] data, int size, string fileName) - { - string filePath = Path.Combine(Path.GetDirectoryName(fileNode.GetMkDocument()), fileName); - IVsRunningDocumentTable rdt = this.projectMgr.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - - // (kberes) Shouldn't this be an InvalidOperationException instead with some not to annoying errormessage to the user? - if(rdt == null) - { - ErrorHandler.ThrowOnFailure(VSConstants.E_FAIL); - } - - IVsHierarchy hier; - uint cookie; - uint itemid; - IntPtr docData = IntPtr.Zero; - ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)(_VSRDTFLAGS.RDT_NoLock), filePath, out hier, out itemid, out docData, out cookie)); - if(docData != IntPtr.Zero) - { - Marshal.Release(docData); - IVsTextStream srpStream = null; - if(srpStream != null) - { - int oldLen = 0; - int hr = srpStream.GetSize(out oldLen); - if(ErrorHandler.Succeeded(hr)) - { - IntPtr dest = IntPtr.Zero; - try - { - dest = Marshal.AllocCoTaskMem(data.Length); - Marshal.Copy(data, 0, dest, data.Length); - ErrorHandler.ThrowOnFailure(srpStream.ReplaceStream(0, oldLen, dest, size / 2)); - } - finally - { - if(dest != IntPtr.Zero) - { - Marshal.Release(dest); - } - } - } - } - } - else - { - using(FileStream generatedFileStream = File.Open(filePath, FileMode.OpenOrCreate)) - { - generatedFileStream.Write(data, 0, size); - } - - EnvDTE.ProjectItem projectItem = fileNode.GetAutomationObject() as EnvDTE.ProjectItem; - if(projectItem != null && (this.projectMgr.FindChild(fileNode.FileName) == null)) - { - projectItem.ProjectItems.AddFromFile(filePath); - } - } - return filePath; - } - #endregion - - #region helpers - /// - /// Returns the buffer contents for a moniker. - /// - /// Buffer contents - private string GetBufferContents(string fileName, out IVsTextStream srpStream) - { - Guid CLSID_VsTextBuffer = new Guid("{8E7B96A8-E33D-11d0-A6D5-00C04FB67F6A}"); - string bufferContents = ""; - srpStream = null; - - IVsRunningDocumentTable rdt = this.projectMgr.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - if(rdt != null) - { - IVsHierarchy hier; - IVsPersistDocData persistDocData; - uint itemid, cookie; - bool docInRdt = true; - IntPtr docData = IntPtr.Zero; - int hr = NativeMethods.E_FAIL; - try - { - //Getting a read lock on the document. Must be released later. - hr = rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_ReadLock, fileName, out hier, out itemid, out docData, out cookie); - if(ErrorHandler.Failed(hr) || docData == IntPtr.Zero) - { - Guid iid = VSConstants.IID_IUnknown; - cookie = 0; - docInRdt = false; - ILocalRegistry localReg = this.projectMgr.GetService(typeof(SLocalRegistry)) as ILocalRegistry; - ErrorHandler.ThrowOnFailure(localReg.CreateInstance(CLSID_VsTextBuffer, null, ref iid, (uint)CLSCTX.CLSCTX_INPROC_SERVER, out docData)); - } - - persistDocData = Marshal.GetObjectForIUnknown(docData) as IVsPersistDocData; - } - finally - { - if(docData != IntPtr.Zero) - { - Marshal.Release(docData); - } - } - - //Try to get the Text lines - IVsTextLines srpTextLines = persistDocData as IVsTextLines; - if(srpTextLines == null) - { - // Try getting a text buffer provider first - IVsTextBufferProvider srpTextBufferProvider = persistDocData as IVsTextBufferProvider; - if(srpTextBufferProvider != null) - { - hr = srpTextBufferProvider.GetTextBuffer(out srpTextLines); - } - } - - if(ErrorHandler.Succeeded(hr)) - { - srpStream = srpTextLines as IVsTextStream; - if(srpStream != null) - { - // QI for IVsBatchUpdate and call FlushPendingUpdates if they support it - IVsBatchUpdate srpBatchUpdate = srpStream as IVsBatchUpdate; - if(srpBatchUpdate != null) - ErrorHandler.ThrowOnFailure(srpBatchUpdate.FlushPendingUpdates(0)); - - int lBufferSize = 0; - hr = srpStream.GetSize(out lBufferSize); - - if(ErrorHandler.Succeeded(hr)) - { - IntPtr dest = IntPtr.Zero; - try - { - // Note that GetStream returns Unicode to us so we don't need to do any conversions - dest = Marshal.AllocCoTaskMem((lBufferSize + 1) * 2); - ErrorHandler.ThrowOnFailure(srpStream.GetStream(0, lBufferSize, dest)); - //Get the contents - bufferContents = Marshal.PtrToStringUni(dest); - } - finally - { - if(dest != IntPtr.Zero) - Marshal.FreeCoTaskMem(dest); - } - } - } - - } - // Unlock the document in the RDT if necessary - if(docInRdt && rdt != null) - { - ErrorHandler.ThrowOnFailure(rdt.UnlockDocument((uint)(_VSRDTFLAGS.RDT_ReadLock | _VSRDTFLAGS.RDT_Unlock_NoSave), cookie)); - } - - if(ErrorHandler.Failed(hr)) - { - // If this failed then it's probably not a text file. In that case, - // we just read the file as a binary - bufferContents = File.ReadAllText(fileName); - } - - - } - return bufferContents; - } - - /// - /// Returns TRUE if open and dirty. Note that documents can be open without a - /// window frame so be careful. Returns the DocData and doc cookie if requested - /// - /// document path - /// hierarchy - /// doc data associated with document - /// item cookie - /// True if FIle is dirty - private bool VerifyFileDirtyInRdt(string document, out IVsHierarchy pHier, out IVsPersistDocData ppDocData, out uint cookie) - { - int ret = 0; - pHier = null; - ppDocData = null; - cookie = 0; - - IVsRunningDocumentTable rdt = this.projectMgr.GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable; - if(rdt != null) - { - IntPtr docData; - uint dwCookie = 0; - IVsHierarchy srpHier; - uint itemid = VSConstants.VSITEMID_NIL; - - ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, document, out srpHier, out itemid, out docData, out dwCookie)); - IVsPersistHierarchyItem srpIVsPersistHierarchyItem = srpHier as IVsPersistHierarchyItem; - if(srpIVsPersistHierarchyItem != null) - { - // Found in the RDT. See if it is dirty - try - { - ErrorHandler.ThrowOnFailure(srpIVsPersistHierarchyItem.IsItemDirty(itemid, docData, out ret)); - cookie = dwCookie; - ppDocData = Marshal.GetObjectForIUnknown(docData) as IVsPersistDocData; - } - finally - { - if(docData != IntPtr.Zero) - { - Marshal.Release(docData); - } - - pHier = srpHier; - } - } - } - return (ret == 1); - } - #endregion - - - - - #region QueryEditQuerySave helpers - /// - /// This function asks to the QueryEditQuerySave service if it is possible to - /// edit the file. - /// - private bool CanEditFile(string documentMoniker) - { - Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "\t**** CanEditFile called ****")); - - // Check the status of the recursion guard - if(this.gettingCheckoutStatus) - { - return false; - } - - try - { - // Set the recursion guard - this.gettingCheckoutStatus = true; - - // Get the QueryEditQuerySave service - IVsQueryEditQuerySave2 queryEditQuerySave = (IVsQueryEditQuerySave2)this.projectMgr.GetService(typeof(SVsQueryEditQuerySave)); - - // Now call the QueryEdit method to find the edit status of this file - string[] documents = { documentMoniker }; - uint result; - uint outFlags; - - // Note that this function can popup a dialog to ask the user to checkout the file. - // When this dialog is visible, it is possible to receive other request to change - // the file and this is the reason for the recursion guard. - int hr = queryEditQuerySave.QueryEditFiles( - 0, // Flags - 1, // Number of elements in the array - documents, // Files to edit - null, // Input flags - null, // Input array of VSQEQS_FILE_ATTRIBUTE_DATA - out result, // result of the checkout - out outFlags // Additional flags - ); - - if(ErrorHandler.Succeeded(hr) && (result == (uint)tagVSQueryEditResult.QER_EditOK)) - { - // In this case (and only in this case) we can return true from this function. - return true; - } - } - finally - { - this.gettingCheckoutStatus = false; - } - - return false; - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/SingleFileGeneratorFactory.cs b/SHFB/Source/MPFProj_VS2010/SingleFileGeneratorFactory.cs deleted file mode 100644 index 24d8f79f..00000000 --- a/SHFB/Source/MPFProj_VS2010/SingleFileGeneratorFactory.cs +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.Win32; -using VSRegistry = Microsoft.VisualStudio.Shell.VSRegistry; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Provides implementation IVsSingleFileGeneratorFactory for - /// - public class SingleFileGeneratorFactory : IVsSingleFileGeneratorFactory - { - #region nested types - private class GeneratorMetaData - { - #region fields - private Guid generatorClsid = Guid.Empty; - private int generatesDesignTimeSource = -1; - private int generatesSharedDesignTimeSource = -1; - private int useDesignTimeCompilationFlag = -1; - object generator; - #endregion - - #region ctor - /// - /// Constructor - /// - public GeneratorMetaData() - { - } - #endregion - - #region Public Properties - /// - /// Generator instance - /// - public Object Generator - { - get - { - return generator; - } - set - { - generator = value; - } - } - - /// - /// GeneratesDesignTimeSource reg value name under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[VsVer]\Generators\[ProjFacGuid]\[GeneratorProgId] - /// - public int GeneratesDesignTimeSource - { - get - { - return generatesDesignTimeSource; - } - set - { - generatesDesignTimeSource = value; - } - } - - /// - /// GeneratesSharedDesignTimeSource reg value name under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[VsVer]\Generators\[ProjFacGuid]\[GeneratorProgId] - /// - public int GeneratesSharedDesignTimeSource - { - get - { - return generatesSharedDesignTimeSource; - } - set - { - generatesSharedDesignTimeSource = value; - } - } - - /// - /// UseDesignTimeCompilationFlag reg value name under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[VsVer]\Generators\[ProjFacGuid]\[GeneratorProgId] - /// - public int UseDesignTimeCompilationFlag - { - get - { - return useDesignTimeCompilationFlag; - } - set - { - useDesignTimeCompilationFlag = value; - } - } - - /// - /// Generator Class ID. - /// - public Guid GeneratorClsid - { - get - { - return generatorClsid; - } - set - { - generatorClsid = value; - } - } - #endregion - } - #endregion - - #region fields - /// - /// Base generator registry key for MPF based project - /// - private RegistryKey baseGeneratorRegistryKey; - - /// - /// CLSID reg value name under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[VsVer]\Generators\[ProjFacGuid]\[GeneratorProgId] - /// - private string GeneratorClsid = "CLSID"; - - /// - /// GeneratesDesignTimeSource reg value name under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[VsVer]\Generators\[ProjFacGuid]\[GeneratorProgId] - /// - private string GeneratesDesignTimeSource = "GeneratesDesignTimeSource"; - - /// - /// GeneratesSharedDesignTimeSource reg value name under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[VsVer]\Generators\[ProjFacGuid]\[GeneratorProgId] - /// - private string GeneratesSharedDesignTimeSource = "GeneratesSharedDesignTimeSource"; - - /// - /// UseDesignTimeCompilationFlag reg value name under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[VsVer]\Generators\[ProjFacGuid]\[GeneratorProgId] - /// - private string UseDesignTimeCompilationFlag = "UseDesignTimeCompilationFlag"; - - /// - /// Caches all the generators registered for the project type. - /// - private Dictionary generatorsMap = new Dictionary(); - - /// - /// The project type guid of the associated project. - /// - private Guid projectType; - - /// - /// A service provider - /// - private System.IServiceProvider serviceProvider; - #endregion - - #region ctors - /// - /// Constructor for SingleFileGeneratorFactory - /// - /// The project type guid of the associated project. - /// A service provider. - public SingleFileGeneratorFactory(Guid projectType, System.IServiceProvider serviceProvider) - { - this.projectType = projectType; - this.serviceProvider = serviceProvider; - } - #endregion - - #region properties - /// - /// Defines the project type guid of the associated project. - /// - public Guid ProjectGuid - { - get { return this.projectType; } - set { this.projectType = value; } - } - - /// - /// Defines an associated service provider. - /// - public System.IServiceProvider ServiceProvider - { - get { return this.serviceProvider; } - set { this.serviceProvider = value; } - } - #endregion - - #region IVsSingleFileGeneratorFactory Helpers - /// - /// Returns the project generator key under [VS-ConfigurationRoot]]\Generators - /// - private RegistryKey BaseGeneratorsKey - { - get - { - if(this.baseGeneratorRegistryKey == null) - { - using(RegistryKey root = VSRegistry.RegistryRoot(__VsLocalRegistryType.RegType_Configuration)) - { - if(null != root) - { - string regPath = "Generators\\" + this.ProjectGuid.ToString("B"); - baseGeneratorRegistryKey = root.OpenSubKey(regPath); - } - } - } - - return this.baseGeneratorRegistryKey; - } - } - - /// - /// Returns the local registry instance - /// - private ILocalRegistry LocalRegistry - { - get - { - return this.serviceProvider.GetService(typeof(SLocalRegistry)) as ILocalRegistry; - } - } - #endregion - - #region IVsSingleFileGeneratorFactory Members - /// - /// Creates an instance of the single file generator requested - /// - /// prog id of the generator to be created. For e.g HKLM\SOFTWARE\Microsoft\VisualStudio\9.0Exp\Generators\[prjfacguid]\[wszProgId] - /// GeneratesDesignTimeSource key value - /// GeneratesSharedDesignTimeSource key value - /// UseDesignTimeCompilationFlag key value - /// IVsSingleFileGenerator interface - /// S_OK if succesful - public virtual int CreateGeneratorInstance(string progId, out int generatesDesignTimeSource, out int generatesSharedDesignTimeSource, out int useTempPEFlag, out IVsSingleFileGenerator generate) - { - Guid genGuid; - ErrorHandler.ThrowOnFailure(this.GetGeneratorInformation(progId, out generatesDesignTimeSource, out generatesSharedDesignTimeSource, out useTempPEFlag, out genGuid)); - - //Create the single file generator and pass it out. Check to see if it is in the cache - if(!this.generatorsMap.ContainsKey(progId) || ((this.generatorsMap[progId]).Generator == null)) - { - Guid riid = VSConstants.IID_IUnknown; - uint dwClsCtx = (uint)CLSCTX.CLSCTX_INPROC_SERVER; - IntPtr genIUnknown = IntPtr.Zero; - //create a new one. - ErrorHandler.ThrowOnFailure(this.LocalRegistry.CreateInstance(genGuid, null, ref riid, dwClsCtx, out genIUnknown)); - if(genIUnknown != IntPtr.Zero) - { - try - { - object generator = Marshal.GetObjectForIUnknown(genIUnknown); - //Build the generator meta data object and cache it. - GeneratorMetaData genData = new GeneratorMetaData(); - genData.GeneratesDesignTimeSource = generatesDesignTimeSource; - genData.GeneratesSharedDesignTimeSource = generatesSharedDesignTimeSource; - genData.UseDesignTimeCompilationFlag = useTempPEFlag; - genData.GeneratorClsid = genGuid; - genData.Generator = generator; - this.generatorsMap[progId] = genData; - } - finally - { - Marshal.Release(genIUnknown); - } - } - } - - generate = (this.generatorsMap[progId]).Generator as IVsSingleFileGenerator; - - return VSConstants.S_OK; - } - - /// - /// Gets the default generator based on the file extension. HKLM\Software\Microsoft\VS\9.0\Generators\[prjfacguid]\.extension - /// - /// File name with extension - /// The generator prog ID - /// S_OK if successful - public virtual int GetDefaultGenerator(string filename, out string progID) - { - progID = ""; - return VSConstants.E_NOTIMPL; - } - - /// - /// Gets the generator information. - /// - /// prog id of the generator to be created. For e.g HKLM\SOFTWARE\Microsoft\VisualStudio\9.0Exp\Generators\[prjfacguid]\[wszProgId] - /// GeneratesDesignTimeSource key value - /// GeneratesSharedDesignTimeSource key value - /// UseDesignTimeCompilationFlag key value - /// CLSID key value - /// S_OK if succesful - public virtual int GetGeneratorInformation(string progId, out int generatesDesignTimeSource, out int generatesSharedDesignTimeSource, out int useTempPEFlag, out Guid guidGenerator) - { - RegistryKey genKey; - generatesDesignTimeSource = -1; - generatesSharedDesignTimeSource = -1; - useTempPEFlag = -1; - guidGenerator = Guid.Empty; - if(string.IsNullOrEmpty(progId)) - return VSConstants.S_FALSE; - - //Create the single file generator and pass it out. - if(!this.generatorsMap.ContainsKey(progId)) - { - // We have to check whether the BaseGeneratorkey returns null. - RegistryKey tempBaseGeneratorKey = this.BaseGeneratorsKey; - if(tempBaseGeneratorKey == null || (genKey = tempBaseGeneratorKey.OpenSubKey(progId)) == null) - { - return VSConstants.S_FALSE; - } - - //Get the CLSID - string guid = (string)genKey.GetValue(GeneratorClsid, ""); - if(string.IsNullOrEmpty(guid)) - return VSConstants.S_FALSE; - - GeneratorMetaData genData = new GeneratorMetaData(); - - genData.GeneratorClsid = guidGenerator = new Guid(guid); - //Get the GeneratesDesignTimeSource flag. Assume 0 if not present. - genData.GeneratesDesignTimeSource = generatesDesignTimeSource = (int)genKey.GetValue(this.GeneratesDesignTimeSource, 0); - //Get the GeneratesSharedDesignTimeSource flag. Assume 0 if not present. - genData.GeneratesSharedDesignTimeSource = generatesSharedDesignTimeSource = (int)genKey.GetValue(GeneratesSharedDesignTimeSource, 0); - //Get the UseDesignTimeCompilationFlag flag. Assume 0 if not present. - genData.UseDesignTimeCompilationFlag = useTempPEFlag = (int)genKey.GetValue(UseDesignTimeCompilationFlag, 0); - this.generatorsMap.Add(progId, genData); - } - else - { - GeneratorMetaData genData = this.generatorsMap[progId]; - generatesDesignTimeSource = genData.GeneratesDesignTimeSource; - //Get the GeneratesSharedDesignTimeSource flag. Assume 0 if not present. - generatesSharedDesignTimeSource = genData.GeneratesSharedDesignTimeSource; - //Get the UseDesignTimeCompilationFlag flag. Assume 0 if not present. - useTempPEFlag = genData.UseDesignTimeCompilationFlag; - //Get the CLSID - guidGenerator = genData.GeneratorClsid; - } - - return VSConstants.S_OK; - } - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/SolutionListener.cs b/SHFB/Source/MPFProj_VS2010/SolutionListener.cs deleted file mode 100644 index 5587a360..00000000 --- a/SHFB/Source/MPFProj_VS2010/SolutionListener.cs +++ /dev/null @@ -1,278 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; - -namespace Microsoft.VisualStudio.Project -{ - - [CLSCompliant(false)] - public abstract class SolutionListener : IVsSolutionEvents3, IVsSolutionEvents4, IDisposable - { - - #region fields - private uint eventsCookie; - private IVsSolution solution; - private IServiceProvider serviceProvider; - private bool isDisposed; - /// - /// Defines an object that will be a mutex for this object for synchronizing thread calls. - /// - private static volatile object Mutex = new object(); - #endregion - - #region ctors - protected SolutionListener(IServiceProvider serviceProviderParameter) - { - if (serviceProviderParameter == null) - { - throw new ArgumentNullException("serviceProviderParameter"); - } - - this.serviceProvider = serviceProviderParameter; - this.solution = this.serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution; - - Debug.Assert(this.solution != null, "Could not get the IVsSolution object from the services exposed by this project"); - - if(this.solution == null) - { - throw new InvalidOperationException(); - } - - this.InteropSafeIVsSolutionEvents = Utilities.GetOuterAs(this); - } - #endregion - - #region properties - - public IVsSolutionEvents InteropSafeIVsSolutionEvents - { - get; - protected set; - } - - protected uint EventsCookie - { - get - { - return this.eventsCookie; - } - } - - protected IVsSolution Solution - { - get - { - return this.solution; - } - } - - protected IServiceProvider ServiceProvider - { - get - { - return this.serviceProvider; - } - } - #endregion - - #region IVsSolutionEvents3, IVsSolutionEvents2, IVsSolutionEvents methods - public virtual int OnAfterCloseSolution(object reserved) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterClosingChildren(IVsHierarchy hierarchy) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterLoadProject(IVsHierarchy stubHierarchy, IVsHierarchy realHierarchy) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterMergeSolution(object pUnkReserved) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterOpenProject(IVsHierarchy hierarchy, int added) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterOpenSolution(object pUnkReserved, int fNewSolution) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterOpeningChildren(IVsHierarchy hierarchy) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnBeforeCloseProject(IVsHierarchy hierarchy, int removed) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnBeforeCloseSolution(object pUnkReserved) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnBeforeClosingChildren(IVsHierarchy hierarchy) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnBeforeOpeningChildren(IVsHierarchy hierarchy) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnBeforeUnloadProject(IVsHierarchy realHierarchy, IVsHierarchy rtubHierarchy) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnQueryCloseProject(IVsHierarchy hierarchy, int removing, ref int cancel) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnQueryCloseSolution(object pUnkReserved, ref int cancel) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnQueryUnloadProject(IVsHierarchy pRealHierarchy, ref int cancel) - { - return VSConstants.E_NOTIMPL; - } - #endregion - - #region IVsSolutionEvents4 methods - public virtual int OnAfterAsynchOpenProject(IVsHierarchy hierarchy, int added) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterChangeProjectParent(IVsHierarchy hierarchy) - { - return VSConstants.E_NOTIMPL; - } - - public virtual int OnAfterRenameProject(IVsHierarchy hierarchy) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Fired before a project is moved from one parent to another in the solution explorer - /// - public virtual int OnQueryChangeProjectParent(IVsHierarchy hierarchy, IVsHierarchy newParentHier, ref int cancel) - { - return VSConstants.E_NOTIMPL; - } - #endregion - - #region Dispose - - /// - /// The IDispose interface Dispose method for disposing the object determinastically. - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - #region methods - public void Init() - { - if(this.solution != null) - { - ErrorHandler.ThrowOnFailure(this.solution.AdviseSolutionEvents(this.InteropSafeIVsSolutionEvents, out this.eventsCookie)); - } - } - - /// - /// The method that does the cleanup. - /// - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsSolution.UnadviseSolutionEvents(System.UInt32)")] - protected virtual void Dispose(bool disposing) - { - // Everybody can go here. - if(!this.isDisposed) - { - // Synchronize calls to the Dispose simulteniously. - lock(Mutex) - { - if(disposing && this.eventsCookie != (uint)ShellConstants.VSCOOKIE_NIL && this.solution != null) - { - this.solution.UnadviseSolutionEvents((uint)this.eventsCookie); - this.eventsCookie = (uint)ShellConstants.VSCOOKIE_NIL; - } - - this.isDisposed = true; - } - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/SolutionListenerForBuildDependencyUpdate.cs b/SHFB/Source/MPFProj_VS2010/SolutionListenerForBuildDependencyUpdate.cs deleted file mode 100644 index 40efea93..00000000 --- a/SHFB/Source/MPFProj_VS2010/SolutionListenerForBuildDependencyUpdate.cs +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// The purpose of this class is to set a build dependency from a modeling project to all its sub projects - /// - class SolutionListenerForBuildDependencyUpdate : SolutionListener - { - #region ctors - public SolutionListenerForBuildDependencyUpdate(IServiceProvider serviceProvider) - : base(serviceProvider) - { - } - #endregion - - #region overridden methods - /// - /// Update build dependency list if solution is fully loaded - /// - /// - /// - /// - public override int OnAfterOpenProject(IVsHierarchy hierarchy, int added) - { - // Return from here if we are at load time - if(added == 0) - { - return VSConstants.S_OK; - } - - IBuildDependencyOnProjectContainer projectNode = hierarchy as IBuildDependencyOnProjectContainer; - - // We will update only nested project types and the BuildNestedProjectsOnBuild flag is set to true - if(projectNode != null) - { - if(projectNode.BuildNestedProjectsOnBuild) - { - // Enum all sub projects and add to dependency list - UpdateDependencyListWithSubProjects(projectNode); - } - } - return VSConstants.S_OK; - } - - /// - /// Called at load time when solution has finished opening. - /// - /// reserved - /// true if this is a new solution - /// - public override int OnAfterOpenSolution(object pUnkReserved, int fNewSolution) - { - // Enum all sub project and add to dependeny list - UpdateDependencyListWithSubProjects(null); - - return VSConstants.S_OK; - } - #endregion - - #region Helper methods - /// - /// Update dependency list - /// - /// Project node to be updated. If null then all ProjectContainer nodes are updated - private void UpdateDependencyListWithSubProjects(IBuildDependencyOnProjectContainer projectNode) - { - if(projectNode != null) - { - // Get list of sub projects - IList nestedProjectList = projectNode.EnumNestedHierachiesForBuildDependency(); - if(nestedProjectList != null && nestedProjectList.Count > 0) - { - // Loop nested projects and add project dependency (if supported) - foreach(IVsHierarchy nestedProject in nestedProjectList) - { - AddBuildDependenyToNestedProject(projectNode as IBuildDependencyUpdate, nestedProject); - } - } - } - else - { - // Update all ProjectContainerNode nodes - List projectList = this.GetListOfProjectContainerNodes(); - if(projectList != null && projectList.Count > 0) - { - foreach(IBuildDependencyOnProjectContainer project in projectList) - { - UpdateDependencyListWithSubProjects(project); - } - } - } - } - - /// - /// Enum all projects in the solution and collect all that derives from ProjectContainerNode - /// - /// List of ProjectContainerNode nodes - private List GetListOfProjectContainerNodes() - { - List projectList = new List(); - - Debug.Assert(this.Solution != null, "IVsSolution object not set on this object"); - if(this.Solution == null) - { - // Bad state, so we quit - return projectList; - } - - // Enum projects loaded in the solution (normal projects only) - IEnumHierarchies enumHierarchies = null; - Guid guid = Guid.Empty; - __VSENUMPROJFLAGS flags = __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION; - ErrorHandler.ThrowOnFailure(this.Solution.GetProjectEnum((uint)flags, ref guid, out enumHierarchies)); - - if(enumHierarchies != null) - { - // Loop projects found - IVsHierarchy[] hierarchy = new IVsHierarchy[1]; - uint fetched = 0; - while(enumHierarchies.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1) - { - // If this is a ProjectContainerNode then add to list - IBuildDependencyOnProjectContainer projectNode = hierarchy[0] as IBuildDependencyOnProjectContainer; - if(projectNode != null) - { - projectList.Add(projectNode); - } - } - } - - return projectList; - } - - /// - /// Add build dependency to ProjectContainerNode if IVsBuildDependency is supported by the nested project - /// - /// Project Container where we should add the build dependency - /// Nested project to set a build dependency against - private static void AddBuildDependenyToNestedProject(IBuildDependencyUpdate projectContainer, IVsHierarchy nestedProject) - { - // Validate input - Debug.Assert(projectContainer != null, "Project Container must not be null"); - Debug.Assert(nestedProject != null, "Nested Project must not be null"); - if(projectContainer == null || nestedProject == null) - { - // Invalid argument - return; - } - - // Create new NestedProjectBuildDependency - NestedProjectBuildDependency dependency = new NestedProjectBuildDependency(nestedProject); - projectContainer.AddBuildDependency(dependency); - } - - #endregion - - } -} diff --git a/SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectEvents.cs b/SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectEvents.cs deleted file mode 100644 index cb04e0a7..00000000 --- a/SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectEvents.cs +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// This class triggers the project events for "our" hierrachies. - /// - internal class SolutionListenerForProjectEvents : SolutionListener, IProjectEvents - { - #region events - /// - /// Event raised just after the project file opened. - /// - public event EventHandler AfterProjectFileOpened; - - /// - /// Event raised before the project file closed. - /// - public event EventHandler BeforeProjectFileClosed; - #endregion - - #region ctor - internal SolutionListenerForProjectEvents(IServiceProvider serviceProvider) - : base(serviceProvider) - { - } - #endregion - - #region overridden methods - public override int OnAfterOpenProject(IVsHierarchy hierarchy, int added) - { - IProjectEventsListener projectEventListener = hierarchy as IProjectEventsListener; - if(projectEventListener != null && projectEventListener.IsProjectEventsListener) - { - this.RaiseAfterProjectFileOpened((added != 0) ? true : false); - } - - return VSConstants.S_OK; - } - - public override int OnBeforeCloseProject(IVsHierarchy hierarchy, int removed) - { - IProjectEventsListener projectEvents = hierarchy as IProjectEventsListener; - if(projectEvents != null && projectEvents.IsProjectEventsListener) - { - this.RaiseBeforeProjectFileClosed((removed != 0) ? true : false); - } - - return VSConstants.S_OK; - } - #endregion - - #region helpers - /// - /// Raises after project file opened event. - /// - /// True if the project is added to the solution after the solution is opened. false if the project is added to the solution while the solution is being opened. - private void RaiseAfterProjectFileOpened(bool added) - { - // Save event in temporary variable to avoid race condition. - EventHandler tempEvent = this.AfterProjectFileOpened; - if(tempEvent != null) - { - tempEvent(this, new AfterProjectFileOpenedEventArgs(added)); - } - } - - - - - /// - /// Raises the before project file closed event. - /// - /// true if the project was removed from the solution before the solution was closed. false if the project was removed from the solution while the solution was being closed. - private void RaiseBeforeProjectFileClosed(bool removed) - { - // Save event in temporary variable to avoid race condition. - EventHandler tempEvent = this.BeforeProjectFileClosed; - if(tempEvent != null) - { - tempEvent(this, new BeforeProjectFileClosedEventArgs(removed)); - } - } - } - #endregion -} diff --git a/SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectOpen.cs b/SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectOpen.cs deleted file mode 100644 index 7ff63863..00000000 --- a/SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectOpen.cs +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - - [CLSCompliant(false)] - public class SolutionListenerForProjectOpen : SolutionListener - { - public SolutionListenerForProjectOpen(IServiceProvider serviceProvider) - : base(serviceProvider) - { - } - - public override int OnAfterOpenProject(IVsHierarchy hierarchy, int added) - { - // If this is a new project and our project. We use here that it is only our project that will implemnet the "internal" IBuildDependencyOnProjectContainer. - if(added != 0 && hierarchy is IBuildDependencyUpdate) - { - IVsUIHierarchy uiHierarchy = hierarchy as IVsUIHierarchy; - Debug.Assert(uiHierarchy != null, "The ProjectNode should implement IVsUIHierarchy"); - // Expand and select project node - IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ServiceProvider, HierarchyNode.SolutionExplorer); - if(uiWindow != null) - { - __VSHIERARCHYITEMSTATE state; - uint stateAsInt; - if(uiWindow.GetItemState(uiHierarchy, VSConstants.VSITEMID_ROOT, (uint)__VSHIERARCHYITEMSTATE.HIS_Expanded, out stateAsInt) == VSConstants.S_OK) - { - state = (__VSHIERARCHYITEMSTATE)stateAsInt; - if(state != __VSHIERARCHYITEMSTATE.HIS_Expanded) - { - int hr; - hr = uiWindow.ExpandItem(uiHierarchy, VSConstants.VSITEMID_ROOT, EXPANDFLAGS.EXPF_ExpandParentsToShowItem); - if(ErrorHandler.Failed(hr)) - Trace.WriteLine("Failed to expand project node"); - hr = uiWindow.ExpandItem(uiHierarchy, VSConstants.VSITEMID_ROOT, EXPANDFLAGS.EXPF_SelectItem); - if(ErrorHandler.Failed(hr)) - Trace.WriteLine("Failed to select project node"); - - return hr; - } - } - } - } - return VSConstants.S_OK; - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectReferenceUpdate.cs b/SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectReferenceUpdate.cs deleted file mode 100644 index ab746d67..00000000 --- a/SHFB/Source/MPFProj_VS2010/SolutionListenerForProjectReferenceUpdate.cs +++ /dev/null @@ -1,283 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//=============================================================================================================== -// File : SolutionListenerForProjectReferenceUpdate.cs -// Updated : 05/10/2013 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// Date Who Comments -// ============================================================================================================== -// 05/10/2013 EFW Added code to ignore closed files not hosted within a project in the solution -//=============================================================================================================== - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; - -namespace Microsoft.VisualStudio.Project -{ - [CLSCompliant(false)] - public class SolutionListenerForProjectReferenceUpdate : SolutionListener - { - #region ctor - public SolutionListenerForProjectReferenceUpdate(IServiceProvider serviceProvider) - : base(serviceProvider) - { - } - #endregion - - #region overridden methods - /// - /// Delete this project from the references of projects of this type, if it is found. - /// - /// - /// - /// - public override int OnBeforeCloseProject(IVsHierarchy hierarchy, int removed) - { - if(removed != 0) - { - List projectReferences = this.GetProjectReferencesContainingThisProject(hierarchy); - - foreach(ProjectReferenceNode projectReference in projectReferences) - { - projectReference.Remove(false); - // Set back the remove state on the project refererence. The reason why we are doing this is that the OnBeforeUnloadProject immedaitely calls - // OnBeforeCloseProject, thus we would be deleting references when we should not. Unload should not remove references. - projectReference.CanRemoveReference = true; - } - } - - return VSConstants.S_OK; - } - - - /// - /// Needs to update the dangling reference on projects that contain this hierarchy as project reference. - /// - /// - /// - /// - public override int OnAfterLoadProject(IVsHierarchy stubHierarchy, IVsHierarchy realHierarchy) - { - List projectReferences = this.GetProjectReferencesContainingThisProject(realHierarchy); - - // Refersh the project reference node. That should trigger the drawing of the normal project reference icon. - foreach(ProjectReferenceNode projectReference in projectReferences) - { - projectReference.CanRemoveReference = true; - - projectReference.OnInvalidateItems(projectReference.Parent); - } - - return VSConstants.S_OK; - } - - - public override int OnAfterRenameProject(IVsHierarchy hierarchy) - { - if(hierarchy == null) - { - return VSConstants.E_INVALIDARG; - } - - try - { - List projectReferences = this.GetProjectReferencesContainingThisProject(hierarchy); - - // Collect data that is needed to initialize the new project reference node. - string projectRef; - ErrorHandler.ThrowOnFailure(this.Solution.GetProjrefOfProject(hierarchy, out projectRef)); - - object nameAsObject; - ErrorHandler.ThrowOnFailure(hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_Name, out nameAsObject)); - string projectName = (string)nameAsObject; - - string projectPath = String.Empty; - - IVsProject3 project = hierarchy as IVsProject3; - - if(project != null) - { - ErrorHandler.ThrowOnFailure(project.GetMkDocument(VSConstants.VSITEMID_ROOT, out projectPath)); - projectPath = Path.GetDirectoryName(projectPath); - } - - // Remove and re add the node. - foreach(ProjectReferenceNode projectReference in projectReferences) - { - ProjectNode projectMgr = projectReference.ProjectMgr; - IReferenceContainer refContainer = projectMgr.GetReferenceContainer(); - projectReference.Remove(false); - - VSCOMPONENTSELECTORDATA selectorData = new VSCOMPONENTSELECTORDATA(); - selectorData.type = VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project; - selectorData.bstrTitle = projectName; - selectorData.bstrFile = projectPath; - selectorData.bstrProjRef = projectRef; - refContainer.AddReferenceFromSelectorData(selectorData); - } - } - catch(COMException e) - { - return e.ErrorCode; - } - - return VSConstants.S_OK; - } - - - public override int OnBeforeUnloadProject(IVsHierarchy realHierarchy, IVsHierarchy stubHierarchy) - { - List projectReferences = this.GetProjectReferencesContainingThisProject(realHierarchy); - - // Refresh the project reference node. That should trigger the drawing of the dangling project reference icon. - foreach(ProjectReferenceNode projectReference in projectReferences) - { - projectReference.IsNodeValid = true; - projectReference.OnInvalidateItems(projectReference.Parent); - projectReference.CanRemoveReference = false; - projectReference.IsNodeValid = false; - projectReference.ReferencedProjectObject = null; - } - - return VSConstants.S_OK; - - } - - #endregion - - #region helper methods - private List GetProjectReferencesContainingThisProject(IVsHierarchy inputHierarchy) - { - List projectReferences = new List(); - if(this.Solution == null || inputHierarchy == null) - { - return projectReferences; - } - - uint flags = (uint)(__VSENUMPROJFLAGS.EPF_ALLPROJECTS | __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION); - Guid enumOnlyThisType = Guid.Empty; - IEnumHierarchies enumHierarchies = null; - - ErrorHandler.ThrowOnFailure(this.Solution.GetProjectEnum(flags, ref enumOnlyThisType, out enumHierarchies)); - Debug.Assert(enumHierarchies != null, "Could not get list of hierarchies in solution"); - - IVsHierarchy[] hierarchies = new IVsHierarchy[1]; - uint fetched; - int returnValue = VSConstants.S_OK; - do - { - returnValue = enumHierarchies.Next(1, hierarchies, out fetched); - Debug.Assert(fetched <= 1, "We asked one project to be fetched VSCore gave more than one. We cannot handle that"); - if(returnValue == VSConstants.S_OK && fetched == 1) - { - IVsHierarchy hierarchy = hierarchies[0]; - Debug.Assert(hierarchy != null, "Could not retrieve a hierarchy"); - IReferenceContainerProvider provider = hierarchy as IReferenceContainerProvider; - if(provider != null) - { - IReferenceContainer referenceContainer = provider.GetReferenceContainer(); - - Debug.Assert(referenceContainer != null, "Could not found the References virtual node"); - ProjectReferenceNode projectReferenceNode = GetProjectReferenceOnNodeForHierarchy(referenceContainer.EnumReferences(), inputHierarchy); - if(projectReferenceNode != null) - { - projectReferences.Add(projectReferenceNode); - } - } - } - } while(returnValue == VSConstants.S_OK && fetched == 1); - - return projectReferences; - } - - private static ProjectReferenceNode GetProjectReferenceOnNodeForHierarchy(IList references, IVsHierarchy inputHierarchy) - { - if(references == null) - return null; - - Guid projectGuid; - - // !EFW - This is an odd one. Open a file not contained within a project in the active solution and - // then close it. When you do, this method is called and it fails here. The file is hosted in the - // Miscellaneous Files hierarchy. In such cases, we'll just ignore it and return null. - if(inputHierarchy.GetGuidProperty(VSConstants.VSITEMID_ROOT, - (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, out projectGuid) != VSConstants.S_OK) - return null; - - string canonicalName; - ErrorHandler.ThrowOnFailure(inputHierarchy.GetCanonicalName(VSConstants.VSITEMID_ROOT, out canonicalName)); - - foreach(ReferenceNode refNode in references) - { - ProjectReferenceNode projRefNode = refNode as ProjectReferenceNode; - - if(projRefNode != null) - { - if(projRefNode.ReferencedProjectGuid == projectGuid) - return projRefNode; - - // Try with canonical names, if the project that is removed is an unloaded project that the - // above criteria will not pass. - if(!String.IsNullOrEmpty(projRefNode.Url) && NativeMethods.IsSamePath(projRefNode.Url, canonicalName)) - return projRefNode; - } - } - - return null; - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/StructuresEnums.cs b/SHFB/Source/MPFProj_VS2010/StructuresEnums.cs deleted file mode 100644 index abf50d2f..00000000 --- a/SHFB/Source/MPFProj_VS2010/StructuresEnums.cs +++ /dev/null @@ -1,572 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project -{ - #region structures - [StructLayoutAttribute(LayoutKind.Sequential)] - internal struct _DROPFILES - { - public Int32 pFiles; - public Int32 X; - public Int32 Y; - public Int32 fNC; - public Int32 fWide; - } - #endregion - - #region enums - - /// - /// The type of build performed. - /// - public enum BuildKind - { - Sync, - Async - } - - /// - /// Defines possible types of output that can produced by a language project - /// - [PropertyPageTypeConverterAttribute(typeof(OutputTypeConverter))] - public enum OutputType - { - /// - /// The output type is a class library. - /// - Library, - - /// - /// The output type is a windows executable. - /// - WinExe, - - /// - /// The output type is an executable. - /// - Exe - } - - /// - /// Debug values used by DebugModeConverter. - /// - [PropertyPageTypeConverterAttribute(typeof(DebugModeConverter))] - public enum DebugMode - { - Project, - Program, - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "URL")] - URL - } - - /// - /// An enumeration that describes the type of action to be taken by the build. - /// - [PropertyPageTypeConverterAttribute(typeof(BuildActionConverter))] - public enum BuildAction - { - None, - Compile, - Content, - EmbeddedResource - } - - /// - /// Defines the currect state of a property page. - /// - [Flags] - public enum PropPageStatus - { - - Dirty = 0x1, - - Validate = 0x2, - - Clean = 0x4 - } - - [Flags] - [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")] - public enum ModuleKindFlags - { - - ConsoleApplication, - - WindowsApplication, - - DynamicallyLinkedLibrary, - - ManifestResourceFile, - - UnmanagedDynamicallyLinkedLibrary - } - - /// - /// Defines the status of the command being queried - /// - [Flags] - [SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames")] - [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")] - public enum QueryStatusResult - { - /// - /// The command is not supported. - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "NOTSUPPORTED")] - NOTSUPPORTED = 0, - - /// - /// The command is supported - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SUPPORTED")] - SUPPORTED = 1, - - /// - /// The command is enabled - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ENABLED")] - ENABLED = 2, - - /// - /// The command is toggled on - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "LATCHED")] - LATCHED = 4, - - /// - /// The command is toggled off (the opposite of LATCHED). - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "NINCHED")] - NINCHED = 8, - - /// - /// The command is invisible. - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "INVISIBLE")] - INVISIBLE = 16 - } - - /// - /// Defines the type of item to be added to the hierarchy. - /// - public enum HierarchyAddType - { - AddNewItem, - AddExistingItem - } - - /// - /// Defines the component from which a command was issued. - /// - public enum CommandOrigin - { - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ui")] - UiHierarchy, - OleCommandTarget - } - - /// - /// Defines the current status of the build process. - /// - public enum MSBuildResult - { - /// - /// The build is currently suspended. - /// - Suspended, - - /// - /// The build has been restarted. - /// - Resumed, - - /// - /// The build failed. - /// - Failed, - - /// - /// The build was successful. - /// - Successful, - } - - /// - /// Defines the type of action to be taken in showing the window frame. - /// - public enum WindowFrameShowAction - { - DoNotShow, - Show, - ShowNoActivate, - Hide, - } - - /// - /// Defines drop types - /// - internal enum DropDataType - { - None, - Shell, - VsStg, - VsRef - } - - /// - /// Used by the hierarchy node to decide which element to redraw. - /// - [Flags] - [SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames")] - public enum UIHierarchyElement - { - None = 0, - - /// - /// This will be translated to VSHPROPID_IconIndex - /// - Icon = 1, - - /// - /// This will be translated to VSHPROPID_StateIconIndex - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scc")] - SccState = 2, - - /// - /// This will be translated to VSHPROPID_Caption - /// - Caption = 4 - } - - /// - /// Defines the global propeties used by the msbuild project. - /// - public enum GlobalProperty - { - /// - /// Property specifying that we are building inside VS. - /// - BuildingInsideVisualStudio, - - /// - /// The VS installation directory. This is the same as the $(DevEnvDir) macro. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Env")] - DevEnvDir, - - /// - /// The name of the solution the project is created. This is the same as the $(SolutionName) macro. - /// - SolutionName, - - /// - /// The file name of the solution. This is the same as $(SolutionFileName) macro. - /// - SolutionFileName, - - /// - /// The full path of the solution. This is the same as the $(SolutionPath) macro. - /// - SolutionPath, - - /// - /// The directory of the solution. This is the same as the $(SolutionDir) macro. - /// - SolutionDir, - - /// - /// The extension of teh directory. This is the same as the $(SolutionExt) macro. - /// - SolutionExt, - - /// - /// The fxcop installation directory. - /// - FxCopDir, - - /// - /// The ResolvedNonMSBuildProjectOutputs msbuild property - /// - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "VSIDE")] - VSIDEResolvedNonMSBuildProjectOutputs, - - /// - /// The Configuartion property. - /// - Configuration, - - /// - /// The platform property. - /// - Platform, - - /// - /// The RunCodeAnalysisOnce property - /// - RunCodeAnalysisOnce, - - /// - /// The VisualStudioStyleErrors property - /// - VisualStudioStyleErrors, - } - #endregion - - public class AfterProjectFileOpenedEventArgs : EventArgs - { - #region fields - private bool added; - #endregion - - #region properties - /// - /// True if the project is added to the solution after the solution is opened. false if the project is added to the solution while the solution is being opened. - /// - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal bool Added - { - get { return this.added; } - } - #endregion - - #region ctor - internal AfterProjectFileOpenedEventArgs(bool added) - { - this.added = added; - } - #endregion - } - - public class BeforeProjectFileClosedEventArgs : EventArgs - { - #region fields - private bool removed; - #endregion - - #region properties - /// - /// true if the project was removed from the solution before the solution was closed. false if the project was removed from the solution while the solution was being closed. - /// - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal bool Removed - { - get { return this.removed; } - } - #endregion - - #region ctor - internal BeforeProjectFileClosedEventArgs(bool removed) - { - this.removed = removed; - } - #endregion - } - - /// - /// This class is used for the events raised by a HierarchyNode object. - /// - internal class HierarchyNodeEventArgs : EventArgs - { - private HierarchyNode child; - - internal HierarchyNodeEventArgs(HierarchyNode child) - { - this.child = child; - } - - public HierarchyNode Child - { - get { return this.child; } - } - } - - /// - /// Event args class for triggering file change event arguments. - /// - internal class FileChangedOnDiskEventArgs : EventArgs - { - #region Private fields - /// - /// File name that was changed on disk. - /// - private string fileName; - - /// - /// The item ide of the file that has changed. - /// - private uint itemID; - - /// - /// The reason the file has changed on disk. - /// - private _VSFILECHANGEFLAGS fileChangeFlag; - #endregion - - /// - /// Constructs a new event args. - /// - /// File name that was changed on disk. - /// The item id of the file that was changed on disk. - /// File change flags - internal FileChangedOnDiskEventArgs(string fileName, uint id, _VSFILECHANGEFLAGS flag) - { - this.fileName = fileName; - this.itemID = id; - this.fileChangeFlag = flag; - } - - /// - /// Gets the file name that was changed on disk. - /// - /// The file that was changed on disk. - internal string FileName - { - get - { - return this.fileName; - } - } - - /// - /// Gets item id of the file that has changed - /// - /// The file that was changed on disk. - internal uint ItemID - { - get - { - return this.itemID; - } - } - - /// - /// The reason while the file has chnaged on disk. - /// - /// The reason while the file has chnaged on disk. - internal _VSFILECHANGEFLAGS FileChangeFlag - { - get - { - return this.fileChangeFlag; - } - } - } - - /// - /// Defines the event args for the active configuration chnage event. - /// - public class ActiveConfigurationChangedEventArgs : EventArgs - { - #region Private fields - /// - /// The hierarchy whose configuration has changed - /// - private IVsHierarchy hierarchy; - #endregion - - /// - /// Constructs a new event args. - /// - /// The hierarchy that has changed its configuration. - internal ActiveConfigurationChangedEventArgs(IVsHierarchy hierarchy) - { - this.hierarchy = hierarchy; - } - - /// - /// The hierarchy whose configuration has changed - /// - internal IVsHierarchy Hierarchy - { - get - { - return this.hierarchy; - } - } - } - - /// - /// Argument of the event raised when a project property is changed. - /// - [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] - public class ProjectPropertyChangedArgs : EventArgs - { - private string propertyName; - private string oldValue; - private string newValue; - - internal ProjectPropertyChangedArgs(string propertyName, string oldValue, string newValue) - { - this.propertyName = propertyName; - this.oldValue = oldValue; - this.newValue = newValue; - } - - public string NewValue - { - get { return newValue; } - } - - public string OldValue - { - get { return oldValue; } - } - - public string PropertyName - { - get { return propertyName; } - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/SuspendFileChanges.cs b/SHFB/Source/MPFProj_VS2010/SuspendFileChanges.cs deleted file mode 100644 index 222bf3e4..00000000 --- a/SHFB/Source/MPFProj_VS2010/SuspendFileChanges.cs +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// helper to make the editor ignore external changes - /// - internal class SuspendFileChanges - { - private string documentFileName; - - private bool isSuspending; - - private IServiceProvider site; - - private IVsDocDataFileChangeControl fileChangeControl; - - public SuspendFileChanges(IServiceProvider site, string document) - { - this.site = site; - this.documentFileName = document; - } - - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] - public void Suspend() - { - if(this.isSuspending) - return; - - IntPtr docData = IntPtr.Zero; - try - { - IVsRunningDocumentTable rdt = this.site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; - - IVsHierarchy hierarchy; - uint itemId; - uint docCookie; - IVsFileChangeEx fileChange; - - - if(rdt == null) return; - - ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, this.documentFileName, out hierarchy, out itemId, out docData, out docCookie)); - - if((docCookie == (uint)ShellConstants.VSDOCCOOKIE_NIL) || docData == IntPtr.Zero) - return; - - fileChange = this.site.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx; - - if(fileChange != null) - { - this.isSuspending = true; - ErrorHandler.ThrowOnFailure(fileChange.IgnoreFile(0, this.documentFileName, 1)); - if(docData != IntPtr.Zero) - { - IVsPersistDocData persistDocData = null; - - // if interface is not supported, return null - object unknown = Marshal.GetObjectForIUnknown(docData); - if(unknown is IVsPersistDocData) - { - persistDocData = (IVsPersistDocData)unknown; - if(persistDocData is IVsDocDataFileChangeControl) - { - this.fileChangeControl = (IVsDocDataFileChangeControl)persistDocData; - if(this.fileChangeControl != null) - { - ErrorHandler.ThrowOnFailure(this.fileChangeControl.IgnoreFileChanges(1)); - } - } - } - } - } - } - catch(InvalidCastException e) - { - Trace.WriteLine("Exception" + e.Message); - } - finally - { - if(docData != IntPtr.Zero) - { - Marshal.Release(docData); - } - } - return; - } - - public void Resume() - { - if(!this.isSuspending) - return; - IVsFileChangeEx fileChange; - fileChange = this.site.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx; - if(fileChange != null) - { - this.isSuspending = false; - ErrorHandler.ThrowOnFailure(fileChange.IgnoreFile(0, this.documentFileName, 0)); - if(this.fileChangeControl != null) - { - ErrorHandler.ThrowOnFailure(this.fileChangeControl.IgnoreFileChanges(0)); - } - } - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/TokenProcessor.cs b/SHFB/Source/MPFProj_VS2010/TokenProcessor.cs deleted file mode 100644 index d76f1c07..00000000 --- a/SHFB/Source/MPFProj_VS2010/TokenProcessor.cs +++ /dev/null @@ -1,574 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Collections; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Text; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Replacement type - /// - public enum TokenReplaceType - { - ReplaceString, - ReplaceNumber, - ReplaceCode - } - - /// - /// Contain a number of functions that handle token replacement - /// - [CLSCompliant(false)] - public class TokenProcessor - { - #region fields - // Internal fields - private ArrayList tokenlist; - - - #endregion - - #region Initialization - /// - /// Constructor - /// - public TokenProcessor() - { - tokenlist = new ArrayList(); - } - - /// - /// Reset list of TokenReplacer entries - /// - public virtual void Reset() - { - tokenlist.Clear(); - } - - - /// - /// Add a replacement type entry - /// - /// token to replace - /// replacement string - public virtual void AddReplace(string token, string replacement) - { - tokenlist.Add(new ReplacePairToken(token, replacement)); - } - - /// - /// Add replace between entry - /// - /// The token ID - /// Start token - /// End token - /// The replacement value - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "tokenid")] - public virtual void AddReplaceBetween(string tokenid, string tokenStart, string tokenEnd, string replacement) - { - tokenlist.Add(new ReplaceBetweenPairToken(tokenid, tokenStart, tokenEnd, replacement)); - } - - /// - /// Add a deletion entry - /// - /// Token to delete - public virtual void AddDelete(string tokenToDelete) - { - tokenlist.Add(new DeleteToken(tokenToDelete)); - } - #endregion - - #region TokenProcessing - /// - /// For all known token, replace token with correct value - /// - /// File of the source file - /// File of the destination file - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily"), SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Untoken")] - public virtual void UntokenFile(string source, string destination) - { - if(string.IsNullOrEmpty(source)) - throw new ArgumentNullException("source"); - - if(string.IsNullOrEmpty(destination)) - throw new ArgumentNullException("destination"); - - // Make sure that the destination folder exists. - string destinationFolder = Path.GetDirectoryName(destination); - if(!Directory.Exists(destinationFolder)) - { - Directory.CreateDirectory(destinationFolder); - } - - //Open the file. Check to see if the File is binary or text. - // NOTE: This is not correct because GetBinaryType will return true - // only if the file is executable, not if it is a dll, a library or - // any other type of binary file. - - uint binaryType; - if(!NativeMethods.GetBinaryType(source, out binaryType)) - { - Encoding encoding = Encoding.Default; - string buffer = null; - // Create the reader to get the text. Note that we will default to ASCII as - // encoding if the file does not contains a different signature. - using(StreamReader reader = new StreamReader(source, Encoding.ASCII, true)) - { - // Get the content of the file. - buffer = reader.ReadToEnd(); - // Detect the encoding of the source file. Note that we - // can get the encoding only after a read operation is - // performed on the file. - encoding = reader.CurrentEncoding; - } - foreach(object pair in tokenlist) - { - if(pair is DeleteToken) - DeleteTokens(ref buffer, (DeleteToken)pair); - if(pair is ReplaceBetweenPairToken) - ReplaceBetweenTokens(ref buffer, (ReplaceBetweenPairToken)pair); - if(pair is ReplacePairToken) - ReplaceTokens(ref buffer, (ReplacePairToken)pair); - } - File.WriteAllText(destination, buffer, encoding); - } - else - File.Copy(source, destination); - - } - - /// - /// Replaces the tokens in a buffer with the replacement string - /// - /// Buffer to update - /// replacement data - public virtual void ReplaceTokens(ref string buffer, ReplacePairToken tokenToReplace) - { - if (tokenToReplace == null) - { - throw new ArgumentNullException("tokenToReplace"); - } - - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - - buffer = buffer.Replace(tokenToReplace.Token, tokenToReplace.Replacement); - } - - /// - /// Deletes the token from the buffer - /// - /// Buffer to update - /// token to delete - public virtual void DeleteTokens(ref string buffer, DeleteToken tokenToDelete) - { - if (tokenToDelete == null) - { - throw new ArgumentNullException("tokenToDelete"); - } - - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - - buffer = buffer.Replace(tokenToDelete.StringToDelete, string.Empty); - } - - /// - /// Replaces the token from the buffer between the provided tokens - /// - /// Buffer to update - /// replacement token - public virtual void ReplaceBetweenTokens(ref string buffer, ReplaceBetweenPairToken rpBetweenToken) - { - if (rpBetweenToken == null) - { - throw new ArgumentNullException("rpBetweenToken"); - } - - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } - - string regularExp = rpBetweenToken.TokenStart + "[^" + rpBetweenToken.TokenIdentifier + "]*" + rpBetweenToken.TokenEnd; - buffer = System.Text.RegularExpressions.Regex.Replace(buffer, regularExp, rpBetweenToken.TokenReplacement); - } - - #endregion - - #region Guid generators - /// - /// Generates a string representation of a guid with the following format: - /// 0x01020304, 0x0506, 0x0708, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 - /// - /// Guid to be generated - /// The guid as string - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] - public string GuidToForm1(Guid value) - { - byte[] GuidBytes = value.ToByteArray(); - StringBuilder ResultingStr = new StringBuilder(80); - - // First 4 bytes - int i = 0; - int Number = 0; - for(i = 0; i < 4; ++i) - { - int CurrentByte = GuidBytes[i]; - Number += CurrentByte << (8 * i); - } - UInt32 FourBytes = (UInt32)Number; - ResultingStr.AppendFormat(CultureInfo.InvariantCulture, "0x{0}", FourBytes.ToString("X", CultureInfo.InvariantCulture)); - - // 2 chunks of 2 bytes - for(int j = 0; j < 2; ++j) - { - Number = 0; - for(int k = 0; k < 2; ++k) - { - int CurrentByte = GuidBytes[i++]; - Number += CurrentByte << (8 * k); - } - UInt16 TwoBytes = (UInt16)Number; - ResultingStr.AppendFormat(CultureInfo.InvariantCulture, ", 0x{0}", TwoBytes.ToString("X", CultureInfo.InvariantCulture)); - } - - // 8 chunks of 1 bytes - for(int j = 0; j < 8; ++j) - { - ResultingStr.AppendFormat(CultureInfo.InvariantCulture, ", 0x{0}", GuidBytes[i++].ToString("X", CultureInfo.InvariantCulture)); - } - - return ResultingStr.ToString(); - } - #endregion - - #region Helper Methods - /// - /// This function will accept a subset of the characters that can create an - /// identifier name: there are other unicode char that can be inside the name, but - /// this function will not allow. By now it can work this way, but when and if the - /// VSIP package will handle also languages different from english, this function - /// must be changed. - /// - /// Character to validate - /// true if successful false otherwise - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "c")] - protected static bool IsValidIdentifierChar(char c) - { - if((c >= 'a') && (c <= 'z')) - { - return true; - } - if((c >= 'A') && (c <= 'Z')) - { - return true; - } - if(c == '_') - { - return true; - } - if((c >= '0') && (c <= '9')) - { - return true; - } - - return false; - } - - /// - /// Verifies if the start character is valid - /// - /// Start character - /// true if successful false otherwise - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "c")] - protected static bool IsValidIdentifierStartChar(char c) - { - if(!IsValidIdentifierChar(c)) - { - return false; - } - if((c >= '0') && (c <= '9')) - { - return false; - } - - return true; - } - - /// - /// The goal here is to reduce the risk of name conflict between 2 classes - /// added in different directories. This code does NOT garanty uniqueness. - /// To garanty uniqueness, you should change this function to work with - /// the language service to verify that the namespace+class generated does - /// not conflict. - /// - /// Full path to the new file - /// The project node - /// Namespace to use for the new file - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] - public string GetFileNamespace(string fileFullPath, ProjectNode node) - { - if (node == null) - { - throw new ArgumentNullException("node"); - } - - // Get base namespace from the project - string namespce = node.GetProjectProperty("RootNamespace"); - if(String.IsNullOrEmpty(namespce)) - namespce = Path.GetFileNameWithoutExtension(fileFullPath); ; - - // If the item is added to a subfolder, the name space should reflect this. - // This is done so that class names from 2 files with the same name but different - // directories don't conflict. - string relativePath = Path.GetDirectoryName(fileFullPath); - string projectPath = Path.GetDirectoryName(node.GetMkDocument()); - // Our project system only support adding files that are sibling of the project file or that are in subdirectories. - if(String.Compare(projectPath, 0, relativePath, 0, projectPath.Length, true, CultureInfo.CurrentCulture) == 0) - { - relativePath = relativePath.Substring(projectPath.Length); - } - else - { - Debug.Fail("Adding an item to the project that is NOT under the project folder."); - // We are going to use the full file path for generating the namespace - } - - // Get the list of parts - int index = 0; - string[] pathParts; - pathParts = relativePath.Split(Path.DirectorySeparatorChar); - - // Use a string builder with default size being the expected size - StringBuilder result = new StringBuilder(namespce, namespce.Length + relativePath.Length + 1); - // For each path part - while(index < pathParts.Length) - { - string part = pathParts[index]; - ++index; - - // This could happen if the path had leading/trailing slash, we want to ignore empty pieces - if(String.IsNullOrEmpty(part)) - continue; - - // If we reach here, we will be adding something, so add a namespace separator '.' - result.Append('.'); - - // Make sure it starts with a letter - if(!char.IsLetter(part, 0)) - result.Append('N'); - - // Filter invalid namespace characters - foreach(char c in part) - { - if(char.IsLetterOrDigit(c)) - result.Append(c); - } - } - return result.ToString(); - } - #endregion - - } - - /// - /// Storage classes for replacement tokens - /// - public class ReplacePairToken - { - /// - /// token string - /// - private string token; - - /// - /// Replacement string - /// - private string replacement; - - /// - /// Constructor - /// - /// replaceable token - /// replacement string - public ReplacePairToken(string token, string replacement) - { - this.token = token; - this.replacement = replacement; - } - - /// - /// Token that needs to be replaced - /// - public string Token - { - get { return token; } - } - /// - /// String to replace the token with - /// - public string Replacement - { - get { return replacement; } - } - } - - /// - /// Storage classes for token to be deleted - /// - public class DeleteToken - { - /// - /// String to delete - /// - private string token; - - /// - /// Constructor - /// - /// Deletable token. - public DeleteToken(string token) - { - this.token = token; - } - - /// - /// Token marking the end of the block to delete - /// - public string StringToDelete - { - get { return token; } - } - } - - /// - /// Storage classes for string to be deleted between tokens to be deleted - /// - public class ReplaceBetweenPairToken - { - /// - /// Token start - /// - private string tokenStart; - - /// - /// End token - /// - private string tokenEnd; - - /// - /// Replacement string - /// - private string replacement; - - /// - /// Token identifier string - /// - private string tokenidentifier; - - /// - /// Constructor - /// - /// The token id - /// Start token - /// End Token - /// Replacement string. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "tokenid")] - public ReplaceBetweenPairToken(string tokenid, string blockStart, string blockEnd, string replacement) - { - tokenStart = blockStart; - tokenEnd = blockEnd; - this.replacement = replacement; - tokenidentifier = tokenid; - } - - /// - /// Token marking the begining of the block to delete - /// - public string TokenStart - { - get { return tokenStart; } - } - - /// - /// Token marking the end of the block to delete - /// - public string TokenEnd - { - get { return tokenEnd; } - } - - /// - /// Token marking the end of the block to delete - /// - public string TokenReplacement - { - get { return replacement; } - } - - /// - /// Token Identifier - /// - public string TokenIdentifier - { - get { return tokenidentifier; } - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Tracing.cs b/SHFB/Source/MPFProj_VS2010/Tracing.cs deleted file mode 100644 index 32154fb4..00000000 --- a/SHFB/Source/MPFProj_VS2010/Tracing.cs +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System.Diagnostics; - -namespace Microsoft.VisualStudio.Project -{ - internal class CCITracing - { - private CCITracing() { } - - [ConditionalAttribute("Enable_CCIDiagnostics")] - static void InternalTraceCall(int levels) - { - System.Diagnostics.StackFrame stack; - stack = new System.Diagnostics.StackFrame(levels); - System.Reflection.MethodBase method = stack.GetMethod(); - if(method != null) - { - string name = method.Name + " \tin class " + method.DeclaringType.Name; - System.Diagnostics.Trace.WriteLine("Call Trace: \t" + name); - } - } - - [ConditionalAttribute("CCI_TRACING")] - static public void TraceCall() - { - // skip this one as well - CCITracing.InternalTraceCall(2); - } - - [ConditionalAttribute("CCI_TRACING")] - static public void TraceCall(string strParameters) - { - CCITracing.InternalTraceCall(2); - System.Diagnostics.Trace.WriteLine("\tParameters: \t" + strParameters); - } - - [ConditionalAttribute("CCI_TRACING")] - static public void Trace(System.Exception e) - { - CCITracing.InternalTraceCall(2); - System.Diagnostics.Trace.WriteLine("ExceptionInfo: \t" + e.ToString()); - } - - [ConditionalAttribute("CCI_TRACING")] - static public void Trace(string strOutput) - { - System.Diagnostics.Trace.WriteLine(strOutput); - } - - [ConditionalAttribute("CCI_TRACING")] - static public void TraceData(string strOutput) - { - System.Diagnostics.Trace.WriteLine("Data Trace: \t" + strOutput); - } - - [ConditionalAttribute("Enable_CCIFileOutput")] - [ConditionalAttribute("CCI_TRACING")] - static public void AddTraceLog(string strFileName) - { - TextWriterTraceListener tw = new TextWriterTraceListener("c:\\mytrace.log"); - System.Diagnostics.Trace.Listeners.Add(tw); - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/TrackDocumentsHelper.cs b/SHFB/Source/MPFProj_VS2010/TrackDocumentsHelper.cs deleted file mode 100644 index 75b4a1a7..00000000 --- a/SHFB/Source/MPFProj_VS2010/TrackDocumentsHelper.cs +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Used by a project to query the environment for permission to add, remove, or rename a file or directory in a solution - /// - internal class TrackDocumentsHelper - { - #region fields - private ProjectNode projectMgr; - #endregion - - #region properties - - #endregion - - #region ctors - internal TrackDocumentsHelper(ProjectNode project) - { - this.projectMgr = project; - } - #endregion - - #region helper methods - /// - /// Gets the IVsTrackProjectDocuments2 object by asking the service provider for it. - /// - /// the IVsTrackProjectDocuments2 object - private IVsTrackProjectDocuments2 GetIVsTrackProjectDocuments2() - { - Debug.Assert(this.projectMgr != null && !this.projectMgr.IsClosed && this.projectMgr.Site != null); - - IVsTrackProjectDocuments2 documentTracker = this.projectMgr.Site.GetService(typeof(SVsTrackProjectDocuments)) as IVsTrackProjectDocuments2; - if(documentTracker == null) - { - throw new InvalidOperationException(); - } - - return documentTracker; - } - - /// - /// Asks the environment for permission to add files. - /// - /// The files to add. - /// The VSQUERYADDFILEFLAGS flags associated to the files added - /// true if the file can be added, false if not. - internal bool CanAddItems(string[] files, VSQUERYADDFILEFLAGS[] flags) - { - // If we are silent then we assume that the file can be added, since we do not want to trigger this event. - if((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) != 0) - { - return true; - } - - if(files == null || files.Length == 0) - { - return false; - } - - int len = files.Length; - VSQUERYADDFILERESULTS[] summary = new VSQUERYADDFILERESULTS[1]; - ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnQueryAddFiles(this.projectMgr.InteropSafeIVsProject3, len, files, flags, summary, null)); - if(summary[0] == VSQUERYADDFILERESULTS.VSQUERYADDFILERESULTS_AddNotOK) - { - return false; - } - - return true; - } - - /// - /// Notify the environment about a file just added - /// - internal void OnItemAdded(string file, VSADDFILEFLAGS flag) - { - if((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) == 0) - { - ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterAddFilesEx(this.projectMgr.InteropSafeIVsProject3, 1, new string[1] { file }, new VSADDFILEFLAGS[1] { flag })); - } - } - - /// - /// Asks the environment for permission to remove files. - /// - /// an array of files to remove - /// The VSQUERYREMOVEFILEFLAGS associated to the files to be removed. - /// true if the files can be removed, false if not. - internal bool CanRemoveItems(string[] files, VSQUERYREMOVEFILEFLAGS[] flags) - { - // If we are silent then we assume that the file can be removed, since we do not want to trigger this event. - if((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) != 0) - { - return true; - } - - if(files == null || files.Length == 0) - { - return false; - } - int length = files.Length; - - VSQUERYREMOVEFILERESULTS[] summary = new VSQUERYREMOVEFILERESULTS[1]; - - ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnQueryRemoveFiles(this.projectMgr.InteropSafeIVsProject3, length, files, flags, summary, null)); - if(summary[0] == VSQUERYREMOVEFILERESULTS.VSQUERYREMOVEFILERESULTS_RemoveNotOK) - { - return false; - } - - return true; - } - - /// - /// Notify the environment about a file just removed - /// - internal void OnItemRemoved(string file, VSREMOVEFILEFLAGS flag) - { - if((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) == 0) - { - ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterRemoveFiles(this.projectMgr.InteropSafeIVsProject3, 1, new string[1] { file }, new VSREMOVEFILEFLAGS[1] { flag })); - } - } - - /// - /// Asks the environment for permission to rename files. - /// - /// Path to the file to be renamed. - /// Path to the new file. - /// The VSRENAMEFILEFLAGS associated with the file to be renamed. - /// true if the file can be renamed. Otherwise false. - internal bool CanRenameItem(string oldFileName, string newFileName, VSRENAMEFILEFLAGS flag) - { - // If we are silent then we assume that the file can be renamed, since we do not want to trigger this event. - if((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) != 0) - { - return true; - } - - int iCanContinue = 0; - ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnQueryRenameFile(this.projectMgr.InteropSafeIVsProject3, oldFileName, newFileName, flag, out iCanContinue)); - return (iCanContinue != 0); - } - - /// - /// Get's called to tell the env that a file was renamed - /// - /// - internal void OnItemRenamed(string strOldName, string strNewName, VSRENAMEFILEFLAGS flag) - { - if((this.projectMgr.EventTriggeringFlag & ProjectNode.EventTriggering.DoNotTriggerTrackerEvents) == 0) - { - ErrorHandler.ThrowOnFailure(this.GetIVsTrackProjectDocuments2().OnAfterRenameFile(this.projectMgr.InteropSafeIVsProject3, strOldName, strNewName, flag)); - } - } - #endregion - } -} - diff --git a/SHFB/Source/MPFProj_VS2010/TypeConverters.cs b/SHFB/Source/MPFProj_VS2010/TypeConverters.cs deleted file mode 100644 index 58537632..00000000 --- a/SHFB/Source/MPFProj_VS2010/TypeConverters.cs +++ /dev/null @@ -1,315 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Runtime.Versioning; -using Microsoft.VisualStudio.Shell.Interop; -using System.Runtime.InteropServices; - -namespace Microsoft.VisualStudio.Project -{ - public class OutputTypeConverter : EnumConverter - { - public OutputTypeConverter() - : base(typeof(OutputType)) - { - - } - - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - { - if(sourceType == typeof(string)) return true; - - return base.CanConvertFrom(context, sourceType); - } - - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - string str = value as string; - - if(str != null) - { - if(str == SR.GetString(SR.Exe, culture)) return OutputType.Exe; - if(str == SR.GetString(SR.Library, culture)) return OutputType.Library; - if(str == SR.GetString(SR.WinExe, culture)) return OutputType.WinExe; - } - - return base.ConvertFrom(context, culture, value); - } - - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) - { - if(destinationType == typeof(string)) - { - string result = null; - // In some cases if multiple nodes are selected the windows form engine - // calls us with a null value if the selected node's property values are not equal - if(value != null) - { - result = SR.GetString(((OutputType)value).ToString(), culture); - } - else - { - result = SR.GetString(OutputType.Library.ToString(), culture); - } - - if(result != null) return result; - } - - return base.ConvertTo(context, culture, value, destinationType); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) - { - return true; - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) - { - return new StandardValuesCollection(new OutputType[] { OutputType.Exe, OutputType.Library, OutputType.WinExe }); - } - } - - public class DebugModeConverter : EnumConverter - { - - public DebugModeConverter() - : base(typeof(DebugMode)) - { - - } - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - { - if(sourceType == typeof(string)) return true; - - return base.CanConvertFrom(context, sourceType); - } - - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - string str = value as string; - - if(str != null) - { - if(str == SR.GetString(SR.Program, culture)) return DebugMode.Program; - - if(str == SR.GetString(SR.Project, culture)) return DebugMode.Project; - - if(str == SR.GetString(SR.URL, culture)) return DebugMode.URL; - } - - return base.ConvertFrom(context, culture, value); - } - - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) - { - if(destinationType == typeof(string)) - { - string result = null; - // In some cases if multiple nodes are selected the windows form engine - // calls us with a null value if the selected node's property values are not equal - if(value != null) - { - result = SR.GetString(((DebugMode)value).ToString(), culture); - } - else - { - result = SR.GetString(DebugMode.Program.ToString(), culture); - } - - if(result != null) return result; - } - - return base.ConvertTo(context, culture, value, destinationType); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) - { - return true; - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) - { - return new StandardValuesCollection(new DebugMode[] { DebugMode.Program, DebugMode.Project, DebugMode.URL }); - } - } - - public class BuildActionConverter : EnumConverter - { - - public BuildActionConverter() - : base(typeof(BuildAction)) - { - - } - - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - { - if(sourceType == typeof(string)) return true; - - return base.CanConvertFrom(context, sourceType); - } - - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - string str = value as string; - - if(str != null) - { - if(str == SR.GetString(SR.Compile, culture)) return BuildAction.Compile; - - if(str == SR.GetString(SR.Content, culture)) return BuildAction.Content; - - if(str == SR.GetString(SR.EmbeddedResource, culture)) return BuildAction.EmbeddedResource; - - if(str == SR.GetString(SR.None, culture)) return BuildAction.None; - } - - return base.ConvertFrom(context, culture, value); - } - - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) - { - if(destinationType == typeof(string)) - { - string result = null; - - // In some cases if multiple nodes are selected the windows form engine - // calls us with a null value if the selected node's property values are not equal - // Example of windows form engine passing us null: File set to Compile, Another file set to None, bot nodes are selected, and the build action combo is clicked. - if(value != null) - { - result = SR.GetString(((BuildAction)value).ToString(), culture); - } - else - { - result = SR.GetString(BuildAction.None.ToString(), culture); - } - - if(result != null) return result; - } - - return base.ConvertTo(context, culture, value, destinationType); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) - { - return true; - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) - { - return new StandardValuesCollection(new BuildAction[] { BuildAction.Compile, BuildAction.Content, BuildAction.EmbeddedResource, BuildAction.None }); - } - } - - public class FrameworkNameConverter : TypeConverter - { - public FrameworkNameConverter() - { - } - - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) - { - if (sourceType == typeof(string)) return true; - - return base.CanConvertFrom(context, sourceType); - } - - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - string str = value as string; - - if (str != null) - { - return new FrameworkName(str); - } - - return base.ConvertFrom(context, culture, value); - } - - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) - { - if (destinationType == typeof(string)) - { - var name = value as FrameworkName; - if (name != null) - { - return name.FullName; - } - } - - return base.ConvertTo(context, culture, value, destinationType); - } - - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) - { - return true; - } - - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) - { - IServiceProvider sp = ProjectNode.ServiceProvider; - var multiTargetService = sp.GetService(typeof(SVsFrameworkMultiTargeting)) as IVsFrameworkMultiTargeting; - if (multiTargetService == null) - { - Trace.TraceError("Unable to acquire the SVsFrameworkMultiTargeting service."); - return new StandardValuesCollection(new string[0]); - } - Array frameworks; - Marshal.ThrowExceptionForHR(multiTargetService.GetSupportedFrameworks(out frameworks)); - return new StandardValuesCollection( - frameworks.Cast().Select(fx => new FrameworkName(fx)).ToArray() - ); - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/UIThread.cs b/SHFB/Source/MPFProj_VS2010/UIThread.cs deleted file mode 100644 index 4d5813ac..00000000 --- a/SHFB/Source/MPFProj_VS2010/UIThread.cs +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -namespace Microsoft.VisualStudio.Project -{ - using Microsoft.VisualStudio.Shell; - using System; - using System.Diagnostics; - using System.Globalization; - using System.Threading; - using System.Windows.Forms; - - internal sealed class UIThread : IDisposable - { - private WindowsFormsSynchronizationContext synchronizationContext; -#if DEBUG - /// - /// Stack trace when synchronizationContext was captured - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] - private StackTrace captureStackTrace; -#endif - - private Thread uithread; - - /// - /// RunSync puts orignal exception stacktrace to Exception.Data by this key if action throws on UI thread - /// - /// WrappedStacktraceKey is a string to keep exception serializable. - private const string WrappedStacktraceKey = "$$Microsoft.VisualStudio.Package.UIThread.WrappedStacktraceKey$$"; - - /// - /// The singleton instance. - /// - private static volatile UIThread instance = new UIThread(); - - internal UIThread() - { - this.Initialize(); - } - - /// - /// Gets the singleton instance - /// - public static UIThread Instance - { - get - { - return instance; - } - } - - /// - /// Checks whether this is the UI thread. - /// - public bool IsUIThread - { - get { return this.uithread == System.Threading.Thread.CurrentThread; } - } - - /// - /// Gets a value indicating whether unit tests are running. - /// - internal static bool IsUnitTest { get; set; } - - #region IDisposable Members - /// - /// Dispose implementation. - /// - public void Dispose() - { - if (this.synchronizationContext != null) - { - this.synchronizationContext.Dispose(); - } - } - - #endregion - - /// - /// Initializes unit testing mode for this object - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal void InitUnitTestingMode() - { - Debug.Assert(this.synchronizationContext == null, "Context has already been captured; too late to InitUnitTestingMode"); - IsUnitTest = true; - } - - [Conditional("DEBUG")] - internal void MustBeCalledFromUIThread() - { - Debug.Assert(this.uithread == System.Threading.Thread.CurrentThread || IsUnitTest, "This must be called from the GUI thread"); - } - - /// - /// Runs an action asynchronously on an associated forms synchronization context. - /// - /// The action to run - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - internal void Run(Action a) - { - if (IsUnitTest) - { - a(); - return; - } - Debug.Assert(this.synchronizationContext != null, "The SynchronizationContext must be captured before calling this method"); -#if DEBUG - StackTrace stackTrace = new StackTrace(true); -#endif - this.synchronizationContext.Post(delegate(object ignore) - { - try - { - this.MustBeCalledFromUIThread(); - a(); - } -#if DEBUG - catch (Exception e) - { - // swallow, random exceptions should not kill process - Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "UIThread.Run caught and swallowed exception: {0}\n\noriginally invoked from stack:\n{1}", e.ToString(), stackTrace.ToString())); - } -#else - catch (Exception) - { - // swallow, random exceptions should not kill process - } -#endif - }, null); - - } - - /// - /// Runs an action synchronously on an associated forms synchronization context - /// - /// The action to run. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - internal void RunSync(Action a) - { - if (IsUnitTest) - { - a(); - return; - } - Exception exn = null; ; - Debug.Assert(this.synchronizationContext != null, "The SynchronizationContext must be captured before calling this method"); - - // Send on UI thread will execute immediately. - this.synchronizationContext.Send(ignore => - { - try - { - this.MustBeCalledFromUIThread(); - a(); - } - catch (Exception e) - { - exn = e; - } - }, null - ); - if (exn != null) - { - // throw exception on calling thread, preserve stacktrace - if (!exn.Data.Contains(WrappedStacktraceKey)) exn.Data[WrappedStacktraceKey] = exn.StackTrace; - throw exn; - } - } - - /// - /// Performs a callback on the UI thread, blocking until the action completes. Uses the VS mechanism - /// of marshalling back to the main STA thread via COM RPC. - /// - internal static T DoOnUIThread(Func callback) - { - return ThreadHelper.Generic.Invoke(callback); - } - - /// - /// Performs a callback on the UI thread, blocking until the action completes. Uses the VS mechanism - /// of marshalling back to the main STA thread via COM RPC. - /// - internal static void DoOnUIThread(Action callback) - { - ThreadHelper.Generic.Invoke(callback); - } - - /// - /// Initializes this object. - /// - private void Initialize() - { - if (IsUnitTest) return; - this.uithread = System.Threading.Thread.CurrentThread; - - if (this.synchronizationContext == null) - { -#if DEBUG - // This is a handy place to do this, since the product and all interesting unit tests - // must go through this code path. - AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(delegate(object sender, UnhandledExceptionEventArgs args) - { - if (args.IsTerminating) - { - string s = String.Format(CultureInfo.InvariantCulture, "An unhandled exception is about to terminate the process. Exception info:\n{0}", args.ExceptionObject.ToString()); - Debug.Assert(false, s); - } - }); - - this.captureStackTrace = new StackTrace(true); -#endif - this.synchronizationContext = new WindowsFormsSynchronizationContext(); - } - else - { - // Make sure we are always capturing the same thread. - Debug.Assert(this.uithread == Thread.CurrentThread); - } - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/UpdateSolutionEventsListener.cs b/SHFB/Source/MPFProj_VS2010/UpdateSolutionEventsListener.cs deleted file mode 100644 index 2ef6427b..00000000 --- a/SHFB/Source/MPFProj_VS2010/UpdateSolutionEventsListener.cs +++ /dev/null @@ -1,319 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; -using IServiceProvider = System.IServiceProvider; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Defines an abstract class implementing IVsUpdateSolutionEvents interfaces. - /// - [CLSCompliant(false)] - public abstract class UpdateSolutionEventsListener : IVsUpdateSolutionEvents3, IVsUpdateSolutionEvents2, IDisposable - { - #region fields - /// - /// The cookie associated to the the events based IVsUpdateSolutionEvents2. - /// - private uint solutionEvents2Cookie; - - /// - /// The cookie associated to the theIVsUpdateSolutionEvents3 events. - /// - private uint solutionEvents3Cookie; - - /// - /// The IVsSolutionBuildManager2 object controlling the update solution events. - /// - private IVsSolutionBuildManager2 solutionBuildManager; - - - /// - /// The associated service provider. - /// - private IServiceProvider serviceProvider; - - /// - /// Flag determining if the object has been disposed. - /// - private bool isDisposed; - - /// - /// Defines an object that will be a mutex for this object for synchronizing thread calls. - /// - private static volatile object Mutex = new object(); - #endregion - - #region ctors - /// - /// Overloaded constructor. - /// - /// A service provider. - protected UpdateSolutionEventsListener(IServiceProvider serviceProvider) - { - if(serviceProvider == null) - { - throw new ArgumentNullException("serviceProvider"); - } - - this.serviceProvider = serviceProvider; - - this.solutionBuildManager = this.serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2; - - if(this.solutionBuildManager == null) - { - throw new InvalidOperationException(); - } - - ErrorHandler.ThrowOnFailure(this.solutionBuildManager.AdviseUpdateSolutionEvents(this, out this.solutionEvents2Cookie)); - - Debug.Assert(this.solutionBuildManager is IVsSolutionBuildManager3, "The solution build manager object implementing IVsSolutionBuildManager2 does not implement IVsSolutionBuildManager3"); - ErrorHandler.ThrowOnFailure(this.SolutionBuildManager3.AdviseUpdateSolutionEvents3(this, out this.solutionEvents3Cookie)); - } - #endregion - - #region properties - - /// - /// The associated service provider. - /// - protected IServiceProvider ServiceProvider - { - get - { - return this.serviceProvider; - } - } - - /// - /// The solution build manager object controlling the solution events. - /// - protected IVsSolutionBuildManager2 SolutionBuildManager2 - { - get - { - return this.solutionBuildManager; - } - } - - /// - /// The solution build manager object controlling the solution events. - /// - protected IVsSolutionBuildManager3 SolutionBuildManager3 - { - get - { - return (IVsSolutionBuildManager3)this.solutionBuildManager; - } - - } - #endregion - - #region IVsUpdateSolutionEvents3 Members - - /// - /// Fired after the active solution config is changed (pOldActiveSlnCfg can be NULL). - /// - /// Old configuration. - /// New configuration. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int OnAfterActiveSolutionCfgChange(IVsCfg oldActiveSlnCfg, IVsCfg newActiveSlnCfg) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Fired before the active solution config is changed (pOldActiveSlnCfg can be NULL - /// - /// Old configuration. - /// New configuration. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int OnBeforeActiveSolutionCfgChange(IVsCfg oldActiveSlnCfg, IVsCfg newActiveSlnCfg) - { - return VSConstants.E_NOTIMPL; - } - - #endregion - - #region IVsUpdateSolutionEvents2 Members - - /// - /// Called when the active project configuration for a project in the solution has changed. - /// - /// The project whose configuration has changed. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int OnActiveProjectCfgChange(IVsHierarchy hierarchy) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Called right before a project configuration begins to build. - /// - /// The project that is to be build. - /// A configuration project object. - /// A configuration solution object. - /// The action taken. - /// A flag indicating cancel. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - /// The values for the action are defined in the enum _SLNUPDACTION env\msenv\core\slnupd2.h - public int UpdateProjectCfg_Begin(IVsHierarchy hierarchy, IVsCfg configProject, IVsCfg configSolution, uint action, ref int cancel) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Called right after a project configuration is finished building. - /// - /// The project that has finished building. - /// A configuration project object. - /// A configuration solution object. - /// The action taken. - /// Flag indicating success. - /// Flag indicating cancel. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - /// The values for the action are defined in the enum _SLNUPDACTION env\msenv\core\slnupd2.h - public virtual int UpdateProjectCfg_Done(IVsHierarchy hierarchy, IVsCfg configProject, IVsCfg configSolution, uint action, int success, int cancel) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Called before any build actions have begun. This is the last chance to cancel the build before any building begins. - /// - /// Flag indicating cancel update. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int UpdateSolution_Begin(ref int cancelUpdate) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Called when a build is being cancelled. - /// - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int UpdateSolution_Cancel() - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Called when a build is completed. - /// - /// true if no update actions failed. - /// true if any update action succeeded. - /// true if update actions were canceled. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int UpdateSolution_Done(int succeeded, int modified, int cancelCommand) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Called before the first project configuration is about to be built. - /// - /// A flag indicating cancel update. - /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. - public virtual int UpdateSolution_StartUpdate(ref int cancelUpdate) - { - return VSConstants.E_NOTIMPL; - } - - #endregion - - - #region IDisposable Members - - /// - /// The IDispose interface Dispose method for disposing the object determinastically. - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - #region methods - /// - /// The method that does the cleanup. - /// - /// true if called from IDispose.Dispose; false if called from Finalizer. - protected virtual void Dispose(bool disposing) - { - // Everybody can go here. - if(!this.isDisposed) - { - // Synchronize calls to the Dispose simultaniously. - lock(Mutex) - { - if(this.solutionEvents2Cookie != (uint)ShellConstants.VSCOOKIE_NIL) - { - ErrorHandler.ThrowOnFailure(this.solutionBuildManager.UnadviseUpdateSolutionEvents(this.solutionEvents2Cookie)); - this.solutionEvents2Cookie = (uint)ShellConstants.VSCOOKIE_NIL; - } - - if(this.solutionEvents3Cookie != (uint)ShellConstants.VSCOOKIE_NIL) - { - ErrorHandler.ThrowOnFailure(this.SolutionBuildManager3.UnadviseUpdateSolutionEvents3(this.solutionEvents3Cookie)); - this.solutionEvents3Cookie = (uint)ShellConstants.VSCOOKIE_NIL; - } - - this.isDisposed = true; - } - } - } - #endregion - } -} diff --git a/SHFB/Source/MPFProj_VS2010/Utilities.cs b/SHFB/Source/MPFProj_VS2010/Utilities.cs deleted file mode 100644 index d9713a5c..00000000 --- a/SHFB/Source/MPFProj_VS2010/Utilities.cs +++ /dev/null @@ -1,1092 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//=============================================================================================================== -// File : Utilities.cs -// Updated : 02/15/2013 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// This file has been modified to fix a bug in RecursivelyCopyDirectory() that allowed a parent folder to be -// copied to one of its child sub-folders. Search for "!EFW" to find the changes. -// -// Date Who Comments -// ============================================================================================================== -// 01/01/2012 EFW Fixed bug in RecursivelyCopyDirectory() -// 02/14/2012 EFW Removed RegexOptions.Compiled as it doesn't make sense to use it here and made the two -// affected expressions static. -//=============================================================================================================== - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security.Permissions; -using System.Text; -using System.Text.RegularExpressions; -using System.Windows.Forms; - -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.Win32; - -using IServiceProvider = System.IServiceProvider; -using MSBuild = Microsoft.Build.Evaluation; -using VSRegistry = Microsoft.VisualStudio.Shell.VSRegistry; - -namespace Microsoft.VisualStudio.Project -{ - public static class Utilities - { - private const string defaultMSBuildVersion = "4.0"; - - /// - /// Look in the registry under the current hive for the path - /// of MSBuild - /// - /// - [CLSCompliant(false)] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ms")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "msbuild")] - public static string GetMsBuildPath(IServiceProvider serviceProvider) - { - return GetMsBuildPath(serviceProvider, defaultMSBuildVersion); - } - - /// - /// Search the registry for the tools path for MSBuild. - /// - /// The service provider. - /// Msbuild version. - /// The msbuild tools path - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ms")] - public static string GetMsBuildPath(IServiceProvider serviceProvider, string version) - { - string msBuildPath = null; - using(RegistryKey root = VSRegistry.RegistryRoot(serviceProvider, __VsLocalRegistryType.RegType_Configuration, false)) - { - // Get the value from the registry - using(RegistryKey vsKey = root.OpenSubKey("MSBuild", false)) - { - msBuildPath = (string)vsKey.GetValue("MSBuildBinPath", null); - } - } - if(!string.IsNullOrEmpty(msBuildPath)) - { - return msBuildPath; - } - - // The path to MSBuild was not found in the VisualStudio's registry hive, so try to - // find it in the new MSBuild hive. - string registryPath = string.Format(CultureInfo.InvariantCulture, "Software\\Microsoft\\MSBuild\\ToolsVersions\\{0}", version); - using(Microsoft.Win32.RegistryKey msbuildKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(registryPath, false)) - { - msBuildPath = (string)msbuildKey.GetValue("MSBuildToolsPath", null); - } - if(string.IsNullOrEmpty(msBuildPath)) - { - string error = SR.GetString(SR.ErrorMsBuildRegistration, CultureInfo.CurrentUICulture); - throw new FileLoadException(error); - } - return msBuildPath; - } - - /// - /// Is Visual Studio in design mode. - /// - /// The service provider. - /// true if visual studio is in design mode - public static bool IsVisualStudioInDesignMode(IServiceProvider site) - { - if (site == null) - { - throw new ArgumentNullException("site"); - } - - IVsMonitorSelection selectionMonitor = site.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection; - uint cookie = 0; - int active = 0; - Guid designContext = VSConstants.UICONTEXT_DesignMode; - ErrorHandler.ThrowOnFailure(selectionMonitor.GetCmdUIContextCookie(ref designContext, out cookie)); - ErrorHandler.ThrowOnFailure(selectionMonitor.IsCmdUIContextActive(cookie, out active)); - return active != 0; - } - - // - /// - /// Is an extensibility object executing an automation function. - /// - /// The service provider. - /// true if the extensiblity object is executing an automation function. - public static bool IsInAutomationFunction(IServiceProvider serviceProvider) - { - if(serviceProvider == null) - { - throw new ArgumentNullException("serviceProvider"); - } - - IVsExtensibility3 extensibility = serviceProvider.GetService(typeof(EnvDTE.IVsExtensibility)) as IVsExtensibility3; - - if(extensibility == null) - { - throw new InvalidOperationException(); - } - int inAutomation = 0; - ErrorHandler.ThrowOnFailure(extensibility.IsInAutomationFunction(out inAutomation)); - return inAutomation != 0; - } - - /// - /// Creates a semicolon delinited list of strings. This can be used to provide the properties for VSHPROPID_CfgPropertyPagesCLSIDList, VSHPROPID_PropertyPagesCLSIDList, VSHPROPID_PriorityPropertyPagesCLSIDList - /// - /// An array of Guids. - /// A semicolon delimited string, or null - [CLSCompliant(false)] - public static string CreateSemicolonDelimitedListOfStringFromGuids(Guid[] guids) - { - if(guids == null || guids.Length == 0) - { - return null; - } - - // Create a StringBuilder with a pre-allocated buffer big enough for the - // final string. 39 is the length of a GUID in the "B" form plus the final ';' - StringBuilder stringList = new StringBuilder(39 * guids.Length); - for(int i = 0; i < guids.Length; i++) - { - stringList.Append(guids[i].ToString("B")); - stringList.Append(";"); - } - - return stringList.ToString().TrimEnd(';'); - } - - private static char[] curlyBraces = new char[] { '{', '}' }; - /// - /// Take list of guids as a single string and generate an array of Guids from it - /// - /// Semi-colon separated list of Guids - /// Array of Guids - [CLSCompliant(false)] - public static Guid[] GuidsArrayFromSemicolonDelimitedStringOfGuids(string guidList) - { - if(guidList == null) - { - return null; - } - - List guids = new List(); - string[] guidsStrings = guidList.Split(';'); - foreach(string guid in guidsStrings) - { - if(!String.IsNullOrEmpty(guid)) - guids.Add(new Guid(guid.Trim(curlyBraces))); - } - - return guids.ToArray(); - } - - /// - /// Validates a file path by validating all file parts. If the - /// the file name is invalid it throws an exception if the project is in automation. Otherwise it shows a dialog box with the error message. - /// - /// The service provider - /// A full path to a file name - /// In case of failure an InvalidOperationException is thrown. - public static void ValidateFileName(IServiceProvider serviceProvider, string filePath) - { - string errorMessage = String.Empty; - if(String.IsNullOrEmpty(filePath)) - { - errorMessage = SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture); - } - else if(filePath.Length > NativeMethods.MAX_PATH) - { - errorMessage = String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.PathTooLong, CultureInfo.CurrentUICulture), filePath); - } - else if(ContainsInvalidFileNameChars(filePath)) - { - errorMessage = SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture); - } - - if(errorMessage.Length == 0) - { - string fileName = Path.GetFileName(filePath); - if(String.IsNullOrEmpty(fileName) || IsFileNameInvalid(fileName)) - { - errorMessage = SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture); - } - else - { - string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); - - // If there is no filename or it starts with a leading dot issue an error message and quit. - if(String.IsNullOrEmpty(fileNameWithoutExtension) || fileNameWithoutExtension[0] == '.') - { - errorMessage = SR.GetString(SR.FileNameCannotContainALeadingPeriod, CultureInfo.CurrentUICulture); - } - } - } - - if(errorMessage.Length > 0) - { - // If it is not called from an automation method show a dialog box. - if(!Utilities.IsInAutomationFunction(serviceProvider)) - { - string title = null; - OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL; - OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK; - OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; - VsShellUtilities.ShowMessageBox(serviceProvider, title, errorMessage, icon, buttons, defaultButton); - } - else - { - throw new InvalidOperationException(errorMessage); - } - } - - } - - /// - /// Creates a CALPOLESTR from a list of strings - /// It is the responsability of the caller to release this memory. - /// - /// - /// A CALPOLESTR that was created from the the list of strings. - [CLSCompliant(false)] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CALPOLESTR")] - public static CALPOLESTR CreateCALPOLESTR(IList strings) - { - CALPOLESTR calpolStr = new CALPOLESTR(); - - if(strings != null) - { - // Demand unmanaged permissions in order to access unmanaged memory. - new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); - - calpolStr.cElems = (uint)strings.Count; - - int size = Marshal.SizeOf(typeof(IntPtr)); - - calpolStr.pElems = Marshal.AllocCoTaskMem(strings.Count * size); - - IntPtr ptr = calpolStr.pElems; - - foreach(string aString in strings) - { - IntPtr tempPtr = Marshal.StringToCoTaskMemUni(aString); - Marshal.WriteIntPtr(ptr, tempPtr); - ptr = new IntPtr(ptr.ToInt64() + size); - } - } - - return calpolStr; - } - - /// - /// Creates a CADWORD from a list of tagVsSccFilesFlags. Memory is allocated for the elems. - /// It is the responsability of the caller to release this memory. - /// - /// - /// A CADWORD created from the list of tagVsSccFilesFlags. - [CLSCompliant(false)] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CADWORD")] - public static CADWORD CreateCADWORD(IList flags) - { - CADWORD cadWord = new CADWORD(); - - if(flags != null) - { - // Demand unmanaged permissions in order to access unmanaged memory. - new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); - - cadWord.cElems = (uint)flags.Count; - - int size = Marshal.SizeOf(typeof(UInt32)); - - cadWord.pElems = Marshal.AllocCoTaskMem(flags.Count * size); - - IntPtr ptr = cadWord.pElems; - - foreach(tagVsSccFilesFlags flag in flags) - { - Marshal.WriteInt32(ptr, (int)flag); - ptr = new IntPtr(ptr.ToInt64() + size); - } - } - - return cadWord; - } - - /// - /// Splits a bitmap from a Stream into an ImageList - /// - /// A Stream representing a Bitmap - /// An ImageList object representing the images from the given stream - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - public static ImageList GetImageList(Stream imageStream) - { - ImageList ilist = new ImageList(); - - if(imageStream == null) - { - return ilist; - } - ilist.ColorDepth = ColorDepth.Depth24Bit; - ilist.ImageSize = new Size(16, 16); - Bitmap bitmap = new Bitmap(imageStream); - ilist.Images.AddStrip(bitmap); - ilist.TransparentColor = Color.Magenta; - return ilist; - } - - /// - /// Splits a bitmap from a pointer to an ImageList - /// - /// A pointer to a bitmap of images to split - /// An ImageList object representing the images from the given stream - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - public static ImageList GetImageList(object imageListAsPointer) - { - ImageList images = null; - - IntPtr intPtr = new IntPtr((int)imageListAsPointer); - HandleRef hImageList = new HandleRef(null, intPtr); - int count = UnsafeNativeMethods.ImageList_GetImageCount(hImageList); - - if(count > 0) - { - // Create a bitmap big enough to hold all the images - Bitmap b = new Bitmap(16 * count, 16); - Graphics g = Graphics.FromImage(b); - - // Loop through and extract each image from the imagelist into our own bitmap - IntPtr hDC = IntPtr.Zero; - try - { - hDC = g.GetHdc(); - HandleRef handleRefDC = new HandleRef(null, hDC); - for(int i = 0; i < count; i++) - { - UnsafeNativeMethods.ImageList_Draw(hImageList, i, handleRefDC, i * 16, 0, NativeMethods.ILD_NORMAL); - } - } - finally - { - if(g != null && hDC != IntPtr.Zero) - { - g.ReleaseHdc(hDC); - } - } - - // Create a new imagelist based on our stolen images - images = new ImageList(); - images.ColorDepth = ColorDepth.Depth24Bit; - images.ImageSize = new Size(16, 16); - images.Images.AddStrip(b); - } - return images; - } - - /// - /// Gets the active configuration name. - /// - /// The automation object. - /// The name of the active configuartion. - internal static string GetActiveConfigurationName(EnvDTE.Project automationObject) - { - if(automationObject == null) - { - throw new ArgumentNullException("automationObject"); - } - - string currentConfigName = string.Empty; - if(automationObject.ConfigurationManager != null) - { - EnvDTE.Configuration activeConfig = automationObject.ConfigurationManager.ActiveConfiguration; - if(activeConfig != null) - { - currentConfigName = activeConfig.ConfigurationName; - } - } - return currentConfigName; - - } - - - /// - /// Verifies that two objects represent the same instance of a COM object. - /// This essentially compares the IUnkown pointers of the 2 objects. - /// This is needed in scenario where aggregation is involved. - /// - /// Can be an object, interface or IntPtr - /// Can be an object, interface or IntPtr - /// True if the 2 items represent the same thing - [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj")] - public static bool IsSameComObject(object obj1, object obj2) - { - bool isSame = false; - IntPtr unknown1 = IntPtr.Zero; - IntPtr unknown2 = IntPtr.Zero; - try - { - // If we have 2 null, then they are not COM objects and as such "it's not the same COM object" - if(obj1 != null && obj2 != null) - { - unknown1 = QueryInterfaceIUnknown(obj1); - unknown2 = QueryInterfaceIUnknown(obj2); - - isSame = IntPtr.Equals(unknown1, unknown2); - } - } - finally - { - if(unknown1 != IntPtr.Zero) - { - Marshal.Release(unknown1); - } - - if(unknown2 != IntPtr.Zero) - { - Marshal.Release(unknown2); - } - - } - - return isSame; - } - - /// - /// Retrieve the IUnknown for the managed or COM object passed in. - /// - /// Managed or COM object. - /// Pointer to the IUnknown interface of the object. - internal static IntPtr QueryInterfaceIUnknown(object objToQuery) - { - bool releaseIt = false; - IntPtr unknown = IntPtr.Zero; - IntPtr result; - try - { - if(objToQuery is IntPtr) - { - unknown = (IntPtr)objToQuery; - } - else - { - // This is a managed object (or RCW) - unknown = Marshal.GetIUnknownForObject(objToQuery); - releaseIt = true; - } - - // We might already have an IUnknown, but if this is an aggregated - // object, it may not be THE IUnknown until we QI for it. - Guid IID_IUnknown = VSConstants.IID_IUnknown; - ErrorHandler.ThrowOnFailure(Marshal.QueryInterface(unknown, ref IID_IUnknown, out result)); - } - finally - { - if(releaseIt && unknown != IntPtr.Zero) - { - Marshal.Release(unknown); - } - - } - - return result; - } - - /// - /// Returns true if thename that can represent a path, absolut or relative, or a file name contains invalid filename characters. - /// - /// File name - /// true if file name is invalid - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", - Justification="The name is validated.")] - public static bool ContainsInvalidFileNameChars(string name) - { - if(String.IsNullOrEmpty(name)) - { - return true; - } - - try - { - if(Path.IsPathRooted(name) && !name.StartsWith(@"\\", StringComparison.Ordinal)) - { - string root = Path.GetPathRoot(name); - name = name.Substring(root.Length); - } - } - // The Path methods used by ContainsInvalidFileNameChars return argument exception if the filePath contains invalid characters. - catch(ArgumentException) - { - return true; - } - - Microsoft.VisualStudio.Shell.Url uri = new Microsoft.VisualStudio.Shell.Url(name); - - // This might be confusing bur Url.IsFile means that the uri represented by the name is either absolut or relative. - if(uri.IsFile) - { - string[] segments = uri.Segments; - if(segments != null && segments.Length > 0) - { - foreach(string segment in segments) - { - if(IsFilePartInValid(segment)) - { - return true; - } - } - - // Now the last segment should be specially taken care, since that cannot be all dots or spaces. - string lastSegment = segments[segments.Length - 1]; - string filePart = Path.GetFileNameWithoutExtension(lastSegment); - if(IsFileNameAllGivenCharacter('.', filePart) || IsFileNameAllGivenCharacter(' ', filePart)) - { - return true; - } - } - } - else - { - // The assumption here is that we got a file name. - string filePart = Path.GetFileNameWithoutExtension(name); - if(IsFileNameAllGivenCharacter('.', filePart) || IsFileNameAllGivenCharacter(' ', filePart)) - { - return true; - } - - - return IsFilePartInValid(name); - } - - return false; - } - - /// - /// Checks if a file name is valid. - /// - /// The name of the file - /// True if the file is valid. - public static bool IsFileNameInvalid(string fileName) - { - if(String.IsNullOrEmpty(fileName)) - { - return true; - } - - if(IsFileNameAllGivenCharacter('.', fileName) || IsFileNameAllGivenCharacter(' ', fileName)) - { - return true; - } - - - return IsFilePartInValid(fileName); - - } - - /// - /// Helper method to call a converter explicitely to convert to an enum type - /// - /// THe enum to convert to - /// The enum value to be converted to - /// The type to convert - /// The culture to use to read the localized strings - /// - [CLSCompliant(false)] - public static object ConvertToType(T value, Type typeToConvert, CultureInfo culture) - where T : struct - { - EnumConverter converter = GetEnumConverter(); - if(converter == null) - { - return null; - } - if(converter.CanConvertTo(typeToConvert)) - { - return converter.ConvertTo(null, culture, value, typeToConvert); - } - - return null; - } - - /// - /// Helper method for converting from a string to an enum using a converter. - /// - /// - /// - /// The culture to use to read the localized strings - /// - [CLSCompliant(false)] - public static Nullable ConvertFromType(string value, CultureInfo culture) - where T : struct - { - Nullable returnValue = new Nullable(); - - returnValue = returnValue.GetValueOrDefault(); - - if(value == null) - { - return returnValue; - } - - EnumConverter converter = GetEnumConverter(); - if(converter == null) - { - return returnValue; - } - - if(converter.CanConvertFrom(value.GetType())) - { - object converted = converter.ConvertFrom(null, culture, value); - - if(converted != null && (converted is T)) - { - returnValue = (T)converted; - } - } - - return returnValue; - } - - - /// - /// Sets a string value from an enum - /// - /// The enum type - /// The value of teh enum. - /// The culture to use - /// - [CLSCompliant(false)] - public static string SetStringValueFromConvertedEnum(T enumValue, CultureInfo culture) - where T : struct - { - string convertToType = ConvertToType(enumValue, typeof(string), culture) as string; - - if(convertToType == null) - { - return String.Empty; - } - - return convertToType; - } - - - /// - /// Initializes the in memory project. Sets BuildEnabled on the project to true. - /// - /// The build engine to use to create a build project. - /// The full path of the project. - /// A loaded msbuild project. - internal static MSBuild.Project InitializeMsBuildProject(MSBuild.ProjectCollection buildEngine, string fullProjectPath) - { - if(String.IsNullOrEmpty(fullProjectPath)) - { - throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "fullProjectPath"); - } - - // Call GetFullPath to expand any relative path passed into this method. - fullProjectPath = Path.GetFullPath(fullProjectPath); - - - // Check if the project already has been loaded with the fullProjectPath. If yes return the build project associated to it. - List loadedProject = new List(buildEngine.GetLoadedProjects(fullProjectPath)); - MSBuild.Project buildProject = loadedProject != null && loadedProject.Count > 0 && loadedProject[0] != null ? loadedProject[0] : null; - - if(buildProject == null) - { - buildProject = buildEngine.LoadProject(fullProjectPath); - } - - return buildProject; - } - - /// - /// Loads a project file for the file. If the build project exists and it was loaded with a different file then it is unloaded first. - /// - /// The build engine to use to create a build project. - /// The full path of the project. - /// An Existing build project that will be reloaded. - /// A loaded msbuild project. - internal static MSBuild.Project ReinitializeMsBuildProject(MSBuild.ProjectCollection buildEngine, string fullProjectPath, MSBuild.Project exitingBuildProject) - { - // If we have a build project that has been loaded with another file unload it. - try - { - if(exitingBuildProject != null && exitingBuildProject.ProjectCollection != null && !NativeMethods.IsSamePath(exitingBuildProject.FullPath, fullProjectPath)) - { - buildEngine.UnloadProject(exitingBuildProject); - } - } - // We catch Invalid operation exception because if the project was unloaded while we touch the ParentEngine the msbuild API throws. - // Is there a way to figure out that a project was unloaded? - catch(InvalidOperationException) - { - } - - return Utilities.InitializeMsBuildProject(buildEngine, fullProjectPath); - } - - /// - /// Initialize the build engine. Sets the build enabled property to true. The engine is initialzed if the passed in engine is null or does not have its bin path set. - /// - /// An instance of MSBuild.ProjectCollection build engine, that will be checked if initialized. - /// The service provider. - /// The buildengine to use. - internal static MSBuild.ProjectCollection InitializeMsBuildEngine(MSBuild.ProjectCollection existingEngine, IServiceProvider serviceProvider) - { - if(serviceProvider == null) - { - throw new ArgumentNullException("serviceProvider"); - } - - if(existingEngine == null) - { - MSBuild.ProjectCollection buildEngine = MSBuild.ProjectCollection.GlobalProjectCollection; - return buildEngine; - } - - return existingEngine; - } - - /// - /// Get the outer T implementation - /// - internal static T GetOuterAs(object o) - where T : class - { - T hierarchy = null; - - // The hierarchy of a node is its project node hierarchy. - IntPtr projectUnknown = Marshal.GetIUnknownForObject(o); - - try - { - hierarchy = (T)Marshal.GetTypedObjectForIUnknown(projectUnknown, typeof(T)); - } - finally - { - if (projectUnknown != IntPtr.Zero) - { - Marshal.Release(projectUnknown); - } - } - - return hierarchy; - } - - /// - /// Gets an instance of an EnumConverter for enums that have PropertyPageTypeConverter attribute - /// - /// The type to search for the PropertyPageTypeConverter attribute. - /// An instance of an enum converter, or null if none found. - private static EnumConverter GetEnumConverter() - where T : struct - { - object[] attributes = typeof(T).GetCustomAttributes(typeof(PropertyPageTypeConverterAttribute), true); - - // There should be only one PropertyPageTypeConverterAttribute defined on T - if(attributes != null && attributes.Length == 1) - { - - Debug.Assert(attributes[0] is PropertyPageTypeConverterAttribute, "The returned attribute must be an attribute is PropertyPageTypeConverterAttribute"); - PropertyPageTypeConverterAttribute converterAttribute = (PropertyPageTypeConverterAttribute)attributes[0]; - - if(converterAttribute.ConverterType.IsSubclassOf(typeof(EnumConverter))) - { - return Activator.CreateInstance(converterAttribute.ConverterType) as EnumConverter; - } - } - - return null; - } - - /// > - /// Checks if the file name is all the given character. - /// - private static bool IsFileNameAllGivenCharacter(char c, string fileName) - { - // A valid file name cannot be all "c" . - int charFound = 0; - for(charFound = 0; charFound < fileName.Length && fileName[charFound] == c; ++charFound) ; - if(charFound >= fileName.Length) - { - return true; - } - - return false; - } - - //!EFW - Made the two regular expression instances that were in IsFilePartInValid static since they never - // change. Also removed the RegexOptions.Compiled flag on them since it doesn't appear to have any - // benefit based on how they are used. - - // Define a regular expression that covers all characters that are not in the safe character sets. - private const string reservedName = "(\\b(nul|con|aux|prn)\\b)|(\\b((com|lpt)[0-9])\\b)"; - private const string invalidChars = "([/?:&\\\\*<>|#%\"])"; - - private static Regex unsafeCharactersRegex = new Regex(invalidChars, RegexOptions.IgnoreCase | - RegexOptions.CultureInvariant); - private static Regex unsafeFileNameCharactersRegex = new Regex(reservedName + "|" + invalidChars, - RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); - - /// - /// Checks whether a file part contains valid characters. The file part can be any part of a non rooted - /// path. - /// - /// The file part to check - /// True if the file part is invalid, false if not - private static bool IsFilePartInValid(string filePart) - { - if(String.IsNullOrEmpty(filePart)) - return true; - - string fileNameToVerify = filePart; - - // The filePart might still be a file and extension. If it is like that then we must check them - // separately, since different rules apply. - string extension = String.Empty; - - try - { - extension = Path.GetExtension(filePart); - } - catch(ArgumentException) - { - // We catch the ArgumentException because we want this method to return true if the filename is - // not valid. FilePart could be for example #�&%"�&"% and that would throw ArgumentException on - // GetExtension. - return true; - } - - if(!String.IsNullOrEmpty(extension)) - { - // Check the extension first - if(unsafeCharactersRegex.IsMatch(extension)) - return true; - - // We want to verify here everything but the extension. - // We cannot use GetFileNameWithoutExtension because it might be that for example - // (..\\filename.txt) is passed in and that should fail, since that is not a valid filename. - fileNameToVerify = filePart.Substring(0, filePart.Length - extension.Length); - - if(String.IsNullOrEmpty(fileNameToVerify)) - return true; - } - - // We verify CLOCK$ (a device name) outside the regex since for some reason the regex is not matching - // the clock\\$ added. - if(String.Compare(fileNameToVerify, "CLOCK$", StringComparison.OrdinalIgnoreCase) == 0) - return true; - - return unsafeFileNameCharactersRegex.IsMatch(fileNameToVerify); - } - - /// - /// Copy a directory recursively to the specified non-existing directory - /// - /// Directory to copy from - /// Directory to copy to - public static void RecursivelyCopyDirectory(string source, string target) - { - // !EFW - Make sure we aren't copying a parent folder to one of it's child sub-folder - string sourcePath, destPath; - - // Either one may or may not have the trailing backslash so remove it from both if present - if(target.EndsWith("\\", StringComparison.Ordinal)) - sourcePath = Path.GetDirectoryName(source); - else - sourcePath = source; - - if(target.EndsWith("\\", StringComparison.Ordinal)) - destPath = Path.GetDirectoryName(target); - else - destPath = target; - - if(destPath.StartsWith(sourcePath, StringComparison.OrdinalIgnoreCase)) - throw new InvalidOperationException("Cannot copy a parent folder to one of its child sub-folder"); - - // Make sure it doesn't already exist - if(Directory.Exists(target)) - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.FileOrFolderAlreadyExists, CultureInfo.CurrentUICulture), target)); - - Directory.CreateDirectory(target); - DirectoryInfo directory = new DirectoryInfo(source); - - // Copy files - foreach(FileInfo file in directory.GetFiles()) - { - file.CopyTo(Path.Combine(target, file.Name)); - } - - // Now recurse to child directories - foreach(DirectoryInfo child in directory.GetDirectories()) - { - RecursivelyCopyDirectory(child.FullName, Path.Combine(target, child.Name)); - } - } - - /// - /// Canonicalizes a file name, including: - /// - determines the full path to the file - /// - casts to upper case - /// Canonicalizing a file name makes it possible to compare file names using simple simple string comparison. - /// - /// Note: this method does not handle shared drives and UNC drives. - /// - /// A file name, which can be relative/absolute and contain lower-case/upper-case characters. - /// Canonicalized file name. - internal static string CanonicalizeFileName(string anyFileName) - { - // Get absolute path - // Note: this will not handle UNC paths - FileInfo fileInfo = new FileInfo(anyFileName); - string fullPath = fileInfo.FullName; - - // Cast to upper-case - fullPath = fullPath.ToUpper(CultureInfo.CurrentCulture); - - return fullPath; - } - - - /// - /// Determines if a file is a template. - /// - /// The file to check whether it is a template file - /// true if the file is a template file - internal static bool IsTemplateFile(string fileName) - { - if(String.IsNullOrEmpty(fileName)) - { - return false; - } - - string extension = Path.GetExtension(fileName); - return (String.Compare(extension, ".vstemplate", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(extension, ".vsz", StringComparison.OrdinalIgnoreCase) == 0); - } - - /// - /// Retrives the configuration and the platform using the IVsSolutionBuildManager2 interface. - /// - /// A service provider. - /// The hierarchy whose configuration is requested. This method calls into - /// native code and may be called on a background thread, so make sure the IVsHierarchy passed is - /// safe to use for that sort of interop. - /// The name of the active configuration. - /// The name of the platform. - /// true if successfull. - internal static bool TryGetActiveConfigurationAndPlatform(System.IServiceProvider serviceProvider, IVsHierarchy hierarchy, out string configuration, out string platform) - { - if(serviceProvider == null) - { - throw new ArgumentNullException("serviceProvider"); - } - - if(hierarchy == null) - { - throw new ArgumentNullException("hierarchy"); - } - - configuration = String.Empty; - platform = String.Empty; - - IVsSolutionBuildManager2 solutionBuildManager = serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2; - - if(solutionBuildManager == null) - { - return false; - } - - IVsProjectCfg[] activeConfigs = new IVsProjectCfg[1]; - ErrorHandler.ThrowOnFailure(solutionBuildManager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, hierarchy, activeConfigs)); - - IVsProjectCfg activeCfg = activeConfigs[0]; - - // Can it be that the activeCfg is null? - System.Diagnostics.Debug.Assert(activeCfg != null, "Cannot find the active configuration"); - - string canonicalName; - ErrorHandler.ThrowOnFailure(activeCfg.get_CanonicalName(out canonicalName)); - - return ProjectConfig.TrySplitConfigurationCanonicalName(canonicalName, out configuration, out platform); - } - - /// - /// Determines whether the shell is in command line mode. - /// - /// A reference to a Service Provider. - /// true if the shell is in command line mode. false otherwise. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal static bool IsShellInCommandLineMode(System.IServiceProvider serviceProvider) - { - if(serviceProvider == null) - { - throw new ArgumentNullException("serviceProvider"); - } - - IVsShell shell = serviceProvider.GetService(typeof(SVsShell)) as IVsShell; - if(shell == null) - { - throw new InvalidOperationException(); - } - - object isInCommandLineModeAsObject; - ErrorHandler.ThrowOnFailure(shell.GetProperty((int)__VSSPROPID.VSSPROPID_IsInCommandLineMode, out isInCommandLineModeAsObject)); - - return ((bool)isInCommandLineModeAsObject); - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/VSShellUtilities.cs b/SHFB/Source/MPFProj_VS2010/VSShellUtilities.cs deleted file mode 100644 index 440b0133..00000000 --- a/SHFB/Source/MPFProj_VS2010/VSShellUtilities.cs +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell.Interop; - -namespace Microsoft.VisualStudio.Project -{ - /// - ///This class provides some useful static shell based methods. - /// - [CLSCompliant(false)] - public static class UIHierarchyUtilities - { - /// - /// Get reference to IVsUIHierarchyWindow interface from guid persistence slot. - /// - /// The service provider. - /// 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. - /// A reference to an IVsUIHierarchyWindow interface. - public static IVsUIHierarchyWindow GetUIHierarchyWindow(IServiceProvider serviceProvider, Guid persistenceSlot) - { - if(serviceProvider == null) - { - throw new ArgumentNullException("serviceProvider"); - } - - IVsUIShell shell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; - - Debug.Assert(shell != null, "Could not get the ui shell from the project"); - if(shell == null) - { - throw new InvalidOperationException(); - } - - object pvar = null; - IVsWindowFrame frame = null; - IVsUIHierarchyWindow uiHierarchyWindow = null; - - try - { - ErrorHandler.ThrowOnFailure(shell.FindToolWindow(0, ref persistenceSlot, out frame)); - ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out pvar)); - } - finally - { - if(pvar != null) - { - uiHierarchyWindow = (IVsUIHierarchyWindow)pvar; - } - } - - return uiHierarchyWindow; - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/VisualStudio.Project.cs b/SHFB/Source/MPFProj_VS2010/VisualStudio.Project.cs deleted file mode 100644 index 1d9d950b..00000000 --- a/SHFB/Source/MPFProj_VS2010/VisualStudio.Project.cs +++ /dev/null @@ -1,322 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -//=============================================================================================================== -// File : NodeProperties.cs -// Updated : 12/29/2013 -// Modifier: Eric Woodruff (Eric@EWoodruff.us) -// -// Search for "!EFW" to find the changes -// -// Date Who Comments -// ============================================================================================================== -// 12/29/2013 EFW Added support for ReferenceOutputAssembly metadata -//=============================================================================================================== - -using System; -using System.Globalization; -using System.Resources; -using System.Threading; -using System.ComponentModel; - -namespace Microsoft.VisualStudio.Project -{ - [AttributeUsage(AttributeTargets.All)] - internal sealed class SRDescriptionAttribute : DescriptionAttribute - { - private bool replaced; - - public SRDescriptionAttribute(string description) - : base(description) - { - } - - public override string Description - { - get - { - if(!replaced) - { - replaced = true; - DescriptionValue = SR.GetString(base.Description, CultureInfo.CurrentUICulture); - } - return base.Description; - } - } - } - - [AttributeUsage(AttributeTargets.All)] - internal sealed class SRCategoryAttribute : CategoryAttribute - { - - public SRCategoryAttribute(string category) - : base(category) - { - } - - protected override string GetLocalizedString(string value) - { - return SR.GetString(value, CultureInfo.CurrentUICulture); - } - } - internal sealed class SR - { - internal const string AddReferenceDialogTitle = "AddReferenceDialogTitle"; - internal const string AddToNullProjectError = "AddToNullProjectError"; - internal const string Advanced = "Advanced"; - internal const string AssemblyReferenceAlreadyExists = "AssemblyReferenceAlreadyExists"; - internal const string AttributeLoad = "AttributeLoad"; - internal const string BuildAction = "BuildAction"; - internal const string BuildActionDescription = "BuildActionDescription"; - internal const string BuildCaption = "BuildCaption"; - internal const string BuildVerbosity = "BuildVerbosity"; - internal const string BuildVerbosityDescription = "BuildVerbosityDescription"; - internal const string BuildEventError = "BuildEventError"; - internal const string CancelQueryEdit = "CancelQueryEdit"; - internal const string CannotAddFileThatIsOpenInEditor = "CannotAddFileThatIsOpenInEditor"; - internal const string CanNotSaveFileNotOpeneInEditor = "CanNotSaveFileNotOpeneInEditor"; - internal const string cli1 = "cli1"; - internal const string Compile = "Compile"; - internal const string ConfirmExtensionChange = "ConfirmExtensionChange"; - internal const string Content = "Content"; - internal const string CopyToLocal = "CopyToLocal"; - internal const string CopyToLocalDescription = "CopyToLocalDescription"; - internal const string EmbedInteropTypes = "EmbedInteropTypes"; - internal const string EmbedInteropTypesDescription = "EmbedInteropTypesDescription"; - // !EFW - Added support for ReferenceOutputAssembly metadata - internal const string ReferenceOutputAssembly = "ReferenceOutputAssembly"; - internal const string ReferenceOutputAssemblyDescription = "ReferenceOutputAssemblyDescription"; - - internal const string CustomTool = "CustomTool"; - internal const string CustomToolDescription = "CustomToolDescription"; - internal const string CustomToolNamespace = "CustomToolNamespace"; - internal const string CustomToolNamespaceDescription = "CustomToolNamespaceDescription"; - internal const string DetailsImport = "DetailsImport"; - internal const string DetailsUserImport = "DetailsUserImport"; - internal const string DetailsItem = "DetailsItem"; - internal const string DetailsItemLocation = "DetailsItemLocation"; - internal const string DetailsProperty = "DetailsProperty"; - internal const string DetailsTarget = "DetailsTarget"; - internal const string DetailsUsingTask = "DetailsUsingTask"; - internal const string Detailed = "Detailed"; - internal const string Diagnostic = "Diagnostic"; - internal const string DirectoryExistError = "DirectoryExistError"; - internal const string EditorViewError = "EditorViewError"; - internal const string EmbeddedResource = "EmbeddedResource"; - internal const string Error = "Error"; - internal const string ErrorInvalidFileName = "ErrorInvalidFileName"; - internal const string ErrorInvalidProjectName = "ErrorInvalidProjectName"; - internal const string ErrorReferenceCouldNotBeAdded = "ErrorReferenceCouldNotBeAdded"; - internal const string ErrorMsBuildRegistration = "ErrorMsBuildRegistration"; - internal const string ErrorSaving = "ErrorSaving"; - internal const string Exe = "Exe"; - internal const string ExpectedObjectOfType = "ExpectedObjectOfType"; - internal const string FailedToGetService = "FailedToGetService"; - internal const string FailedToRetrieveProperties = "FailedToRetrieveProperties"; - internal const string FileNameCannotContainALeadingPeriod = "FileNameCannotContainALeadingPeriod"; - internal const string FileCannotBeRenamedToAnExistingFile = "FileCannotBeRenamedToAnExistingFile"; - internal const string FileAlreadyExistsAndCannotBeRenamed = "FileAlreadyExistsAndCannotBeRenamed"; - internal const string FileAlreadyExists = "FileAlreadyExists"; - internal const string FileAlreadyExistsCaption = "FileAlreadyExistsCaption"; - internal const string FileAlreadyInProject = "FileAlreadyInProject"; - internal const string FileAlreadyInProjectCaption = "FileAlreadyInProjectCaption"; - internal const string FileCopyError = "FileCopyError"; - internal const string FileName = "FileName"; - internal const string FileNameDescription = "FileNameDescription"; - internal const string FileOrFolderAlreadyExists = "FileOrFolderAlreadyExists"; - internal const string FileOrFolderCannotBeFound = "FileOrFolderCannotBeFound"; - internal const string FileProperties = "FileProperties"; - internal const string FolderName = "FolderName"; - internal const string FolderNameDescription = "FolderNameDescription"; - internal const string FolderProperties = "FolderProperties"; - internal const string FullPath = "FullPath"; - internal const string FullPathDescription = "FullPathDescription"; - internal const string ItemDoesNotExistInProjectDirectory = "ItemDoesNotExistInProjectDirectory"; - internal const string InvalidAutomationObject = "InvalidAutomationObject"; - internal const string InvalidLoggerType = "InvalidLoggerType"; - internal const string InvalidParameter = "InvalidParameter"; - internal const string Library = "Library"; - internal const string LinkedItemsAreNotSupported = "LinkedItemsAreNotSupported"; - internal const string Minimal = "Minimal"; - internal const string Misc = "Misc"; - internal const string None = "None"; - internal const string Normal = "Normal"; - internal const string NestedProjectFailedToReload = "NestedProjectFailedToReload"; - internal const string OutputPath = "OutputPath"; - internal const string OutputPathDescription = "OutputPathDescription"; - internal const string PasteFailed = "PasteFailed"; - internal const string ParameterMustBeAValidGuid = "ParameterMustBeAValidGuid"; - internal const string ParameterMustBeAValidItemId = "ParameterMustBeAValidItemId"; - internal const string ParameterCannotBeNullOrEmpty = "ParameterCannotBeNullOrEmpty"; - internal const string PathTooLong = "PathTooLong"; - internal const string ProjectContainsCircularReferences = "ProjectContainsCircularReferences"; - internal const string Program = "Program"; - internal const string Project = "Project"; - internal const string ProjectFile = "ProjectFile"; - internal const string ProjectFileDescription = "ProjectFileDescription"; - internal const string ProjectFolder = "ProjectFolder"; - internal const string ProjectFolderDescription = "ProjectFolderDescription"; - internal const string ProjectProperties = "ProjectProperties"; - internal const string Quiet = "Quiet"; - internal const string QueryReloadNestedProject = "QueryReloadNestedProject"; - internal const string ReferenceAlreadyExists = "ReferenceAlreadyExists"; - internal const string ReferencesNodeName = "ReferencesNodeName"; - internal const string ReferenceProperties = "ReferenceProperties"; - internal const string RefName = "RefName"; - internal const string RefNameDescription = "RefNameDescription"; - internal const string RenameFolder = "RenameFolder"; - internal const string RTL = "RTL"; - internal const string SaveCaption = "SaveCaption"; - internal const string SaveModifiedDocuments = "SaveModifiedDocuments"; - internal const string SaveOfProjectFileOutsideCurrentDirectory = "SaveOfProjectFileOutsideCurrentDirectory"; - internal const string StandardEditorViewError = "StandardEditorViewError"; - internal const string Settings = "Settings"; - internal const string URL = "URL"; - internal const string UseOfDeletedItemError = "UseOfDeletedItemError"; - internal const string Warning = "Warning"; - internal const string WinExe = "WinExe"; - internal const string CannotLoadUnknownTargetFrameworkProject = "CannotLoadUnknownTargetFrameworkProject"; - internal const string ReloadPromptOnTargetFxChanged = "ReloadPromptOnTargetFxChanged"; - internal const string ReloadPromptOnTargetFxChangedCaption = "ReloadPromptOnTargetFxChangedCaption"; - - static SR loader; - ResourceManager resources; - - private static Object s_InternalSyncObject; - private static Object InternalSyncObject - { - get - { - if(s_InternalSyncObject == null) - { - Object o = new Object(); - Interlocked.CompareExchange(ref s_InternalSyncObject, o, null); - } - return s_InternalSyncObject; - } - } - - internal SR() - { - resources = new System.Resources.ResourceManager("Microsoft.VisualStudio.Project", this.GetType().Assembly); - } - - private static SR GetLoader() - { - if(loader == null) - { - lock(InternalSyncObject) - { - if(loader == null) - { - loader = new SR(); - } - } - } - - return loader; - } - - private static CultureInfo Culture - { - get { return null/*use ResourceManager default, CultureInfo.CurrentUICulture*/; } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - public static ResourceManager Resources - { - get - { - return GetLoader().resources; - } - } - - public static string GetString(string name, params object[] args) - { - SR sys = GetLoader(); - if(sys == null) - return null; - string res = sys.resources.GetString(name, SR.Culture); - - if(args != null && args.Length > 0) - { - return String.Format(CultureInfo.CurrentCulture, res, args); - } - else - { - return res; - } - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - public static string GetString(string name) - { - SR sys = GetLoader(); - if(sys == null) - return null; - return sys.resources.GetString(name, SR.Culture); - } - - public static string GetString(string name, CultureInfo culture) - { - SR sys = GetLoader(); - if(sys == null) - return null; - return sys.resources.GetString(name, culture); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - public static object GetObject(string name) - { - SR sys = GetLoader(); - if(sys == null) - return null; - return sys.resources.GetObject(name, SR.Culture); - } - } -} diff --git a/SHFB/Source/MPFProj_VS2010/VisualStudio.Project.resx b/SHFB/Source/MPFProj_VS2010/VisualStudio.Project.resx deleted file mode 100644 index 14f475fc..00000000 --- a/SHFB/Source/MPFProj_VS2010/VisualStudio.Project.resx +++ /dev/null @@ -1,547 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Failed to add file '{0}' to project as project is null. - - - Advanced - Project Property Page Caption - - - A reference to component '{0}' cannot be added. A reference to the component already exists in the project. - ReferenceAlreadyExists error message - - - Could not load attribute '{0}' from project file '{1}'. - - - Build Action - Project Build Property Name - - - How the file relates to the build and deployment process - Project Build Property Description - - - Verbosity - - - Specify how much information is included in the build output - - - ECMA-335 CLI compatible framework (location must be provided) - Target platform drop down option - - - Compile - Build Action - drop down option - - - If you change a file name extension, the file may become unusable. Are you sure you want to change it? - - - A file with name '{0}' already exists and is open in an editor. Please give a unique name to the item you are adding, or delete the existing item first. - - - Cannot save '{0}' as it is not open in the editor. - - - Content - Build Action - drop down option - - - Copy Local - File property - - - Indicates whether the reference will be copied to the output directory. - - - Embed Interop Types - - - Whether to include the COM interface definitions directly in the compiled assembly. - - - Detailed - - - Diagnostic - - - Directory already exists - - - Error opening specified view '{0}' using editor '{1}' - - - Embedded Resource - Build Action - drop down option - - - error - - - Files and folders cannot be: -- Empty strings -- System reserved names, including 'CON', 'AUX', PRN', 'COM1' or 'LPT2' -- contain only '.' -- have any of the following characters: / ? : & \ * " < > | # % - - - The name you provided is not a valid project name. - - - MSBuild path not found in registry. Please reinstall to fix the problem. - - - Error Saving File - - - Console Application - - - Expecting object of type {0}. - - - Failed to retrieve MSBuild property {0} from the project file. - The exception message thrown when getting a property from msbuild fails. - - - A file with the same name '{0}' already exists. Do you want to overwrite it? - - - A file with the same name '{0}' already exists. - - - Destination File Exists - - - A file of this name is already part of the project. Do you want to overwrite it? - - - Destination File Exists - - - A file or folder with the name '{0}' already exists on disk at this location. Please choose another name. - - - Error Copying File - - - File Name - - - File and folder names cannot contain a leading period. - - - The name of the file or folder - - - Folder Name - - - Name of this folder - - - Full Path - - - Location of the file - - - The item '{0}' does not exist in the project directory. It may have been moved, renamed or deleted. - - - Cannot save '{0}' outside the project directory. Linked items are not supported. - - - Class Library - - - Minimal - - - Misc - - - None - - - Normal - - - Item is not available or corrupted and thus cannot be pasted. - - - Program - - - Project - - - A reference to library '{0}' cannot be added. Adding this project as a reference would cause a circular dependency. - - - Project File - - - The name of the file containing build, configuration, and other information about the project. - - - Project Folder - - - The absolute location of the project. - - - Quiet - - - (Name) - - - References - - - Display name of the reference - - - Rename directory failed. {0} - - - RTL_False - - - Save? - - - Do you want to save modified documents? - - - The project file can only be saved into the project location '{0}'. - - - Error opening specified view '{0}' using standard editor. - - - URL - - - You are trying to use an item that has already been deleted or that does not exist. - - - Microsoft .NET Framework v1.0 - - - Microsoft .NET Framework v1.1 - - - Microsoft .NET Framework v2.0 - - - warning - - - Windows Application - - - Add Reference - - - Automation object invalid. - - - The command you are attempting cannot be completed because the file '{0}' that must be modified cannot be changed. If the file is under source control, you may want to check it out; if the file is read-only on disk, you may want to change its attributes. - MsgBox - - - Parameter must be a valid guid. - Error message in the ArgumentException for a parameter that is not a valid guid. - - - Invalid logger type\nExpected: {0}\nReceived: {1} - Error message thrown for when an invalid logger type is set. - - - InvalidParameter - Generic error message for invalid parameters. - - - ParameterCannotBeNullOEmpty - Error message for string parameters that cannot be null or empty. - - - Parameter must be a valid item identifier. - Error message thrown when an invalid item id is retrieved. - - - File Properties - - - Folder Properties - - - Project Properties - - - Reference Properties - - - A file or folder with the name '{0}' already exists on disk at this location. Please choose another name. - - - Build - - - Output Path - - - The path to the primary output - - - The complete path to '{0}' exceeds the maximum number of characters permitted by the file system. - - - Custom Tool - - - Specifies the tool that transforms a file at design time and places the output of that transformation into another file. For example, a dataset (.xsd) file comes with a default custom tool. - - - Custom Tool Namespace - - - The namespace into which the output of the custom tool is placed. - - - Primary Output - - - Content Files - - - Documentation Files - - - Localized Resources - - - Source Files - - - Debug Symbols - - - XML Serialization Assemblies - - - Contains the DLL or EXE built by the project. - - - Contains all content files in the project. - - - Contains the XML Documentation files for the project. - - - Contains the satellite assemblies for each culture's resources. - - - Contains all source files in the project. - - - Contains the debugging files for the project. - - - Contains the XML serialization assemblies for the project. - - - The project file '{0}' has been modified outside of Visual Studio. Do you want to reload the project? - - - The nested project has failed to reload. - - - The item '{0}' cannot be found on disk, either because it has been renamed, deleted, or moved to a new location. - - - A reference to {0} could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component. - - - An 'Import' of the file '{1}' was found in the project file '{0}'. This file is not registered as a safe file to import, and could contain targets and tasks that are harmful. If this imported file is indeed considered safe, then it can be registered by writing to the registry key {2}. - - - An 'Import' of the file '{1}' was found in the user project file '{0}'. All imports in user project files are considered unsafe. - - - One or more items named '{1}' were found in the project file '{0}'. These items normally should not be specified in the project file. They can change the way targets and tasks are executed during project load, and this could have harmful effects. - - - A property named '{1}' was found in the project file '{0}'. This property normally should not be specified in the project file. Its value can change the way targets and tasks are executed during project load, and this could have harmful effects. - - - A 'UsingTask' tag which registers the '{1}' task was found in the project file '{0}'. 'UsingTask' tags in the project file take precedence over those in the imported .TARGETS files, and therefore could be used to execute arbitrary code during an otherwise unmodified build process. - - - A 'Target' named '{1}' was found in the project file '{0}'. The tasks within this target could contain arbitrary code and may get executed as soon as the project is loaded in the IDE. - - - An item referring to the file '{1}' was found in the project file '{0}'. Since this file is located within a system directory, root directory, or network share, it could be harmful to write to this file. - - - The project location is not trusted:{0}{0}{1}{0}{0}Running the application may result in security exceptions when it {0}attempts to perform actions which require full trust.{0}{0}Click OK to ignore and continue. - - - Exception was thrown during BuildBegin event\n{0} - - - Settings - - - Microsoft .NET Framework v3.0 - - - Microsoft .NET Framework v3.5 - - - Microsoft .NET Framework v4.0 - - - The project '{0}' is targeting '{1}'; however, the target framework is not installed on the machine. - - - Changing the Target Framework requires that the current project be closed and then reopened. -Any unsaved changes within the project will be automatically saved. - -Changing Target Framework may require manual modification of project files in order to build. - -Are you sure you want to change the Target Framework for this project? - - - Target Framework Change - - - Reference Output Assembly - - - True to reference the output assembly or false to only use it for MSBuild dependency determination - - \ No newline at end of file diff --git a/SHFB/Source/MPFProj_VS2010/VsCommands.cs b/SHFB/Source/MPFProj_VS2010/VsCommands.cs deleted file mode 100644 index fb5fa7c5..00000000 --- a/SHFB/Source/MPFProj_VS2010/VsCommands.cs +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************************** - -Copyright (c) Microsoft Corporation -All rights reserved. - -Microsoft Public License: - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free copyright license to reproduce its contribution, prepare derivative works of -its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions -and limitations in section 3, each contributor grants you a non-exclusive, worldwide, -royalty-free license under its licensed patents to make, have made, use, sell, offer for -sale, import, and/or otherwise dispose of its contribution in the software or derivative -works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' -name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are -infringed by the software, your patent license from such contributor to the software ends -automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, -trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only -under this license by including a complete copy of this license with your distribution. -If you distribute any portion of the software in compiled or object code form, you may only -do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give -no express warranties, guarantees or conditions. You may have additional consumer rights -under your local laws which this license cannot change. To the extent permitted under your -local laws, the contributors exclude the implied warranties of merchantability, fitness for -a particular purpose and non-infringement. - -********************************************************************************************/ - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Microsoft.VisualStudio.Project -{ - /// - /// Defines menu commands guids and menu command id's - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1053:StaticHolderTypesShouldNotHaveConstructors"), SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Vs")] - public class VsMenus - { - // menu command guids. - [SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible")] - public static Guid guidStandardCommandSet97 = new Guid("5efc7975-14bc-11cf-9b2b-00aa00573819"); - - [SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible")] - public static Guid guidStandardCommandSet2K = new Guid("1496A755-94DE-11D0-8C3F-00C04FC2AAE2"); - - [SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pkg")] - public static Guid guidVsVbaPkg = new Guid(0xa659f1b3, 0xad34, 0x11d1, 0xab, 0xad, 0x0, 0x80, 0xc7, 0xb8, 0x9c, 0x95); - - [SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible")] - public static Guid guidSHLMainMenu = new Guid(0xd309f791, 0x903f, 0x11d0, 0x9e, 0xfc, 0x00, 0xa0, 0xc9, 0x11, 0x00, 0x4f); - - [SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible")] - public static Guid guidVSUISet = new Guid("60481700-078b-11d1-aaf8-00a0c9055a90"); - - [SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cmds")] - public static Guid guidVsUIHierarchyWindowCmds = new Guid("60481700-078B-11D1-AAF8-00A0C9055A90"); - - // Special Menus. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CODEWIN")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CTXT")] - [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] - public const int IDM_VS_CTXT_CODEWIN = 0x040D; - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ITEMNODE")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CTXT")] - [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] - public const int IDM_VS_CTXT_ITEMNODE = 0x0430; - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "PROJNODE")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CTXT")] - [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] - public const int IDM_VS_CTXT_PROJNODE = 0x0402; - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "REFERENCEROOT")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CTXT")] - [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] - public const int IDM_VS_CTXT_REFERENCEROOT = 0x0450; - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "REFERENCE")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CTXT")] - [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] - public const int IDM_VS_CTXT_REFERENCE = 0x0451; - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "FOLDERNODE")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CTXT")] - [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] - public const int IDM_VS_CTXT_FOLDERNODE = 0x0431; - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "NOCOMMANDS")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CTXT")] - [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] - public const int IDM_VS_CTXT_NOCOMMANDS = 0x041A; - - public const int VSCmdOptQueryParameterList = 1; - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "MULTIITEM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CTXT")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "XPROJ")] - [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] - public const int IDM_VS_CTXT_XPROJ_MULTIITEM = 0x0419; - - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "PROJITEM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "IDM")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CTXT")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "XPROJ")] - [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] - public const int IDM_VS_CTXT_XPROJ_PROJITEM = 0x0417; - } -} diff --git a/SHFB/Source/SandcastleBuilderPackage.sln b/SHFB/Source/SandcastleBuilderPackage.sln index 81a8fc7d..c1a8a5b3 100644 --- a/SHFB/Source/SandcastleBuilderPackage.sln +++ b/SHFB/Source/SandcastleBuilderPackage.sln @@ -6,8 +6,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SandcastleBuilderPackage", {72331A21-C452-4BE4-BFDB-B8029A6BC1C0} = {72331A21-C452-4BE4-BFDB-B8029A6BC1C0} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.VisualStudio.Project", "MPFProj_VS2010\Microsoft.VisualStudio.Project.csproj", "{CACB60A9-1E76-4F92-8831-B134A658C695}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SandcastleBuilderUtils", "SandcastleBuilderUtils\SandcastleBuilderUtils.csproj", "{330DADF7-3AB1-49A0-B3C6-A69D2C4F06A6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorizerLibrary", "CodeColorizer\ColorizerLibrary\ColorizerLibrary.csproj", "{72331A21-C452-4BE4-BFDB-B8029A6BC1C0}" @@ -31,10 +29,6 @@ Global {242129CC-9310-450C-AEE3-4B849ECFB67E}.Debug|Any CPU.Build.0 = Debug|Any CPU {242129CC-9310-450C-AEE3-4B849ECFB67E}.Release|Any CPU.ActiveCfg = Release|Any CPU {242129CC-9310-450C-AEE3-4B849ECFB67E}.Release|Any CPU.Build.0 = Release|Any CPU - {CACB60A9-1E76-4F92-8831-B134A658C695}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CACB60A9-1E76-4F92-8831-B134A658C695}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CACB60A9-1E76-4F92-8831-B134A658C695}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CACB60A9-1E76-4F92-8831-B134A658C695}.Release|Any CPU.Build.0 = Release|Any CPU {330DADF7-3AB1-49A0-B3C6-A69D2C4F06A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {330DADF7-3AB1-49A0-B3C6-A69D2C4F06A6}.Debug|Any CPU.Build.0 = Debug|Any CPU {330DADF7-3AB1-49A0-B3C6-A69D2C4F06A6}.Release|Any CPU.ActiveCfg = Release|Any CPU From 103821bb3efd66b234f99c6ef850c86ff62a158e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 11 Aug 2014 15:06:21 -0500 Subject: [PATCH 3/3] Simplify implementation of AddFileToMSBuild --- .../Nodes/SandcastleBuilderProjectNode.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNode.cs b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNode.cs index 322da0ab..2b8d7745 100644 --- a/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNode.cs +++ b/SHFB/Source/SandcastleBuilderPackage/Nodes/SandcastleBuilderProjectNode.cs @@ -704,9 +704,7 @@ public override int GetFormatList(out string ppszFormatList) public override ProjectElement AddFileToMSBuild(string file) { SandcastleBuildAction buildAction = SandcastleProject.DefaultBuildAction(file); - string itemPath = PackageUtilities.MakeRelative(base.FileName, file); - - ProjectElement newItem = this.CreateMSBuildFileItem(itemPath, buildAction.ToString()); + ProjectElement newItem = AddFileToMSBuild(file, buildAction.ToString(), null); // Set the default ID and alternate text if it is an Image element if(buildAction == SandcastleBuildAction.Image)