SharpView 0.4.1
dotnet add package SharpView --version 0.4.1
NuGet\Install-Package SharpView -Version 0.4.1
<PackageReference Include="SharpView" Version="0.4.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="SharpView" Version="0.4.1" />
<PackageReference Include="SharpView"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add SharpView --version 0.4.1
#r "nuget: SharpView, 0.4.1"
#:package SharpView@0.4.1
#addin nuget:?package=SharpView&version=0.4.1
#tool nuget:?package=SharpView&version=0.4.1
SharpView (MSBuild package)
Reports SharpView's exception findings as build warnings after each build: in dotnet build, Visual Studio's Error List and VS Code's Problems panel. Build agents need nothing extra; dotnet restore brings it.
The usual way to run SharpView is the SharpView.Cli tool, in CI or on demand: dotnet sharpview exceptions MyApi.slnx --format msbuild prints the same warnings without adding seconds to every build. Use this package when you want them in every build without anyone running the tool.
<ItemGroup>
<PackageReference Include="SharpView" Version="x.y.z" />
</ItemGroup>
| Code | Finding |
|---|---|
SV0001 |
An exception may escape a controller action: no catch on the way. |
SV0002 |
The same, but a global exception handler (exception middleware or filter) receives it. |
SV0003 |
A throw passes through a try whose catch clauses do not match its type. |
SV0004 |
A third-party call with no catch on the way from the action (only with --strict). |
SV0000 |
The analysis itself failed; build with -v:n to see why. |
Each warning points at the throw (SV0001/2), the try (SV0003) or the call (SV0004), and names the actions and one example path. Interface and virtual calls are followed into their source implementations; such paths say "possible, not proven".
Suppressing one finding
Use the C# suppression forms where the warning points (the throw, the try or the call):
#pragma warning disable SV0003 // ArgumentException is the only one we can recover from here
try { Load(); } catch (ArgumentException) { }
#pragma warning restore SV0003
[SuppressMessage("SharpView", "SV0002:Mapped to 404 by middleware")]
public Order Find(int id) => orders.Get(id) ?? throw new NotFoundException(id);
A pragma covers the code up to its restore (or the end of the file); an attribute covers the method, property or type it is on. Assembly-level [assembly: SuppressMessage] is not read. The build log counts suppressed warnings. If the IDE flags these as unnecessary suppressions (IDE0079), add dotnet_remove_unnecessary_suppression_exclusions = SV0001,SV0002,SV0003,SV0004 to .editorconfig.
Settings
<PropertyGroup>
<NoWarn>$(NoWarn);SV0002</NoWarn>
<WarningsAsErrors>$(WarningsAsErrors);SV0001</WarningsAsErrors>
<SharpViewEnabled Condition="'$(CI)' != 'true'">false</SharpViewEnabled>
<SharpViewInput>$(MSBuildThisFileDirectory)../MyApi.slnx</SharpViewInput>
<SharpViewArguments>--strict</SharpViewArguments>
</PropertyGroup>
The analysis loads the whole project graph, so it adds seconds to every build. It does not run during the IDE's background design-time builds, and warnings appear after a build, not while typing. Requires a .NET 10 (or newer) SDK. For the command-line tool, install SharpView.Cli (dotnet tool install -g SharpView.Cli). Licensed under MIT.
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.