Repository navigation
Bug fix for issue #8111 - Don't mark cast as redundant if removing it will change the shape of a new anonymous object - #8195
Conversation
… will change the shape of a new anonymous object
This fixes a corner case in which the IDE0004 diagnostic ("C# Cast is
redundant") claims a cast is safe to remove, when removing it could in
fact change program behavior, by changing the type of an anonymous
object's member
|
@dotnet-bot test eta please tag @dotnet/roslyn-ide @DustinCampbell |
|
@dotnet-bot retest prtest/mac/dbg/unit32 please |
There was a problem hiding this comment.
It's be good to add a test to ensure that it still reports redundant identity casts in this scenario.
There was a problem hiding this comment.
Also, tests for casts when the property name is omitted. E.g.
object thing = new { (int)Directions.South };There was a problem hiding this comment.
Both good ideas, I'll try to get those in soon
|
Ignore my comment about |
…nAnalyzer (from CastExpressionSyntaxExtentions)
…dundant from being marked for removal
|
tag @dotnet/roslyn-ide for another look. |
|
LGTM 👍 |
There was a problem hiding this comment.
why 'is' instead of the Kind checks like above?
There was a problem hiding this comment.
Saw others with "is", especially at the top of the method, copied that style.
|
👍 just had a nit. |
|
Sorry for the late reply on this, we'll try and get this merged in today. @dotnet-bot test eta please |
|
@dotnet-bot test eta please |
|
@dotnet-bot test eta please |
|
test vsi please |
|
retest this please |
|
@steveniles -- sorry it took so long to get this one in. Running tests one more time. 😄 |
|
@DustinCampbell No problem, figured it would get done once the issues with the test server(s) were resolved :) |
Fixes #8111
This fixes a corner case in which the IDE0004 diagnostic ("C# Cast is redundant") claims a cast is safe to remove, when removing it could in fact change program behavior, by changing the type of an anonymous object's member