summaryrefslogtreecommitdiff
path: root/modules/mono/editor/GodotTools
AgeCommit message (Collapse)Author
2022-10-07[.NET Export] Improve .NET export process.bruvzg
[macOS export] Fix incorrect file placement, search paths and architecture detection. [macOS export] Automatically detect executable files and set +x flag. [macOS export] Automatically apply "Disable Library Validation" entitlements when required. [macOS export] Remove old Mono export code. Fix folder tree creation for shared objects export. Add arch suffix to the exported .NET "data" folder name. Remove old Mono code from .NET "data" folder lookup.
2022-09-19Replace File/Directory with FileAccess/DirAccesskobewi
2022-09-15Fix NuGet fallback folder packagesRaul Santos
- Creates a `Godot.Offline.Config` file to configurate NuGet with Godot's fallback folder. This is easier because now we can assume we can override the entire file since user config will likely be in the default `NuGet.Config` file or an additional `*.config` file. - Ensure the NuGet fallback folder is created at the same time it is added to the NuGet configuration so future builds don't fail. - Add `GodotSharp` and `GodotSharpEditor` packages to the fallback folder. - Add `.nupkg.metadata` file to packages in fallback folder. - Refer to `Godot.SourceGenerators` using the specific non-floating version since floating versions don't seem to work with fallbackPackageFolders.
2022-09-14[macOS, .NET] Fix dotnet binary detection.bruvzg
2022-09-08Make `Vector2i` values paired with `EDSCALE` be just `Vector2`Michael Alexsander
2022-09-01C#: Assume 64-bit types when type has no metaRaul Santos
When the C# bindings generator finds a type without meta assume the type refers to the 64-bit version of the type: - `float` is converted to `double` - `int` is converted to `long`
2022-08-29Merge pull request #64987 from raulsntos/dotnet/linux-exportIgnacio Roldán Etcheverry
Fix .NET exporting in Linux
2022-08-29[Web] Rename JavaScript platform to Web.Fabio Alessandrelli
Also rename export name from "HTML5" to "Web".
2022-08-29Merge pull request #64956 from raulsntos/dotnet/format-ciRémi Verschelde
Add `dotnet format` to CI to check C# style
2022-08-29Merge pull request #64900 from raulsntos/dotnet/fix-exceptionsIgnacio Roldán Etcheverry
Fix various C# exceptions
2022-08-28Fix .NET exporting in LinuxRaul Santos
- Fix platform detection after Linux OS name was renamed from `LinuxBSD` to `Linux` - Fix arch detection after renaming `64` to `x86_64` - Fix typo in `find_hostfxr`
2022-08-27Fix C# style with `dotnet format`Raul Santos
2022-08-27Rename `hint_tooltip` to `tooltip_text` & setgetMicky
`hint_tooltip` -> `tooltip_text` `set_tooltip` -> `set_tooltip_text` `_get_tooltip` -> `get_tooltip_text` Updates documentation, too.
2022-08-26Fix various C# exceptionsRaul Santos
- Replace `IndexOutOfRangeException` with `ArgumentOutOfRangeException` - Replace `Exception` with a more specific exception - Add the parameter name to argument exception - Update documentation for methods that throw exceptions - Use `StringBuilder` to build exception messages - Ensure exception messages end with a period
2022-08-26Merge pull request #64901 from raulsntos/dotnet/equalsIgnacio Roldán Etcheverry
C#: Use pattern matching to simplify `Equals`
2022-08-25Various C# documentation improvementsRaul Santos
Fixes wrong/invalid documentation and add documentation to some OS members.
2022-08-25Unify bits, arch, and android_arch into env["arch"]Aaron Franke
Fully removes the `bits` option and adapts the code that relied on it. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2022-08-24Remove mentions of the Server platform from the Mono moduleAaron Franke
2022-08-24Use pattern matching to simplify `Equals`Raul Santos
- Simplify and unify `Equals` implementation of C# struct types - Also add pattern matching to replace a cast in `DebuggingUtils`
2022-08-22C#: Replace P/Invoke with delegate pointersIgnacio Roldán Etcheverry
- Moves interop functions to UnmanagedCallbacks struct that contains the function pointers and is passed to C#. - Implements UnmanagedCallbacksGenerator, a C# source generator that generates the UnmanagedCallbacks struct in C# and the body for the NativeFuncs methods (their implementation just calls the function pointer in the UnmanagedCallbacks). The generated methods are needed because .NET pins byref parameters of native calls, even if they are 'ref struct's, which don't need pinning. The generated methods use `Unsafe.AsPointer` so that we can benefit from byref parameters without suffering overhead of pinning. Co-authored-by: Raul Santos <raulsntos@gmail.com>
2022-08-22C#: Use custom project setting for C# project files nameIgnacio Roldán Etcheverry
The setting is initially assigned the name of the Godot project, but it's kept freezed to prevent issues when renaming the Godot project. The user can always rename the C# project and solution manually and change the setting to the new name.
2022-08-22C#: Re-introduce generic Godot Array and DictionaryIgnacio Roldán Etcheverry
This new version does not support the following type arguments: - Generic types - Array of Godot Object (Godot.Object[]) or derived types The new implementation uses delegate pointers to call the Variant conversion methods. We do type checking only once in the static constructor to get the conversion delegates. Now, we no longer need to do type checking every time, and we no longer have to box value types. This is the best implementation I could come up with, as C# generics don't support anything similar to C++ template specializations.
2022-08-22C#: Array, Dictionary and marshaling refactoringIgnacio Roldán Etcheverry
- 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.
2022-08-22C#: Add dedicated Variant struct, replacing System.ObjectIgnacio Roldán Etcheverry
2022-08-22C#: Add source generator for signals as eventsIgnacio Roldán Etcheverry
Changed the signal declaration signal to: ``` // The following generates a MySignal event [Signal] public delegate void MySignalEventHandler(int param); ```
2022-08-22C#: Re-implement assembly reloading with ALCsIgnacio Roldán Etcheverry
2022-08-22C#: Initial NativeAOT supportIgnacio Roldán Etcheverry
This commit adds initial support for games exported as NativeAOT shared libraries. At this moment, the NativeAOT runtime is experimental. Additionally, Godot is not trim-safe as it still makes some use of reflection. For the time being, a rd.xml file is needed to prevent code triming: ``` <Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata"> <Application> <Assembly Name="GodotSharp" Dynamic="Required All" /> <Assembly Name="GAME_ASSEMBLY" Dynamic="Required All" /> </Application> </Directives> ``` These are the csproj changes for publishing: ``` <PropertyGroup> <NativeLib>Shared</NativeLib> </PropertyGroup> <ItemGroup> <RdXmlFile Include="rd.xml" /> <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="7.0.0-*" /> </ItemGroup> ``` More info: - https://github.com/dotnet/runtimelab/blob/feature/NativeAOT/docs/using-nativeaot/compiling.md - https://github.com/dotnet/runtimelab/tree/feature/NativeAOT/samples/NativeLibrary - https://github.com/dotnet/runtimelab/blob/feature/NativeAOT/docs/using-nativeaot/rd-xml-format.md
2022-08-22C#: Upgrade to .NET 6 (5.0 -> 6.0)Ignacio Roldán Etcheverry
2022-08-22C#: Static marshaling for bindings and source generatorsIgnacio Roldán Etcheverry
Previously, we added source generators for invoking/accessing methods, properties and fields in scripts. This freed us from the overhead of reflection. However, the generated code still used our dynamic marshaling functions, which do runtime type checking and box value types. This commit changes the bindings and source generators to include 'static' marshaling. Based on the types known at compile time, now we generate the appropriate marshaling call for each type.
2022-08-22C#: Add source generator for properties and exports default valuesIgnacio Roldán Etcheverry
The editor no longer needs to create temporary instances to get the default values. The initializer values of the exported properties are still evaluated at runtime. For example, in the following example, `GetInitialValue()` will be called when first looks for default values: ``` [Export] int MyValue = GetInitialValue(); ``` Exporting fields with a non-supported type now results in a compiler error rather than a runtime error when the script is used.
2022-08-22C#/netcore: Add base desktop game export implementationIgnacio Roldán Etcheverry
This base implementation is still very barebones but it defines the path for how exporting will work (at least when embedding the .NET runtime). Many manual steps are still needed, which should be automatized in the future. For example, in addition to the API assemblies, now you also need to copy the GodotPlugins assembly to each game project.
2022-08-22C#: Code cleanup and greatly reduce use of C# pointersIgnacio Roldán Etcheverry
2022-08-22C#: Begin move to .NET CoreIgnacio Roldán Etcheverry
We're targeting .NET 5 for now to make development easier while .NET 6 is not yet released. TEMPORARY REGRESSIONS --------------------- Assembly unloading is not implemented yet. As such, many Godot resources are leaked at exit. This will be re-implemented later together with assembly hot-reloading.
2022-08-22C#: Restructure code prior move to .NET CoreIgnacio Roldán Etcheverry
The main focus here was to remove the majority of code that relied on Mono's embedding APIs, specially the reflection APIs. The embedding APIs we still use are the bare minimum we need for things to work. A lot of code was moved to C#. We no longer deal with any managed objects (`MonoObject*`, and such) in native code, and all marshaling is done in C#. The reason for restructuring the code and move away from embedding APIs is that once we move to .NET Core, we will be limited by the much more minimal .NET hosting. PERFORMANCE REGRESSIONS ----------------------- Some parts of the code were written with little to no concern about performance. This includes code that calls into script methods and accesses script fields, properties and events. The reason for this is that all of that will be moved to source generators, so any work prior to that would be a waste of time. DISABLED FEATURES ----------------- Some code was removed as it no longer makes sense (or won't make sense in the future). Other parts were commented out with `#if 0`s and TODO warnings because it doesn't make much sense to work on them yet as those parts will change heavily when we switch to .NET Core but also when we start introducing source generators. As such, the following features were disabled temporarily: - Assembly-reloading (will be done with ALCs in .NET Core). - Properties/fields exports and script method listing (will be handled by source generators in the future). - Exception logging in the editor and stack info for errors. - Exporting games. - Building of C# projects. We no longer copy the Godot API assemblies to the project directory, so MSBuild won't be able to find them. The idea is to turn them into NuGet packages in the future, which could also be obtained from local NuGet sources during development.
2022-08-22C#: Move marshaling logic and generated glue to C#Ignacio Roldán Etcheverry
We will be progressively moving most code to C#. The plan is to only use Mono's embedding APIs to set things at launch. This will make it much easier to later support CoreCLR too which doesn't have rich embedding APIs. Additionally the code in C# is more maintainable and makes it easier to implement new features, e.g.: runtime codegen which we could use to avoid using reflection for marshaling everytime a field, property or method is accessed. SOME NOTES ON INTEROP We make the same assumptions as GDNative about the size of the Godot structures we use. We take it a bit further by also assuming the layout of fields in some cases, which is riskier but let's us squeeze out some performance by avoiding unnecessary managed to native calls. Code that deals with native structs is less safe than before as there's no RAII and copy constructors in C#. It's like using the GDNative C API directly. One has to take special care to free values they own. Perhaps we could use roslyn analyzers to check this, but I don't know any that uses attributes to determine what's owned or borrowed. As to why we maily use pointers for native structs instead of ref/out: - AFAIK (and confirmed with a benchmark) ref/out are pinned during P/Invoke calls and that has a cost. - Native struct fields can't be ref/out in the first place. - A `using` local can't be passed as ref/out, only `in`. Calling a method or property on an `in` value makes a silent copy, so we want to avoid `in`. REGARDING THE BUILD SYSTEM There's no longer a `mono_glue=yes/no` SCons options. We no longer need to build with `mono_glue=no`, generate the glue and then build again with `mono_glue=yes`. We build only once and generate the glue (which is in C# now). However, SCons no longer builds the C# projects for us. Instead one must run `build_assemblies.py`, e.g.: ```sh %godot_src_root%/modules/mono/build_scripts/build_assemblies.py \ --godot-output-dir=%godot_src_root%/bin \ --godot-target=release_debug` ``` We could turn this into a custom build target, but I don't know how to do that with SCons (it's possible with Meson). OTHER NOTES Most of the moved code doesn't follow the C# naming convention and still has the word Mono in the names despite no longer dealing with Mono's embedding APIs. This is just temporary while transitioning, to make it easier to understand what was moved where.
2022-08-08Avoid paths with invalid characters in `IsRider`Raul Santos
2022-07-22Rename directory for export templates from templates to export_templatesAaron Franke
2022-07-21Rename OSX to macOS and iPhoneOS to iOS.bruvzg
2022-07-07Ensure NuGet.config directory existsRaul Santos
2022-06-24Merge pull request #59918 from ↵Rémi Verschelde
piiertho/enhancement/rename-controll-minimum_size-to-custom_minimum_size
2022-06-23enhancement: rename exposed property Control::minimum_size to ↵Pierre-Thomas Meisels
Control::custom_minimum_size
2022-06-23Mono: Update Newtonsoft.Json to 13.0.1Rémi Verschelde
See https://github.com/advisories/GHSA-5crp-9r3c-p9vr
2022-05-12Fix blank command prompts spawningJulian Mills
prevent certain mono actions from displaying empty command prompts.
2022-05-06Changed signals of ItemListVitika9
2022-03-16Implement GDExtension export plugin.bruvzg
2022-03-08Rename Control's Rect properties to exclude rect_ partMarcel Admiraal
2022-02-08Remove support for ARMv7 (32-bit) on iOSHugo Locurcio
All iOS devices since the iPhone 5S support ARMv8 (64-bit). The last iOS version supported on ARMv7 devices is 10.x, which is too old to run Godot 4.0 projects since the minimum supported iOS version is 11.0.
2022-02-04Fixed opening new instances of VS 2022 while a instance is already openDensorius
2022-02-04Add Visual Studio 2022 support with fallback to 2019Densorius
2022-01-23BaseButton: Rename `pressed` property to `button_pressed`Rémi Verschelde
This fixes a conflict with the `pressed` signal. The new name is temporary and only intended to solve the conflict for upcoming alpha builds. Discussions are still ongoing regarding the BaseButton API and how to rename and refactor more of its properties, signals and methods to have a clearer API in 4.0.