$ show Cat-Lips/GodotSharp.SourceGenerators
The GodotSharp.SourceGenerators repository provides a set of Roslyn source generators designed to enhance the Godot Engine C# development experience. These generators inspect C# source code for specific attributes (such as `[SceneTree]`, `[AnimNames]`, `[AudioBus]`, etc.) and generate corresponding strongly-typed accessor code, eliminating the need for magic strings and improving compile-time safety. The project supports both Godot 3 and Godot 4 versions, with a clear migration path outlined in the documentation. The architecture follows a modular pattern where each feature (e.g., scene tree access, animation names) is implemented as a separate extension. Each extension consists of an attribute, a data model, a scraper to extract information from the project and source files, a source generator that uses Scriban templates to produce C# code, and the template itself. Shared utilities handle common tasks such as path resolution, string manipulation, and unique ID generation, promoting code reuse and consistency across generators. The repository includes extensive test suites for both Godot 3 and 4, validating the generated code against various scenarios including inheritance, same-name handling, nullable reference types, and edge cases. This ensures the generators remain robust despite Godot's evolving API. The project is actively maintained, with recent commits and a structured approach to handling breaking changes between versions.
The LLM identified 3 files worth highlighting for reuse:
A lightweight C# symbol scraper that uses regex and string parsing to extract class, method, and property information without relying on Roslyn. It is completely self-contained with no internal dependencies, demonstrating skill in parsing C# for specific use cases where a full compiler is unnecessary or unavailable. This component can be extracted and used in any code generation or analysis tool that needs basic C# symbol information.
A set of string extension methods providing common transformations for code generation, such as converting strings to valid C# identifiers, removing file extensions, and handling Godot-specific naming conventions. It has zero internal dependencies and is self-contained, making it easily reusable in any .NET project that requires string manipulation for symbol generation or code formatting.
A simple utility that generates a unique identifier from an input string using a hash algorithm. It is self-contained with no dependencies beyond System, demonstrating a reliable pattern for avoiding name collisions in generated code. This component can be directly copied into any project needing deterministic unique ID generation from string inputs.