{"id":25407667,"url":"https://github.com/codartesien/godot-source-generators-csharp","last_synced_at":"2026-04-29T17:05:49.571Z","repository":{"id":276038333,"uuid":"927807499","full_name":"codartesien/godot-source-generators-csharp","owner":"codartesien","description":"A collection of source generators for Godot 4+ C# projects.","archived":false,"fork":false,"pushed_at":"2025-02-05T23:11:29.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-16T07:18:01.976Z","etag":null,"topics":["csharp","godot","source-generator"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codartesien.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-05T15:22:11.000Z","updated_at":"2025-02-05T23:11:32.000Z","dependencies_parsed_at":"2025-02-05T23:38:18.685Z","dependency_job_id":"030e81d3-4b54-4d3b-887c-2da77e9d5238","html_url":"https://github.com/codartesien/godot-source-generators-csharp","commit_stats":null,"previous_names":["codartesien/godot-source-generators-csharp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codartesien%2Fgodot-source-generators-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codartesien%2Fgodot-source-generators-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codartesien%2Fgodot-source-generators-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codartesien%2Fgodot-source-generators-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codartesien","download_url":"https://codeload.github.com/codartesien/godot-source-generators-csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248704523,"owners_count":21148387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","godot","source-generator"],"created_at":"2025-02-16T07:17:51.808Z","updated_at":"2026-04-29T17:05:49.487Z","avatar_url":"https://github.com/codartesien.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Godot C# Source Generators\n\nA collection of source generators for Godot 4+ C# projects.\n\n## Installation\n\nGit clone this repository and build the project using `dotnet build`. \n\nThen reference the generated assembly in your main project:\n\n```xml\n\u003cItemGroup\u003e\n    \u003cProjectReference Include=\"\u003cpath_to_solution\u003e\\Codartesien.SourceGenerators.csproj\" OutputItemType=\"Analyzer\" /\u003e\n\u003c/ItemGroup\u003e\n```\n\nIf you need to debug the source generators, you can add the following to your main project file:\n\n```xml\n\u003cItemGroup\u003e\n    \u003c!-- Uncomment to have the generated files dumped in the project (.godot/mono/temp/obj/Generated) --\u003e\n    \u003cEmitCompilerGeneratedFiles\u003etrue\u003c/EmitCompilerGeneratedFiles\u003e\n    \u003cCompilerGeneratedFilesOutputPath\u003e$(BaseIntermediateOutputPath)Generated\u003c/CompilerGeneratedFilesOutputPath\u003e\n\u003c/ItemGroup\u003e\n```\n\n## Source Generators\n\n### SceneNodeResolver\n\nThis source generator generates code to automatically resolve scene nodes in your scripts.\nYour scene nodes must have a `SceneNode` attribute with the path to the node in the scene.\nIt generates a partial class with a public `ResolveNodes()` method that you can call in your `_Ready()` method.\n\n```csharp\nusing Godot;\nusing Codartesien.SourceGenerators;\n\npublic partial class MyNode : Node\n{\n    [SceneNode(\"Sprite\")]\n    private Sprite _sprite;\n\n    [SceneNode(\"%MyLabel\")]\n    private Label _label;\n\n    public override void _Ready()\n    {\n        base._Ready();\n        ResolveNodes();\n    }\n}\n```\n\n### DependencyResolver\n\nThis source generator generates code to automatically resolve dependencies targeting Godot globals (aka autoload or singletons) in your `Node` scripts.\nThink of this as a simple dependency injection system for your Godot project. \n\n\u003e [!NOTE]  \n\u003e As this generator relies on the `GetTree()` method, `[InjectDependency]` attribute can only be used in scripts that inherit from `Node` (so not in raw C# classes).\n\nFor example, if you add the `HappinessManager` class as a global node in your project, you'll be able to inject it in your scripts using the `[InjectDependency]` attribute.\n\n```csharp\nusing Godot;\nusing Codartesien.SourceGenerators;\n\npublic partial class MyNode : Node\n{\n    [InjectDependency]\n    private HappinessManager _happinessManager;\n\n    public override void _Ready()\n    {\n        base._Ready();\n        ResolveDependencies();\n        \n        _happinessManager.DoSomething();\n    }\n}\n```\n\nYou can use the `[InjectDependency]` attribute on any property which related to a global node in your project.\n\nUnder the hood, the source generator creates a dictionary of all children of the `root` node and inject them in the fields marked with the `[InjectDependency]` attribute.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodartesien%2Fgodot-source-generators-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodartesien%2Fgodot-source-generators-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodartesien%2Fgodot-source-generators-csharp/lists"}