~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/ICSharpCode.Decompiler/Tests/CustomAttributes/S_CustomAttributeSamples.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
ļ»æ// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
 
3
 
 
4
//$CS
 
5
using System;
 
6
//$CE
 
7
 
 
8
//$$ TargetModule (ignored)
 
9
//[module: CLSCompliantAttribute(false)]
 
10
//$$ ParameterlessAttributeUsage
 
11
namespace ParameterLessAttributeUsage
 
12
{
 
13
        [Flags]
 
14
        public enum EnumWithFlagsAttribute
 
15
        {
 
16
                None = 0
 
17
        }
 
18
}
 
19
//$$ AttributeWithEnumArgument
 
20
namespace AttributeWithEnumArgument
 
21
{
 
22
        [AttributeUsage(AttributeTargets.All)]
 
23
        public class MyAttributeAttribute : Attribute
 
24
        {
 
25
        }
 
26
}
 
27
//$$ AttributeWithEnumExpressionArgument
 
28
namespace AttributeWithEnumExpressionArgument
 
29
{
 
30
        [AttributeUsage(AttributeTargets.Method | AttributeTargets.Interface)]
 
31
        public class MyAttributeAttribute : Attribute
 
32
        {
 
33
        }
 
34
}
 
35
//$$ AttributeWithStringExpressionArgument
 
36
namespace AttributeWithStringExpressionArgument
 
37
{
 
38
        [Obsolete("message")]
 
39
        public class ObsoletedClass
 
40
        {
 
41
        }
 
42
}
 
43
//$$ AttributeWithTypeArgument
 
44
namespace AttributeWithTypeArgument
 
45
{
 
46
        [AttributeUsage(AttributeTargets.All)]
 
47
        public class MyTypeAttribute : Attribute
 
48
        {
 
49
                public MyTypeAttribute(Type t)
 
50
                {
 
51
                }
 
52
        }
 
53
 
 
54
        [MyType(typeof(Attribute))]
 
55
        public class SomeClass
 
56
        {
 
57
        }
 
58
}
 
59
//$$ AppliedToEvent
 
60
namespace AppliedToEvent
 
61
{
 
62
        [AttributeUsage(AttributeTargets.Event)]
 
63
        public class MyAttributeAttribute : Attribute
 
64
        {
 
65
        }
 
66
        public class TestClass
 
67
        {
 
68
                [MyAttribute]
 
69
                public event EventHandler MyEvent;
 
70
        }
 
71
}
 
72
//$$ AppliedToField
 
73
namespace AppliedToField
 
74
{
 
75
        [AttributeUsage(AttributeTargets.Field)]
 
76
        public class MyAttributeAttribute : Attribute
 
77
        {
 
78
        }
 
79
        public class TestClass
 
80
        {
 
81
                [MyAttribute]
 
82
                public int Field;
 
83
        }
 
84
}
 
85
//$$ AppliedToProperty
 
86
namespace AppliedToProperty
 
87
{
 
88
        public class TestClass
 
89
        {
 
90
                [Obsolete("reason")]
 
91
                public int Property
 
92
                {
 
93
                        get
 
94
                        {
 
95
                                return 0;
 
96
                        }
 
97
                }
 
98
        }
 
99
}
 
100
//$$ AppliedToPropertyGet
 
101
namespace AppliedToPropertyGet
 
102
{
 
103
        [AttributeUsage(AttributeTargets.All)]
 
104
        public class MyAttributeAttribute : Attribute
 
105
        {
 
106
        }
 
107
        public class TestClass
 
108
        {
 
109
                public int Property
 
110
                {
 
111
                        [MyAttribute]
 
112
                        get
 
113
                        {
 
114
                                return 0;
 
115
                        }
 
116
                }
 
117
        }
 
118
}
 
119
//$$ AppliedToPropertySet
 
120
namespace AppliedToPropertySet
 
121
{
 
122
        [AttributeUsage(AttributeTargets.All)]
 
123
        public class MyAttributeAttribute : Attribute
 
124
        {
 
125
        }
 
126
        public class TestClass
 
127
        {
 
128
                public int Property
 
129
                {
 
130
                        get
 
131
                        {
 
132
                                return 3;
 
133
                        }
 
134
                        [MyAttribute]
 
135
                        set
 
136
                        {
 
137
                        }
 
138
                }
 
139
        }
 
140
}
 
141
//$$ AppliedToIndexer
 
142
namespace AppliedToIndexer
 
143
{
 
144
        public class TestClass
 
145
        {
 
146
                [Obsolete("reason")]
 
147
                public int this[int i]
 
148
                {
 
149
                        get
 
150
                        {
 
151
                                return 0;
 
152
                        }
 
153
                }
 
154
        }
 
155
}
 
156
//$$ AppliedToDelegate
 
157
[Obsolete("reason")]
 
158
public delegate int AppliedToDelegate();
 
159
//$$ AppliedToMethod
 
