-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIx Redundant Cast incorrect for SimpleArguments #44516 #45102
FIx Redundant Cast incorrect for SimpleArguments #44516 #45102
Conversation
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Utilities/CastAnalyzer.vb
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Utilities/CastAnalyzer.vb
Outdated
Show resolved
Hide resolved
This is failing the test: TestVisualBasic_DoNotRemove_NecessaryCastForParamsArgument |
@CyrusNajmabadi I believe TestVisualBasic_DoNotRemove_NecessaryCastForParamsArgument should fail as written. If I copy the result into Visual Studio and remove the DirectCast Visual Studio is happy with the results. If you agree I will correct or remove the test. |
The test appears to be correct. If you remove the cast, the code will still compile, but the semantics will be different, leading to different runtime behavior. |
Please update the pr to handle the new case, without regressing the existing cases. Thanks! |
src/Analyzers/VisualBasic/Tests/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.vb
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Utilities/CastAnalyzer.vb
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Utilities/CastAnalyzer.vb
Outdated
Show resolved
Hide resolved
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Utilities/CastAnalyzer.vb
Outdated
Show resolved
Hide resolved
… for Casts in SimpleArguments
All tests pass without any changes and new tests added to test issue and they pass.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
src/Analyzers/VisualBasic/Tests/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.vb
Show resolved
Hide resolved
Dim parentSimpleArgument = TryCast(parent, SimpleArgumentSyntax) | ||
If TypeOf parentSimpleArgument?.Expression Is CastExpressionSyntax OrElse | ||
TypeOf parentSimpleArgument?.Expression Is PredefinedCastExpressionSyntax Then | ||
Return semanticModel.GetTypeInfo(parentSimpleArgument.Expression, cancellationToken).Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see tests for the PredefinedCastExpressionSyntax case. but not for CastExpressionSyntax
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Utilities/CastAnalyzer.vb
Show resolved
Hide resolved
This PR has a lot of unrelated files in it. Is there anything that the compiler team actually needs to review in it? |
Agree. This really needs to be cleaned up before we can consider merging. This change shouldn't be impacting 500+ files. In addithion to making our history hard to follow it's not reasonable to review such a change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Git history needs to be cleaned up before we can review
Did you merge something into your branch? |
The last commit has a stray second parent. Looks like an accidental merge to an old version of the same commits. The fix:
|
yes but I don't know how it happened. It should be fixed now. |
Thanks! |
Add tests for Casts in SimpleArguments
Fixes #44516