Install
E128.Analyzers 3.12.4 is a development-only NuGet package. Add it to the project that needs the rules and keep it out of the published dependency graph.
Installation
<PackageReference Include="E128.Analyzers" Version="3.12.4" PrivateAssets="all" />
PrivateAssets="all"keeps the analyzers out of your consumers’ dependency graph.
Supported hosts
The analyzer assemblies target netstandard2.0, and the package carries no dependency of its own. The package holds one build per Roslyn band:
analyzers/dotnet/roslyn5.9/csholds the base rules. Roslyn 5.9 and above load it, which covers the .NET SDK 10.0 and later.analyzers/dotnet/roslyn5.12/csholds the base rules plus the union rules. Only a Roslyn 5.12 host loads it, which means the .NET SDK 11.0 and later.
The SDK selects one folder per package, so a host below Roslyn 5.9 loads nothing. Roslyn reports that as CS9057, one diagnostic per project, and a repository with TreatWarningsAsErrors turns it into a build failure. The package reports it earlier as the E128PKG0001 error and names the host version.
E128220 and E128221 read the C# union syntax. A Roslyn 5.9 compiler cannot parse that syntax, so those two rules are absent on a .NET SDK 10.0 host. Every other rule runs on both hosts.
The rules read syntax and symbols, so they work on any C# project. A rule stays silent where the target framework cannot express what it looks for.
Versions 3.5.0 through 3.5.4 shipped a base build that referenced Roslyn 5.12, so a .NET SDK 10.0 host rejects them with CS9057. Use 3.5.5 or later on SDK 10.0, or stay on 3.4.2 until you upgrade.
Transitive Pinning Guidance
If your library uses Central Package Management with transitive pinning, review its package dependencies before publishing. NuGet can promote pinned transitive packages to explicit dependencies in the generated .nuspec.
E128.Analyzers prints guidance during Pack when the C# project enables central transitive pinning and emits package dependencies. The message uses high importance, so normal pack output shows it. It is not a warning or an error. Enabled pinning alone does not prove that NuGet promoted a dependency.
The message stays silent during ordinary builds and design-time builds. It also stays silent for non-packable projects and SuppressDependenciesWhenPacking=true. It also runs for a multi-target project. Quiet verbosity can hide the message.
- Prefer an upstream package update that removes the need for a pin.
- Pin a version at least as high as the requested dependency version. NuGet rejects downgrades with
NU1109. - Document each pin with its reason, advisory or issue reference, and removal condition.
- Review the generated
.nuspecfor dependencies that the pin adds. - Run NuGet Audit for direct and transitive dependencies. Use
NuGetAuditMode=allwhen you need explicit configuration. - When the upstream dependency meets the removal condition, remove the temporary pin.
- Choose global or per-project pinning according to the projects that need it.
Do not hide a runtime dependency with PrivateAssets="all" just to remove it from your package metadata. Consumers can then resolve an older vulnerable version or miss a required dependency. The installation example uses PrivateAssets="all" because E128.Analyzers is a development-only dependency.
See NuGet Transitive Pinning and NuGet Audit.
Requirements
- .NET SDK 10.0+ (Roslyn 5.9 host compiler required, and an older host fails with
E128PKG0001) - Visual Studio 2022 17.8+, Rider 2024.1+, or
dotnet buildfrom CLI