Allow VB to consume extension properties
Is your feature request related to a problem? Please describe.
I would like to use C# 14's extension properties, e.g.
var s = "";
Console.WriteLine(s.IsFancy);
public static class StringExtensions
{
extension(string s)
{
public bool IsFancy => true;
}
}
…but then also to consume them in VB.
However, while VB does see extension methods even when they're in the new extension container syntax, it doesn't appear to see extension properties.
Describe the solution you'd like
It would be great if extension properties simply showed up in IntelliSense.
It would also be workable if VB merely saw methods, i.e. string.get_IsFancy in the above case, although the syntax wouldn't be quite as nice for a setter.
Additional context
For now, I'll manually write method wrappers so the extension properties can sort of be accessed from VB.
From VB, you are able to consume as StringExtensions.get_IsFancy(s), right?
Yep. However, that does mean I lose:
- extension semantics (
StringExtensions.get_IsFancy(s)rather thans.get_IsFancy())[^1], as well as - property semantics (mostly relevant in a setter:
set_isFancy(newValue)instead ofIsFancy = newValue)
[^1]: This also means that, when browsing through IntelliSense for a string, the existence of the extension isn't surfaced. In VS, if there are extension methods for a type, those are offered, even if the namespace hasn't been imported yet.
+1