Skip to content

Diagnostics

Ian Wold edited this page Nov 10, 2026 · 3 revisions
ID Kind Category Default What it does Fix
UN0001 Suppression Suppresses CS8509 on a switch expression whose unhandled cases earlier code ruled out
UN0011 Suppression Suppresses CS8846, the same warning when an arm with a when clause might cover what's missing
UN0012 Suppression Suppresses CS8655 (null not handled) when earlier code ruled out null
UN0013 Suppression Suppresses CS8847, the same warning when an arm with a when clause might cover null
UN0008 Suppression Suppresses IDE0072 (populate switch expression) on a switch over a union or closed hierarchy
UN0009 Suppression Suppresses IDE0010 (populate switch statement) on a switch that handles every remaining case
UN0002 Analyzer Reliability Warning A throwing default (or final else, or a throw after the switch) catches cases the switch doesn't otherwise handle Name the cases
UN0003 Analyzer Reliability Info A default union value, which holds no case
UN0004 Analyzer Style Info An arm, case label or type test can't match, because earlier code ruled out its cases Remove it
UN0005 Analyzer Usage Info A switch or test on union.Value that could be on the union itself Switch on the union
UN0006 Analyzer Reliability Info An array whose elements are, or are reset to, default unions
UN0007 Analyzer Reliability Info A union member (or a member of a struct with a union inside) that some constructor can leave as default Make it required
UN0010 Analyzer Reliability Info A call that can fall back to a default union
UN0014 Analyzer Usage Warning A type test, cast, Equals or GetType() on a boxed union, as though it were what it holds Look at what it holds
UN0015 Analyzer Usage Info A union formatted as text, which shows its type name Format its Value, Override ToString
UN0016 Analyzer Reliability Info A throwing default on a switch that handles every case Remove it
UN0018 Analyzer Reliability Info The default of a struct or tuple with a union inside, which holds no case
UN0019 Analyzer Usage Info A record whose generated ToString prints a union member as its type name Override ToString
CS8509, CS8846, CS8655, CS8847 Code fix Add missing arms
IDE0010 Code fix Add missing cases
CS0161, CS1643, CS0165 Code fix Add a throwing default

The analyzers report at Info, so they show up as suggestions in the editor, except two warnings: UN0002, because the default it reports hides a case the switch is missing, which is what CS8509 would otherwise say, and UN0014, because the code it reports never does what it looks like. To see the others in builds, to make them fail a build, or to turn one off, set their severity in .editorconfig:

[*.cs]
dotnet_diagnostic.UN0003.severity = warning
dotnet_diagnostic.UN0006.severity = warning
dotnet_diagnostic.UN0016.severity = none

Clone this wiki locally