diff --git a/src/fsharp/lib.fs b/src/fsharp/lib.fs index fee5e7c848b..60c705d1b92 100644 --- a/src/fsharp/lib.fs +++ b/src/fsharp/lib.fs @@ -341,53 +341,6 @@ type Graph<'Data, 'Id when 'Id : comparison and 'Id : equality> else List.iter (trace (node.nodeData::path)) node.nodeNeighbours List.iter (fun node -> trace [] node) nodes -#if OLDCODE - - member g.DepthFirstSearch() = - let grey = ref Set.empty - let time = ref 0 - let forest = ref [] - let backEdges = ref [] - let discoveryTimes = ref Map.empty - let finishingTimes = ref Map.empty - nodes |> List.iter (fun n -> - // build a dfsTree for each node in turn - let treeEdges = ref [] - let rec visit n1 = - incr time; - grey := Set.add n1.nodeId !grey; - discoveryTimes := Map.add n1.nodeId !time !discoveryTimes; - for n2 in n1.nodeNeighbours do - if not ((!grey).Contains n2.nodeId) then - treeEdges := (n1.nodeId,n2.nodeId) :: !treeEdges; - visit(n2) - else - backEdges := (n1.nodeId,n2.nodeId) :: !backEdges - incr time; - finishingTimes := Map.add n1.nodeId !time !finishingTimes; - () - if not ((!grey).Contains n.nodeId) then - visit(n); - forest := (n.nodeId,!treeEdges) :: !forest); - - !forest, !backEdges, (fun n -> (!discoveryTimes).[n]), (fun n -> (!finishingTimes).[n]) - - - // Present strongly connected components, in dependency order - // Each node is assumed to have a self-edge - member g.GetTopologicalSortStronglyConnectedComponents() = - let forest, backEdges, discoveryTimes, finishingTimes = g.DepthFirstSearch() - let nodeIds = List.map (fun n -> n.nodeId) nodes - let nodesInDecreasingFinishingOrder = - List.sortWith (fun n1 n2 -> -(compare (finishingTimes n1) (finishingTimes n2))) nodeIds - let gT = Graph (nodeIdentity, List.map g.GetNodeData nodesInDecreasingFinishingOrder, List.map (fun (x,y) -> (g.GetNodeData y, g.GetNodeData x)) edges) - let forest, backEdges, discoveryTimes, finishingTimes = gT.DepthFirstSearch() - let scc (root,tree) = Set.add root (List.foldBack (fun (n1,n2) acc -> Set.add n1 (Set.add n2 acc)) tree Set.empty) - let sccs = List.rev (List.map scc forest) - List.map (Set.toList >> List.map g.GetNodeData) sccs -#endif - - //--------------------------------------------------------------------------- // In some cases we play games where we use 'null' as a more efficient representation // in F#. The functions below are used to give initial values to mutable fields. diff --git a/src/fsharp/vs/ServiceDeclarations.fs b/src/fsharp/vs/ServiceDeclarations.fs index 1cbfa1b4322..8cae7b7814d 100644 --- a/src/fsharp/vs/ServiceDeclarations.fs +++ b/src/fsharp/vs/ServiceDeclarations.fs @@ -107,35 +107,6 @@ module internal ItemDescriptionsImpl = // Format the supertypes and other useful information about a type to a buffer let OutputUsefulTypeInfo _isDeclInfo (_infoReader:InfoReader) _m _denv _os _ty = () -#if DISABLED - if false then - ErrorScope.ProtectAndDiscard m (fun () -> - let g = infoReader.g - let amap = infoReader.amap - let supertypes = - let supertypes = AllSuperTypesOfType g amap m AllowMultiIntfInstantiations.Yes ty - let supertypes = supertypes |> List.filter (AccessibilityLogic.IsTypeAccessible g AccessibleFromSomewhere) - let supertypes = supertypes |> List.filter (typeEquiv g g.obj_ty >> not) - let selfs,supertypes = supertypes |> List.partition (typeEquiv g ty) - let supertypesC,supertypesI = supertypes |> List.partition (isInterfaceTy g) - let supertypes = selfs @ supertypesC @ supertypesI - supertypes - let supertypeLs,_ = NicePrint.layoutPrettifiedTypes denv supertypes - // Suppress printing supertypes for enums, delegates, exceptions and attributes - if supertypes.Length > 1 // more then self - && not (isEnumTy g ty) - && not (isUnionTy g ty) - && not (isRecdTy g ty) - && not (isDelegateTy g ty) - && not (ExistsHeadTypeInEntireHierarchy g amap m ty g.exn_tcr) - && not (ExistsHeadTypeInEntireHierarchy g amap m ty g.tcref_System_Attribute) then - bprintf os "\n\n"; - List.zip supertypes supertypeLs |> List.iter (fun (superty,supertyL) -> - if typeEquiv g superty ty then bprintf os " %s: %a\n" (FSComp.SR.typeInfoType()) bufferL supertyL - elif isClassTy g superty || isInterfaceTy g ty then bprintf os " %s: %a\n" (FSComp.SR.typeInfoInherits()) bufferL supertyL - else bprintf os " %s: %a\n" (FSComp.SR.typeInfoImplements()) bufferL supertyL)) -#endif - let rangeOfPropInfo (pinfo:PropInfo) = match pinfo with diff --git a/src/utils/sformat.fs b/src/utils/sformat.fs index 35e25169b04..18905583bd7 100644 --- a/src/utils/sformat.fs +++ b/src/utils/sformat.fs @@ -1159,31 +1159,6 @@ namespace Microsoft.FSharp.Text.StructuredFormat // pprinter: leafFormatter // -------------------------------------------------------------------- -#if Suggestion4299 - // See bug 4299. Suppress FSI_dddd+ from fsi printer. - let fixupForInteractiveFSharpClassesWithNoToString obj (text:string) = - // Given obj:T. - // If T is a nested type inside a parent type called FSI_dddd, then it looks like an F# Interactive type. - // Further, if the .ToString() text starts with "FSI_dddd+T" then it looks like it's the default ToString. - // A better test: it is default ToString if the MethodInfo.DeclaringType is System.Object. - // In this case, replace "FSI_dddd+T" by "T". - // assert(obj <> null) - let fullName = obj.GetType().FullName // e.g. "FSI_0123+Name" - let name = obj.GetType().Name // e.g. "Name" - let T = obj.GetType() - if text.StartsWith(fullName) then - // text could be a default .ToString() since it starts with the FullName of the type. More checks... - if T.IsNested && - T.DeclaringType.Name.StartsWith("FSI_") && // Name has "FSI_" which is - T.DeclaringType.Name.Substring(4) |> Seq.forall System.Char.IsDigit // followed by digits? - then - name ^ text.Substring(fullName.Length) // replace fullName by name at start of text - else - text - else - text -#endif - let leafFormatter (opts:FormatOptions) (obj :obj) = match obj with | null -> "null" @@ -1219,10 +1194,6 @@ namespace Microsoft.FSharp.Text.StructuredFormat | :? bool as b -> (if b then "true" else "false") | :? char as c -> "\'" + formatChar true c + "\'" | _ -> try let text = obj.ToString() -//Suggestion4299. Not yet fixed. -//#if COMPILER -// let text = fixupForInteractiveFSharpClassesWithNoToString obj text -//#endif text with e -> // If a .ToString() call throws an exception, catch it and use the message as the result. diff --git a/vsintegration/src/Salsa/VsMocks.fs b/vsintegration/src/Salsa/VsMocks.fs index 90a1addead3..1226e1ee7a6 100644 --- a/vsintegration/src/Salsa/VsMocks.fs +++ b/vsintegration/src/Salsa/VsMocks.fs @@ -1222,39 +1222,6 @@ module internal VsMocks = member this.UnadviseFileChange(vscookie) = nothing() } -#if NOT_YET_NEEDED - let vsExtensibility3 = - { new IVsExtensibility3 with - member this.GetProperties(pParent, pdispPropObj, ppProperties) = err(__LINE__) - member this.RunWizardFile(bstrWizFilename, hwndOwner, vContextParams, pResult) = err(__LINE__) - member this.EnterAutomationFunction() = err(__LINE__) - member this.ExitAutomationFunction() = err(__LINE__) - member this.IsInAutomationFunction(pfInAutoFunc) = err(__LINE__) - member this.GetUserControl( fUserControl) = err(__LINE__) - member this.SetUserControl( fUserControl) = err(__LINE__) - member this.SetUserControlUnlatched( fUserControl) = err(__LINE__) - member this.LockServer( vb) = err(__LINE__) - member this.GetLockCount( pCount) = err(__LINE__) - member this.TestForShutdown( fShutdown) = err(__LINE__) - member this.GetGlobalsObject( extractFrom, ppGlobals) = err(__LINE__) - member this.GetConfigMgr( pIVsProject, itemid, ppCfgMgr) = err(__LINE__) - member this.FireMacroReset() = err(__LINE__) - member this.GetDocumentFromDocCookie( lDocCookie, ppDoc) = err(__LINE__) - member this.IsMethodDisabled( pGUID, dispid) = err(__LINE__) - member this. SetSuppressUI( In) = err(__LINE__) - member this.GetSuppressUI( pOut) = err(__LINE__) - member this.FireProjectsEvent_ItemAdded( project) = err(__LINE__) - member this.FireProjectsEvent_ItemRemoved( project) = err(__LINE__) - member this.FireProjectsEvent_ItemRenamed( project, oldName) = err(__LINE__) - member this.FireProjectItemsEvent_ItemAdded( projectItem) = err(__LINE__) - member this.FireProjectItemsEvent_ItemRemoved( projectItem) = err(__LINE__) - member this.FireProjectItemsEvent_ItemRenamed( projectItem, oldName) = err(__LINE__) - member this.IsFireCodeModelEventNeeded( vbNeeded) = err(__LINE__) - member this.RunWizardFileEx( bstrWizFilename, hwndOwner, vContextParams, vCustomParams, pResult) = err(__LINE__) - member this.FireCodeModelEvent3( dispid, pParent, pElement, changeKind) = err(__LINE__) - } -#endif - let vsSolution = { new IVsSolution with member x.GetProjectEnum(grfEnumFlags, rguidEnumOnlyThisType, ppenum) = err(__LINE__) @@ -1566,9 +1533,6 @@ module internal VsMocks = sp.AddService(typeof, box(vsTaskList()), false) sp.AddService(typeof, box vsMonitorSelection, false) sp.AddService(typeof, box vsFileChangeManager, false) -#if NOT_YET_NEEDED - sp.AddService(typeof, box vsExtensibility3, false) -#endif sp.AddService(typeof, box vsSolution, false) sp.AddService(typeof, box vsSolutionBuildManager, false) sp.AddService(typeof, box vsRunningDocumentTable, false) diff --git a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/EditorFactory.cs b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/EditorFactory.cs deleted file mode 100644 index 56bbbf1ee93..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/EditorFactory.cs +++ /dev/null @@ -1,582 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Globalization; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.TextManager.Interop; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -using System.Runtime.InteropServices; -using System.Collections; -using System.Collections.Specialized; -using System.IO; -using Microsoft.Win32; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; -using IServiceProvider = System.IServiceProvider; -using System.Diagnostics; - -// WARNING: Do not activate this code without reviewing the use of Marshal.Release(). It looks like there's a leak in the exception case. -// WARNING: Also review Marshal.GetIUnknownForObject - -#if NEVER -namespace Microsoft.VisualStudio.FSharp.LanguageService { - - /// - /// You must inherit from this class and simply add a [ComVisible] and - /// [GuidAttribute] and then specify the EditorFactoryGuid, EditorFactoryGuid - /// and EditorName variables in your Registration class. - /// This base class provides a default editor factory implementation - /// that hosts the Visual Studio Core editor. - /// - [CLSCompliant(false), ComVisible(true)] - public class EditorFactory : IVsEditorFactory { - Microsoft.VisualStudio.Shell.Package package; - IServiceProvider site; - - public static readonly Guid GuidVSBufferDetectLangSid = new Guid(0x17F375AC, 0xC814, 0x11D1, 0x88, 0xAD, 0x00, 0x00, 0xF8, 0x75, 0x79, 0xD2); - - __PROMPTONLOADFLAGS promptFlags = __PROMPTONLOADFLAGS.codepageNoPrompt; - - public class EditorInfo { - private string name; - private Guid guid; - private int priority; - private EditorInfo next; - - public string Name { - get { return name; } - set { name = value; } - } - - public Guid Guid { - get { return guid; } - set { guid = value; } - } - - public int Priority { - get { return priority; } - set { priority = value; } - } - - public EditorInfo Next { - get { return next; } - set { next = value; } - } - } - - // all registered editors. - static Hashtable editors; // extension -> EditorInfo - - // Registered exenstions for this editor under HKLM\Software\Microsoft\Visual Studio\9.0\Editors\\{" + this.GetType().GUID.ToString() + "}\\Extensions - StringDictionary editorExtensions; // string -> string - - // all known extensions under HKLM\Software\Microsoft\Visual Studio\9.0\Language Services\Extensions - static StringDictionary languageExtensions; // string -> language service guid. - - public EditorFactory(Microsoft.VisualStudio.Shell.Package package) { - this.package = package; - this.site = package; - } - - public EditorFactory() { } - - ~EditorFactory() { - site = null; -#if LANGTRACE - Trace.WriteLine("~EditorFactory"); -#endif - } - - protected IServiceProvider GetSite() { - return this.site; - } - protected Microsoft.VisualStudio.Shell.Package GetPackage() { - return this.package; - } - - /// Returns true if the given extension is one of our registered extensions - public virtual bool IsRegisteredExtension(string extension) { - return GetEditorExtensions().ContainsKey(extension); - } - - /// Return list of file extensions registered for this editor factory under - /// HKLM\Software\Microsoft\Visual Studio\9.0\Editors\\{" + this.GetType().GUID.ToString() + "}\\Extensions - /// - public virtual string[] GetExtensions() { - ArrayList list = new ArrayList(this.GetEditorExtensions().Keys); - return (string[])list.ToArray(typeof(string)); - } - - /// Returns the guid of the language service registered for this file extension - /// HKLM\Software\Microsoft\Visual Studio\9.0\Language Services\Extensions - public virtual string GetLanguageService(string fileExtension) { - return GetLanguageExtensions(this.site)[fileExtension] as string; - } - - public virtual __PROMPTONLOADFLAGS CodePagePrompt { - get { return this.promptFlags; } - set { this.promptFlags = value; } - } - - bool CheckAllFileTypes() { - return GetEditorExtensions().ContainsKey("*"); - } - - // Return your language service Guid here, this is used to set the language service on the - // IVsTextLines buffer returned from CreateEditorInstance. - public virtual Guid GetLanguageServiceGuid() { - return Guid.Empty; - } - - /// Returns the guid of the highest priority editor registered for this extension. - /// This will also pick up user defined file extension to editor associations - public virtual Guid GetRegisteredEditor(string extension) { - EditorInfo ei = GetRegisteredEditorInfo(extension); - if (ei != null) { - return ei.Guid; - } - return Guid.Empty; - } - - /// Returns the guid of the highest priority editor registered for this extension. - /// This will also pick up user defined file extension to editor associations. - /// You can then access all registered editors via the .Next property. - public virtual EditorInfo GetRegisteredEditorInfo(string extension) { - string key = extension.ToUpperInvariant(); - return (EditorInfo)GetEditors(this.site)[key]; - } - - /// Returns the guid of the editor that the user has defined for this file extension or - /// Guid.Empty if none is found - public Guid GetUserDefinedEditor(string extension) { - StringDictionary map = this.GetFileExtensionMappings(); - object v = map[extension]; - if (v != null) { - return GetGuid(v.ToString()); - } - return Guid.Empty; - } - - /// Returns true if the file extension is one that you registered for this editor - /// factory, or your have registered the "*" extension and (this file type matches your - /// GetLanguageServiceGuid() or there is no other language service registered for this file extension). - bool IsFileExtensionWeShouldEditAnyway(string ext) { - - if (!this.CheckAllFileTypes()) - return false;// you did not register "*". - - Guid langSid = GetLanguageServiceGuid(); - - string guid = this.GetLanguageService(ext); - if (!string.IsNullOrEmpty(guid)) { - // There is a language service associated with this file extension, see if it is ours or not. - if (GetGuid(guid) != langSid) { - // Then it is not our extension. - return false; - } - } - return true; - } - - static Guid GetGuid(string value) { - // we want to ignore badly registered guids. - try { - Guid guid = new Guid(value); - return guid; - } catch (FormatException) { - // ignore badly registered file extensions - return Guid.Empty; - } - } - - // This method is called when the user has not explicitly requested your editor - // and if the file extension doesn't match an explicit extension you registered, - // and if you have registered the extension "*" to determine if this file is - // really something you want to take over or not. If you return false then VS - // will find the next best editor in the list. - public virtual bool IsOurFileFormat(string moniker) { - return true; - } - - /// - /// This method checks to see if the specified file is one that your editor supports - /// and if so, creates the core text editor and associated your language service - /// with it. To figure out if the file is one that your editor supports it performs - /// the following check: - /// - /// - /// Call IsRegisteredExtension to see if the file extension is explicitly - /// registered to your editor. - /// - /// - /// Call GetUserDefinedEditor to see if the user has explicitly mapped the - /// extension to your editor. - /// - /// - /// If your editor registered the "*" extension, then it also calls - /// IsFileExtensionWeShouldEditAnyway and IsOurFileFormat to let you sniff - /// the file and see if you think it contains stuff that your editor recognizes - /// - /// - /// If all this is true then it goes ahead with the next step which is to - /// get an IVsTextLines buffer and set it up as follows: - /// - /// - /// If existingDocData is non-null then it checks to see if it can get an - /// IVsTextLines buffer from this docData, and if not, returns VS_E_INCOMPATIBLEDOCDATA. - /// Otherwise it creates a new VsTextBufferClass. - /// - /// Calls IVsUserData.SetData on the IVsTextLines buffer with any code page prompt - /// flags you have provided via the CodePagePrompt property. - /// - /// - /// Calls SetLanguageServiceID to pass in your language service Guid and - /// sets the GuidVSBufferDetectLangSid IVsUserData to false to stop the core - /// text editor from looking up a different language service. - /// - /// Lastly it calls CreateEditorView to create the docView. - /// - public virtual int CreateEditorInstance(uint createDocFlags, string moniker, string physicalView, IVsHierarchy pHier, uint itemid, IntPtr existingDocData, out IntPtr docView, out IntPtr docData, out string editorCaption, out Guid cmdUI, out int cancelled) { - docView = IntPtr.Zero; - docData = IntPtr.Zero; - editorCaption = null; - cmdUI = Guid.Empty; - cancelled = 0; - int hr = NativeMethods.S_OK; - - if (this.promptFlags == __PROMPTONLOADFLAGS.codepagePrompt && existingDocData != IntPtr.Zero) { - //since we are trying to open with encoding just return - hr = (int)NativeMethods.VS_E_INCOMPATIBLEDOCDATA; - goto cleanup; - } - - bool takeover = false; - if (!string.IsNullOrEmpty(moniker)) { - string ext = FilePathUtilities.GetFileExtension(moniker); - docData = IntPtr.Zero; - docView = IntPtr.Zero; - editorCaption = null; - - bool openSpecific = (createDocFlags & (uint)__VSCREATEEDITORFLAGS2.CEF_OPENSPECIFIC) != 0; - - bool isOurs = IsRegisteredExtension(ext); - bool isUserDefined = (GetUserDefinedEditor(ext) == this.GetType().GUID); - - // If this file extension belongs to a different language service, then we should not open it, - // unless the user specifically requested our editor in the Open With... dialog. - if (!isOurs && !isUserDefined && !this.IsFileExtensionWeShouldEditAnyway(ext) && !openSpecific) { - return (int)NativeMethods.VS_E_UNSUPPORTEDFORMAT; - } - - takeover = (CheckAllFileTypes() && !isOurs); - if (takeover && !isOurs && !isUserDefined && !openSpecific) { - if (!IsOurFileFormat(moniker)) { - return (int)NativeMethods.VS_E_UNSUPPORTEDFORMAT; - } - } - } - - IVsTextLines buffer = null; - if (existingDocData != IntPtr.Zero) { - object dataObject = Marshal.GetObjectForIUnknown(existingDocData); - buffer = dataObject as IVsTextLines; - if (buffer == null) { - IVsTextBufferProvider bp = dataObject as IVsTextBufferProvider; - if (bp != null) { - NativeMethods.ThrowOnFailure(bp.GetTextBuffer(out buffer)); - } - } - if (buffer == null) { - // unknown docData type then, so we have to force VS to close the other editor. - hr = (int)NativeMethods.VS_E_INCOMPATIBLEDOCDATA; - goto cleanup; - } - - } else { - // Create a new IVsTextLines buffer. - Type textLinesType = typeof(IVsTextLines); - Guid riid = textLinesType.GUID; - Guid clsid = typeof(VsTextBufferClass).GUID; - buffer = (IVsTextLines)package.CreateInstance(ref clsid, ref riid, textLinesType); - if (!string.IsNullOrEmpty(moniker)) { - IVsUserData iud = buffer as IVsUserData; - if (iud != null) { - Guid GUID_VsBufferMoniker = typeof(IVsUserData).GUID; - // Must be set in time for language service GetColorizer call in case the colorizer - // is file name dependent. - NativeMethods.ThrowOnFailure(iud.SetData(ref GUID_VsBufferMoniker, moniker)); - } - } - IObjectWithSite ows = buffer as IObjectWithSite; - if (ows != null) { - ows.SetSite(this.site.GetService(typeof(IOleServiceProvider))); - } - } - - if (this.promptFlags == __PROMPTONLOADFLAGS.codepagePrompt && buffer is IVsUserData) { - IVsUserData iud = (IVsUserData)buffer; - Guid GUID_VsBufferEncodingPromptOnLoad = new Guid(0x99ec03f0, 0xc843, 0x4c09, 0xbe, 0x74, 0xcd, 0xca, 0x51, 0x58, 0xd3, 0x6c); - NativeMethods.ThrowOnFailure(iud.SetData(ref GUID_VsBufferEncodingPromptOnLoad, (uint)this.CodePagePrompt)); - } - - Guid langSid = GetLanguageServiceGuid(); - if (langSid != Guid.Empty) { - Guid vsCoreSid = new Guid("{8239bec4-ee87-11d0-8c98-00c04fc2ab22}"); - Guid currentSid; - NativeMethods.ThrowOnFailure(buffer.GetLanguageServiceID(out currentSid)); - if (currentSid == langSid) { - // We may have recently closed the editor on this buffer and for some - // reason VS loses our colorizer, so we need to reset it. - NativeMethods.ThrowOnFailure(buffer.SetLanguageServiceID(ref vsCoreSid)); - } else if (currentSid != vsCoreSid) { - // Some other language service has it, so return VS_E_INCOMPATIBLEDOCDATA - hr = (int)NativeMethods.VS_E_INCOMPATIBLEDOCDATA; - goto cleanup; - } - NativeMethods.ThrowOnFailure(buffer.SetLanguageServiceID(ref langSid)); - takeover = true; - } - - if (takeover) { - IVsUserData vud = (IVsUserData)buffer; - Guid bufferDetectLang = GuidVSBufferDetectLangSid; - NativeMethods.ThrowOnFailure(vud.SetData(ref bufferDetectLang, false)); - } - - if (existingDocData != IntPtr.Zero) { - docData = existingDocData; - Marshal.AddRef(docData); - } else { - docData = Marshal.GetIUnknownForObject(buffer); - } - docView = CreateEditorView(moniker, buffer, physicalView, out editorCaption, out cmdUI); - - if (docView == IntPtr.Zero) { - // We couldn't create the view, so return this special error code so - // VS can try another editor factory. - hr = (int)NativeMethods.VS_E_UNSUPPORTEDFORMAT; - } - - cleanup: - if (docView == IntPtr.Zero) { - if (existingDocData != docData && docData != IntPtr.Zero) { - Marshal.Release(docData); - docData = IntPtr.Zero; - } - } - return hr; - } - - /// Return docView IUnknown COM object. - public virtual IntPtr CreateEditorView(string moniker, IVsTextLines buffer, string physicalView, out string editorCaption, out Guid cmdUI) { - Type tcw = typeof(IVsCodeWindow); - Guid riid = tcw.GUID; - Guid clsid = typeof(VsCodeWindowClass).GUID; - IntPtr docView = IntPtr.Zero; - IVsCodeWindow window = (IVsCodeWindow)package.CreateInstance(ref clsid, ref riid, tcw); - - NativeMethods.ThrowOnFailure(window.SetBuffer(buffer)); - NativeMethods.ThrowOnFailure(window.SetBaseEditorCaption(null)); - NativeMethods.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption)); - - Guid CMDUIGUID_TextEditor = new Guid(0x8B382828, 0x6202, 0x11d1, 0x88, 0x70, 0x00, 0x00, 0xF8, 0x75, 0x79, 0xD2); - cmdUI = CMDUIGUID_TextEditor; - docView = Marshal.GetIUnknownForObject(window); - - return docView; - } - - /// The default implementation supports LOGVIEWID_Code, LOGVIEWID_TextView, - /// LOGVIEWID_Debugging, and LOGVIEWID_Primary returning null for - /// the physicalView string. - public virtual int MapLogicalView(ref Guid logicalView, out string physicalView) { - physicalView = null; - // The default suppo - if (logicalView == NativeMethods.LOGVIEWID_Code || - logicalView == NativeMethods.LOGVIEWID_TextView || - logicalView == NativeMethods.LOGVIEWID_Debugging || - logicalView == NativeMethods.LOGVIEWID_Primary) { - physicalView = null; - return NativeMethods.S_OK; - } - return NativeMethods.E_NOTIMPL; - } - - public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp) { - this.site = new ServiceProvider(psp); - return NativeMethods.S_OK; - } - - StringDictionary GetEditorExtensions() { - if (this.editorExtensions != null) - return this.editorExtensions; - - Guid ourGuid = this.GetType().GUID; - StringDictionary map = new StringDictionary(); - Hashtable editors = GetEditors(this.site); - foreach (string ext in editors.Keys) { - EditorInfo ei = (EditorInfo)editors[ext]; - while (ei != null) { - if (ei.Guid == ourGuid) { - map[ext] = ext; - break; - } - ei = ei.Next; - } - } - return this.editorExtensions = map; - } - - static StringDictionary GetLanguageExtensions(IServiceProvider site) { - if (EditorFactory.languageExtensions != null) - return EditorFactory.languageExtensions; - - StringDictionary extensions = new StringDictionary(); - ILocalRegistry3 localRegistry = site.GetService(typeof(SLocalRegistry)) as ILocalRegistry3; - string root = null; - if (localRegistry != null) { - NativeMethods.ThrowOnFailure(localRegistry.GetLocalRegistryRoot(out root)); - } - using (RegistryKey rootKey = Registry.LocalMachine.OpenSubKey(root)) { - if (rootKey != null) { - - string relpath = "Languages\\File Extensions"; - using (RegistryKey key = rootKey.OpenSubKey(relpath, false)) { - if (key != null) { - foreach (string ext in key.GetSubKeyNames()) { - using (RegistryKey extkey = key.OpenSubKey(ext, false)) { - if (extkey != null) { - string fe = ext; - string guid = extkey.GetValue(null) as string; // get default value - if (!extensions.ContainsKey(fe)) { - extensions.Add(fe, guid); - } - } - } - } - } - } - } - } - return EditorFactory.languageExtensions = extensions; - } - - static Hashtable GetEditors(IServiceProvider site) { - if (EditorFactory.editors != null) - return EditorFactory.editors; - - Hashtable editors = new Hashtable(); - ILocalRegistry3 localRegistry = site.GetService(typeof(SLocalRegistry)) as ILocalRegistry3; - string root = null; - if (localRegistry == null) { - return editors; - } - NativeMethods.ThrowOnFailure(localRegistry.GetLocalRegistryRoot(out root)); - using (RegistryKey rootKey = Registry.LocalMachine.OpenSubKey(root)) { - if (rootKey != null) { - RegistryKey editorsKey = rootKey.OpenSubKey("Editors", false); - if (editorsKey != null) { - using (editorsKey) { - foreach (string editorGuid in editorsKey.GetSubKeyNames()) { - Guid guid = GetGuid(editorGuid); - using (RegistryKey editorKey = editorsKey.OpenSubKey(editorGuid, false)) { - object value = editorKey.GetValue(null); - string name = (value != null) ? value.ToString() : editorGuid.ToString(); - RegistryKey extensions = editorKey.OpenSubKey("Extensions", false); - if (extensions != null) { - foreach (string s in extensions.GetValueNames()) { - if (!string.IsNullOrEmpty(s)) { - EditorInfo ei = new EditorInfo(); - ei.Name = name; - ei.Guid = guid; - object obj = extensions.GetValue(s); - if (obj is int) { - ei.Priority = (int)obj; - } - string ext = (s == "*") ? s : "." + s; - AddEditorInfo(editors, ext, ei); - } - } - } - } - } - } - } - } - } - return EditorFactory.editors = editors; - } - - static void AddEditorInfo(Hashtable editors, string ext, EditorInfo ei) { - ext = ext.ToUpperInvariant(); - EditorInfo other = (EditorInfo)editors[ext]; - if (other != null) { - EditorInfo previous = null; - while (other != null && other.Priority > ei.Priority) { - previous = other; - other = other.Next; - } - if (previous == null) { - editors[ext] = ei; - ei.Next = other; - } else { - ei.Next = previous.Next; - previous.Next = ei; - } - } else { - editors[ext] = ei; - } - } - - StringDictionary GetFileExtensionMappings() { - ILocalRegistry3 localRegistry = site.GetService(typeof(SLocalRegistry)) as ILocalRegistry3; - string root = null; - if (localRegistry != null) { - NativeMethods.ThrowOnFailure(localRegistry.GetLocalRegistryRoot(out root)); - } - StringDictionary map = new StringDictionary(); - RegistryKey key = Registry.CurrentUser.OpenSubKey(root + "\\Default Editors", false); - if (key != null) { - using (key) { - foreach (string name in key.GetSubKeyNames()) { - using (RegistryKey extkey = key.OpenSubKey(name, false)) { - if (extkey != null) { - object obj = extkey.GetValue("Custom"); - if (obj is string) { - string ext = "." + name; - map[ext] = obj.ToString(); // extension -> editor. - } - } - } - } - } - } - - // Also pick up the "default editors" information - key = Registry.CurrentUser.OpenSubKey(root + "\\Default Editors", false); - if (key != null) { - using (key) { - foreach (string name in key.GetSubKeyNames()) { - using (RegistryKey extkey = key.OpenSubKey(name, false)) { - if (extkey != null) { - object obj = extkey.GetValue("Custom"); - if (obj is string) { - string ext = "." + name; - map[ext] = obj.ToString(); // extension -> editor. - } - } - } - } - } - } - return map; - } - - public virtual int Close() { - this.site = null; - this.package = null; - return NativeMethods.S_OK; - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/EditorView.cs b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/EditorView.cs index 0078dace288..e837b57f14b 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/EditorView.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/EditorView.cs @@ -247,170 +247,6 @@ public virtual int FReserved1(uint reserved, uint message, IntPtr wParam, IntPtr } } -#if CUT - - /// - /// This class View provides an abstract base class for custom editor views that - /// support Ole Inplace activation (ActiveX controls). - /// - [CLSCompliant(false)] - [System.Runtime.InteropServices.ComVisible(true)] - public abstract class OleEditorView : SimpleEditorView, IOleCommandTarget, IVsWindowPane, IVsToolboxUser, IVsStatusbarUser, IOleObject, IOleInPlaceActiveObject, IOleInPlaceObject, IOleInPlaceComponent - //IServiceProvider, - //IOleDocumentView, - //IOleDocument, - //IOleInPlaceUIWindow, - //IVsMultiViewDocumentView, - //IVsFindTarget, - //IVsWindowFrameNotify, - //IVsCodeWindow, - //IVsWindowPaneCommit, - //IVsBroadcastMessageEvents, - //IVsDocOutlineProvider, - //IVsDebuggerEvents, - // ??? VxDTE::IExtensibleObject, - //IVsBackForwardNavigation - // ??? public IVsTextLinesEvents, - // ??? public ISelectionContainer, - // ??? public IVsTextBufferDataEvents, - { - internal EventSinkCollection eventSinks = new EventSinkCollection(); - protected IOleComponentUIManager pCompUIMgr; - protected IOleInPlaceComponentSite pIPCompSite; - protected IOleClientSite pClientSite; - protected Hashtable monikers = new Hashtable(); - protected OleEditorView(IVsTextLines buffer) : base(buffer) { - } - - public virtual void Advise(IAdviseSink sink, out uint cookie) { - cookie = eventSinks.Add(sink); - } - public virtual void Close(uint dwSaveOption) { - } - public virtual int DoVerb(int iVerb, MSG[] msg, IOleClientSite site, int index, IntPtr hwndParent, RECT[] posRect) { - return NativeMethods.S_OK; - } - public virtual void EnumAdvise(out IEnumSTATDATA ppEnumAdvise) { - ppEnumAdvise = null; - } - public virtual int EnumVerbs(out IEnumOLEVERB ppEnumVerbs) { - ppEnumVerbs = null; - return NativeMethods.S_OK; - } - public virtual void GetClientSite(out IOleClientSite site) { - site = this.pClientSite; - } - public virtual void GetClipboardData(uint reserved, out Microsoft.VisualStudio.OLE.Interop.IDataObject obj) { - obj = null; - } - public virtual void GetExtent(uint dwDrawAspect, SIZEL[] size) { - } - public virtual int GetMiscStatus(uint dwAspect, out uint status) { - status = 0; - return NativeMethods.S_OK; - } - public virtual void GetMoniker(uint iAssign, uint whichMoniker, out IMoniker moniker) { - object key = (object)whichMoniker; - - moniker = (IMoniker)monikers[key]; - } - public virtual void GetUserClassID(out Guid pClsid) { - pClsid = this.GetType().GUID; - } - public virtual int GetUserType(uint formOfType, IntPtr userType) { - return NativeMethods.S_OK; - } - public virtual int InitFromData(Microsoft.VisualStudio.OLE.Interop.IDataObject data, int fCreation, uint reserved) { - return NativeMethods.S_OK; - } - public virtual int IsUpToDate() { - return NativeMethods.S_OK; - } - public virtual void SetClientSite(IOleClientSite site) { - this.pClientSite = site; - } - public virtual void SetColorScheme(LOGPALETTE[] logicalPalette) { - } - public virtual void SetExtent(uint drawAspect, SIZEL[] size) { - } - public virtual void SetHostNames(string containerApp, string containerObj) { - } - public virtual void SetMoniker(uint whichMoniker, IMoniker moniker) { - object key = (object)whichMoniker; - - if (monikers.Contains(key)) monikers.Remove(key); - - monikers.Add(key, moniker); - } - public virtual void Unadvise(uint dwCookie) { - eventSinks.RemoveAt(dwCookie); - } - public virtual int Update() { - return NativeMethods.S_OK; - } - - - public virtual void EnableModeless(int fEnable) { - } - public virtual void OnDocWindowActivate(int fActivate) { - } - public virtual void OnFrameWindowActivate(int fActivate) { - } - public virtual void ResizeBorder(RECT[] border, ref Guid iid, IOleInPlaceUIWindow window, int fFrameWindow) { - } - - - - public virtual void ContextSensitiveHelp(int fEnterHelp) { - } - public virtual void GetWindow(out IntPtr hwnd) { - hwnd = IntPtr.Zero; - } - public virtual void InPlaceDeactivate() { - } - public virtual void ReactivateAndUndo() { - } - public virtual void SetObjectRects(RECT[] posRect, RECT[] clipRect) { - } - public virtual void UIDeactivate() { - } - - public virtual int FQueryClose(int fPromptUser) { - return 0; - } - public virtual int GetCntrContextMenu(uint dwRoleActiveObject, ref Guid clsidActiveObject, int nMenuIdActiveObject, POINTS[] pos, out Guid clsidCntr, OLEMENUID[] menuid, out uint pgrf) { - clsidCntr = Guid.Empty; - pgrf = 0; - return NativeMethods.S_OK; - } - public virtual int GetCntrHelp(ref uint pdwRole, ref Guid pclsid, POINT posMouse, uint dwHelpCmd, string pszHelpFileIn, out string pwsHelpFileOut, uint dwDataIn, out uint dwDataOut) { - pwsHelpFileOut = pszHelpFileIn; - dwDataOut = dwDataIn; - return NativeMethods.S_OK; - } - public virtual int GetCntrMessage(ref uint pdwRolw, ref Guid clsid, string titleIn, string textIn, string helpFileIn, out string titleOut, out string textOut, out string helpFileOut, ref uint dwHelpContextId, OLEMSGBUTTON[] msgbutton, OLEMSGDEFBUTTON[] msgdefbutton, OLEMSGICON[] msgicon, ref int sysAlert) { - titleOut = titleIn; - textOut = textIn; - helpFileOut = helpFileIn; - return NativeMethods.S_OK; - } - void IOleInPlaceComponent.OnEnterState(uint dwStateId, int fEnter) { - ((IOleComponent)this).OnEnterState(dwStateId, fEnter); - } - public virtual int OnWindowActivate(uint windowType, int fActivate) { - return NativeMethods.S_OK; - } - public virtual int TranslateCntrAccelerator(MSG[] msg) { - return NativeMethods.S_OK; - } - public virtual int UseComponentUIManager(uint dwCompRole, out uint pgrfCompFlags, IOleComponentUIManager pCompUIMgr, IOleInPlaceComponentSite pIPCompSite) { - pgrfCompFlags = 0; - this.pCompUIMgr = pCompUIMgr; - this.pIPCompSite = pIPCompSite; - return NativeMethods.S_OK; - } - } -#endif /// /// This class wraps a managed WinForm control and uses that as the editor window. /// diff --git a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/FSharp.LanguageService.Base.csproj b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/FSharp.LanguageService.Base.csproj index 043c8859012..5efb2bd274e 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/FSharp.LanguageService.Base.csproj +++ b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/FSharp.LanguageService.Base.csproj @@ -88,7 +88,6 @@ - diff --git a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/LanguageService.cs b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/LanguageService.cs index 75ea1ec76af..21e05ad9594 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/LanguageService.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/LanguageService.cs @@ -58,7 +58,7 @@ public abstract class LanguageService : IDisposable, IVsLanguageInfo, IVsLanguag IObjectWithSite, IVsDebuggerEvents, IVsFormatFilterProvider, ILanguageServiceTestHelper - { //, IVsOutliningCapableLanguage { + { private IServiceProvider site; private ArrayList codeWindowManagers; @@ -1024,14 +1024,6 @@ public void SetSite(object site) this.lcid = pkg.GetProviderLocale(); } -#if IVsOutliningCapableLanguage - public virtual void CollapseToDefinitions(IVsTextLines buffer, IVsOutliningSession session) { - Source source = this.GetSource(buffer); - source.CollapseAllHiddenRegions(session); - } -#endif - - public virtual int OnModeChange(DBGMODE dbgmodeNew) { this.dbgMode = dbgmodeNew; diff --git a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/UnsafeNativeMethods.cs b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/UnsafeNativeMethods.cs index 6eeeb38c3d5..e82f2a84e22 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/UnsafeNativeMethods.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/FSharp.LanguageService.Base/UnsafeNativeMethods.cs @@ -216,14 +216,6 @@ internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, [DllImport("shell32.dll", EntryPoint = "DragQueryFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern uint DragQueryFile(IntPtr hDrop, uint iFile, char[] lpszFile, uint cch); - ///////////// UNUSED - -#if false - [DllImport(ExternDll.Oleaut32, PreserveSig=false)] - public static extern UCOMITypeLib LoadRegTypeLib(ref Guid clsid, int majorVersion, int minorVersion, int lcid); - - #endif - } } diff --git a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/servicem.fs b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/servicem.fs index 02c45aa5ecf..f88334f7bbb 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/servicem.fs +++ b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/servicem.fs @@ -1933,65 +1933,6 @@ module FSharpIntellisenseProvider = member x.Name = filename -#if UNUSED -module Setup = - /// This attribute adds a intellisense provider for a specific language - /// type. - /// For Example: - /// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0Exp\Languages\IntellisenseProviders\ - /// [Custom_Provider] - /// - [] - type ProvideIntellisenseProviderAttribute(provider:Type, providerName:string, addItemLanguageName:string, defaultExtension:string, shortLanguageName:string, templateFolderName:string) = - inherit RegistrationAttribute() - let mutable additionalExtensions : Option = None - - /// Private function to get the provider base key name - let providerRegKey() = String.Format(CultureInfo.InvariantCulture, @"Languages\IntellisenseProviders\{0}", [| box providerName |]) - - /// Gets the Type of the intellisense provider. - member x.Provider = provider - /// Get the Guid representing the generator type - member x.ProviderGuid = provider.GUID - /// Get the ProviderName - member x.ProviderName = providerName - /// Get item language - member x.AddItemLanguageName = addItemLanguageName - /// Get the Default extension - member x.DefaultExtension = defaultExtension - /// Get the short language name - member x.ShortLanguageName = shortLanguageName - /// Get the tempalte folder name - member x.TemplateFolderName = templateFolderName - /// Get/Set Additional extensions - member x.AdditionalExtensions - with get() = additionalExtensions - and set v = additionalExtensions <- Some(v) - /// Called to register this attribute with the given context. The context - /// contains the location where the registration inforomation should be placed. - /// It also contains other information such as the type being registered and path information. - override x.Register(context:RegistrationAttribute.RegistrationContext) = - Check.ArgumentNotNull context "context" - use childKey = context.CreateKey(providerRegKey()) - let mutable providerGuid = provider.GUID - childKey.SetValue("GUID", providerGuid.ToString("B")) - childKey.SetValue("AddItemLanguageName", addItemLanguageName) - childKey.SetValue("DefaultExtension", defaultExtension) - childKey.SetValue("ShortLanguageName", shortLanguageName) - childKey.SetValue("TemplateFolderName", templateFolderName) - match additionalExtensions with - | None | Some "" -> () - | Some(s) -> childKey.SetValue("AdditionalExtensions", s) - - /// - /// Unregister this file extension. - /// - /// - override x.Unregister(context:RegistrationAttribute.RegistrationContext) = - if (null <> context) then - context.RemoveKey(providerRegKey()) -#endif - // Workaround to access non-public settings persistence type. // GetService( ) with this will work as long as the GUID matches the real type. [] diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OANestedProjectItem.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OANestedProjectItem.cs deleted file mode 100644 index d28dbfa359c..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OANestedProjectItem.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if UNUSED_NESTED_PROJECTS -using System; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.Shell; -using System.Runtime.InteropServices; -using System.Collections.Generic; -using System.Collections; -using System.Diagnostics; -using System.Runtime.Serialization; -using System.Reflection; -using IServiceProvider = System.IServiceProvider; -using Microsoft.VisualStudio.OLE.Interop; -using System.Diagnostics.CodeAnalysis; -using Microsoft.VisualStudio.Fsharp.ProjectSystem; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem.Automation -{ - [SuppressMessage("Microsoft.Interoperability", "CA1405:ComVisibleTypeBaseTypesShouldBeComVisible")] - [ComVisible(true), CLSCompliant(false)] - public class OANestedProjectItem : OAProjectItem - { - EnvDTE.Project nestedProject = null; - - internal OANestedProjectItem(OAProject project, NestedProjectNode node) - : base(project, node) - { - object nestedproject = null; - if (ErrorHandler.Succeeded(node.NestedHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out nestedproject))) - { - this.nestedProject = nestedproject as EnvDTE.Project; - } - } - - /// - /// 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; - } - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OAProject.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OAProject.cs index 0d87c4e906a..fcdc5b87a1c 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OAProject.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OAProject.cs @@ -23,9 +23,6 @@ namespace Microsoft.VisualStudio.FSharp.ProjectSystem.Automation public class OAProject : EnvDTE.Project, EnvDTE.ISupportVSProperties { private ProjectNode project; -#if UNUSED_NESTED_PROJECTS - Automation.OASolutionFolder solutionFolder; -#endif EnvDTE.ConfigurationManager configurationManager; public ProjectNode Project @@ -36,13 +33,6 @@ public ProjectNode Project internal OAProject(ProjectNode project) { this.project = project; - -#if UNUSED_NESTED_PROJECTS - if (project is ProjectContainerNode) - { - this.solutionFolder = new Automation.OASolutionFolder((ProjectContainerNode)project); - } -#endif } public virtual string Name diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OAProjectItems.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OAProjectItems.cs index 4628c455bd5..ee1b98ecd6d 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OAProjectItems.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OAProjectItems.cs @@ -255,12 +255,6 @@ public virtual EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string p { item = new OAFileItem(this.Project, nodeAdded as FileNode); } -#if UNUSED_NESTED_PROJECTS - else if (nodeAdded is NestedProjectNode) - { - item = new OANestedProjectItem(this.Project, nodeAdded as NestedProjectNode); - } -#endif else { item = new OAProjectItem(this.Project, nodeAdded); diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OASolutionFolder.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OASolutionFolder.cs deleted file mode 100644 index de21bd0a178..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/OASolutionFolder.cs +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if UNUSED_NESTED_PROJECTS - -using System; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.Shell; -using System.Runtime.InteropServices; -using System.Collections.Generic; -using System.Collections; -using System.Diagnostics; -using System.Runtime.Serialization; -using System.Reflection; -using IServiceProvider = System.IServiceProvider; -using Microsoft.VisualStudio.OLE.Interop; -using System.Globalization; -using Microsoft.VisualStudio.FSharp.ProjectSystem; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem.Automation -{ - [ComVisible(true), CLSCompliant(false)] - public class OASolutionFolder : EnvDTE80.SolutionFolder - where T : HierarchyNode - { - bool hidden = false; - T node; - - internal 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; - } - - - 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)); - } - } - } - -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/VSProject/OAVSProjectItem.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/VSProject/OAVSProjectItem.cs index 34b8a6b0713..d6b1902fae5 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/VSProject/OAVSProjectItem.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Automation/VSProject/OAVSProjectItem.cs @@ -49,9 +49,6 @@ public virtual DTE DTE public virtual void RunCustomTool() { -#if SINGLE_FILE_GENERATOR - this.FileNode.RunGenerator(); -#endif } public FileNode FileNode diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/DependentFileNode.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/DependentFileNode.cs deleted file mode 100644 index eabea37e854..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/DependentFileNode.cs +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if UNUSED_DEPENDENT_FILES -using System; -using System.Runtime.InteropServices; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Windows.Forms; -using System.Diagnostics; -using System.Globalization; -using System.Text; -using System.Threading; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.TextManager.Interop; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; -using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID; -using VsCommands2K = Microsoft.VisualStudio.VSConstants.VSStd2KCmdID; -using MSBuild = Microsoft.Build.BuildEngine; -using System.Diagnostics.CodeAnalysis; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - /// - /// Defines the logic for all dependent file nodes (solution explorer icon, commands etc.) - /// - [CLSCompliant(false)] - [ComVisible(true)] - public class DependentFileNode : FileNode - { - /// - /// 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) - /// - public override int ImageIndex - { - get { return (this.CanShowDefaultIcon() ? (int)ProjectNode.ImageName.DependentFile : (int) ProjectNode.ImageName.MissingFile); } - } - - /// - /// Constructor for the DependentFileNode - /// - /// Root of the hierarchy - /// Associated project element - internal DependentFileNode(ProjectNode root, ProjectElement element) - : base(root, element) - { - this.HasParentNodeNameRelation = false; - } - - - /// - /// Disable rename - /// - /// new label - /// 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 - /// - public 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 - public override StringBuilder PrepareSelectedNodesForClipBoard() - { - return null; - } - - public 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")] - public override void UpdateSccStateIcons() - { - if (!this.ExcludeNodeFromScc) - { - this.Parent.ReDraw(UIHierarchyElement.SccState); - } - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/FileNode.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/FileNode.cs index 7c7f72589b6..5a326688a94 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/FileNode.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/FileNode.cs @@ -212,13 +212,7 @@ internal FileNode(ProjectNode root, ProjectElement element, uint? hierarchyId = public override NodeProperties CreatePropertiesObject() { -#if SINGLE_FILE_GENERATOR - ISingleFileGenerator generator = this.CreateSingleFileGenerator(); - - return generator == null ? new FileNodeProperties(this) : new SingleFileGeneratorNodeProperties(this); -#else return new FileNodeProperties(this); -#endif } public override object GetIconHandle(bool open) @@ -418,12 +412,7 @@ public int SetEditLabel(string label, string relativePath) string oldrelPath = this.ItemNode.GetMetadata(ProjectFileConstants.Include); RenameDocument(oldName, newName); -#if UNUSED_DEPENDENT_FILES - if (this is DependentFileNode) - { - OnInvalidateItems(this.Parent); - } -#endif + // 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) @@ -491,29 +480,6 @@ public override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, } } - // Exec on special filenode commands - if (cmdGroup == VsMenus.guidStandardCommandSet2K) - { -#if SINGLE_FILE_GENERATOR - 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; - } - } - } -#endif - } - return base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut); } @@ -545,16 +511,6 @@ internal override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; return VSConstants.S_OK; } -#if SINGLE_FILE_GENERATOR - if ((VsCommands2K)cmd == VsCommands2K.RUNCUSTOMTOOL) - { - if (string.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.DependentUpon)) && (this.NodeProperties is SingleFileGeneratorNodeProperties)) - { - result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED; - return VSConstants.S_OK; - } - } -#endif } else { @@ -930,17 +886,6 @@ public virtual void RenameInStorage(string oldName, string newName) File.Move(oldName, newName); } -#if SINGLE_FILE_GENERATOR - /// - /// factory method for creating single file generators. - /// - /// - public virtual ISingleFileGenerator CreateSingleFileGenerator() - { - return new SingleFileGenerator(this.ProjectMgr); - } -#endif - /// /// This method should be overridden to provide the list of special files and associated flags for source control. /// @@ -1103,42 +1048,6 @@ private void RenameCaseOnlyChange(string newFileName) uiWindow.ExpandItem(this.ProjectMgr.InteropSafeIVsUIHierarchy, this.ID, EXPANDFLAGS.EXPF_SelectItem); } -#if SINGLE_FILE_GENERATOR - /// - /// 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(); - } -#endif - -#if SINGLE_FILE_GENERATOR - /// - /// Runs a generator. - /// - public void RunGenerator() - { - ISingleFileGenerator generator = this.CreateSingleFileGenerator(); - if (generator != null) - { - generator.RunGenerator(this.Url); - } - } -#endif - /// /// Update the ChildNodes after the parent node has been renamed /// diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/FolderNode.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/FolderNode.cs index 06282742c8f..dd803192cf4 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/FolderNode.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/FolderNode.cs @@ -211,17 +211,6 @@ public override void GetSccSpecialFiles(string sccFile, IList files, ILi { 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; - -#if UNUSED_DEPENDENT_FILES - // Dependents do not participate directly in scc. - if (node != null && !(node is DependentFileNode)) - { - node.GetSccSpecialFiles(sccFile, files, flags); - } -#endif } /// diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/GlobalSuppressions.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/GlobalSuppressions.cs index 650cd150977..5dd47c30cbb 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/GlobalSuppressions.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/GlobalSuppressions.cs @@ -34,23 +34,11 @@ [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.HierarchyNode.#Remove(System.Boolean)")] [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.HierarchyNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ImageHandler.#GetIconHandle(System.Int32)")] -#if UNUSED_NESTED_PROJECTS -[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#Init(System.String,System.String,System.String,Microsoft.VisualStudio.Shell.Interop.__VSCREATEPROJFLAGS)")] -[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#IsItemDirty(System.UInt32,System.IntPtr,System.Int32&)")] -[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#LockRDTEntry()")] -[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#RenameNestedProjectInParentProject(System.String)")] -[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)")] -#endif [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.OleServiceProvider.#QueryService(System.Guid&,System.Guid&,System.IntPtr&)")] [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectConfig.#.ctor(Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectNode,System.String)")] [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectConfig.#DebugLaunch(System.UInt32)")] [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectConfig.#Microsoft.VisualStudio.Shell.Interop.IVsProjectFlavorCfg.get_CfgType(System.Guid&,System.IntPtr&)")] [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectConfig.#SetConfigurationProperty(System.String,System.String)")] -#if UNUSED_NESTED_PROJECTS -[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectContainerNode.#CloseChildren()")] -[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectContainerNode.#GetNestedHierarchy(System.UInt32,System.Guid&,System.IntPtr&,System.UInt32&)")] -[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectContainerNode.#OpenChildren()")] -#endif [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectElement.#ItemName")] [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectElement.#SetMetadata(System.String,System.String)")] [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectFactory.#CreateProject(System.String,System.String,System.String,System.UInt32,System.Guid&,System.IntPtr&,System.Int32&)")] @@ -139,27 +127,9 @@ [assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.IDEBuildLogger.#ShutdownLogger()", MessageId = "")] [assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.IDEBuildLogger.#get_WarningString()", MessageId = "")] [assembly: SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ImageHandler.#.ctor(System.Windows.Forms.ImageList)", MessageId = "")] -#if UNUSED_NESTED_PROJECTS -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#DelegateGetPropertyToNested(System.Int32)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsHierarchy.GetProperty(System.UInt32,System.Int32,System.Object@)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#GetIconHandle(System.Boolean)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsHierarchy.GetProperty(System.UInt32,System.Int32,System.Object@)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#Init(System.String,System.String,System.String,Microsoft.VisualStudio.Shell.Interop.__VSCREATEPROJFLAGS)", MessageId = "")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#InitializeInstanceGuid()", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsHierarchy.GetGuidProperty(System.UInt32,System.Int32,System.Guid@)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#InitializeInstanceGuid()", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsHierarchy.SetGuidProperty(System.UInt32,System.Int32,System.Guid@)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#InitImageHandler()", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsHierarchy.GetProperty(System.UInt32,System.Int32,System.Object@)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#OnChanged(System.Int32)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsProject3.GetMkDocument(System.UInt32,System.String@)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#SaveItem(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.String,System.UInt32,System.IntPtr,System.Int32&)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsUIShell.SaveDocDataToFile(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS,System.Object,System.String,System.String@,System.Int32@)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode.#SetDocCookieOnNestedHier(System.UInt32)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsHierarchy.SetProperty(System.UInt32,System.Int32,System.Object)")] -#endif [assembly: SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Scope = "type", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.OleServiceProvider+ServiceCreatorCallback", MessageId = "")] [assembly: SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.OleServiceProvider+ServiceData.#.ctor(System.Type,System.Object,Microsoft.VisualStudio.FSharp.ProjectSystem.OleServiceProvider+ServiceCreatorCallback,System.Boolean)", MessageId = "")] [assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectConfig.#IsFlavorDirty(Microsoft.VisualStudio.Shell.Interop._PersistStorageType)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IPersistXMLFragment.IsFragmentDirty(System.UInt32,System.Int32@)")] -#if UNUSED_NESTED_PROJECTS -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectContainerNode.#ReloadNestedProjectNode(Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsFireSolutionEvents.FireOnAfterLoadProject(Microsoft.VisualStudio.Shell.Interop.IVsHierarchy)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectContainerNode.#ReloadNestedProjectNode(Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsSolution.CloseSolutionElement(System.UInt32,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy,System.UInt32)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectContainerNode.#ReloadNestedProjectNode(Microsoft.VisualStudio.FSharp.ProjectSystem.NestedProjectNode)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsSolution.GetProjectOfUniqueName(System.String,Microsoft.VisualStudio.Shell.Interop.IVsHierarchy@)")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectContainerNode.#RunVsTemplateWizard(Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectElement,System.Boolean)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsDetermineWizardTrust.OnWizardCompleted")] -[assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectContainerNode.#RunVsTemplateWizard(Microsoft.VisualStudio.FSharp.ProjectSystem.ProjectElement,System.Boolean)", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsDetermineWizardTrust.OnWizardInitiated(System.String,System.Guid@)")] -#endif [assembly: SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Microsoft.VisualStudio.Package.ProjectNode.#AddFolderFromOtherProject(System.String,Microsoft.VisualStudio.Package.HierarchyNode)", MessageId = "")] [assembly: SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", Scope = "member", Target = "Microsoft.VisualStudio.Package.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[])", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsFileChangeEx.IgnoreFile(System.UInt32,System.String,System.Int32)")] [assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Microsoft.VisualStudio.Package.ProjectNode.#AddReferenceCouldNotBeAddedErrorMessage(System.String)", MessageId = "")] diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/HierarchyNode.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/HierarchyNode.cs index 73ffb500acc..075e89c2216 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/HierarchyNode.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/HierarchyNode.cs @@ -37,9 +37,6 @@ namespace Microsoft.VisualStudio.FSharp.ProjectSystem public abstract class HierarchyNode : IVsUIHierarchy, IVsPersistHierarchyItem, -#if IMPLEMENT_IVSPERSISTHIERARCHYITEM2 - IVsPersistHierarchyItem2, -#endif Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget, IVsHierarchyDropDataSource2, IVsHierarchyDropDataSource, @@ -2144,11 +2141,7 @@ public virtual void GetSccFiles(IList files, IList f files.Add(this.GetMkDocument()); -#if UNUSED_DEPENDENT_FILES - tagVsSccFilesFlags flagsToAdd = (this.firstChild != null && (this.firstChild is DependentFileNode)) ? tagVsSccFilesFlags.SFF_HasSpecialFiles : tagVsSccFilesFlags.SFF_NoFlags; -#else tagVsSccFilesFlags flagsToAdd = tagVsSccFilesFlags.SFF_NoFlags; -#endif flags.Add(flagsToAdd); } @@ -2187,36 +2180,6 @@ public virtual void DeleteFromStorage(string path) { } -#if IMPLEMENT_IVSPERSISTHIERARCHYITEM2 - /// - /// Determines whether a file change should be ignored or not. - /// - /// Flag indicating whether or not to ignore changes (true to ignore changes). - public virtual int IgnoreItemFileChanges(bool ignoreFlag) - { - return VSConstants.E_NOTIMPL; - } - - /// - /// Called to determine whether a project item is reloadable. - /// - /// True if the project item is reloadable. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Reloadable")] - public virtual bool IsItemReloadable() - { - return false; - } - - /// - /// Reloads an item. - /// - /// Reserved parameter defined at the IVsPersistHierarchyItem2::ReloadItem parameter. - public virtual int ReloadItem(uint reserved) - { - return VSConstants.E_NOTIMPL; - } -#endif - /// /// Handle the Copy operation to the clipboard /// This method is typically overriden on the project node @@ -2876,84 +2839,6 @@ public virtual int SaveItem(VSSAVEFLAGS saveFlag, string silentSaveAsName, uint return returnCode; } -#if IMPLEMENT_IVSPERSISTHIERARCHYITEM2 - /// - /// 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) - { - if (this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - HierarchyNode n = this.ProjectMgr.NodeFromItemId(itemId); - if (n != null) - { - return n.IgnoreItemFileChanges(ignoreFlag == 0 ? false : true); - } - else - { - return VSConstants.E_INVALIDARG; - } - } - - /// - /// 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; - } - else - { - return VSConstants.E_INVALIDARG; - } - } - - /// - /// 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) - { - if (this.ProjectMgr == null || this.ProjectMgr.IsClosed) - { - return VSConstants.E_FAIL; - } - - HierarchyNode n = this.ProjectMgr.NodeFromItemId(itemId); - if (n != null) - { - return n.ReloadItem(reserved); - } - else - { - return VSConstants.E_INVALIDARG; - } - } -#endif - /// /// CommandTarget.Exec is called for most major operations if they are NOT UI based. Otherwise IVSUInode::exec is called first /// diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NestedProjectBuildDependency.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NestedProjectBuildDependency.cs deleted file mode 100644 index 9c97edfa950..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NestedProjectBuildDependency.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if UNUSED_NESTED_PROJECTS -using System; -using System.Runtime.InteropServices; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Shell.Interop; -using System.Diagnostics; -using System.Globalization; -using System.Collections; -using System.IO; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - /// - /// Used for adding a build dependency to nested project (not a real project reference) - /// - internal class NestedProjectBuildDependency : IVsBuildDependency - { - IVsHierarchy dependentHierarchy = null; - - [CLSCompliant(false)] - public NestedProjectBuildDependency(IVsHierarchy dependentHierarchy) - { - this.dependentHierarchy = dependentHierarchy; - } - - 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; - } - - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NestedProjectNode.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NestedProjectNode.cs deleted file mode 100644 index ab6df0f68b9..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NestedProjectNode.cs +++ /dev/null @@ -1,1103 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -// WARNING: This code has not been reviewed for COM reference leaks. Review before activating. -#if UNUSED_NESTED_PROJECTS - -using System; -using System.CodeDom.Compiler; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Drawing; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Xml; -using System.Windows.Forms; -using System.Diagnostics; -using System.Globalization; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.Shell; -using System.Net; -using MSBuild = Microsoft.Build.BuildEngine; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; -using IServiceProvider = System.IServiceProvider; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; -using ErrorHandler = Microsoft.VisualStudio.ErrorHandler; -using VSLangProj80; -using System.Diagnostics.CodeAnalysis; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - [CLSCompliant(false), ComVisible(true)] - public class NestedProjectNode : HierarchyNode, IPropertyNotifySink - { - - 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; - - public IVsHierarchy NestedHierarchy - { - get - { - return this.nestedHierarchy; - } - } - - /// - /// Returns the __VSADDVPFLAGS that will be passed in when calling AddVirtualProjectEx - /// - public virtual uint VirtualProjectFlags - { - get { return 0; } - } - - /// - /// The path of the nested project. - /// - public override string Url - { - get - { - return this.projectPath; - } - } - - 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; } - } - - public bool IsDisposed - { - get { return this.isDisposed; } - set { this.isDisposed = value; } - } - - public NestedProjectNode() - { - } - - public NestedProjectNode(ProjectNode root, ProjectElement element) - : base(root, element) - { - this.IsExpanded = true; - } - - /// - /// 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; - 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) - { - - } - - /// - /// 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; - 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. - 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 - /// - public override bool CanDeleteItem(__VSDELETEITEMOPERATION deleteOperation) - { - return false; - } - - /// - /// Delegates the call to the inner hierarchy. - /// - /// Reserved parameter defined at the IVsPersistHierarchyItem2::ReloadItem parameter. - public override void ReloadItem(uint reserved) - { - 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"); - - 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 public 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). - public override void IgnoreItemFileChanges(bool ignoreFlag) - { - 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"); - - 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. - /// - public 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. - /// - public 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. - /// - public 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. - /// - public 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; - } - - /// - /// 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 fileNameParam, string destinationParam, string projectNameParam, __VSCREATEPROJFLAGS createFlags) - { - if (String.IsNullOrEmpty(fileNameParam)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "fileNameParam"); - } - - if (String.IsNullOrEmpty(destinationParam)) - { - throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "destinationParam"); - } - - this.projectName = Path.GetFileName(fileNameParam); - this.projectPath = Path.Combine(destinationParam, 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 }, fileNameParam, 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(fileNameParam, destinationParam, projectNameParam, (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. - /// - public 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. - if (this.nestedHierarchy == null) - { - throw new InvalidOperationException(); - } - - // 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(); - this.imageHandler.Close(); - } - } - } - finally - { - base.Dispose(disposing); - this.isDisposed = true; - } - } - } - - /// - /// Creates the project directory if it does not exist. - /// - /// - public 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")] - public 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, 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")] - public 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. - public 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. - /// - /// - public virtual void SaveNestedProjectItemInProjectFile(string newFileName) - { - string existingInclude = MSBuildItem.GetEvaluatedInclude(this.ItemNode.Item); - string existingRelativePath = Path.GetDirectoryName(existingInclude); - string newRelativePath = Path.Combine(existingRelativePath, newFileName); - this.ItemNode.Rename(newRelativePath); - } - - /// - /// Closes a nested project and releases the nested hierrachy pointer. - /// - public 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")); - this.nestedHierarchy.SetGuidProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, ref instanceGuid); - - } - else - { - // Get a guid from the nested hiererachy. - Guid nestedHiererachyInstanceGuid; - 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); - - 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; - this.nestedHierarchy.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ItemDocCookie, docCookie); - } - - 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; - 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) - { - object returnValue = null; - if (!this.ProjectMgr.IsClosed) - { - 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. - this.nestedHierarchy.GetProperty(VSConstants.VSITEMID_ROOT, propID, out returnValue); - } - return returnValue; - } - - /// - /// 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; - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NodeProperties.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NodeProperties.cs index ae3eeb35122..9625a78bd69 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NodeProperties.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/NodeProperties.cs @@ -727,84 +727,6 @@ public override string GetClassName() } } -#if SINGLE_FILE_GENERATOR - [CLSCompliant(false), ComVisible(true)] - public class SingleFileGeneratorNodeProperties : FileNodeProperties - { - private EventHandler onCustomToolChanged; - private EventHandler onCustomToolNameSpaceChanged; - public string _customTool = ""; - public string _customToolNamespace = ""; - - public event EventHandler OnCustomToolChanged - { - add { onCustomToolChanged += value; } - remove { onCustomToolChanged -= value; } - } - - public event EventHandler OnCustomToolNameSpaceChanged - { - add { onCustomToolNameSpaceChanged += value; } - remove { onCustomToolNameSpaceChanged -= value; } - } - - [SRCategoryAttribute(SR.Advanced)] - [LocDisplayName(SR.CustomTool)] - [SRDescriptionAttribute(SR.CustomToolDescription)] - public virtual string CustomTool - { - get - { - _customTool = this.Node.ItemNode.GetMetadata(ProjectFileConstants.Generator); - return _customTool; - } - set - { - _customTool = value; - if (!string.IsNullOrEmpty(_customTool)) - { - this.Node.ItemNode.SetMetadata(ProjectFileConstants.Generator, _customTool); - HierarchyNodeEventArgs args = new HierarchyNodeEventArgs(this.Node); - if (onCustomToolChanged != null) - { - onCustomToolChanged(this.Node, args); - } - } - } - } - - [SRCategoryAttribute(SR.Advanced)] - [LocDisplayName(SR.CustomToolNamespace)] - [SRDescriptionAttribute(SR.CustomToolNamespaceDescription)] - public virtual string CustomToolNamespace - { - get - { - _customToolNamespace = this.Node.ItemNode.GetMetadata(ProjectFileConstants.CustomToolNamespace); - return _customToolNamespace; - } - set - { - _customToolNamespace = value; - if (!string.IsNullOrEmpty(_customToolNamespace)) - { - this.Node.ItemNode.SetMetadata(ProjectFileConstants.CustomToolNamespace, _customToolNamespace); - HierarchyNodeEventArgs args = new HierarchyNodeEventArgs(this.Node); - if (onCustomToolNameSpaceChanged != null) - { - onCustomToolNameSpaceChanged(this.Node, args); - } - } - } - } - - internal SingleFileGeneratorNodeProperties(HierarchyNode node) - : base(node) - { - } - } -#endif - [CLSCompliant(false), ComVisible(true)] public class ProjectNodeProperties : NodeProperties , VSLangProj.ProjectProperties diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectContainerNode.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectContainerNode.cs deleted file mode 100644 index 64e59ca5e54..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectContainerNode.cs +++ /dev/null @@ -1,786 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -// WARNING: This code has not been reviewed for COM reference leaks. Review before activating. -#if UNUSED_NESTED_PROJECTS -using System; -using System.CodeDom.Compiler; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Drawing; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Xml; -using System.Windows.Forms; -using System.Diagnostics; -using System.Globalization; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell.Interop; -using Microsoft.VisualStudio.Shell; -using System.Net; -using MSBuild = Microsoft.Build.BuildEngine; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; -using IServiceProvider = System.IServiceProvider; -using System.Diagnostics.CodeAnalysis; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - [CLSCompliant(false), ComVisible(true)] - public abstract class ProjectContainerNode : ProjectNode, - IVsParentProject, - IBuildDependencyOnProjectContainer - { - /// - /// 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; - - internal ProjectContainerNode() - { - } - - /// - /// Returns teh object that handles listening to file changes on the nested project files. - /// - public FileChangeManager NestedProjectNodeReloader - { - get - { - if (this.nestedProjectNodeReloader == null) - { - this.nestedProjectNodeReloader = new FileChangeManager(this.Site); - this.nestedProjectNodeReloader.FileChangedOnDisk += this.OnNestedProjectFileChangedOnDisk; - } - - return this.nestedProjectNodeReloader; - } - } - - /// - /// This is the object that will be returned by EnvDTE.Project.Object for this project - /// - public override object Object - { - get { return new Automation.OASolutionFolder(this); } - } - - /// - /// 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) - { - if (n is NestedProjectNode && n.ID == itemId) - { - NestedProjectNode p = n as NestedProjectNode; - - 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)); - } - } - - public 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) - { - if (this.IsClosed) - { - return VSConstants.E_FAIL; - } - - 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. - /// - public override void Reload() - { - base.Reload(); - this.CreateNestedProjectNodes(); - } - - 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 e; - } - 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; - } - - /// - /// 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(); - } - - 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. - /// - 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 (Microsoft.Build.Evaluation.ProjectItem item in MSBuildProject.GetItems(this.BuildProject)) - { - if (String.Compare(MSBuildItem.GetItemType(item), 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. - /// - public 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")] - public 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. - 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) - { - 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. - /// - public 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. - /// - public 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 - /// - public 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. - /// - public 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). - /// - public 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 ApplicationException()); - 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. - public 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 e; - } - -#if DEBUG - IVsHierarchy nestedHierarchy; - 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); - - 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) - { - solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject | (uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave, this, 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) - { - 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."); - - 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); - } - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectFileConstants.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectFileConstants.cs index 13a35247088..2a51d1699a1 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectFileConstants.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectFileConstants.cs @@ -181,9 +181,6 @@ internal enum WrapperToolAttributeValue internal static class DefaultSortOrderNode { public const int HierarchyNode = 1000; -#if UNUSED_NESTED_PROJECTS - public const int NestedProjectNode = 200; -#endif public const int ReferenceContainerNode = 300; } diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectNode.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectNode.cs index 612384eae3e..d243a54e157 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectNode.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectNode.cs @@ -649,13 +649,6 @@ public enum EventTriggering private Microsoft.Build.Framework.ILogger myDebugLogger; private static readonly System.Runtime.Versioning.FrameworkName DefaultTargetFrameworkMoniker = new System.Runtime.Versioning.FrameworkName(".NETFramework", new Version(4, 0)); -#if UNUSED - /// - /// Token processor used by the project sample. - /// - private TokenProcessor tokenProcessor = null; -#endif - /// /// Member to store output base relative path. Used by OutputBaseRelativePath property /// @@ -957,24 +950,6 @@ public bool CanFileNodesHaveChilds } } -#if UNUSED - /// - /// Get and set the Token processor. - /// - public TokenProcessor FileTemplateProcessor - { - get - { - if (tokenProcessor == null) - tokenProcessor = new TokenProcessor(); - return tokenProcessor; - } - set - { - tokenProcessor = value; - } - } -#endif public IVsHierarchy InteropSafeIVsHierarchy { get; protected set; } public IVsUIHierarchy InteropSafeIVsUIHierarchy { get; protected set; } public IVsProject InteropSafeIVsProject { get; protected set; } @@ -2265,52 +2240,6 @@ public virtual void OnOpenItem(string fullPathToSourceFile) { } -#if UNUSED_DEPENDENT_FILES - /// - /// 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 - public virtual HierarchyNode AddDependentFileNode(IDictionary subitems, string key) - { - Microsoft.Build.Evaluation.ProjectItem item = subitems[key]; - subitems.Remove(key); - - HierarchyNode newNode; - HierarchyNode parent = null; - - string dependentOf = MSBuildItem.GetMetadataValue(item, 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 != 0) - 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; - } -#endif - /// /// 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 @@ -2765,29 +2694,6 @@ internal virtual LinkedFileNode CreateFileNode(string file, uint? newItemId = nu return this.CreateFileNode(item, newItemId); } -#if UNUSED_DEPENDENT_FILES - /// - /// 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); - } -#endif - /// /// Return an absolute path that is normalized (e.g. no ".." portions) /// @@ -2991,16 +2897,6 @@ public virtual IList GetSelectedNodes() selectedNodes.Add(node); } } -#if UNUSED_NESTED_PROJECTS - else - { - NestedProjectNode node = this.GetNestedProjectForHierarchy(hierarchy); - if (node != null) - { - selectedNodes.Add(node); - } - } -#endif } else if (multiItemSelect != null) { @@ -3963,28 +3859,8 @@ public virtual HierarchyNode AddNewFileNodeToHierarchy(HierarchyNode parentNode, private HierarchyNode AddNewFileNodeToHierarchyCore(HierarchyNode parentNode, string fileName, uint? newItemId = null) { - HierarchyNode child; - -#if UNUSED_DEPENDENT_FILES - // 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 -#endif - { - //Create and add new filenode to the project - child = this.CreateFileNode(fileName, newItemId); - } + //Create and add new filenode to the project + HierarchyNode child = this.CreateFileNode(fileName, newItemId); parentNode.AddChild(child); @@ -4240,34 +4116,7 @@ public virtual void ProcessFilesAndFolders() subitems.Add(MSBuildItem.GetEvaluatedInclude(item), item); } } - -#if UNUSED_DEPENDENT_FILES - // Now process the dependent items. - if (this.CanFileNodesHaveChilds) - { - ProcessDependentFileNodes(subitemsKeys, subitems); - } -#endif - } - -#if UNUSED_DEPENDENT_FILES - /// - /// Processes dependent filenodes from list of subitems. Multi level supported, but not circular dependencies. - /// - /// List of sub item keys - /// - public virtual void ProcessDependentFileNodes(List subitemsKeys, Dictionary subitems) - { - 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); - } } -#endif /// /// For flavored projects which implement IPersistXMLFragment, load the information now @@ -4626,36 +4475,6 @@ internal bool QueryEditProjectFile(bool suppressUI) return result; } -#if UNUSED_NESTED_PROJECTS - /// - /// Checks whether a hierarchy is a nested project. - /// - /// - /// - public NestedProjectNode GetNestedProjectForHierarchy(IVsHierarchy hierarchy) - { - if (hierarchy != null && (hierarchy is IVsProject3)) - { - IVsProject3 project = hierarchy as IVsProject3; - - string mkDocument = String.Empty; - project.GetMkDocument(VSConstants.VSITEMID_ROOT, out mkDocument); - - if (!String.IsNullOrEmpty(mkDocument)) - { - HierarchyNode node = this.FindChild(mkDocument); - - if (node != null && (node is NestedProjectNode)) - { - return node as NestedProjectNode; - } - } - } - - return null; - } -#endif - /// /// 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. @@ -6470,28 +6289,6 @@ private HierarchyNode AddIndependentFileNode(Microsoft.Build.Evaluation.ProjectI return node; } -#if UNUSED_DEPENDENT_FILES - /// - /// Add a dependent file node to the hierarchy - /// - /// msbuild item to add - /// Parent Node - /// Added node - private HierarchyNode AddDependentFileNodeToNode(Microsoft.Build.Evaluation.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; - } -#endif - /// /// Add a file node to the hierarchy /// diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectPackage.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectPackage.cs index 4c5d591b704..d86f683b236 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectPackage.cs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectPackage.cs @@ -45,9 +45,6 @@ protected override void Initialize() // Subscribe to the solution events this.solutionListeners.Add(new SolutionListenerForProjectReferenceUpdate(this)); this.solutionListeners.Add(new SolutionListenerForProjectOpen(this)); -#if UNUSED_NESTED_PROJECTS - this.solutionListeners.Add(new SolutionListenerForBuildDependencyUpdate(this)); -#endif this.solutionListeners.Add(new SolutionListenerForProjectEvents(this)); foreach (SolutionListener solutionListener in this.solutionListeners) diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectSystem.Base.csproj b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectSystem.Base.csproj index 89b121fea93..5ba2f43c3c5 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectSystem.Base.csproj +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectSystem.Base.csproj @@ -76,12 +76,9 @@ - - - @@ -95,7 +92,6 @@ - @@ -105,7 +101,6 @@ - @@ -128,7 +123,6 @@ - @@ -139,14 +133,11 @@ - - - @@ -160,21 +151,15 @@ - - - - - - diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/RegisteredProjectType.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/RegisteredProjectType.cs deleted file mode 100644 index 5e9fb1fff96..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/RegisteredProjectType.cs +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if UNUSED_NESTED_PROJECTS -using System; -using System.Runtime.InteropServices; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using Microsoft.Win32; -using Microsoft.VisualStudio.Shell.Interop; -using VSRegistry = Microsoft.VisualStudio.Shell.VSRegistry; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - /// - /// Gets registry settings from for a project. - /// - internal class RegisteredProjectType - { - private string defaultProjectExtension; - - private string projectTemplatesDir; - - private string wizardTemplatesDir; - - private Guid packageGuid; - - public const string DefaultProjectExtension = "DefaultProjectExtension"; - public const string WizardsTemplatesDir = "WizardsTemplatesDir"; - public const string ProjectTemplatesDir = "ProjectTemplatesDir"; - public const string Package = "Package"; - - - - public string DefaultProjectExtensionValue - { - get - { - return this.defaultProjectExtension; - } - set - { - this.defaultProjectExtension = value; - } - } - - public string ProjectTemplatesDirValue - { - get - { - return this.projectTemplatesDir; - } - set - { - this.projectTemplatesDir = value; - } - } - - public string WizardTemplatesDirValue - { - get - { - return this.wizardTemplatesDir; - } - set - { - this.wizardTemplatesDir = value; - } - } - - public 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" - /// - public 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; - } - - public 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; - } - } -} -#endif \ No newline at end of file diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/SingleFileGenerator.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/SingleFileGenerator.cs deleted file mode 100644 index 7ba76001013..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/SingleFileGenerator.cs +++ /dev/null @@ -1,512 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if SINGLE_FILE_GENERATOR - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - using System; - using System.Runtime.InteropServices; - using System.Collections.Generic; - using System.IO; - using System.Diagnostics; - using System.Globalization; - using Microsoft.VisualStudio.Shell; - using Microsoft.VisualStudio.Shell.Interop; - using Microsoft.VisualStudio.OLE.Interop; - using Microsoft.VisualStudio.TextManager.Interop; - using Microsoft.VisualStudio.FSharp.Package; - - /// - /// Provides support for single file generator. - /// - internal class SingleFileGenerator : ISingleFileGenerator, IVsGeneratorProgress - { - - private bool gettingCheckoutStatus; - private bool runningGenerator; - private bool hasRunGenerator = false; - private ProjectNode projectMgr; - - /// - /// Overloadde ctor. - /// - /// The associated project - public SingleFileGenerator(ProjectNode projectMgr) - { - this.projectMgr = projectMgr; - } - - 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; - } - - /// - /// 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.hasRunGenerator || 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); - if (!this.hasRunGenerator) - this.hasRunGenerator=true; - } - } - } - - /// - /// Invokes the specified generator - /// - /// The node on which to invoke the generator. - public virtual void InvokeGenerator(FileNode fileNode) - { - if (fileNode == null) - { - throw new ArgumentNullException("node"); - } - - 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 - string fileToAdd = 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 - public 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 (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 - public 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; - try - { - ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)(_VSRDTFLAGS.RDT_NoLock), filePath, out hier, out itemid, out docData, out cookie)); - } - catch (Exception) - { - if (docData != IntPtr.Zero) Marshal.Release(docData); - throw; - } - - if (docData != IntPtr.Zero) - { - Marshal.Release(docData); - IVsTextStream srpStream; - string inputFileContents = this.GetBufferContents(filePath, out srpStream); - 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.FreeCoTaskMem(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; - } - - /// - /// 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) - 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 = IntPtr.Zero; - uint dwCookie = 0; - IVsHierarchy srpHier; - uint itemid = VSConstants.VSITEMID_NIL; - - try - { - 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 - { - pHier = srpHier; - } - } - } - finally - { - if (docData != IntPtr.Zero) - { - Marshal.Release(docData); - } - } - } - return (ret == 1); - } - - /// - /// This function asks to the QueryEditQuerySave service if it is possible to - /// edit the file. - /// - private bool CanEditFile(string documentMoniker) - { - Debug.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; - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/SingleFileGeneratorFactory.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/SingleFileGeneratorFactory.cs deleted file mode 100644 index 689d389585c..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/SingleFileGeneratorFactory.cs +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if SINGLE_FILE_GENERATOR - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - using System; - using System.Runtime.InteropServices; - using System.Collections.Generic; - using System.IO; - using System.Diagnostics; - using System.Globalization; - using Microsoft.VisualStudio.Shell; - using Microsoft.VisualStudio.Shell.Interop; - using Microsoft.VisualStudio.OLE.Interop; - using Microsoft.VisualStudio.TextManager.Interop; - using Microsoft.Win32; - - using VSRegistry = Microsoft.VisualStudio.Shell.VSRegistry; - - /// - /// Provides implementation IVsSingleFileGeneratorFactory for - /// - internal class SingleFileGeneratorFactory : IVsSingleFileGeneratorFactory - { - private class GeneratorMetaData - { - private Guid generatorClsid = Guid.Empty; - private int generatesDesignTimeSource = -1; - private int generatesSharedDesignTimeSource = -1; - private int useDesignTimeCompilationFlag = -1; - object generator = null; - - public GeneratorMetaData() - { - } - - /// - /// 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; - } - } - } - - /// - /// Base generator registry key for MPF based project - /// - private RegistryKey baseGeneratorRegistryKey = null; - - /// - /// 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; - - /// - /// 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; - } - - /// - /// 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; } - } - - /// - /// 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; - } - } - - /// - /// 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; - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/SolutionListenerForBuildDependencyUpdate.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/SolutionListenerForBuildDependencyUpdate.cs deleted file mode 100644 index 422f08e492e..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/SolutionListenerForBuildDependencyUpdate.cs +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - - -#if UNUSED_NESTED_PROJECTS -using Microsoft.VisualStudio.Shell.Interop; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Runtime.InteropServices; -using System.Security; -using System.Windows; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; -using System.Drawing; -using System.IO; -using System.Windows.Forms; -using System.Collections; -using System.Text; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; -using IServiceProvider = System.IServiceProvider; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - /// - /// The purpose of this class is to set a build dependency from a modeling project to all its sub projects - /// - internal class SolutionListenerForBuildDependencyUpdate : SolutionListener - { - public SolutionListenerForBuildDependencyUpdate(IServiceProvider serviceProvider) : base(serviceProvider) - { - } - - /// - /// 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; - } - - /// - /// 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 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); - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/TokenProcessor.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/TokenProcessor.cs deleted file mode 100644 index 2d358b467ca..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/TokenProcessor.cs +++ /dev/null @@ -1,503 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if UNUSED -using System; -using System.Collections; -using System.Globalization; -using System.Text; -using System.IO; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - /// - /// Replacement type - /// - public enum TokenReplaceType - { - ReplaceString, - ReplaceNumber, - ReplaceCode - } - - /// - /// Contain a number of functions that handle token replacement - /// - [CLSCompliant(false)] - public class TokenProcessor - { - // Internal fields - private ArrayList tokenlist; - - 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 - /// - /// Start token - /// End token - [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)); - } - - /// - /// For all known token, replace token with correct value - /// - /// File of the source file - /// File of the destination file - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Untoken")] - public virtual void UntokenFile(string source, string destination) - { - if (source == null || destination == null || source.Length == 0 || destination.Length == 0) - throw new ArgumentNullException("Token replacement target file is not valid."); - - // 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)) - { - string buffer = File.ReadAllText(source); - 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); - } - 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) - { - 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) - { - 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) - { - string regularExp = rpBetweenToken.TokenStart + "[^" + rpBetweenToken.TokenIdentifier + "]*" + rpBetweenToken.TokenEnd; - buffer = System.Text.RegularExpressions.Regex.Replace(buffer, regularExp, rpBetweenToken.TokenReplacement); - } - - /// - /// 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 - 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(); - } - - /// - /// 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. - private string GuidToForm2(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 - ResultingStr.AppendFormat(CultureInfo.InvariantCulture, ", {{ 0x{0}", GuidBytes[i++].ToString("X", CultureInfo.InvariantCulture)); - for (int j = 1; j < 8; ++j) - { - ResultingStr.AppendFormat(CultureInfo.InvariantCulture, ", 0x{0}", GuidBytes[i++].ToString("X", CultureInfo.InvariantCulture)); - } - ResultingStr.Append(" }"); - - return ResultingStr.ToString(); - } - - /// - /// 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")] - public 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")] - public 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 - /// Namespace to use for the new file - public string GetFileNamespace(string fileFullPath, ProjectNode 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(); - } - } - - /// - /// 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 - /// - /// 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; } - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Url.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Url.cs deleted file mode 100644 index 8648cbccfc8..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/Url.cs +++ /dev/null @@ -1,366 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if BETA2 - -using System; -using System.Windows.Forms; -using System.Diagnostics; -using Microsoft.Win32; -using System.Globalization; -using System.IO; -using System.Collections; -using System.Xml; -using System.Text; -using System.Net; -using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider; -using IServiceProvider = System.IServiceProvider; -using ShellConstants = Microsoft.VisualStudio.Shell.Interop.Constants; -using OleConstants = Microsoft.VisualStudio.OLE.Interop.Constants; - -namespace Microsoft.VisualStudio.FSharp.ProjectSystem -{ - /// - /// This class wraps the Uri class and provides an unescaped "LocalPath" for file URL's - /// and an unescaped AbsoluteUri for other schemes, plus it also returned an un-hex-escaped - /// result from MakeRelative so it can be presented to the user. - /// - internal class Url - { - private Uri uri = null; - private bool isFile; - - - public Url(string path) - { - Init(path); - } - - void Init(string path) - { - // Must try absolute first, then fall back on relative, otherwise it - // makes some absolute UNC paths like (\\lingw11\Web_test\) relative! - if (path != null) - { - - if (!Uri.TryCreate(path, UriKind.Absolute, out this.uri)) - { - Uri.TryCreate(path, UriKind.Relative, out this.uri); - } - - this.CheckIsFile(); - } - } - - void CheckIsFile() - { - this.isFile = false; - if (this.uri != null) - { - if (this.uri.IsAbsoluteUri) - { - this.isFile = this.uri.IsFile; - } - else - { - string[] test1 = this.uri.OriginalString.Split('/'); - string[] test2 = this.uri.OriginalString.Split('\\'); - if (test1.Length < test2.Length) - { - this.isFile = true; - } - } - } - } - - // allows relpath to be null, in which case it just returns the baseUrl. - - public Url(Url baseUrl, string relpath) - { - if (baseUrl.uri == null) - { - Init(relpath); - } - else if (string.IsNullOrEmpty(relpath)) - { - this.uri = baseUrl.uri; - } - else - { - this.uri = new Uri(baseUrl.uri, relpath); - } - CheckIsFile(); - } - - - public string AbsoluteUrl - { - get - { - if (this.uri == null) return null; - if (this.uri.IsAbsoluteUri) - { - if (this.isFile) - { - // Fix for build break. UriComponents.LocalPath is no longer available. - // return uri.GetComponents(UriComponents.LocalPath, UriFormat.SafeUnescaped); - return uri.LocalPath; - } - else - { - return uri.GetComponents(UriComponents.AbsoluteUri, UriFormat.SafeUnescaped); - } - } - else - { - return uri.OriginalString; - } - } - } - - - /// Returns the AbsoluteUrl for the parent directory containing the file - /// referenced by this URL object, where the Directory string is also unescaped. - public string Directory - { - get - { - string path = this.AbsoluteUrl; - if (path == null) return null; - int i = path.LastIndexOf(this.IsFile ? Path.DirectorySeparatorChar : '/'); - int len = (i > 0) ? i : path.Length; - return path.Substring(0, len); - } - } - - - public bool IsFile - { - get { return this.isFile; } - } - - - public Url Move(Url oldBase, Url newBase) - { - if (this.uri == null || oldBase.uri == null) return null; - string rel = oldBase.uri.MakeRelativeUri(this.uri).ToString(); - return new Url(newBase, rel); - } - - // return an un-escaped relative path - - public string MakeRelative(Url url) - { - if (this.uri == null || url.uri == null) return null; - if (this.uri.Scheme != url.uri.Scheme || this.uri.Host != url.uri.Host) - { - // Then it cannot be relatavized (e.g from file:// to http://). - return url.AbsoluteUrl; - } - // This will return a hex-escaped string. - string rel = this.uri.MakeRelativeUri(url.uri).ToString(); - - // So unescape it. - return Unescape(rel, this.isFile); - } - - const char c_DummyChar = (char)0xFFFF; - - private static char EscapedAscii(char digit, char next) - { - // Only accept hexadecimal characters - if (!(((digit >= '0') && (digit <= '9')) - || ((digit >= 'A') && (digit <= 'F')) - || ((digit >= 'a') && (digit <= 'f')))) - { - return c_DummyChar; - } - - int res = 0; - if (digit <= '9') - res = (int)digit - (int)'0'; - else if (digit <= 'F') - res = ((int)digit - (int)'A') + 10; - else - res = ((int)digit - (int)'a') + 10; - - // Only accept hexadecimal characters - if (!(((next >= '0') && (next <= '9')) - || ((next >= 'A') && (next <= 'F')) - || ((next >= 'a') && (next <= 'f')))) - { - return c_DummyChar; - } - - res = res << 4; - if (next <= '9') - res += (int)next - (int)'0'; - else if (digit <= 'F') - res += ((int)next - (int)'A') + 10; - else - res += ((int)next - (int)'a') + 10; - - return (char)(res); - } - - - public static string Unescape(string escaped, bool isFile) - { - if (String.IsNullOrEmpty(escaped)) - { - return String.Empty; - } - - byte[] bytes = null; - char[] dest = new char[escaped.Length]; - int j = 0; - - for (int i = 0, end = escaped.Length; i < end; i++) - { - char ch = escaped[i]; - if (ch != '%') - { - if (ch == '/' && isFile) - { - ch = Path.DirectorySeparatorChar; - } - dest[j++] = ch; - } - else - { - int byteCount = 0; - // lazy initialization of max size, will reuse the array for next sequences - if (bytes == null) - { - bytes = new byte[end - i]; - } - - do - { - // Check on exit criterion - if ((ch = escaped[i]) != '%' || (end - i) < 3) - { - break; - } - // already made sure we have 3 characters in str - ch = EscapedAscii(escaped[i + 1], escaped[i + 2]); - if (ch == c_DummyChar) - { - //invalid hex sequence, we will out '%' character - ch = '%'; - break; - } - else if (ch < '\x80') - { - // character is not part of a UTF-8 sequence - i += 2; - break; - } - else - { - //a UTF-8 sequence - bytes[byteCount++] = (byte)ch; - i += 3; - } - } while (i < end); - - if (byteCount != 0) - { - - int charCount = Encoding.UTF8.GetCharCount(bytes, 0, byteCount); - if (charCount != 0) - { - Encoding.UTF8.GetChars(bytes, 0, byteCount, dest, j); - j += charCount; - } - else - { - // the encoded, high-ANSI characters are not UTF-8 encoded - for (int k = 0; k < byteCount; ++k) - { - dest[j++] = (char)bytes[k]; - } - } - } - if (i < end) - { - dest[j++] = ch; - } - } - } - return new string(dest, 0, j); - } - - - public Uri Uri - { - get { return this.uri; } - } - - // Unlike the Uri class, this ALWAYS succeeds, even on relative paths, and it - // strips out the path separator characters - - public string[] GetSegments() - { - if (this.uri == null) return null; - string path = this.AbsoluteUrl; - if (this.isFile || !this.uri.IsAbsoluteUri) - { - if (path.EndsWith("\\")) - path = path.Substring(0, path.Length - 1); - return path.Split(Path.DirectorySeparatorChar); - } - else - { - // strip off "http://" and host name, since those are not part of the path. - path = path.Substring(this.uri.Scheme.Length + 3 + this.uri.Host.Length + 1); - if (path.EndsWith("/")) - path = path.Substring(0, path.Length - 1); - return path.Split('/'); - } - } - - - /// Return unescaped path up to (but not including) segment i. - public string GetPartial(int i) - { - string path = JoinSegments(0, i); - if (!this.isFile) - { - // prepend "http://host/" - path = this.uri.Scheme + "://" + this.uri.Host + '/' + path; - } - return path; - } - - - /// Return unescaped relative path starting segment i. - public string GetRemainder(int i) - { - return JoinSegments(i, -1); - } - - - public string JoinSegments(int i, int j) - { - if (i < 0) - throw new ArgumentOutOfRangeException("i"); - - StringBuilder sb = new StringBuilder(); - string[] segments = this.GetSegments(); - if (segments == null) - return null; - if (j < 0) - j = segments.Length; - int len = segments.Length; - for (; i < j && i < len; i++) - { - if (sb.Length > 0) - sb.Append(this.isFile ? Path.DirectorySeparatorChar : '/'); - string s = segments[i]; - sb.Append(s); - } - return Unescape(sb.ToString(), isFile); - } - } -} -#endif diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/RegistrationAttributes/SingleFileGeneratorSupportRegistrationAttribute.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/RegistrationAttributes/SingleFileGeneratorSupportRegistrationAttribute.cs deleted file mode 100644 index 56eb76d9fa9..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/RegistrationAttributes/SingleFileGeneratorSupportRegistrationAttribute.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if SINGLE_FILE_GENERATOR - -using System; -using System.Globalization; - -namespace Microsoft.VisualStudio.Shell -{ - /// - /// This attribute adds a custom file generator registry entry for specific file - /// type. - /// For Example: - /// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Generators\ - /// [proj_fac_guid] - /// - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] - internal sealed class SingleFileGeneratorSupportRegistrationAttribute : RegistrationAttribute - { - private Guid _prjFacGuid; - /// - /// Creates a new SingleFileGeneratorSupportRegistrationAttribute attribute to register a custom - /// code generator for the provided context. - /// - /// The type of Code generator. Type that implements IVsSingleFileGenerator - /// The generator name - /// The context GUID this code generator would appear under. - public SingleFileGeneratorSupportRegistrationAttribute(Type prjFactoryType) - { - if (prjFactoryType == null) - throw new ArgumentNullException("prjFactoryType"); - - _prjFacGuid = prjFactoryType.GUID; - } - - - /// - /// Get the Guid representing the generator type - /// - public Guid ProjectFactoryGuid - { - get { return _prjFacGuid; } - } - - /// - /// Property that gets the generator base key name - /// - private string GeneratorRegKey - { - get { return string.Format(CultureInfo.InvariantCulture, @"Generators\{0}", ProjectFactoryGuid.ToString("B")); } - } - /// - /// Called to register this attribute with the given context. The context - /// contains the location where the registration inforomation should be placed. - /// It also contains other information such as the type being registered and path information. - /// - public override void Register(RegistrationContext context) - { - using (Key childKey = context.CreateKey(GeneratorRegKey)) - { - childKey.SetValue(string.Empty, string.Empty); - } - - } - - /// - /// Unregister this file extension. - /// - /// - public override void Unregister(RegistrationContext context) - { - context.RemoveKey(GeneratorRegKey); - } - } -} -#endif \ No newline at end of file diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/RegistrationAttributes/WebSiteProjectAttribute.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/RegistrationAttributes/WebSiteProjectAttribute.cs deleted file mode 100644 index f9ec5e07ee1..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/RegistrationAttributes/WebSiteProjectAttribute.cs +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - - -#if UNUSED - -using System; -using System.IO; -using System.ComponentModel; -using System.Globalization; -using Microsoft.Win32; - -namespace Microsoft.VisualStudio.Shell -{ - /// - /// This attribute adds a ProjectSubType to the exisiting list defined of ProjectSubTypes - /// for the Web Site Project - /// - /// - /// For example: - /// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\(*version*)\Projects\ - /// {E24C65DC-7377-472B-9ABA-BC803B73C61A}\ProjectSubType(VsTemplate)\IronPython - /// "Default"="Iron Python" - /// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0Exp\NewProjectTemplates\TemplateDirs\{39c9c826-8ef8-4079-8c95-428f5b1c323f}\IronPython] - /// @="Iron Python" - /// "NewProjectDialogExOnly"=dword:00000001 - /// "SortPriority"=dword:0000012c - /// "TemplatesDir"="D:\\Program Files\\Microsoft Visual Studio 8\\Web\\.\\WebProjects\\IronPython" - /// "DeveloperActivity"="IronPython" - - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] - [System.Runtime.InteropServices.ComVisibleAttribute(false)] - public sealed class WebSiteProjectAttribute : RegistrationAttribute - { - private const string webSiteProjectGuid = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}"; - private const string websitePackageGuid = "{39c9c826-8ef8-4079-8c95-428f5b1c323f}"; - - private Type packageType; - private string languageID; - private string languageName; - - /// - /// Creates a new WebSiteProjectAttribute attribute to register a - /// language with the web site project - /// - /// Language ID which is being referenced from the vstemplate - /// Language Name which shows up in the add new Web Site dialog under the list of languages - public WebSiteProjectAttribute(string languageID, string languageName) - { - if (languageID == null) - { - throw new ArgumentNullException("languageID", "languageID can not be null."); - } - if (languageName == null) - { - throw new ArgumentNullException("languageName", "languageName can not be null."); - } - - this.languageID = languageID; - this.languageName = languageName; - - } - - /// - /// Gets the Language ID which is being referenced from the vstemplate - /// - public string LanguageID - { - get { return languageID; } - } - - /// - /// Gets the Language Name which shows up in the add new Web Site dialog under the list of languages - /// - public object LanguageName - { - get { return languageName; } - } - - /// - /// ProjectSubTypePath for Web Site Project - /// - private string ProjectSubTypePath - { - get - { - return string.Format(CultureInfo.InvariantCulture, @"Projects\{0}\ProjectSubType(VsTemplate)", webSiteProjectGuid); - } - } - - private string ProjectTemplatesDir - { - get - { - return string.Format(CultureInfo.InvariantCulture, @"NewProjectTemplates\TemplateDirs\{0}", websitePackageGuid); - } - } - /// - /// Gets the Location of devenv.exe based on the RegistryRoot for the current package type - /// - private string getVSInstallDir(RegistrationContext context) - { - DefaultRegistryRootAttribute regRootAttr = (DefaultRegistryRootAttribute)TypeDescriptor.GetAttributes(context.ComponentType)[typeof(DefaultRegistryRootAttribute)]; - if (regRootAttr == null) - { - throw new NotSupportedException("could not find DefaultRegitryRootAttribute on " + context.ComponentType.ToString()); - } - - Win32.RegistryKey key = Win32.Registry.LocalMachine.OpenSubKey(regRootAttr.Root); - //We are using HKCU in the case that the HKLM Experimental hive doesn't exist - if (key == null || key.GetValue("InstallDir") == null) - { - key = Win32.Registry.CurrentUser.OpenSubKey(regRootAttr.Root + @"\Configuration"); - } - string vsInstallDir = (string)key.GetValue("InstallDir"); - key.Close(); - return vsInstallDir; - } - - /// - /// Called to register this attribute with the given context. The context - /// contains the location where the registration information should be placed. - /// It also contains other information such as the type being registered and path information. - /// - /// Given context to register in - public override void Register(RegistrationContext context) - { - if (context == null) - { - throw new ArgumentNullException("context"); - } - packageType = context.ComponentType; - context.Log.WriteLine(String.Format(CultureInfo.CurrentCulture, "WebSiteProject: LanguageID = {0} Language Name = {1}\n", languageID, languageName)); - - //Register ProjectSubType(VsTemplates) - using (Key childKey = context.CreateKey(string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", ProjectSubTypePath, languageID))) - { - childKey.SetValue("", languageName); - } - - //Register NewProjectTemplates - using (Key childKey = context.CreateKey(string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", ProjectTemplatesDir, languageID))) - { - childKey.SetValue("", languageName); - childKey.SetValue("NewProjectDialogExOnly", 1); - childKey.SetValue("SortPriority", 300); - string templateDir = context.RootFolder.TrimEnd('\\') + string.Format(CultureInfo.InvariantCulture, "\\Web\\.\\WebProjects\\{0}", languageID); - childKey.SetValue("TemplatesDir", context.EscapePath(templateDir)); - childKey.SetValue("DeveloperActivity", languageID); - } - } - - /// - /// Unregister this languageID - /// - /// Given context to unregister from - public override void Unregister(RegistrationContext context) - { - if (context != null) - { - //UnRegister ProjectSubType(VsTemplates) - context.RemoveKey(string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", ProjectSubTypePath, languageID)); - - //Register NewProjectTemplates - context.RemoveKey(string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", ProjectTemplatesDir, languageID)); - } - } - } -} - -#endif \ No newline at end of file diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/RegistrationAttributes/WebSiteProjectRelatedFilesAttribute.cs b/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/RegistrationAttributes/WebSiteProjectRelatedFilesAttribute.cs deleted file mode 100644 index 3eab84bb54c..00000000000 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/RegistrationAttributes/WebSiteProjectRelatedFilesAttribute.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - - -#if UNUSED - -using System; -using System.IO; -using System.ComponentModel; -using System.Globalization; -using Microsoft.Win32; - -namespace Microsoft.VisualStudio.Shell -{ - /// - /// This attribute allows the Web Site Project to nest one file type (related) under another file type (primary) in the solution explorer - /// - /// - /// As an example the following Attribute definition - /// [WebSiteProjectRelatedFiles("aspx","py")] - /// - /// would add the following registry key: - /// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\(*version*)\Projects\ - /// {E24C65DC-7377-472B-9ABA-BC803B73C61A}\RelatedFiles\.aspx\.py - /// "Default"="" - - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] - [System.Runtime.InteropServices.ComVisibleAttribute(false)] - public sealed class WebSiteProjectRelatedFilesAttribute : RegistrationAttribute - { - private const string webSiteProjectGuid = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}"; - - private string primaryFileExtension; - private string relatedFileExtension; - - /// - /// Creates a new WebSiteProjectAttribute attribute to register a - /// language with the web site project - /// - /// The primary file extension which will nest files. - /// The related file extion which willl nest under the primary file extension - public WebSiteProjectRelatedFilesAttribute(string primaryFileExtension, string relatedFileExtension) - { - if (string.IsNullOrEmpty(primaryFileExtension)) - { - throw new ArgumentNullException("primaryFileExtension", "primaryFileExtension can not be null."); - } - if (primaryFileExtension.Contains(".")) - { - throw new ArgumentNullException("primaryFileExtension", "primaryFileExtension must not contain '.'"); - } - if (string.IsNullOrEmpty(relatedFileExtension)) - { - throw new ArgumentNullException("relatedFileExtension", "relatedFileExtension can not be null."); - } - if (relatedFileExtension.Contains(".")) - { - throw new ArgumentNullException("relatedFileExtension", "relatedFileExtension must not contain '.'"); - } - - this.primaryFileExtension = primaryFileExtension; - this.relatedFileExtension = relatedFileExtension; - - } - - /// - /// Gets the primary file extension which will nest files - /// - public string PrimaryFileExtension - { - get { return primaryFileExtension; } - } - - /// - /// Gets the related file extion which willl nest under the primary file extension - /// - public object RelatedFileExtension - { - get { return relatedFileExtension; } - } - - /// - /// Returns the Web Site Project RelatedFiles Path - /// - private string RelatedFilePath - { - get - { - string relatedFiles = string.Format(CultureInfo.InvariantCulture, @"Projects\{0}\RelatedFiles", webSiteProjectGuid); - return string.Format(CultureInfo.InvariantCulture, "{0}\\.{1}\\.{2}", relatedFiles, primaryFileExtension, relatedFileExtension); - } - } - - /// - /// Called to register this attribute with the given context. The context - /// contains the location where the registration information should be placed. - /// It also contains other information such as the type being registered and path information. - /// - /// Given context to register in - public override void Register(RegistrationContext context) - { - if (context == null) - { - throw new ArgumentNullException("context"); - } - context.Log.WriteLine(String.Format(CultureInfo.CurrentCulture, "WebSiteProjectRelatedFiles: Primary File Ext = {0} Related File Ext = {1}\n", primaryFileExtension, relatedFileExtension)); - - //Register Related File - context.CreateKey(RelatedFilePath); - } - - /// - /// Unregister this related file extension - /// - /// Given context to unregister from - public override void Unregister(RegistrationContext context) - { - if (context != null) - { - //UnRegister related file extextion - context.RemoveKey(RelatedFilePath); - } - - } - } -} -#endif \ No newline at end of file diff --git a/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs b/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs index da90625ac07..082c43b8ad3 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs +++ b/vsintegration/src/vs/FsPkgs/FSharp.Project/FS/Project.fs @@ -1213,16 +1213,6 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. (newNode :> LinkedFileNode) -#if UNUSED_DEPENDENT_FILES - override x.CreateDependentFileNode(item:ProjectElement ) = - let node = base.CreateDependentFileNode(item) - if (null <> node) then - let includ = item.GetMetadata(ProjectFileConstants.Include) - if (FSharpProjectNode.IsCompilingFSharpFile(includ)) then - node.OleServiceProvider.AddService(typeof, new OleServiceProvider.ServiceCreatorCallback(this.CreateServices), false) - node -#endif - /// Creates the format list for the open file dialog /// The formatlist to return override x.GetFormatList(formatlist:byref ) = @@ -2391,11 +2381,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. [] [] public FSharpFileNodeProperties internal (node:HierarchyNode) = -#if SINGLE_FILE_GENERATOR - inherit SingleFileGeneratorNodeProperties(node) -#else inherit FileNodeProperties(node) -#endif [] member x.Url = "file:///" + x.Node.Url @@ -2526,10 +2512,6 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. override x.CreatePropertiesObject() = let properties = new FSharpFileNodeProperties(x) -#if SINGLE_FILE_GENERATOR - properties.OnCustomToolChanged.AddHandler(EventHandler<_>(fun sender args -> x.OnCustomToolChanged(sender,args))) - properties.OnCustomToolNameSpaceChanged.AddHandler(EventHandler<_>(fun sender args -> x.OnCustomToolNameSpaceChanged(sender,args))) -#endif (properties :> NodeProperties) member x.DisposeSelectionListener() = @@ -3044,11 +3026,7 @@ See also ...\SetupAuthoring\FSharp\Registry\FSProjSys_Registration.wxs, e.g. hr <- hier.ParseCanonicalName((document :?> string), &itemid) match projMgr.NodeFromItemId(itemid) with | :? FSharpFileNode as node -> -#if SINGLE_FILE_GENERATOR - node.RunGenerator() -#else ignore(node) -#endif | _ -> () hr