Repository metrics
- Stars
- (20,414 stars)
- PR merge metrics
- (Avg merge 6d 17h) (256 merged PRs in 30d)
Description
This issue has been moved from a ticket on Developer Community.
VS 2022 shows 2 contradicting warnings.
First, VS wants me to convert an if statement into a conditional expression.
I don't want to do that, because I feel the if statement is better readable. So I added "#pragma warning disable IDE0046 // Convert to conditional expression":
public static string? GetFrameWorkElementName(FrameworkElement frameworkElement) {
if (! IsTracingOn) return null;
#pragma warning disable IDE0046 // Convert to conditional expression
if (frameworkElement is ITraceName iTraceName && iTraceName.TraceName!=null && iTraceName.TraceName.Length>0) {
#pragma warning restore IDE0046
return iTraceName.TraceName;
}
return frameworkElement.Name!=null && frameworkElement.Name.Length>0 ? frameworkElement.Name :
frameworkElement.GetType(). ToString();
}
The lightbulb displays 2 contradicting warnings:
- Use conditional expression for return (IDE0046)
- Remove unnecessary suppression (IDE0079)
However, they contradict each other, not both can be true at the same time !!!!!!!!!!!!!
I like that VS tries to tell me there might be a problem. But there MUST be a way to tell VS that at this place it is not a problem and VS needs to stop warning me here. My goal is to have 0 warnings. If I have some untrue warnings here and there, the warnings become useless, because I can no longer easily see that all warnings are resolved.
Original Comments
Feedback Bot on 2/28/2022, 01:44 AM:
Feedback Bot on 2/28/2022, 00:24 PM:
Original Solutions
(no solutions)