summaryrefslogtreecommitdiffstats
path: root/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs
Commit message (Collapse)AuthorAgeFilesLines
* Fix interpolated strings in ScriptPropertyDefValPaul Joannon2024-03-011-1/+18
|
* Cleanup C# projects, code quality & stylePaul Joannon2024-02-271-1/+1
| | | | | | | | | | | | | | | | | | | | | New rules: - Do not silence CA1805 any more - Limit where we silence CA1707, CA1711, CA1720 - Enforce severity=warning for IDE0040 - Enforce Allman style braces - Enforce naming conventions (IDE1006 is still severity=suggestion) Fixes: - Fix REFL045, CS1572, CS1573 - Suppress CS0618 when generating `InvokeGodotClassMethod` - Fix indent when generating GD_constants.cs - Temporarily silence CS1734 in generated code - Fix a lot of naming rule violations Misc.: - Remove ReSharper comments for RedundantNameQualifier - Remove suppression attributes for RedundantNameQualifier - Remove severity=warnings for CA1716, CA1304 (already included in the level of analysis we run)
* Clean diagnostic rulesPaul Joannon2024-02-181-0/+5
| | | | | | | | 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.
* C#: Report diagnostic for Node exports in a type that doesn't derive from NodeRaul Santos2023-10-061-1/+1
|
* Allow readonly and writeonly C# properties to be accessed from GDScriptWilliam Scalf2023-08-131-9/+0
|
* Merge pull request #79007 from 398utubzyt/dotnet/globalclass-analyzerYuri Sizov2023-07-141-2/+2
|\ | | | | | | C#: Add a Roslyn analyzer for global classes
| * C#: Add a Roslyn analyzer for global classes398utubzyt2023-07-071-2/+2
| | | | | | | | Co-Authored-By: Raul Santos <raulsntos@gmail.com>
* | C#: Compare symbol names without null flow stateRaul Santos2023-07-061-7/+7
|/
* C#: Add global class supportRaul Santos2023-05-291-0/+3
| | | | Co-authored-by: willnationsdev <willnationsdev@gmail.com>
* Add fine-grained disabling of SourceGeneratorsAlex de la Mare2023-03-251-0/+6
| | | | | This allows manual testing and/or alternate source generators to provide functionality without conflict.
* C#: Rename `Object` to `GodotObject`Raul Santos2023-01-271-1/+1
|
* C#: Disallow init-only propertiesRaul Santos2022-12-231-2/+2
| | | | | | 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.
* C#: Cleanup Variant marshaling code in source/bindings generatorsIgnacio Roldán Etcheverry2022-12-021-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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`
* C#: Add `global::` namespace to generated sourceRaul Santos2022-11-261-14/+21
| | | | | Adds `global::` to the fully qualified types in source generators to prevent ambiguity.
* Fully qualify C# default values in exported fields.R. Alex Hofer2022-11-221-0/+45
| | | | | This avoids issues when the default values rely on using namespaces.
* C#: Guard against null assembliesRaul Santos2022-09-221-2/+2
| | | | | A symbol's containing assembly will be null if the symbol is shared across multiple assemblies.
* C#: Preserve order of exported fields/categoriesPaul Joannon2022-08-251-0/+8
|
* Add MustBeVariant attribute and analyzerRaul Santos2022-08-251-0/+3
| | | | | | - 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 source generator for signals as eventsIgnacio Roldán Etcheverry2022-08-221-25/+39
| | | | | | | | | Changed the signal declaration signal to: ``` // The following generates a MySignal event [Signal] public delegate void MySignalEventHandler(int param); ```
* C#: Re-implement assembly reloading with ALCsIgnacio Roldán Etcheverry2022-08-221-2/+8
|
* C#: Static marshaling for bindings and source generatorsIgnacio Roldán Etcheverry2022-08-221-1/+2
| | | | | | | | | | | | 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.
* C#: Add source generator for properties and exports default valuesIgnacio Roldán Etcheverry2022-08-221-14/+134
| | | | | | | | | | | | | | 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-1/+45
| | | | | | | | | 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-5/+7
| | | | | | | | | | | | | | | | | | | | 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.
* C#: Fix ScriptPathAttribute generator with none or nested namespacesIgnacio Etcheverry2021-03-131-0/+3
| | | | | | | | | | | The following two bugs were fixed: - For classes without namespace we were still generating `namespace {` without a namespace identifier, causing a syntax error. - For classes with nested namespaces we were generating only the innermost part of the namespace was being generated, e.g.: for `Foo.Bar` we were generating `namespace Bar {` instead of `namespace Foo.Bar {`. This wasn't causing any build error, but because of the wrong namespace Godot wasn't able to find the class associated with the script.
* Add C# source generator for a new ScriptPath attributeIgnacio Etcheverry2021-03-061-0/+86
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.