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

Option strict on source level #206

Closed
ghost opened this issue Nov 26, 2017 · 5 comments
Closed

Option strict on source level #206

ghost opened this issue Nov 26, 2017 · 5 comments

Comments

@ghost
Copy link

ghost commented Nov 26, 2017

In VB.Net, we have option Strict on project level and on file level.
It should be nice to have it on source level too:

Option Strict On
Public Class x
Private f as string = "123"
#Option Strict OFF
Private f2 as string = 123 'this will compile
#Option Strict ON
Private f3 as string = 123 'this won't compile

@reduckted
Copy link
Contributor

#117

@paul1956
Copy link

Your example has a simple workaround just cast 123 but this would be useful because as I have reported in #23367 (repeated below) sometime valid code will not compile depending on state of Option Strict and Option Infer and there is no easy workaround that don't change the original code..

Option Strict Off or On
Option Infer Off or On
        Friend Overloads Shared Function GetUnificationUseSiteDiagnosticRecursive(Of T As TypeSymbol)(types As ImmutableArray(Of T), owner As Symbol, ByRef checkedTypes As HashSet(Of TypeSymbol)) As DiagnosticInfo
            For Each t In types '            For Each t As T In types '***** This line is the issue
 
            Next
            Return Nothing
        End Function

@ghost
Copy link
Author

ghost commented Nov 27, 2017

@paul1956
It was only an example - in real world I work with Option Strict On except for cases where late-bound is needed - mostly one or two lines in a complete file.
And at this moment this means that I have to use Option Strict Off for all code, just to be able to add those two lines.
@reduckted
Indeed, this is a duplicate of #117 - my apologies.

@paul1956
Copy link

@tverweij I agree it would be very useful, I always use Strict On and Infer Off and continue to run into issues on one line in a file where this would help. My workaround today is to flip the Options get rid of all the errors I can (using codefix) and then flipping the Options back and hoping no one ever touches the file again.

@ghost
Copy link
Author

ghost commented Nov 30, 2017

Closed - duplicate of 117

@ghost ghost closed this as completed Nov 30, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants