Extension type missing features #8161
Replies: 4 comments 49 replies
-
As I understand it, constructors on extensions is something the team is looking at, but it will not be in C# 13. The plan is to release something and improve it later. It's the same with |
Beta Was this translation helpful? Give feedback.
-
All three are being discussed. Check out the issue here: #5497 The team is definitely interested in gating/validation of explicit extensions, and there's a whole question/conversation as to how conversions work. Extension implementation is also a goal as it enables type classes, but it is unlikely to make it for C# 13 given the runtime ramifications. Extension constructors have been mentioned recently too, although I've not heard anything concrete as to how they would behave. |
Beta Was this translation helpful? Give feedback.
-
I think gating/validation for explicit extensions is very important for that feature to be useful. Absent such a mechanism, it looks a lot like a pit of failure to me. |
Beta Was this translation helpful? Give feedback.
-
With explicit extensions being kind of ( but not really) functional/TypeScript-like", it would be nice if something akin to the following TypeScript code was possible. type JsonString = string & { _type: "json }; // branded type - this would be the explicit extension.
function isJson(value: string): value is JsonString {
// Logic to determine whether it's a Json string, returning true if it is, and false if it isn't.
}
const str = ....; // type: string
if(isJson(str)) {
// str is now type: JsonString
}
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a few things I think might be missing from the C# 13's new extension types
Try...
might be clunky.Beta Was this translation helpful? Give feedback.
All reactions