Commit graph

1697 commits

Author SHA1 Message Date
Ignacio Roldán Etcheverry
2303c26783 C#: Load assemblies as collectible only in the Godot editor
We use collectible AssemblyLoadContexts as that's the only way to allow
reloading assemblies after building. However, collectible assemblies
have some restrictions:

- https://learn.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/collectible-assemblies#restrictions-on-collectible-assemblies

Those restrictions can cause issues with third-party code, such as some
mocking libraries.

In order to work around this problem, we're going to load assemblies
as collectible only in Godot editor, and not when running games.
These issues will still exist in the editor, but this will be enough
for some users.
2022-10-17 00:22:48 +02:00
Yuri Rubinsky
04f7207009 Add a Plane(Vector3, Vector3) constructor for C# 2022-10-16 14:10:58 +03:00
Raul Santos
333f88dc49
Guard against more potential conflicts in C# bindings generator 2022-10-15 12:47:10 +02:00
Rémi Verschelde
b9e924c806 Merge pull request #67216 from dotlogix/Bugfix/FixErrorWhenSerializingSignals
Fix crash when serializing empty delegates in C#
2022-10-13 09:05:22 +02:00
Alexander Schill
5f47873f10 Adding null check to prevent null reference exception when serializing delegates in C# 2022-10-13 00:19:46 +02:00
Rémi Verschelde
f2248969db
Merge pull request #66952 from bruvzg/macos_net_export
Fix macOS .NET export.
2022-10-12 22:52:59 +02:00
Micky
fe56c1ff75 Use JSON::stringify where possible 2022-10-11 00:27:23 +02:00
Raul Santos
fbea89d4f1
C#: Generate symbols packages 2022-10-08 13:59:06 +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
Raul Santos
86f6662a8c
C#: Fix signature of generated signal callbacks
- Use `long` and `double` types since signals currently only support 64-bit types.
- Fix bug for checking if the type name is a class registered in ClassDB.
2022-10-07 12:11:24 +02:00
Rémi Verschelde
340f62d1ec .NET: Generate SdkPackageVersions.props from version.py
Ensures that the versions always match the Godot version, albeit following
SemVer 2.0 so inserting a dot between "beta" and the build number.

For "stable" status, we omit the suffix as this would be interpreted as a
pre-release build too.

So we have:

| Godot version  | Nupkg version  |
| -------------- | -------------- |
| 4.0.0-beta     | 4.0.0-beta     |
| 4.0.0-beta2    | 4.0.0-beta.2   |
| 4.0.0-rc1      | 4.0.0-rc.1     |
| 4.0.0-stable   | 4.0.0          |
2022-10-05 20:31:26 +02:00
Rémi Verschelde
52f5a58c38 Merge pull request #66873 from akien-mga/script-tweak-error-invalid-script-type
GDScript/C#: Tweak error message for invalid script type for object
2022-10-05 08:38:52 +02:00
Aaron Franke
2cea42cc7f
Rename Projection matrix to columns 2022-10-04 12:34:19 -05:00
Rémi Verschelde
5bf95518fd GDScript/C#: Tweak error message for invalid script type for object
See #66870.
2022-10-04 12:56:49 +02:00
Rémi Verschelde
cd7f172cf8 Merge pull request #66804 from akien-mga/core-remove-NO_SAFE_CAST
Remove unsupported `NO_SAFE_CAST`/`-fno-rtti` from Android build
2022-10-04 10:22:24 +02:00
Raul Santos
67d058da30
C#: Use Span in Color to avoid string allocations 2022-10-03 12:11:37 +02:00
Rémi Verschelde
82b87d7a17 Remove unsupported NO_SAFE_CAST/-fno-rtti from Android build
Android was the last platform to still attempt to disable RTTI (for binary
size), but both the Android editor and now the ICU library used by templates
need RTTI.

