DimonSmart.DynamicLeakAnalyzer 1.0.1

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package DimonSmart.DynamicLeakAnalyzer --version 1.0.1
                    
NuGet\Install-Package DimonSmart.DynamicLeakAnalyzer -Version 1.0.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="DimonSmart.DynamicLeakAnalyzer" Version="1.0.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DimonSmart.DynamicLeakAnalyzer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="DimonSmart.DynamicLeakAnalyzer">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 DimonSmart.DynamicLeakAnalyzer --version 1.0.1
                    
#r "nuget: DimonSmart.DynamicLeakAnalyzer, 1.0.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 DimonSmart.DynamicLeakAnalyzer@1.0.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=DimonSmart.DynamicLeakAnalyzer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=DimonSmart.DynamicLeakAnalyzer&version=1.0.1
                    
Install as a Cake Tool

DimonSmart.DynamicLeakAnalyzer

Roslyn analyzer that detects unintended dynamic leaks: implicit conversions from dynamic to static types (DSM001) and var inferred as dynamic (DSM002).

Install

<ItemGroup>
  <PackageReference Include="DimonSmart.DynamicLeakAnalyzer" Version="0.1.0" PrivateAssets="all" />
</ItemGroup>

Strict .editorconfig

Recommended settings to surface leaks early:

root = true

[*.cs]
# Report dynamic -> object (disabled by default)
dsmdynamicleak_ignore_dynamic_to_object = false

# Analyze generated code if you want it included (default false)
dsmdynamicleak_analyze_generated_code = false

# Standard severity control
# dotnet_diagnostic.DSM001.severity = warning
# dotnet_diagnostic.DSM002.severity = warning

Suppress allowed zones

Use the attribute to allow dynamic usage inside specific members or types:

using DimonSmart;

[DimonSmartAllowDynamicLeak]
public int Parse(dynamic row) => row.Value;

Suppression applies to DSM001 and DSM002 inside the attributed member or type.

Examples

DSM001 - implicit dynamic conversion:

Before:

int M(dynamic d)
{
    return d; // DSM001
}

After:

int M(dynamic d)
{
    return (int)d;
}

DSM002 - var inferred as dynamic:

Before:

var x = GetValue(dynamicRow); // DSM002

After:

dynamic x = GetValue(dynamicRow);
// or
int x = (int)GetValue(dynamicRow);

Allow dynamic in boundary layers (interop, JSON/DB adapters, integration code), but stop leaks before they reach core domain logic.

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.4 149 1/14/2026
1.0.3 120 1/10/2026
1.0.2 123 1/9/2026
1.0.1 123 1/9/2026