-
Notifications
You must be signed in to change notification settings - Fork 222
/
DebuggerDisplayUsesExistingMembers.vb
224 lines (187 loc) · 9.98 KB
/
DebuggerDisplayUsesExistingMembers.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
Imports System
Imports System.Diagnostics
Public Class TestOnPropertiesAndFields
Const ConstantWithoutInvalidMembers As String = "Something"
Const ConstantWithInvalidMember As String = "{Nonexistent}"
Const ConstantFragment1 As String = "{Non"
Const ConstantFragment2 As String = "Existent}"
Public Property SomeProperty As Integer
Public SomeField As Integer
<DebuggerDisplayAttribute("Hardcoded text")> Property WithSuffix As Integer
<System.Diagnostics.DebuggerDisplay("Hardcoded text")> Property WithNamespace As Integer
<Global.System.Diagnostics.DebuggerDisplay("Hardcoded text")> Property WithGlobal As Integer
<DebuggerDisplay(Nothing)> Property WithEmptyArgList As Integer
<DebuggerDisplay("")> Property WithEmptyFormat As Integer
<DebuggerDisplay(ConstantWithoutInvalidMembers)> Property WithFormatAsConstant1 As Integer
<DebuggerDisplay(NameOf(ConstantWithoutInvalidMembers))> Property WithFormatAsNameOf As Integer
<DebuggerDisplay("{SomeProperty}")> Property WithExistingProperty As Integer
<DebuggerDisplay("{SomeField}")> Property WithExistingField As Integer
<DebuggerDisplay("{SomeField}")> Property WithExistingFieldVerbatim As Integer
<DebuggerDisplay("{1 + 1}")> Property WithNoMemberReferenced1 As Integer
<DebuggerDisplay("{""1"" + ""1""}")> Property WithNoMemberReferenced2 As Integer
<DebuggerDisplay("{Nonexistent}")> Property WithNonexistentMember1 As Integer ' Noncompliant {{'Nonexistent' doesn't exist in this context.}}
' ^^^^^^^^^^^^^^^
<DebuggerDisplay("1 + {Nonexistent}")> Property WithNonexistentMember2 As Integer ' Noncompliant {{'Nonexistent' doesn't exist in this context.}}
' ^^^^^^^^^^^^^^^^^^^
<DebuggerDisplay("{Nonexistent1} bla bla {Nonexistent2}")> Property WithMultipleNonexistent As Integer ' Noncompliant {{'Nonexistent1' doesn't exist in this context.}}
' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<DebuggerDisplay("{Nonexistent}")> Property WithNonexistentMemberVerbatim As Integer ' Noncompliant {{'Nonexistent' doesn't exist in this context.}}
' ^^^^^^^^^^^^^^^
<System.Diagnostics.DebuggerDisplay("{Nonexistent}")> Property WithNamespaceAndNonexistent As Integer ' Noncompliant {{'Nonexistent' doesn't exist in this context.}}
' ^^^^^^^^^^^^^^^
<Global.System.Diagnostics.DebuggerDisplay("{Nonexistent}")> Property WithGlobalAndNonexistent As Integer ' Noncompliant {{'Nonexistent' doesn't exist in this context.}}
' ^^^^^^^^^^^^^^^
<DebuggerDisplay(ConstantWithInvalidMember)> Property WithFormatAsConstant2 As Integer ' FN: constants are not checked
<DebuggerDisplay("{Non" & "Existing}")> Property WithFormatAsConcatenationOfLiterals As Integer ' FN: only simple literal supported
<DebuggerDisplay(ConstantFragment1 & ConstantFragment2)> Property WithFormatAsConcatenationOfConstants As Integer ' FN: only simple literal supported
<DebuggerDisplay("{Me.NonexistentProperty}")> Property PropertyWithExplicitThis As Integer ' FN: "Me." not supported (valid when debugging a VB.NET project)
<DebuggerDisplay("{this.NonexistentField}")> Property FieldWithExplicitThis As Integer ' FN: "this." not supported (valid when debugging a C# project)
<DebuggerDisplay("{1 + NonexistentProperty}")> Property ContainingInvalidMembers As Integer ' FN: expressions not supported
End Class
<DebuggerDisplay("{Me.ToString()}")> ' Compliant, it's a method call in VB.NET syntax (valid when debugging a VB.NET project)
<DebuggerDisplay("{this.ToString()}")> ' Compliant, it's a method call in C# syntax (valid when debugging a C# project)
<DebuggerDisplay("{Nonexistent}")> ' Noncompliant
Public Enum TopLevelEnum
One
Two
Three
End Enum
<DebuggerDisplay("{SomeProperty}")>
<DebuggerDisplay("{SomeField}")>
<DebuggerDisplay("{Nonexistent}")> ' Noncompliant
Public Class TestOnNestedTypes
Public Property SomeProperty As Integer
Public SomeField As Integer
<DebuggerDisplay("{ExistingProperty}")>
<DebuggerDisplay("{ExistingField}")>
<DebuggerDisplay("{SomeProperty}")> ' Noncompliant
<DebuggerDisplay("{SomeField}")> ' Noncompliant
Public Class NestedClass
Property ExistingProperty As Integer
Property ExistingField As Integer
End Class
<DebuggerDisplay("{ExistingProperty}")>
<DebuggerDisplay("{ExistingField}")>
<DebuggerDisplay("{SomeProperty}")> ' Noncompliant
<DebuggerDisplay("{SomeField}")> ' Noncompliant
Public Structure NestedStruct
Property ExistingProperty As Integer
Property ExistingField As Integer
End Structure
Public Enum NestedEnum
One
Two
Three
End Enum
End Class
Class TestOnDelegates
Property ExistingProperty As Integer
<DebuggerDisplay("{ExistingProperty}")> ' Noncompliant
<DebuggerDisplay("{42}")>
Delegate Sub Delegate1()
End Class
Class TestOnIndexers
Public Property ExistingProperty As Integer
Public ExistingField As Integer
<DebuggerDisplay("{ExistingProperty}")>
<DebuggerDisplay("{ExistingField}")>
<DebuggerDisplay("{Nonexistent}")> ' Noncompliant
Default Property Item(ByVal i As Integer) As Integer
Get
Return 1
End Get
Set(value As Integer)
End Set
End Property
End Class
<DebuggerDisplay("{SomeProperty}"), DebuggerDisplay("{SomeField}"), DebuggerDisplay("{Nonexistent}")> ' Noncompliant
Class TestMultipleAttributes
' ^^^^^^^^^^^^^^^@-1
Public Property SomeProperty As Integer
Public SomeField As Integer = 1
<DebuggerDisplay("{SomeProperty}"), DebuggerDisplay("{SomeField}"), DebuggerDisplay("{Nonexistent}")> Property OtherProperty1 As Integer ' Noncompliant
' ^^^^^^^^^^^^^^^
<DebuggerDisplay("{Nonexistent1}"), DebuggerDisplay("{Nonexistent2}")> Property OtherProperty2 As Integer
' ^^^^^^^^^^^^^^^^
' ^^^^^^^^^^^^^^^^@-1
<DebuggerDisplay("{Nonexistent1}")> <DebuggerDisplay("{Nonexistent2}")> Property OtherProperty3 As Integer
' ^^^^^^^^^^^^^^^^
' ^^^^^^^^^^^^^^^^@-1
End Class
Class SupportCaseInsensitivity
Property SomeProperty As Integer = 1
<DebuggerDisplay("{SOMEPROPERTY}")>
<DebuggerDisplay("{SomeProperty}")>
<DebuggerDisplay("{someProperty}")>
<DebuggerDisplay("{someproperty}")>
Property OtherProperty As Integer
End Class
Class SupportNonAlphanumericChars
Property Aa1_뿓 As Integer
<DebuggerDisplay("{Aa1_뿓}")>
<DebuggerDisplay("{Aa1_㤬}")> ' Noncompliant {{'Aa1_㤬' doesn't exist in this context.}}
Property SomeProperty1 As Integer
End Class
Class SupportWhitespaces
<DebuggerDisplay("{ SomeProperty}")>
<DebuggerDisplay("{SomeProperty }")>
<DebuggerDisplay("{" & vbTab & "SomeProperty}")>
<DebuggerDisplay("{" & vbTab & "SomeProperty" & vbTab & "}")>
<DebuggerDisplay("{ Nonexistent}")> ' Noncompliant {{'Nonexistent' doesn't exist in this context.}}
<DebuggerDisplay("{Nonexistent }")> ' Noncompliant {{'Nonexistent' doesn't exist in this context.}}
<DebuggerDisplay("{" & vbTab & "Nonexistent}")> ' FN: string concatenation not supported
<DebuggerDisplay("{" & vbTab & "Nonexistent" & vbTab & "}")> ' FN: string concatenation not supported
Property SomeProperty As Integer
End Class
Class SupportNq
<DebuggerDisplay("{SomeProperty,nq}")>
<DebuggerDisplay("{SomeProperty ,nq}")>
<DebuggerDisplay("{SomeProperty, nq}")>
<DebuggerDisplay("{SomeProperty,nq }")>
<DebuggerDisplay("{Nonexistent,nq}")> ' Noncompliant
<DebuggerDisplay("{Nonexistent ,nq}")> ' Noncompliant
<DebuggerDisplay("{Nonexistent, nq}")> ' Noncompliant
<DebuggerDisplay("{Nonexistent,nq }")> ' Noncompliant
Property SomeProperty As Integer
End Class
Class SupportOptionalAttributeParameter
<DebuggerDisplay("{SomeProperty}", Name:="Any name")>
<DebuggerDisplay("{Nonexistent}", Name:="Any name")> ' Noncompliant
<DebuggerDisplay("{Nonexistent}", Name:="Any name", Type:=NameOf(SupportOptionalAttributeParameter))> ' Noncompliant
<DebuggerDisplay("{Nonexistent}", Name:="Any name", Target:=GetType(SupportOptionalAttributeParameter))> ' Noncompliant
Property SomeProperty As Integer
' ^^^^^^^^^^^^^^^@-3
' ^^^^^^^^^^^^^^^@-3
' ^^^^^^^^^^^^^^^@-3
End Class
Class SupportInheritance
Class BaseClass
Property SomeProperty As Integer
End Class
Class SubClass
Inherits BaseClass
<DebuggerDisplay("{SomeProperty}")> ' Compliant, defined in base class
Property OtherProperty As Integer
End Class
End Class
Class SupportAccessModifiers
Class BaseClass
Public Property PublicProperty As Integer
Friend Property InternalProperty As Integer
Protected Property ProtectedProperty As Integer
Private Property PrivateProperty As Integer
<DebuggerDisplay("{PublicProperty}")>
<DebuggerDisplay("{InternalProperty}")>
<DebuggerDisplay("{ProtectedProperty}")>
<DebuggerDisplay("{PrivateProperty}")>
Property SomeProperty As Integer
End Class
Class SubClass
Inherits BaseClass
<DebuggerDisplay("{PublicProperty}")>
<DebuggerDisplay("{InternalProperty}")>
<DebuggerDisplay("{ProtectedProperty}")>
<DebuggerDisplay("{PrivateProperty}")>
Property OtherProperty As Integer
End Class
End Class