// Static fields in generic types: this is a runtime/JIT-only test // // We need to make sure that we're instantiating each closed generic // type (ie. "Test") only once. using System; public class Test { public static int Count; public void Foo () { Count++; } public int GetCount () { return Count; } } class X { static int DoTheTest () { Test test = new Test (); test.Foo (); if (test.GetCount () != 1) return 1; if (Test.Count != 1) return 2; test.Foo (); if (test.GetCount () != 2) return 3; if (Test.Count != 2) return 4; test.Foo (); if (test.GetCount () != 3) return 5; if (Test.Count != 3) return 6; return 0; } public static int Main () { int result = DoTheTest (); if (result != 0) return result; result = DoTheTest () + 10; if (result != 10) return result; Test.Count = 0; ++Test.Count; result = DoTheTest () + 20; if (result != 20) return result; if (Test.Count != 3) return 31; if (Test.Count != 4) return 32; Test.Count = 5; if (Test.Count != 3) return 33; if (Test.Count != 4) return 34; return 0; } }