Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4ecda670
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,发现更多精彩内容 >>
提交
4ecda670
编写于
1月 17, 2020
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle newly added property sub-pattern operation in OperationExtensions.GetValueUsageInfo
Fix #40499
上级
a1862b77
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
62 addition
and
0 deletion
+62
-0
src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedValueAssignmentTests.cs
...edParametersAndValues/RemoveUnusedValueAssignmentTests.cs
+54
-0
src/Workspaces/Core/Portable/Extensions/OperationExtensions.cs
...orkspaces/Core/Portable/Extensions/OperationExtensions.cs
+8
-0
未找到文件。
src/EditorFeatures/CSharpTest/RemoveUnusedParametersAndValues/RemoveUnusedValueAssignmentTests.cs
浏览文件 @
4ecda670
...
@@ -7415,6 +7415,60 @@ string M(object obj)
...
@@ -7415,6 +7415,60 @@ string M(object obj)
}"
,
new
TestParameters
(
options
:
PreferUnusedLocal
,
parseOptions
:
new
CSharpParseOptions
(
LanguageVersion
.
CSharp8
)));
}"
,
new
TestParameters
(
options
:
PreferUnusedLocal
,
parseOptions
:
new
CSharpParseOptions
(
LanguageVersion
.
CSharp8
)));
}
}
[
WorkItem
(
40499
,
"https://github.com/dotnet/roslyn/issues/40499"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedValues
)]
public
async
Task
LocalUsedWithPropertySubPattern
()
{
await
TestDiagnosticMissingAsync
(
@"class C
{
public object P { get; }
void M()
{
C [|c|] = new C();
var x = c is { P : int i };
}
}"
,
new
TestParameters
(
options
:
PreferDiscard
,
parseOptions
:
new
CSharpParseOptions
(
LanguageVersion
.
CSharp8
)));
}
[
WorkItem
(
40499
,
"https://github.com/dotnet/roslyn/issues/40499"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedValues
)]
public
async
Task
UnusedLocalDefinedInPropertySubPattern_PreferDiscard
()
{
await
TestInRegularAndScriptAsync
(
@"class C
{
public object P { get; }
void M(C c)
{
var x = c is { P : int [|i|] };
}
}"
,
@"class C
{
public object P { get; }
void M(C c)
{
var x = c is { P : int _ };
}
}"
,
options
:
PreferDiscard
,
parseOptions
:
new
CSharpParseOptions
(
LanguageVersion
.
CSharp8
));
}
[
WorkItem
(
40499
,
"https://github.com/dotnet/roslyn/issues/40499"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedValues
)]
public
async
Task
UnusedLocalDefinedInPropertySubPattern_PreferUnusedLocal
()
{
await
TestDiagnosticMissingAsync
(
@"class C
{
public object P { get; }
void M(C c)
{
var x = c is { P : int [|i|] };
}
}"
,
new
TestParameters
(
options
:
PreferUnusedLocal
,
parseOptions
:
new
CSharpParseOptions
(
LanguageVersion
.
CSharp8
)));
}
[
WorkItem
(
38640
,
"https://github.com/dotnet/roslyn/issues/38640"
)]
[
WorkItem
(
38640
,
"https://github.com/dotnet/roslyn/issues/38640"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedValues
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedValues
)]
public
async
Task
DeclarationPatternInSwitchExpressionArm_UnusedLocal_PreferDiscard
()
public
async
Task
DeclarationPatternInSwitchExpressionArm_UnusedLocal_PreferDiscard
()
...
...
src/Workspaces/Core/Portable/Extensions/OperationExtensions.cs
浏览文件 @
4ecda670
...
@@ -91,6 +91,14 @@ public static ValueUsageInfo GetValueUsageInfo(this IOperation operation)
...
@@ -91,6 +91,14 @@ public static ValueUsageInfo GetValueUsageInfo(this IOperation operation)
//
//
return
ValueUsageInfo
.
Write
;
return
ValueUsageInfo
.
Write
;
case
IPropertySubpatternOperation
_
:
// A declaration pattern within a property sub-pattern is a
// write for the declared local.
// For example, 'x' is defined and assigned the value from 'obj.Property' below:
// if (obj is { Property : int x })
//
return
ValueUsageInfo
.
Write
;
default
:
default
:
Debug
.
Fail
(
"Unhandled declaration pattern context"
);
Debug
.
Fail
(
"Unhandled declaration pattern context"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录