/Test/Resources/cs/CustomAttributes.cs

http://github.com/jbevain/cecil · C# · 162 lines · 107 code · 38 blank · 17 comment · 0 complexity · b2a0e454dc765cb2c5e3da8d60c0a3bd MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. [assembly: Foo ("bingo")]
  5. [assembly: TypeForwardedTo (typeof (System.Diagnostics.DebuggableAttribute))]
  6. enum Bingo : short {
  7. Fuel = 2,
  8. Binga = 4,
  9. }
  10. /*
  11. in System.Security.AccessControl
  12. [Flags]
  13. public enum AceFlags : byte {
  14. None = 0,
  15. ObjectInherit = 0x01,
  16. ContainerInherit = 0x02,
  17. NoPropagateInherit = 0x04,
  18. InheritOnly = 0x08,
  19. InheritanceFlags = ObjectInherit | ContainerInherit | NoPropagateInherit | InheritOnly,
  20. Inherited = 0x10,
  21. SuccessfulAccess = 0x40,
  22. FailedAccess = 0x80,
  23. AuditFlags = SuccessfulAccess | FailedAccess,
  24. }
  25. */
  26. class FooAttribute : Attribute {
  27. internal class Token {
  28. }
  29. public FooAttribute ()
  30. {
  31. }
  32. public FooAttribute (string str)
  33. {
  34. }
  35. public FooAttribute (sbyte a, byte b, bool c, bool d, ushort e, short f, char g)
  36. {
  37. }
  38. public FooAttribute (int a, uint b, float c, long d, ulong e, double f)
  39. {
  40. }
  41. public FooAttribute (char [] chars)
  42. {
  43. }
  44. public FooAttribute (object a, object b)
  45. {
  46. }
  47. public FooAttribute (Bingo bingo)
  48. {
  49. }
  50. public FooAttribute (System.Security.AccessControl.AceFlags flags)
  51. {
  52. }
  53. public FooAttribute (Type type)
  54. {
  55. }
  56. public int Bang { get { return 0; } set {} }
  57. public string Fiou { get { return "fiou"; } set {} }
  58. public object Pan;
  59. public string [] PanPan;
  60. public Type Chose;
  61. }
  62. [Foo ("bar")]
  63. class Hamster {
  64. }
  65. [Foo ((string) null)]
  66. class Dentist {
  67. }
  68. [Foo (-12, 242, true, false, 4242, -1983, 'c')]
  69. class Steven {
  70. }
  71. [Foo (-100000, 200000, 12.12f, long.MaxValue, ulong.MaxValue, 64.646464)]
  72. class Seagull {
  73. }
  74. [Foo (new char [] { 'c', 'e', 'c', 'i', 'l' })]
  75. class Rifle {
  76. }
  77. [Foo ("2", 2)]
  78. class Worm {
  79. }
  80. [Foo (new object [] { "2", 2, 'c' }, new object [] { new object [] { 1, 2, 3}, null })]
  81. class Sheep {
  82. }
  83. [Foo (Bang = 42, PanPan = new string [] { "yo", "yo" }, Pan = new object [] { 1, "2", '3' }, Fiou = null)]
  84. class Angola {
  85. }
  86. [Foo (Pan = "fiouuu")]
  87. class BoxedStringField {
  88. }
  89. [Foo (Bingo.Fuel)]
  90. class Zero {
  91. }
  92. [Foo (System.Security.AccessControl.AceFlags.NoPropagateInherit)]
  93. class Ace {
  94. }
  95. [Foo (new object [] { Bingo.Fuel, Bingo.Binga }, null, Pan = System.Security.AccessControl.AceFlags.NoPropagateInherit)]
  96. class Bzzz {
  97. }
  98. [Foo (typeof (Bingo))]
  99. class Typed {
  100. }
  101. [Foo (typeof (FooAttribute.Token))]
  102. class NestedTyped {
  103. }
  104. [Foo (Chose = typeof (Typed))]
  105. class Truc {
  106. }
  107. [Foo (Chose = (Type) null)]
  108. class Machin {
  109. }
  110. [Foo (typeof (Dictionary<,>))]
  111. class OpenGeneric<X, Y> {
  112. }
  113. [Foo (typeof (Dictionary<string, OpenGeneric<Machin, int>[,]>))]
  114. class ClosedGeneric {
  115. }
  116. [Foo (typeof (Parent.Child[]))]
  117. class Parent {
  118. public class Child {
  119. }
  120. }
  121. [Foo ("Foo\0Bar\0")]
  122. class NullCharInString {
  123. }