From da8aefc879e58250b3e821ce6440da1b8bf38c5b Mon Sep 17 00:00:00 2001 From: Tratter Sebastian Date: Tue, 6 Sep 2022 17:09:31 +0200 Subject: [PATCH] Add detection of sdk style projects in GodotSolutionListener.IsGodotProject() --- GodotAddinVS/GodotPackage.cs | 1 + GodotAddinVS/GodotSolutionEventsListener.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/GodotAddinVS/GodotPackage.cs b/GodotAddinVS/GodotPackage.cs index 975c78e..5c90b03 100644 --- a/GodotAddinVS/GodotPackage.cs +++ b/GodotAddinVS/GodotPackage.cs @@ -36,6 +36,7 @@ namespace GodotAddinVS [ProvideOptionPage(typeof(GeneralOptionsPage), "Godot", "General", 0, 0, true)] [ProvideMenuResource("Menus.ctmenu", 1)] + [ProvideAutoLoad(UIContextGuids80.NoSolution, PackageAutoLoadFlags.BackgroundLoad)] public sealed class GodotPackage : AsyncPackage { /// diff --git a/GodotAddinVS/GodotSolutionEventsListener.cs b/GodotAddinVS/GodotSolutionEventsListener.cs index 0d0be66..0bfb2af 100644 --- a/GodotAddinVS/GodotSolutionEventsListener.cs +++ b/GodotAddinVS/GodotSolutionEventsListener.cs @@ -3,11 +3,13 @@ using System.ComponentModel.Design; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using EnvDTE; using GodotAddinVS.Debugging; using GodotAddinVS.GodotMessaging; using GodotTools.IdeMessaging; using GodotTools.IdeMessaging.Requests; +using Microsoft.VisualStudio; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; @@ -67,6 +69,17 @@ private static IEnumerable ParseProjectTypeGuids(string projectTypeGuids) private static bool IsGodotProject(IVsHierarchy hierarchy) { ThreadHelper.ThrowIfNotOnUIThread(); + + hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out var objProj); + + const string csProjectKind = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"; + if (objProj is Project project && project.Kind == csProjectKind) + { + string csprojContent = File.ReadAllText(project.FileName); + Match match = Regex.Match(csprojContent, @"]*>"); + return match.Success; + } + return hierarchy is IVsAggregatableProject aggregatableProject && aggregatableProject.GetAggregateProjectTypeGuids(out string projectTypeGuids) == 0 && ParseProjectTypeGuids(projectTypeGuids)