summaryrefslogtreecommitdiffstats
path: root/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs
Commit message (Collapse)AuthorAgeFilesLines
* Implement [ExportToolButton]Paul Joannon2024-11-181-0/+30
|
* provide analyser corresponding to the GD0001 and GD0002, add ↵Ivan Shakhov2024-02-211-57/+19
| | | | | | | ClassPartialModifierAnalyzerFix, and tests Co-authored-by: Raul Santos <raulsntos@gmail.com> Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
* C#: Various fixes to generic scriptsRaul Santos2024-02-191-0/+10
| | | | | | - Report a diagnostic when there are multiple classes that match the script file name in the same script since that will result in a duplicate path key in the bimap and it's not allowed. - Fix InspectorPlugin to handle empty paths in case the project was built with a previous version of Godot that used empty paths for generic scripts. - Add tests for the new diagnostic GD0003.
* Clean diagnostic rulesPaul Joannon2024-02-181-382/+104
| | | | | | | | Move the following diagnostics into static readonly fields: GD0101, GD0102, GD0103, GD0104, GD0105, GD0106, GD0107, GD0201, GD0202, GD0203, GD0301, GD0302, GD0303, GD0401, GD0402. To be more consistent, the titles for the following diagnostics were modified: GD0101, GD0105, GD0106, GD0302, GD0303, GD0401, GD0402. A subsequent update of the documentation repo is needed. Tests for the following diagnostics were created: GD0201, GD0202, GD0203.
* fix: use correct number in GD0103 linkMikael Klasson2023-12-271-1/+1
|
* Merge pull request #82918 from raulsntos/dotnet/only-node-can-export-nodeRémi Verschelde2023-10-271-0/+25
|\ | | | | | | C#: Report diagnostic for Node exports in a type that doesn't derive from Node
| * C#: Report diagnostic for Node exports in a type that doesn't derive from NodeRaul Santos2023-10-061-0/+25
| |
* | C#: Improve diagnostic messages and add help linkRaul Santos2023-10-171-27/+50
|/ | | | | - Reword diagnostic messages. - Add help link to diagnostics.
* C#: Add a Roslyn analyzer for global classes398utubzyt2023-07-071-0/+60
| | | | Co-Authored-By: Raul Santos <raulsntos@gmail.com>
* C#: Ignore explicit interface implementationsRaul Santos2023-03-041-0/+26
|
* C#: Rename `Object` to `GodotObject`Raul Santos2023-01-271-4/+4
|
* C#: Add `global::` namespace to generated sourceRaul Santos2022-11-261-2/+2
| | | | | Adds `global::` to the fully qualified types in source generators to prevent ambiguity.
* C#: Ignore property indexers and report if exportedRaul Santos2022-08-281-0/+26
| | | | | Ignore property indexers since they are unsupported and report a diagnostic if an user tries to export it.
* Add MustBeVariant attribute and analyzerRaul Santos2022-08-251-9/+102
| | | | | | - 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.
* Improve C# signal analyzer errorsRaul Santos2022-08-221-4/+28
| | | | Report the specific parameters that are not supported.
* C#: Add source generator for signals as eventsIgnacio Roldán Etcheverry2022-08-221-0/+49
| | | | | | | | | 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/+106
| | | | | | | | | | | | | | 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#/netcore: Add base desktop game export implementationIgnacio Roldán Etcheverry2022-08-221-0/+32
| | | | | | | | | 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.
* C#: Add initial implementation of source generator for script membersIgnacio Roldán Etcheverry2022-08-221-3/+2
| | | | | | | | | | | | | | | | | | | | 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/+33
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.