adding a base record for exception #6671
Replies: 31 comments 10 replies
-
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Beta Was this translation helpful? Give feedback.
-
Well, it doesn't make sense. Frankly speaking, you reinvented |
Beta Was this translation helpful? Give feedback.
-
for record |
Beta Was this translation helpful? Give feedback.
-
Could you define, what is a major difference between |
Beta Was this translation helpful? Give feedback.
-
It sounds like what you're really asking for is the ability to declare a record that derives from Exception. That's an issue for dotnet/csharplang, the ability to derive a record from a non-record. |
Beta Was this translation helpful? Give feedback.
-
The record can be written much faster and can be wtites into one file. |
Beta Was this translation helpful? Give feedback.
-
This is a runtime problem, because I implemented it without changing the programming language. |
Beta Was this translation helpful? Give feedback.
-
RecordException would need to derive from Exception. And if that were possible, you wouldn't need RecordException at all, as any record could derive from Exception directly. "record" is a construct of the C# language. Augmenting its design and capabilities are the domain of the C# language. |
Beta Was this translation helpful? Give feedback.
-
Oh, I see. Thanks for elaborating. So the main suggestion of this issue shortens to "Add ability to inherit a record from a non-record (here in issue: record from class)). So, as I see it, this issue is not an issue, but a suggestion. Not sure that it's going to be useful, but anyway |
Beta Was this translation helpful? Give feedback.
-
Well, change the logic of work "throw" and make a basic type for excluding records |
Beta Was this translation helpful? Give feedback.
-
Yes, I do it at the level of il code, but in my example it will not be possible to do this in C# code. |
Beta Was this translation helpful? Give feedback.
-
Again, that's the C# language. The runtime supports throwing anything. This is not actionable here. I'm going to close it. Thanks. |
Beta Was this translation helpful? Give feedback.
-
So my library changes the programming language :) |
Beta Was this translation helpful? Give feedback.
-
The limitation is that C# does not allow records to extend from non-records (other than |
Beta Was this translation helpful? Give feedback.
-
And at the same time add the il code project |
Beta Was this translation helpful? Give feedback.
-
This is why I'm suggesting that if this is considered that it would be addressed by lifting the limitation, allowing records to extend from other arbitrary classes. Then a record could extend from |
Beta Was this translation helpful? Give feedback.
-
It's bad, it's better to change the programming language, or to write one class in il, which is easier? |
Beta Was this translation helpful? Give feedback.
-
Either way the programming language would change because |
Beta Was this translation helpful? Give feedback.
-
Yes, but from this record, only records will be followed, it will have a base class Exception, the programming language at the C# level is not affected, because it is written in il code, a basic record for errors just appears. |
Beta Was this translation helpful? Give feedback.
-
I don't see the point of them imitating records, in fact a base class for records is needed to reduce the routine of writing classes for errors |
Beta Was this translation helpful? Give feedback.
-
The BCL is written in C#, if C# doesn't allow it then it won't end up in the runtime. They have already closed your suggestion of adding a new base exception class as something they won't do.
Which just makes them that much less useful. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
You'll also notice this: They've already stated that this is a language concern, and as a language concern the possible solution would be to lift the limitation on extending non-records. The runtime team has expressed being not interested in writing custom IL for specific APIs that cannot be expressed in C#, such as defining helper methods that used |
Beta Was this translation helpful? Give feedback.
-
That's a test. This was transferred to the C# repo for a reason, it's a language issue. If you're stuck on this being implemented as a special new class you're going to be disappointed. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
You're trying to use a feature of the C# language: records. You don't like a limitation of that C# feature: records currently can't derive from non-records. The fix isn't to special-case a single base type in the core libraries and hack it outside of C# to work-around the designed C# constraint for that one case. You're asking for a custom Exception base type, but there are thousands and thousands of other classes that folks might similarly want as a base type for a record; Exception is not special in that regard. Thank you for your suggestion, but we're not going to add such a type to the base libraries. In the meantime, you've hacked up an approach in IL that obviously meets your needs, since you're asking us to replicate what you've done. You're obviously free to use that as a helper in your own projects, and even to publish a NuGet package for others to consume if you believe it's so impactful. In the meantime, I'd encourage you to have the conversation at the language level about lifting the constraint, and more importantly, how to address the holes that constraint is there to prevent. Thanks. |
Beta Was this translation helpful? Give feedback.
-
well, they won't be able to do it (it's good, because these are fundamentally different things, I just don't see the second solution), this record will be an ordinary record, besides, it will be accepted by throw |
Beta Was this translation helpful? Give feedback.
-
Okay, this is just an idea, if you don’t want to implement it, I’ll use the library maybe) |
Beta Was this translation helpful? Give feedback.
-
I suggest adding a base record for exception
Similar to this https://github.com/Mr0N/CustomExceptionRecords
Beta Was this translation helpful? Give feedback.
All reactions