160
namespace AppliedToMethod
 
161
{
 
162
        [AttributeUsage(AttributeTargets.Method)]
 
163
        public class MyAttributeAttribute : Attribute
 
164
        {
 
165
        }
 
166
        public class TestClass
 
167
        {
 
168
                [MyAttribute]
 
169
                public void Method()
 
170
                {
 
171
                }
 
172
        }
 
173
}
 
174
//$$ AppliedToInterface
 
175
[Obsolete("reason")]
 
176
public interface AppliedToInterface
 
177
{
 
178
}
 
179
//$$ AppliedToStruct
 
180
[Obsolete("reason")]
 
181
public struct AppliedToStruct
 
182
{
 
183
        public int Field;
 
184
}
 
185
//$$ AppliedToParameter
 
186
namespace AppliedToParameter
 
187
{
 
188
        [AttributeUsage(AttributeTargets.Parameter)]
 
189
        public class MyAttributeAttribute : Attribute
 
190
        {
 
191
        }
 
192
        public class MyClass
 
193
        {
 
194
                public void Method([MyAttribute] int val)
 
195
                {
 
196
                }
 
197
        }
 
198
}
 
199
//$$ NamedInitializerProperty
 
200
namespace NamedInitializerProperty
 
201
{
 
202
        [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
 
203
        public class MyAttributeAttribute : Attribute
 
204
        {
 
205
        }
 
206
}
 
207
//$$ NamedInitializerPropertyString
 
208
namespace NamedInitializerPropertyString
 
209
{
 
210
        [AttributeUsage(AttributeTargets.All)]
 
211
        public class MyAttributeAttribute : Attribute
 
212
        {
 
213
                public string Prop
 
214
                {
 
215
                        get
 
216
                        {
 
217
                                return "";
 
218
                        }
 
219
                        set
 
220
                        {
 
221
                        }
 
222
                }
 
223
        }
 
224
        [MyAttribute(Prop = "value")]
 
225
        public class MyClass
 
226
        {
 
227
        }
 
228
}
 
229
//$$ NamedInitializerPropertyType
 
230
namespace NamedInitializerPropertyType
 
231
{
 
232
        [AttributeUsage(AttributeTargets.All)]
 
233
        public class MyAttributeAttribute : Attribute
 
234
        {
 
235
                public Type Prop
 
236
                {
 
237
                        get
 
238
                        {
 
239
                                return null;
 
240
                        }
 
241
                        set
 
242
                        {
 
243
                        }
 
244
                }
 
245
        }
 
246
        [MyAttribute(Prop = typeof(Enum))]
 
247
        public class MyClass
 
248
        {
 
249
        }
 
250
}
 
251
//$$ NamedInitializerPropertyEnum
 
252
namespace NamedInitializerPropertyEnum
 
253
{
 
254
        [AttributeUsage(AttributeTargets.All)]
 
255
        public class MyAttributeAttribute : Attribute
 
256
        {
 
257
                public AttributeTargets Prop
 
258
                {
 
259
                        get
 
260
                        {
 
261
                                return AttributeTargets.All;
 
262
                        }
 
263
                        set
 
264
                        {
 
265
                        }
 
266
                }
 
267
        }
 
268
        [MyAttribute(Prop = (AttributeTargets.Class | AttributeTargets.Method))]
 
269
        public class MyClass
 
270
        {
 
271
        }
 
272
}
 
273
//$$ NamedInitializerFieldEnum
 
274
namespace NamedInitializerFieldEnum
 
275
{
 
276
        [AttributeUsage(AttributeTargets.All)]
 
277
        public class MyAttributeAttribute : Attribute
 
278
        {
 
279
                public AttributeTargets Field;
 
280
        }
 
281
        [MyAttribute(Field = (AttributeTargets.Class | AttributeTargets.Method))]
 
282
        public class MyClass
 
283
        {
 
284
        }
 
285
}
 
286
//$$ TargetReturn
 
287
namespace TargetReturn
 
288
{
 
289
        [AttributeUsage(AttributeTargets.All)]
 
290
        public class MyAttributeAttribute : Attribute
 
291
        {
 
292
        }
 
293
        public class MyClass
 
294
        {
 
295
                [return: MyAttribute]
 
296
                public int MyMethod()
 
297
                {
 
298
                        return 5;
 
299
                }
 
300
        }
 
301
}
 
302
//$$ TargetPropertyGetReturn
 
303
namespace TargetPropertyGetReturn
 
304
{
 
305
        [AttributeUsage(AttributeTargets.All)]
 
306
        public class MyAttributeAttribute : Attribute
 
307
        {
 
308
        }
 
309
        public class MyClass
 
310
        {
 
311
                public int Prop
 
312
                {
 
313
                        [return: MyAttribute]
 
314
                        get
 
315
                        {
 
316
                                return 3;
 
317
                        }
 
318
                }
 
319
        }
 
320
}
 
321
//$$ TargetPropertySetParam
 
322
namespace TargetPropertySetParam
 
323
{
 
324
        [AttributeUsage(AttributeTargets.All)]
 
325
        public class MyAttributeAttribute : Attribute
 
326
        {
 
327
        }
 
328
        public class MyClass
 
329
        {
 
330
                public int Prop
 
331
                {
 
332
                        [param: MyAttribute]
 
333
                        set
 
334
                        {
 
335
                        }
 
336
                }
 
337
        }
 
338
}
 
339
//$$ TargetPropertySetReturn
 
340
namespace TargetPropertySetReturn
 
341
{
 
342
        [AttributeUsage(AttributeTargets.All)]
 
343
        public class MyAttributeAttribute : Attribute
 
344
        {
 
345
        }
 
346
        public class MyClass
 
347
        {
 
348
                public int Prop
 
349
                {
 
350
                        get
 
351
                        {
 
352
                                return 3;
 
353
                        }
 
354
                        [return: MyAttribute]
 
355
                        set
 
356
                        {
 
357
                        }
 
358
                }
 
359
        }
 
360
}
 
361
//$$ TargetPropertyIndexGetReturn
 
362
namespace TargetPropertyIndexGetReturn
 
363
{
 
364
        [AttributeUsage(AttributeTargets.All)]
 
365
        public class MyAttributeAttribute : Attribute
 
366
        {
 
367
        }
 
368
        public class MyClass
 
369
        {
 
370
                public int this[string s]
 
371
                {
 
372
                        [return: MyAttribute]
 
373
                        get
 
374
                        {
 
375
                                return 3;
 
376
                        }
 
377
                }
 
378
        }
 
379
}
 
380
//$$ TargetPropertyIndexParamOnlySet
 
381
namespace TargetPropertyIndexParamOnlySet
 
382
{
 
383
        [AttributeUsage(AttributeTargets.All)]
 
384
        public class MyAttributeAttribute : Attribute
 
385
        {
 
386
        }
 
387
        public class MyClass
 
388
        {
 
389
                public int this[[MyAttribute] string s]
 
390
                {
 
391
                        set
 
392
                        {
 
393
                        }
 
394
                }
 
395
        }
 
396
}
 
397
//$$ TargetPropertyIndexParamOnlyGet
 
398
namespace TargetPropertyIndexParamOnlyGet
 
399
{
 
400
        [AttributeUsage(AttributeTargets.All)]
 
401
        public class MyAttributeAttribute : Attribute
 
402
        {
 
403
        }
 
404
        public class MyClass
 
405
        {
 
406
                public int this[[MyAttribute] string s]
 
407
                {
 
408
                        get
 
409
                        {
 
410
                                return 3;
 
411
                        }
 
412
                }
 
413
        }
 
414
}
 
415
//$$ TargetPropertyIndexSetReturn
 
416
namespace TargetPropertyIndexSetReturn
 
417
{
 
418
        [AttributeUsage(AttributeTargets.All)]
 
419
        public class MyAttributeAttribute : Attribute
 
420
        {
 
421
        }
 
422
        public class MyClass
 
423
        {
 
424
                public string this[int index]
 
425
                {
 
426
                        get
 
427
                        {
 
428
                                return "";
 
429
                        }
 
430
                        [return: MyAttribute]
 
431
                        set
 
432
                        {
 
433
                        }
 
434
                }
 
435
        }
 
436
}
 
437
//$$ TargetPropertyIndexSetMultiParam
 
438
namespace TargetPropertyIndexSetMultiParam
 
439
{
 
440
        [AttributeUsage(AttributeTargets.All)]
 
441
        public class MyAttributeAttribute : Attribute
 
442
        {
 
443
                public int Field;
 
444
        }
 
445
        public class MyClass
 
446
        {
 
447
                public string this[[MyAttribute(Field = 2)] int index1, [MyAttribute(Field = 3)] int index2]
 
448
                {
 
449
                        get
 
450
                        {
 
451
                                return "";
 
452
                        }
 
453
                        [param: MyAttribute]
 
454
                        set
 
455
                        {
 
456
                        }
 
457
                }
 
458
        }
 
459
}
 
460
//$$ ClassAttributeOnTypeParameter
 
461
namespace ClassAttributeOnTypeParameter
 
462
{
 
463
        [AttributeUsage(AttributeTargets.All)]
 
464
        public class MyAttributeAttribute : Attribute
 
465
        {
 
466
        }
 
467
        public class MyClass<[MyAttribute] T>
 
468
        {
 
469
        }
 
470
}
 
471
//$$ AttributeOnReturnTypeOfDelegate
 
472
namespace AttributeOnReturnTypeOfDelegate
 
473
{
 
474
        [AttributeUsage(AttributeTargets.All)]
 
475
        public class MyAttributeAttribute : Attribute
 
476
        {
 
477
        }
 
478
        [return: MyAttribute]
 
479
        public delegate void Test();
 
480
}