GodotSharpAnalyzers 0.1.0

dotnet add package GodotSharpAnalyzers --version 0.1.0
                    
NuGet\Install-Package GodotSharpAnalyzers -Version 0.1.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="GodotSharpAnalyzers" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GodotSharpAnalyzers" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="GodotSharpAnalyzers" />
                    
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 GodotSharpAnalyzers --version 0.1.0
                    
#r "nuget: GodotSharpAnalyzers, 0.1.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 GodotSharpAnalyzers@0.1.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=GodotSharpAnalyzers&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GodotSharpAnalyzers&version=0.1.0
                    
Install as a Cake Tool

GodotSharpAnalyzers

Roslyn analyzers for Godot C# projects to catch common pitfalls and enforce best practices.

Features

  • Detect common Godot C# anti-patterns
  • Provide code fixes for common issues
  • Help enforce Godot best practices
  • Support for Godot 4.x projects using .NET 8.0+

Installation

Via NuGet Package Manager

dotnet add package GodotSharpAnalyzers

Via PackageReference

<PackageReference Include="GodotSharpAnalyzers" Version="0.1.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>analyzers; build</IncludeAssets>
</PackageReference>

Analyzer Rules

  • GD0001 (Memory): Signal connections should be disconnected to prevent memory leaks
  • GD0001a (Memory): Signal connected to lambda expression (informational)

Configuration

You can customize the analyzer behavior by setting MSBuild properties in your project file:

Disable All Analyzers

<PropertyGroup>
  <EnableGodotSharpAnalyzers>false</EnableGodotSharpAnalyzers>
</PropertyGroup>

Disable Specific Rules

<PropertyGroup>
  <GodotSharpAnalyzersDisableSignalConnectionLeak>true</GodotSharpAnalyzersDisableSignalConnectionLeak>
  <GodotSharpAnalyzersDisableSignalLambdaConnectionLeak>true</GodotSharpAnalyzersDisableSignalLambdaConnectionLeak>
</PropertyGroup>

Treat Signal Connection Leak Rule as Error

<PropertyGroup>
  <GodotSharpAnalyzersSignalConnectionLeakAsError>true</GodotSharpAnalyzersSignalConnectionLeakAsError>
</PropertyGroup>

Suppress Singleton Signal Warnings

Option 1: Using MSBuild properties (recommended)

<PropertyGroup>
  <GodotSharpAnalyzersSuppressSingletonSignals>true</GodotSharpAnalyzersSuppressSingletonSignals>
</PropertyGroup>

Option 2: Using .editorconfig

[*.cs]
godot_analyzer.suppress_singleton_signals = true

Show Information Messages

<PropertyGroup>
  <GodotSharpAnalyzersShowInfo>true</GodotSharpAnalyzersShowInfo>
</PropertyGroup>

Known Limitations

GD0001 - Signal Connection Leak Detection:

  • Only analyzes within single class scope
  • May produce false positives for temporary objects or valid persistent connections
  • Doesn't track cross-method signal flows or complex object lifetimes
  • Conditional connections (e.g., in loops or if statements) may not be fully analyzed

Building from Source

Prerequisites

  • .NET 8.0 SDK or later
  • Visual Studio 2022 or VS Code with C# extensions

Build

dotnet build

Run Tests

dotnet test

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-analyzer)
  3. Commit your changes (git commit -m 'Add amazing analyzer')
  4. Push to the branch (git push origin feature/amazing-analyzer)
  5. Open a Pull Request

Setting up CI/CD for Releases

To enable automatic publishing of NuGet packages when tags are created:

  1. Generate a NuGet API Key:

    • Go to nuget.org and sign in
    • Navigate to your account settings → API Keys
    • Create a new API key with "Push new packages and package versions" permissions
    • Optionally scope it to specific packages or use global permissions
  2. Add the API Key to GitHub Secrets:

    • Go to your repository on GitHub
    • Navigate to Settings → Secrets and variables → Actions
    • Click "New repository secret"
    • Name: NUGET_API_KEY
    • Value: Paste your NuGet API key
    • Click "Add secret"
  3. Create a Release:

    • Tag your release with a version number: git tag v0.1.0
    • Push the tag: git push origin v0.1.0
    • The GitHub Actions workflow will automatically build, test, and publish to NuGet

Note: The GITHUB_TOKEN secret is automatically provided by GitHub Actions and doesn't need manual setup.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built for the Godot Engine community
  • Inspired by common issues found in Godot C# projects
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • 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
0.1.0 2,155 7/22/2025