BrooklynLittell.GodotExportValidator 1.0.0

dotnet add package BrooklynLittell.GodotExportValidator --version 1.0.0
                    
NuGet\Install-Package BrooklynLittell.GodotExportValidator -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BrooklynLittell.GodotExportValidator" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BrooklynLittell.GodotExportValidator" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="BrooklynLittell.GodotExportValidator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BrooklynLittell.GodotExportValidator --version 1.0.0
                    
#r "nuget: BrooklynLittell.GodotExportValidator, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BrooklynLittell.GodotExportValidator@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BrooklynLittell.GodotExportValidator&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=BrooklynLittell.GodotExportValidator&version=1.0.0
                    
Install as a Cake Tool

GodotExportValidator

Validates C# Godot exports to catch null values earlier.

Built using Godot 4.7, but should support Godot 4.5+

Usage

  1. Add Nuget Package to your Godot C# project
  2. Follow the following example

Example

// Player.cs

using GodotExportValidator;

[ExportValidation]                   // <- Class Attribute
public partial class Player : CharacterBody3D
{
    [Export]
    [ExportNullCheck]                // <- Export Attribute
    private HealthComponent _healthComponent;
    
    [Export]
    [ExportNullCheck]                // <- Export Attribute
    private Camera3D _camera;
    
    public override void _Ready()
    {
        ValidateExports();           // <- Generated Function
    }
}

<details>

<summary>Generated Code</summary>

// Player.g.cs
// This file will not appear in your editor but is consumed by the compiler

public partial class Player
{
    private void ValidateExports()
    {
        if (_healthComponent == null)
        {
            GD.PushError("Null Export: Player _healthComponent HealthComponent");
        }
        if (_camera == null)
        {
            GD.PushError("Null Export: Player _camera Camera3D");
        }
    }
}

</details>

Why?

Most sample code for Godot references scene nodes using GetNode<T>("NodeName"). I don't like this because it conflates editor context with script context. Scripts should not need to track editor node names, and editor organizational changes should not impact script function.

Whenever my scripts need to reference nodes in their scene, I instead [Export] the nodes. This makes it clear in the editor when a certain node is required, while at the same time separating script naming conventions from the editor. However, it can be easy to forget to hook-up a node export, or, depending on the editor action, accidentally disconnect a node export. When this happens scripts will stop working but not neccessarily be obvious.

To help catch these errors faster, I check for Node null values in _Ready. This leads to boilerplate bloat this is better handled by a source generator. Thus, this library 😃

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 108 8/19/2026
1.0.0-preview.1 76 8/19/2026