Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1115b7f8
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,发现更多精彩内容 >>
提交
1115b7f8
编写于
3月 31, 2020
作者:
D
David Poeschl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup
上级
f20df757
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
27 deletion
+23
-27
src/Workspaces/VisualBasic/Portable/Recommendations/VisualBasicRecommendationServiceRunner.vb
...Recommendations/VisualBasicRecommendationServiceRunner.vb
+23
-27
未找到文件。
src/Workspaces/VisualBasic/Portable/Recommendations/VisualBasicRecommendationServiceRunner.vb
浏览文件 @
1115b7f8
...
...
@@ -70,17 +70,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
Return
False
End
Function
Private
Sub
X
(
foo
As
Action
(
Of
Integer
))
End
Sub
Private
Function
IsWritableFieldOrLocal
(
symbol
As
ISymbol
)
As
Boolean
If
symbol
.
Kind
()
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Field
Then
If
symbol
.
Kind
()
=
SymbolKind
.
Field
Then
Dim
field
=
DirectCast
(
symbol
,
IFieldSymbol
)
Return
Not
field
.
IsReadOnly
AndAlso
Not
field
.
IsConst
End
If
If
symbol
.
Kind
()
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Local
Then
If
symbol
.
Kind
()
=
SymbolKind
.
Local
Then
Dim
local
=
DirectCast
(
symbol
,
ILocalSymbol
)
Return
Not
local
.
IsConst
End
If
...
...
@@ -111,7 +107,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
Return
_context
.
SemanticModel
_
.
LookupSymbols
(
_context
.
Position
,
container
:
=
containingType
)
_
.
WhereAsArray
(
Function
(
s
)
s
.
Kind
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Event
AndAlso
Equals
(
s
.
ContainingType
,
containingType
))
.
WhereAsArray
(
Function
(
s
)
s
.
Kind
=
SymbolKind
.
Event
AndAlso
Equals
(
s
.
ContainingType
,
containingType
))
End
Function
Private
Function
GetUnqualifiedSymbolsForType
()
As
ImmutableArray
(
Of
ISymbol
)
...
...
@@ -264,7 +260,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
excludeInstance
=
False
End
If
If
container
Is
Nothing
OrElse
container
.
IsType
AndAlso
DirectCast
(
container
,
Global
.
Microsoft
.
CodeAnalysis
.
ITypeSymbol
).
TypeKind
=
Global
.
Microsoft
.
CodeAnalysis
.
TypeKind
.
Enum
Then
If
container
Is
Nothing
OrElse
container
.
IsType
AndAlso
DirectCast
(
container
,
ITypeSymbol
).
TypeKind
=
TypeKind
.
Enum
Then
excludeShared
=
False
' need to allow shared members for enums
End
If
...
...
@@ -283,7 +279,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
If
_context
.
TargetToken
.
GetPreviousToken
().
IsKind
(
SyntaxKind
.
QuestionToken
)
Then
Dim
type
=
TryCast
(
container
,
INamedTypeSymbol
)
If
type
?
.
ConstructedFrom
.
SpecialType
=
Global
.
Microsoft
.
CodeAnalysis
.
SpecialType
.
System_Nullable_T
Then
If
type
?
.
ConstructedFrom
.
SpecialType
=
SpecialType
.
System_Nullable_T
Then
container
=
type
.
GetTypeArguments
().
First
()
End
If
End
If
...
...
@@ -326,7 +322,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
If
leftHandSymbolInfo
.
Symbol
IsNot
Nothing
AndAlso
leftHandSymbolInfo
.
Symbol
.
IsMyFormsProperty
(
_context
.
SemanticModel
.
Compilation
)
Then
symbols
=
symbols
.
WhereAsArray
(
Function
(
s
)
s
.
Kind
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Property
)
symbols
=
symbols
.
WhereAsArray
(
Function
(
s
)
s
.
Kind
=
SymbolKind
.
Property
)
End
If
' Also filter out operators
...
...
@@ -350,14 +346,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
''' Also, filter out any implicitly declared members generated by event declaration or property declaration
''' </summary>
Private
Shared
Function
FilterEventsAndGeneratedSymbols
(
node
As
MemberAccessExpressionSyntax
,
s
As
ISymbol
)
As
Boolean
If
s
.
Kind
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Event
Then
If
s
.
Kind
=
SymbolKind
.
Event
Then
Return
node
IsNot
Nothing
AndAlso
node
.
GetAncestor
(
Of
AddRemoveHandlerStatementSyntax
)
IsNot
Nothing
ElseIf
s
.
Kind
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Field
AndAlso
s
.
IsImplicitlyDeclared
Then
ElseIf
s
.
Kind
=
SymbolKind
.
Field
AndAlso
s
.
IsImplicitlyDeclared
Then
Dim
associatedSymbol
=
DirectCast
(
s
,
IFieldSymbol
).
AssociatedSymbol
If
associatedSymbol
IsNot
Nothing
Then
Return
associatedSymbol
.
Kind
<>
SymbolKind
.
Event
AndAlso
associatedSymbol
.
Kind
<>
SymbolKind
.
Property
End
If
ElseIf
s
.
Kind
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
NamedType
AndAlso
s
.
IsImplicitlyDeclared
Then
ElseIf
s
.
Kind
=
SymbolKind
.
NamedType
AndAlso
s
.
IsImplicitlyDeclared
Then
Return
Not
TypeOf
DirectCast
(
s
,
INamedTypeSymbol
).
AssociatedSymbol
Is
IEventSymbol
End
If
Return
True
...
...
@@ -368,7 +364,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
While
symbol
IsNot
Nothing
Dim
method
=
TryCast
(
symbol
,
IMethodSymbol
)
If
method
IsNot
Nothing
AndAlso
method
.
MethodKind
=
Global
.
Microsoft
.
CodeAnalysis
.
MethodKind
.
Constructor
Then
If
method
IsNot
Nothing
AndAlso
method
.
MethodKind
=
MethodKind
.
Constructor
Then
Return
method
End
If
End
While
...
...
@@ -390,7 +386,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
typeOrAssemblySymbol
=
_context
.
SemanticModel
.
Compilation
.
Assembly
End
If
Dim
isInterface
=
TryCast
(
typeOrAssemblySymbol
,
Global
.
Microsoft
.
CodeAnalysis
.
ITypeSymbol
)
?
.
TypeKind
=
Global
.
Microsoft
.
CodeAnalysis
.
TypeKind
.
Interface
Dim
isInterface
=
TryCast
(
typeOrAssemblySymbol
,
ITypeSymbol
)
?
.
TypeKind
=
TypeKind
.
Interface
If
inheritsContext
Then
...
...
@@ -435,7 +431,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
End
Function
Private
Function
IsValidAccessibleInterfaceOrContainer
(
symbol
As
ISymbol
,
within
As
ISymbol
)
As
Boolean
If
symbol
.
Kind
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Alias
Then
If
symbol
.
Kind
=
SymbolKind
.
Alias
Then
symbol
=
DirectCast
(
symbol
,
IAliasSymbol
).
Target
End
If
...
...
@@ -449,14 +445,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
Return
False
End
If
Return
namedTypeSymbol
.
TypeKind
=
Global
.
Microsoft
.
CodeAnalysis
.
TypeKind
.
Interface
OrElse
namedTypeSymbol
_
Return
namedTypeSymbol
.
TypeKind
=
TypeKind
.
Interface
OrElse
namedTypeSymbol
_
.
GetAccessibleMembersInThisAndBaseTypes
(
Of
INamedTypeSymbol
)(
within
)
_
.
Any
(
Function
(
m
)
IsOrContainsValidAccessibleInterface
(
m
,
within
))
End
Function
Private
Function
IsOrContainsValidAccessibleInterface
(
namespaceOrTypeSymbol
As
INamespaceOrTypeSymbol
,
within
As
ISymbol
)
As
Boolean
If
namespaceOrTypeSymbol
.
Kind
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Namespace
Then
If
namespaceOrTypeSymbol
.
Kind
=
SymbolKind
.
Namespace
Then
Return
IsValidAccessibleInterfaceOrContainer
(
namespaceOrTypeSymbol
,
within
)
End
If
...
...
@@ -465,7 +461,7 @@ namedTypeSymbol _
Return
False
End
If
If
namedTypeSymbol
.
TypeKind
=
Global
.
Microsoft
.
CodeAnalysis
.
TypeKind
.
Interface
Then
If
namedTypeSymbol
.
TypeKind
=
TypeKind
.
Interface
Then
Return
True
End
If
...
...
@@ -476,20 +472,20 @@ namedTypeSymbol _
End
Function
Private
Function
IsValidAccessibleClassOrContainer
(
symbol
As
ISymbol
,
within
As
ISymbol
)
As
Boolean
If
symbol
.
Kind
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Alias
Then
If
symbol
.
Kind
=
SymbolKind
.
Alias
Then
symbol
=
DirectCast
(
symbol
,
IAliasSymbol
).
Target
End
If
Dim
type
=
TryCast
(
symbol
,
ITypeSymbol
)
If
type
IsNot
Nothing
Then
If
type
.
TypeKind
=
Global
.
Microsoft
.
CodeAnalysis
.
TypeKind
.
Class
AndAlso
Not
type
.
IsSealed
AndAlso
Not
Equals
(
type
,
within
)
Then
If
type
.
TypeKind
=
TypeKind
.
Class
AndAlso
Not
type
.
IsSealed
AndAlso
Not
Equals
(
type
,
within
)
Then
Return
True
End
If
If
type
.
TypeKind
=
Global
.
Microsoft
.
CodeAnalysis
.
TypeKind
.
Class
OrElse
type
.
TypeKind
=
Global
.
Microsoft
.
CodeAnalysis
.
TypeKind
.
Module
OrElse
type
.
TypeKind
=
Global
.
Microsoft
.
CodeAnalysis
.
TypeKind
.
Struct
Then
If
type
.
TypeKind
=
TypeKind
.
Class
OrElse
type
.
TypeKind
=
TypeKind
.
Module
OrElse
type
.
TypeKind
=
TypeKind
.
Struct
Then
Return
type
.
GetAccessibleMembersInThisAndBaseTypes
(
Of
INamedTypeSymbol
)(
within
).
Any
(
Function
(
m
)
IsOrContainsValidAccessibleClass
(
m
,
within
))
End
If
...
...
@@ -504,7 +500,7 @@ namedTypeSymbol _
End
Function
Private
Function
IsOrContainsValidAccessibleClass
(
namespaceOrTypeSymbol
As
INamespaceOrTypeSymbol
,
within
As
ISymbol
)
As
Boolean
If
namespaceOrTypeSymbol
.
Kind
=
Global
.
Microsoft
.
CodeAnalysis
.
SymbolKind
.
Namespace
Then
If
namespaceOrTypeSymbol
.
Kind
=
SymbolKind
.
Namespace
Then
Return
IsValidAccessibleClassOrContainer
(
namespaceOrTypeSymbol
,
within
)
End
If
...
...
@@ -513,7 +509,7 @@ namedTypeSymbol _
Return
False
End
If
If
namedTypeSymbol
.
TypeKind
=
Global
.
Microsoft
.
CodeAnalysis
.
TypeKind
.
Class
AndAlso
Not
namedTypeSymbol
.
IsSealed
AndAlso
Not
Equals
(
namedTypeSymbol
,
within
)
Then
If
namedTypeSymbol
.
TypeKind
=
TypeKind
.
Class
AndAlso
Not
namedTypeSymbol
.
IsSealed
AndAlso
Not
Equals
(
namedTypeSymbol
,
within
)
Then
Return
True
End
If
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录