summaryrefslogtreecommitdiff
path: root/modules
AgeCommit message (Collapse)Author
2022-08-22C#: Ensure we only create one CSharpScript per typeIgnacio Roldán Etcheverry
Previously, for each scripts class instance that was created from code rather than by the engine, we were constructing, configuring and assigning a new CSharpScript. This has changed now and we make sure there's only one CSharpScript associated to 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#: Ensure native handles are freed after switch to .NET CoreIgnacio Roldán Etcheverry
Finalizers are longer guaranteed to be called on exit now that we switched to .NET Core. This results in native instances leaking. The only solution I can think of so far is to keep a list of all instances alive to dispose when the AssemblyLoadContext.Unloading event is raised.
2022-08-22C#: Add initial implementation of source generator for script membersIgnacio Roldán Etcheverry
This replaces the way we invoke methods and set/get properties. This first iteration rids us of runtime type checking in those cases, as it's now done at compile time. Later it will also stop needing the use of reflection. After that, we will only depend on reflection for generic Godot Array and Dictionary. We're stuck with reflection in generic collections for now as C# doesn't support generic/template specialization. This is only the initial implementation. Further iterations are coming, specially once we switch to the native extension system which completely changes the way members are accessed/invoked. For example, with the native extension system we will likely need to create `UnmanagedCallersOnly` invoke wrapper methods and return function pointers to the engine. Other kind of members, like event signals will be receiving the same treatment in the future.
2022-08-22C#: Code cleanup and greatly reduce use of C# pointersIgnacio Roldán Etcheverry
2022-08-22Fix detection of .NET Sdk from snap and allow higher versionsIgnacio Roldán Etcheverry
2022-08-22C#: Fallback to `dotnet --info` to determine .NET RIDIgnacio Roldán Etcheverry
Some Linux distros use their distro name as the RID for directory names. If the .NET Host directory cannot be found with the generic RID, try to get the rid from `dotnet --info`. The generic RID should still be the first choice. Some platforms like Windows 10 define the RID as `win10-x64` but still use the generic `win-x64` for directory names. Co-authored-by: Lewis James <lewiji+github@gmail.com>
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#: Re-write GD and some other icalls as P/InvokeIgnacio Roldán Etcheverry
2022-08-22C#: Re-write Array, Dictionary, NodePath, String icalls as P/InvokeIgnacio Roldán Etcheverry
2022-08-22C#: Remove DynamicGodotObject/Object.DynamicObjectIgnacio Roldán Etcheverry
We are moving in the direction of no dynamic code generation, so this is no longer desired. The feature can still be easily implemented by any project that still want it.
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-20Merge pull request #64170 from YuriSizov/docs-annotations-in-technicolorMax Hilbrunner
Add documentation for all annotations
2022-08-19Merge pull request #64334 from YuriSizov/core-bind-property-revert-methodsYuri Sizov
Make `property_*_revert` methods multilevel and expose them for scripting
2022-08-19Add documentation for all annotationsYuri Sizov
2022-08-19Merge pull request #63326 from MewPurPur/binary-highlighting-fixMax Hilbrunner
Fix highlighting of multiple operators
2022-08-18Merge pull request #64156 from bruvzg/sys_msdfClay John
Allow MSDF rendering for system fonts, fix crash on loading damaged / unsupported font files.
2022-08-18Make `property_*_revert` methods multilevel and expose them for scriptingYuri Sizov
2022-08-15Improve the `make_rst.py` parser for BBCode tagsYuri Sizov
2022-08-14Document GLTFLight and GLTFSpecGlossAaron Franke
2022-08-14Improve binary operator highlightingVolTer
2022-08-10Merge pull request #62934 from Xwdit/script_doc_arg_def_varRémi Verschelde
2022-08-10Merge pull request #63015 from Xwdit/fix_gds_editor_tooltip_arg_typeRémi Verschelde
2022-08-10Merge pull request #63020 from Xwdit/fix_gds_editor_tooltip_return_typeRémi Verschelde
2022-08-10Merge pull request #64169 from hakro/fix-gltf-animations-always-importedRémi Verschelde
2022-08-10Fix script documentation method argument default valuesXwdit
Co-Authored-By: Rémi Verschelde <rverschelde@gmail.com>
2022-08-10Fixed incorrect type display of function argument in GDScript editor tooltipsXwdit
2022-08-10Fixed incorrect type display of void return in GDScript editor tooltipsXwdit
2022-08-10Merge pull request #64206 from Chaosus/gds_fixRémi Verschelde
2022-08-10Merge pull request #64188 from YeldhamDev/gridmap_item_fixRémi Verschelde
2022-08-10Prevent AnimationPlayer from being added on GLTF import if the option is ↵Hakim
unchecked. Fixes #63954
2022-08-10Prevent global functions from overriding completion of subscriptYuri Rubinsky
2022-08-09Fix error when switching to another `GridMap` with an item with higher index ↵Michael Alexsander
selected
2022-08-09Allow MSDF rendering for system fonts, fix crash on loading damaged / ↵bruvzg
unsupported font files.
2022-08-09vector4 distance_squared_to and update csharpantonWetzel
2022-08-08Merge pull request #64099 from A-Lamia/lsp_uri_path_fixesRémi Verschelde
2022-08-08Rename the argument tag to param in XML documentationYuri Sizov
2022-08-08Merge pull request #64076 from raulsntos/doc-fixesRémi Verschelde
Add `@GDScript.type_exists` documentation, Fix typo in weakref documentation
2022-08-08Merge pull request #64004 from YuriSizov/doctool-fail-on-unnamed-argsRémi Verschelde
Add checks and tests for empty/unnamed arguments
2022-08-08Merge pull request #63932 from smix8/navigation_heightmapshape_baking_4.xRémi Verschelde
2022-08-08Add `@GDScript.type_exists` documentationRaul Santos
2022-08-08Add tests for empty/unnamed arguments to ClassDB, Variant, GDScriptYuri Sizov
2022-08-08fix: modifies workspace->root_uri so that p_uri is symmetrical to other ↵Lamia
operating systems. #63388
2022-08-08Merge pull request #64085 from raulsntos/fix-rider-checkRémi Verschelde
2022-08-08Merge pull request #64046 from ↵Rémi Verschelde
AntonioDell/bugfix/63715-infer-preloaded-const-types
2022-08-08Avoid paths with invalid characters in `IsRider`Raul Santos
2022-08-07Various fixes to C# documentationRaul Santos
2022-08-07fix(gdscript): Infer type from preload constAntonio Dell'Annunziata
When resolving the type of the attribute from the variant, the result_type.kind was overritten for no reason. It is assumed that this only needs to be done, if the variant value is not valid to have any kind here. Solves #63715