-
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
VB quickfix "insert missing cast" improvements #3438
Comments
@ljw1004: Can you be more specific about what compilation settings you had for the second case? |
Now in VS2015 RTM I can no longer repro the second case. |
Just came looking for this, it's really annoying as it is. |
@jrmoreno1 This is a 'help wanted' issue. We would happily take a PR here if you're interested :) |
@CyrusNajmabadi : I was thinking about it... |
@jrmoreno1 If you are not going to get to it I will try it. Do you know where the code is for this fix? |
@paul1956 : I was planning on looking into it either this weekend or next. I believe it is happening in : |
@jrmoreno1 I wanted to look into #44516 and though it might to related code or at least a related test. I can't know which test covers this Visual Basic Casts. |
The code is in AbstractAddExplicitCastCodeFixProvider and subclasses: https://github.com/dotnet/roslyn/blob/master/src/Features/Core/Portable/CodeFixes/AddExplicitCast/AbstractAddExplicitCastCodeFixProvider.cs |
Tests for this are in: AddExplicitCastTests.vb and AddExplicitCastTests.cs |
@jrmoreno1 I will leave this one to you and look at "CInt Redundant Cast incorrect for Math functions and constants" #44516 |
@paul1956 : the problem is simple, the extension method GetPredefinedCastKeyword in ITypeSymbolExtensions doesn't include a check for SpecialType.System_String or return SyntaxKind.CStrKeyword. I'll have to see what if anything breaks when I change it, which is hard because the test take so long on my machine. |
…nctions when available
@ljw1004, @CyrusNajmabadi : I don't understand what should be different about Option Strict Custom. I don't know where BC42016 is being generated in that case or where I would find a test to see if my pull request #45139 does fix it. |
Sorry, I don't know what this if in reference to. |
@CyrusNajmabadi: the second point for this issue was:
There’s an update saying it couldn’t be reproduced in 2015RTM, I’m trying to figure out if it is still an issue and how to test for it if it is. |
You don't need to worry about 'option strict custom'. It's not really relevant for this scenario. It's more about if the individual warnings are elevated to errors or not. |
#3438, use standard Type Conversion Functions when possible
I'm putting two related bug reports in this issue.
First: the quickfix "Insert Missing Cast" for BC30512 suggests here to insert
CType(expr,String)
. It should instead be suggesting the nicerCStr(expr)
.[edit: retrying this with VS2015 RTM, I can still repro the first issue, but can't repro the second...]
Second: if we switch to Option Strict Custom, the compiler is correct to give warning BC42016 instead of error BC30512. Unfortunately the only quickfix offered for BC42016 is
#Disable Warning
. But it should first offer the same "Insert Missing Cast" quickfix as it does for BC30512.The text was updated successfully, but these errors were encountered: