Skip to content

IDE0066 (ConvertSwitchStatementToExpression) does not respect severity from CSharpCodeStyleOptions.PreferSwitchExpression #36086

@mavasani

Description

@mavasani

Version Used:

Latest master

Steps to Reproduce:

  1. Create a C# project with following code and <LangVersion>preview</LangVersion>:
using System;

namespace ConvertToSwitchExpression
{
    public class A
    {
        public string M1(int i)
        {
            switch (i)
            {
                case 0:
                    return "Zero";
                case 1:
                    return "One";
                default:
                    return "Multiple";
            }
        }
    }
}
  1. Verify code fix to convert switch statement to switch expression is shown, and IDE0066 is a hidden diagnostic
  2. Change severity of CSharpCodeStyleOptions.PreferSwitchExpression to Warning
    image

Expected Behavior:
See a warning in error list and a squiggle in the editor on switch keyword.

Actual Behavior:
IDE0066 is always reported as a hidden diagnostic

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions