/Test/Resources/cs/Generics.cs

http://github.com/jbevain/cecil · C# · 121 lines · 91 code · 30 blank · 0 comment · 0 complexity · e383feadf356609aace4f2f0dc7d849d MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. class Foo<TBar, TBaz> {}
  4. abstract class Bar<T> {
  5. T bang;
  6. public abstract Bar<T> Self ();
  7. public abstract Bar<string> SelfString ();
  8. }
  9. abstract class Baz {
  10. public abstract TBang Gazonk<TBang> (object o);
  11. public abstract Bar<TBingo> Gazoo<TBingo> ();
  12. }
  13. class Zap {}
  14. interface IZoom {}
  15. class Bongo<T> where T : Zap, IZoom {
  16. enum Dang {
  17. Ding = 2,
  18. Dong = 12,
  19. }
  20. }
  21. class Parent<T> {}
  22. class Child<T> : Parent<T> {
  23. public T [] array;
  24. }
  25. class TamChild : Child<Tamtam> {}
  26. class RecChild : Child<RecChild> {}
  27. class Tamtam {
  28. static void Foo<TFoo> (TFoo tf)
  29. {
  30. }
  31. static void Bar ()
  32. {
  33. Foo (2);
  34. }
  35. static List<TBeta> Beta<TBeta> ()
  36. {
  37. return new List<TBeta> ();
  38. }
  39. static List<TCharlie> Charlie<TCharlie> ()
  40. {
  41. return new List<TCharlie> ();
  42. }
  43. }
  44. class It {
  45. public IEnumerable<Foo<string, string>> Pwow ()
  46. {
  47. yield return new Foo<string, string> ();
  48. yield return new Foo<string, string> ();
  49. yield return new Foo<string, string> ();
  50. }
  51. public void ReadPwow ()
  52. {
  53. foreach (Foo<string, string> foo in Pwow ())
  54. Tac (foo);
  55. }
  56. public void Tac<T> (T t)
  57. {
  58. }
  59. }
  60. class Duel<T1, T2, T3> where T2 : T1 where T3 : T2 {}
  61. class ChildReader {
  62. public int Read (TamChild t)
  63. {
  64. return t.array.Length;
  65. }
  66. }
  67. struct Nilible<T> where T : struct {
  68. public T t;
  69. }
  70. class Null {
  71. public static int Compare<T> (Nilible<T> x, Nilible<T> y) where T : struct
  72. {
  73. return Comparer<T>.Default.Compare (x.t, y.t);
  74. }
  75. }
  76. public class DoubleFuncClass {
  77. public void Test () { Test<int> (); Test<int, int> (); }
  78. public void Test<T> () { Test<T, int> (); Test<T, T> (); }
  79. public void Test<T, T1> () { Test<T1> (); Test<T1, T> (); }
  80. }
  81. public class DoubleFuncClass<X> {
  82. public void Test () { Test<int> (); Test<int, int> (); }
  83. public void Test<T> () { Test<X, int> (); Test<T, X> (); }
  84. public void Test<T, T1> () { Test<T1> (); Test<T1, T> (); }
  85. }
  86. public class LaMatrix {
  87. public static T At<T> (T[,] m, int i, int j)
  88. {
  89. return m [i, j];
  90. }
  91. }