Siemens.AspNet.CodeRules
7.8.19
Prefix Reserved
dotnet add package Siemens.AspNet.CodeRules --version 7.8.19
NuGet\Install-Package Siemens.AspNet.CodeRules -Version 7.8.19
<PackageReference Include="Siemens.AspNet.CodeRules" Version="7.8.19" />
<PackageVersion Include="Siemens.AspNet.CodeRules" Version="7.8.19" />
<PackageReference Include="Siemens.AspNet.CodeRules" />
paket add Siemens.AspNet.CodeRules --version 7.8.19
#r "nuget: Siemens.AspNet.CodeRules, 7.8.19"
#:package Siemens.AspNet.CodeRules@7.8.19
#addin nuget:?package=Siemens.AspNet.CodeRules&version=7.8.19
#tool nuget:?package=Siemens.AspNet.CodeRules&version=7.8.19
Siemens.AspNet.CodeRules
The code rules of the Siemens ASP.NET SDK as one rule pack.
Architecture and convention rules for repositories built with the Siemens ASP.NET SDK: Minimal API endpoints, request
validation, DynamoDB, records, classes, services, projects, NuGet packaging and tests. The rules run on the
code rule engine as tests or with the coderules CLI.
Installation
dotnet add package Siemens.AspNet.CodeRules
Together with a test adapter in your code rule project, e.g. Siemens.AspNet.CodeRules.MSTest.
Usage
public sealed class CodeRuleSetup : ICodeRuleSetup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddCodeRuleEngine("MyRepo.slnx", o => o.AddRulePack<SdkRules>()
.SkipRule<SomeRule>("accepted until #1234"));
}
}
Every public rule of the pack becomes one generated test. Skip a rule, a group or a tag with a reason, accept single findings
in the code with [SuppressMessage].
Rules
Every rule has a stable id (RJIT_CR_<CATEGORY>_<NUMBER>), a title, why it exists and how to fix a finding.
The full list is in the rule set documentation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Asp.Versioning.Abstractions (>= 10.2.1)
- AspNetCore.Simple.MsTest.Sdk (>= 10.1.2)
- Extensions.Pack (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.14)
- MSTest.TestFramework (>= 4.5.2)
- Siemens.AspNet.CodeRules.Engine (>= 7.8.19)
- Siemens.AspNet.DbProvider.Contracts (>= 7.8.19)
- Siemens.AspNet.ErrorHandling.Contracts (>= 7.8.19)
- Siemens.AspNet.MinimalApi.Sdk (>= 7.8.19)
- Solution.Parser (>= 6.1.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
## Next
First release as a NuGet package: the code rules of the Siemens ASP.NET SDK as one rule pack.
- `AddRulePack<SdkRules>()` registers every rule: Minimal API, validation, DynamoDB, records, classes, interfaces, services, projects, NuGet packaging and test conventions.
- Skip single rules, groups or tags with the engine options, always with a reason.
### Validation test engine (`Siemens.AspNet.MsTest.Sdk`)
- **Breaking:** `RJIT_CR_MAPI_00026` accepts only a `[DynamicRequestValidation<T>]` test as coverage of a validated request. Hand-written `Status_422_UnprocessableContent/Requests/*.json` cases no longer count. Custom validation attributes count as validated now, and the suggested test takes the case as one string and passes it to `ValidationTestRunner.AssertAsync`. The class name is unchanged, so existing `SkipRule<...>` keep working.
- `RJIT_CR_T_00041`: every custom validation attribute has its rule test case `XyzRuleTestCase : ValidationRuleTestCaseBase<XyzAttribute>` (only in solutions with a `[DynamicRequestValidation]` test).
- `RJIT_CR_T_00042`: a rule test case is named after the rule it describes - `{Rule}RuleTestCase`.
- `RJIT_CR_T_00043`: a `[DynamicRequestValidation]` test takes the validation case as one string and passes it on unchanged.
- `RJIT_CR_T_00044`: the `HttpAction` and the route of `[DynamicRequestValidation<T>]` reach an endpoint that takes `T` (placeholder names, prefix and query do not matter). The finding shows the attribute with the verb and route of the endpoint.
- `RJIT_CR_T_00046`: every `[DynamicRequestValidation<T>]` test has its committed `Baselines/<T>.Schema.json`, and every schema snapshot has its test - a missing snapshot is found at build time instead of as a red CI run.
- `RJIT_CR_T_00047`: every placeholder of the route (query included) gets a value through `routeParameters`.
- `RJIT_CR_T_00048`: a `[DynamicRequestValidation]` test lives below `Status_422_UnprocessableContent`.
- `RJIT_CR_T_00049`: a validation rule is described by exactly one rule test case - a second one would make the engine refuse its catalog at discovery.
- `RJIT_CR_T_00050`: a rule test case for an sdk validation attribute carries `[ReplacesSdkRule("why")]`.
- `RJIT_CR_T_00045` (**breaking**): the folder of a `[DynamicRequestValidation]` test holds no `Requests/` / `Responses/` json and no `[DynamicRequestLocator]` tests - only the recorded `Baselines/` (schema snapshot `<RequestType>.Schema.json`). A snapshot still in `Responses/<RequestType>.json` is reported with the hint to move it. Simple cases belong into a validation attribute; only a complex 422 the engine cannot express (deployed resource, stored data) keeps a hand-written test. Both kinds side by side: the engine test goes into `Status_422_UnprocessableContent/Dynamic/`, the hand-written ones into folders named after what they check (`Deployed/`, `Complex/`, ...).
- `RJIT_CR_T_00021` accepts a `Status_422_UnprocessableContent` class whose test is a `[DynamicRequestValidation]` test.