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

[Proposal]: Mark methods of Microsoft.VisualBasic.Information module with [Extension] #549

Open
VBAndCs opened this issue Aug 6, 2020 · 3 comments

Comments

@VBAndCs
Copy link

VBAndCs commented Aug 6, 2020

Based on #546, #547 I suggest to:

  1. Mark methods of Microsoft.VisualBasic.Information module with the ExtensionAttribute.
  2. Make the compiler look at this special module first to resolve extension methods for objects if they are not members of the type itself, ignoring Option Strict On and any current limitations due to late binding. After all this is only one intrinsic module containing object-related jobs. SO, we can write:
   If x.IsDbNull Then
  1. Add some more useful functions to the module to shorten object checks syntax, such as IsSomething or HasValueor alike as proposed in I propose we add Something keyword #546.
   If x.HasValue Then
@AdamSpeight2008
Copy link
Contributor

@VBAndCs Maybe also raise the issue on the runtime repo.

https://github.com/dotnet/runtime/issues

@VBAndCs
Copy link
Author

VBAndCs commented Aug 6, 2020

It is a VB.NET issue, since it needs a special treatment of the compiler.
There is also the issue when the object is Nothing. The workaround is to use the ? operator:
If x?.IsDbNull
I think we should not need the ? since this is an extension method, but I don't know how the compiler acts in this case in runtime.

@pricerc
Copy link

pricerc commented Aug 6, 2020

It is a VB.NET issue, since it needs a special treatment of the compiler.
There is also the issue when the object is Nothing. The workaround is to use the ? operator:
If x?.IsDbNull
I think we should not need the ? since this is an extension method, but I don't know how the compiler acts in this case in runtime.

hmmm. I like how you're thinking here, but....

dim haveValue = x.IsDbNull

vs

dim haveValue = x?.IsDbNull

what's the correct response in each case if x is nothing ?

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

3 participants