Skip to content
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

Closed
ljw1004 opened this issue Jun 11, 2015 · 17 comments
Closed

VB quickfix "insert missing cast" improvements #3438

ljw1004 opened this issue Jun 11, 2015 · 17 comments
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@ljw1004
Copy link
Contributor

ljw1004 commented Jun 11, 2015

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 nicer CStr(expr).
bc30512

[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.
bc42016

@Pilchie Pilchie added this to the 1.1 milestone Jun 11, 2015
@Pilchie
Copy link
Member

Pilchie commented Aug 5, 2015

@ljw1004: Can you be more specific about what compilation settings you had for the second case?

@ljw1004
Copy link
Contributor Author

ljw1004 commented Aug 11, 2015

Now in VS2015 RTM I can no longer repro the second case.

@Pilchie Pilchie modified the milestones: 1.2, 1.1 Sep 22, 2015
@jaredpar jaredpar removed this from the 1.2 milestone Nov 23, 2015
@davkean davkean added this to the 1.2 milestone Dec 4, 2015
@Pilchie Pilchie modified the milestones: Unknown, 1.2 Dec 11, 2015
@Pilchie Pilchie added the help wanted The issue is "up for grabs" - add a comment if you are interested in working on it label Dec 11, 2015
@jrmoreno1
Copy link
Contributor

Just came looking for this, it's really annoying as it is.

@CyrusNajmabadi
Copy link
Member

@jrmoreno1 This is a 'help wanted' issue. We would happily take a PR here if you're interested :)

@jrmoreno1
Copy link
Contributor

@CyrusNajmabadi : I was thinking about it...

@paul1956
Copy link
Contributor

@jrmoreno1 If you are not going to get to it I will try it. Do you know where the code is for this fix?

@jrmoreno1
Copy link
Contributor

jrmoreno1 commented Jun 10, 2020

@paul1956 : I was planning on looking into it either this weekend or next. I believe it is happening in :
\repos\roslyn\src\Features\VisualBasic\Portable\CodeFixes\AddExplicitCast\VisualBasicAddExplicitCastCodeFixProvider.vb, but that is a quick look, I wouldn't bet on it being the right spot.

@paul1956
Copy link
Contributor

@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.

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi
Copy link
Member

I can't know which test covers this

Tests for this are in: AddExplicitCastTests.vb and AddExplicitCastTests.cs

@paul1956
Copy link
Contributor

@jrmoreno1 I will leave this one to you and look at "CInt Redundant Cast incorrect for Math functions and constants" #44516

@jrmoreno1
Copy link
Contributor

@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.

jrmoreno1 added a commit to jrmoreno1/roslyn that referenced this issue Jun 13, 2020
jrmoreno1 added a commit to jrmoreno1/roslyn that referenced this issue Jun 13, 2020
@jrmoreno1
Copy link
Contributor

jrmoreno1 commented Jun 17, 2020

@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.

@CyrusNajmabadi
Copy link
Member

Sorry, I don't know what this if in reference to.

@jrmoreno1
Copy link
Contributor

@CyrusNajmabadi: the second point for this issue was:

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.

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.

@CyrusNajmabadi
Copy link
Member

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.

mavasani added a commit that referenced this issue Jul 13, 2020
#3438, use standard Type Conversion Functions when possible
@CyrusNajmabadi
Copy link
Member

Closing out as this works now:

image

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

No branches or pull requests

8 participants