There could still be the possibility to support this for non-ICU template
builds (i.e. without the TextServerAdvanced module), but since this isn't one
of the build configurations we test regularly it's pretty risky to keep this
option only for that specific use case. And our code is already littered with
`dynamic_cast`s which weren't guarded with `!defined(NO_SAFE_CAST)`.
2022-10-03 11:18:31 +02:00
Rémi Verschelde
9c2894180d Merge pull request #66387 from aaronfranke/cs-basis-euler
C#: Update Basis Euler angle code to match core
2022-10-03 09:26:16 +02:00
Patrick Dawson
161f295f52 ManagedCallable: use delegate target instead of middleman when possible
If the delegate target is an Object, the connected signal will be registered in that object instead of the middleman. So when that object is destroyed, the signal will be properly disconnected.
2022-10-01 02:09:58 +02:00
Rémi Verschelde
ef8834a642 Merge pull request #64784 from yedpodtrzitko/yed/ci-add-mypy
ci: add Python static analysis check via mypy
2022-09-30 17:44:39 +02: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
Jiri Suchan
c5bd2f9dce ci: add Python static analysis check via mypy 2022-09-30 19:03:17 +07:00
Rémi Verschelde
39facb35a0 SCons: Unify tools/target build type configuration
Implements https://github.com/godotengine/godot-proposals/issues/3371.

New `target` presets
====================

The `tools` option is removed and `target` changes to use three new presets,
which match the builds users are familiar with. These targets control the
default optimization level and enable editor-specific and debugging code:

- `editor`: Replaces `tools=yes target=release_debug`.
  * Defines: `TOOLS_ENABLED`, `DEBUG_ENABLED`, `-O2`/`/O2`
- `template_debug`: Replaces `tools=no target=release_debug`.
  * Defines: `DEBUG_ENABLED`, `-O2`/`/O2`
- `template_release`: Replaces `tools=no target=release`.
  * Defines: `-O3`/`/O2`

New `dev_build` option
======================

The previous `target=debug` is now replaced by a separate `dev_build=yes`
option, which can be used in combination with either of the three targets,
and changes the following:

- `dev_build`: Defines `DEV_ENABLED`, disables optimization (`-O0`/`/0d`),
  enables generating debug symbols, does not define `NDEBUG` so `assert()`
  works in thirdparty libraries, adds a `.dev` suffix to the binary name.

Note: Unlike previously, `dev_build` defaults to off so that users who
compile Godot from source get an optimized and small build by default.
Engine contributors should now set `dev_build=yes` in their build scripts or
IDE configuration manually.

Changed binary names
====================

The name of generated binaries and object files are changed too, to follow
this format:

`godot.<platform>.<target>[.dev][.double].<arch>[.<extra_suffix>][.<ext>]`

For example:
- `godot.linuxbsd.editor.dev.arm64`
- `godot.windows.template_release.double.x86_64.mono.exe`

Be sure to update your links/scripts/IDE config accordingly.

More flexible `optimize` and `debug_symbols` options
====================================================

The optimization level and whether to generate debug symbols can be further
specified with the `optimize` and `debug_symbols` options. So the default
values listed above for the various `target` and `dev_build` combinations
are indicative and can be replaced when compiling, e.g.:

