Torture.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #define TORTURE_FLAG
  2. global using GlobalNs.Thing;
  3. using System;
  4. using System.Collections.Generic;
  5. using static System.Math;
  6. namespace Torture.Alpha
  7. {
  8. using System.Text;
  9. namespace Inner
  10. {
  11. public class Deep { }
  12. }
  13. /// <summary>Doc line.</summary>
  14. /// <remarks>Second doc line over an attribute.</remarks>
  15. [Serializable]
  16. public class TortureClass : Widget
  17. {
  18. #pragma warning disable 168
  19. public const int MaxItems = 10;
  20. public static readonly string DefaultName = "x";
  21. private const int LOCAL_SHADOWED = 5;
  22. private Widget A, B;
  23. private readonly int _count;
  24. private static int counter;
  25. private IRepo _repo;
  26. private ServiceCollection builder;
  27. private int status;
  28. private List<Action<int>> Table = new() { TargetCb };
  29. #nullable enable
  30. public string Name { get; set; }
  31. public Widget Parent { get; init; }
  32. public List<Widget> Items { get; }
  33. public int Computed => MaxItems + 1;
  34. public Widget Made { get; } = new();
  35. public int Accessored { get { return Lookup(1); } set { Store(value); } }
  36. public Action A2 { get; } = () => Register(HandleThing);
  37. public event Action Changed;
  38. public event Action Custom
  39. {
  40. add { Register(HandleThing); }
  41. remove { Unregister(value); }
  42. }
  43. public static TortureClass operator +(TortureClass a, TortureClass b) { return Combine(a, b); }
  44. public static explicit operator int(TortureClass t) { return Score(t); }
  45. public int this[int idx] { get { return Lookup(idx); } }
  46. ~TortureClass() { Cleanup(); }
  47. public TortureClass(int seed) : base(Compute(seed)) { Init(seed); }
  48. public TortureClass() => Init(0);
  49. void IDisposable.Dispose() { Cleanup(); }
  50. protected internal void PI() { }
  51. private protected void PP() { }
  52. public async Task Waity() { await Task.Delay(1); }
  53. public int Sum() => Compute(1) + 2;
  54. private void HandleThing(int v) { }
  55. private static void StaticHandler() { }
  56. private void OnClick() { }
  57. private void Handler() { }
  58. private static void TargetCb(int n) { }
  59. private static int Compute(int v) { return v; }
  60. private static Widget Mk() { return null; }
  61. public void Wire(Widget button, int status)
  62. {
  63. Register(HandleThing);
  64. Register(this.HandleThing);
  65. Register(C.StaticHandler);
  66. button.Click += OnClick;
  67. this.status = status;
  68. Del d = Handler;
  69. Action g = () => Register(HandleThing);
  70. }
  71. public void CallsZoo(Widget p, MyDel myDel, HttpRequest request)
  72. {
  73. Helper();
  74. Generic<int>(5);
  75. this.Run(1);
  76. base.Method();
  77. _repo.Save(2);
  78. var svcs = builder
  79. .Services
  80. .AddSingleton<IRepo, Repo>();
  81. "lit".ToUpper();
  82. request?.Method();
  83. p!.Force();
  84. Foo.Create(1).Bar();
  85. GetThing().Bar();
  86. (myDel)(3);
  87. var n = nameof(Widget);
  88. }
  89. public void Reads(User u)
  90. {
  91. DoThing(Constants.MAX);
  92. var x = ReadType.ReadAsDouble;
  93. var y = Outer.Inner.DEEP;
  94. var age = u.Age;
  95. Console.WriteLine(x);
  96. }
  97. public void News()
  98. {
  99. var a = new Widget(1) { Name = Mk() };
  100. var b = new Ns.Foo<int>();
  101. Widget c = new();
  102. var d = new { X = 1 };
  103. var e = new Widget[10];
  104. var f = new[] { Mk() };
  105. }
  106. public IEnumerable<int> Query(List<int> items)
  107. {
  108. var q = from x in items where Check(x) select Map(x);
  109. var s = items.Count switch { 0 => One(), _ => Other() };
  110. var msg = $"Hello {NameOf(this)}";
  111. var raw = """raw text""";
  112. var verb = @"verbatim\path";
  113. int[] coll = [First(), Second()];
  114. return q;
  115. }
  116. public int WithLocal()
  117. {
  118. int Local(int v) { return Compute(v); }
  119. return Local(2);
  120. }
  121. public Task<List<Widget>> Fetch(Widget? maybe, Widget[] arr, (int Code, Widget Payload) pair, List<Widget> list, Sys.ICloneable c, dynamic dyn, String s, int nn) { return null; }
  122. public Task<Widget> Single() { return null; }
  123. public Ns.Foo Qual() { return null; }
  124. public int Reader()
  125. {
  126. var LOCAL_SHADOWED = 1;
  127. return MaxItems + LOCAL_SHADOWED;
  128. }
  129. public string Reader2() => DefaultName.Trim();
  130. }
  131. public class Client : ClientBase<Widget>, Sys.ICloneable, IThing { }
  132. public partial class PartialHost { partial void Hook(); }
  133. public partial class PartialHost { partial void Hook() { } }
  134. public interface IWidgetRepo<T> where T : IEntity
  135. {
  136. Task<T> Get(int id);
  137. string Label { get; }
  138. int Compute(int x) => x + 1;
  139. }
  140. public enum ReadType : byte
  141. {
  142. [Obsolete] ReadAsInt = 1,
  143. ReadAsDouble,
  144. }
  145. public struct Point3 { public int X; }
  146. #region grouped
  147. public class Grouped { }
  148. #endregion
  149. }
  150. namespace Torture.Beta
  151. {
  152. public class Other { }
  153. }