Intellisense/aspnetcore not allowing void -> object casting
See original GitHub issueDescribe the bug
When using ActionResult<object>
as a result, the resulting method allows for the return of void
from another function, but it shouldn’t, as this gives a ProgramException.
I dont know if this is a Roslyn bug or AspNetCore bug.
To Reproduce
Steps to reproduce the behavior:
- Using this version of ASP.NET Core 2.2
- Run this code
private void ReturnVoid() { }
public ActionResult<object> FaultyMethod()
{
return ReturnVoid();
}
- With these argumentsx
- See error
ProgramException
Expected behavior
It should return an EmptyResult to the end user. Or give an error in intellisense/Roslyn that this sort of thing should not happen.
Or am I missing something here?
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Cannot implicitly convert type 'Microsoft.AspNetCore.Mvc. ...
Mvc.BadRequestObjectResult' to 'System.Collections.Generic.IList'. An explicit conversion exists (are you missing a cast?) This is my code ...
Read more >Unary + on lambda false error in IntelliSense
The following two pieces of code compile and work correctly, but display an error message in the IDE: auto a = []{}; void(*b)()...
Read more >Incorrect IntelliSense for functions with a default argument ...
U> void i(int i = 0, T... args, U... args2) {} int main() { i(3); }. This code compiles, but "i(3);" has red...
Read more >Dynamic Type in C#
Dynamic is basically System.Object type under the hood, but it doesn't need to explicitly cast a value before using it. More on that...
Read more >Using type dynamic
Learn how to use the dynamic type. The dynamic type is a static type, but dynamic objects bypass static type checking.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Eilon yes we should. Can’t do a real move though because don’t have a dual Admin. I will do a manual move.
Woah you guys move fast.