`scons p=linuxbsd target=template_debug dev_build=yes optimize=debug`
will make a "debug" export template with dev-only code enabled, `-Og`
optimization level for GCC/Clang, and debug symbols. Perfect for debugging
complex crashes at runtime in an exported project.
2022-09-26 16:31:46 +02:00
Rémi Verschelde
49fcf4ffad Style: Cleanup header guards for consistency
Fix file names for {Static,Lightmap}RaycasterEmbree.
2022-09-26 13:51:17 +02:00
Aaron Franke
fe7135344b
C#: Update Basis Euler angle code to match core 2022-09-25 22:28:52 -05: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
Rémi Verschelde
d96b7d767a Merge pull request #66110 from Zylann/reference_get_count
get_reference_count()`
2022-09-22 08:26:29 +02:00
Marc Gilleron
474cee7daf Rename and expose RefCounted::get_reference_count() 2022-09-21 21:18:54 +01:00
Raul Santos
5be5f167a1
C#: Rename PlusFile to PathJoin 2022-09-19 18:25:29 +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
Rémi Verschelde
1c0ed3d1ed Merge pull request #65877 from raulsntos/dotnet/signal-delegate-docs
Add documentation to signal delegates
2022-09-18 00:41:39 +02:00
antonWetzel
5090355907 don't marshal multidimensional arrays 2022-09-17 00:18:08 +02:00
Raul Santos
7535803023
C#: Fix marshaling generic Godot collections
Add support for generic Godot collections to
`ConvertManagedObjectToVariant`.
2022-09-16 16:42:40 +02:00
Raul Santos
ba0e7622cd
Make push_nupkgs_local absolute
Ensures the `push_nupkgs_local` argument in build_assemblies.py is an
absolute path so the argument can be
given as a relative path and it will be converted.
2022-09-16 10:08:05 +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
047801693c
Merge pull request #65533 from neikeq/issue-65522 2022-09-09 09:11:38 +02: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
Ignacio Roldán Etcheverry
8199a209c2 C#: Fix module builds for Windows 32-bit with mingw-w64
The lambda was giving issues, so I re-wrote it as a static function.
2022-09-08 20:57:28 +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
5c5079b398 Merge pull request #65197 from Mickeon/rename-connect-one-shot
Rename CONNECT_ONESHOT to CONNECT_ONE_SHOT
2022-09-07 08:51:10 +02:00
Rémi Verschelde
432c4c40a9
Merge pull request #65433 from neikeq/fix-mustbevariant-omittedtypearg 2022-09-06 21:41:53 +02:00
Micky
dd26ecdd31 Rename CONNECT_ONESHOT TO CONNECT_ONE_SHOT
For consistency. Every other exposed `one_shot` is spaced out like this.
2022-09-06 19:00:33 +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
Ignacio Roldán Etcheverry
5628ab9215
Merge pull request #65410 from magian1127/4.0UnifiedMemberName
C# Modify the MemberName generated for the user script
2022-09-06 18:49:48 +02:00
Rémi Verschelde
5062aafc2d Merge pull request #64417 from aaronfranke/has-space
Replace AABB/Rect2/Rect2i has_no_* methods with has_* methods
2022-09-06 17:00:44 +02:00
Magian
4448859ead C# Modify the MemberName generated for the user script 2022-09-06 20:43:40 +08:00
Micky
b6daad8d4b Rename range_lerp to remap 2022-09-06 07:19:20 +02: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
Rémi Verschelde
785ce4208d Merge pull request #65266 from raulsntos/dotnet/reload-non-tool-scripts
Create script instance of reloaded scripts even if they're not tools
2022-09-05 08:27:16 +02:00
Aaron Franke
7c2f0a82f0
Replace AABB/Rect2(i) HasNo* methods in C# 2022-09-04 23:03:36 -05:00
Aaron Franke
39521f9c8e
Fix some bugs with Vector4 in C# 2022-09-04 19:55:30 -05:00
Raul Santos
a91a3d01f8
C#: Create script instance of reloaded scripts even if they're not tools
Scripts that are instantiated at some point will always be recreated
if they ever become placeholders to prevent non-tool scripts
instantiated manually by users to become placeholders, if they
do become placeholders due to errors that prevent instantiation
(such as a missing parameterless constructor) these scripts
will also be recreated replacing the temporary placeholder.

If a script is marked as a tool but becomes a non-tool script
in a rebuild, the script will become a placeholder and will
no longer be considered applicable to be replaced by an instance
since the user explicitly removed the Tool attribute.
2022-09-04 20:39:37 +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
Ignacio Roldán Etcheverry
8a928bf465
Merge pull request #65296 from raulsntos/dotnet/signal-once
C#: Connect only once for each signal of a script
2022-09-03 23:12:36 +02:00
Raul Santos
281ccc7e1b
C#: Connect only once for each signal of a script
Since the list of signals in `CSharpScript::event_signals` retrieved
from calling `ScriptManagerBridge.UpdateScriptClassInfo` already
includes the signals from base scripts there is no need to iterate the
hierarchy again on `CSharpInstance::connect_event_signals`.
2022-09-03 20:39:01 +02:00
Almighty Laxz
c71b78bbb8 Add float arg to build_assemblies.py 2022-09-04 04:02:39 +09:30
Almighty Laxz
2c1593f7e4 Fixed build failing when REAL_T double and dotnet enabled 2022-09-03 00:24:14 +09:30
Ignacio Roldán Etcheverry
00058bb0ea
Merge pull request #65168 from raulsntos/dotnet/float64
C#: Assume 64-bit types when type has no meta
2022-09-01 18:05:33 +02:00
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
Ignacio Roldán Etcheverry
0e63185651 C#: Fix Vector4 in godot_variant and missing marshaling
Vector4 and Vector4i were implemented incorrectly in godot_variant.
They were also missing their respective Variant conversion callbacks
(used for generic collections).

Took the chance to remove unnecessary native calls for creating
Variant from Vector4, as now it can be done from C# (which is faster).
2022-08-31 23:43:28 +02:00
Hugo Locurcio
291d3aaabe
Improve null and object printing to avoid confusion with arrays
- Use different syntax for object printing to avoid confusion with arrays.
- Print null as `<null>` to avoid confusion with a string `"null"`.
- Display `<empty>` in editor resource pickers to avoid confusion
  with array-based properties.
2022-08-31 15:31:49 +02:00
Ignacio Roldán Etcheverry
706d988baa
Merge pull request #65061 from paulloz/dotnet/fix-godot_variants-with-empty-type-field
C#: Populate `Type` field on `godot_variant` created in managed
2022-08-30 18:01:00 +02:00
Danil Alexeev
d4555ef5fb
Add String.to_{camel,pascal,snake}_case methods 2022-08-30 12:36:24 +03:00
Aaron Franke
10a56981dc
Rename String plus_file to path_join 2022-08-29 19:38:13 -05:00
Paul Joannon
b783be59a2
C#: godot_variant should always have a valid type 2022-08-30 00:32:53 +02:00
Ignacio Roldán Etcheverry
051f24b067
Merge pull request #65049 from paulloz/dotnet/win10-export
C#: Fix .NET export template compilation on Windows
2022-08-29 18:34:02 +02: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
Paul Joannon
ab5807d722
Fix .NET export template compilation on Windows 10 2022-08-29 17:49:37 +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
Rémi Verschelde
f7f8af232c
Merge pull request #64885 from Mickeon/rename-tooltip-hint
Rename `hint_tooltip` to `tooltip_text` & setter getter
2022-08-28 17:43:01 +02:00
Raul Santos
b0274d0ee7
Fix .NET exporting in Linux
- 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-28 15:44:05 +02:00
Ignacio Roldán Etcheverry
202f0f2f1b
Merge pull request #64959 from raulsntos/dotnet/fix-malloc-size
C#: Fix byteCount in `NativeMemory.Alloc`
2022-08-28 01:44:56 +02:00
Rémi Verschelde
19e2f30a55
Merge pull request #64860 from raulsntos/dotnet/sync-math
Sync C# cubic interpolation with core
2022-08-27 19:01:37 +02:00
Rémi Verschelde
b5294b5759
Merge pull request #64922 from akien-mga/dotnet-fix-app-host-version-detection
.NET: Change NETCore.App version detection to use highest match
2022-08-27 18:58:40 +02:00
Raul Santos
ebe008d41b
C#: Fix byteCount in NativeMemory.Alloc
`NativeMemory.Alloc` takes the byte count as parameter, this is
calculated by multiplying the element size in bytes by the length
of the array.
2022-08-27 17:35:53 +02:00
Raul Santos
f64b845514
C#: Add CubicInterpolateAngle 2022-08-27 12:28:54 +02:00
Raul Santos
623f4a52ca
C#: Add CubicInterpolateInTime 2022-08-27 12:27:11 +02:00
Raul Santos
4c5cefe4fe
C#: Rename and fix Quaternion.SphericalCubicInterpolate 2022-08-27 12:26:38 +02:00
Raul Santos
f72b7a1595
C#: Fix Quaternion.CubicSlerp 2022-08-27 12:26:38 +02:00