Neo.SmartContract.Analyzer 3.10.1

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

Neo Smart Contract Roslyn Analyzers

Neo.SmartContract.Analyzer bundles Roslyn analyzers and code fixes that enforce NeoVM constraints, NEP standards, and high-signal best practices before you deploy a contract.

Highlights

  • Type Safety – blocks unsupported primitives such as float, double, decimal, risky System.Math/string/char helpers, and unsafe BigInteger construction.
  • BCL Guardrails – warns when contracts use LINQ, generic collections, System.Diagnostics, or other runtime-only APIs.
  • Contract Shape – validates SupportedStandards, method naming, event names, static-field initialization, and NEP boilerplate.
  • Error Handling – restricts multiple catch blocks, ref/volatile, and suspect cast patterns so on-chain code stays deterministic.

Analyzer catalog

Install

dotnet add package Neo.SmartContract.Analyzer --prerelease

or add to the project (or Directory.Build.props) and keep it private to the contract:

<ItemGroup>
  <PackageReference Include="Neo.SmartContract.Analyzer" Version="*"
                    PrivateAssets="all"
                    IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>

Source reference

When the analyzer lives in the same repo, reference it directly so you can debug rules:

<ItemGroup>
  <ProjectReference Include="..\path\to\Neo.SmartContract.Analyzer.csproj"
                    OutputItemType="Analyzer"
                    ReferenceOutputAssembly="false" />
</ItemGroup>

Using the diagnostics

  1. Build or save the contract project—diagnostics show up in VS/VS Code, dotnet build, and CI.
  2. Treat analyzer output as build failures:
dotnet build /warnaserror

Add the following to .editorconfig to promote all seven shipped analyzer categories (Usage, Syntax, Security, Naming, Type, Method, and Namespace) to errors while keeping selected rules at a different severity:

[*.cs]
dotnet_analyzer_diagnostic.category-Usage.severity = error
dotnet_analyzer_diagnostic.category-Syntax.severity = error
dotnet_analyzer_diagnostic.category-Security.severity = error
dotnet_analyzer_diagnostic.category-Naming.severity = error
dotnet_analyzer_diagnostic.category-Type.severity = error
dotnet_analyzer_diagnostic.category-Method.severity = error
dotnet_analyzer_diagnostic.category-Namespace.severity = error

# Override individual rules after setting category defaults when needed.
dotnet_diagnostic.NC4014.severity = warning
  1. Only suppress warnings with #pragma warning disable when you fully understand the trade-off.

CI tips

  • Restore/install the analyzer before dotnet build /warnaserror so unsupported APIs never land on dev.
  • Upload build logs or SARIF reports so the whole team can track rule regressions.

Contributing

Add new rules, refine diagnostics, or update docs—just run dotnet test Neo.SmartContract.Analyzer.UnitTests before opening a PR.

License

MIT – see LICENSE.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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
3.10.1 44 7/23/2026
3.10.0 340 6/12/2026
3.9.1 667 1/28/2026
3.8.1 334 5/12/2025
3.7.4.1 223 11/6/2024
3.7.4 299 5/20/2024