DataverseAnalyzer 1.0.3
See the version list below for details.
dotnet add package DataverseAnalyzer --version 1.0.3
NuGet\Install-Package DataverseAnalyzer -Version 1.0.3
<PackageReference Include="DataverseAnalyzer" Version="1.0.3"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="DataverseAnalyzer" Version="1.0.3" />
<PackageReference Include="DataverseAnalyzer"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add DataverseAnalyzer --version 1.0.3
#r "nuget: DataverseAnalyzer, 1.0.3"
#:package DataverseAnalyzer@1.0.3
#addin nuget:?package=DataverseAnalyzer&version=1.0.3
#tool nuget:?package=DataverseAnalyzer&version=1.0.3
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
statementsthrow
statementscontinue
statementsbreak
statementsyield 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.
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.