DataverseAnalyzer 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package DataverseAnalyzer --version 1.0.3
                    
NuGet\Install-Package DataverseAnalyzer -Version 1.0.3
                    
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="DataverseAnalyzer" Version="1.0.3">
  <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="DataverseAnalyzer" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="DataverseAnalyzer">
  <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 DataverseAnalyzer --version 1.0.3
                    
#r "nuget: DataverseAnalyzer, 1.0.3"
                    
#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 DataverseAnalyzer@1.0.3
                    
#: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=DataverseAnalyzer&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=DataverseAnalyzer&version=1.0.3
                    
Install as a Cake Tool

Dataverse Analyzer

A Roslyn analyzer for .NET Core projects that enforces specific coding standards and best practices.

Rule CT0001: Control Flow Braces Rule

This analyzer enforces that if and else control flow statements without braces can only contain:

  • return statements
  • throw statements
  • continue statements
  • break statements
  • yield break statements

Examples

Allowed (no braces needed):

if (condition)
    return;

if (error)
    throw new Exception();

while (true)
    break;

foreach (var item in items)
    continue;

if (done)
    yield break;

Not allowed (braces required):

// This will trigger CT0001
if (condition)
    DoSomething();

Rule CT0002: Enum Assignment Rule

This analyzer prevents assigning literal values to enum properties, requiring the use of proper enum values instead.

Examples

Allowed:

AccountCategoryCode = AccountCategoryCode.Standard;

Not allowed:

// This will trigger CT0002
AccountCategoryCode = 1;

Rule CT0003: Object Initialization Rule

This analyzer prevents the use of empty parentheses in object initialization when using object initializers.

Examples

Allowed:

var account = new Account
{
    Name = "MoneyMan",
};

var account = new Account(accountId)
{
    Name = "MoneyMan",
};

Not allowed:

// This will trigger CT0003
var account = new Account()
{
    Name = "MoneyMan",
};

Usage

The analyzer is designed to be consumed as a project reference or NuGet package in other .NET projects. When integrated, it will automatically analyze your code and report violations of the rules.

Building

dotnet build src\DataverseAnalyzer\DataverseAnalyzer.csproj --configuration Release

The built analyzer DLL will be available in src\DataverseAnalyzer\bin\Release\net8.0\DataverseAnalyzer.dll.

Integration

To use this analyzer in your projects, reference the built DLL as an analyzer:

<ItemGroup>
  <Analyzer Include="path\to\DataverseAnalyzer.dll" />
</ItemGroup>

The analyzer includes an automatic code fix provider that can add braces when violations are detected.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • net8.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
1.0.5 115 8/20/2025
1.0.4 112 8/19/2025
1.0.3 112 8/19/2025
1.0.2 128 8/13/2025
1.0.1 129 8/12/2025
1.0.0 136 8/12/2025