// var s = SolutionHelper.CurrentSolution._solution; // foreach (Project p in s.Projects) // { // NavigateProject(p); // } //} //private void NavigateProject(Project project ) //{ // textBox.Text = $"{project.Name}\n{project.FullName}\n{project.UniqueName}"; // StringBuilder text = new StringBuilder(); // foreach (ProjectItem pi in project.ProjectItems) // { // string kind = DecodeProjectItemKind(pi.Kind); // if (kind == "File") // { // text.AppendLine($"{pi.Name}, {kind}"); // if (pi.Name.ToLower() == "Startup.cs".ToLower()) // { // var w = pi.Open(EnvDTE.Constants.vsViewKindPrimary); //Constants.vsViewKindCode); // _w = w; // w.Visible = true; // //OpenProjectItemInView(pi); // } // } // } // _projectItems.Text = text.ToString(); //} //private string DecodeProjectItemKind(string kind) //{ // switch(kind) // { // case EnvDTE.Constants.vsProjectItemKindPhysicalFile: // return "File"; // default: // return "other"; // } //} private void OpenProjectItemInView(EnvDTE.ProjectItem projectItem) { //public static void OpenDocumentWithSpecificEditor( // IServiceProvider provider, // string fullPath, // Guid editorType, // Guid logicalView, // out IVsUIHierarchy hierarchy, // out uint itemID, // out IVsWindowFrame windowFrame //) Guid guid_microsoft_visual_basic_editor = new Guid("{2C015C70-C72C-11D0-88C3-00A0C9110049}"); Guid guid_microsoft_visual_basic_editor_with_encoding = new Guid("{6C33E1AA-1401-4536-AB67-0E21E6E569DA}"); Guid guid_microsoft_csharp_editor = new Guid("{A6C744A8-0E4A-4FC6-886A-064283054674}"); Guid guid_microsoft_csharp_editor_with_encoding = new Guid("{08467b34-b90f-4d91-bdca-eb8c8cf3033a}"); // Microsoft.VisualStudio.VSConstants.GUID_TextEditorFactory Guid guid_source_code_text_editor = new Guid("{8B382828-6202-11d1-8870-0000F87579D2}"); Guid guid_source_code_text_editor_with_encoding = new Guid("{C7747503-0E24-4FBE-BE4B-94180C3947D7}"); var sp = GetGloblalServiceProvider(); IVsUIHierarchy hierarchy; uint itemID; IVsWindowFrame windowFrame; VsShellUtilities.TryOpenDocument(sp, projectItem.FileNames[0], guid_microsoft_csharp_editor_with_encoding, out hierarchy, out itemID, out windowFrame); }
protected virtual /* for testing */ void OpenDocumentInVs(string filePath) { // TryOpenDocument calls several other VS services. From a testing point of view, it's simpler to // create a subclass and override this method. var viewType = Guid.Empty; VsShellUtilities.TryOpenDocument(serviceProvider, filePath, viewType, out var _, out var _, out var _); new NativeInterop().CloseRootWindow(win32Window); }