question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intellisense/aspnetcore not allowing void -> object casting

See original GitHub issue

Describe 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:

  1. Using this version of ASP.NET Core 2.2
  2. Run this code
        private void ReturnVoid() { }


        public ActionResult<object> FaultyMethod()
        {
            return ReturnVoid();
        }
  1. With these argumentsx
  2. 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:closed
  • Created 4 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jaredparcommented, Apr 9, 2019

@Eilon yes we should. Can’t do a real move though because don’t have a dual Admin. I will do a manual move.

0reactions
wisepotatocommented, Apr 9, 2019

Woah you guys move fast.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found