Examples of errors detected by the V3202 diagnostic
V3202. Unreachable code detected. The 'case' value is out of the range of the match expression.
Files
V3202 Unreachable code detected. The 'case' value is out of range of the match expression. Files.App SentryLogger.cs 35
public void Log<TState>(....)
{
if (exception is null ||
exception.Data[Mechanism.HandledKey] is false ||
logLevel <= LogLevel.Information)
return;
var generalSettingsService =
Ioc.Default.GetRequiredService<IGeneralSettingsService>();
var level = logLevel switch
{
LogLevel.Debug => SentryLevel.Debug,
LogLevel.Information => SentryLevel.Info,
LogLevel.Warning => SentryLevel.Warning,
LogLevel.Error => SentryLevel.Error,
LogLevel.Critical => SentryLevel.Fatal,
_ => SentryLevel.Debug
};
}
ScottPlot
V3202 Unreachable code detected. The 'case' value is out of range of the match expression. ScottPlot.WinForms FormsPlotExtensions.cs 106
public static Interactivity.Key GetKey(this Keys keys)
{
Keys keyCode = keys & ~Keys.Modifiers; // <=
Interactivity.Key key = keyCode switch
{
Keys.Alt => Interactivity.StandardKeys.Alt, // <=
Keys.Menu => Interactivity.StandardKeys.Alt,
Keys.Shift => Interactivity.StandardKeys.Shift, // <=
Keys.ShiftKey => Interactivity.StandardKeys.Shift,
Keys.LShiftKey => Interactivity.StandardKeys.Shift,
Keys.RShiftKey => Interactivity.StandardKeys.Shift,
Keys.Control => Interactivity.StandardKeys.Control, // <=
Keys.ControlKey => Interactivity.StandardKeys.Control,
Keys.Down => Interactivity.StandardKeys.Down,
Keys.Up => Interactivity.StandardKeys.Up,
Keys.Left => Interactivity.StandardKeys.Left,
Keys.Right => Interactivity.StandardKeys.Right,
_ => Interactivity.StandardKeys.Unknown,
};
....
}
[Flags]
[TypeConverter(typeof(KeysConverter))]
[Editor(....)]
public enum Keys
{
Modifiers = unchecked((int)0xFFFF0000),
....
Shift = 0x00010000,
Control = 0x00020000,
Alt = 0x00040000
}
.NET 9
V3202 Unreachable code detected. The 'case' value is out of range of the match expression. VBCodeGenerator.cs 580
public enum MemberAttributes
{
Abstract = 0x0001,
Final = 0x0002,
Static = 0x0003,
Override = 0x0004,
Const = 0x0005,
New = 0x0010,
Overloaded = 0x0100,
Assembly = 0x1000,
FamilyAndAssembly = 0x2000,
Family = 0x3000,
FamilyOrAssembly = 0x4000,
Private = 0x5000,
Public = 0x6000,
AccessMask = 0xF000,
ScopeMask = 0x000F,
VTableMask = 0x00F0
}
protected override void OutputMemberScopeModifier(MemberAttributes attributes)
{
switch (attributes & MemberAttributes.ScopeMask)
{
case MemberAttributes.Abstract:
Output.Write("MustOverride ");
break;
case MemberAttributes.Final:
Output.Write("");
break;
....
case MemberAttributes.Private: // <=
Output.Write("Private ");
break;
....
}
}