dotnet/roslyn

Code fix suggestion: fix return type

Aperta

#29.677 aperta il 5 set 2018

 (12 commenti) (5 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-IDEhelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

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.

Guida contributor