Commit graph

589 commits

Author SHA1 Message Date
Rémi Verschelde
124594593f
Merge pull request #68580 from rhofour/fix-source-generation
First attempt at fully qualifying the default values of C# properties.
2022-11-23 17:19:26 +01:00
R. Alex Hofer
6ab93bd919 Fully qualify C# default values in exported fields.
This avoids issues when the default values rely on using
namespaces.
2022-11-22 18:10:34 -05:00
Rémi Verschelde
52c51563fd
Merge pull request #68866 from raulsntos/dotnet/godot-enums
C#: Synchronize Godot enums with core
2022-11-19 09:40:05 +01:00
Raul Santos
792e618749
C#: Synchronize Godot enums with core 2022-11-19 01:54:23 +01:00
Raul Santos
71df6d66ae
Add readonly to C# methods and types that don't mutate
Also removes a few unnecessary temp variables
2022-11-14 20:32:20 +01:00
Rémi Verschelde
5947f22be9
Merge pull request #67578 from KoBeWi/GEDITOR
Unify usage of GLOBAL/EDITOR_GET
2022-10-31 13:15:58 +01:00
Ignacio Roldán Etcheverry
282bd37e5c C#: Remove need for reflection to invoking callable delegates
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-30 01:24:15 +02:00
Raul Santos
687633e5bd
Use .generated suffix for generated C# code
Use the `.generated` suffix instead of `_Generated` so .NET marks C#
file generated by Godot source generators as generated code.
2022-10-22 23:13:52 +02:00
kobewi
e48c5daddf Unify usage of GLOBAL/EDITOR_GET 2022-10-18 19:01:48 +02:00
Raul Santos
333f88dc49
Guard against more potential conflicts in C# bindings generator 2022-10-15 12:47:10 +02:00
bruvzg
6daf4c6593
[.NET Export] Improve .NET export process.
[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-10-07 13:33:06 +03:00
Aaron Franke
2cea42cc7f
Rename Projection matrix to columns 2022-10-04 12:34:19 -05:00
Rémi Verschelde
166df0896c Fix typos with codespell
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-30 14:23:36 +02:00
Ignacio Roldán Etcheverry
62792eeb9f
Merge pull request #66253 from raulsntos/dotnet/assembly-may-be-null
C#: Guard against null assemblies
2022-09-22 18:24:31 +02:00
Raul Santos
24ac82e235
C#: Suppress EventHandler suffix diagnostic for signals
Suppress CA1711 for signal delegates because they are used in events so
the naming follows the guidelines.
2022-09-22 14:23:01 +02:00
Raul Santos
f6d60764d3
C#: Guard against null assemblies
A symbol's containing assembly will be null if the symbol is shared
across multiple assemblies.
2022-09-22 12:41:38 +02:00
kobewi
9f2dc68279 Replace File/Directory with FileAccess/DirAccess 2022-09-19 11:03:31 +02:00
Rémi Verschelde
956ea15e81 Merge pull request #65879 from magian1127/4.0GenSDoc
inheritdoc the "///" comment from EventHandler to the generated event
2022-09-19 09:23:05 +02:00
Magian
4bd7c63669 C#: inheritdoc the "///" comment from EventHandler to the generated event 2022-09-18 23:08:22 +08:00
Rémi Verschelde
e5594c26b1
Merge pull request #44143 from KoBeWi/callable_multiplayer 2022-09-18 13:47:04 +02:00
Tomasz Chabora
882a4f8906 Port remaining connections to callable_mp 2022-09-18 13:08:54 +02:00
Rémi Verschelde
ee39c68d4f Merge pull request #65946 from antonWetzel/csharp-nd-array
Don't marshal multidimensional arrays
2022-09-18 00:42:50 +02:00
antonWetzel
5090355907 don't marshal multidimensional arrays 2022-09-17 00:18:08 +02:00
Raul Santos
70b4533c47
C#: Add documentation to signal delegates 2022-09-16 09:56:59 +02:00
Ignacio Roldán Etcheverry
d39d462907
Merge pull request #65823 from raulsntos/dotnet/signal-docs
C#: Move signal documentation to the event
2022-09-15 18:37:12 +02:00
Raul Santos
a5ffd25292
C#: Move signal documentation to the event
Move signal documentation from the delegate to the event and also
deprecate the event if the signal is deprecated.
2022-09-15 13:24:41 +02:00
Raul Santos
02bd0724f5
Fix NuGet fallback folder packages
- 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-15 09:28:59 +02:00
bruvzg
f4f556d198
[macOS, .NET] Fix dotnet binary detection. 2022-09-14 18:31:52 +03:00
Rémi Verschelde
c909120b59
Merge pull request #64373 from YeldhamDev/edscale_likes_them_floaty 2022-09-09 09:07:53 +02:00
Raul Santos
f63cfc12c5
Fix MacOS compiler flags in .NET module 2022-09-08 23:29:01 +02:00
Michael Alexsander
c4c9e41073 Make Vector2i values paired with EDSCALE be just Vector2 2022-09-08 14:46:32 -03:00
Rémi Verschelde
6b92dbfce2 Merge pull request #65438 from neikeq/replace-libnethost-dependency
Replace libnethost dependency to find hostfxr
2022-09-07 17:55:07 +02:00
Ignacio Roldán Etcheverry
f784fb2000 C#: Replace libnethost dependency to find hostfxr
We want to replace libnethost as it gives us issues with some compilers.
Our implementation tries to mimic libnethost's hostfxr_resolver search
logic. We try to use the same function names for easier comparing in
case we need to update this in the future.
2022-09-07 16:36:36 +02:00
Rémi Verschelde
432c4c40a9
Merge pull request #65433 from neikeq/fix-mustbevariant-omittedtypearg 2022-09-06 21:41:53 +02:00
Ignacio Roldán Etcheverry
3666e9fcd0 C#: Make MustBeVariantAnalyzer ignore OmittedTypeArgument
Fixes assertion error in the analyzer.
2022-09-06 18:51:45 +02:00
Magian
4448859ead C# Modify the MemberName generated for the user script 2022-09-06 20:43:40 +08:00
Rémi Verschelde
6c818da55e
Merge pull request #65321 from rburing/physics_server_2d_extension
Create GDExtension classes for PhysicsServer2D
2022-09-05 12:44:58 +02:00
Ricardo Buring
d22ff48b3d Create GDExtension classes for PhysicsServer2D
This allows a 2D physics server created entirely from GDExtension.
Based on the structure of PhysicsServer3DExtension by reduz.
2022-09-04 12:04:08 +02:00
Almighty Laxz
c71b78bbb8 Add float arg to build_assemblies.py 2022-09-04 04:02:39 +09:30
Raul Santos
9a10701c69
C#: Assume 64-bit types when type has no meta
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-09-01 10:29:52 +02:00
Aaron Franke
10a56981dc
Rename String plus_file to path_join 2022-08-29 19:38:13 -05:00
Ignacio Roldán Etcheverry
a5218989a2
Merge pull request #65046 from neikeq/dotnet-fix-exported-game-uninitialized-callbacks
C#: Fix exported game crash because of uninitialized callbacks
2022-08-29 18:14:04 +02:00
Ignacio Roldán Etcheverry
70c0774e70
Merge pull request #64987 from raulsntos/dotnet/linux-export
Fix .NET exporting in Linux
2022-08-29 18:13:20 +02:00
Ignacio Roldán Etcheverry
8d9ff955b7 C#: Fix exported game crash because of uninitialized callbacks
This was a regression from 2c180f62d9,
where I forgot to update the source generator.
2022-08-29 17:37:56 +02:00
Rémi Verschelde
e60086f98b
Merge pull request #64119 from YuriSizov/theme-init-database 2022-08-29 14:02:21 +02:00
Fabio Alessandrelli
d20b32186f [Web] Rename JavaScript platform to Web.
Also rename export name from "HTML5" to "Web".
2022-08-29 11:52:00 +02:00
Rémi Verschelde
4333f785f6
Merge pull request #64956 from raulsntos/dotnet/format-ci
Add `dotnet format` to CI to check C# style
2022-08-29 07:03:20 +02:00
Ignacio Roldán Etcheverry
58f8f3a40e
Merge pull request #64900 from raulsntos/dotnet/fix-exceptions
Fix various C# exceptions
2022-08-29 01:22:39 +02:00
Ignacio Roldán Etcheverry
f70e106010
Merge pull request #64994 from raulsntos/dotnet/property-indexers
C#: Ignore property indexers and report if exported
2022-08-29 00:52:25 +02:00
Raul Santos
761e2b1a65
C#: Ignore property indexers and report if exported
Ignore property indexers since they are unsupported and report a
diagnostic if an user tries to export it.
2022-08-28 18:16:57 +02:00