-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work]
When you enter the following code in a C# class:
public static int DemoFunction1(int value) {
switch (value) { // IDE0066
case 0: return 123;
case 1: return 234;
default: throw new ArgumentException(String.Format("unhandled value {0}", value), nameof(value));
}
}
you get a IDE0066 message "use switch expression" for the line with switch (value). When you let the IDE fix this issue, you get
public static int DemoFunction1(int value) {
return value switch {
0 => 123,
1 => 234,
_ => throw new ArgumentException(String.Format("unhandled value {0}", value), nameof(value)),
};
}
where the comment has been silently discarded.
I'd expect
public static int DemoFunction1(int value) {
return value switch { // IDE0066
0 => 123,
1 => 234,
_ => throw new ArgumentException(String.Format("unhandled value {0}", value), nameof(value)),
};
}
with the comment still in place.
I found that this seems to be a duplicate of https://developercommunity2.visualstudio.com/t/IDE0017-removes-comments/12543?entry=problem&ref=native&refTime=1617023654675&refUserId=a6b2a6f6-934e-4823-8293-ec744e00e728 , but that one is in VB.NET and more than 4 years old, whereas this one in C#, and I'm one of those old-school guys who actually do believe a language's feature to accept comments is there for a reason.
Original Comments
Feedback Bot on 3/29/2021, 11:58 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
(no solutions)