Commit graph

859 commits

Author SHA1 Message Date
Rémi Verschelde 5dccc940e7
Merge pull request #74375 from raulsntos/dotnet/ignore-explicit-interface-implementations
C#: Ignore explicit interface implementations
2023-03-05 13:39:45 +01:00
Rémi Verschelde afc9d381d5
Merge pull request #74312 from raulsntos/dotnet/godot-project-dir-base64
C#: Encode GodotProjectDir as Base64 to prevent issues with special characters
2023-03-05 13:28:14 +01:00
Raul Santos f949e94991
C#: Encode GodotProjectDir as Base64 to prevent issues with special characters 2023-03-04 23:33:30 +01:00
Raul Santos 0372bd56b6
C#: Ignore explicit interface implementations 2023-03-04 19:16:48 +01:00
RedworkDE 16a2a164fe C#: Get singleton instances using the Core name 2023-03-03 16:30:18 +01:00
Rémi Verschelde 526f115752
Merge pull request #73904 from raulsntos/dotnet/tools-popup
C#: Always show "Create C# solution" option
2023-03-02 11:22:59 +01:00
Rémi Verschelde 1c1524a651
Bump version to 4.1-dev
Can't stop, won't stop, they said, huh?
2023-03-01 01:44:37 +01:00
Raul Santos a1a2fc2255
C#: Always show "Create C# solution" option
Prevents ending up with an empty C# menu.
The option to create the C# solution no longer disappears, to avoid confusing users.
If an user tries to use it when a C# solution already exists they are warned that it will override their sln and csproj files.
2023-02-26 02:56:34 +01:00
Raul Santos 3730d8e343
C#: Check if a class is a singleton using the Core name
Use the name of the class in Core, rather than the C# rename, when checking if a class is registered as a singleton.
2023-02-24 18:02:31 +01:00
RedworkDE 756a48023f C#: Fix line position when opening file in VSCode 2023-02-19 12:43:15 +01:00
Rémi Verschelde 2527d4ce9b
Merge pull request #73458 from paulloz/csharp/actually-clean-solution
.NET: Clicking "Clean solution" should clean, not build
2023-02-17 00:30:55 +01:00
Paul Joannon 5e3d114829
Clicking "Clean solution" should clean, not build 2023-02-16 11:45:33 +01:00
Raul Santos d57cb460e2
C#: Open the solution directory when using VSCode
The solution directory used to be the same as the project
directory (`res://`). We now allow specifying a different
path for the solution and the other external editors already
use that (which seems more convenient for multi-project
scenarios).
2023-02-15 20:13:40 +01:00
Raul Santos 2a1523d751
Build C# csproj instead of the solution 2023-02-10 03:19:30 +01:00
Rémi Verschelde b53c4dda62
Merge pull request #72849 from RedworkDE/net-export-settings
C#: Rename export settings `mono` -> `dotnet` and remove unused AOT settings
2023-02-08 09:32:41 +01:00
RedworkDE bf47b62203 C#: Rename export settings mono -> dotnet and remove unused AOT settings 2023-02-07 18:20:23 +01:00
Paul Joannon c70c82b0fb
Try and match MSBuild and Godot UI languages 2023-02-07 16:48:23 +01:00
Paul Joannon 9bf2a0bcda
Add new settings about MSBuild
- toggle creation of binary logs
- manage log verbosity
- toggle logging in console
2023-02-07 16:48:23 +01:00
Paul Joannon 7cf42dbdee
Add button to open the msbuild logs folder 2023-02-07 16:48:23 +01:00
Paul Joannon e51a20b714
Rename existing editor settings mono -> dotnet 2023-02-07 16:48:18 +01:00
Rémi Verschelde c5c6f2db89
Merge pull request #72553 from RedworkDE/net-output-directory
C#: Preserve directories in output during export
2023-02-02 13:59:05 +01:00
RedworkDE 70ebb6378c C#: Preserve directories in output during export 2023-02-01 00:37:12 +01:00
Treer 086ce855a8
Update modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotPluginsInitializerGenerator.cs
Co-authored-by: Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com>
2023-02-01 07:56:20 +11:00
Treer 273df44e1d Qualify Console's namespace to avoid mixup with plugin's objects
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-31 16:23:17 +11:00
Rémi Verschelde 2b55ac445b
Merge pull request #72111 from raulsntos/method-info-metadata
Add `GodotTypeInfo::Metadata` to `MethodInfo`
2023-01-27 15:41:38 +01:00
Raul Santos 1aceacaa6b
C#: Rename Object to GodotObject 2023-01-27 02:04:18 +01:00
Raul Santos a968e51414
C#: Renames to follow .NET naming conventions
Renamed C# types and members to use PascalCase and follow .NET naming conventions.
2023-01-27 02:04:17 +01:00
Raul Santos 4788cb35c1
C#: Add global namespace to grouping property info 2023-01-27 01:15:19 +01:00
Rémi Verschelde 0d1b5f8832
Merge pull request #71356 from raulsntos/dotnet/get
C#: Lookup signals and methods in Get method
2023-01-27 00:13:13 +01:00
Rémi Verschelde 4f572d1587
Merge pull request #71535 from raulsntos/dotnet/pointers-are-yabai
C#: Skip methods with pointer parameters
2023-01-26 23:44:28 +01:00
Rémi Verschelde 63b5adf8a8
Merge pull request #72057 from raulsntos/dotnet/fix-must-be-variant
C#: Annotate API with `[MustBeVariant]`
2023-01-26 23:00:30 +01:00
Rémi Verschelde 2aa532ad6c
Merge pull request #65529 from magian1127/4.0FixDocTag
C# Improve the "Tag" conversion of documents
2023-01-26 22:58:26 +01:00
Raul Santos cac7a784d6
Add GodotTypeInfo::Metadata to MethodInfo 2023-01-26 15:51:34 +01:00
Raul Santos 256632a07e
C#: Skip documentation syntax in MustBeVariant analyzer 2023-01-25 17:29:08 +01:00
Aaron Franke 2a65f6812b
Add PROPERTY_USAGE_NEVER_DUPLICATE flag and use for script
Co-authored-by: Yakov Borevich <j.borevich@gmail.com>
2023-01-24 16:37:50 -06:00
Aaron Franke 2bc0bcbd26
PropertyUsage: Rename "DO_NOT_SHARE_ON_DUPLICATE" to "ALWAYS_DUPLICATE" 2023-01-24 16:05:07 -06:00
Magian 35bfce2afd C# Improve the "Tag" conversion of documents
[codeblocks] for Keep only the [CSharp] part.
[param] is changed to <c>.
[b] for bold text.
[i] for italic text.
4.0 now uses variant, so [variant] to <see cref="Godot.Variant"/>.
since Rider does not support [u], only comments have been modified.
2023-01-24 18:40:48 +08:00
Raul Santos 3425d43fed
C#: Move GLOBAL_DEFs to CSharpLanguage ctor
Also documents the .NET project settings.
2023-01-18 21:53:58 +01:00
Raul Santos 62106fe5e3
C#: Implement ExportPlugin::_get_name 2023-01-18 18:17:38 +01:00
Raul Santos ab5e532f1a
C#: Skip methods with pointer parameters 2023-01-17 04:32:05 +01:00
Raul Santos 47e355f965
C#: Make property accessors internal 2023-01-16 15:15:26 +01:00
Raul Santos a6ba914f15
C#: Lookup signals and methods in Get method
Allows to retrieve `Callable`s and `Signal`s using `Get` like it works in GDScript.
2023-01-13 22:19:25 +01:00
Rémi Verschelde 64f2b970d8
Merge pull request #71114 from reduz/cleanup-property-hints
Removed unused property hints and `Object::get_translatable_strings()`
2023-01-09 16:57:31 +01:00
Juan Linietsky 0e0a6bb39b
Removed unused property hints and Object::get_translatable_strings()
* 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>
2023-01-09 16:56:01 +01:00
Raul Santos 59e8fc1edf
C#: Add [Flags] attribute to core bitfield enums 2023-01-09 16:13:28 +01:00
Juan Linietsky 47592927b3 Use BitField<> hint for ArrayFormat
This was missing in the conversion of bitflags to BitField<>.
2023-01-08 18:47:48 +01:00
Rémi Verschelde d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Raul Santos a43e8285a7
C#: Avoid generic types in the script path attribute generator
- 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-28 23:20:02 +01:00
Ignacio Roldán Etcheverry 5784bf1be0
Merge pull request #70486 from raulsntos/dotnet/convert-to
C#: Rename `ConvertToX` methods
2022-12-23 21:15:24 +01:00
Raul Santos 24e4ac9167
C#: Rename ConvertToX methods
- Renamed `ConvertToX` to `ConvertToNativeX`.
- Renamed `ConvertToXObject` to `ConvertToX`.
- Renamed `ConvertToXManaged` to `ConvertToX`.
- Fix `Signal` name in bindings generator and csharp script.
2022-12-23 19:40:32 +01:00
Raul Santos 03c26d6618
C#: Disallow init-only properties
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-23 19:04:14 +01:00
Silc Renew a52479f770 Fix out of sync PropertyUsageFlags for cs 2022-12-16 06:27:04 +09:00
Rémi Verschelde 346efd29e0
Fix typos with codespell 2022-12-15 12:24:08 +01:00
Rémi Verschelde b8e1d6585c
Merge pull request #69971 from neikeq/csharp-vararg-ret-premature-free
C#: Fix premature free of returned Variant in vararg methods
2022-12-14 23:27:40 +01:00
Ignacio Roldán Etcheverry 833b252ce7 C#: Fix premature free of returned Variant in vararg methods
Notably, this fixes obscure issues after calling `script.New()` when
the returned instance is a `RefCounted`.
2022-12-12 17:54:28 +01:00
Raul Santos 1a4c8856ec
C#: Rename SignalInfo to Signal and make awaitable 2022-12-12 17:30:14 +01:00
Raul Santos 1ab4f26cc4
C#: Fix bindings generator for methods that return signals 2022-12-12 17:04:03 +01:00
Ignacio Roldán Etcheverry 5c6c766732 C#: Fix exported properties of GodotObject[] type
This was a regression from 17b2838f39.
`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-11 22:29:31 +01:00
Rémi Verschelde f3c68d6c83
Merge pull request #69391 from NeilKleistGao/sln
Fix C# Solution Directory Project Settings
2022-12-02 16:48:30 +01:00
NeilKleistGao 2bab84c8c7 Fix C# solution directory settings
Co-authored-by: Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com>
2022-12-02 22:01:15 +08:00
Ignacio Roldán Etcheverry 17b2838f39 C#: Cleanup Variant marshaling code in source/bindings generators
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-02 14:47:12 +01:00
Ignacio Roldán Etcheverry f86c6b6ac4 C#: Replace most conversions between Variant and System.Object
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-12-02 14:47:12 +01:00
R. Alex Hofer 215022c507 Remove unnecessary namespaces in generated PropertyDefVal files. 2022-11-29 22:12:34 -05:00
Ignacio Roldán Etcheverry 4a82d71d73
Merge pull request #65907 from magian1127/4.0FixPropertiesGenerator
C#: Fix Generated ScriptProperty Error.
2022-11-28 01:48:52 +01:00
Magian c41196f0f3 C#: Fix Generated ScriptProperty Error.
1. Add "this." to prevent errors caused by duplicate variable names.
2. Try to find the default value of property getters.
2022-11-27 17:40:40 +08:00
Ignacio Roldán Etcheverry 690199b7dd
Merge pull request #69194 from raulsntos/dotnet/begone-variant-disposer
C#: Remove VariantSpanDisposer and use constants in stackalloc
2022-11-27 03:30:59 +01:00
Raul Santos 3ff181096a
C#: Remove VariantSpanDisposer and use constants in stackalloc
- Remove `VariantSpanDisposer`, no need to dispose of the Variant Spans
since we are now borrowing the Variants instead of copying them.
- Remove `VariantSpanExtensions.Cleared` that was only used so the
Span was initialized for `VariantSpanDisposer` to know what to dispose.
- Fix stackalloc Spans to use constant VarArgsSpanThreshold
and avoid bound checks.
2022-11-27 03:04:34 +01:00
Ignacio Roldán Etcheverry 50badbd1f4
Merge pull request #69088 from raulsntos/dotnet/global
C#: Add `global::` namespace to generated source
2022-11-26 04:36:26 +01:00
Raul Santos b9e1ca1e86
C#: Add global:: namespace to generated source
Adds `global::` to the fully qualified types in source generators to
prevent ambiguity.
2022-11-26 01:13:16 +01:00
Ignacio Roldán Etcheverry 3f645f980c C#: Optimize Variant conversion callbacks
These callbacks are used for marshaling by callables and generic Godot
collections.

C# generics don't support specialization the way C++ templates do.
I knew NativeAOT could optimize away many type checks when the types
are known at compile time, but I didn't trust the JIT would do as good
a job, so I initially went with cached function pointers.

Well, it turns out the JIT is also very good at optimizing in this
scenario, so I'm changing the methods to do the conversion directly,
rather than returning a function pointer for the conversion.

The methods were moved to `VariantUtils`, and were renamed from
`GetFromVariantCallback/GetToVariantCallback` to `ConvertTo/CreateFrom`.

The new implementation looks like it goes through many `if` checks
at runtime to find the right branch for the type, but in practice it
works pretty much like template specialization. The JIT only generates
code for the relevant branch. Together with inlining, the result is
very close or the same as doing the conversion manually:

```cs
godot_variant variant;

