Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f0ec22a5
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f0ec22a5
编写于
9月 30, 2018
作者:
Š
Šimon Koníček
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix to unwrap non-generic Task to void
上级
81614bdc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
434 addition
and
27 deletion
+434
-27
src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs
...arpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs
+229
-5
src/EditorFeatures/CSharpTest/GenerateVariable/GenerateVariableTests.cs
...ures/CSharpTest/GenerateVariable/GenerateVariableTests.cs
+5
-5
src/EditorFeatures/CSharpTest/TypeInferrer/TypeInferrerTests.cs
...itorFeatures/CSharpTest/TypeInferrer/TypeInferrerTests.cs
+189
-14
src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs
...nguageServices/CSharpTypeInferenceService.TypeInferrer.cs
+11
-3
未找到文件。
src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs
浏览文件 @
f0ec22a5
...
...
@@ -2573,7 +2573,7 @@ private static int Goo()
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateInAsyncSimpleLambda
()
public
async
Task
TestGenerateInAsync
TaskOfT
SimpleLambda
()
{
await
TestInRegularAndScriptAsync
(
@"using System;
...
...
@@ -2605,7 +2605,7 @@ private static int Goo(string x)
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateInAsyncParenthesizedLambda
()
public
async
Task
TestGenerateInAsync
TaskOfT
ParenthesizedLambda
()
{
await
TestInRegularAndScriptAsync
(
@"using System;
...
...
@@ -2635,6 +2635,132 @@ private static int Goo()
}"
);
}
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateInAsyncTaskSimpleLambda
()
{
await
TestInRegularAndScriptAsync
(
@"using System;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Func<string, Task> f = async x => [|Goo|](x);
}
}"
,
@"using System;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Func<string, Task> f = async x => Goo(x);
}
private static void Goo(string x)
{
throw new NotImplementedException();
}
}"
);
}
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateInAsyncTaskParenthesizedLambda
()
{
await
TestInRegularAndScriptAsync
(
@"using System;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Func<Task> f = async () => [|Goo|]();
}
}"
,
@"using System;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Func<Task> f = async () => Goo();
}
private static void Goo()
{
throw new NotImplementedException();
}
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateInAsyncVoidSimpleLambda
()
{
await
TestInRegularAndScriptAsync
(
@"using System;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Action<string> f = async x => [|Goo|](x);
}
}"
,
@"using System;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Action<string> f = async x => Goo(x);
}
private static void Goo(string x)
{
throw new NotImplementedException();
}
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateInAsyncVoidParenthesizedLambda
()
{
await
TestInRegularAndScriptAsync
(
@"using System;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Action f = async () => [|Goo|]();
}
}"
,
@"using System;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Action f = async () => Goo();
}
private static void Goo()
{
throw new NotImplementedException();
}
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateInAssignmentInAnonymousMethod
()
{
...
...
@@ -6458,7 +6584,7 @@ private static C x()
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateMethodInExpressionBodiedAsyncMethod
()
public
async
Task
TestGenerateMethodInExpressionBodiedAsync
TaskOfT
Method
()
{
await
TestInRegularAndScriptAsync
(
@"class C
...
...
@@ -6478,6 +6604,49 @@ private static C x()
}"
);
}
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateMethodInExpressionBodiedAsyncTaskMethod
()
{
await
TestInRegularAndScriptAsync
(
@"class C
{
public static async System.Threading.Tasks.Task GetValue(C p) => [|x|]();
}"
,
@"using System;
class C
{
public static async System.Threading.Tasks.Task GetValue(C p) => x();
private static void x()
{
throw new NotImplementedException();
}
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateMethodInExpressionBodiedAsyncVoidMethod
()
{
await
TestInRegularAndScriptAsync
(
@"class C
{
public static async void GetValue(C p) => [|x|]();
}"
,
@"using System;
class C
{
public static async void GetValue(C p) => x();
private static void x()
{
throw new NotImplementedException();
}
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateMethodInExpressionBodiedOperator
()
{
...
...
@@ -7971,7 +8140,7 @@ private int GenerateMethod()
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateMethodInExpressionBodiedAsyncLocalFunction
()
public
async
Task
TestGenerateMethodInExpressionBodiedAsync
TaskOfT
LocalFunction
()
{
await
TestInRegularAndScriptAsync
(
@"class Class
...
...
@@ -7997,6 +8166,61 @@ private int GenerateMethod()
}"
);
}
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateMethodInExpressionBodiedAsyncTaskLocalFunction
()
{
await
TestInRegularAndScriptAsync
(
@"class Class
{
void Method()
{
async System.Threading.Tasks.Task Local() => [|GenerateMethod()|];
}
}"
,
@"using System;
class Class
{
void Method()
{
async System.Threading.Tasks.Task Local() => GenerateMethod();
}
private void GenerateMethod()
{
throw new NotImplementedException();
}
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateMethodInExpressionBodiedAsyncVoidLocalFunction
()
{
await
TestInRegularAndScriptAsync
(
@"class Class
{
void Method()
{
async void Local() => [|GenerateMethod()|];
}
}"
,
@"using System;
class Class
{
void Method()
{
async void Local() => GenerateMethod();
}
private void GenerateMethod()
{
throw new NotImplementedException();
}
}"
);
}
[
WorkItem
(
26993
,
"https://github.com/dotnet/roslyn/issues/26993"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateMethodInBlockBodiedLocalFunction
()
...
...
@@ -8032,7 +8256,7 @@ private int GenerateMethod()
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateMethod
)]
public
async
Task
TestGenerateMethodInBlockBodiedAsyncLocalFunction
()
public
async
Task
TestGenerateMethodInBlockBodiedAsync
TaskOfT
LocalFunction
()
{
await
TestInRegularAndScriptAsync
(
@"class Class
...
...
src/EditorFeatures/CSharpTest/GenerateVariable/GenerateVariableTests.cs
浏览文件 @
f0ec22a5
...
...
@@ -1475,7 +1475,7 @@ static void Main(string[] args)
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateVariable
)]
public
async
Task
TestGenerateFieldInAsyncSimpleLambda
()
public
async
Task
TestGenerateFieldInAsync
TaskOfT
SimpleLambda
()
{
await
TestInRegularAndScriptAsync
(
@"using System;
...
...
@@ -1504,7 +1504,7 @@ static void Main(string[] args)
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateVariable
)]
public
async
Task
TestGenerateFieldInAsyncParenthesizedLambda
()
public
async
Task
TestGenerateFieldInAsync
TaskOfT
ParenthesizedLambda
()
{
await
TestInRegularAndScriptAsync
(
@"using System;
...
...
@@ -6543,7 +6543,7 @@ public async Task TestGeneratePropertyInExpressionBodiedMethod()
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateVariable
)]
public
async
Task
TestGeneratePropertyInExpressionBodiedAsyncMethod
()
public
async
Task
TestGeneratePropertyInExpressionBodiedAsync
TaskOfT
Method
()
{
await
TestInRegularAndScriptAsync
(
@"class C
...
...
@@ -7969,7 +7969,7 @@ public void Method()
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateVariable
)]
public
async
Task
TestGeneratePropertyInExpressionBodiedAsyncLocalFunction
()
public
async
Task
TestGeneratePropertyInExpressionBodiedAsync
TaskOfT
LocalFunction
()
{
await
TestInRegularAndScriptAsync
(
@"class Program
...
...
@@ -8104,7 +8104,7 @@ int Local()
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateVariable
)]
public
async
Task
TestGeneratePropertyInBlockBodiedAsyncLocalFunction
()
public
async
Task
TestGeneratePropertyInBlockBodiedAsync
TaskOfT
LocalFunction
()
{
await
TestInRegularAndScriptAsync
(
@"class Program
...
...
src/EditorFeatures/CSharpTest/TypeInferrer/TypeInferrerTests.cs
浏览文件 @
f0ec22a5
...
...
@@ -705,7 +705,17 @@ public async Task TestReturnInMethod()
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncMethod
()
public
async
Task
TestReturnInVoidMethod
()
{
await
TestInClassAsync
(
@"void M()
{
return [|Goo()|];
}"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncTaskOfTMethod
()
{
await
TestInClassAsync
(
@"async System.Threading.Tasks.Task<int> M()
...
...
@@ -715,10 +725,23 @@ public async Task TestReturnInAsyncMethod()
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnIn
Void
Method
()
public
async
Task
TestReturnIn
AsyncTask
Method
()
{
await
TestInMethodAsync
(
@"return [|Goo()|];"
,
"void"
);
await
TestInClassAsync
(
@"async System.Threading.Tasks.Task M()
{
return [|Goo()|];
}"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncVoidMethod
()
{
await
TestInClassAsync
(
@"async void M()
{
return [|Goo()|];
}"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
...
...
@@ -835,7 +858,7 @@ int F()
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncLocalFunction
()
public
async
Task
TestReturnInAsync
TaskOfT
LocalFunction
()
{
await
TestInClassAsync
(
@"void M()
...
...
@@ -847,6 +870,32 @@ async System.Threading.Tasks.Task<int> F()
}"
,
"global::System.Int32"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncTaskLocalFunction
()
{
await
TestInClassAsync
(
@"void M()
{
async System.Threading.Tasks.Task F()
{
return [|Goo()|];
}
}"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncVoidLocalFunction
()
{
await
TestInClassAsync
(
@"void M()
{
async void F()
{
return [|Goo()|];
}
}"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestExpressionBodiedConstructor
()
{
...
...
@@ -868,19 +917,34 @@ public async Task TestExpressionBodiedMethod()
@"int M() => [|Goo()|];"
,
"global::System.Int32"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestExpressionBodiedVoidMethod
()
{
await
TestInClassAsync
(
@"void M() => [|Goo()|];"
,
"void"
);
}
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestExpressionBodiedAsyncMethod
()
public
async
Task
TestExpressionBodiedAsync
TaskOfT
Method
()
{
await
TestInClassAsync
(
@"async System.Threading.Tasks.Task<int> M() => [|Goo()|];"
,
"global::System.Int32"
);
}
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestExpressionBodied
Void
Method
()
public
async
Task
TestExpressionBodied
AsyncTask
Method
()
{
await
TestInClassAsync
(
@"void M() => [|Goo()|];"
,
"void"
);
@"async System.Threading.Tasks.Task M() => [|Goo()|];"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestExpressionBodiedAsyncVoidMethod
()
{
await
TestInClassAsync
(
@"async void M() => [|Goo()|];"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
...
...
@@ -965,7 +1029,7 @@ public async Task TestExpressionBodiedLocalFunction()
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestExpressionBodiedAsyncLocalFunction
()
public
async
Task
TestExpressionBodiedAsync
TaskOfT
LocalFunction
()
{
await
TestInClassAsync
(
@"void M()
...
...
@@ -974,6 +1038,27 @@ public async Task TestExpressionBodiedAsyncLocalFunction()
}"
,
"global::System.Int32"
);
}
[
WorkItem
(
27647
,
"https://github.com/dotnet/roslyn/issues/27647"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestExpressionBodiedAsyncTaskLocalFunction
()
{
await
TestInClassAsync
(
@"void M()
{
async System.Threading.Tasks.Task F() => [|Goo()|];
}"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestExpressionBodiedAsyncVoidLocalFunction
()
{
await
TestInClassAsync
(
@"void M()
{
async void F() => [|Goo()|];
}"
,
"void"
);
}
[
WorkItem
(
827897
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/827897"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestYieldReturnInMethod
()
...
...
@@ -1043,7 +1128,7 @@ public async Task TestReturnInAnonymousMethod()
[
WorkItem
(
4486
,
"https://github.com/dotnet/roslyn/issues/4486"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncSimpleLambda
()
public
async
Task
TestReturnInAsync
TaskOfT
SimpleLambda
()
{
await
TestInMethodAsync
(
@"System.Func<string, System.Threading.Tasks.Task<int>> f = async s =>
...
...
@@ -1054,7 +1139,7 @@ public async Task TestReturnInAsyncSimpleLambda()
[
WorkItem
(
4486
,
"https://github.com/dotnet/roslyn/issues/4486"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncParenthesizedLambda
()
public
async
Task
TestReturnInAsync
TaskOfT
ParenthesizedLambda
()
{
await
TestInMethodAsync
(
@"System.Func<System.Threading.Tasks.Task<int>> f = async () =>
...
...
@@ -1065,7 +1150,7 @@ public async Task TestReturnInAsyncParenthesizedLambda()
[
WorkItem
(
4486
,
"https://github.com/dotnet/roslyn/issues/4486"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncAnonymousMethod
()
public
async
Task
TestReturnInAsync
TaskOfT
AnonymousMethod
()
{
await
TestInMethodAsync
(
@"System.Func<System.Threading.Tasks.Task<int>> f = async delegate ()
...
...
@@ -1074,6 +1159,66 @@ public async Task TestReturnInAsyncAnonymousMethod()
};"
,
"global::System.Int32"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncTaskSimpleLambda
()
{
await
TestInMethodAsync
(
@"System.Func<string, System.Threading.Tasks.Task> f = async s =>
{
return [|Goo()|];
};"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncTaskParenthesizedLambda
()
{
await
TestInMethodAsync
(
@"System.Func<System.Threading.Tasks.Task> f = async () =>
{
return [|Goo()|];
};"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncTaskAnonymousMethod
()
{
await
TestInMethodAsync
(
@"System.Func<System.Threading.Tasks.Task> f = async delegate ()
{
return [|Goo()|];
};"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncVoidSimpleLambda
()
{
await
TestInMethodAsync
(
@"System.Action<string> f = async s =>
{
return [|Goo()|];
};"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncVoidParenthesizedLambda
()
{
await
TestInMethodAsync
(
@"System.Action f = async () =>
{
return [|Goo()|];
};"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestReturnInAsyncVoidAnonymousMethod
()
{
await
TestInMethodAsync
(
@"System.Action f = async delegate ()
{
return [|Goo()|];
};"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestSimpleLambda
()
{
...
...
@@ -1090,7 +1235,7 @@ public async Task TestParenthesizedLambda()
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestAsyncSimpleLambda
()
public
async
Task
TestAsync
TaskOfT
SimpleLambda
()
{
await
TestInMethodAsync
(
@"System.Func<string, System.Threading.Tasks.Task<int>> f = async s => [|Goo()|];"
,
"global::System.Int32"
);
...
...
@@ -1098,12 +1243,42 @@ public async Task TestAsyncSimpleLambda()
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestAsyncParenthesizedLambda
()
public
async
Task
TestAsync
TaskOfT
ParenthesizedLambda
()
{
await
TestInMethodAsync
(
@"System.Func<System.Threading.Tasks.Task<int>> f = async () => [|Goo()|];"
,
"global::System.Int32"
);
}
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestAsyncTaskSimpleLambda
()
{
await
TestInMethodAsync
(
@"System.Func<string, System.Threading.Tasks.Task> f = async s => [|Goo()|];"
,
"void"
);
}
[
WorkItem
(
30232
,
"https://github.com/dotnet/roslyn/issues/30232"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestAsyncTaskParenthesizedLambda
()
{
await
TestInMethodAsync
(
@"System.Func<System.Threading.Tasks.Task> f = async () => [|Goo()|];"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestAsyncVoidSimpleLambda
()
{
await
TestInMethodAsync
(
@"System.Action<string> f = async s => [|Goo()|];"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestAsyncVoidParenthesizedLambda
()
{
await
TestInMethodAsync
(
@"System.Action f = async () => [|Goo()|];"
,
"void"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
TypeInferenceService
)]
public
async
Task
TestExpressionTreeSimpleLambda
()
{
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs
浏览文件 @
f0ec22a5
...
...
@@ -1811,9 +1811,17 @@ private IEnumerable<TypeInferenceInfo> InferTypeInRefExpression(RefExpressionSyn
private
ITypeSymbol
UnwrapTaskLike
(
ITypeSymbol
type
,
bool
isAsync
)
{
return
isAsync
&&
type
.
OriginalDefinition
.
Equals
(
this
.
Compilation
.
TaskOfTType
())
?
((
INamedTypeSymbol
)
type
).
TypeArguments
[
0
]
:
type
;
if
(!
isAsync
)
{
return
type
;
}
return
type
.
OriginalDefinition
.
Equals
(
this
.
Compilation
.
TaskOfTType
())
?
((
INamedTypeSymbol
)
type
).
TypeArguments
[
0
]
:
type
.
OriginalDefinition
.
Equals
(
this
.
Compilation
.
TaskType
())
?
this
.
Compilation
.
GetSpecialType
(
SpecialType
.
System_Void
)
:
type
;
}
private
IEnumerable
<
TypeInferenceInfo
>
InferTypeForReturnStatement
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录