dotnet/roslyn

Code fix suggestion: fix return type

开放

#29,677 创建于 2018年9月5日

 (12 条评论) (5 个反应) (0 位负责人)C# (4,257 个派生)batch import
Area-IDEhelp wanted

仓库指标

星标
 (20,414 个星标)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

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.

贡献者指南