Dinaup.Analyzers 0.1.0-alpha

This is a prerelease version of Dinaup.Analyzers.
dotnet add package Dinaup.Analyzers --version 0.1.0-alpha
                    
NuGet\Install-Package Dinaup.Analyzers -Version 0.1.0-alpha
                    
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="Dinaup.Analyzers" Version="0.1.0-alpha">
  <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="Dinaup.Analyzers" Version="0.1.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Dinaup.Analyzers">
  <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 Dinaup.Analyzers --version 0.1.0-alpha
                    
#r "nuget: Dinaup.Analyzers, 0.1.0-alpha"
                    
#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 Dinaup.Analyzers@0.1.0-alpha
                    
#: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=Dinaup.Analyzers&version=0.1.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Dinaup.Analyzers&version=0.1.0-alpha&prerelease
                    
Install as a Cake Tool

Dinaup.Analyzers

Roslyn analyzers para aplicar las convenciones de estilo de código C# de Dinaup automáticamente.

Instalación

dotnet add package Dinaup.Analyzers

O añadir al .csproj:

<PackageReference Include="Dinaup.Analyzers" Version="1.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

Reglas incluidas

ID Severidad Descripción
DNA001 ⚠️ Warning No usar operador ! - usar == false
DNA002 ⚠️ Warning No usar DateTime?, decimal?, Guid? - usar valores por defecto
DNA003 ⚠️ Warning Usar .IsEmpty() en lugar de == Guid.Empty
DNA004 ⚠️ Warning Usar .IsNotEmpty() en lugar de != Guid.Empty
DNA005 ⚠️ Warning No usar float o double - usar decimal
DNA006 ℹ️ Info Usar .STR() en lugar de .ToString()
DNA007 ⚠️ Warning Usar .IsNotEmpty() / .IsEmpty() para colecciones

Ejemplos

DNA001 - No usar negación (!)

// ❌ Incorrecto
if (!user.Enabled)
    return;

// ✅ Correcto
if (user.Enabled == false)
    return;

DNA002 - No usar tipos nullable

// ❌ Incorrecto
DateTime? fecha = null;
decimal? precio = null;

// ✅ Correcto
DateTime fecha = DateTime.MinValue;
decimal precio = 0;

DNA003/DNA004 - Usar IsEmpty/IsNotEmpty para Guid

// ❌ Incorrecto
if (id == Guid.Empty)
if (id != Guid.Empty)

// ✅ Correcto
if (id.IsEmpty())
if (id.IsNotEmpty())

DNA005 - No usar float/double

// ❌ Incorrecto
float precio = 19.99f;
double total = precio * cantidad;

// ✅ Correcto
decimal precio = 19.99m;
decimal total = precio * cantidad;

DNA006 - Usar STR()

// ❌ Incorrecto
string id = guid.ToString();
string valor = decimal.ToString();

// ✅ Correcto
string id = guid.STR();
string valor = decimal.STR();

DNA007 - Usar IsNotEmpty/IsEmpty para colecciones

// ❌ Incorrecto
if (items?.Count > 0)
if (items.Any())
if (items.Count == 0)

// ✅ Correcto
if (items.IsNotEmpty())
if (items.IsEmpty())

Configuración

Deshabilitar reglas específicas

En el archivo .editorconfig:

[*.cs]
# Deshabilitar una regla específica
dotnet_diagnostic.DNA006.severity = none

# Cambiar severidad
dotnet_diagnostic.DNA001.severity = error

Suprimir en código

#pragma warning disable DNA001
if (!condition) { }
#pragma warning restore DNA001

Quick Fixes

Todas las reglas incluyen Quick Fixes automáticos que puedes aplicar:

  • Individualmente con Ctrl+. (VS) o Cmd+. (VS Code)
  • En masa con "Fix all in Document/Project/Solution"

Compilar desde código fuente

cd Dinaup.Analyzers
dotnet build -c Release

El paquete NuGet se genera automáticamente en bin/Release/.

Requisitos

  • .NET Standard 2.0 compatible
  • Visual Studio 2019+ / VS Code / Rider
  • Roslyn 4.8+

Licencia

MIT

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
0.1.0-alpha 118 2/2/2026

Initial alpha release. Includes analyzers: DNA001 (no bang operator), DNA002 (no nullable DateTime/decimal/Guid), DNA003/DNA004 (use IsEmpty/IsNotEmpty for Guid), DNA005 (no float/double), DNA006 (use STR method), DNA007 (use IsEmpty/IsNotEmpty for collections).