Commit graph

112 commits

Author SHA1 Message Date
Yuri Sizov
0a9006a5aa Merge pull request #79501 from raulsntos/dotnet/warnings/NU5128
C#: Suppress NU5128 warning
2023-08-02 21:36:51 +02:00
Yuri Sizov
b78fe83ed4 Merge pull request #79239 from raulsntos/dotnet/document-generated-members
C#: Document generated members
2023-07-25 21:51:20 +02:00
Yuri Sizov
f8f06d3d38
Merge pull request #78264 from magian1127/4.0StringName
C#: Add `PropertyHint.Enum` support to `Array<StringName>`
2023-07-18 12:19:37 +02:00
Raul Santos
f2e9cbf9e8
C#: Suppress NU5128 warning
Suppress dependencies of SourceGenerators package to fix NU5128.
2023-07-15 15:25:37 +02:00
Yuri Sizov
bb6879e7cc Merge pull request #79007 from 398utubzyt/dotnet/globalclass-analyzer
C#: Add a Roslyn analyzer for global classes
2023-07-14 18:49:16 +02:00
Raul Santos
12e4aa93b3
C#: Document generated members
Documents generated members and tries to discourage users from calling/overriding internal methods that only exist to be used by the engine.
2023-07-09 14:26:15 +02:00
398utubzyt
8e56c807cc C#: Add a Roslyn analyzer for global classes
Co-Authored-By: Raul Santos <raulsntos@gmail.com>
2023-07-07 16:37:16 -07:00
Rémi Verschelde
26a58976e7
Merge pull request #79094 from raulsntos/dotnet/fix-symbol-comparison
C#: Compare symbol names without null flow state
2023-07-07 08:35:20 +02:00
Raul Santos
671a5b4ea5
C#: Compare symbol names without null flow state 2023-07-06 16:10:14 +02:00
Rémi Verschelde
8a847d82a8
Merge pull request #78722 from RedworkDE/net-auto-version-defines
C#: Automatically generate version defines
2023-07-05 22:15:47 +02:00
Rémi Verschelde
346f1ab86b
Bump version to 4.2-dev
Keep on waitin'
2023-07-05 22:07:03 +02:00
RedworkDE
fe7c27b086 C#: Automatically generate version defines 2023-06-28 21:45:58 +02:00
Raul Santos
8f6166bd14
C#: Remove whitespace from define constants
Co-authored-by: RedworkDE <10944644+RedworkDE@users.noreply.github.com>
2023-06-20 14:33:45 +02:00
Raul Santos
48e20c628a
C#: Set PropertyInfo.class_name for method parameters 2023-06-16 23:19:38 +02:00
RedworkDE
1b466c6298 C#: Add version defines to help users deal with breaking changes 2023-06-15 13:18:04 +02:00
Magian
e8aeb6baa0 C# Array<StringName> support PropertyHint.Enum 2023-06-15 16:01:42 +08:00
Raul Santos
a1f454fee3
C#: Add global class support
Co-authored-by: willnationsdev <willnationsdev@gmail.com>
2023-05-29 19:04:02 +02:00
Raul Santos
a34207b812
Reorder PropertyHint enum to avoid breaking compat
Also syncs the Core enum with the C# enum for the source generators.
2023-05-12 01:48:07 +02:00
Alex de la Mare
8ab3295e57 Add fine-grained disabling of SourceGenerators
This allows manual testing and/or alternate source generators to
provide functionality without conflict.
2023-03-25 13:46:12 +11:00
RedworkDE
6019f497b8 C#: Fix building projects for MSBuild before 17.3 2023-03-06 17:58:20 +01:00
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
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
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
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
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
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
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
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
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
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
Raul Santos
1a4c8856ec
C#: Rename SignalInfo to Signal and make awaitable 2022-12-12 17:30:14 +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