Shaka.Godot.OnReady 1.0.1-pre.815ac57

This is a prerelease version of Shaka.Godot.OnReady.
dotnet add package Shaka.Godot.OnReady --version 1.0.1-pre.815ac57
                    
NuGet\Install-Package Shaka.Godot.OnReady -Version 1.0.1-pre.815ac57
                    
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="Shaka.Godot.OnReady" Version="1.0.1-pre.815ac57" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shaka.Godot.OnReady" Version="1.0.1-pre.815ac57" />
                    
Directory.Packages.props
<PackageReference Include="Shaka.Godot.OnReady" />
                    
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 Shaka.Godot.OnReady --version 1.0.1-pre.815ac57
                    
#r "nuget: Shaka.Godot.OnReady, 1.0.1-pre.815ac57"
                    
#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 Shaka.Godot.OnReady@1.0.1-pre.815ac57
                    
#: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=Shaka.Godot.OnReady&version=1.0.1-pre.815ac57&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Shaka.Godot.OnReady&version=1.0.1-pre.815ac57&prerelease
                    
Install as a Cake Tool

Shaka.Godot.OnReady

Source generator for Godot 4 .NET version. It adds an OnReady attribute which automatically implements a property or method which calls GetNode or GetNodeOrNull.

Setup

Add the Shaka.Godot.OnReady package through nuget package manager.

Or add this to your csproj file:

<ItemGroup>
    <PackageReference Include="Shaka.Godot.OnReady" Version="1.0.0"/>
</ItemGroup>

Usage

Add the Onready attribute to any partial property or method in a class deriving from Godot.Node.

Property(Only available from .NET9):

public partial class Player : CharacterBody2D
{
    [OnReady("%Sprite2D")]
    private partial Sprite2D Sprite { get; }
}

This will generate:

public partial class Player
{
    private Sprite2D? _sprite;
    private Sprite2D Sprite => _sprite ??= GetNode("%Sprite2D");
}

Method:

public partial class Player : CharacterBody2D
{
    [OnReady("%Sprite2D")]
    private partial Sprite2D Sprite();
}

This will generate:

public partial class Player
{
    private Sprite2D? _sprite;
    private Sprite2D Sprite
    {
        return _sprite ??= GetNode("%Sprite2D");
    }
}

Nullable

When using a nullable type, the generator will instead generate this:

public partial class Player
{
    private Sprite2D? _sprite;
    private Sprite2D? Sprite => _sprite ??= GetNodeOrNull("%Sprite2D");
}

This way your code will not crash when getnode fails and you can handle nulls yourself.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1-pre.815ac57 0 11/23/2024
1.0.0 0 11/23/2024