diff options
author | Ignacio Roldán Etcheverry <ignalfonsore@gmail.com> | 2022-07-28 17:41:50 +0200 |
---|---|---|
committer | Ignacio Roldán Etcheverry <ignalfonsore@gmail.com> | 2022-08-22 03:36:52 +0200 |
commit | 3123be2384c14f7dd156b1cc2d53d822002b837a (patch) | |
tree | 34358a0c1b1e2555b8df0a5c346e20e4d9ff6645 /modules/mono/editor/GodotTools | |
parent | 344f5028d48d4a5caf321abdf023c34f52aae0a4 (diff) |
C#: Array, Dictionary and marshaling refactoring
- Array and Dictionary now store `Variant` instead of `System.Object`.
- Removed generic Array and Dictionary.
They cause too much issues, heavily relying on reflection and
very limited by the lack of a generic specialization.
- Removed support for non-Godot collections.
Support for them also relied heavily on reflection for marshaling.
Support for them will likely be re-introduced in the future, but
it will have to rely on source generators instead of reflection.
- Reduced our use of reflection.
The remaining usages will be moved to source generators soon.
The only usage that I'm not sure yet how to replace is dynamic
invocation of delegates.
Diffstat (limited to 'modules/mono/editor/GodotTools')
5 files changed, 14 insertions, 14 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs index f8a810fd44..3c5b897719 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs @@ -20,7 +20,7 @@ namespace GodotTools.Build public bool OnlyClean { get; private set; } // TODO Use List once we have proper serialization - public Array<string> CustomProperties { get; private set; } = new Array<string>(); + public Godot.Collections.Array CustomProperties { get; private set; } = new(); public string LogsDirPath => Path.Combine(GodotSharpDirs.BuildLogsDirs, $"{Solution.MD5Text()}_{Configuration}"); diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs index 38d2eefd02..a8128be909 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs @@ -1,7 +1,6 @@ using Godot; using System; using System.Diagnostics.CodeAnalysis; -using Godot.Collections; using GodotTools.Internals; using File = GodotTools.Utils.File; using Path = System.IO.Path; @@ -59,7 +58,7 @@ namespace GodotTools.Build } // TODO Use List once we have proper serialization. - private Array<BuildIssue> _issues = new Array<BuildIssue>(); + private Godot.Collections.Array _issues = new(); private ItemList _issuesList; private PopupMenu _issuesListContextMenu; private TextEdit _buildLog; @@ -129,12 +128,12 @@ namespace GodotTools.Build if (issueIndex < 0 || issueIndex >= _issues.Count) throw new IndexOutOfRangeException("Issue index out of range"); - BuildIssue issue = _issues[issueIndex]; + var issue = (BuildIssue)_issues[issueIndex]; if (string.IsNullOrEmpty(issue.ProjectFile) && string.IsNullOrEmpty(issue.File)) return; - string projectDir = issue.ProjectFile.Length > 0 ? + string projectDir = !string.IsNullOrEmpty(issue.ProjectFile) ? issue.ProjectFile.GetBaseDir() : _buildInfo.Solution.GetBaseDir(); @@ -163,7 +162,7 @@ namespace GodotTools.Build { for (int i = 0; i < _issues.Count; i++) { - BuildIssue issue = _issues[i]; + var issue = (BuildIssue)_issues[i]; if (!(issue.Warning ? WarningsVisible : ErrorsVisible)) continue; diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs index 506c0ec067..655be0ab5e 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs @@ -4,6 +4,7 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Diagnostics; using System.IO; +using System.Linq; using System.Text; using System.Threading.Tasks; using GodotTools.BuildLogger; @@ -156,9 +157,9 @@ namespace GodotTools.Build AddLoggerArgument(buildInfo, arguments); // Custom properties - foreach (string customProperty in buildInfo.CustomProperties) + foreach (var customProperty in buildInfo.CustomProperties) { - arguments.Add("-p:" + customProperty); + arguments.Add("-p:" + (string)customProperty); } } @@ -198,9 +199,9 @@ namespace GodotTools.Build AddLoggerArgument(buildInfo, arguments); // Custom properties - foreach (string customProperty in buildInfo.CustomProperties) + foreach (var customProperty in buildInfo.CustomProperties) { - arguments.Add("-p:" + customProperty); + arguments.Add("-p:" + (string)customProperty); } // Publish output directory diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index 362bb18b36..dcc3f3db76 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -481,9 +481,9 @@ namespace GodotTools _editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary { - ["type"] = Variant.Type.Int, + ["type"] = (int)Variant.Type.Int, ["name"] = "mono/editor/external_editor", - ["hint"] = PropertyHint.Enum, + ["hint"] = (int)PropertyHint.Enum, ["hint_string"] = settingsHintStr }); diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs index a62fe29e7e..60602a5847 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs @@ -30,9 +30,9 @@ namespace GodotTools.Ides.Rider Globals.EditorDef(EditorPathSettingName, "Optional"); editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary { - ["type"] = Variant.Type.String, + ["type"] = (int)Variant.Type.String, ["name"] = EditorPathSettingName, - ["hint"] = PropertyHint.File, + ["hint"] = (int)PropertyHint.File, ["hint_string"] = "" }); } |