1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System;
6 using System.Collections;
7 using System.Collections.Generic;
8 using System.Runtime.CompilerServices;
9 
10 #pragma warning disable 414
11 #pragma warning disable 67
12 #pragma warning disable 3009
13 #pragma warning disable 3016
14 #pragma warning disable 3001
15 #pragma warning disable 3015
16 #pragma warning disable 169
17 #pragma warning disable 649
18 
19 [assembly: SampleMetadata.SimpleStringCa("assembly")]
20 
21 public class SimpleTopLevelClass
22 {
MethodWithDefaultParamValue(int a1 = 32)23     public void MethodWithDefaultParamValue(int a1 = 32)
24     {
25     }
26 }
27 
28 namespace SampleMetadata
29 {
30     public class Outer
31     {
32         public class Inner
33         {
34             public class ReallyInner
35             {
36             }
37         }
38     }
39 
40     public class Outer2
41     {
42         public class Inner2
43         {
44             protected class ProtectedInner
45             {
46             }
47 
48             internal class InternalInner
49             {
50             }
51 
52             private class PrivateInner
53             {
54             }
55         }
56 
57         private class PrivateInner2
58         {
59             public class ReallyInner2
60             {
61             }
62         }
63     }
64 
65     internal class Hidden
66     {
67         public class PublicInsideHidden
68         {
69         }
70     }
71 
72     public class SimpleGenericType<T>
73     {
74     }
75 
76     [SimpleStringCa("type")]
77     public class GenericTypeWithThreeParameters<X, Y, Z>
78     {
GenericTypeWithThreeParameters(int x)79         public GenericTypeWithThreeParameters(int x)
80         {
81         }
82 
83         [SimpleStringCa("ctor")]
GenericTypeWithThreeParameters(String s)84         private GenericTypeWithThreeParameters(String s)
85         {
86         }
87 
88         [return: SimpleStringCa("return")]
SimpleMethod()89         public void SimpleMethod()
90         {
91         }
92 
93         [SimpleStringCa("method")]
SimpleGenericMethod(X arg1, N arg2)94         public M SimpleGenericMethod<M, N>(X arg1, N arg2)
95         {
96             throw null;
97         }
98 
99         public X SimpleReadOnlyProperty { get { throw null; } }
100 
101         [SimpleStringCa("property")]
102         public Y SimpleMutableProperty
103         {
104             get
105             {
106                 throw null;
107             }
108             [SimpleStringCa("setter")]
109             set
110             {
111                 throw null;
112             }
113         }
114 
115         [IndexerName("SimpleIndexedProperty")]
116         public X this[int i1, Y i2] { get { throw null; } }
117 
118         public int MyField1;
119 
120         [SimpleStringCa("field")]
121         public static String MyField2;
122 
123         private double MyField3 = 0.0;
124 
125         [SimpleStringCa("event")]
126         public event Action SimpleEvent
127         {
128             add
129             {
130                 throw null;
131             }
132 
133             remove
134             {
135                 throw null;
136             }
137         }
138 
139         [SimpleStringCa("nestedtype")]
140         public class InnerType
141         {
142         }
143 
144         public class InnerGenericType<W>
145         {
146         }
147 
GenericTypeWithThreeParameters()148         static GenericTypeWithThreeParameters()
149         {
150         }
151     }
152 
153     public class Derived : SampleMetadata.Extra.Deep.BaseContainer.SubmergedBaseClass
154     {
155     }
156 
157     public interface IFoo
158     {
159     }
160 
161     public interface IBar
162     {
163     }
164 
165     public interface IComplex : IFoo, IBar, IList, IEnumerable
166     {
167     }
168 
169     public class CFoo : IFoo
170     {
171     }
172 
173     public class GenericTypeWithConstraints<A, B, C, D, E, F, G, H, AA, BB, CC, DD, EE, FF, GG, HH>
174         where B : CFoo, IList
175         where C : IList
176         where D : struct
177         where E : class
178         where F : new()
179         where G : class, new()
180         where H : IList, new()
181         where AA : A
182         where BB : B
183         where CC : C
184         // where DD : D // cannot use a "struct"-constrainted generic parameter as a constraint.
185         where EE : E
186         where FF : F
187         where GG : G
188         where HH : H
189     {
190     }
191 
192     public struct SimpleStruct
193     {
194     }
195 
196     public struct SimpleGenericStruct<T>
197     {
198     }
199 
200     public interface ISimpleGenericInterface<T>
201     {
202     }
203 
204     public class MethodContainer<T>
205     {
Moo(int i, T g, String[] s, IEnumerable<String> e, ref double d, out Object o)206         public String Moo(int i, T g, String[] s, IEnumerable<String> e, ref double d, out Object o)
207         {
208             throw null;
209         }
210 
211         [IndexerName("SimpleIndexedSetterOnlyProperty")]
212         public int this[String i1, T i2] { set { throw null; } }
213     }
214 
215     public enum SimpleEnum
216     {
217         Red = 1,
218         Blue = 2,
219         Green = 3,
220         Green_a = 3,
221         Green_b = 3,
222     }
223 
224     public enum ByteEnum : byte
225     {
226         Min = 0,
227         One = 1,
228         Two = 2,
229         Max = 0xff,
230     }
231 
232     public enum SByteEnum : sbyte
233     {
234         Min = -128,
235         One = 1,
236         Two = 2,
237         Max = 127,
238     }
239 
240     public enum UInt16Enum : ushort
241     {
242         Min = 0,
243         One = 1,
244         Two = 2,
245         Max = 0xffff,
246     }
247 
248     public enum Int16Enum : short
249     {
250         Min = unchecked((short)0x8000),
251         One = 1,
252         Two = 2,
253         Max = 0x7fff,
254     }
255 
256     public enum UInt32Enum : uint
257     {
258         Min = 0,
259         One = 1,
260         Two = 2,
261         Max = 0xffffffff,
262     }
263 
264     public enum Int32Enum : int
265     {
266         Min = unchecked((int)0x80000000),
267         One = 1,
268         Two = 2,
269         Max = 0x7fffffff,
270     }
271 
272     public enum UInt64Enum : ulong
273     {
274         Min = 0,
275         One = 1,
276         Two = 2,
277         Max = 0xffffffffffffffff,
278     }
279 
280     public enum Int64Enum : long
281     {
282         Min = unchecked((long)0x8000000000000000L),
283         One = 1,
284         Two = 2,
285         Max = 0x7fffffffffffffff,
286     }
287 
288     public class SimpleCaAttribute : Attribute
289     {
SimpleCaAttribute()290         public SimpleCaAttribute()
291         {
292         }
293     }
294 
295     public class SimpleStringCaAttribute : Attribute
296     {
SimpleStringCaAttribute(String s)297         public SimpleStringCaAttribute(String s)
298         {
299         }
300     }
301 
302     public class SimpleCaWithBigCtorAttribute : Attribute
303     {
SimpleCaWithBigCtorAttribute(bool b, char c, float f, double d, sbyte sb, short sh, int i, long l, byte by, ushort us, uint ui, ulong ul, String s, Type t)304         public SimpleCaWithBigCtorAttribute(bool b, char c, float f, double d, sbyte sb, short sh, int i, long l, byte by, ushort us, uint ui, ulong ul, String s, Type t)
305         {
306         }
307     }
308 
309     public class SimpleArrayCaAttribute : Attribute
310     {
SimpleArrayCaAttribute(bool[] b)311         public SimpleArrayCaAttribute(bool[] b) { }
SimpleArrayCaAttribute(char[] b)312         public SimpleArrayCaAttribute(char[] b) { }
SimpleArrayCaAttribute(float[] b)313         public SimpleArrayCaAttribute(float[] b) { }
SimpleArrayCaAttribute(double[] b)314         public SimpleArrayCaAttribute(double[] b) { }
SimpleArrayCaAttribute(sbyte[] b)315         public SimpleArrayCaAttribute(sbyte[] b) { }
SimpleArrayCaAttribute(short[] b)316         public SimpleArrayCaAttribute(short[] b) { }
SimpleArrayCaAttribute(int[] b)317         public SimpleArrayCaAttribute(int[] b) { }
SimpleArrayCaAttribute(long[] b)318         public SimpleArrayCaAttribute(long[] b) { }
SimpleArrayCaAttribute(byte[] b)319         public SimpleArrayCaAttribute(byte[] b) { }
SimpleArrayCaAttribute(ushort[] b)320         public SimpleArrayCaAttribute(ushort[] b) { }
SimpleArrayCaAttribute(uint[] b)321         public SimpleArrayCaAttribute(uint[] b) { }
SimpleArrayCaAttribute(ulong[] b)322         public SimpleArrayCaAttribute(ulong[] b) { }
SimpleArrayCaAttribute(String[] b)323         public SimpleArrayCaAttribute(String[] b) { }
SimpleArrayCaAttribute(Type[] b)324         public SimpleArrayCaAttribute(Type[] b) { }
325     }
326 
327     public class SimpleObjectArrayCaAttribute : Attribute
328     {
SimpleObjectArrayCaAttribute(object[] o)329         public SimpleObjectArrayCaAttribute(object[] o) { }
330     }
331 
332     public class SimpleEnumCaAttribute : Attribute
333     {
SimpleEnumCaAttribute(SimpleEnum e)334         public SimpleEnumCaAttribute(SimpleEnum e) { }
SimpleEnumCaAttribute(SimpleEnum[] e)335         public SimpleEnumCaAttribute(SimpleEnum[] e) { }
336     }
337 
338     public class AnnoyingSpecialCaseAttribute : Attribute
339     {
AnnoyingSpecialCaseAttribute(Object o)340         public AnnoyingSpecialCaseAttribute(Object o)
341         {
342         }
343 
344         public Object Oops;
345     }
346 
347     public class SimpleCaWithNamedParametersAttribute : Attribute
348     {
SimpleCaWithNamedParametersAttribute(int i, String s)349         public SimpleCaWithNamedParametersAttribute(int i, String s)
350         {
351         }
352 
353         public double DParameter;
354 
355         public Type TParameter { get; set; }
356     }
357 
358     [SimpleCaWithBigCtor(true, 'c', (float)1.5f, 1.5, (sbyte)(-2), (short)(-2), (int)(-2), (long)(-2), (byte)0xfe, (ushort)0xfedc, (uint)0xfedcba98, (ulong)0xfedcba9876543210, "Hello", typeof(IEnumerable<String>))]
359     public class CaHolder
360     {
361         [AnnoyingSpecialCase(SimpleEnum.Blue, Oops = SimpleEnum.Red)]
362         public class ObjectCa { }
363 
364         [SimpleObjectArrayCa(new object[] { SimpleEnum.Red, 123 })]
365         public class ObjectArrayCa { }
366 
367         [SimpleEnumCa(SimpleEnum.Green)]
368         public class EnumCa { }
369 
370         [SimpleEnumCa(new SimpleEnum[] { SimpleEnum.Green, SimpleEnum.Red })]
371         public class EnumArray { }
372 
373         [SimpleCaWithNamedParameters(42, "Yo", DParameter = 2.3, TParameter = typeof(IList<String>))]
374         public class Named { }
375 
376         [SimpleArrayCa(new bool[] { true, false, true, true, false, false, false, true })]
377         public class BoolArray { }
378 
379         [SimpleArrayCa(new char[] { 'a', 'b', 'c', 'd', 'e' })]
380         public class CharArray { }
381 
382         [SimpleArrayCa(new byte[] { 1, 2, 0xfe, 0xff })]
383         public class ByteArray { }
384 
385         [SimpleArrayCa(new sbyte[] { 1, 2, -2, -1 })]
386         public class SByteArray { }
387 
388         [SimpleArrayCa(new ushort[] { 1, 2, 0xfedc })]
389         public class UShortArray { }
390 
391         [SimpleArrayCa(new short[] { 1, 2, -2, -1 })]
392         public class ShortArray { }
393 
394         [SimpleArrayCa(new uint[] { 1, 2, 0xfedcba98 })]
395         public class UIntArray { }
396 
397         [SimpleArrayCa(new int[] { 1, 2, -2, -1 })]
398         public class IntArray { }
399 
400         [SimpleArrayCa(new ulong[] { 1, 2, 0xfedcba9876543210 })]
401         public class ULongArray { }
402 
403         [SimpleArrayCa(new long[] { 1, 2, -2, -1 })]
404         public class LongArray { }
405 
406         [SimpleArrayCa(new float[] { 1.2f, 3.5f })]
407         public class FloatArray { }
408 
409         [SimpleArrayCa(new double[] { 1.2, 3.5 })]
410         public class DoubleArray { }
411 
412         [SimpleArrayCa(new String[] { "Hello", "There" })]
413         public class StringArray { }
414 
415         [SimpleArrayCa(new Type[] { typeof(Object), typeof(String), null })]
416         public class TypeArray { }
417     }
418 
419     public class DefaultValueHolder
420     {
LotsaDefaults( bool b = true, char c = B, sbyte sb = -2, byte by = 0xfe, short sh = -2, ushort ush = 0xfedc, int i = -2, uint ui = 0xfedcba98, long l = -2, ulong ul = 0xfedcba9876543210, float f = 1.5f, double d = 1.5, String s = R, String sn = null, Object o = null, SimpleEnum e = SimpleEnum.Blue )421         public static void LotsaDefaults(
422             bool b = true,
423             char c = 'a',
424             sbyte sb = -2,
425             byte by = 0xfe,
426             short sh = -2,
427             ushort ush = 0xfedc,
428             int i = -2,
429             uint ui = 0xfedcba98,
430             long l = -2,
431             ulong ul = 0xfedcba9876543210,
432             float f = 1.5f,
433             double d = 1.5,
434             String s = "Hello",
435             String sn = null,
436             Object o = null,
437             SimpleEnum e = SimpleEnum.Blue
438             )
439         {
440         }
441     }
442 
443     public class SimpleIntCustomAttributeAttribute : Attribute
444     {
SimpleIntCustomAttributeAttribute(int a1)445         public SimpleIntCustomAttributeAttribute(int a1)
446         {
447         }
448     }
449 
450     [SimpleIntCustomAttribute(32)]
451     public class SimpleTypeWithCustomAttribute
452     {
453         [SimpleIntCustomAttribute(64)]
SimpleMethodWithCustomAttribute()454         public void SimpleMethodWithCustomAttribute()
455         {
456         }
457     }
458 
459     public interface IMethodImplTest
460     {
MethodImplFunc()461         void MethodImplFunc();
462     }
463 
464     public class MethodImplTest : IMethodImplTest
465     {
IMethodImplTest.MethodImplFunc()466         void IMethodImplTest.MethodImplFunc()
467         {
468         }
469     }
470 
471     public class GenericOutside<S>
472     {
473         public class Inside
474         {
475             public class ReallyInside<I>
476             {
477                 public S TypeS_Field;
478                 public I TypeI_Field;
479 
480                 public class Really2Inside
481                 {
482                     public class Really3Inside<D>
483                     {
484                         public class Really4Inside<O>
485                         {
486                             public GenericTypeWithThreeParameters<S, I, D> TypeSID_Field;
487                             public GenericTypeWithThreeParameters<S, I, O> TypeSIO_Field;
488                         }
489                     }
490                 }
491             }
492         }
493     }
494 
495     public class NonGenericOutside
496     {
497         public class GenericInside<T>
498         {
499         }
500     }
501 
502     public static class SimpleStaticClass
503     {
504         public class NestedInsideSimpleStatic
505         {
506         }
507 
Foo(int x)508         public static void Foo(int x)
509         {
510         }
511     }
512 
513     public static class SimpleGenericStaticClass<T>
514     {
515         public class NestedInsideSimpleStatic
516         {
517         }
518 
Foo(T x)519         public static void Foo(T x)
520         {
521         }
522     }
523 }
524 
525 namespace SampleMetadata.Extra.Deep
526 {
527     public class BaseContainer
528     {
529         [SimpleStringCa("base")]
530         public class SubmergedBaseClass
531         {
532         }
533     }
534 }
535 
536 namespace SampleMetadata
537 {
538     // Create two types with the exact same shape. Ensure that MdTranform and Reflection can
539     // distinguish the members.
540 
541     public class DoppleGanger1
542     {
DoppleGanger1()543         public DoppleGanger1()
544         {
545         }
546 
Moo()547         public void Moo()
548         {
549         }
550 
551         public int Field;
552 
553         public int Prop { get; set; }
554 
555         public event Action Event
556         {
557             add
558             {
559                 throw null;
560             }
561 
562             remove
563             {
564                 throw null;
565             }
566         }
567 
568         public class NestedType
569         {
570         }
571     }
572 
573     public class DoppleGanger2
574     {
DoppleGanger2()575         public DoppleGanger2()
576         {
577         }
578 
Moo()579         public void Moo()
580         {
581         }
582 
583         public int Field;
584 
585         public int Prop { get; set; }
586 
587         public event Action Event
588         {
589             add
590             {
591                 throw null;
592             }
593 
594             remove
595             {
596                 throw null;
597             }
598         }
599 
600         public class NestedType
601         {
602         }
603     }
604 }
605 
606 namespace SampleMetadata
607 {
608     // Create two types with "identical" methods.
609 
610     public class ProtoType
611     {
612         [SimpleStringCa("1")]
Meth()613         public void Meth()
614         {
615         }
616 
Foo([SimpleStringCa(R)] int twin, Object differentTypes)617         public void Foo([SimpleStringCa("p1")] int twin, Object differentTypes)
618         {
619         }
620     }
621 
622     public class Similar
623     {
624         [SimpleStringCa("2")]
Meth()625         public void Meth()
626         {
627         }
628 
Foo([SimpleStringCa(R)] int twin, String differentTypes)629         public void Foo([SimpleStringCa("p2")] int twin, String differentTypes)
630         {
631         }
632     }
633 }
634 
635 namespace SampleMetadata
636 {
637     public class MethodFamilyIsInstance
638     {
MethodFamily()639         public void MethodFamily()
640         {
641         }
642     }
643 
644     public class MethodFamilyIsStatic
645     {
MethodFamily()646         public static void MethodFamily()
647         {
648         }
649     }
650 
651     public class MethodFamilyIsPrivate
652     {
MethodFamily()653         private void MethodFamily()
654         {
655         }
656     }
657 
658     public class MethodFamilyIsGeneric
659     {
660         public void MethodFamily<M1>()
661             where M1 : IEquatable<M1>
662         {
663         }
664     }
665 
666     public class MethodFamilyIsAlsoGeneric
667     {
668         public void MethodFamily<M2>()
669             where M2 : IEquatable<M2>
670         {
671         }
672     }
673 
674     public class MethodFamilyIsUnary
675     {
MethodFamily(int m)676         public void MethodFamily(int m)
677         {
678         }
679     }
680 
681     public class MethodFamilyReturnsSomething
682     {
MethodFamily()683         public String MethodFamily()
684         {
685             return null;
686         }
687     }
688 
689     public class MethodFamilyHasCtor1
690     {
691         [Circular(1)]
MethodFamily()692         public void MethodFamily()
693         {
694         }
695     }
696 
697     public class MethodFamilyHasCtor2
698     {
699         [Circular(2)]
MethodFamily()700         public void MethodFamily()
701         {
702         }
703     }
704 }
705 
706 namespace SampleMetadata
707 {
708     [Circular(1)]
709     public class CircularAttribute : Attribute
710     {
711         [Circular(2)]
CircularAttribute([Circular(3)] int x)712         public CircularAttribute([Circular(3)] int x)
713         {
714         }
715     }
716 }
717 
718 namespace SampleMetadata.NS1
719 {
720     public class Twin
721     {
722     }
723 }
724 
725 namespace SampleMetadata.NS2
726 {
727     public class Twin
728     {
729     }
730 }
731 
732 namespace SampleMetadata
733 {
734     public class FieldInvokeSampleBase
735     {
736         public String InheritedField;
737     }
738 
739     public class FieldInvokeSample : FieldInvokeSampleBase
740     {
741         public String InstanceField;
742 
743         public static String StaticField;
744 
745         public const int LiteralInt32Field = 42;
746 
747         public const SimpleEnum LiteralEnumField = SimpleEnum.Green;
748 
749         public const String LiteralStringField = "Hello";
750 
751         public const Object LiteralNullField = null;
752     }
753 
754     public class PropertyInvokeSample
755     {
PropertyInvokeSample(String name)756         public PropertyInvokeSample(String name)
757         {
758             this.Name = name;
759         }
760 
761         public String InstanceProperty
762         {
763             get;
764             set;
765         }
766         public static String StaticProperty
767         {
768             get;
769             set;
770         }
771 
772         public String ReadOnlyInstanceProperty
773         {
774             get { return "rip:"; }
775         }
776         public static String ReadOnlyStaticProperty
777         {
778             get { return "rsp"; }
779         }
780 
781         [IndexerName("IndexedProperty")]
782         public String this[int i1, int i2]
783         {
784             get
785             {
786                 return _indexed;
787             }
788 
789             set
790             {
791                 _indexed = value;
792             }
793         }
794 
795         private String _indexed;
796 
797         public String Name;
798     }
799 
800     public class MethodInvokeSample
801     {
MethodInvokeSample(String name)802         public MethodInvokeSample(String name)
803         {
804             this.Name = name;
805         }
806 
InstanceMethod(int x, String s)807         public void InstanceMethod(int x, String s)
808         {
809         }
810 
InstanceMethodWithSingleParameter(String s)811         public void InstanceMethodWithSingleParameter(String s)
812         {
813         }
814 
StaticMethod(int x, String s)815         public static void StaticMethod(int x, String s)
816         {
817         }
818 
InstanceFunction(int x, String s)819         public String InstanceFunction(int x, String s)
820         {
821             throw null;
822         }
823 
StaticFunction(int x, String s)824         public static String StaticFunction(int x, String s)
825         {
826             throw null;
827         }
828 
829         public static String LastStaticCall { get; set; }
830         public String LastCall { get; set; }
831         public String Name;
832     }
833 }
834 
835 namespace SampleMetadataEx
836 {
837     public enum Color
838     {
839         Red = 1,
840         Green = 2,
841         Blue = 3,
842     }
843 
844     //=========================================================================================
845     //=========================================================================================
846     public class DataTypeTestAttribute : Attribute
847     {
DataTypeTestAttribute(int i, String s, Type t, Color c, int[] iArray, String[] sArray, Type[] tArray, Color[] cArray)848         public DataTypeTestAttribute(int i, String s, Type t, Color c, int[] iArray, String[] sArray, Type[] tArray, Color[] cArray)
849         {
850             this.I = i;
851             this.S = s;
852             this.T = t;
853             this.C = c;
854             this.IArray = iArray;
855             this.SArray = sArray;
856             this.TArray = tArray;
857             this.CArray = cArray;
858         }
859 
860         public int I { get; private set; }
861         public String S { get; private set; }
862         public Type T { get; private set; }
863         public Color C { get; private set; }
864 
865         public int[] IArray { get; private set; }
866         public String[] SArray { get; private set; }
867         public Type[] TArray { get; private set; }
868         public Color[] CArray { get; private set; }
869     }
870 
871     //=========================================================================================
872     // Named arguments.
873     //=========================================================================================
874     public class NamedArgumentsAttribute : Attribute
875     {
NamedArgumentsAttribute()876         public NamedArgumentsAttribute()
877         {
878         }
879 
880         public int F1;
881         public Color F2;
882         public int P1 { get; set; }
883         public Color P2 { get; set; }
884     }
885 
886     //=========================================================================================
887     // The annoying special case where the formal parameter type is Object.
888     //=========================================================================================
889     public class ObjectTypeTestAttribute : Attribute
890     {
ObjectTypeTestAttribute(Object o)891         public ObjectTypeTestAttribute(Object o)
892         {
893             this.O = o;
894         }
895 
896         public Object O { get; private set; }
897 
898         public Object F;
899 
900         public Object P { get; set; }
901     }
902 
903     public class BaseAttribute : Attribute
904     {
BaseAttribute(String s)905         public BaseAttribute(String s)
906         {
907             S = s;
908         }
909 
BaseAttribute(String s, int i)910         public BaseAttribute(String s, int i)
911         {
912         }
913 
914         public int F;
915 
916         public int P { get; set; }
917 
918         public String S { get; private set; }
919 
ToString()920         public sealed override String ToString()
921         {
922             throw null;
923         }
924     }
925 
926     public class MidAttribute : BaseAttribute
927     {
MidAttribute(String s)928         public MidAttribute(String s)
929             : base(s)
930         {
931         }
932 
MidAttribute(String s, int i)933         public MidAttribute(String s, int i)
934             : base(s, i)
935         {
936         }
937 
938         public new int F;
939 
940         public new int P { get; set; }
941     }
942 
943     public class DerivedAttribute : MidAttribute
944     {
DerivedAttribute(String s)945         public DerivedAttribute(String s)
946             : base(s)
947         {
948         }
949 
950         public new int F;
951 
952         public new int P { get; set; }
953     }
954 
955     public class NonInheritableAttribute : BaseAttribute
956     {
957 
NonInheritableAttribute(String s)958         public NonInheritableAttribute(String s)
959             : base(s)
960         {
961         }
962     }
963 
964     public class BaseAmAttribute : Attribute
965     {
BaseAmAttribute(String s)966         public BaseAmAttribute(String s)
967         {
968             S = s;
969         }
970 
BaseAmAttribute(String s, int i)971         public BaseAmAttribute(String s, int i)
972         {
973         }
974 
975         public String S { get; private set; }
976 
ToString()977         public sealed override String ToString()
978         {
979             throw null;
980         }
981     }
982 
983     public class MidAmAttribute : BaseAmAttribute
984     {
MidAmAttribute(String s)985         public MidAmAttribute(String s)
986             : base(s)
987         {
988         }
989     }
990 
991     public class DerivedAmAttribute : MidAmAttribute
992     {
DerivedAmAttribute(String s)993         public DerivedAmAttribute(String s)
994             : base(s)
995         {
996         }
997     }
998 }
999 
1000 namespace SampleMetadataEx
1001 {
1002     public class CaHolder
1003     {
1004         [DataTypeTest(
1005             42,
1006             "FortyTwo",
1007             typeof(IList<String>),
1008             Color.Green,
1009             new int[] { 1, 2, 3 },
1010             new String[] { "One", "Two", "Three" },
1011             new Type[] { typeof(int), typeof(String) },
1012             new Color[] { Color.Red, Color.Blue }
1013             )]
1014         public int DataTypeTest = 1;
1015 
1016         [NamedArguments(F1 = 42, F2 = Color.Blue, P1 = 77, P2 = Color.Green)]
1017         public int NamedArgumentsTest = 1;
1018 
1019         [ObjectTypeTest(Color.Red, F = Color.Blue, P = Color.Green)]
1020         public int ObjectTest = 1;
1021 
1022         [Base("B", F = 1, P = 2)]
1023         public int BaseTest = 1;
1024 
1025         [Mid("M", F = 5, P = 6)]
1026         public int MidTest = 1;
1027 
1028         [Derived("D", F = 8, P = 9)]
1029         public int DerivedTest = 1;
1030     }
1031 
1032     [BaseAttribute("[Base]SearchType.Field")]
1033     [MidAttribute("[Mid]SearchType.Field")]
1034     [DerivedAttribute("[Derived]SearchType.Field")]
1035     public class SearchType1
1036     {
1037         public int Field;
1038     }
1039 
1040     [BaseAttribute("[Base]B")]
1041     [MidAttribute("[Mid]B", 42)]   // This is hidden by down-level MidAttributes, even though the down-level MidAttributes are using a different .ctor
1042     [DerivedAttribute("[Derived]B")]
1043     [BaseAmAttribute("[BaseAm]B")]
1044     [MidAmAttribute("[MidAm]B")]
1045     [DerivedAmAttribute("[DerivedAm]B")]
1046     public abstract class B
1047     {
1048         [BaseAm("[BaseAm]B.M1()")]
M1([BaseAm(R)] int x)1049         public virtual void M1([BaseAm("[BaseAm]B.M1.x")] int x) { }
1050 
1051         [BaseAm("[BaseAm]B.M2()")]
M2([BaseAm(R)] int x)1052         public void M2([BaseAm("[BaseAm]B.M2.x")] int x) { }
1053 
1054         [BaseAm("[BaseAm]B.P1")]
1055         public virtual int P1 { get; set; }
1056 
1057         [BaseAm("[BaseAm]B.P2")]
1058         public int P2 { get; set; }
1059 
1060         [BaseAm("[BaseAm]B.E1")]
1061         public virtual event Action E1 { add { } remove { } }
1062 
1063         [BaseAm("[BaseAm]B.E2")]
1064         public event Action E2 { add { } remove { } }
1065     }
1066 
1067     [NonInheritable("[Noninheritable]M")]
1068     [MidAttribute("[Mid]M")]
1069     [DerivedAttribute("[Derived]M")]
1070     [MidAmAttribute("[MidAm]M")]
1071     [DerivedAmAttribute("[DerivedAm]M")]
1072     public abstract class M : B
1073     {
M1(int x)1074         public override void M1(int x) { }
1075         public override int P1 { get; set; }
1076         public override event Action E1 { add { } remove { } }
1077     }
1078 
1079     [DerivedAttribute("[Derived]D")]
1080     [DerivedAmAttribute("[DerivedAm]D")]
1081     public abstract class D : M, ID
1082     {
Foo()1083         public void Foo() { }
1084 
M1(int x)1085         public new virtual void M1(int x) { }
M2(int x)1086         public new void M2(int x) { }
1087 
1088         public new virtual int P1 { get; set; }
1089         public new int P2 { get; set; }
1090 
1091         public new virtual event Action E1 { add { } remove { } }
1092         public new event Action E2 { add { } remove { } }
1093     }
1094 
1095     // These attributes won't be inherited as the CA inheritance only walks base classes, not interfaces.
1096     [BaseAttribute("[Base]ID")]
1097     [MidAttribute("[Mid]ID")]
1098     [DerivedAttribute("[Derived]ID")]
1099     [BaseAmAttribute("[BaseAm]ID")]
1100     [MidAmAttribute("[MidAm]ID")]
1101     [DerivedAmAttribute("[DerivedAm]ID")]
1102     public interface ID
1103     {
1104         [BaseAmAttribute("[BaseAm]ID.Foo()")]
Foo()1105         void Foo();
1106     }
1107 }
1108 
1109 namespace SampleMetadataRex
1110 {
1111     public class DelegateBinding
1112     {
M1()1113         public static void M1()
1114         {
1115         }
1116 
M2()1117         public static void M2()
1118         {
1119         }
1120     }
1121 
1122     public class MethodLookup
1123     {
Moo(int x)1124         public void Moo(int x) { }
Moo(String s)1125         public void Moo(String s) { }
Moo(String s, int x)1126         public void Moo(String s, int x) { }
1127     }
1128 
1129     public interface IFoo
1130     {
Foo()1131         void Foo();
Hidden()1132         void Hidden();
1133         int FooProp { get; set; }
1134         event Action FooEvent;
1135     }
1136 
1137     public interface IBar : IFoo
1138     {
Bar()1139         void Bar();
Hidden()1140         new void Hidden();
1141     }
1142 
1143     public abstract class CBar : IBar
1144     {
Bar()1145         public void Bar()
1146         {
1147         }
1148 
Hidden()1149         public void Hidden()
1150         {
1151         }
1152 
Foo()1153         public void Foo()
1154         {
1155         }
1156 
1157         public int FooProp
1158         {
1159             get
1160             {
1161                 throw null;
1162             }
1163             set
1164             {
1165                 throw null;
1166             }
1167         }
1168 
1169         public event Action FooEvent
1170         {
1171             add { }
1172             remove { }
1173         }
1174     }
1175 
1176     public abstract class Base
1177     {
1178         // Instance fields
1179 
1180         public int B_InstFieldPublic;
1181 
1182         protected int B_InstFieldFamily;
1183 
1184         private int B_InstFieldPrivate;
1185 
1186         internal int B_InstFieldAssembly;
1187 
1188         protected internal int B_InstFieldFamOrAssembly;
1189 
1190         // Hidden fields
1191 
1192         public int B_HiddenFieldPublic;
1193 
1194         protected int B_HiddenFieldFamily;
1195 
1196         private int B_HiddenFieldPrivate;
1197 
1198         internal int B_HiddenFieldAssembly;
1199 
1200         protected internal int B_HiddenFieldFamOrAssembly;
1201 
1202         // Static fields
1203 
1204         public static int B_StaticFieldPublic;
1205 
1206         protected static int B_StaticFieldFamily;
1207 
1208         private static int B_StaticFieldPrivate;
1209 
1210         internal static int B_StaticFieldAssembly;
1211 
1212         protected internal static int B_StaticFieldFamOrAssembly;
1213 
1214         // Instance methods
1215 
B_InstMethPublic()1216         public void B_InstMethPublic() { }
1217 
B_InstMethFamily()1218         protected void B_InstMethFamily() { }
1219 
B_InstMethPrivate()1220         private void B_InstMethPrivate() { }
1221 
B_InstMethAssembly()1222         internal void B_InstMethAssembly() { }
1223 
B_InstMethFamOrAssembly()1224         protected internal void B_InstMethFamOrAssembly() { }
1225 
1226         // Hidden methods
1227 
B_HiddenMethPublic()1228         public void B_HiddenMethPublic() { }
1229 
B_HiddenMethFamily()1230         protected void B_HiddenMethFamily() { }
1231 
B_HiddenMethPrivate()1232         private void B_HiddenMethPrivate() { }
1233 
B_HiddenMethAssembly()1234         internal void B_HiddenMethAssembly() { }
1235 
B_HiddenMethFamOrAssembly()1236         protected internal void B_HiddenMethFamOrAssembly() { }
1237 
1238         // Static methods
1239 
B_StaticMethPublic()1240         public static void B_StaticMethPublic() { }
1241 
B_StaticMethFamily()1242         protected static void B_StaticMethFamily() { }
1243 
B_StaticMethPrivate()1244         private static void B_StaticMethPrivate() { }
1245 
B_StaticMethAssembly()1246         internal static void B_StaticMethAssembly() { }
B_StaticMethFamOrAssembly()1247         protected internal static void B_StaticMethFamOrAssembly() { }
1248 
1249         // Virtual methods
1250 
B_VirtualMethPublic()1251         public virtual void B_VirtualMethPublic() { }
1252 
B_VirtualMethFamily()1253         protected virtual void B_VirtualMethFamily() { }
1254 
B_VirtualMethAssembly()1255         internal virtual void B_VirtualMethAssembly() { }
1256 
B_VirtualMethFamOrAssembly()1257         protected virtual internal void B_VirtualMethFamOrAssembly() { }
1258 
1259         // Instance properties
1260 
1261         public int B_InstPropPublic { get { return 5; } }
1262 
1263         protected int B_InstPropFamily { get { return 5; } }
1264 
1265         private int B_InstPropPrivate { get { return 5; } }
1266 
1267         internal int B_InstPropAssembly { get { return 5; } }
1268 
1269         protected internal int B_InstPropFamOrAssembly { get { return 5; } }
1270 
1271         // Hidden properties
1272 
1273         public int B_HiddenPropPublic { get { return 5; } }
1274 
1275         protected int B_HiddenPropFamily { get { return 5; } }
1276 
1277         private int B_HiddenPropPrivate { get { return 5; } }
1278 
1279         internal int B_HiddenPropAssembly { get { return 5; } }
1280 
1281         protected internal int B_HiddenPropFamOrAssembly { get { return 5; } }
1282 
1283         // Static properties
1284 
1285         public static int B_StaticPropPublic { get { return 5; } }
1286 
1287         protected static int B_StaticPropFamily { get { return 5; } }
1288 
1289         private static int B_StaticPropPrivate { get { return 5; } }
1290 
1291         internal static int B_StaticPropAssembly { get { return 5; } }
1292 
1293         protected internal static int B_StaticPropFamOrAssembly { get { return 5; } }
1294 
1295         // Virtual properties
1296 
1297         public virtual int B_VirtualPropPublic { get { return 5; } }
1298 
1299         protected virtual int B_VirtualPropFamily { get { return 5; } }
1300 
1301         internal virtual int B_VirtualPropAssembly { get { return 5; } }
1302 
1303         protected virtual internal int B_VirtualPropFamOrAssembly { get { return 5; } }
1304 
1305         // Instance events
1306 
1307         public event Action B_InstEventPublic { add { } remove { } }
1308 
1309         protected event Action B_InstEventFamily { add { } remove { } }
1310 
1311         private event Action B_InstEventPrivate { add { } remove { } }
1312 
1313         internal event Action B_InstEventAssembly { add { } remove { } }
1314 
1315         protected internal event Action B_InstEventFamOrAssembly { add { } remove { } }
1316 
1317         // Hidden events
1318 
1319         public event Action B_HiddenEventPublic { add { } remove { } }
1320 
1321         protected event Action B_HiddenEventFamily { add { } remove { } }
1322 
1323         private event Action B_HiddenEventPrivate { add { } remove { } }
1324 
1325         internal event Action B_HiddenEventAssembly { add { } remove { } }
1326 
1327         protected internal event Action B_HiddenEventFamOrAssembly { add { } remove { } }
1328 
1329         // Static events
1330 
1331         public static event Action B_StaticEventPublic { add { } remove { } }
1332 
1333         protected static event Action B_StaticEventFamily { add { } remove { } }
1334 
1335         private static event Action B_StaticEventPrivate { add { } remove { } }
1336 
1337         internal static event Action B_StaticEventAssembly { add { } remove { } }
1338 
1339         protected internal static event Action B_StaticEventFamOrAssembly { add { } remove { } }
1340 
1341         // Virtual events
1342 
1343         public virtual event Action B_VirtualEventPublic { add { } remove { } }
1344 
1345         protected virtual event Action B_VirtualEventFamily { add { } remove { } }
1346 
1347         internal virtual event Action B_VirtualEventAssembly { add { } remove { } }
1348 
1349         protected virtual internal event Action B_VirtualEventFamOrAssembly { add { } remove { } }
1350     }
1351 
1352     public abstract class Mid : Base
1353     {
1354         // Instance fields
1355 
1356         public int M_InstFieldPublic;
1357 
1358         protected int M_InstFieldFamily;
1359 
1360         private int M_InstFieldPrivate;
1361 
1362         internal int M_InstFieldAssembly;
1363 
1364         protected internal int M_InstFieldFamOrAssembly;
1365 
1366         // Hidden fields
1367 
1368         public new int B_HiddenFieldPublic;
1369 
1370         protected new int B_HiddenFieldFamily;
1371 
1372         private /*new*/ int B_HiddenFieldPrivate;
1373 
1374         internal new int B_HiddenFieldAssembly;
1375 
1376         protected internal new int B_HiddenFieldFamOrAssembly;
1377 
1378         // Static fields
1379 
1380         public static int M_StaticFieldPublic;
1381 
1382         protected static int M_StaticFieldFamily;
1383 
1384         private static int M_StaticFieldPrivate;
1385 
1386         internal static int M_StaticFieldAssembly;
1387 
1388         protected internal static int M_StaticFieldFamOrAssembly;
1389 
1390         // Instance methods
1391 
M_InstMethPublic()1392         public void M_InstMethPublic() { }
1393 
M_InstMethFamily()1394         protected void M_InstMethFamily() { }
1395 
M_InstMethPrivate()1396         private void M_InstMethPrivate() { }
1397 
M_InstMethAssembly()1398         internal void M_InstMethAssembly() { }
1399 
M_InstMethFamOrAssembly()1400         protected internal void M_InstMethFamOrAssembly() { }
1401 
1402         // Hidden methods
1403 
B_HiddenMethPublic()1404         public new void B_HiddenMethPublic() { }
1405 
B_HiddenMethFamily()1406         protected new void B_HiddenMethFamily() { }
1407 
B_HiddenMethPrivate()1408         private void B_HiddenMethPrivate() { }
1409 
B_HiddenMethAssembly()1410         internal new void B_HiddenMethAssembly() { }
1411 
B_HiddenMethFamOrAssembly()1412         protected new internal void B_HiddenMethFamOrAssembly() { }
1413 
1414         // Static methods
1415 
M_StaticMethPublic()1416         public static void M_StaticMethPublic() { }
1417 
M_StaticMethFamily()1418         protected static void M_StaticMethFamily() { }
1419 
M_StaticMethPrivate()1420         private static void M_StaticMethPrivate() { }
1421 
M_StaticMethAssembly()1422         internal static void M_StaticMethAssembly() { }
1423 
M_StaticMethFamOrAssembly()1424         protected internal static void M_StaticMethFamOrAssembly() { }
1425 
1426         // Overriding Virtual methods
1427 
B_VirtualMethPublic()1428         public override void B_VirtualMethPublic() { }
1429 
B_VirtualMethFamily()1430         protected override void B_VirtualMethFamily() { }
1431 
B_VirtualMethAssembly()1432         internal override void B_VirtualMethAssembly() { }
1433 
B_VirtualMethFamOrAssembly()1434         protected override internal void B_VirtualMethFamOrAssembly() { }
1435 
1436         // Instance properties
1437 
1438         public int M_InstPropPublic { get { return 5; } }
1439 
1440         protected int M_InstPropFamily { get { return 5; } }
1441 
1442         private int M_InstPropPrivate { get { return 5; } }
1443 
1444         internal int M_InstPropAssembly { get { return 5; } }
1445 
1446         protected internal int M_InstPropFamOrAssembly { get { return 5; } }
1447 
1448         // Hidden properties
1449 
1450         public new int B_HiddenPropPublic { get { return 5; } }
1451 
1452         protected new int B_HiddenPropFamily { get { return 5; } }
1453 
1454         private int B_HiddenPropPrivate { get { return 5; } }
1455 
1456         internal new int B_HiddenPropAssembly { get { return 5; } }
1457 
1458         protected new internal int B_HiddenPropFamOrAssembly { get { return 5; } }
1459 
1460         // Static properties
1461 
1462         public static int M_StaticPropPublic { get { return 5; } }
1463 
1464         protected static int M_StaticPropFamily { get { return 5; } }
1465 
1466         private static int M_StaticPropPrivate { get { return 5; } }
1467 
1468         internal static int M_StaticPropAssembly { get { return 5; } }
1469 
1470         protected internal static int M_StaticPropFamOrAssembly { get { return 5; } }
1471 
1472         // Overriding Virtual properties
1473 
1474         public override int B_VirtualPropPublic { get { return 5; } }
1475 
1476         protected override int B_VirtualPropFamily { get { return 5; } }
1477 
1478         internal override int B_VirtualPropAssembly { get { return 5; } }
1479 
1480         protected override internal int B_VirtualPropFamOrAssembly { get { return 5; } }
1481 
1482         // Instance events
1483 
1484         public event Action M_InstEventPublic { add { } remove { } }
1485 
1486         protected event Action M_InstEventFamily { add { } remove { } }
1487 
1488         private event Action M_InstEventPrivate { add { } remove { } }
1489 
1490         internal event Action M_InstEventAssembly { add { } remove { } }
1491 
1492         protected internal event Action M_InstEventFamOrAssembly { add { } remove { } }
1493 
1494         // Hidden events
1495 
1496         public new event Action B_HiddenEventPublic { add { } remove { } }
1497 
1498         protected new event Action B_HiddenEventFamily { add { } remove { } }
1499 
1500         private event Action B_HiddenEventPrivate { add { } remove { } }
1501 
1502         internal new event Action B_HiddenEventAssembly { add { } remove { } }
1503 
1504         protected new internal event Action B_HiddenEventFamOrAssembly { add { } remove { } }
1505 
1506         // Static events
1507 
1508         public static event Action M_StaticEventPublic { add { } remove { } }
1509 
1510         protected static event Action M_StaticEventFamily { add { } remove { } }
1511 
1512         private static event Action M_StaticEventPrivate { add { } remove { } }
1513 
1514         internal static event Action M_StaticEventAssembly { add { } remove { } }
1515 
1516         protected internal static event Action M_StaticEventFamOrAssembly { add { } remove { } }
1517 
1518         // Overriding Virtual events
1519 
1520         public override event Action B_VirtualEventPublic { add { } remove { } }
1521 
1522         protected override event Action B_VirtualEventFamily { add { } remove { } }
1523 
1524         internal override event Action B_VirtualEventAssembly { add { } remove { } }
1525 
1526         protected override internal event Action B_VirtualEventFamOrAssembly { add { } remove { } }
1527     }
1528 
1529     public abstract class Derived : Mid
1530     {
1531         // New Virtual methods
1532 
B_VirtualMethPublic()1533         public new virtual void B_VirtualMethPublic() { }
1534 
B_VirtualMethFamily()1535         protected new virtual void B_VirtualMethFamily() { }
1536 
B_VirtualMethAssembly()1537         internal new virtual void B_VirtualMethAssembly() { }
1538 
B_VirtualMethFamOrAssembly()1539         protected new virtual internal void B_VirtualMethFamOrAssembly() { }
1540 
1541         // New Virtual properties
1542 
1543         public new virtual int B_VirtualPropPublic { get { return 5; } }
1544 
1545         protected new virtual int B_VirtualPropFamily { get { return 5; } }
1546 
1547         internal new virtual int B_VirtualPropAssembly { get { return 5; } }
1548 
1549         protected new virtual internal int B_VirtualPropFamOrAssembly { get { return 5; } }
1550 
1551         // New Virtual events
1552 
1553         public new virtual event Action B_VirtualEventPublic { add { } remove { } }
1554 
1555         protected new virtual event Action B_VirtualEventFamily { add { } remove { } }
1556 
1557         internal new virtual event Action B_VirtualEventAssembly { add { } remove { } }
1558 
1559         protected new virtual internal event Action B_VirtualEventFamOrAssembly { add { } remove { } }
1560     }
1561 
1562     public abstract class S1
1563     {
1564 
1565         public int Prop1 { get; set; }
1566 
1567         public int Prop2 { get; set; }
1568 
1569         public event Action Event1 { add { } remove { } }
1570 
1571         public event Action Event2 { add { } remove { } }
1572 
M1()1573         protected abstract void M1();
1574 
M3()1575         protected virtual void M3() { }
1576 
M4()1577         protected virtual void M4() { }
1578     }
1579 
1580     public abstract class S2 : S1
1581     {
1582 
1583         private new int Prop1 { get; set; }
1584 
1585         private new event Action Event1 { add { } remove { } }
1586 
M2()1587         protected virtual void M2() { }
1588 
M4()1589         protected new virtual void M4() { }
1590     }
1591 
1592     public abstract class S3 : S2
1593     {
1594         public static new int Prop2 { get; set; }
1595         public static new event Action Event2 { add { } remove { } }
1596 
M1()1597         protected override void M1() { }
1598 
M2()1599         protected abstract override void M2();
1600 
M4()1601         protected override void M4() { }
1602     }
1603 
1604     public abstract class S4 : S3
1605     {
1606 
M2()1607         protected override void M2() { }
1608 
M3()1609         protected override void M3() { }
1610 
M4()1611         protected new virtual void M4() { }
1612     }
1613 
1614     public interface INov1
1615     {
Foo()1616         void Foo();
1617     }
1618 
1619     public interface INov2 : INov1
1620     {
1621     }
1622 
1623     public class Nov : INov2
1624     {
S()1625         public static void S() { }
I()1626         public void I() { }
Foo()1627         public void Foo() { }
1628     }
1629 
1630     public class GetRuntimeMethodBase
1631     {
Hidden1(int x)1632         public void Hidden1(int x) { }
1633 
DefinedInBaseOnly(int x)1634         public void DefinedInBaseOnly(int x) { }
1635 
InExact(Object o)1636         public void InExact(Object o) { }
1637 
Close1(String s)1638         public void Close1(String s) { }
1639 
VarArgs(int x, params Object[] varargs)1640         public void VarArgs(int x, params Object[] varargs) { }
1641 
Primitives(int i)1642         public void Primitives(int i) { }
1643     }
1644 
1645     public class GetRuntimeMethodDerived : GetRuntimeMethodBase
1646     {
Hidden1(int x)1647         public new void Hidden1(int x) { }
1648 
Close1(Object s)1649         public void Close1(Object s) { }
1650     }
1651 }
1652 
1653 namespace SampleMetadataMethodImpl
1654 {
1655     interface ICloneable
1656     {
Clone()1657         void Clone();
GenericClone()1658         void GenericClone<T>();
1659     }
1660 
1661     class ImplementsICloneable : ICloneable
1662     {
ICloneable.Clone()1663         void ICloneable.Clone()
1664         {
1665         }
ICloneable.GenericClone()1666         void ICloneable.GenericClone<T>()
1667         {
1668         }
1669     }
1670 }
1671 
1672