vblang
vblang copied to clipboard
[Proposal]: Mark methods of Microsoft.VisualBasic.Information module with [Extension]
Based on #546, #547 I suggest to:
- Mark methods of Microsoft.VisualBasic.Information module with the ExtensionAttribute.
- 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 Onand 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
- Add some more useful functions to the module to shorten object checks syntax, such as
IsSomethingorHasValueor alike as proposed in #546.
If x.HasValue Then
@VBAndCs Maybe also raise the issue on the runtime repo.
https://github.com/dotnet/runtime/issues
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.
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?.IsDbNullI 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 ?