Exhausted switch with enum suggestion seems bad
switch (output.AudioCodec)
{
case AudioCodec.Aac:
arguments.Append("-acodec aac ");
break;
case AudioCodec.Copy:
arguments.Append("-acodec copy ");
break;
default:
throw new NotSupportedException($"The audio codec {output.AudioCodec} is not supported");
}
By both the latest Rider and R# that switch statement gives the suggestion of: "Some values of the enum are not processed inside switch: Unspecified".
This is technically incorrect because it is processed by the default clause, but what's worse about this is if you try to let R#/Rider auto-implement the suggestion (auto-generate switch label) it gives you:
switch (output.AudioCodec)
{
case AudioCodec.Aac:
arguments.Append("-acodec aac ");
break;
case AudioCodec.Copy:
arguments.Append("-acodec copy ");
break;
case AudioCodec.Unspecified:
break;
default:
throw new NotSupportedException($"The audio codec {output.AudioCodec} is not supported");
}
Which is 100% a bug in my application, and in most circumstances where a default clause is specified. In my opinion this suggestion should either not come up with a default clause or the generated suggestion should be a fallback case clause if a default clause is detected.
Please sign in to leave a comment.
Added to Youtrack on https://youtrack.jetbrains.com/issue/RSRP-463953