summaryrefslogtreecommitdiffstats
path: root/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/GodotClasses.cs
Commit message (Collapse)AuthorAgeFilesLines
* Implement [ExportToolButton]Paul Joannon2024-11-181-0/+2
|
* Add tests and fix exports diagnosticsPaul Joannon2024-02-201-0/+1
| | | | | | - Add tests for the following diagnostics: GD0101, GD0102, GD0103, GD0104, GD0105, GD0106, GD0107. - Fix GD0101 not being reported any more (was filtering static classes before reporting). - Fix GD0107 not preventing `Node` members from being exported from not-`Node` types.
* C#: Add global class supportRaul Santos2023-05-291-0/+1
| | | | Co-authored-by: willnationsdev <willnationsdev@gmail.com>
* C#: Rename `Object` to `GodotObject`Raul Santos2023-01-271-1/+1
|
* C#: Renames to follow .NET naming conventionsRaul Santos2023-01-271-1/+1
| | | | Renamed C# types and members to use PascalCase and follow .NET naming conventions.
* Add MustBeVariant attribute and analyzerRaul Santos2022-08-251-0/+1
| | | | | | - 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.
* C#: Add grouping attributes for properties.Zae2022-08-231-0/+3
|
* C#: Add source generator for signals as eventsIgnacio Roldán Etcheverry2022-08-221-0/+1
| | | | | | | | | Changed the signal declaration signal to: ``` // The following generates a MySignal event [Signal] public delegate void MySignalEventHandler(int param); ```
* C#: Add source generator for properties and exports default valuesIgnacio Roldán Etcheverry2022-08-221-0/+3
| | | | | | | | | | | | | | 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.
* C#: Add initial implementation of source generator for script membersIgnacio Roldán Etcheverry2022-08-221-1/+0
| | | | | | | | | | | | | | | | | | | | 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.
* Add C# source generator for a new ScriptPath attributeIgnacio Etcheverry2021-03-061-0/+9
This source generator adds a newly introduced attribute, `ScriptPath` to all classes that: - Are top-level classes (not inner/nested). - Have the `partial` modifier. - Inherit `Godot.Object`. - The class name matches the file name. A build error is thrown if the generator finds a class that meets these conditions but is not declared `partial`, unless the class is annotated with the `DisableGodotGenerators` attribute. We also generate an `AssemblyHasScripts` assembly attribute which Godot uses to get all the script classes in the assembly, eliminating the need for Godot to search them. We can also avoid searching in assemblies that don't have this attribute. This will be good for performance in the future once we support multiple assemblies with Godot script classes. This is an example of what the generated code looks like: ``` using Godot; namespace Foo { [ScriptPathAttribute("res://Player.cs")] // Multiple partial declarations are allowed [ScriptPathAttribute("res://Foo/Player.cs")] partial class Player {} } [assembly:AssemblyHasScripts(new System.Type[] { typeof(Foo.Player) })] ``` The new attributes replace script metadata which we were generating by determining the namespace of script classes with a very simple parser. This fixes several issues with the old approach related to parser errors and conditional compilation. It also makes the task part of the MSBuild project build, rather than a separate step executed by the Godot editor.