godot/modules/mono
Ignacio Etcheverry e2afe700f6 Add C# source generator for a new ScriptPath attribute
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.
2021-03-06 21:50:32 +01:00
..
build_scripts Add C# source generator for a new ScriptPath attribute 2021-03-06 21:50:32 +01:00
doc_classes Add link titles for all links in the class reference 2020-08-31 14:22:07 +02:00
editor Add C# source generator for a new ScriptPath attribute 2021-03-06 21:50:32 +01:00
glue Add C# source generator for a new ScriptPath attribute 2021-03-06 21:50:32 +01:00
icons Optimize SVG using svgcleaner --multipass 2020-10-25 10:02:37 +01:00
mono_gd Add C# source generator for a new ScriptPath attribute 2021-03-06 21:50:32 +01:00
utils Update Mono module to use new execute method. 2021-01-13 09:34:14 +00:00
__init__.py Re-write mono module editor code in C# 2019-07-05 09:38:23 +02:00
.gitignore Make git no longer ignore solution files inside the mono module 2019-08-12 15:59:06 +02:00
class_db_api_json.cpp Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
class_db_api_json.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
config.py Mono: Add mono_bcl SCons option for a custom BCL location 2020-12-06 01:15:20 +01:00
csharp_script.cpp Add C# source generator for a new ScriptPath attribute 2021-03-06 21:50:32 +01:00
csharp_script.h Add C# source generator for a new ScriptPath attribute 2021-03-06 21:50:32 +01:00
Directory.Build.props Add C# source generator for a new ScriptPath attribute 2021-03-06 21:50:32 +01:00
godotsharp_defs.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
godotsharp_dirs.cpp Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
godotsharp_dirs.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
managed_callable.cpp Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
managed_callable.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
mono_gc_handle.cpp Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
mono_gc_handle.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
register_types.cpp Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
register_types.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
SCsub C#: Make editor create NuGet fallback folder for Godot packages 2020-10-23 10:54:49 +02:00
SdkPackageVersions.props Add C# source generator for a new ScriptPath attribute 2021-03-06 21:50:32 +01:00
signal_awaiter_utils.cpp Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
signal_awaiter_utils.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00