summaryrefslogtreecommitdiff
path: root/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators
AgeCommit message (Collapse)Author
2023-04-04Bump version to 4.0.3-rcRémi Verschelde
2023-03-30Bump version to 4.0.2-rcRémi Verschelde
2023-03-27C#: Encode GodotProjectDir as Base64 to prevent issues with special charactersRaul Santos
(cherry picked from commit f949e949913205fe413377e2dc37b84552c523e0)
2023-03-13C#: Ignore explicit interface implementationsRaul Santos
(cherry picked from commit 0372bd56b69fd3a0f8efd6067deb30ee7a60e17d)
2023-03-01Bump version to 4.0.1-rcRémi Verschelde
2023-02-01Update ↵Treer
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs Co-authored-by: Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com>
2023-01-31Qualify Console's namespace to avoid mixup with plugin's objectsTreer
Avoid error when a plugin contains a class called "Console": Godot.SourceGenerators\Godot.SourceGenerators.GodotPluginsInitializerGenerator\GodotPlugins.Game.generated.cs(32,25): error CS0117: 'Console' does not contain a definition for 'Error'
2023-01-27C#: Rename `Object` to `GodotObject`Raul Santos
2023-01-27C#: Renames to follow .NET naming conventionsRaul Santos
Renamed C# types and members to use PascalCase and follow .NET naming conventions.
2023-01-27C#: Add global namespace to grouping property infoRaul Santos
2023-01-27Merge pull request #71356 from raulsntos/dotnet/getRémi Verschelde
C#: Lookup signals and methods in Get method
2023-01-26Merge pull request #72057 from raulsntos/dotnet/fix-must-be-variantRémi Verschelde
C#: Annotate API with `[MustBeVariant]`
2023-01-25C#: Skip documentation syntax in MustBeVariant analyzerRaul Santos
2023-01-24Add PROPERTY_USAGE_NEVER_DUPLICATE flag and use for scriptAaron Franke
Co-authored-by: Yakov Borevich <j.borevich@gmail.com>
2023-01-24PropertyUsage: Rename "DO_NOT_SHARE_ON_DUPLICATE" to "ALWAYS_DUPLICATE"Aaron Franke
2023-01-13C#: Lookup signals and methods in Get methodRaul Santos
Allows to retrieve `Callable`s and `Signal`s using `Get` like it works in GDScript.
2023-01-09Removed unused property hints and `Object::get_translatable_strings()`Juan Linietsky
* Remove unused `EditorPropertyMember` and related hints, previouly used by VisualScript. Such logic should be implemented in the VS module itself. * As the above broke compatibility with the VS module, clean up the other hacks that were still in core in support of VisualScript. * `PROPERTY_USAGE_INTERNATIONALIZED` was only used in Object's `get_translatable_strings()`, which is a legacy function not used anywhere. So both are removed. * Reordered some usage flags after the above removal to minimize the diff. * General clean up. Fixes #30203. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2022-12-28C#: Avoid generic types in the script path attribute generatorRaul Santos
- Avoid generic types in `ScriptPathAttributeGenerator`, this means they won't be added to the `[AssemblyHasScripts]` attribute and a `[ScriptPath]` attribute won't be added to the class. Since generic classes can't be used as scripts they shouldn't use those attributes, this also makes CSharpScript consider those types invalid since they won't be added to the script/type map. - Avoid generic types in `ScriptManagerBridge.LookupScriptsInAssembly`. - Set `outMethodsDest` in `ScriptManagerBridge.UpdateScriptClassInfo`.
2022-12-23Merge pull request #70486 from raulsntos/dotnet/convert-toIgnacio Roldán Etcheverry
C#: Rename `ConvertToX` methods
2022-12-23C#: Rename `ConvertToX` methodsRaul Santos
- Renamed `ConvertToX` to `ConvertToNativeX`. - Renamed `ConvertToXObject` to `ConvertToX`. - Renamed `ConvertToXManaged` to `ConvertToX`. - Fix `Signal` name in bindings generator and csharp script.
2022-12-23C#: Disallow init-only propertiesRaul Santos
ReadOnly properties are currently not allowed because the generated code needs to set them, this also apply to `init` properties because they need to be set after initialization.
2022-12-16Fix out of sync PropertyUsageFlags for csSilc Renew
2022-12-12C#: Rename SignalInfo to Signal and make awaitableRaul Santos
2022-12-11C#: Fix exported properties of GodotObject[] typeIgnacio Roldán Etcheverry
This was a regression from 17b2838f39c634324710166d2f36458906ecaf4a. `MarshalUtils` was changed in the source generators to use `ConvertTo<T>` and `CreateFrom<T>`, which don't support `GodotObject[]` because it would need reflection. As such, we need to keep the custom cases for `GodotObject[]` in `MarshalUtils`.
2022-12-02C#: Cleanup Variant marshaling code in source/bindings generatorsIgnacio Roldán Etcheverry
This change aims to reduce the number of places that need to be changed when adding or editing a Godot type to the bindings. Since the addition of `Variant.From<T>/As<T>` and `VariantUtils.CreateFrom<T>/ConvertTo<T>`, we can now replace a lot of the previous code in the bindings generator and the source generators that specify these conversions for each type manually. The only exceptions are the generic Godot collections (`Array<T>` and `Dictionary<TKey, TValue>`) which still use the old version, as that one cannot be matched by our new conversion methods (limitation in the language with generics, forcing us to use delegate pointers). The cleanup applies to: - Bindings generator: - `TypeInterface.cs_variant_to_managed` - `TypeInterface.cs_managed_to_variant` - Source generators: - `MarshalUtils.AppendNativeVariantToManagedExpr` - `MarshalUtils.AppendManagedToNativeVariantExpr` - `MarshalUtils.AppendVariantToManagedExpr` - `MarshalUtils.AppendManagedToVariantExpr`
2022-12-02C#: Replace most conversions between Variant and System.ObjectIgnacio Roldán Etcheverry
This commit replaces most usages of `ConvertManagedObjectToVariant` and `ConvertVariantToManagedObjectOfType`, by using the `Godot.Variant` struct instead of `System.Object`. The most notable change is to the `GetGodotPropertyDefaultValues` method that's generated for scripts. The dictionary it returns now stores `Godot.Variant` values. Remaining usages are: - The `DelegateUtils` class, for the serialization of closure display classes during assembly reloading by the editor. These display classes are compiler generated classes to store values captured by a closure. Since it's generated by the compiler, the only way we have to access the fields is through reflection. This leads to using `System.Object`. - Converting parameters when invoking constructors from the engine. This will be replaced with source generators in the future. - Legacy support for old `GetGodotPropertyDefaultValues` return values. We need to keep supporting the old version of this generated method for some time. Otherwise, if loading a project built with the previous version, it could lead to the loss of exported property values. Ideally, we should remove this legacy support before a stable release.
2022-11-29Remove unnecessary namespaces in generated PropertyDefVal files.R. Alex Hofer
2022-11-28Merge pull request #65907 from magian1127/4.0FixPropertiesGeneratorIgnacio Roldán Etcheverry
C#: Fix Generated ScriptProperty Error.
2022-11-27C#: Fix Generated ScriptProperty Error.Magian
1. Add "this." to prevent errors caused by duplicate variable names. 2. Try to find the default value of property getters.
2022-11-26C#: Add `global::` namespace to generated sourceRaul Santos
Adds `global::` to the fully qualified types in source generators to prevent ambiguity.
2022-11-23Merge pull request #68580 from rhofour/fix-source-generationRémi Verschelde
First attempt at fully qualifying the default values of C# properties.
2022-11-22Fully qualify C# default values in exported fields.R. Alex Hofer
This avoids issues when the default values rely on using namespaces.
2022-11-19Merge pull request #68866 from raulsntos/dotnet/godot-enumsRémi Verschelde
C#: Synchronize Godot enums with core
2022-11-19C#: Synchronize Godot enums with coreRaul Santos
2022-11-14Add `readonly` to C# methods and types that don't mutateRaul Santos
Also removes a few unnecessary temp variables
2022-10-30C#: Remove need for reflection to invoking callable delegatesIgnacio Roldán Etcheverry
We aim to make the C# API reflection-free, mainly for concerns about performance, and to be able to target NativeAOT in refletion-free mode, which reduces the binary size. One of the main usages of reflection still left was the dynamic invokation of callable delegates, and for some time I wasn't sure I would find an alternative solution that I'd be happy with. The new solution uses trampoline functions to invoke the delegates: ``` static void Trampoline(object delegateObj, NativeVariantPtrArgs args, out godot_variant ret) { if (args.Count != 1) throw new ArgumentException($"Callable expected 1 arguments but received {args.Count}."); string res = ((Func<int, string>)delegateObj)( VariantConversionCallbacks.GetToManagedCallback<int>()(args[0]) ); ret = VariantConversionCallbacks.GetToVariantCallback<string>()(res); } Callable.CreateWithUnsafeTrampoline((int num) => "Foo" + num, &Trampoline); ``` Of course, this is too much boilerplate for user code. To improve this, the `Callable.From` methods were added. These are overloads that take `Action` and `Func` delegates, which covers the most common use cases: lambdas and method groups: ``` // Lambda Callable.From((int num) => "Foo" + num); // Method group string AppendNum(int num) => "Foo" + num; Callable.From(AppendNum); ``` Unfortunately, due to limitations in the C# language, implicit conversions from delegates to `Callable` are not supported. `Callable.From` does not support custom delegates. These should be uncommon, but the Godot C# API actually uses them for event signals. As such, the bindings generator was updated to generate trampoline functions for event signals. It was also optimized to use `Action` instead of a custom delegate for parameterless signals, which removes the need for the trampoline functions for those signals. The change to reflection-free invokation removes one of the last needs for `ConvertVariantToManagedObjectOfType`. The only remaining usage is from calling script constructors with parameters from the engine (`CreateManagedForGodotObjectScriptInstance`). Once that one is made reflection-free, `ConvertVariantToManagedObjectOfType` can be removed.
2022-10-22Use `.generated` suffix for generated C# codeRaul Santos
Use the `.generated` suffix instead of `_Generated` so .NET marks C# file generated by Godot source generators as generated code.
2022-09-30Fix typos with codespellRémi Verschelde
Using codespell 2.3-dev from current git. And fix typo in `methods.py` for `vsproj=yes` option (still won't work though).
2022-09-22Merge pull request #66253 from raulsntos/dotnet/assembly-may-be-nullIgnacio Roldán Etcheverry
C#: Guard against null assemblies
2022-09-22C#: Suppress EventHandler suffix diagnostic for signalsRaul Santos
Suppress CA1711 for signal delegates because they are used in events so the naming follows the guidelines.
2022-09-22C#: Guard against null assembliesRaul Santos
A symbol's containing assembly will be null if the symbol is shared across multiple assemblies.
2022-09-19Merge pull request #65879 from magian1127/4.0GenSDocRémi Verschelde
inheritdoc the "///" comment from EventHandler to the generated event
2022-09-18C#: inheritdoc the "///" comment from EventHandler to the generated eventMagian
2022-09-17don't marshal multidimensional arraysantonWetzel
2022-09-06Merge pull request #65433 from neikeq/fix-mustbevariant-omittedtypeargRémi Verschelde
2022-09-06C#: Make MustBeVariantAnalyzer ignore OmittedTypeArgumentIgnacio Roldán Etcheverry
Fixes assertion error in the analyzer.
2022-09-06C# Modify the MemberName generated for the user scriptMagian
2022-08-29C#: Fix exported game crash because of uninitialized callbacksIgnacio Roldán Etcheverry
This was a regression from 2c180f62d985194060f1a8d2070c130081177c90, where I forgot to update the source generator.
2022-08-29Merge pull request #64900 from raulsntos/dotnet/fix-exceptionsIgnacio Roldán Etcheverry
Fix various C# exceptions
2022-08-28C#: Ignore property indexers and report if exportedRaul Santos
Ignore property indexers since they are unsupported and report a diagnostic if an user tries to export it.