dotnet/roslyn

Code fix suggestion: fix return type

Open

#29,677 opened on Sep 5, 2018

View on GitHub
 (12 comments) (5 reactions) (0 assignees)C# (4,257 forks)batch import
Area-IDEhelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (Avg merge 6d 17h) (256 merged PRs in 30d)

Description

I want to propose a code fix for fixing the return type.

Example 1:

image

image

Here I would like to press CTRL + . and get the code fix suggestion: Fix return type from void to IEnumerable<InputParameter>

Mind that void is just a return type here (a Unit). So for example when the return type was InputParameter you would get the suggestion: Fix return type from InputParameter to IEnumerable<InputParameter>

Sorry for the brief suggestion, maybe I can add more details later @kuhlenh


Update (jcouv): As of 16.1p1, some scenarios are now handled (see PR https://github.com/dotnet/roslyn/pull/33457):

  • void M() { return 1; } (CS0127)
  • async void M() { return 1; } (CS1997)
  • void M() => 1; (CS0201)

Other scenarios listed below are not handled yet. In particular:

  • fixing an existing return type that is not void,
  • giving a clever type, instead of object, when typeless expressions (lambdas) are returned,
  • VB scenarios.

Contributor guide