Creating a Source Generator for Godot's property changes

Posted by Miha Markič on January 26, 2026 · 2 mins read

Note: This post is based on README from my Righthand Godot Properties Changed Source Generator project.

I think we all agree that wiring boilerplate code is tedious and too verbose at best. Not to dwell too much into the subject, consider this code, which is a typical verbose code one has to write when dealing with not dumb properties in Godot scripts.

private int _simpleExportedWithDefault = 5;

[Export]
public int SimpleExportedWithDefault
{
	get => _simpleExportedWithDefault;
	set
	{
		if (_simpleExportedWithDefault != value)
		{
			_simpleExportedWithDefault = value;
			UpdateState(nameof(SimpleExportedWithDefault));
		}
	}
}
private void UpdateState(string? propertyName)
{
	QueueRedraw();
}

Such code is usually required when one wants to update Godot’s scene in editor where node is expected to request QueueRedraw on changes.

Isn’t the code below more readable and terse? Not to mention less typing.

[Export, DefaultValue(5)]
public partial int SimpleExportedWithDefault { get; set; }

private void UpdateState(string? propertyName)
{
	QueueRedraw();
}

The actual implementation code is generated by source code generator behind the scenes.

Does it look useful? It certainly does to me. The source generator is currently in beta phase, so make sure you enable prerelease nuget versions. The actual source code generator handles more complex scenarios as well, make sure you read instructions.

Find the project hosted at Codeberg, an EU based a democratic community-driven, non-profit software development platform and include it into your Godot’s project through NuGet source.