Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4f7d0f1d
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,发现更多精彩内容 >>
提交
4f7d0f1d
编写于
7月 16, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add VB tests.
上级
f7e1805c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
234 addition
and
39 deletion
+234
-39
src/EditorFeatures/VisualBasicTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.vb
...dAccessibilityModifiers/AddAccessibilityModifiersTests.vb
+200
-0
src/Features/VisualBasic/Portable/AddAccessibilityModifiers/VisualBasicAddAccessibilityModifiersDiagnosticAnalyzer.vb
...VisualBasicAddAccessibilityModifiersDiagnosticAnalyzer.vb
+33
-38
src/Workspaces/VisualBasic/Portable/Extensions/StatementSyntaxExtensions.vb
...ualBasic/Portable/Extensions/StatementSyntaxExtensions.vb
+1
-1
未找到文件。
src/EditorFeatures/VisualBasicTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.vb
0 → 100644
浏览文件 @
4f7d0f1d
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports
Microsoft.CodeAnalysis.CodeFixes
Imports
Microsoft.CodeAnalysis.Diagnostics
Imports
Microsoft.CodeAnalysis.VisualBasic.AddAccessibilityModifiers
Imports
Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics
Namespace
Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.AddAccessibilityModifiers
Public
Class
AddAccessibilityModifiersTests
Inherits
AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest
Friend
Overrides
Function
CreateDiagnosticProviderAndFixer
(
workspace
As
Workspace
)
As
(
DiagnosticAnalyzer
,
CodeFixProvider
)
Return
(
New
VisualBasicAddAccessibilityModifiersDiagnosticAnalyzer
(),
New
VisualBasicAddAccessibilityModifiersCodeFixProvider
())
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsAddAccessibilityModifiers
)
>
Public
Async
Function
TestAllConstructs
()
As
Task
Await
TestInRegularAndScriptAsync
(
"
namespace N
namespace Outer.Inner
class {|FixAllInDocument:C|}
class NestedClass
end class
structure NestedStruct
end structure
dim f1 as integer
dim f2, f3 as integer
dim f4, f5 as integer, f6, f7 as boolean
public f4 as integer
event e1 as Action
public event e2 as Action
custom event e4 as Action
end event
shared sub new()
end sub
sub new()
end sub
public sub new(i as integer)
end sub
sub M1()
end sub
public sub M2()
end sub
function M3() as integer
end function
function M4() as integer
public function M5() as integer
end function
property P1 as integer
property P2 as integer
get
end get
end property
public property P3 as integer
shared operator &(c1 as C, c2 as C) as integer
end operator
end class
interface I
event e6 as Action
sub M3()
function M4() as integer
property P3 as integer
end interface
delegate sub D1()
delegate function D2() as integer
enum E
EMember
end enum
structure S
dim f as integer
sub M()
end sub()
shared operator &(c1 as S, c2 as S) as integer
end operator
end structure
module M
dim f as integer
sub M()
end sub()
end module
end namespace
end namespace"
,
"
namespace N
namespace Outer.Inner
Friend class C
Public class NestedClass
end class
Public structure NestedStruct
end structure
Private f1 as integer
Private f2, f3 as integer
Private f4, f5 as integer, f6, f7 as boolean
public f4 as integer
Public event e1 as Action
public event e2 as Action
Public custom event e4 as Action
end event
shared sub new()
end sub
Public sub new()
end sub
public sub new(i as integer)
end sub
Public sub M1()
end sub
public sub M2()
end sub
Public function M3() as integer
end function
Public function M4() as integer
public function M5() as integer
end function
Public property P1 as integer
Public property P2 as integer
get
end get
end property
public property P3 as integer
Public shared operator &(c1 as C, c2 as C) as integer
end operator
end class
Friend interface I
event e6 as Action
sub M3()
function M4() as integer
property P3 as integer
end interface
Friend delegate sub D1()
Friend delegate function D2() as integer
Friend enum E
EMember
end enum
Friend structure S
Public f as integer
Public sub M()
end sub()
Public shared operator &(c1 as S, c2 as S) as integer
end operator
end structure
Friend module M
Private f as integer
Public sub M()
end sub()
end module
end namespace
end namespace"
)
End
Function
End
Class
End
Namespace
src/Features/VisualBasic/Portable/AddAccessibilityModifiers/VisualBasicAddAccessibilityModifiersDiagnosticAnalyzer.vb
浏览文件 @
4f7d0f1d
...
...
@@ -21,60 +21,55 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.AddAccessibilityModifiers
Private
Sub
ProcessMembers
(
context
As
SyntaxTreeAnalysisContext
,
generator
As
SyntaxGenerator
,
[
option
]
As
CodeStyleOption
(
Of
AccessibilityModifiersRequired
),
members
As
SyntaxList
(
Of
StatementSyntax
))
For
Each
member
In
members
ProcessMember
(
context
,
generator
,
[
option
]
,
member
)
Next
End
Sub
For
Each
member
In
members
ProcessMember
(
context
,
generator
,
[
option
]
,
member
)
Next
End
Sub
Private
Sub
ProcessMember
(
context
As
SyntaxTreeAnalysisContext
,
generator
As
SyntaxGenerator
,
Private
Sub
ProcessMember
(
context
As
SyntaxTreeAnalysisContext
,
generator
As
SyntaxGenerator
,
[
option
]
As
CodeStyleOption
(
Of
AccessibilityModifiersRequired
),
member
As
StatementSyntax
)
If
member
.
Kind
()
=
SyntaxKind
.
NamespaceBlock
Then
Dim
namespaceBlock
=
DirectCast
(
member
,
NamespaceBlockSyntax
)
ProcessMembers
(
context
,
generator
,
[
option
]
,
namespaceBlock
.
Members
)
End
If
If
member
.
Kind
()
=
SyntaxKind
.
NamespaceBlock
Then
Dim
namespaceBlock
=
DirectCast
(
member
,
NamespaceBlockSyntax
)
ProcessMembers
(
context
,
generator
,
[
option
]
,
namespaceBlock
.
Members
)
End
If
' If we have a class or struct or module, recurse inwards.
If
member
.
IsKind
(
SyntaxKind
.
ClassBlock
)
OrElse
' If we have a class or struct or module, recurse inwards.
If
member
.
IsKind
(
SyntaxKind
.
ClassBlock
)
OrElse
member
.
IsKind
(
SyntaxKind
.
StructureBlock
)
OrElse
member
.
IsKind
(
SyntaxKind
.
ModuleBlock
)
Then
Dim
typeBlock
=
DirectCast
(
member
,
TypeBlockSyntax
)
ProcessMembers
(
context
,
generator
,
[
option
]
,
typeBlock
.
Members
)
End
If
Dim
declarationStatement
=
TryCast
(
member
,
DeclarationStatementSyntax
)
If
declarationStatement
IsNot
Nothing
Then
Return
End
If
Dim
typeBlock
=
DirectCast
(
member
,
TypeBlockSyntax
)
ProcessMembers
(
context
,
generator
,
[
option
]
,
typeBlock
.
Members
)
End
If
' Have to have a name to report the issue on.
Dim
name
=
declarationStatement
.
GetNameToken
()
If
name
.
Kind
()
=
SyntaxKind
.
None
Then
Return
End
If
' Have to have a name to report the issue on.
Dim
name
=
member
.
GetNameToken
()
If
name
.
Kind
()
=
SyntaxKind
.
None
Then
Return
End
If
' If they already have accessibility, no need to report anything.
Dim
Accessibility
=
generator
.
GetAccessibility
(
member
)
If
Accessibility
<>
Accessibility
.
NotApplicable
Then
Return
End
If
' If they already have accessibility, no need to report anything.
Dim
Accessibility
=
generator
.
GetAccessibility
(
member
)
If
Accessibility
<>
Accessibility
.
NotApplicable
Then
Return
End
If
' Certain members never have accessibility. Don't bother reporting on them.
' Certain members never have accessibility. Don't bother reporting on them.
If
member
.
IsKind
(
SyntaxKind
.
ConstructorBlock
)
AndAlso
If
member
.
IsKind
(
SyntaxKind
.
ConstructorBlock
)
AndAlso
member
.
GetModifiers
().
Any
(
SyntaxKind
.
SharedKeyword
)
Then
Return
End
If
Return
End
If
' Missing accessibility. Report issue to user.
Dim
additionalLocations
=
ImmutableArray
.
Create
(
member
.
GetLocation
())
context
.
ReportDiagnostic
(
Diagnostic
.
Create
(
' Missing accessibility. Report issue to user.
Dim
additionalLocations
=
ImmutableArray
.
Create
(
member
.
GetLocation
())
context
.
ReportDiagnostic
(
Diagnostic
.
Create
(
CreateDescriptorWithSeverity
(
[
option
]
.
Notification
.
Value
),
name
.
GetLocation
(),
additionalLocations
:
=
additionalLocations
))
End
Sub
End
Class
End
Sub
End
Class
End
Namespace
src/Workspaces/VisualBasic/Portable/Extensions/StatementSyntaxExtensions.vb
浏览文件 @
4f7d0f1d
...
...
@@ -303,7 +303,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
End
Function
<
Extension
()
>
Public
Function
GetNameToken
(
member
As
Declaration
StatementSyntax
)
As
SyntaxToken
Public
Function
GetNameToken
(
member
As
StatementSyntax
)
As
SyntaxToken
If
member
IsNot
Nothing
Then
Select
Case
member
.
Kind
Case
SyntaxKind
.
ClassBlock
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录