Commit Graph

434 Commits

Author SHA1 Message Date
5815d1c8c8 Improve handling of generic C# types
- Create CSharpScript for generic C# types.
  - `ScriptPathAttributeGenerator` registers the path for the generic type definition.
  - `ScriptManagerBridge` lookup uses the generic type definition that was registered by the generator.
  - Constructed generic types use a virtual `csharp://` path so they can be registered in the map and loaded as if there was a different file for each constructed type, even though they all share the same real path.
  - This allows getting the base type for a C# type that derives from a generic type.
- Shows base scripts in the _Add Node_ and _Create Resource_ dialogs even when they are generic types.
  - `get_global_class_name` implementation was moved to C# and now always returns the base type even if the script is not a global class (this behavior matches GDScript).
- Create `CSharpScript::TypeInfo` struct to hold all the type information about the C# type that corresponds to the `CSharpScript`, and use it as the parameter in `UpdateScriptClassInfo` to avoid adding more parameters.
2024-02-08 18:31:13 +01:00
8ce4a0cf15 C#: Fix crash when reloading scripts
The crash cond was accidentally moved to the `reload_scripts` method when it was only meant to be in the `reload_tool_script` method. Same about restarting the HotReloadAssemblyWatcher timer.

Also removed the loop that checks if the script array contains a C# script because if we're in CSharpLanguage we can assume that at least one of them is.
2024-02-07 06:33:51 +01:00
9d50a486bf Fixed ~CSharpScript() holding on to a mutex longer than necessary, creating potential for a deadlock. 2024-01-28 21:28:14 +01:00
3bbf4abfaa Merge pull request #87550 from zaevi/fix_csharp_generic_reloading
C#: Fix sorting for generic types when reloading assemblies.
2024-01-26 11:48:18 +01:00
d36f5cf2ba Merge pull request #85504 from nongvantinh/fix-csharp-loader
Fix C# script loader does not work reliably
2024-01-26 11:42:01 +01:00
Zae
18599c0935 C#: Fix sorting for generic types when reloading assemblies. 2024-01-26 18:00:46 +08:00
7676e389a7 Fixes C# script loader does not work reliably 2024-01-22 04:20:27 +07:00
b6a2c78033 Merge pull request #87286 from akien-mga/fix-preprocessor-if-ENABLED-checks
Fix `#if *_ENABLED` inconsistencies, should check if defined
2024-01-17 18:53:33 +01:00
c027aecc2e Merge pull request #86676 from rune-scape/sparse-script-reload
GDScript: Hot-reload changed scripts only
2024-01-17 18:52:54 +01:00
0a7579b161 Fix #if *_ENABLED inconsistencies, should check if defined
Co-authored-by: Caroline Joy Bell <halotroop2288@proton.me>
2024-01-17 10:30:15 +01:00
Zae
51c54b03d1 C#: Fix return type hint for methods. 2024-01-09 04:28:17 +08:00
96a95cb974 Add const lvalue ref to container parameters 2024-01-05 14:49:57 -03:00
cde478bda6 Hot-reload only changed scripts 2024-01-02 17:56:52 -08:00
0818d015db Inspector ⚠️ when C# props might be out of date 2023-12-22 23:27:13 +01:00
a351c4bbe3 C#: Use get_instance_binding instead of set 2023-11-15 21:06:13 +01:00
3936871077 C#: Fail callp silently if script is not valid 2023-11-14 16:56:16 +01:00
ce53362f98 Merge pull request #83670 from raulsntos/notification-predelete-cleanup
Add `NOTIFICATION_PREDELETE_CLEANUP` notification to fix C# `Dispose()`
2023-11-09 11:45:49 +01:00
6afd320984 Merge pull request #78157 from RedworkDE/net-shutting-down-abruptly
C#: Fix crash with `DisposablesTracker_OnGodotShuttingDown`
2023-10-31 20:52:27 +01:00
9750e49c57 Add NOTIFICATION_PREDELETE_CLEANUP notification
New notification sent after `NOTIFICATION_PREDELETE` to let Objects cleanup at the very end, it should be the last notification sent.
2023-10-20 13:43:42 +02:00
be1dfd3b3a C#: Allow exporting games without C#
When exporting a game that contains a C# solution, a feature is added so the exported game can check if it should initialize the .NET module. Otherwise, the module initialization is skipped so games without C# won't check for the assemblies and won't show alerts when they're missing.
2023-10-16 05:07:11 +02:00
de7cbe8789 Highlight doc comments in a different color 2023-10-08 19:26:10 +03:00
d759f91f8d Merge pull request #81101 from 398utubzyt/dotnet/abstract-class-support
C#: Add abstract class support
2023-09-25 17:18:05 +02:00
1a0e653d7f Merge pull request #78573 from dalexeev/editor-create-script-class-name
Editor: Remove unused Class Name field from Create Script dialog
2023-09-25 17:17:46 +02:00
ce0fa4c691 Merge pull request #81783 from zaevi/fix-csharp-static-method
C#: make C# static methods accessible.
2023-09-20 18:55:10 +02:00
Zae
67e1373e5a C#: make C# static methods accessible. 2023-09-20 22:49:33 +08:00
2df37a237a C#: Abstract script class support 2023-09-15 20:35:25 -07:00
26ce861910 Editor: Remove unused Class Name field from Create Script dialog 2023-09-12 12:49:56 +03:00
4b5daf06ef Editor: Improve signal callback generation 2023-09-11 18:45:39 +03:00
1594acc64e Merge pull request #81073 from raulsntos/dotnet/cached-string-names
C#: Replace `StringNameCache` with `SNAME`
2023-08-31 08:54:53 +02:00
c4705a590b Fix Object::notification order
Previously the `p_reversed` parameter didn't influence the order
in a correct way.
Also script overridden _notification functions were not called in
the correct order.

