-
Notifications
You must be signed in to change notification settings - Fork 64
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] Extension Property? #73
Comments
And note VB Axis Queries already provides a Property Extension for .Value: https://docs.microsoft.com/en-us/dotnet/articles/visual-basic/language-reference/xml-axis/xml-value-property |
Hi, @markhurd, Using XML value property is kind of like using Using Dictionary as the extension property example: Dim o As New Dictionary(Of String, Object)
o!ABC = New Dictionary(Of String, Double) From {
{"ABC", 123.0#},
{"BBB", 666.0#}
}
o!Date = #2017-5-11 11:11:11#
Call println("ABC=%s,\n\nDate=%s\n", GetObjectJson(o!ABC, o!ABC.GetType), o!Date) But the problem is that
|
@markhurd you've discovered the secret! We've talked for years about defining extension properties using the equivalent syntax we use for methods given that VB supports parameterized properties already. They wouldn't be generic but they'd be something. |
We're working on an "Extension everything" proposal which would let you define more than just methods and properties as extensions. It's a more general feature which we'd prefer over a special case. That said, since VB supports parameterized properties, we would consider a prototype demonstrating extending the existing extension method syntax to support parameterized properties. |
As all we knowns that since VB6, the
Property Procedures
in VisualBasic is consist with a paired method and function which have name prefixGet
andSet
. The vb6 compiler can automatic properties this paired method as Class property.Sometime we just want a light weight class type without too many function and property, and using the extension method can simply extend this light weight class type and add more function based on our different demands. But as so far, we don't have the extension property yet, but we can doing something currently like:
So that I think why don't we just enable using this extension method way to add a extension property as the VB6 it does?
The compiler match this two extension function their name with rule: Set<Name> and Get<Name>, so that we can paired these two extension method as an extension property.
Then we use such extension method as in sciBASIC it does: https://github.com/xieguigang/GCModeller/blob/7f44b456e1df40b450614a21769126c4f23c35f8/src/interops/localblast/LocalBLAST/LocalBLAST/LocalBLAST/Application/COG/Whog/Category.vb#L110
For the parameter property, that we can
The text was updated successfully, but these errors were encountered: