summaryrefslogtreecommitdiffstats
path: root/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectExtensions.cs
diff options
context:
space:
mode:
authorIgnacio Etcheverry <ignalfonsore@gmail.com>2019-07-03 09:44:53 +0200
committerIgnacio Etcheverry <ignalfonsore@gmail.com>2019-07-05 09:38:23 +0200
commit270af6fa089ccfb93ace68ada8d476bd902b10fa (patch)
treefee771a4f58a8d799f70d37547391831f52b5cd2 /modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectExtensions.cs
parent7b569e91c0c6b84965cad416b8e86dcfdacbcfc4 (diff)
downloadredot-engine-270af6fa089ccfb93ace68ada8d476bd902b10fa.tar.gz
Re-write mono module editor code in C#
Make the build system automatically build the C# Api assemblies to be shipped with the editor. Make the editor, editor player and debug export templates use Api assemblies built with debug symbols. Always run MSBuild to build the editor tools and Api assemblies when building Godot. Several bugs fixed related to assembly hot reloading and restoring state. Fix StringExtensions internal calls not being registered correctly, resulting in MissingMethodException.
Diffstat (limited to 'modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectExtensions.cs')
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectExtensions.cs61
1 files changed, 61 insertions, 0 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectExtensions.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectExtensions.cs
new file mode 100644
index 0000000000..36961eb45e
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectExtensions.cs
@@ -0,0 +1,61 @@
+using GodotTools.Core;
+using System;
+using DotNet.Globbing;
+using Microsoft.Build.Construction;
+
+namespace GodotTools.ProjectEditor
+{
+ public static class ProjectExtensions
+ {
+ public static bool HasItem(this ProjectRootElement root, string itemType, string include)
+ {
+ GlobOptions globOptions = new GlobOptions();
+ globOptions.Evaluation.CaseInsensitive = false;
+
+ string normalizedInclude = include.NormalizePath();
+
+ foreach (var itemGroup in root.ItemGroups)
+ {
+ if (itemGroup.Condition.Length != 0)
+ continue;
+
+ foreach (var item in itemGroup.Items)
+ {
+ if (item.ItemType != itemType)
+ continue;
+
+ var glob = Glob.Parse(item.Include.NormalizePath(), globOptions);
+
+ if (glob.IsMatch(normalizedInclude))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public static bool AddItemChecked(this ProjectRootElement root, string itemType, string include)
+ {
+ if (!root.HasItem(itemType, include))
+ {
+ root.AddItem(itemType, include);
+ return true;
+ }
+
+ return false;
+ }
+
+ public static Guid GetGuid(this ProjectRootElement root)
+ {
+ foreach (var property in root.Properties)
+ {
+ if (property.Name == "ProjectGuid")
+ return Guid.Parse(property.Value);
+ }
+
+ return Guid.Empty;
+ }
+ }
+}