To fix this some `notification` functions had to add a `p_reversed`
parameter.

This made it necessary to adjust cpp-bindings.

Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-08-30 00:15:55 +02:00
6d7d083254 C#: Replace StringNameCache with SNAME 2023-08-28 15:41:26 +02:00
67db4693eb Expose _validate_property() for scripting 2023-08-28 15:18:48 +02:00
6b713b1682 C#: Generate instance types for singletons 2023-08-06 00:48:22 +02:00
03598062fd C#: Move build button to EditorRunBar
- Move C# build button to `EditorRunBar`.
- Add C# build icon.
- Add shortcut macros to `GodotTools`.
- Move C# build shortcuts to C#.
2023-08-03 17:55:52 +02:00
f3f3365abd C#: Fix command line exporting 2023-07-07 20:51:46 +02:00
60b9eb169e C# Fix reloading of non-tool scripts 2023-06-28 11:46:43 +02:00
e0f644a48d C#: Fix editor integration breaking and causing error spam when reloading assemblies fails
- Do not reload scripts from non-collectible assemblies
- Do not load GodotTools as collectible
- Do not attempt to reload the same project assembly forever
2023-06-21 12:47:52 +02:00
48e20c628a C#: Set PropertyInfo.class_name for method parameters 2023-06-16 23:19:38 +02:00
25b2f1780a Style: Harmonize header includes in modules
This applies our existing style guide, and adds a new rule to that style
guide for modular components such as platform ports and modules:

Includes from the platform port or module ("local" includes) should be listed
first in their own block using relative paths, before Godot's "core" includes
which use "absolute" (project folder relative) paths, and finally thirdparty
includes.

Includes in `#ifdef`s come after their relevant section, i.e. the overall
structure is:

- Local includes
  * Conditional local includes
- Core includes
  * Conditional core includes
- Thirdparty includes
  * Conditional thirdparty includes
2023-06-15 14:35:45 +02:00
92f13ba9ea C#: Unify project name handling and fix issues with the handling of some special characters
Co-authored-by: Raul Santos <raulsntos@gmail.com>
2023-06-14 21:07:58 +02:00
d515fcc47a C#: Fix crash with DisposablesTracker_OnGodotShuttingDown 2023-06-13 07:49:21 +02:00
1c1d1a1e2e Fix crash when using base types of extension-based types from C# 2023-06-12 18:29:52 +02:00
e2fcc4de34 Merge pull request #75188 from RedworkDE/net-synchronize-insert
C#: Synchronize adding ScriptInstances
2023-06-06 20:39:16 +02:00
a1f454fee3 C#: Add global class support
Co-authored-by: willnationsdev <willnationsdev@gmail.com>
2023-05-29 19:04:02 +02:00
8fdebb85ef C#: Synchronize adding ScriptInstances 2023-05-22 21:40:14 +02:00
156a2fabea Merge pull request #76659 from shana/shana/75152-fix-crash-when-initializing-glue-generation
Skip initializing the C# runtime when generating glue bindings
2023-05-19 17:10:40 +02:00
e56fdc8a9a Skip initializing the C# runtime when generating glue bindings
The bindings generator doesn't require the C# runtime in order to generate
the glue, and when it the glue generation runs, it exits immediately
afterwards, so we can skip this initialization when the `--generate-mono-glue`
flag is passed in.

Fixes issue 75152
2023-05-18 13:57:42 +02:00
610877e326 Merge pull request #72288 from MewPurPur/use-string-repeat
Use `String.repeat()` to optimize several String methods
2023-05-05 09:56:48 -07:00
6b84e258d2 Use String.repeat() in more places 2023-05-01 02:27:46 +02:00
ff5d8c4a42 Fix "hides member" warnings in csharp_script.cpp 2023-03-25 14:44:12 +01:00