-
Notifications
You must be signed in to change notification settings - Fork 10.3k
ActionResult<T> class shouldn't be sealed #6729
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
Comments
Without the class name we can't really talk about why it's sealed. Could you please supply it? |
The issue got edited (see there) -> |
I, too, had to discard the |
I should probably also mention why I found |
My personal thinking at the time was that |
Can you elaborate? |
Hey David, sure. A crude example to start. If we are generating proxies or documentation from our return types, of course we'd like the compiler to ensure our proxy/client doesn't throw RT (de)serialization errors. Otherwise attribute-based documentation performs the same function. However, the following compiles:
Of course, in most cases, we don't call
|
In my case, I just don't want to write this over and over in conrollers:
|
I hear you and appreciate your intuitive desire to reduce repetition. Of course reducing code shouldn't be the only goal. Readability is important too, and not always correlated with fewer characters. e.g. if we just want to reduce code we could simply state the return type as IActionResult in all cases. By merging the content type with the platform type, we make it harder for consumers (both humans and tooling) to understand the data type that will need to be (de)serialized. We can't apply a simple logical rule and say "our web methods return whatever is inside the ActionResult angle braces". |
I don't know how |
We're tracking addressing this using an analyzer in #8535. Is there a reason you weren't able to use |
@pranavkm I'm not sure. As I noted above, I reviewed it as an option at the time I selected an approach, and chose against it. Looking at what I did, I probably chose to derive from
@pranavkm Thanks for the heads-up. I wish it weren't necessary. See my comment in 8535 Personally, for most of the work I do in the middle tier, what I really desire are raw DTO return values. I could ignore all of this business if there were a better way to return |
Thank you for contacting us. Due to no activity on this issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue. |
Describe the bug
I was going to make an inherited class
ActionListResult : ActionResult<List>
to help avoid repeating List everywhere in controllers but I can't do this because this class is marked as sealed. Why mark this as sealed?Expected behavior
Be able to use inheritance.
The text was updated successfully, but these errors were encountered: