Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b1ab1b05
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,发现更多精彩内容 >>
未验证
提交
b1ab1b05
编写于
10月 11, 2018
作者:
M
Manish Vasani
提交者:
GitHub
10月 11, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #30402 from mavasani/Issue_30397
Fix for Incorrect IDE0052 (assigned but never read)
上级
0f340a52
8b2bd26e
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
170 addition
and
145 deletion
+170
-145
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
...SharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
+94
-87
src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs
...ies/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs
+4
-1
src/EditorFeatures/TestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs
...tics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs
+11
-1
src/EditorFeatures/VisualBasicTest/RemoveUnusedMembers/RemoveUnusedMembersTests.vb
...BasicTest/RemoveUnusedMembers/RemoveUnusedMembersTests.vb
+59
-54
src/Features/Core/Portable/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs
...dMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs
+2
-2
未找到文件。
src/EditorFeatures/CSharpTest/RemoveUnusedMembers/RemoveUnusedMembersTests.cs
浏览文件 @
b1ab1b05
此差异已折叠。
点击以展开。
src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs
浏览文件 @
b1ab1b05
...
...
@@ -36,6 +36,7 @@ public struct TestParameters
internal
readonly
CompilationOptions
compilationOptions
;
internal
readonly
int
index
;
internal
readonly
CodeActionPriority
?
priority
;
internal
readonly
bool
retainNonFixableDiagnostics
;
internal
TestParameters
(
ParseOptions
parseOptions
=
null
,
...
...
@@ -43,7 +44,8 @@ public struct TestParameters
IDictionary
<
OptionKey
,
object
>
options
=
null
,
object
fixProviderData
=
null
,
int
index
=
0
,
CodeActionPriority
?
priority
=
null
)
CodeActionPriority
?
priority
=
null
,
bool
retainNonFixableDiagnostics
=
false
)
{
this
.
parseOptions
=
parseOptions
;
this
.
compilationOptions
=
compilationOptions
;
...
...
@@ -51,6 +53,7 @@ public struct TestParameters
this
.
fixProviderData
=
fixProviderData
;
this
.
index
=
index
;
this
.
priority
=
priority
;
this
.
retainNonFixableDiagnostics
=
retainNonFixableDiagnostics
;
}
public
TestParameters
WithParseOptions
(
ParseOptions
parseOptions
)
...
...
src/EditorFeatures/TestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs
浏览文件 @
b1ab1b05
...
...
@@ -143,8 +143,18 @@ public void TestSupportedDiagnosticsMessageHelpLinkUri()
var
ids
=
new
HashSet
<
string
>(
fixer
.
FixableDiagnosticIds
);
var
dxs
=
diagnostics
.
Where
(
d
=>
ids
.
Contains
(
d
.
Id
)).
ToList
();
return
await
GetDiagnosticAndFixesAsync
(
var
(
resultDiagnostics
,
codeActions
,
actionToInvoke
)
=
await
GetDiagnosticAndFixesAsync
(
dxs
,
provider
,
fixer
,
testDriver
,
document
,
span
,
annotation
,
parameters
.
index
);
// If we are also testing non-fixable diagnostics,
// then the result diagnostics need to include all diagnostics,
// not just the fixable ones returned from GetDiagnosticAndFixesAsync.
if
(
parameters
.
retainNonFixableDiagnostics
)
{
resultDiagnostics
=
diagnostics
;
}
return
(
resultDiagnostics
,
codeActions
,
actionToInvoke
);
}
protected
async
Task
TestDiagnosticInfoAsync
(
...
...
src/EditorFeatures/VisualBasicTest/RemoveUnusedMembers/RemoveUnusedMembersTests.vb
浏览文件 @
b1ab1b05
...
...
@@ -12,6 +12,11 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.RemoveUnusedMember
Return
(
New
VisualBasicRemoveUnusedMembersDiagnosticAnalyzer
(),
New
VisualBasicRemoveUnusedMembersCodeFixProvider
())
End
Function
' Ensure that we explicitly test missing IDE0052, which has no corresponding code fix (non-fixable diagnostic).
Private
Overloads
Function
TestDiagnosticMissingAsync
(
initialMarkup
As
String
)
As
Task
Return
TestDiagnosticMissingAsync
(
initialMarkup
,
New
TestParameters
(
retainNonFixableDiagnostics
:
=
True
))
End
Function
Private
Shared
Function
Diagnostic
(
id
As
String
)
As
DiagnosticDescription
Return
TestHelpers
.
Diagnostic
(
id
)
End
Function
...
...
@@ -22,7 +27,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.RemoveUnusedMember
<
InlineData
(
"Protected"
)
>
<
InlineData
(
"Protected Friend"
)
>
Public
Async
Function
NonPrivateField
(
accessibility
As
String
)
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
$
"Class C
{accessibility} [|_goo|] As Integer
End Class"
)
...
...
@@ -34,7 +39,7 @@ End Class")
<
InlineData
(
"Protected"
)
>
<
InlineData
(
"Protected Friend"
)
>
Public
Async
Function
NonPrivateFieldWithConstantInitializer
(
accessibility
As
String
)
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
$
"Class C
{accessibility} [|_goo|] As Integer = 0
End Class"
)
...
...
@@ -46,7 +51,7 @@ End Class")
<
InlineData
(
"Protected"
)
>
<
InlineData
(
"Protected Friend"
)
>
Public
Async
Function
NonPrivateFieldWithNonConstantInitializer
(
accessibility
As
String
)
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
$
"Class C
{accessibility} [|_goo|] As Integer = _goo2
Private Shared ReadOnly _goo2 As Integer = 0
...
...
@@ -59,7 +64,7 @@ End Class")
<
InlineData
(
"Protected"
)
>
<
InlineData
(
"Protected Friend"
)
>
Public
Async
Function
NonPrivateMethod
(
accessibility
As
String
)
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
$
"Class C
{accessibility} Sub [|M|]
End Sub
...
...
@@ -72,7 +77,7 @@ End Class")
<
InlineData
(
"Protected"
)
>
<
InlineData
(
"Protected Friend"
)
>
Public
Async
Function
NonPrivateProperty
(
accessibility
As
String
)
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
$
"Class C
{accessibility} Property [|P|] As Integer
End Class"
)
...
...
@@ -84,7 +89,7 @@ End Class")
<
InlineData
(
"Protected"
)
>
<
InlineData
(
"Protected Friend"
)
>
Public
Async
Function
NonPrivateIndexer
(
accessibility
As
String
)
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
$
"Class C
{accessibility} Property [|P|](i As Integer) As Integer
Get
...
...
@@ -102,7 +107,7 @@ End Class")
<
InlineData
(
"Protected"
)
>
<
InlineData
(
"Protected Friend"
)
>
Public
Async
Function
NonPrivateEvent
(
accessibility
As
String
)
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
$
"Class C
{accessibility} Event [|E|] As EventHandler
End Class"
)
...
...
@@ -154,7 +159,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
InstanceConstructorIsUnused_NoArguments
()
As
Task
' We only flag constructors with arguments.
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|New()|]
End Sub
...
...
@@ -174,7 +179,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
StaticConstructorIsNotFlagged
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Shared Sub [|New()|]
End Sub
...
...
@@ -337,7 +342,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Public Function M() As Integer
...
...
@@ -348,7 +353,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_Lambda
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Public Function M() As Integer
...
...
@@ -359,7 +364,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_Accessor
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Public Property P As Integer
...
...
@@ -372,7 +377,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_DifferentInstance
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Public Function M() As Integer
...
...
@@ -383,7 +388,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_ObjectInitializer
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Public Function M() As C2
...
...
@@ -398,7 +403,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_ObjectInitializer_02
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Dim _goo2 As Integer
...
...
@@ -410,7 +415,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_MeInstance
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Public Function M() As Integer
...
...
@@ -421,7 +426,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_Attribute
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Const [|_goo|] As String =
""""
...
...
@@ -433,7 +438,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
MethodIsInvoked
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|M|]()
End Sub
...
...
@@ -446,7 +451,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
MethodIsAddressTaken
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|M|]()
End Sub
...
...
@@ -459,7 +464,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
GenericMethodIsInvoked_ExplicitTypeArguments
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|M1|](Of T)()
End Sub
...
...
@@ -472,7 +477,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
GenericMethodIsInvoked_ImplicitTypeArguments
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|M1|](Of T)(t1 As T)
End Sub
...
...
@@ -485,7 +490,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
MethodInGenericTypeIsInvoked_NoTypeArguments
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C(Of T)
Private Sub [|M1|]()
End Sub
...
...
@@ -498,7 +503,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
MethodInGenericTypeIsInvoked_NonConstructedType
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C(Of T)
Private Sub [|M1|]()
End Sub
...
...
@@ -511,7 +516,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
MethodInGenericTypeIsInvoked_ConstructedType
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C(Of T)
Private Sub [|M1|]()
End Sub
...
...
@@ -524,7 +529,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
InstanceConstructorIsUsed_NoArguments
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|New|]()
End Sub
...
...
@@ -535,7 +540,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
InstanceConstructorIsUsed_NoArguments_AsNew
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|New|]()
End Sub
...
...
@@ -546,7 +551,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
InstanceConstructorIsUsed_WithArguments
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|New|](i As Integer)
End Sub
...
...
@@ -557,7 +562,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
InstanceConstructorIsUsed_WithArguments_AsNew
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|New|](i As Integer)
End Sub
...
...
@@ -568,7 +573,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
PropertyIsRead
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private ReadOnly Property [|P|] As Integer
Public Function M() As Integer
...
...
@@ -579,7 +584,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
IndexerIsRead
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Shared Property [|P|](i As Integer) As Integer
Get
...
...
@@ -597,7 +602,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
EventIsRead
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Event [|E|] As System.EventHandler
...
...
@@ -609,7 +614,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
EventIsSubscribed
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Event [|E|] As System.EventHandler
...
...
@@ -621,7 +626,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
EventIsRaised
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Imports System
Class C
...
...
@@ -801,7 +806,7 @@ End Class", parameters:=Nothing,
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsReadAndWritten
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Public Sub M()
...
...
@@ -813,7 +818,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
PropertyIsReadAndWritten
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private ReadOnly Property [|P|] As Integer
Public Sub M()
...
...
@@ -825,7 +830,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
IndexerIsReadAndWritten
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Property [|P|](i As Integer) As Integer
Get
...
...
@@ -887,7 +892,7 @@ End Class", parameters:=Nothing,
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsArg
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Public Sub M1()
...
...
@@ -900,7 +905,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsByRefArg
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Dim [|_goo|] As Integer
Public Sub M1()
...
...
@@ -913,7 +918,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
MethodIsArg
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|M()|]
End Sub
...
...
@@ -928,7 +933,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
PropertyIsArg
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private ReadOnly Property [|P|] As Integer
Public Sub M1()
...
...
@@ -941,7 +946,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
IndexerIsArg
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Property [|P|](i As Integer) As Integer
Get
...
...
@@ -961,7 +966,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
EventIsArg
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Event [|_goo|] As System.EventHandler
Public Sub M1()
...
...
@@ -1013,7 +1018,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
MultipleFields_SomeUnused_02
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private [|_goo|] = 0, _goo2 = 0
Public Function M() As Integer
...
...
@@ -1024,7 +1029,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_InNestedType
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private [|_goo|] As Integer
Private Class Nested
...
...
@@ -1037,7 +1042,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
MethodIsInvoked_InNestedType
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Sub [|M1|]()
End Sub
...
...
@@ -1066,7 +1071,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldOfNestedTypeIsRead
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private Class Nested
Private [|_goo|] As Integer
...
...
@@ -1089,7 +1094,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_PartialClass
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Partial Class C
Private [|_goo|] As Integer
End Class
...
...
@@ -1103,7 +1108,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_PartialClass_DifferentFile
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"<Workspace>
<Project Language=
""
Visual Basic
""
AssemblyName=
""
Assembly1
""
CommonReferences=
""
true
""
>
<Document>
...
...
@@ -1146,7 +1151,7 @@ End Class
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsRead_InParens
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private [|_goo|] As Integer
Public Function M() As Integer
...
...
@@ -1157,7 +1162,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsWritten_InParens
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private [|_goo|] As Integer
Public Sub M()
...
...
@@ -1169,7 +1174,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsUnusedInType_SyntaxError
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private [|_goo|] As Integer
Public Sub M()
...
...
@@ -1180,7 +1185,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsUnusedInType_SemanticError
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private [|_goo|] As Integer
Public Sub M()
...
...
@@ -1237,7 +1242,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldIsGeneratedCode
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
<System.CodeDom.Compiler.GeneratedCodeAttribute(
""""
,
""""
)>
Private [|i|] As Integer
...
...
@@ -1249,7 +1254,7 @@ End Class")
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsRemoveUnusedMembers
)
>
Public
Async
Function
FieldUsedInGeneratedCode
()
As
Task
Await
Test
MissingInRegularAndScript
Async
(
Await
Test
DiagnosticMissing
Async
(
"Class C
Private [|i|] As Integer
...
...
src/Features/Core/Portable/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs
浏览文件 @
b1ab1b05
...
...
@@ -194,7 +194,7 @@ private void AnalyzeMemberReferenceOperation(OperationAnalysisContext operationC
compoundAssignment
.
Target
==
memberReference
||
memberReference
.
Parent
is
IIncrementOrDecrementOperation
);
// Compound assignment or increment whose value is being dropped (parent
has null type
)
// Compound assignment or increment whose value is being dropped (parent
is an expression statement
)
// is treated as a Write as the value was never actually 'read' in a way that is observable.
//
// Consider the following example:
...
...
@@ -209,7 +209,7 @@ private void AnalyzeMemberReferenceOperation(OperationAnalysisContext operationC
// while the increment operation '_f2++' is child of a return statement, which uses the result of the increment.
// For the above test, '_f1' can be safely removed without affecting the semantics of the program, while '_f2' cannot be removed.
if
(
memberReference
.
Parent
.
Parent
?.
Type
==
null
)
if
(
memberReference
.
Parent
.
Parent
is
IExpressionStatementOperation
)
{
valueUsageInfo
=
ValueUsageInfo
.
Write
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录