[netcore] Ongoing work. (#13391)
[mono-project.git] / mono / tests / bug-60843.cs
blob29523464f2665debd281ab289b473cc95e3f1d08
1 using System;
2 using System.Runtime.CompilerServices;
4 class A : Attribute
6 public object X;
8 public static void Main()
10 var x = (C<int>.E)AttributeTest(typeof(C<>.E));
11 Assert(C<int>.E.V == x);
12 var y = (C<int>.E2[])AttributeTest(typeof(C<>.E2));
13 Assert(y.Length == 2);
14 Assert(y[0] == C<int>.E2.A);
15 Assert(y[1] == C<int>.E2.B);
18 public static object AttributeTest (Type t) {
19 var cas = t.GetCustomAttributes(false);
20 Assert(cas.Length == 1);
21 Assert(cas[0] is A);
22 var a = (A)cas[0];
23 return a.X;
26 private static int AssertCount = 0;
28 public static void Assert (
29 bool b,
30 [CallerFilePath] string sourceFile = null,
31 [CallerLineNumber] int lineNumber = 0
32 ) {
33 AssertCount++;
35 if (!b) {
36 Console.Error.WriteLine($"Assert failed at {sourceFile}:{lineNumber}");
37 Environment.Exit(AssertCount);
42 public class C<T>
44 [A(X = C<int>.E.V)]
45 public enum E { V }
47 [A(X = new [] { C<int>.E2.A, C<int>.E2.B })]
48 public enum E2 { A, B }