int foo = variant.Int;
int bar = VariantUtils.ConvertTo<int>(variant);
```

If the type is a generic Godot collection, the conversion still goes
through a function pointer call.

The new code happens to be much shorter as well, with the file going
from 1057 lines to 407.

Side note: `Variant.cs` was mistakenly created in the wrong folder,
so I moved it to the `Core` folder.
2022-11-25 03:14:10 +01:00
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
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
Raul Santos d35c58507c
Fix C# style with dotnet format 2022-08-27 03:22:31 +02:00
Micky ef5b9a06a9 Rename hint_tooltip to tooltip_text & setget
`hint_tooltip` -> `tooltip_text`
`set_tooltip` -> `set_tooltip_text`
`_get_tooltip` -> `get_tooltip_text`

Updates documentation, too.
2022-08-27 01:35:01 +02:00
Yuri Sizov 6320a0fc18 Add ThemeDB, expose previously static Theme methods 2022-08-26 19:23:05 +03:00
Raul Santos 79f9f59a87
Fix various C# exceptions
- 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-26 16:56:00 +02:00
fabriceci f8cc88fab3 Restore RigidBody2/3D, SoftBody names in physics 2022-08-26 12:26:25 +02:00
Ignacio Roldán Etcheverry e8ce36628f
Merge pull request #64901 from raulsntos/dotnet/equals
C#: Use pattern matching to simplify `Equals`
2022-08-26 08:33:52 +02:00
Raul Santos 9c9b8fcd34
Remove [Signal] attribute from events
- Remove event as a valid target of `SignalAttribute`
- Stop adding the `[Signal]` attribute to events in bindings_generator
- Make bindings_generator use the `EventHandler` suffix to be consistent with the C# source generator
- Remove obsolete comment about the signal's delegate name
2022-08-26 00:53:45 +02:00
Paul Joannon cf99d92a39
C#: Preserve order of exported fields/categories 2022-08-25 20:39:57 +02:00
Ignacio Roldán Etcheverry f03ac21ea8
Merge pull request #52815 from magian1127/temp3
C# Generate SnakeName const
2022-08-25 20:02:16 +02:00
Raul Santos f8ceceed15
Various C# documentation improvements
Fixes wrong/invalid documentation and add documentation to some OS members.
2022-08-25 17:09:32 +02:00
Magian c371d1bac9 C# Generate StringName(SnakeName) for all class members 2022-08-25 23:07:20 +08:00
Aaron Franke 27b0f18275 Unify bits, arch, and android_arch into env["arch"]
Fully removes the `bits` option and adapts the code that relied on it.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2022-08-25 11:19:20 +02:00
Rémi Verschelde 6ffbec9e49
Merge pull request #64731 from raulsntos/dotnet6-variant-generics-analyzer
C#: Add `MustBeVariant` attribute and analyzer
2022-08-25 07:34:05 +02:00
Raul Santos 6468f9b37c
Add MustBeVariant attribute and analyzer
- MustBeVariant attribute can be used to enforce that generic types must
be a marshable from/to Variant.
- Also renames all diagnostic ids to be valid unicode identifiers.
2022-08-25 01:47:40 +02:00
Aaron Franke 09551c3d2b
Remove mentions of the Server platform from the Mono module 2022-08-24 14:56:40 -05:00
Ignacio Roldán Etcheverry 686286ed9d
Merge pull request #64742 from zaevi/csharp_add_grouping_attributes
C#: Add grouping attributes for properties.
2022-08-24 20:09:47 +02:00
Ignacio Roldán Etcheverry e172b1aa91
Merge pull request #64743 from raulsntos/dotnet6-signal-analyzer
Improve C# signal analyzer errors
2022-08-24 19:28:47 +02:00
Raul Santos a0da258401
Use pattern matching to simplify Equals
- Simplify and unify `Equals` implementation of C# struct types
- Also add pattern matching to replace a cast in `DebuggingUtils`
2022-08-24 14:15:33 +02:00
Raul Santos 0b8b733d77
C#: Replace Xform and XformInv with * operator
- In cases where both `Xform`/`XformInv` and the `*` operator were
implemented the `Xform`/`XformInv` methods were removed in favor of the
`*` operator.
- In cases where the `Xform`/`XformInv` existed but not the `*` operator,
the `Xform`/`XformInv` methods were replaced with the `*` operator.
- In cases where no method existed, a new `*` operator has been
implemented to support the same operations that are supported in GDScript.
- Fixes the `Transform.Xform` and `Transform.XformInv` with `Rect2`
implementation to use a zero `Rect2` size to start expanding from
(which is how it's implemented in C++).
2022-08-22 21:11:24 +02:00
Raul Santos 3b201c2b04
Improve C# signal analyzer errors
Report the specific parameters that are not supported.
2022-08-22 19:44:05 +02:00
Zae 431a28fe19 C#: Add grouping attributes for properties. 2022-08-23 01:23:45 +08:00
Ignacio Roldán Etcheverry 2c180f62d9 C#: Replace P/Invoke with delegate pointers
- 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-22 03:36:52 +02:00
Ignacio Roldán Etcheverry 1bf4397e5b C#: Use custom project setting for C# project files name
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-22 03:36:52 +02:00
Ignacio Roldán Etcheverry 0c30c678f0 C#: Re-introduce generic Godot Array and Dictionary
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-22 03:36:52 +02:00
Ignacio Roldán Etcheverry 3123be2384 C#: Array, Dictionary and marshaling refactoring
- 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-22 03:36:52 +02:00
Ignacio Roldán Etcheverry 344f5028d4 C#: Add dedicated Variant struct, replacing System.Object 2022-08-22 03:36:52 +02:00
Ignacio Roldán Etcheverry a9892f2571 C#: Add source generator for method list 2022-08-22 03:36:52 +02:00
Ignacio Roldán Etcheverry 97713ff77a C#: Add source generator for signals as events
Changed the signal declaration signal to:

```
// The following generates a MySignal event
[Signal] public delegate void MySignalEventHandler(int param);
```
2022-08-22 03:36:52 +02:00
Ignacio Roldán Etcheverry e235cef09f C#: Re-implement assembly reloading with ALCs 2022-08-22 03:36:51 +02:00
Ignacio Roldán Etcheverry d78e0a8426 C#: Make GodotSharp API a NuGet package
In the past, the Godot editor distributed the API assemblies and
copied them to project directories for projects to reference them.
This changed with the move to .NET 5/6. Godot no longer copies the
assemblies to project directories. However, the project Sdk still
tried to reference them from the same location.
From now on, the GodotSharp API is distributed as a NuGet package,
which the Sdk can reference.

Added an option to `build_assemblies.py` to copy all Godot NuGet
packages to an existing local NuGet source. This will be needed
during development, while packages are not published to a remote
NuGet repository.
This option also makes sure to remove packages of the same version
installed (~/.nuget/packages). Very useful during development, when
packages change, to make sure the package being used by a project is
the same we just built and not one from a previous build.

A local NuGet source can be created like this:

```
mkdir ~/MyLocalNuGetSource && \
dotnet nuget add source ~/MyLocalNuGetSource/ -n MyLocalNuGetSource
```
2022-08-22 03:36:51 +02:00
Ignacio Roldán Etcheverry 4b90d16250 C#: Initial NativeAOT support
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-22 03:36:51 +02:00
Ignacio Roldán Etcheverry 18f805b3aa C#: Upgrade to .NET 6 (5.0 -> 6.0) 2022-08-22 03:36:51 +02:00
Ignacio Roldán Etcheverry e22dd3bc6a C#: Static marshaling for bindings and source generators
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-22 03:36:51 +02:00
Ignacio Roldán Etcheverry 92503ae8db C#: Add source generator for properties and exports default values
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-22 03:36:51 +02:00
Ignacio Roldán Etcheverry 88e367a406 C#/netcore: Add base desktop game export implementation
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-22 03:36:51 +02:00
Ignacio Roldán Etcheverry f88d8902cf C#: Ensure native handles are freed after switch to .NET Core
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-22 03:36:51 +02:00
Ignacio Roldán Etcheverry 4d710bf659 C#: Add initial implementation of source generator for script members
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-22 03:36:51 +02:00
Ignacio Roldán Etcheverry e5e7a795b1 C#: Code cleanup and greatly reduce use of C# pointers 2022-08-22 03:36:51 +02:00
Ignacio Roldán Etcheverry f9a67ee9da C#: Begin move to .NET Core
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-22 03:35:59 +02:00
Ignacio Roldán Etcheverry 513ee857a9 C#: Restructure code prior move to .NET Core
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-22 03:35:59 +02:00
Ignacio Roldán Etcheverry 124fbf95f8 C#: Move marshaling logic and generated glue to C#
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-22 03:35:59 +02:00
Raul Santos 34c3966510
Avoid paths with invalid characters in IsRider 2022-08-08 02:00:17 +02:00
Hugo Locurcio db22b7ded0
Rename shader parameter uniform setter/getter methods for consistency
`shader_uniform` is now consistenly used across both per-shader
and per-instance shader uniform methods. This makes methods easier
to find in the class reference when looking for them.
2022-08-04 23:17:06 +02:00
Rémi Verschelde 14828c331c Mono: Fix build after #63737 2022-08-01 00:40:18 +02:00
Raul Santos cef3ca4024
Add editor_paths.h include missing in mono module 2022-07-30 02:00:56 +02:00
Aaron Franke ac870ab1c8
Move editor paths into the EditorPaths class 2022-07-29 11:07:30 -05:00
Rémi Verschelde 90019676b0 Code quality: Fix header guards consistency
Adds `header_guards.sh` bash script, used in CI to validate future
changes. Can be run locally to fix invalid header guards.
2022-07-25 11:17:40 +02:00
reduz 455c06ecd4 Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.

* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.

These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.

**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-23 14:00:01 +02:00
Aaron Franke b00bb577e7
Rename directory for export templates from templates to export_templates 2022-07-22 12:35:43 -05:00
bruvzg 8823eae328
Rename OSX to macOS and iPhoneOS to iOS. 2022-07-21 09:37:52 +03:00
Rémi Verschelde 421e93b590
Merge pull request #62782 from raulsntos/csharp-bitfield-enums 2022-07-07 14:59:21 +02:00
Raul Santos 1637d0c699
Ensure NuGet.config directory exists 2022-07-07 01:53:32 +02:00
Raul Santos f9c43c5489
Add C# support for bitfield enums (flags) 2022-07-06 17:49:37 +02:00
reduz 5ac42cf576 Implement a BitField hint
Allows to specify the binder that an enum must be treated as a bitfield.
2022-07-05 22:13:37 +02:00
Rémi Verschelde fec3a48e53
Merge pull request #59918 from piiertho/enhancement/rename-controll-minimum_size-to-custom_minimum_size 2022-06-24 14:54:53 +02:00
Pierre-Thomas Meisels 5ad1a1b5e7 enhancement: rename exposed property Control::minimum_size to Control::custom_minimum_size 2022-06-23 18:06:10 +02:00
Rémi Verschelde 870c02143b Mono: Update Newtonsoft.Json to 13.0.1
See https://github.com/advisories/GHSA-5crp-9r3c-p9vr
2022-06-23 16:24:16 +02:00
bruvzg 860e24683f
Make enum/constant binds 64-bit. 2022-06-17 16:36:26 +03:00
Raul Santos 525b5e0e16
Fix EditorScenePostImport templates for C# 2022-06-16 19:29:59 +02:00
Rémi Verschelde d82c227e2b
Merge pull request #61486 from jtnicholl/import_script_templates
Add script templates for EditorScenePostImport
2022-06-15 21:07:42 +02:00
Jonathan Nicholl 912d8e23ca Add script templates for EditorScenePostImport 2022-06-15 12:41:37 -04:00
Raul Santos 8dec74f22f
Generate typed array parameters in C# bindings
Adds support for generating C# bindings that use the generic `Array<T>`
type instead of the non-generic `Array` type when the registered ClassDB
method specifies the array element type.
2022-06-03 05:17:53 +02:00
reduz 746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
Rémi Verschelde 947a1fa090
Merge pull request #60956 from macjuul/hide-mono-cmd-prompt
Prevent blank command prompts from spawning when building a mono project
2022-05-12 21:23:00 +02:00
Julian Mills d606a8eded Fix blank command prompts spawning
prevent certain mono actions from displaying empty command prompts.
2022-05-12 13:49:37 +02:00
reduz 8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
Vitika9 aef3b5681d Changed signals of ItemList 2022-05-06 13:09:04 +05:30
Aaron Franke b831fb0a54
Rename Transform2D "elements" to "columns" 2022-04-29 08:02:39 -05:00
bruvzg 9381acb6a4
Make FileAccess and DirAccess classes reference counted. 2022-04-11 13:28:51 +03:00
Rémi Verschelde c9b75431f3 Refactor GDScript/C# script templates logic to be editor-only
Not a full refactor as it still goes through ScriptLanguage so it's hacky,
but at least it can now compile without this.
2022-03-28 16:21:00 +02:00
Raul Santos 83e0e13f4a
Support static methods in C# bindings generator 2022-03-22 19:36:57 +01:00
Raul Santos 4bbfd20aa9
Ignore PhysicsServer3DExtension class in C#
PhysicsServer3DExtension inherits from PhysicsServer3D which is a
singleton class, since singleton classes are generated as static in C#
it would generate invalid C# so for now we'll be
ignoring PhysicsServer3DExtension.
2022-03-18 17:28:48 +01:00
bruvzg 98d0af7d5c
Implement GDExtension export plugin. 2022-03-16 11:16:19 +02:00
Haoyu Qiu 851ed8886c Fix Autoload capitalization inconsistency 2022-03-09 15:03:03 +08:00
Marcel Admiraal 507f72db8e Rename Control's Rect properties to exclude rect_ part 2022-03-08 16:30:35 +00:00
Raul Santos eaddb79ec6
Refactor bbcode_to_xml into multiple specific methods
The specific `_append_xml_*` methods implement the logic that generates
the proper XML documentation for the given BBCode tag and target and
appends it to the output.
2022-03-03 23:35:10 +01:00
Raul Santos 84615b4b53
Find inherited members in C# documentation generator 2022-03-03 19:53:06 +01:00
Raul Santos 42989befd6
Add theme_item support to C# documentation generator 2022-03-03 18:54:49 +01:00
Raul Santos e601c9eb8f
Fix checking for @GlobalScope in C# documentation generator 2022-03-03 18:54:41 +01:00
Raul Santos 424817039a
Check for missing methods/members in C# documentation generator
- Outputs errors for missing members or methods when generating the C#
documentation.
- Hardcodes a special case for the `_init` method, in C# we'll reference
the constructor.
- Ignores properties with slashes (since they are not declared in C# and
can't be referenced in the documentation).
2022-03-03 18:53:15 +01:00
Raul Santos 47a7d85cc4
Fix references to global constants in C# documentation generator
Tries to find the referenced constants in the GlobalScope
if not found in the target class or if no class is specified.
2022-03-03 18:53:15 +01:00
Rémi Verschelde b8b4580448
Style: Cleanup single-line blocks, semicolons, dead code
Remove currently unused implementation of TextureBasisU, could be re-added
later on if needed and ported.
2022-02-16 14:06:29 +01:00
Hendrik Brucker b396fd4eef Improve compilation speed (forward declarations/includes cleanup) 2022-02-12 02:46:22 +01:00
Raul Santos f380a8e0ec Support signals in C# documentation 2022-02-10 16:02:31 +01:00
Hugo Locurcio 74fc4410f4
Remove support for ARMv7 (32-bit) on iOS
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-08 22:11:29 +01:00
Ignacio Roldán Etcheverry 721c32ee2b
Merge pull request #57618 from Densorius/master
Fixed opening new instances of VS 2022 while a instance is already open
2022-02-04 15:05:51 +01:00
Densorius 93e2d0446f Fixed opening new instances of VS 2022 while a instance is already open 2022-02-04 10:40:43 +01:00
bruvzg 244db37508
Cleanup and move char functions to the char_utils.h header. 2022-02-04 11:35:01 +02:00
Densorius 9ea0508d35 Add Visual Studio 2022 support with fallback to 2019 2022-02-04 00:34:02 +01:00
Rémi Verschelde bd4d57ede2
BaseButton: Rename pressed property to button_pressed
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.
2022-01-23 22:15:09 +01:00
Rémi Verschelde fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
Nathan Franke 49403cbfa0
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
2021-12-09 04:48:38 -06:00
Aaron Franke 6eb7179f1c
Rename "items_count" property to "item_count" 2021-12-06 22:02:27 -06:00
Raul Santos 3609ca67df
Replace deprecated GetItemCount() with ItemsCount
Replace the deprecated method `GetItemCount()` with the new property
`ItemsCount`.
2021-12-06 02:17:03 +01:00
Raul Santos d5d1645e15 Bump Godot.NET.Sdk and SourceGenerators versions
Bump `Godot.NET.Sdk` to version 4.0.0-dev6.
Bump `Godot.SourceGenerators` to version 4.0.0-dev3.
Use floating version 4.0.*-* for package references in Sdk.
2021-12-05 15:56:18 +01:00
Raul Santos c52f21335c Fix Godot.SourceGenerators for generic classes
Fix invalid C# generated by source generators for generic classes and
add generic classes to the Sample project for testing.
2021-12-05 15:52:25 +01:00
Rémi Verschelde 7da392bcc5
Don't return reference on copy assignment operators
We prefer to prevent using chained assignment (`T a = b = c = T();`) as this
can lead to confusing code and subtle bugs.

According to https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B), C++
allows any arbitrary return type, so this is standard compliant.

This could be re-assessed if/when we have an actual need for a behavior more
akin to that of the C++ STL, for now this PR simply changes a handful of
cases which were inconsistent with the rest of the codebase (`void` return
type was already the most common case prior to this commit).
2021-11-30 16:26:29 +01:00
Rémi Verschelde 0ae65472e7
clang-format: Enable BreakBeforeTernaryOperators
clang-format keeps breaking the way it handles break *after* ternary operators,
so I give up and go with the only style they seem to actually test.
2021-10-28 15:57:41 +02:00
Rémi Verschelde 3b11e33a09
clang-format: Disable alignment of operands, too unreliable
Sets `AlignOperands` to `DontAlign`.

`clang-format` developers seem to mostly care about space-based indentation and
every other version of clang-format breaks the bad mismatch of tabs and spaces
that it seems to use for operand alignment. So it's better without, so that it
respects our two-tabs `ContinuationIndentWidth`.
2021-10-28 15:19:35 +02:00
ne0fhyk b5c750fa65 Restrict the project data directory configuration 2021-10-18 14:10:38 -07:00
Rémi Verschelde a7ba227631
Merge pull request #52711 from m4gr3d/provide_getter_for_project_data_dir_master 2021-10-05 21:02:27 +02:00
ne0fhyk 69f890ff11 Provide a getter for the project data directory. 2021-09-15 12:52:03 -07:00
Lewis James 913aa270c0 Add editor keyboard shortcut for Mono Build solution button
Apply suggestions from code review

Merging @akien-mga's suggestion with the matching change to the CS project

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-09-14 13:13:00 +01:00
Raul Santos 2962a440ea Fix autoloads iteration
Removes the range iterator usage in the autoloads map since `OrderedHashMap`
does not implement range iterators.
2021-09-12 13:22:18 +02:00
Raul Santos c6b1c8093f Fix properties arrays in C# bindings generator 2021-09-08 12:52:39 +02:00
Raul Santos 415529400b Fix constant tag documentation in C# bindings generator 2021-09-03 18:54:40 +02:00
Raul Santos 5508d4606b Fix PackedInt64Array typo in bindings_generator.h 2021-09-03 18:54:40 +02:00
Aaron Franke 1933df0013
Some more C# formatting 2021-09-02 15:12:15 -05:00
Lyuma 31f790299c Use OrderedHashMap for autoloads to preserve order 2021-08-26 21:55:26 -07:00
Ignacio Roldán Etcheverry d2c3a86844 C#: Fix bindings generator for Callable argument default value
Previously there weren't any Callable arguments with a default value,
but d4dd859991 introduced one.
2021-08-20 11:18:04 +02:00
Max Hilbrunner 81f7d1890b Namespaces instead of underscore prefix for binds
Thanks to neikeq for the initial work.

Co-authored-by: Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com>
2021-08-17 16:10:09 +02:00
Aaron Franke 03e2544d50
Use real_t and double where appropriate in Particles 2021-08-12 11:35:31 -05:00
Raul Santos f20db58271 Ensure MSBuildPanel buttons are instantiated 2021-08-06 22:30:38 +02:00
Yuri Sizov d3e413c659 Fix the editor theme application for the Mono build log 2021-08-03 22:13:32 +03:00
Rémi Verschelde 7cbdb9b4c3
Merge pull request #50917 from raulsntos/more-iterators 2021-07-27 08:05:15 +02:00
Raul Santos d636ebbfe9 Ignore paths with invalid chars in PathWhich 2021-07-27 04:16:20 +02:00
Raul Santos 3fe67fb5ad Use C++ iterators in the Mono module 2021-07-27 02:48:28 +02:00
Raul Santos accd05f4ad Use Array.Empty instead of allocating a every time
Use `System.Array.Empty<T>` to get an empty array instead of allocating
a new one every time. Since arrays are immutable there is no need to
allocate them every time.
2021-07-26 03:52:31 +02:00
Raul Santos b3274a7064 Fix bindings generator range iterator errors 2021-07-25 21:32:54 +02:00
Rémi Verschelde ac3322b0af
Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
Ignacio Roldán Etcheverry 2ee395a277
Merge pull request #50757 from aaronfranke/simple-cs-editorconfig
Add a simple C# `.editorconfig`
2021-07-24 21:48:41 +02:00
Aaron Franke 4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
Aaron Franke 5f8275d9ac
Add a simple C# .editorconfig 2021-07-23 17:04:53 -04:00
reduz 6631f66c2a Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname.
* Subsequent usages use the cached version.
* Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time.
* Replaced all theme usages by this new macro.
* Replace all signal emission usages by this new macro.
* Replace all call_deferred usages by this new macro.

This is part of ongoing work to optimize GUI and the editor.
2021-07-18 21:20:02 -03:00
Rémi Verschelde 671467b888
Mono: Remove info dialog discouraging use in production
While there are still various bugs to solve and features to implement, the C#
support as of Godot 3.4 is fairly mature and already used by a number of users
in production. Now that we default to dotnet CLI as build tool, it also seems
to be more reliable than MSBuild.

The documentation can (and does for the most part) point out some caveats that
users should be aware of, but this info dialog has outlived its intended
purpose.
2021-07-15 11:48:19 +02:00
Grzegorz Puławski fa82727f5b Fixing mono build after instance() -> instanciate() name change 2021-06-23 16:07:23 +02:00
Lightning_A e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Aaron Franke e6c7567da7
Fix a typo in C# bindings generator for default value types 2021-06-18 01:13:00 -04:00
Rémi Verschelde 600b4c9c7b
Merge pull request #34668 from aaronfranke/to-string
[Core] Reformat structure string operators
2021-06-13 11:58:24 +02:00