PageRenderTime 65ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 2ms

/IronPython_Main/Runtime/Tests/ETScenariosCSLinq/CSLinq/ExpressionCompiler/constant_BackSl_test0.cs

#
C# | 17067 lines | 13916 code | 2661 blank | 490 comment | 1717 complexity | 22396c4bece7d3cee26efab926f9d6e0 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. #if !CLR2
  2. using System.Linq.Expressions;
  3. #else
  4. using Microsoft.Scripting.Ast;
  5. using Microsoft.Scripting.Utils;
  6. #endif
  7. using System.Reflection;
  8. using System;
  9. namespace ExpressionCompiler {
  10. //-------- Scenario 1706
  11. namespace Scenario1706{
  12. public class Test
  13. {
  14. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check0__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  15. public static Expression check0__() {
  16. if(Main() != 0 ) {
  17. throw new Exception();
  18. } else {
  19. return Expression.Constant(0);
  20. }
  21. }
  22. public static int Main()
  23. {
  24. Ext.StartCapture();
  25. bool success = false;
  26. try
  27. {
  28. success = check0();
  29. }
  30. finally
  31. {
  32. Ext.StopCapture();
  33. }
  34. return success ? 0 : 1;
  35. }
  36. static bool check0() {
  37. foreach (byte val in new byte[] { 0, 1, byte.MaxValue }) {
  38. if (!check0(val)) {
  39. return false;
  40. }
  41. }
  42. return true;
  43. }
  44. static bool check0(byte val) {
  45. Expression<Func<byte>> e =
  46. Expression.Lambda<Func<byte>>(
  47. Expression.Constant(val, typeof(byte)),
  48. new System.Collections.Generic.List<ParameterExpression>());
  49. Func<byte> f = e.Compile();
  50. return object.Equals(f(), val);
  51. }
  52. }
  53. public static class Ext {
  54. public static void StartCapture() {
  55. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  56. // m.Invoke(null, new object[] { "test.dll" });
  57. }
  58. public static void StopCapture() {
  59. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  60. // m.Invoke(null, new object[0]);
  61. }
  62. public static bool IsIntegralOrEnum(Type type) {
  63. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  64. case TypeCode.Byte:
  65. case TypeCode.SByte:
  66. case TypeCode.Int16:
  67. case TypeCode.Int32:
  68. case TypeCode.Int64:
  69. case TypeCode.UInt16:
  70. case TypeCode.UInt32:
  71. case TypeCode.UInt64:
  72. return true;
  73. default:
  74. return false;
  75. }
  76. }
  77. public static bool IsFloating(Type type) {
  78. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  79. case TypeCode.Single:
  80. case TypeCode.Double:
  81. return true;
  82. default:
  83. return false;
  84. }
  85. }
  86. public static Type GetNonNullableType(Type type) {
  87. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  88. type.GetGenericArguments()[0] :
  89. type;
  90. }
  91. }
  92. }
  93. //-------- Scenario 1707
  94. namespace Scenario1707{
  95. public class Test
  96. {
  97. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check1__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  98. public static Expression check1__() {
  99. if(Main() != 0 ) {
  100. throw new Exception();
  101. } else {
  102. return Expression.Constant(0);
  103. }
  104. }
  105. public static int Main()
  106. {
  107. Ext.StartCapture();
  108. bool success = false;
  109. try
  110. {
  111. success = check1();
  112. }
  113. finally
  114. {
  115. Ext.StopCapture();
  116. }
  117. return success ? 0 : 1;
  118. }
  119. static bool check1() {
  120. foreach (ushort val in new ushort[] { 0, 1, ushort.MaxValue }) {
  121. if (!check1(val)) {
  122. return false;
  123. }
  124. }
  125. return true;
  126. }
  127. static bool check1(ushort val) {
  128. Expression<Func<ushort>> e =
  129. Expression.Lambda<Func<ushort>>(
  130. Expression.Constant(val, typeof(ushort)),
  131. new System.Collections.Generic.List<ParameterExpression>());
  132. Func<ushort> f = e.Compile();
  133. return object.Equals(f(), val);
  134. }
  135. }
  136. public static class Ext {
  137. public static void StartCapture() {
  138. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  139. // m.Invoke(null, new object[] { "test.dll" });
  140. }
  141. public static void StopCapture() {
  142. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  143. // m.Invoke(null, new object[0]);
  144. }
  145. public static bool IsIntegralOrEnum(Type type) {
  146. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  147. case TypeCode.Byte:
  148. case TypeCode.SByte:
  149. case TypeCode.Int16:
  150. case TypeCode.Int32:
  151. case TypeCode.Int64:
  152. case TypeCode.UInt16:
  153. case TypeCode.UInt32:
  154. case TypeCode.UInt64:
  155. return true;
  156. default:
  157. return false;
  158. }
  159. }
  160. public static bool IsFloating(Type type) {
  161. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  162. case TypeCode.Single:
  163. case TypeCode.Double:
  164. return true;
  165. default:
  166. return false;
  167. }
  168. }
  169. public static Type GetNonNullableType(Type type) {
  170. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  171. type.GetGenericArguments()[0] :
  172. type;
  173. }
  174. }
  175. }
  176. //-------- Scenario 1708
  177. namespace Scenario1708{
  178. public class Test
  179. {
  180. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check2__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  181. public static Expression check2__() {
  182. if(Main() != 0 ) {
  183. throw new Exception();
  184. } else {
  185. return Expression.Constant(0);
  186. }
  187. }
  188. public static int Main()
  189. {
  190. Ext.StartCapture();
  191. bool success = false;
  192. try
  193. {
  194. success = check2();
  195. }
  196. finally
  197. {
  198. Ext.StopCapture();
  199. }
  200. return success ? 0 : 1;
  201. }
  202. static bool check2() {
  203. foreach (uint val in new uint[] { 0, 1, uint.MaxValue }) {
  204. if (!check2(val)) {
  205. return false;
  206. }
  207. }
  208. return true;
  209. }
  210. static bool check2(uint val) {
  211. Expression<Func<uint>> e =
  212. Expression.Lambda<Func<uint>>(
  213. Expression.Constant(val, typeof(uint)),
  214. new System.Collections.Generic.List<ParameterExpression>());
  215. Func<uint> f = e.Compile();
  216. return object.Equals(f(), val);
  217. }
  218. }
  219. public static class Ext {
  220. public static void StartCapture() {
  221. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  222. // m.Invoke(null, new object[] { "test.dll" });
  223. }
  224. public static void StopCapture() {
  225. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  226. // m.Invoke(null, new object[0]);
  227. }
  228. public static bool IsIntegralOrEnum(Type type) {
  229. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  230. case TypeCode.Byte:
  231. case TypeCode.SByte:
  232. case TypeCode.Int16:
  233. case TypeCode.Int32:
  234. case TypeCode.Int64:
  235. case TypeCode.UInt16:
  236. case TypeCode.UInt32:
  237. case TypeCode.UInt64:
  238. return true;
  239. default:
  240. return false;
  241. }
  242. }
  243. public static bool IsFloating(Type type) {
  244. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  245. case TypeCode.Single:
  246. case TypeCode.Double:
  247. return true;
  248. default:
  249. return false;
  250. }
  251. }
  252. public static Type GetNonNullableType(Type type) {
  253. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  254. type.GetGenericArguments()[0] :
  255. type;
  256. }
  257. }
  258. }
  259. //-------- Scenario 1709
  260. namespace Scenario1709{
  261. public class Test
  262. {
  263. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check3__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  264. public static Expression check3__() {
  265. if(Main() != 0 ) {
  266. throw new Exception();
  267. } else {
  268. return Expression.Constant(0);
  269. }
  270. }
  271. public static int Main()
  272. {
  273. Ext.StartCapture();
  274. bool success = false;
  275. try
  276. {
  277. success = check3();
  278. }
  279. finally
  280. {
  281. Ext.StopCapture();
  282. }
  283. return success ? 0 : 1;
  284. }
  285. static bool check3() {
  286. foreach (ulong val in new ulong[] { 0, 1, ulong.MaxValue }) {
  287. if (!check3(val)) {
  288. return false;
  289. }
  290. }
  291. return true;
  292. }
  293. static bool check3(ulong val) {
  294. Expression<Func<ulong>> e =
  295. Expression.Lambda<Func<ulong>>(
  296. Expression.Constant(val, typeof(ulong)),
  297. new System.Collections.Generic.List<ParameterExpression>());
  298. Func<ulong> f = e.Compile();
  299. return object.Equals(f(), val);
  300. }
  301. }
  302. public static class Ext {
  303. public static void StartCapture() {
  304. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  305. // m.Invoke(null, new object[] { "test.dll" });
  306. }
  307. public static void StopCapture() {
  308. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  309. // m.Invoke(null, new object[0]);
  310. }
  311. public static bool IsIntegralOrEnum(Type type) {
  312. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  313. case TypeCode.Byte:
  314. case TypeCode.SByte:
  315. case TypeCode.Int16:
  316. case TypeCode.Int32:
  317. case TypeCode.Int64:
  318. case TypeCode.UInt16:
  319. case TypeCode.UInt32:
  320. case TypeCode.UInt64:
  321. return true;
  322. default:
  323. return false;
  324. }
  325. }
  326. public static bool IsFloating(Type type) {
  327. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  328. case TypeCode.Single:
  329. case TypeCode.Double:
  330. return true;
  331. default:
  332. return false;
  333. }
  334. }
  335. public static Type GetNonNullableType(Type type) {
  336. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  337. type.GetGenericArguments()[0] :
  338. type;
  339. }
  340. }
  341. }
  342. //-------- Scenario 1710
  343. namespace Scenario1710{
  344. public class Test
  345. {
  346. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check4__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  347. public static Expression check4__() {
  348. if(Main() != 0 ) {
  349. throw new Exception();
  350. } else {
  351. return Expression.Constant(0);
  352. }
  353. }
  354. public static int Main()
  355. {
  356. Ext.StartCapture();
  357. bool success = false;
  358. try
  359. {
  360. success = check4();
  361. }
  362. finally
  363. {
  364. Ext.StopCapture();
  365. }
  366. return success ? 0 : 1;
  367. }
  368. static bool check4() {
  369. foreach (sbyte val in new sbyte[] { 0, 1, -1, sbyte.MinValue, sbyte.MaxValue }) {
  370. if (!check4(val)) {
  371. return false;
  372. }
  373. }
  374. return true;
  375. }
  376. static bool check4(sbyte val) {
  377. Expression<Func<sbyte>> e =
  378. Expression.Lambda<Func<sbyte>>(
  379. Expression.Constant(val, typeof(sbyte)),
  380. new System.Collections.Generic.List<ParameterExpression>());
  381. Func<sbyte> f = e.Compile();
  382. return object.Equals(f(), val);
  383. }
  384. }
  385. public static class Ext {
  386. public static void StartCapture() {
  387. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  388. // m.Invoke(null, new object[] { "test.dll" });
  389. }
  390. public static void StopCapture() {
  391. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  392. // m.Invoke(null, new object[0]);
  393. }
  394. public static bool IsIntegralOrEnum(Type type) {
  395. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  396. case TypeCode.Byte:
  397. case TypeCode.SByte:
  398. case TypeCode.Int16:
  399. case TypeCode.Int32:
  400. case TypeCode.Int64:
  401. case TypeCode.UInt16:
  402. case TypeCode.UInt32:
  403. case TypeCode.UInt64:
  404. return true;
  405. default:
  406. return false;
  407. }
  408. }
  409. public static bool IsFloating(Type type) {
  410. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  411. case TypeCode.Single:
  412. case TypeCode.Double:
  413. return true;
  414. default:
  415. return false;
  416. }
  417. }
  418. public static Type GetNonNullableType(Type type) {
  419. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  420. type.GetGenericArguments()[0] :
  421. type;
  422. }
  423. }
  424. }
  425. //-------- Scenario 1711
  426. namespace Scenario1711{
  427. public class Test
  428. {
  429. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check5__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  430. public static Expression check5__() {
  431. if(Main() != 0 ) {
  432. throw new Exception();
  433. } else {
  434. return Expression.Constant(0);
  435. }
  436. }
  437. public static int Main()
  438. {
  439. Ext.StartCapture();
  440. bool success = false;
  441. try
  442. {
  443. success = check5();
  444. }
  445. finally
  446. {
  447. Ext.StopCapture();
  448. }
  449. return success ? 0 : 1;
  450. }
  451. static bool check5() {
  452. foreach (short val in new short[] { 0, 1, -1, short.MinValue, short.MaxValue }) {
  453. if (!check5(val)) {
  454. return false;
  455. }
  456. }
  457. return true;
  458. }
  459. static bool check5(short val) {
  460. Expression<Func<short>> e =
  461. Expression.Lambda<Func<short>>(
  462. Expression.Constant(val, typeof(short)),
  463. new System.Collections.Generic.List<ParameterExpression>());
  464. Func<short> f = e.Compile();
  465. return object.Equals(f(), val);
  466. }
  467. }
  468. public static class Ext {
  469. public static void StartCapture() {
  470. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  471. // m.Invoke(null, new object[] { "test.dll" });
  472. }
  473. public static void StopCapture() {
  474. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  475. // m.Invoke(null, new object[0]);
  476. }
  477. public static bool IsIntegralOrEnum(Type type) {
  478. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  479. case TypeCode.Byte:
  480. case TypeCode.SByte:
  481. case TypeCode.Int16:
  482. case TypeCode.Int32:
  483. case TypeCode.Int64:
  484. case TypeCode.UInt16:
  485. case TypeCode.UInt32:
  486. case TypeCode.UInt64:
  487. return true;
  488. default:
  489. return false;
  490. }
  491. }
  492. public static bool IsFloating(Type type) {
  493. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  494. case TypeCode.Single:
  495. case TypeCode.Double:
  496. return true;
  497. default:
  498. return false;
  499. }
  500. }
  501. public static Type GetNonNullableType(Type type) {
  502. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  503. type.GetGenericArguments()[0] :
  504. type;
  505. }
  506. }
  507. }
  508. //-------- Scenario 1712
  509. namespace Scenario1712{
  510. public class Test
  511. {
  512. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check6__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  513. public static Expression check6__() {
  514. if(Main() != 0 ) {
  515. throw new Exception();
  516. } else {
  517. return Expression.Constant(0);
  518. }
  519. }
  520. public static int Main()
  521. {
  522. Ext.StartCapture();
  523. bool success = false;
  524. try
  525. {
  526. success = check6();
  527. }
  528. finally
  529. {
  530. Ext.StopCapture();
  531. }
  532. return success ? 0 : 1;
  533. }
  534. static bool check6() {
  535. foreach (int val in new int[] { 0, 1, -1, int.MinValue, int.MaxValue }) {
  536. if (!check6(val)) {
  537. return false;
  538. }
  539. }
  540. return true;
  541. }
  542. static bool check6(int val) {
  543. Expression<Func<int>> e =
  544. Expression.Lambda<Func<int>>(
  545. Expression.Constant(val, typeof(int)),
  546. new System.Collections.Generic.List<ParameterExpression>());
  547. Func<int> f = e.Compile();
  548. return object.Equals(f(), val);
  549. }
  550. }
  551. public static class Ext {
  552. public static void StartCapture() {
  553. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  554. // m.Invoke(null, new object[] { "test.dll" });
  555. }
  556. public static void StopCapture() {
  557. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  558. // m.Invoke(null, new object[0]);
  559. }
  560. public static bool IsIntegralOrEnum(Type type) {
  561. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  562. case TypeCode.Byte:
  563. case TypeCode.SByte:
  564. case TypeCode.Int16:
  565. case TypeCode.Int32:
  566. case TypeCode.Int64:
  567. case TypeCode.UInt16:
  568. case TypeCode.UInt32:
  569. case TypeCode.UInt64:
  570. return true;
  571. default:
  572. return false;
  573. }
  574. }
  575. public static bool IsFloating(Type type) {
  576. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  577. case TypeCode.Single:
  578. case TypeCode.Double:
  579. return true;
  580. default:
  581. return false;
  582. }
  583. }
  584. public static Type GetNonNullableType(Type type) {
  585. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  586. type.GetGenericArguments()[0] :
  587. type;
  588. }
  589. }
  590. }
  591. //-------- Scenario 1713
  592. namespace Scenario1713{
  593. public class Test
  594. {
  595. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check7__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  596. public static Expression check7__() {
  597. if(Main() != 0 ) {
  598. throw new Exception();
  599. } else {
  600. return Expression.Constant(0);
  601. }
  602. }
  603. public static int Main()
  604. {
  605. Ext.StartCapture();
  606. bool success = false;
  607. try
  608. {
  609. success = check7();
  610. }
  611. finally
  612. {
  613. Ext.StopCapture();
  614. }
  615. return success ? 0 : 1;
  616. }
  617. static bool check7() {
  618. foreach (long val in new long[] { 0, 1, -1, long.MinValue, long.MaxValue }) {
  619. if (!check7(val)) {
  620. return false;
  621. }
  622. }
  623. return true;
  624. }
  625. static bool check7(long val) {
  626. Expression<Func<long>> e =
  627. Expression.Lambda<Func<long>>(
  628. Expression.Constant(val, typeof(long)),
  629. new System.Collections.Generic.List<ParameterExpression>());
  630. Func<long> f = e.Compile();
  631. return object.Equals(f(), val);
  632. }
  633. }
  634. public static class Ext {
  635. public static void StartCapture() {
  636. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  637. // m.Invoke(null, new object[] { "test.dll" });
  638. }
  639. public static void StopCapture() {
  640. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  641. // m.Invoke(null, new object[0]);
  642. }
  643. public static bool IsIntegralOrEnum(Type type) {
  644. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  645. case TypeCode.Byte:
  646. case TypeCode.SByte:
  647. case TypeCode.Int16:
  648. case TypeCode.Int32:
  649. case TypeCode.Int64:
  650. case TypeCode.UInt16:
  651. case TypeCode.UInt32:
  652. case TypeCode.UInt64:
  653. return true;
  654. default:
  655. return false;
  656. }
  657. }
  658. public static bool IsFloating(Type type) {
  659. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  660. case TypeCode.Single:
  661. case TypeCode.Double:
  662. return true;
  663. default:
  664. return false;
  665. }
  666. }
  667. public static Type GetNonNullableType(Type type) {
  668. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  669. type.GetGenericArguments()[0] :
  670. type;
  671. }
  672. }
  673. }
  674. //-------- Scenario 1714
  675. namespace Scenario1714{
  676. public class Test
  677. {
  678. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check8__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  679. public static Expression check8__() {
  680. if(Main() != 0 ) {
  681. throw new Exception();
  682. } else {
  683. return Expression.Constant(0);
  684. }
  685. }
  686. public static int Main()
  687. {
  688. Ext.StartCapture();
  689. bool success = false;
  690. try
  691. {
  692. success = check8();
  693. }
  694. finally
  695. {
  696. Ext.StopCapture();
  697. }
  698. return success ? 0 : 1;
  699. }
  700. static bool check8() {
  701. foreach (float val in new float[] { 0, 1, -1, float.MinValue, float.MaxValue, float.Epsilon, float.NegativeInfinity, float.PositiveInfinity, float.NaN }) {
  702. if (!check8(val)) {
  703. return false;
  704. }
  705. }
  706. return true;
  707. }
  708. static bool check8(float val) {
  709. Expression<Func<float>> e =
  710. Expression.Lambda<Func<float>>(
  711. Expression.Constant(val, typeof(float)),
  712. new System.Collections.Generic.List<ParameterExpression>());
  713. Func<float> f = e.Compile();
  714. return object.Equals(f(), val);
  715. }
  716. }
  717. public static class Ext {
  718. public static void StartCapture() {
  719. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  720. // m.Invoke(null, new object[] { "test.dll" });
  721. }
  722. public static void StopCapture() {
  723. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  724. // m.Invoke(null, new object[0]);
  725. }
  726. public static bool IsIntegralOrEnum(Type type) {
  727. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  728. case TypeCode.Byte:
  729. case TypeCode.SByte:
  730. case TypeCode.Int16:
  731. case TypeCode.Int32:
  732. case TypeCode.Int64:
  733. case TypeCode.UInt16:
  734. case TypeCode.UInt32:
  735. case TypeCode.UInt64:
  736. return true;
  737. default:
  738. return false;
  739. }
  740. }
  741. public static bool IsFloating(Type type) {
  742. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  743. case TypeCode.Single:
  744. case TypeCode.Double:
  745. return true;
  746. default:
  747. return false;
  748. }
  749. }
  750. public static Type GetNonNullableType(Type type) {
  751. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  752. type.GetGenericArguments()[0] :
  753. type;
  754. }
  755. }
  756. }
  757. //-------- Scenario 1715
  758. namespace Scenario1715{
  759. public class Test
  760. {
  761. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check9__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  762. public static Expression check9__() {
  763. if(Main() != 0 ) {
  764. throw new Exception();
  765. } else {
  766. return Expression.Constant(0);
  767. }
  768. }
  769. public static int Main()
  770. {
  771. Ext.StartCapture();
  772. bool success = false;
  773. try
  774. {
  775. success = check9();
  776. }
  777. finally
  778. {
  779. Ext.StopCapture();
  780. }
  781. return success ? 0 : 1;
  782. }
  783. static bool check9() {
  784. foreach (double val in new double[] { 0, 1, -1, double.MinValue, double.MaxValue, double.Epsilon, double.NegativeInfinity, double.PositiveInfinity, double.NaN }) {
  785. if (!check9(val)) {
  786. return false;
  787. }
  788. }
  789. return true;
  790. }
  791. static bool check9(double val) {
  792. Expression<Func<double>> e =
  793. Expression.Lambda<Func<double>>(
  794. Expression.Constant(val, typeof(double)),
  795. new System.Collections.Generic.List<ParameterExpression>());
  796. Func<double> f = e.Compile();
  797. return object.Equals(f(), val);
  798. }
  799. }
  800. public static class Ext {
  801. public static void StartCapture() {
  802. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  803. // m.Invoke(null, new object[] { "test.dll" });
  804. }
  805. public static void StopCapture() {
  806. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  807. // m.Invoke(null, new object[0]);
  808. }
  809. public static bool IsIntegralOrEnum(Type type) {
  810. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  811. case TypeCode.Byte:
  812. case TypeCode.SByte:
  813. case TypeCode.Int16:
  814. case TypeCode.Int32:
  815. case TypeCode.Int64:
  816. case TypeCode.UInt16:
  817. case TypeCode.UInt32:
  818. case TypeCode.UInt64:
  819. return true;
  820. default:
  821. return false;
  822. }
  823. }
  824. public static bool IsFloating(Type type) {
  825. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  826. case TypeCode.Single:
  827. case TypeCode.Double:
  828. return true;
  829. default:
  830. return false;
  831. }
  832. }
  833. public static Type GetNonNullableType(Type type) {
  834. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  835. type.GetGenericArguments()[0] :
  836. type;
  837. }
  838. }
  839. }
  840. //-------- Scenario 1716
  841. namespace Scenario1716{
  842. public class Test
  843. {
  844. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check10__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  845. public static Expression check10__() {
  846. if(Main() != 0 ) {
  847. throw new Exception();
  848. } else {
  849. return Expression.Constant(0);
  850. }
  851. }
  852. public static int Main()
  853. {
  854. Ext.StartCapture();
  855. bool success = false;
  856. try
  857. {
  858. success = check10();
  859. }
  860. finally
  861. {
  862. Ext.StopCapture();
  863. }
  864. return success ? 0 : 1;
  865. }
  866. static bool check10() {
  867. foreach (decimal val in new decimal[] { decimal.Zero, decimal.One, decimal.MinusOne, decimal.MinValue, decimal.MaxValue }) {
  868. if (!check10(val)) {
  869. return false;
  870. }
  871. }
  872. return true;
  873. }
  874. static bool check10(decimal val) {
  875. Expression<Func<decimal>> e =
  876. Expression.Lambda<Func<decimal>>(
  877. Expression.Constant(val, typeof(decimal)),
  878. new System.Collections.Generic.List<ParameterExpression>());
  879. Func<decimal> f = e.Compile();
  880. return object.Equals(f(), val);
  881. }
  882. }
  883. public static class Ext {
  884. public static void StartCapture() {
  885. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  886. // m.Invoke(null, new object[] { "test.dll" });
  887. }
  888. public static void StopCapture() {
  889. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  890. // m.Invoke(null, new object[0]);
  891. }
  892. public static bool IsIntegralOrEnum(Type type) {
  893. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  894. case TypeCode.Byte:
  895. case TypeCode.SByte:
  896. case TypeCode.Int16:
  897. case TypeCode.Int32:
  898. case TypeCode.Int64:
  899. case TypeCode.UInt16:
  900. case TypeCode.UInt32:
  901. case TypeCode.UInt64:
  902. return true;
  903. default:
  904. return false;
  905. }
  906. }
  907. public static bool IsFloating(Type type) {
  908. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  909. case TypeCode.Single:
  910. case TypeCode.Double:
  911. return true;
  912. default:
  913. return false;
  914. }
  915. }
  916. public static Type GetNonNullableType(Type type) {
  917. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  918. type.GetGenericArguments()[0] :
  919. type;
  920. }
  921. }
  922. }
  923. //-------- Scenario 1717
  924. namespace Scenario1717{
  925. public class Test
  926. {
  927. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check11__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  928. public static Expression check11__() {
  929. if(Main() != 0 ) {
  930. throw new Exception();
  931. } else {
  932. return Expression.Constant(0);
  933. }
  934. }
  935. public static int Main()
  936. {
  937. Ext.StartCapture();
  938. bool success = false;
  939. try
  940. {
  941. success = check11();
  942. }
  943. finally
  944. {
  945. Ext.StopCapture();
  946. }
  947. return success ? 0 : 1;
  948. }
  949. static bool check11() {
  950. foreach (char val in new char[] { '\0', '\b', 'A', '\uffff' }) {
  951. if (!check11(val)) {
  952. return false;
  953. }
  954. }
  955. return true;
  956. }
  957. static bool check11(char val) {
  958. Expression<Func<char>> e =
  959. Expression.Lambda<Func<char>>(
  960. Expression.Constant(val, typeof(char)),
  961. new System.Collections.Generic.List<ParameterExpression>());
  962. Func<char> f = e.Compile();
  963. return object.Equals(f(), val);
  964. }
  965. }
  966. public static class Ext {
  967. public static void StartCapture() {
  968. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  969. // m.Invoke(null, new object[] { "test.dll" });
  970. }
  971. public static void StopCapture() {
  972. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  973. // m.Invoke(null, new object[0]);
  974. }
  975. public static bool IsIntegralOrEnum(Type type) {
  976. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  977. case TypeCode.Byte:
  978. case TypeCode.SByte:
  979. case TypeCode.Int16:
  980. case TypeCode.Int32:
  981. case TypeCode.Int64:
  982. case TypeCode.UInt16:
  983. case TypeCode.UInt32:
  984. case TypeCode.UInt64:
  985. return true;
  986. default:
  987. return false;
  988. }
  989. }
  990. public static bool IsFloating(Type type) {
  991. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  992. case TypeCode.Single:
  993. case TypeCode.Double:
  994. return true;
  995. default:
  996. return false;
  997. }
  998. }
  999. public static Type GetNonNullableType(Type type) {
  1000. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  1001. type.GetGenericArguments()[0] :
  1002. type;
  1003. }
  1004. }
  1005. }
  1006. //-------- Scenario 1718
  1007. namespace Scenario1718{
  1008. public class Test
  1009. {
  1010. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check12__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  1011. public static Expression check12__() {
  1012. if(Main() != 0 ) {
  1013. throw new Exception();
  1014. } else {
  1015. return Expression.Constant(0);
  1016. }
  1017. }
  1018. public static int Main()
  1019. {
  1020. Ext.StartCapture();
  1021. bool success = false;
  1022. try
  1023. {
  1024. success = check12();
  1025. }
  1026. finally
  1027. {
  1028. Ext.StopCapture();
  1029. }
  1030. return success ? 0 : 1;
  1031. }
  1032. static bool check12() {
  1033. foreach (bool val in new bool[] { true, false }) {
  1034. if (!check12(val)) {
  1035. return false;
  1036. }
  1037. }
  1038. return true;
  1039. }
  1040. static bool check12(bool val) {
  1041. Expression<Func<bool>> e =
  1042. Expression.Lambda<Func<bool>>(
  1043. Expression.Constant(val, typeof(bool)),
  1044. new System.Collections.Generic.List<ParameterExpression>());
  1045. Func<bool> f = e.Compile();
  1046. return object.Equals(f(), val);
  1047. }
  1048. }
  1049. public static class Ext {
  1050. public static void StartCapture() {
  1051. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1052. // m.Invoke(null, new object[] { "test.dll" });
  1053. }
  1054. public static void StopCapture() {
  1055. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1056. // m.Invoke(null, new object[0]);
  1057. }
  1058. public static bool IsIntegralOrEnum(Type type) {
  1059. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1060. case TypeCode.Byte:
  1061. case TypeCode.SByte:
  1062. case TypeCode.Int16:
  1063. case TypeCode.Int32:
  1064. case TypeCode.Int64:
  1065. case TypeCode.UInt16:
  1066. case TypeCode.UInt32:
  1067. case TypeCode.UInt64:
  1068. return true;
  1069. default:
  1070. return false;
  1071. }
  1072. }
  1073. public static bool IsFloating(Type type) {
  1074. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1075. case TypeCode.Single:
  1076. case TypeCode.Double:
  1077. return true;
  1078. default:
  1079. return false;
  1080. }
  1081. }
  1082. public static Type GetNonNullableType(Type type) {
  1083. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  1084. type.GetGenericArguments()[0] :
  1085. type;
  1086. }
  1087. }
  1088. }
  1089. //-------- Scenario 1719
  1090. namespace Scenario1719{
  1091. public class Test
  1092. {
  1093. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check13__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  1094. public static Expression check13__() {
  1095. if(Main() != 0 ) {
  1096. throw new Exception();
  1097. } else {
  1098. return Expression.Constant(0);
  1099. }
  1100. }
  1101. public static int Main()
  1102. {
  1103. Ext.StartCapture();
  1104. bool success = false;
  1105. try
  1106. {
  1107. success = check13();
  1108. }
  1109. finally
  1110. {
  1111. Ext.StopCapture();
  1112. }
  1113. return success ? 0 : 1;
  1114. }
  1115. static bool check13() {
  1116. foreach (S val in new S[] { default(S), new S() }) {
  1117. if (!check13(val)) {
  1118. return false;
  1119. }
  1120. }
  1121. return true;
  1122. }
  1123. static bool check13(S val) {
  1124. Expression<Func<S>> e =
  1125. Expression.Lambda<Func<S>>(
  1126. Expression.Constant(val, typeof(S)),
  1127. new System.Collections.Generic.List<ParameterExpression>());
  1128. Func<S> f = e.Compile();
  1129. return object.Equals(f(), val);
  1130. }
  1131. }
  1132. public static class Ext {
  1133. public static void StartCapture() {
  1134. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1135. // m.Invoke(null, new object[] { "test.dll" });
  1136. }
  1137. public static void StopCapture() {
  1138. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1139. // m.Invoke(null, new object[0]);
  1140. }
  1141. public static bool IsIntegralOrEnum(Type type) {
  1142. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1143. case TypeCode.Byte:
  1144. case TypeCode.SByte:
  1145. case TypeCode.Int16:
  1146. case TypeCode.Int32:
  1147. case TypeCode.Int64:
  1148. case TypeCode.UInt16:
  1149. case TypeCode.UInt32:
  1150. case TypeCode.UInt64:
  1151. return true;
  1152. default:
  1153. return false;
  1154. }
  1155. }
  1156. public static bool IsFloating(Type type) {
  1157. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1158. case TypeCode.Single:
  1159. case TypeCode.Double:
  1160. return true;
  1161. default:
  1162. return false;
  1163. }
  1164. }
  1165. public static Type GetNonNullableType(Type type) {
  1166. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  1167. type.GetGenericArguments()[0] :
  1168. type;
  1169. }
  1170. }
  1171. public interface I {
  1172. void M();
  1173. }
  1174. public class C : IEquatable<C>, I {
  1175. void I.M() {
  1176. }
  1177. public override bool Equals(object o) {
  1178. return o is C && Equals((C) o);
  1179. }
  1180. public bool Equals(C c) {
  1181. return c != null;
  1182. }
  1183. public override int GetHashCode() {
  1184. return 0;
  1185. }
  1186. }
  1187. public class D : C, IEquatable<D> {
  1188. public int Val;
  1189. public D() {
  1190. }
  1191. public D(int val) {
  1192. Val = val;
  1193. }
  1194. public override bool Equals(object o) {
  1195. return o is D && Equals((D) o);
  1196. }
  1197. public bool Equals(D d) {
  1198. return d != null && d.Val == Val;
  1199. }
  1200. public override int GetHashCode() {
  1201. return Val;
  1202. }
  1203. }
  1204. public enum E {
  1205. A=1, B=2
  1206. }
  1207. public enum El : long {
  1208. A, B, C
  1209. }
  1210. public struct S : IEquatable<S> {
  1211. public override bool Equals(object o) {
  1212. return (o is S) && Equals((S) o);
  1213. }
  1214. public bool Equals(S other) {
  1215. return true;
  1216. }
  1217. public override int GetHashCode() {
  1218. return 0;
  1219. }
  1220. }
  1221. public struct Sp : IEquatable<Sp> {
  1222. public Sp(int i, double d) {
  1223. I = i;
  1224. D = d;
  1225. }
  1226. public int I;
  1227. public double D;
  1228. public override bool Equals(object o) {
  1229. return (o is Sp) && Equals((Sp) o);
  1230. }
  1231. public bool Equals(Sp other) {
  1232. return other.I == I && other.D == D;
  1233. }
  1234. public override int GetHashCode() {
  1235. return I.GetHashCode() ^ D.GetHashCode();
  1236. }
  1237. }
  1238. public struct Ss : IEquatable<Ss> {
  1239. public Ss(S s) {
  1240. Val = s;
  1241. }
  1242. public S Val;
  1243. public override bool Equals(object o) {
  1244. return (o is Ss) && Equals((Ss) o);
  1245. }
  1246. public bool Equals(Ss other) {
  1247. return other.Val.Equals(Val);
  1248. }
  1249. public override int GetHashCode() {
  1250. return Val.GetHashCode();
  1251. }
  1252. }
  1253. public struct Sc : IEquatable<Sc> {
  1254. public Sc(string s) {
  1255. S = s;
  1256. }
  1257. public string S;
  1258. public override bool Equals(object o) {
  1259. return (o is Sc) && Equals((Sc) o);
  1260. }
  1261. public bool Equals(Sc other) {
  1262. return other.S == S;
  1263. }
  1264. public override int GetHashCode() {
  1265. return S.GetHashCode();
  1266. }
  1267. }
  1268. public struct Scs : IEquatable<Scs> {
  1269. public Scs(string s, S val) {
  1270. S = s;
  1271. Val = val;
  1272. }
  1273. public string S;
  1274. public S Val;
  1275. public override bool Equals(object o) {
  1276. return (o is Scs) && Equals((Scs) o);
  1277. }
  1278. public bool Equals(Scs other) {
  1279. return other.S == S && other.Val.Equals(Val);
  1280. }
  1281. public override int GetHashCode() {
  1282. return S.GetHashCode() ^ Val.GetHashCode();
  1283. }
  1284. }
  1285. }
  1286. //-------- Scenario 1720
  1287. namespace Scenario1720{
  1288. public class Test
  1289. {
  1290. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check14__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  1291. public static Expression check14__() {
  1292. if(Main() != 0 ) {
  1293. throw new Exception();
  1294. } else {
  1295. return Expression.Constant(0);
  1296. }
  1297. }
  1298. public static int Main()
  1299. {
  1300. Ext.StartCapture();
  1301. bool success = false;
  1302. try
  1303. {
  1304. success = check14();
  1305. }
  1306. finally
  1307. {
  1308. Ext.StopCapture();
  1309. }
  1310. return success ? 0 : 1;
  1311. }
  1312. static bool check14() {
  1313. foreach (Sp val in new Sp[] { default(Sp), new Sp(), new Sp(5,5.0) }) {
  1314. if (!check14(val)) {
  1315. return false;
  1316. }
  1317. }
  1318. return true;
  1319. }
  1320. static bool check14(Sp val) {
  1321. Expression<Func<Sp>> e =
  1322. Expression.Lambda<Func<Sp>>(
  1323. Expression.Constant(val, typeof(Sp)),
  1324. new System.Collections.Generic.List<ParameterExpression>());
  1325. Func<Sp> f = e.Compile();
  1326. return object.Equals(f(), val);
  1327. }
  1328. }
  1329. public static class Ext {
  1330. public static void StartCapture() {
  1331. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1332. // m.Invoke(null, new object[] { "test.dll" });
  1333. }
  1334. public static void StopCapture() {
  1335. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1336. // m.Invoke(null, new object[0]);
  1337. }
  1338. public static bool IsIntegralOrEnum(Type type) {
  1339. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1340. case TypeCode.Byte:
  1341. case TypeCode.SByte:
  1342. case TypeCode.Int16:
  1343. case TypeCode.Int32:
  1344. case TypeCode.Int64:
  1345. case TypeCode.UInt16:
  1346. case TypeCode.UInt32:
  1347. case TypeCode.UInt64:
  1348. return true;
  1349. default:
  1350. return false;
  1351. }
  1352. }
  1353. public static bool IsFloating(Type type) {
  1354. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1355. case TypeCode.Single:
  1356. case TypeCode.Double:
  1357. return true;
  1358. default:
  1359. return false;
  1360. }
  1361. }
  1362. public static Type GetNonNullableType(Type type) {
  1363. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  1364. type.GetGenericArguments()[0] :
  1365. type;
  1366. }
  1367. }
  1368. public interface I {
  1369. void M();
  1370. }
  1371. public class C : IEquatable<C>, I {
  1372. void I.M() {
  1373. }
  1374. public override bool Equals(object o) {
  1375. return o is C && Equals((C) o);
  1376. }
  1377. public bool Equals(C c) {
  1378. return c != null;
  1379. }
  1380. public override int GetHashCode() {
  1381. return 0;
  1382. }
  1383. }
  1384. public class D : C, IEquatable<D> {
  1385. public int Val;
  1386. public D() {
  1387. }
  1388. public D(int val) {
  1389. Val = val;
  1390. }
  1391. public override bool Equals(object o) {
  1392. return o is D && Equals((D) o);
  1393. }
  1394. public bool Equals(D d) {
  1395. return d != null && d.Val == Val;
  1396. }
  1397. public override int GetHashCode() {
  1398. return Val;
  1399. }
  1400. }
  1401. public enum E {
  1402. A=1, B=2
  1403. }
  1404. public enum El : long {
  1405. A, B, C
  1406. }
  1407. public struct S : IEquatable<S> {
  1408. public override bool Equals(object o) {
  1409. return (o is S) && Equals((S) o);
  1410. }
  1411. public bool Equals(S other) {
  1412. return true;
  1413. }
  1414. public override int GetHashCode() {
  1415. return 0;
  1416. }
  1417. }
  1418. public struct Sp : IEquatable<Sp> {
  1419. public Sp(int i, double d) {
  1420. I = i;
  1421. D = d;
  1422. }
  1423. public int I;
  1424. public double D;
  1425. public override bool Equals(object o) {
  1426. return (o is Sp) && Equals((Sp) o);
  1427. }
  1428. public bool Equals(Sp other) {
  1429. return other.I == I && other.D == D;
  1430. }
  1431. public override int GetHashCode() {
  1432. return I.GetHashCode() ^ D.GetHashCode();
  1433. }
  1434. }
  1435. public struct Ss : IEquatable<Ss> {
  1436. public Ss(S s) {
  1437. Val = s;
  1438. }
  1439. public S Val;
  1440. public override bool Equals(object o) {
  1441. return (o is Ss) && Equals((Ss) o);
  1442. }
  1443. public bool Equals(Ss other) {
  1444. return other.Val.Equals(Val);
  1445. }
  1446. public override int GetHashCode() {
  1447. return Val.GetHashCode();
  1448. }
  1449. }
  1450. public struct Sc : IEquatable<Sc> {
  1451. public Sc(string s) {
  1452. S = s;
  1453. }
  1454. public string S;
  1455. public override bool Equals(object o) {
  1456. return (o is Sc) && Equals((Sc) o);
  1457. }
  1458. public bool Equals(Sc other) {
  1459. return other.S == S;
  1460. }
  1461. public override int GetHashCode() {
  1462. return S.GetHashCode();
  1463. }
  1464. }
  1465. public struct Scs : IEquatable<Scs> {
  1466. public Scs(string s, S val) {
  1467. S = s;
  1468. Val = val;
  1469. }
  1470. public string S;
  1471. public S Val;
  1472. public override bool Equals(object o) {
  1473. return (o is Scs) && Equals((Scs) o);
  1474. }
  1475. public bool Equals(Scs other) {
  1476. return other.S == S && other.Val.Equals(Val);
  1477. }
  1478. public override int GetHashCode() {
  1479. return S.GetHashCode() ^ Val.GetHashCode();
  1480. }
  1481. }
  1482. }
  1483. //-------- Scenario 1721
  1484. namespace Scenario1721{
  1485. public class Test
  1486. {
  1487. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check15__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  1488. public static Expression check15__() {
  1489. if(Main() != 0 ) {
  1490. throw new Exception();
  1491. } else {
  1492. return Expression.Constant(0);
  1493. }
  1494. }
  1495. public static int Main()
  1496. {
  1497. Ext.StartCapture();
  1498. bool success = false;
  1499. try
  1500. {
  1501. success = check15();
  1502. }
  1503. finally
  1504. {
  1505. Ext.StopCapture();
  1506. }
  1507. return success ? 0 : 1;
  1508. }
  1509. static bool check15() {
  1510. foreach (Ss val in new Ss[] { default(Ss), new Ss(), new Ss(new S()) }) {
  1511. if (!check15(val)) {
  1512. return false;
  1513. }
  1514. }
  1515. return true;
  1516. }
  1517. static bool check15(Ss val) {
  1518. Expression<Func<Ss>> e =
  1519. Expression.Lambda<Func<Ss>>(
  1520. Expression.Constant(val, typeof(Ss)),
  1521. new System.Collections.Generic.List<ParameterExpression>());
  1522. Func<Ss> f = e.Compile();
  1523. return object.Equals(f(), val);
  1524. }
  1525. }
  1526. public static class Ext {
  1527. public static void StartCapture() {
  1528. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1529. // m.Invoke(null, new object[] { "test.dll" });
  1530. }
  1531. public static void StopCapture() {
  1532. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1533. // m.Invoke(null, new object[0]);
  1534. }
  1535. public static bool IsIntegralOrEnum(Type type) {
  1536. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1537. case TypeCode.Byte:
  1538. case TypeCode.SByte:
  1539. case TypeCode.Int16:
  1540. case TypeCode.Int32:
  1541. case TypeCode.Int64:
  1542. case TypeCode.UInt16:
  1543. case TypeCode.UInt32:
  1544. case TypeCode.UInt64:
  1545. return true;
  1546. default:
  1547. return false;
  1548. }
  1549. }
  1550. public static bool IsFloating(Type type) {
  1551. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1552. case TypeCode.Single:
  1553. case TypeCode.Double:
  1554. return true;
  1555. default:
  1556. return false;
  1557. }
  1558. }
  1559. public static Type GetNonNullableType(Type type) {
  1560. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  1561. type.GetGenericArguments()[0] :
  1562. type;
  1563. }
  1564. }
  1565. public interface I {
  1566. void M();
  1567. }
  1568. public class C : IEquatable<C>, I {
  1569. void I.M() {
  1570. }
  1571. public override bool Equals(object o) {
  1572. return o is C && Equals((C) o);
  1573. }
  1574. public bool Equals(C c) {
  1575. return c != null;
  1576. }
  1577. public override int GetHashCode() {
  1578. return 0;
  1579. }
  1580. }
  1581. public class D : C, IEquatable<D> {
  1582. public int Val;
  1583. public D() {
  1584. }
  1585. public D(int val) {
  1586. Val = val;
  1587. }
  1588. public override bool Equals(object o) {
  1589. return o is D && Equals((D) o);
  1590. }
  1591. public bool Equals(D d) {
  1592. return d != null && d.Val == Val;
  1593. }
  1594. public override int GetHashCode() {
  1595. return Val;
  1596. }
  1597. }
  1598. public enum E {
  1599. A=1, B=2
  1600. }
  1601. public enum El : long {
  1602. A, B, C
  1603. }
  1604. public struct S : IEquatable<S> {
  1605. public override bool Equals(object o) {
  1606. return (o is S) && Equals((S) o);
  1607. }
  1608. public bool Equals(S other) {
  1609. return true;
  1610. }
  1611. public override int GetHashCode() {
  1612. return 0;
  1613. }
  1614. }
  1615. public struct Sp : IEquatable<Sp> {
  1616. public Sp(int i, double d) {
  1617. I = i;
  1618. D = d;
  1619. }
  1620. public int I;
  1621. public double D;
  1622. public override bool Equals(object o) {
  1623. return (o is Sp) && Equals((Sp) o);
  1624. }
  1625. public bool Equals(Sp other) {
  1626. return other.I == I && other.D == D;
  1627. }
  1628. public override int GetHashCode() {
  1629. return I.GetHashCode() ^ D.GetHashCode();
  1630. }
  1631. }
  1632. public struct Ss : IEquatable<Ss> {
  1633. public Ss(S s) {
  1634. Val = s;
  1635. }
  1636. public S Val;
  1637. public override bool Equals(object o) {
  1638. return (o is Ss) && Equals((Ss) o);
  1639. }
  1640. public bool Equals(Ss other) {
  1641. return other.Val.Equals(Val);
  1642. }
  1643. public override int GetHashCode() {
  1644. return Val.GetHashCode();
  1645. }
  1646. }
  1647. public struct Sc : IEquatable<Sc> {
  1648. public Sc(string s) {
  1649. S = s;
  1650. }
  1651. public string S;
  1652. public override bool Equals(object o) {
  1653. return (o is Sc) && Equals((Sc) o);
  1654. }
  1655. public bool Equals(Sc other) {
  1656. return other.S == S;
  1657. }
  1658. public override int GetHashCode() {
  1659. return S.GetHashCode();
  1660. }
  1661. }
  1662. public struct Scs : IEquatable<Scs> {
  1663. public Scs(string s, S val) {
  1664. S = s;
  1665. Val = val;
  1666. }
  1667. public string S;
  1668. public S Val;
  1669. public override bool Equals(object o) {
  1670. return (o is Scs) && Equals((Scs) o);
  1671. }
  1672. public bool Equals(Scs other) {
  1673. return other.S == S && other.Val.Equals(Val);
  1674. }
  1675. public override int GetHashCode() {
  1676. return S.GetHashCode() ^ Val.GetHashCode();
  1677. }
  1678. }
  1679. }
  1680. //-------- Scenario 1722
  1681. namespace Scenario1722{
  1682. public class Test
  1683. {
  1684. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check16__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  1685. public static Expression check16__() {
  1686. if(Main() != 0 ) {
  1687. throw new Exception();
  1688. } else {
  1689. return Expression.Constant(0);
  1690. }
  1691. }
  1692. public static int Main()
  1693. {
  1694. Ext.StartCapture();
  1695. bool success = false;
  1696. try
  1697. {
  1698. success = check16();
  1699. }
  1700. finally
  1701. {
  1702. Ext.StopCapture();
  1703. }
  1704. return success ? 0 : 1;
  1705. }
  1706. static bool check16() {
  1707. foreach (Sc val in new Sc[] { default(Sc), new Sc(), new Sc(null) }) {
  1708. if (!check16(val)) {
  1709. return false;
  1710. }
  1711. }
  1712. return true;
  1713. }
  1714. static bool check16(Sc val) {
  1715. Expression<Func<Sc>> e =
  1716. Expression.Lambda<Func<Sc>>(
  1717. Expression.Constant(val, typeof(Sc)),
  1718. new System.Collections.Generic.List<ParameterExpression>());
  1719. Func<Sc> f = e.Compile();
  1720. return object.Equals(f(), val);
  1721. }
  1722. }
  1723. public static class Ext {
  1724. public static void StartCapture() {
  1725. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1726. // m.Invoke(null, new object[] { "test.dll" });
  1727. }
  1728. public static void StopCapture() {
  1729. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1730. // m.Invoke(null, new object[0]);
  1731. }
  1732. public static bool IsIntegralOrEnum(Type type) {
  1733. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1734. case TypeCode.Byte:
  1735. case TypeCode.SByte:
  1736. case TypeCode.Int16:
  1737. case TypeCode.Int32:
  1738. case TypeCode.Int64:
  1739. case TypeCode.UInt16:
  1740. case TypeCode.UInt32:
  1741. case TypeCode.UInt64:
  1742. return true;
  1743. default:
  1744. return false;
  1745. }
  1746. }
  1747. public static bool IsFloating(Type type) {
  1748. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1749. case TypeCode.Single:
  1750. case TypeCode.Double:
  1751. return true;
  1752. default:
  1753. return false;
  1754. }
  1755. }
  1756. public static Type GetNonNullableType(Type type) {
  1757. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  1758. type.GetGenericArguments()[0] :
  1759. type;
  1760. }
  1761. }
  1762. public interface I {
  1763. void M();
  1764. }
  1765. public class C : IEquatable<C>, I {
  1766. void I.M() {
  1767. }
  1768. public override bool Equals(object o) {
  1769. return o is C && Equals((C) o);
  1770. }
  1771. public bool Equals(C c) {
  1772. return c != null;
  1773. }
  1774. public override int GetHashCode() {
  1775. return 0;
  1776. }
  1777. }
  1778. public class D : C, IEquatable<D> {
  1779. public int Val;
  1780. public D() {
  1781. }
  1782. public D(int val) {
  1783. Val = val;
  1784. }
  1785. public override bool Equals(object o) {
  1786. return o is D && Equals((D) o);
  1787. }
  1788. public bool Equals(D d) {
  1789. return d != null && d.Val == Val;
  1790. }
  1791. public override int GetHashCode() {
  1792. return Val;
  1793. }
  1794. }
  1795. public enum E {
  1796. A=1, B=2
  1797. }
  1798. public enum El : long {
  1799. A, B, C
  1800. }
  1801. public struct S : IEquatable<S> {
  1802. public override bool Equals(object o) {
  1803. return (o is S) && Equals((S) o);
  1804. }
  1805. public bool Equals(S other) {
  1806. return true;
  1807. }
  1808. public override int GetHashCode() {
  1809. return 0;
  1810. }
  1811. }
  1812. public struct Sp : IEquatable<Sp> {
  1813. public Sp(int i, double d) {
  1814. I = i;
  1815. D = d;
  1816. }
  1817. public int I;
  1818. public double D;
  1819. public override bool Equals(object o) {
  1820. return (o is Sp) && Equals((Sp) o);
  1821. }
  1822. public bool Equals(Sp other) {
  1823. return other.I == I && other.D == D;
  1824. }
  1825. public override int GetHashCode() {
  1826. return I.GetHashCode() ^ D.GetHashCode();
  1827. }
  1828. }
  1829. public struct Ss : IEquatable<Ss> {
  1830. public Ss(S s) {
  1831. Val = s;
  1832. }
  1833. public S Val;
  1834. public override bool Equals(object o) {
  1835. return (o is Ss) && Equals((Ss) o);
  1836. }
  1837. public bool Equals(Ss other) {
  1838. return other.Val.Equals(Val);
  1839. }
  1840. public override int GetHashCode() {
  1841. return Val.GetHashCode();
  1842. }
  1843. }
  1844. public struct Sc : IEquatable<Sc> {
  1845. public Sc(string s) {
  1846. S = s;
  1847. }
  1848. public string S;
  1849. public override bool Equals(object o) {
  1850. return (o is Sc) && Equals((Sc) o);
  1851. }
  1852. public bool Equals(Sc other) {
  1853. return other.S == S;
  1854. }
  1855. public override int GetHashCode() {
  1856. return S.GetHashCode();
  1857. }
  1858. }
  1859. public struct Scs : IEquatable<Scs> {
  1860. public Scs(string s, S val) {
  1861. S = s;
  1862. Val = val;
  1863. }
  1864. public string S;
  1865. public S Val;
  1866. public override bool Equals(object o) {
  1867. return (o is Scs) && Equals((Scs) o);
  1868. }
  1869. public bool Equals(Scs other) {
  1870. return other.S == S && other.Val.Equals(Val);
  1871. }
  1872. public override int GetHashCode() {
  1873. return S.GetHashCode() ^ Val.GetHashCode();
  1874. }
  1875. }
  1876. }
  1877. //-------- Scenario 1723
  1878. namespace Scenario1723{
  1879. public class Test
  1880. {
  1881. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check17__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  1882. public static Expression check17__() {
  1883. if(Main() != 0 ) {
  1884. throw new Exception();
  1885. } else {
  1886. return Expression.Constant(0);
  1887. }
  1888. }
  1889. public static int Main()
  1890. {
  1891. Ext.StartCapture();
  1892. bool success = false;
  1893. try
  1894. {
  1895. success = check17();
  1896. }
  1897. finally
  1898. {
  1899. Ext.StopCapture();
  1900. }
  1901. return success ? 0 : 1;
  1902. }
  1903. static bool check17() {
  1904. foreach (Scs val in new Scs[] { default(Scs), new Scs(), new Scs(null,new S()) }) {
  1905. if (!check17(val)) {
  1906. return false;
  1907. }
  1908. }
  1909. return true;
  1910. }
  1911. static bool check17(Scs val) {
  1912. Expression<Func<Scs>> e =
  1913. Expression.Lambda<Func<Scs>>(
  1914. Expression.Constant(val, typeof(Scs)),
  1915. new System.Collections.Generic.List<ParameterExpression>());
  1916. Func<Scs> f = e.Compile();
  1917. return object.Equals(f(), val);
  1918. }
  1919. }
  1920. public static class Ext {
  1921. public static void StartCapture() {
  1922. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1923. // m.Invoke(null, new object[] { "test.dll" });
  1924. }
  1925. public static void StopCapture() {
  1926. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  1927. // m.Invoke(null, new object[0]);
  1928. }
  1929. public static bool IsIntegralOrEnum(Type type) {
  1930. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1931. case TypeCode.Byte:
  1932. case TypeCode.SByte:
  1933. case TypeCode.Int16:
  1934. case TypeCode.Int32:
  1935. case TypeCode.Int64:
  1936. case TypeCode.UInt16:
  1937. case TypeCode.UInt32:
  1938. case TypeCode.UInt64:
  1939. return true;
  1940. default:
  1941. return false;
  1942. }
  1943. }
  1944. public static bool IsFloating(Type type) {
  1945. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  1946. case TypeCode.Single:
  1947. case TypeCode.Double:
  1948. return true;
  1949. default:
  1950. return false;
  1951. }
  1952. }
  1953. public static Type GetNonNullableType(Type type) {
  1954. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  1955. type.GetGenericArguments()[0] :
  1956. type;
  1957. }
  1958. }
  1959. public interface I {
  1960. void M();
  1961. }
  1962. public class C : IEquatable<C>, I {
  1963. void I.M() {
  1964. }
  1965. public override bool Equals(object o) {
  1966. return o is C && Equals((C) o);
  1967. }
  1968. public bool Equals(C c) {
  1969. return c != null;
  1970. }
  1971. public override int GetHashCode() {
  1972. return 0;
  1973. }
  1974. }
  1975. public class D : C, IEquatable<D> {
  1976. public int Val;
  1977. public D() {
  1978. }
  1979. public D(int val) {
  1980. Val = val;
  1981. }
  1982. public override bool Equals(object o) {
  1983. return o is D && Equals((D) o);
  1984. }
  1985. public bool Equals(D d) {
  1986. return d != null && d.Val == Val;
  1987. }
  1988. public override int GetHashCode() {
  1989. return Val;
  1990. }
  1991. }
  1992. public enum E {
  1993. A=1, B=2
  1994. }
  1995. public enum El : long {
  1996. A, B, C
  1997. }
  1998. public struct S : IEquatable<S> {
  1999. public override bool Equals(object o) {
  2000. return (o is S) && Equals((S) o);
  2001. }
  2002. public bool Equals(S other) {
  2003. return true;
  2004. }
  2005. public override int GetHashCode() {
  2006. return 0;
  2007. }
  2008. }
  2009. public struct Sp : IEquatable<Sp> {
  2010. public Sp(int i, double d) {
  2011. I = i;
  2012. D = d;
  2013. }
  2014. public int I;
  2015. public double D;
  2016. public override bool Equals(object o) {
  2017. return (o is Sp) && Equals((Sp) o);
  2018. }
  2019. public bool Equals(Sp other) {
  2020. return other.I == I && other.D == D;
  2021. }
  2022. public override int GetHashCode() {
  2023. return I.GetHashCode() ^ D.GetHashCode();
  2024. }
  2025. }
  2026. public struct Ss : IEquatable<Ss> {
  2027. public Ss(S s) {
  2028. Val = s;
  2029. }
  2030. public S Val;
  2031. public override bool Equals(object o) {
  2032. return (o is Ss) && Equals((Ss) o);
  2033. }
  2034. public bool Equals(Ss other) {
  2035. return other.Val.Equals(Val);
  2036. }
  2037. public override int GetHashCode() {
  2038. return Val.GetHashCode();
  2039. }
  2040. }
  2041. public struct Sc : IEquatable<Sc> {
  2042. public Sc(string s) {
  2043. S = s;
  2044. }
  2045. public string S;
  2046. public override bool Equals(object o) {
  2047. return (o is Sc) && Equals((Sc) o);
  2048. }
  2049. public bool Equals(Sc other) {
  2050. return other.S == S;
  2051. }
  2052. public override int GetHashCode() {
  2053. return S.GetHashCode();
  2054. }
  2055. }
  2056. public struct Scs : IEquatable<Scs> {
  2057. public Scs(string s, S val) {
  2058. S = s;
  2059. Val = val;
  2060. }
  2061. public string S;
  2062. public S Val;
  2063. public override bool Equals(object o) {
  2064. return (o is Scs) && Equals((Scs) o);
  2065. }
  2066. public bool Equals(Scs other) {
  2067. return other.S == S && other.Val.Equals(Val);
  2068. }
  2069. public override int GetHashCode() {
  2070. return S.GetHashCode() ^ Val.GetHashCode();
  2071. }
  2072. }
  2073. }
  2074. //-------- Scenario 1724
  2075. namespace Scenario1724{
  2076. public class Test
  2077. {
  2078. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check18_S___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  2079. public static Expression check18_S___() {
  2080. if(Main() != 0 ) {
  2081. throw new Exception();
  2082. } else {
  2083. return Expression.Constant(0);
  2084. }
  2085. }
  2086. public static int Main()
  2087. {
  2088. Ext.StartCapture();
  2089. bool success = false;
  2090. try
  2091. {
  2092. success = check18<S>();
  2093. }
  2094. finally
  2095. {
  2096. Ext.StopCapture();
  2097. }
  2098. return success ? 0 : 1;
  2099. }
  2100. static bool check18<Ts>() where Ts : struct {
  2101. foreach (Ts val in new Ts[] { default(Ts), new Ts() }) {
  2102. if (!check18<Ts>(val)) {
  2103. return false;
  2104. }
  2105. }
  2106. return true;
  2107. }
  2108. static bool check18<Ts>(Ts val) where Ts : struct {
  2109. Expression<Func<Ts>> e =
  2110. Expression.Lambda<Func<Ts>>(
  2111. Expression.Constant(val, typeof(Ts)),
  2112. new System.Collections.Generic.List<ParameterExpression>());
  2113. Func<Ts> f = e.Compile();
  2114. return object.Equals(f(), val);
  2115. }
  2116. }
  2117. public static class Ext {
  2118. public static void StartCapture() {
  2119. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2120. // m.Invoke(null, new object[] { "test.dll" });
  2121. }
  2122. public static void StopCapture() {
  2123. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2124. // m.Invoke(null, new object[0]);
  2125. }
  2126. public static bool IsIntegralOrEnum(Type type) {
  2127. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2128. case TypeCode.Byte:
  2129. case TypeCode.SByte:
  2130. case TypeCode.Int16:
  2131. case TypeCode.Int32:
  2132. case TypeCode.Int64:
  2133. case TypeCode.UInt16:
  2134. case TypeCode.UInt32:
  2135. case TypeCode.UInt64:
  2136. return true;
  2137. default:
  2138. return false;
  2139. }
  2140. }
  2141. public static bool IsFloating(Type type) {
  2142. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2143. case TypeCode.Single:
  2144. case TypeCode.Double:
  2145. return true;
  2146. default:
  2147. return false;
  2148. }
  2149. }
  2150. public static Type GetNonNullableType(Type type) {
  2151. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  2152. type.GetGenericArguments()[0] :
  2153. type;
  2154. }
  2155. }
  2156. public interface I {
  2157. void M();
  2158. }
  2159. public class C : IEquatable<C>, I {
  2160. void I.M() {
  2161. }
  2162. public override bool Equals(object o) {
  2163. return o is C && Equals((C) o);
  2164. }
  2165. public bool Equals(C c) {
  2166. return c != null;
  2167. }
  2168. public override int GetHashCode() {
  2169. return 0;
  2170. }
  2171. }
  2172. public class D : C, IEquatable<D> {
  2173. public int Val;
  2174. public D() {
  2175. }
  2176. public D(int val) {
  2177. Val = val;
  2178. }
  2179. public override bool Equals(object o) {
  2180. return o is D && Equals((D) o);
  2181. }
  2182. public bool Equals(D d) {
  2183. return d != null && d.Val == Val;
  2184. }
  2185. public override int GetHashCode() {
  2186. return Val;
  2187. }
  2188. }
  2189. public enum E {
  2190. A=1, B=2
  2191. }
  2192. public enum El : long {
  2193. A, B, C
  2194. }
  2195. public struct S : IEquatable<S> {
  2196. public override bool Equals(object o) {
  2197. return (o is S) && Equals((S) o);
  2198. }
  2199. public bool Equals(S other) {
  2200. return true;
  2201. }
  2202. public override int GetHashCode() {
  2203. return 0;
  2204. }
  2205. }
  2206. public struct Sp : IEquatable<Sp> {
  2207. public Sp(int i, double d) {
  2208. I = i;
  2209. D = d;
  2210. }
  2211. public int I;
  2212. public double D;
  2213. public override bool Equals(object o) {
  2214. return (o is Sp) && Equals((Sp) o);
  2215. }
  2216. public bool Equals(Sp other) {
  2217. return other.I == I && other.D == D;
  2218. }
  2219. public override int GetHashCode() {
  2220. return I.GetHashCode() ^ D.GetHashCode();
  2221. }
  2222. }
  2223. public struct Ss : IEquatable<Ss> {
  2224. public Ss(S s) {
  2225. Val = s;
  2226. }
  2227. public S Val;
  2228. public override bool Equals(object o) {
  2229. return (o is Ss) && Equals((Ss) o);
  2230. }
  2231. public bool Equals(Ss other) {
  2232. return other.Val.Equals(Val);
  2233. }
  2234. public override int GetHashCode() {
  2235. return Val.GetHashCode();
  2236. }
  2237. }
  2238. public struct Sc : IEquatable<Sc> {
  2239. public Sc(string s) {
  2240. S = s;
  2241. }
  2242. public string S;
  2243. public override bool Equals(object o) {
  2244. return (o is Sc) && Equals((Sc) o);
  2245. }
  2246. public bool Equals(Sc other) {
  2247. return other.S == S;
  2248. }
  2249. public override int GetHashCode() {
  2250. return S.GetHashCode();
  2251. }
  2252. }
  2253. public struct Scs : IEquatable<Scs> {
  2254. public Scs(string s, S val) {
  2255. S = s;
  2256. Val = val;
  2257. }
  2258. public string S;
  2259. public S Val;
  2260. public override bool Equals(object o) {
  2261. return (o is Scs) && Equals((Scs) o);
  2262. }
  2263. public bool Equals(Scs other) {
  2264. return other.S == S && other.Val.Equals(Val);
  2265. }
  2266. public override int GetHashCode() {
  2267. return S.GetHashCode() ^ Val.GetHashCode();
  2268. }
  2269. }
  2270. }
  2271. //-------- Scenario 1725
  2272. namespace Scenario1725{
  2273. public class Test
  2274. {
  2275. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check18_Scs___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  2276. public static Expression check18_Scs___() {
  2277. if(Main() != 0 ) {
  2278. throw new Exception();
  2279. } else {
  2280. return Expression.Constant(0);
  2281. }
  2282. }
  2283. public static int Main()
  2284. {
  2285. Ext.StartCapture();
  2286. bool success = false;
  2287. try
  2288. {
  2289. success = check18<Scs>();
  2290. }
  2291. finally
  2292. {
  2293. Ext.StopCapture();
  2294. }
  2295. return success ? 0 : 1;
  2296. }
  2297. static bool check18<Ts>() where Ts : struct {
  2298. foreach (Ts val in new Ts[] { default(Ts), new Ts() }) {
  2299. if (!check18<Ts>(val)) {
  2300. return false;
  2301. }
  2302. }
  2303. return true;
  2304. }
  2305. static bool check18<Ts>(Ts val) where Ts : struct {
  2306. Expression<Func<Ts>> e =
  2307. Expression.Lambda<Func<Ts>>(
  2308. Expression.Constant(val, typeof(Ts)),
  2309. new System.Collections.Generic.List<ParameterExpression>());
  2310. Func<Ts> f = e.Compile();
  2311. return object.Equals(f(), val);
  2312. }
  2313. }
  2314. public static class Ext {
  2315. public static void StartCapture() {
  2316. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2317. // m.Invoke(null, new object[] { "test.dll" });
  2318. }
  2319. public static void StopCapture() {
  2320. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2321. // m.Invoke(null, new object[0]);
  2322. }
  2323. public static bool IsIntegralOrEnum(Type type) {
  2324. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2325. case TypeCode.Byte:
  2326. case TypeCode.SByte:
  2327. case TypeCode.Int16:
  2328. case TypeCode.Int32:
  2329. case TypeCode.Int64:
  2330. case TypeCode.UInt16:
  2331. case TypeCode.UInt32:
  2332. case TypeCode.UInt64:
  2333. return true;
  2334. default:
  2335. return false;
  2336. }
  2337. }
  2338. public static bool IsFloating(Type type) {
  2339. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2340. case TypeCode.Single:
  2341. case TypeCode.Double:
  2342. return true;
  2343. default:
  2344. return false;
  2345. }
  2346. }
  2347. public static Type GetNonNullableType(Type type) {
  2348. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  2349. type.GetGenericArguments()[0] :
  2350. type;
  2351. }
  2352. }
  2353. public interface I {
  2354. void M();
  2355. }
  2356. public class C : IEquatable<C>, I {
  2357. void I.M() {
  2358. }
  2359. public override bool Equals(object o) {
  2360. return o is C && Equals((C) o);
  2361. }
  2362. public bool Equals(C c) {
  2363. return c != null;
  2364. }
  2365. public override int GetHashCode() {
  2366. return 0;
  2367. }
  2368. }
  2369. public class D : C, IEquatable<D> {
  2370. public int Val;
  2371. public D() {
  2372. }
  2373. public D(int val) {
  2374. Val = val;
  2375. }
  2376. public override bool Equals(object o) {
  2377. return o is D && Equals((D) o);
  2378. }
  2379. public bool Equals(D d) {
  2380. return d != null && d.Val == Val;
  2381. }
  2382. public override int GetHashCode() {
  2383. return Val;
  2384. }
  2385. }
  2386. public enum E {
  2387. A=1, B=2
  2388. }
  2389. public enum El : long {
  2390. A, B, C
  2391. }
  2392. public struct S : IEquatable<S> {
  2393. public override bool Equals(object o) {
  2394. return (o is S) && Equals((S) o);
  2395. }
  2396. public bool Equals(S other) {
  2397. return true;
  2398. }
  2399. public override int GetHashCode() {
  2400. return 0;
  2401. }
  2402. }
  2403. public struct Sp : IEquatable<Sp> {
  2404. public Sp(int i, double d) {
  2405. I = i;
  2406. D = d;
  2407. }
  2408. public int I;
  2409. public double D;
  2410. public override bool Equals(object o) {
  2411. return (o is Sp) && Equals((Sp) o);
  2412. }
  2413. public bool Equals(Sp other) {
  2414. return other.I == I && other.D == D;
  2415. }
  2416. public override int GetHashCode() {
  2417. return I.GetHashCode() ^ D.GetHashCode();
  2418. }
  2419. }
  2420. public struct Ss : IEquatable<Ss> {
  2421. public Ss(S s) {
  2422. Val = s;
  2423. }
  2424. public S Val;
  2425. public override bool Equals(object o) {
  2426. return (o is Ss) && Equals((Ss) o);
  2427. }
  2428. public bool Equals(Ss other) {
  2429. return other.Val.Equals(Val);
  2430. }
  2431. public override int GetHashCode() {
  2432. return Val.GetHashCode();
  2433. }
  2434. }
  2435. public struct Sc : IEquatable<Sc> {
  2436. public Sc(string s) {
  2437. S = s;
  2438. }
  2439. public string S;
  2440. public override bool Equals(object o) {
  2441. return (o is Sc) && Equals((Sc) o);
  2442. }
  2443. public bool Equals(Sc other) {
  2444. return other.S == S;
  2445. }
  2446. public override int GetHashCode() {
  2447. return S.GetHashCode();
  2448. }
  2449. }
  2450. public struct Scs : IEquatable<Scs> {
  2451. public Scs(string s, S val) {
  2452. S = s;
  2453. Val = val;
  2454. }
  2455. public string S;
  2456. public S Val;
  2457. public override bool Equals(object o) {
  2458. return (o is Scs) && Equals((Scs) o);
  2459. }
  2460. public bool Equals(Scs other) {
  2461. return other.S == S && other.Val.Equals(Val);
  2462. }
  2463. public override int GetHashCode() {
  2464. return S.GetHashCode() ^ Val.GetHashCode();
  2465. }
  2466. }
  2467. }
  2468. //-------- Scenario 1726
  2469. namespace Scenario1726{
  2470. public class Test
  2471. {
  2472. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check18_E___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  2473. public static Expression check18_E___() {
  2474. if(Main() != 0 ) {
  2475. throw new Exception();
  2476. } else {
  2477. return Expression.Constant(0);
  2478. }
  2479. }
  2480. public static int Main()
  2481. {
  2482. Ext.StartCapture();
  2483. bool success = false;
  2484. try
  2485. {
  2486. success = check18<E>();
  2487. }
  2488. finally
  2489. {
  2490. Ext.StopCapture();
  2491. }
  2492. return success ? 0 : 1;
  2493. }
  2494. static bool check18<Ts>() where Ts : struct {
  2495. foreach (Ts val in new Ts[] { default(Ts), new Ts() }) {
  2496. if (!check18<Ts>(val)) {
  2497. return false;
  2498. }
  2499. }
  2500. return true;
  2501. }
  2502. static bool check18<Ts>(Ts val) where Ts : struct {
  2503. Expression<Func<Ts>> e =
  2504. Expression.Lambda<Func<Ts>>(
  2505. Expression.Constant(val, typeof(Ts)),
  2506. new System.Collections.Generic.List<ParameterExpression>());
  2507. Func<Ts> f = e.Compile();
  2508. return object.Equals(f(), val);
  2509. }
  2510. }
  2511. public static class Ext {
  2512. public static void StartCapture() {
  2513. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2514. // m.Invoke(null, new object[] { "test.dll" });
  2515. }
  2516. public static void StopCapture() {
  2517. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2518. // m.Invoke(null, new object[0]);
  2519. }
  2520. public static bool IsIntegralOrEnum(Type type) {
  2521. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2522. case TypeCode.Byte:
  2523. case TypeCode.SByte:
  2524. case TypeCode.Int16:
  2525. case TypeCode.Int32:
  2526. case TypeCode.Int64:
  2527. case TypeCode.UInt16:
  2528. case TypeCode.UInt32:
  2529. case TypeCode.UInt64:
  2530. return true;
  2531. default:
  2532. return false;
  2533. }
  2534. }
  2535. public static bool IsFloating(Type type) {
  2536. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2537. case TypeCode.Single:
  2538. case TypeCode.Double:
  2539. return true;
  2540. default:
  2541. return false;
  2542. }
  2543. }
  2544. public static Type GetNonNullableType(Type type) {
  2545. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  2546. type.GetGenericArguments()[0] :
  2547. type;
  2548. }
  2549. }
  2550. public interface I {
  2551. void M();
  2552. }
  2553. public class C : IEquatable<C>, I {
  2554. void I.M() {
  2555. }
  2556. public override bool Equals(object o) {
  2557. return o is C && Equals((C) o);
  2558. }
  2559. public bool Equals(C c) {
  2560. return c != null;
  2561. }
  2562. public override int GetHashCode() {
  2563. return 0;
  2564. }
  2565. }
  2566. public class D : C, IEquatable<D> {
  2567. public int Val;
  2568. public D() {
  2569. }
  2570. public D(int val) {
  2571. Val = val;
  2572. }
  2573. public override bool Equals(object o) {
  2574. return o is D && Equals((D) o);
  2575. }
  2576. public bool Equals(D d) {
  2577. return d != null && d.Val == Val;
  2578. }
  2579. public override int GetHashCode() {
  2580. return Val;
  2581. }
  2582. }
  2583. public enum E {
  2584. A=1, B=2
  2585. }
  2586. public enum El : long {
  2587. A, B, C
  2588. }
  2589. public struct S : IEquatable<S> {
  2590. public override bool Equals(object o) {
  2591. return (o is S) && Equals((S) o);
  2592. }
  2593. public bool Equals(S other) {
  2594. return true;
  2595. }
  2596. public override int GetHashCode() {
  2597. return 0;
  2598. }
  2599. }
  2600. public struct Sp : IEquatable<Sp> {
  2601. public Sp(int i, double d) {
  2602. I = i;
  2603. D = d;
  2604. }
  2605. public int I;
  2606. public double D;
  2607. public override bool Equals(object o) {
  2608. return (o is Sp) && Equals((Sp) o);
  2609. }
  2610. public bool Equals(Sp other) {
  2611. return other.I == I && other.D == D;
  2612. }
  2613. public override int GetHashCode() {
  2614. return I.GetHashCode() ^ D.GetHashCode();
  2615. }
  2616. }
  2617. public struct Ss : IEquatable<Ss> {
  2618. public Ss(S s) {
  2619. Val = s;
  2620. }
  2621. public S Val;
  2622. public override bool Equals(object o) {
  2623. return (o is Ss) && Equals((Ss) o);
  2624. }
  2625. public bool Equals(Ss other) {
  2626. return other.Val.Equals(Val);
  2627. }
  2628. public override int GetHashCode() {
  2629. return Val.GetHashCode();
  2630. }
  2631. }
  2632. public struct Sc : IEquatable<Sc> {
  2633. public Sc(string s) {
  2634. S = s;
  2635. }
  2636. public string S;
  2637. public override bool Equals(object o) {
  2638. return (o is Sc) && Equals((Sc) o);
  2639. }
  2640. public bool Equals(Sc other) {
  2641. return other.S == S;
  2642. }
  2643. public override int GetHashCode() {
  2644. return S.GetHashCode();
  2645. }
  2646. }
  2647. public struct Scs : IEquatable<Scs> {
  2648. public Scs(string s, S val) {
  2649. S = s;
  2650. Val = val;
  2651. }
  2652. public string S;
  2653. public S Val;
  2654. public override bool Equals(object o) {
  2655. return (o is Scs) && Equals((Scs) o);
  2656. }
  2657. public bool Equals(Scs other) {
  2658. return other.S == S && other.Val.Equals(Val);
  2659. }
  2660. public override int GetHashCode() {
  2661. return S.GetHashCode() ^ Val.GetHashCode();
  2662. }
  2663. }
  2664. }
  2665. //-------- Scenario 1727
  2666. namespace Scenario1727{
  2667. public class Test
  2668. {
  2669. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check19__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  2670. public static Expression check19__() {
  2671. if(Main() != 0 ) {
  2672. throw new Exception();
  2673. } else {
  2674. return Expression.Constant(0);
  2675. }
  2676. }
  2677. public static int Main()
  2678. {
  2679. Ext.StartCapture();
  2680. bool success = false;
  2681. try
  2682. {
  2683. success = check19();
  2684. }
  2685. finally
  2686. {
  2687. Ext.StopCapture();
  2688. }
  2689. return success ? 0 : 1;
  2690. }
  2691. static bool check19() {
  2692. foreach (E val in new E[] { (E) 0, E.A, E.B, (E) int.MaxValue, (E) int.MinValue }) {
  2693. if (!check19(val)) {
  2694. return false;
  2695. }
  2696. }
  2697. return true;
  2698. }
  2699. static bool check19(E val) {
  2700. Expression<Func<E>> e =
  2701. Expression.Lambda<Func<E>>(
  2702. Expression.Constant(val, typeof(E)),
  2703. new System.Collections.Generic.List<ParameterExpression>());
  2704. Func<E> f = e.Compile();
  2705. return object.Equals(f(), val);
  2706. }
  2707. }
  2708. public static class Ext {
  2709. public static void StartCapture() {
  2710. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2711. // m.Invoke(null, new object[] { "test.dll" });
  2712. }
  2713. public static void StopCapture() {
  2714. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2715. // m.Invoke(null, new object[0]);
  2716. }
  2717. public static bool IsIntegralOrEnum(Type type) {
  2718. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2719. case TypeCode.Byte:
  2720. case TypeCode.SByte:
  2721. case TypeCode.Int16:
  2722. case TypeCode.Int32:
  2723. case TypeCode.Int64:
  2724. case TypeCode.UInt16:
  2725. case TypeCode.UInt32:
  2726. case TypeCode.UInt64:
  2727. return true;
  2728. default:
  2729. return false;
  2730. }
  2731. }
  2732. public static bool IsFloating(Type type) {
  2733. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2734. case TypeCode.Single:
  2735. case TypeCode.Double:
  2736. return true;
  2737. default:
  2738. return false;
  2739. }
  2740. }
  2741. public static Type GetNonNullableType(Type type) {
  2742. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  2743. type.GetGenericArguments()[0] :
  2744. type;
  2745. }
  2746. }
  2747. public interface I {
  2748. void M();
  2749. }
  2750. public class C : IEquatable<C>, I {
  2751. void I.M() {
  2752. }
  2753. public override bool Equals(object o) {
  2754. return o is C && Equals((C) o);
  2755. }
  2756. public bool Equals(C c) {
  2757. return c != null;
  2758. }
  2759. public override int GetHashCode() {
  2760. return 0;
  2761. }
  2762. }
  2763. public class D : C, IEquatable<D> {
  2764. public int Val;
  2765. public D() {
  2766. }
  2767. public D(int val) {
  2768. Val = val;
  2769. }
  2770. public override bool Equals(object o) {
  2771. return o is D && Equals((D) o);
  2772. }
  2773. public bool Equals(D d) {
  2774. return d != null && d.Val == Val;
  2775. }
  2776. public override int GetHashCode() {
  2777. return Val;
  2778. }
  2779. }
  2780. public enum E {
  2781. A=1, B=2
  2782. }
  2783. public enum El : long {
  2784. A, B, C
  2785. }
  2786. public struct S : IEquatable<S> {
  2787. public override bool Equals(object o) {
  2788. return (o is S) && Equals((S) o);
  2789. }
  2790. public bool Equals(S other) {
  2791. return true;
  2792. }
  2793. public override int GetHashCode() {
  2794. return 0;
  2795. }
  2796. }
  2797. public struct Sp : IEquatable<Sp> {
  2798. public Sp(int i, double d) {
  2799. I = i;
  2800. D = d;
  2801. }
  2802. public int I;
  2803. public double D;
  2804. public override bool Equals(object o) {
  2805. return (o is Sp) && Equals((Sp) o);
  2806. }
  2807. public bool Equals(Sp other) {
  2808. return other.I == I && other.D == D;
  2809. }
  2810. public override int GetHashCode() {
  2811. return I.GetHashCode() ^ D.GetHashCode();
  2812. }
  2813. }
  2814. public struct Ss : IEquatable<Ss> {
  2815. public Ss(S s) {
  2816. Val = s;
  2817. }
  2818. public S Val;
  2819. public override bool Equals(object o) {
  2820. return (o is Ss) && Equals((Ss) o);
  2821. }
  2822. public bool Equals(Ss other) {
  2823. return other.Val.Equals(Val);
  2824. }
  2825. public override int GetHashCode() {
  2826. return Val.GetHashCode();
  2827. }
  2828. }
  2829. public struct Sc : IEquatable<Sc> {
  2830. public Sc(string s) {
  2831. S = s;
  2832. }
  2833. public string S;
  2834. public override bool Equals(object o) {
  2835. return (o is Sc) && Equals((Sc) o);
  2836. }
  2837. public bool Equals(Sc other) {
  2838. return other.S == S;
  2839. }
  2840. public override int GetHashCode() {
  2841. return S.GetHashCode();
  2842. }
  2843. }
  2844. public struct Scs : IEquatable<Scs> {
  2845. public Scs(string s, S val) {
  2846. S = s;
  2847. Val = val;
  2848. }
  2849. public string S;
  2850. public S Val;
  2851. public override bool Equals(object o) {
  2852. return (o is Scs) && Equals((Scs) o);
  2853. }
  2854. public bool Equals(Scs other) {
  2855. return other.S == S && other.Val.Equals(Val);
  2856. }
  2857. public override int GetHashCode() {
  2858. return S.GetHashCode() ^ Val.GetHashCode();
  2859. }
  2860. }
  2861. }
  2862. //-------- Scenario 1728
  2863. namespace Scenario1728{
  2864. public class Test
  2865. {
  2866. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check20__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  2867. public static Expression check20__() {
  2868. if(Main() != 0 ) {
  2869. throw new Exception();
  2870. } else {
  2871. return Expression.Constant(0);
  2872. }
  2873. }
  2874. public static int Main()
  2875. {
  2876. Ext.StartCapture();
  2877. bool success = false;
  2878. try
  2879. {
  2880. success = check20();
  2881. }
  2882. finally
  2883. {
  2884. Ext.StopCapture();
  2885. }
  2886. return success ? 0 : 1;
  2887. }
  2888. static bool check20() {
  2889. foreach (El val in new El[] { (El) 0, El.A, El.B, (El) long.MaxValue, (El) long.MinValue }) {
  2890. if (!check20(val)) {
  2891. return false;
  2892. }
  2893. }
  2894. return true;
  2895. }
  2896. static bool check20(El val) {
  2897. Expression<Func<El>> e =
  2898. Expression.Lambda<Func<El>>(
  2899. Expression.Constant(val, typeof(El)),
  2900. new System.Collections.Generic.List<ParameterExpression>());
  2901. Func<El> f = e.Compile();
  2902. return object.Equals(f(), val);
  2903. }
  2904. }
  2905. public static class Ext {
  2906. public static void StartCapture() {
  2907. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2908. // m.Invoke(null, new object[] { "test.dll" });
  2909. }
  2910. public static void StopCapture() {
  2911. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  2912. // m.Invoke(null, new object[0]);
  2913. }
  2914. public static bool IsIntegralOrEnum(Type type) {
  2915. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2916. case TypeCode.Byte:
  2917. case TypeCode.SByte:
  2918. case TypeCode.Int16:
  2919. case TypeCode.Int32:
  2920. case TypeCode.Int64:
  2921. case TypeCode.UInt16:
  2922. case TypeCode.UInt32:
  2923. case TypeCode.UInt64:
  2924. return true;
  2925. default:
  2926. return false;
  2927. }
  2928. }
  2929. public static bool IsFloating(Type type) {
  2930. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  2931. case TypeCode.Single:
  2932. case TypeCode.Double:
  2933. return true;
  2934. default:
  2935. return false;
  2936. }
  2937. }
  2938. public static Type GetNonNullableType(Type type) {
  2939. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  2940. type.GetGenericArguments()[0] :
  2941. type;
  2942. }
  2943. }
  2944. public interface I {
  2945. void M();
  2946. }
  2947. public class C : IEquatable<C>, I {
  2948. void I.M() {
  2949. }
  2950. public override bool Equals(object o) {
  2951. return o is C && Equals((C) o);
  2952. }
  2953. public bool Equals(C c) {
  2954. return c != null;
  2955. }
  2956. public override int GetHashCode() {
  2957. return 0;
  2958. }
  2959. }
  2960. public class D : C, IEquatable<D> {
  2961. public int Val;
  2962. public D() {
  2963. }
  2964. public D(int val) {
  2965. Val = val;
  2966. }
  2967. public override bool Equals(object o) {
  2968. return o is D && Equals((D) o);
  2969. }
  2970. public bool Equals(D d) {
  2971. return d != null && d.Val == Val;
  2972. }
  2973. public override int GetHashCode() {
  2974. return Val;
  2975. }
  2976. }
  2977. public enum E {
  2978. A=1, B=2
  2979. }
  2980. public enum El : long {
  2981. A, B, C
  2982. }
  2983. public struct S : IEquatable<S> {
  2984. public override bool Equals(object o) {
  2985. return (o is S) && Equals((S) o);
  2986. }
  2987. public bool Equals(S other) {
  2988. return true;
  2989. }
  2990. public override int GetHashCode() {
  2991. return 0;
  2992. }
  2993. }
  2994. public struct Sp : IEquatable<Sp> {
  2995. public Sp(int i, double d) {
  2996. I = i;
  2997. D = d;
  2998. }
  2999. public int I;
  3000. public double D;
  3001. public override bool Equals(object o) {
  3002. return (o is Sp) && Equals((Sp) o);
  3003. }
  3004. public bool Equals(Sp other) {
  3005. return other.I == I && other.D == D;
  3006. }
  3007. public override int GetHashCode() {
  3008. return I.GetHashCode() ^ D.GetHashCode();
  3009. }
  3010. }
  3011. public struct Ss : IEquatable<Ss> {
  3012. public Ss(S s) {
  3013. Val = s;
  3014. }
  3015. public S Val;
  3016. public override bool Equals(object o) {
  3017. return (o is Ss) && Equals((Ss) o);
  3018. }
  3019. public bool Equals(Ss other) {
  3020. return other.Val.Equals(Val);
  3021. }
  3022. public override int GetHashCode() {
  3023. return Val.GetHashCode();
  3024. }
  3025. }
  3026. public struct Sc : IEquatable<Sc> {
  3027. public Sc(string s) {
  3028. S = s;
  3029. }
  3030. public string S;
  3031. public override bool Equals(object o) {
  3032. return (o is Sc) && Equals((Sc) o);
  3033. }
  3034. public bool Equals(Sc other) {
  3035. return other.S == S;
  3036. }
  3037. public override int GetHashCode() {
  3038. return S.GetHashCode();
  3039. }
  3040. }
  3041. public struct Scs : IEquatable<Scs> {
  3042. public Scs(string s, S val) {
  3043. S = s;
  3044. Val = val;
  3045. }
  3046. public string S;
  3047. public S Val;
  3048. public override bool Equals(object o) {
  3049. return (o is Scs) && Equals((Scs) o);
  3050. }
  3051. public bool Equals(Scs other) {
  3052. return other.S == S && other.Val.Equals(Val);
  3053. }
  3054. public override int GetHashCode() {
  3055. return S.GetHashCode() ^ Val.GetHashCode();
  3056. }
  3057. }
  3058. }
  3059. //-------- Scenario 1729
  3060. namespace Scenario1729{
  3061. public class Test
  3062. {
  3063. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check21__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  3064. public static Expression check21__() {
  3065. if(Main() != 0 ) {
  3066. throw new Exception();
  3067. } else {
  3068. return Expression.Constant(0);
  3069. }
  3070. }
  3071. public static int Main()
  3072. {
  3073. Ext.StartCapture();
  3074. bool success = false;
  3075. try
  3076. {
  3077. success = check21();
  3078. }
  3079. finally
  3080. {
  3081. Ext.StopCapture();
  3082. }
  3083. return success ? 0 : 1;
  3084. }
  3085. static bool check21() {
  3086. foreach (string val in new string[] { null, "", "a", "foo" }) {
  3087. if (!check21(val)) {
  3088. return false;
  3089. }
  3090. }
  3091. return true;
  3092. }
  3093. static bool check21(string val) {
  3094. Expression<Func<string>> e =
  3095. Expression.Lambda<Func<string>>(
  3096. Expression.Constant(val, typeof(string)),
  3097. new System.Collections.Generic.List<ParameterExpression>());
  3098. Func<string> f = e.Compile();
  3099. return object.Equals(f(), val);
  3100. }
  3101. }
  3102. public static class Ext {
  3103. public static void StartCapture() {
  3104. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3105. // m.Invoke(null, new object[] { "test.dll" });
  3106. }
  3107. public static void StopCapture() {
  3108. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3109. // m.Invoke(null, new object[0]);
  3110. }
  3111. public static bool IsIntegralOrEnum(Type type) {
  3112. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3113. case TypeCode.Byte:
  3114. case TypeCode.SByte:
  3115. case TypeCode.Int16:
  3116. case TypeCode.Int32:
  3117. case TypeCode.Int64:
  3118. case TypeCode.UInt16:
  3119. case TypeCode.UInt32:
  3120. case TypeCode.UInt64:
  3121. return true;
  3122. default:
  3123. return false;
  3124. }
  3125. }
  3126. public static bool IsFloating(Type type) {
  3127. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3128. case TypeCode.Single:
  3129. case TypeCode.Double:
  3130. return true;
  3131. default:
  3132. return false;
  3133. }
  3134. }
  3135. public static Type GetNonNullableType(Type type) {
  3136. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  3137. type.GetGenericArguments()[0] :
  3138. type;
  3139. }
  3140. }
  3141. }
  3142. //-------- Scenario 1730
  3143. namespace Scenario1730{
  3144. public class Test
  3145. {
  3146. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check22__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  3147. public static Expression check22__() {
  3148. if(Main() != 0 ) {
  3149. throw new Exception();
  3150. } else {
  3151. return Expression.Constant(0);
  3152. }
  3153. }
  3154. public static int Main()
  3155. {
  3156. Ext.StartCapture();
  3157. bool success = false;
  3158. try
  3159. {
  3160. success = check22();
  3161. }
  3162. finally
  3163. {
  3164. Ext.StopCapture();
  3165. }
  3166. return success ? 0 : 1;
  3167. }
  3168. static bool check22() {
  3169. foreach (object val in new object[] { null, new object(), new C(), new D(3) }) {
  3170. if (!check22(val)) {
  3171. return false;
  3172. }
  3173. }
  3174. return true;
  3175. }
  3176. static bool check22(object val) {
  3177. Expression<Func<object>> e =
  3178. Expression.Lambda<Func<object>>(
  3179. Expression.Constant(val, typeof(object)),
  3180. new System.Collections.Generic.List<ParameterExpression>());
  3181. Func<object> f = e.Compile();
  3182. return object.Equals(f(), val);
  3183. }
  3184. }
  3185. public static class Ext {
  3186. public static void StartCapture() {
  3187. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3188. // m.Invoke(null, new object[] { "test.dll" });
  3189. }
  3190. public static void StopCapture() {
  3191. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3192. // m.Invoke(null, new object[0]);
  3193. }
  3194. public static bool IsIntegralOrEnum(Type type) {
  3195. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3196. case TypeCode.Byte:
  3197. case TypeCode.SByte:
  3198. case TypeCode.Int16:
  3199. case TypeCode.Int32:
  3200. case TypeCode.Int64:
  3201. case TypeCode.UInt16:
  3202. case TypeCode.UInt32:
  3203. case TypeCode.UInt64:
  3204. return true;
  3205. default:
  3206. return false;
  3207. }
  3208. }
  3209. public static bool IsFloating(Type type) {
  3210. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3211. case TypeCode.Single:
  3212. case TypeCode.Double:
  3213. return true;
  3214. default:
  3215. return false;
  3216. }
  3217. }
  3218. public static Type GetNonNullableType(Type type) {
  3219. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  3220. type.GetGenericArguments()[0] :
  3221. type;
  3222. }
  3223. }
  3224. public interface I {
  3225. void M();
  3226. }
  3227. public class C : IEquatable<C>, I {
  3228. void I.M() {
  3229. }
  3230. public override bool Equals(object o) {
  3231. return o is C && Equals((C) o);
  3232. }
  3233. public bool Equals(C c) {
  3234. return c != null;
  3235. }
  3236. public override int GetHashCode() {
  3237. return 0;
  3238. }
  3239. }
  3240. public class D : C, IEquatable<D> {
  3241. public int Val;
  3242. public D() {
  3243. }
  3244. public D(int val) {
  3245. Val = val;
  3246. }
  3247. public override bool Equals(object o) {
  3248. return o is D && Equals((D) o);
  3249. }
  3250. public bool Equals(D d) {
  3251. return d != null && d.Val == Val;
  3252. }
  3253. public override int GetHashCode() {
  3254. return Val;
  3255. }
  3256. }
  3257. public enum E {
  3258. A=1, B=2
  3259. }
  3260. public enum El : long {
  3261. A, B, C
  3262. }
  3263. public struct S : IEquatable<S> {
  3264. public override bool Equals(object o) {
  3265. return (o is S) && Equals((S) o);
  3266. }
  3267. public bool Equals(S other) {
  3268. return true;
  3269. }
  3270. public override int GetHashCode() {
  3271. return 0;
  3272. }
  3273. }
  3274. public struct Sp : IEquatable<Sp> {
  3275. public Sp(int i, double d) {
  3276. I = i;
  3277. D = d;
  3278. }
  3279. public int I;
  3280. public double D;
  3281. public override bool Equals(object o) {
  3282. return (o is Sp) && Equals((Sp) o);
  3283. }
  3284. public bool Equals(Sp other) {
  3285. return other.I == I && other.D == D;
  3286. }
  3287. public override int GetHashCode() {
  3288. return I.GetHashCode() ^ D.GetHashCode();
  3289. }
  3290. }
  3291. public struct Ss : IEquatable<Ss> {
  3292. public Ss(S s) {
  3293. Val = s;
  3294. }
  3295. public S Val;
  3296. public override bool Equals(object o) {
  3297. return (o is Ss) && Equals((Ss) o);
  3298. }
  3299. public bool Equals(Ss other) {
  3300. return other.Val.Equals(Val);
  3301. }
  3302. public override int GetHashCode() {
  3303. return Val.GetHashCode();
  3304. }
  3305. }
  3306. public struct Sc : IEquatable<Sc> {
  3307. public Sc(string s) {
  3308. S = s;
  3309. }
  3310. public string S;
  3311. public override bool Equals(object o) {
  3312. return (o is Sc) && Equals((Sc) o);
  3313. }
  3314. public bool Equals(Sc other) {
  3315. return other.S == S;
  3316. }
  3317. public override int GetHashCode() {
  3318. return S.GetHashCode();
  3319. }
  3320. }
  3321. public struct Scs : IEquatable<Scs> {
  3322. public Scs(string s, S val) {
  3323. S = s;
  3324. Val = val;
  3325. }
  3326. public string S;
  3327. public S Val;
  3328. public override bool Equals(object o) {
  3329. return (o is Scs) && Equals((Scs) o);
  3330. }
  3331. public bool Equals(Scs other) {
  3332. return other.S == S && other.Val.Equals(Val);
  3333. }
  3334. public override int GetHashCode() {
  3335. return S.GetHashCode() ^ Val.GetHashCode();
  3336. }
  3337. }
  3338. }
  3339. //-------- Scenario 1731
  3340. namespace Scenario1731{
  3341. public class Test
  3342. {
  3343. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check23__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  3344. public static Expression check23__() {
  3345. if(Main() != 0 ) {
  3346. throw new Exception();
  3347. } else {
  3348. return Expression.Constant(0);
  3349. }
  3350. }
  3351. public static int Main()
  3352. {
  3353. Ext.StartCapture();
  3354. bool success = false;
  3355. try
  3356. {
  3357. success = check23();
  3358. }
  3359. finally
  3360. {
  3361. Ext.StopCapture();
  3362. }
  3363. return success ? 0 : 1;
  3364. }
  3365. static bool check23() {
  3366. foreach (C val in new C[] { null, new C(), new D(), new D(0), new D(5) }) {
  3367. if (!check23(val)) {
  3368. return false;
  3369. }
  3370. }
  3371. return true;
  3372. }
  3373. static bool check23(C val) {
  3374. Expression<Func<C>> e =
  3375. Expression.Lambda<Func<C>>(
  3376. Expression.Constant(val, typeof(C)),
  3377. new System.Collections.Generic.List<ParameterExpression>());
  3378. Func<C> f = e.Compile();
  3379. return object.Equals(f(), val);
  3380. }
  3381. }
  3382. public static class Ext {
  3383. public static void StartCapture() {
  3384. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3385. // m.Invoke(null, new object[] { "test.dll" });
  3386. }
  3387. public static void StopCapture() {
  3388. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3389. // m.Invoke(null, new object[0]);
  3390. }
  3391. public static bool IsIntegralOrEnum(Type type) {
  3392. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3393. case TypeCode.Byte:
  3394. case TypeCode.SByte:
  3395. case TypeCode.Int16:
  3396. case TypeCode.Int32:
  3397. case TypeCode.Int64:
  3398. case TypeCode.UInt16:
  3399. case TypeCode.UInt32:
  3400. case TypeCode.UInt64:
  3401. return true;
  3402. default:
  3403. return false;
  3404. }
  3405. }
  3406. public static bool IsFloating(Type type) {
  3407. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3408. case TypeCode.Single:
  3409. case TypeCode.Double:
  3410. return true;
  3411. default:
  3412. return false;
  3413. }
  3414. }
  3415. public static Type GetNonNullableType(Type type) {
  3416. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  3417. type.GetGenericArguments()[0] :
  3418. type;
  3419. }
  3420. }
  3421. public interface I {
  3422. void M();
  3423. }
  3424. public class C : IEquatable<C>, I {
  3425. void I.M() {
  3426. }
  3427. public override bool Equals(object o) {
  3428. return o is C && Equals((C) o);
  3429. }
  3430. public bool Equals(C c) {
  3431. return c != null;
  3432. }
  3433. public override int GetHashCode() {
  3434. return 0;
  3435. }
  3436. }
  3437. public class D : C, IEquatable<D> {
  3438. public int Val;
  3439. public D() {
  3440. }
  3441. public D(int val) {
  3442. Val = val;
  3443. }
  3444. public override bool Equals(object o) {
  3445. return o is D && Equals((D) o);
  3446. }
  3447. public bool Equals(D d) {
  3448. return d != null && d.Val == Val;
  3449. }
  3450. public override int GetHashCode() {
  3451. return Val;
  3452. }
  3453. }
  3454. public enum E {
  3455. A=1, B=2
  3456. }
  3457. public enum El : long {
  3458. A, B, C
  3459. }
  3460. public struct S : IEquatable<S> {
  3461. public override bool Equals(object o) {
  3462. return (o is S) && Equals((S) o);
  3463. }
  3464. public bool Equals(S other) {
  3465. return true;
  3466. }
  3467. public override int GetHashCode() {
  3468. return 0;
  3469. }
  3470. }
  3471. public struct Sp : IEquatable<Sp> {
  3472. public Sp(int i, double d) {
  3473. I = i;
  3474. D = d;
  3475. }
  3476. public int I;
  3477. public double D;
  3478. public override bool Equals(object o) {
  3479. return (o is Sp) && Equals((Sp) o);
  3480. }
  3481. public bool Equals(Sp other) {
  3482. return other.I == I && other.D == D;
  3483. }
  3484. public override int GetHashCode() {
  3485. return I.GetHashCode() ^ D.GetHashCode();
  3486. }
  3487. }
  3488. public struct Ss : IEquatable<Ss> {
  3489. public Ss(S s) {
  3490. Val = s;
  3491. }
  3492. public S Val;
  3493. public override bool Equals(object o) {
  3494. return (o is Ss) && Equals((Ss) o);
  3495. }
  3496. public bool Equals(Ss other) {
  3497. return other.Val.Equals(Val);
  3498. }
  3499. public override int GetHashCode() {
  3500. return Val.GetHashCode();
  3501. }
  3502. }
  3503. public struct Sc : IEquatable<Sc> {
  3504. public Sc(string s) {
  3505. S = s;
  3506. }
  3507. public string S;
  3508. public override bool Equals(object o) {
  3509. return (o is Sc) && Equals((Sc) o);
  3510. }
  3511. public bool Equals(Sc other) {
  3512. return other.S == S;
  3513. }
  3514. public override int GetHashCode() {
  3515. return S.GetHashCode();
  3516. }
  3517. }
  3518. public struct Scs : IEquatable<Scs> {
  3519. public Scs(string s, S val) {
  3520. S = s;
  3521. Val = val;
  3522. }
  3523. public string S;
  3524. public S Val;
  3525. public override bool Equals(object o) {
  3526. return (o is Scs) && Equals((Scs) o);
  3527. }
  3528. public bool Equals(Scs other) {
  3529. return other.S == S && other.Val.Equals(Val);
  3530. }
  3531. public override int GetHashCode() {
  3532. return S.GetHashCode() ^ Val.GetHashCode();
  3533. }
  3534. }
  3535. }
  3536. //-------- Scenario 1732
  3537. namespace Scenario1732{
  3538. public class Test
  3539. {
  3540. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check24__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  3541. public static Expression check24__() {
  3542. if(Main() != 0 ) {
  3543. throw new Exception();
  3544. } else {
  3545. return Expression.Constant(0);
  3546. }
  3547. }
  3548. public static int Main()
  3549. {
  3550. Ext.StartCapture();
  3551. bool success = false;
  3552. try
  3553. {
  3554. success = check24();
  3555. }
  3556. finally
  3557. {
  3558. Ext.StopCapture();
  3559. }
  3560. return success ? 0 : 1;
  3561. }
  3562. static bool check24() {
  3563. foreach (D val in new D[] { null, new D(), new D(0), new D(5) }) {
  3564. if (!check24(val)) {
  3565. return false;
  3566. }
  3567. }
  3568. return true;
  3569. }
  3570. static bool check24(D val) {
  3571. Expression<Func<D>> e =
  3572. Expression.Lambda<Func<D>>(
  3573. Expression.Constant(val, typeof(D)),
  3574. new System.Collections.Generic.List<ParameterExpression>());
  3575. Func<D> f = e.Compile();
  3576. return object.Equals(f(), val);
  3577. }
  3578. }
  3579. public static class Ext {
  3580. public static void StartCapture() {
  3581. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3582. // m.Invoke(null, new object[] { "test.dll" });
  3583. }
  3584. public static void StopCapture() {
  3585. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3586. // m.Invoke(null, new object[0]);
  3587. }
  3588. public static bool IsIntegralOrEnum(Type type) {
  3589. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3590. case TypeCode.Byte:
  3591. case TypeCode.SByte:
  3592. case TypeCode.Int16:
  3593. case TypeCode.Int32:
  3594. case TypeCode.Int64:
  3595. case TypeCode.UInt16:
  3596. case TypeCode.UInt32:
  3597. case TypeCode.UInt64:
  3598. return true;
  3599. default:
  3600. return false;
  3601. }
  3602. }
  3603. public static bool IsFloating(Type type) {
  3604. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3605. case TypeCode.Single:
  3606. case TypeCode.Double:
  3607. return true;
  3608. default:
  3609. return false;
  3610. }
  3611. }
  3612. public static Type GetNonNullableType(Type type) {
  3613. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  3614. type.GetGenericArguments()[0] :
  3615. type;
  3616. }
  3617. }
  3618. public interface I {
  3619. void M();
  3620. }
  3621. public class C : IEquatable<C>, I {
  3622. void I.M() {
  3623. }
  3624. public override bool Equals(object o) {
  3625. return o is C && Equals((C) o);
  3626. }
  3627. public bool Equals(C c) {
  3628. return c != null;
  3629. }
  3630. public override int GetHashCode() {
  3631. return 0;
  3632. }
  3633. }
  3634. public class D : C, IEquatable<D> {
  3635. public int Val;
  3636. public D() {
  3637. }
  3638. public D(int val) {
  3639. Val = val;
  3640. }
  3641. public override bool Equals(object o) {
  3642. return o is D && Equals((D) o);
  3643. }
  3644. public bool Equals(D d) {
  3645. return d != null && d.Val == Val;
  3646. }
  3647. public override int GetHashCode() {
  3648. return Val;
  3649. }
  3650. }
  3651. public enum E {
  3652. A=1, B=2
  3653. }
  3654. public enum El : long {
  3655. A, B, C
  3656. }
  3657. public struct S : IEquatable<S> {
  3658. public override bool Equals(object o) {
  3659. return (o is S) && Equals((S) o);
  3660. }
  3661. public bool Equals(S other) {
  3662. return true;
  3663. }
  3664. public override int GetHashCode() {
  3665. return 0;
  3666. }
  3667. }
  3668. public struct Sp : IEquatable<Sp> {
  3669. public Sp(int i, double d) {
  3670. I = i;
  3671. D = d;
  3672. }
  3673. public int I;
  3674. public double D;
  3675. public override bool Equals(object o) {
  3676. return (o is Sp) && Equals((Sp) o);
  3677. }
  3678. public bool Equals(Sp other) {
  3679. return other.I == I && other.D == D;
  3680. }
  3681. public override int GetHashCode() {
  3682. return I.GetHashCode() ^ D.GetHashCode();
  3683. }
  3684. }
  3685. public struct Ss : IEquatable<Ss> {
  3686. public Ss(S s) {
  3687. Val = s;
  3688. }
  3689. public S Val;
  3690. public override bool Equals(object o) {
  3691. return (o is Ss) && Equals((Ss) o);
  3692. }
  3693. public bool Equals(Ss other) {
  3694. return other.Val.Equals(Val);
  3695. }
  3696. public override int GetHashCode() {
  3697. return Val.GetHashCode();
  3698. }
  3699. }
  3700. public struct Sc : IEquatable<Sc> {
  3701. public Sc(string s) {
  3702. S = s;
  3703. }
  3704. public string S;
  3705. public override bool Equals(object o) {
  3706. return (o is Sc) && Equals((Sc) o);
  3707. }
  3708. public bool Equals(Sc other) {
  3709. return other.S == S;
  3710. }
  3711. public override int GetHashCode() {
  3712. return S.GetHashCode();
  3713. }
  3714. }
  3715. public struct Scs : IEquatable<Scs> {
  3716. public Scs(string s, S val) {
  3717. S = s;
  3718. Val = val;
  3719. }
  3720. public string S;
  3721. public S Val;
  3722. public override bool Equals(object o) {
  3723. return (o is Scs) && Equals((Scs) o);
  3724. }
  3725. public bool Equals(Scs other) {
  3726. return other.S == S && other.Val.Equals(Val);
  3727. }
  3728. public override int GetHashCode() {
  3729. return S.GetHashCode() ^ Val.GetHashCode();
  3730. }
  3731. }
  3732. }
  3733. //-------- Scenario 1733
  3734. namespace Scenario1733{
  3735. public class Test
  3736. {
  3737. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check25_object___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  3738. public static Expression check25_object___() {
  3739. if(Main() != 0 ) {
  3740. throw new Exception();
  3741. } else {
  3742. return Expression.Constant(0);
  3743. }
  3744. }
  3745. public static int Main()
  3746. {
  3747. Ext.StartCapture();
  3748. bool success = false;
  3749. try
  3750. {
  3751. success = check25<object>();
  3752. }
  3753. finally
  3754. {
  3755. Ext.StopCapture();
  3756. }
  3757. return success ? 0 : 1;
  3758. }
  3759. static bool check25<T>() {
  3760. foreach (T val in new T[] { default(T) }) {
  3761. if (!check25<T>(val)) {
  3762. return false;
  3763. }
  3764. }
  3765. return true;
  3766. }
  3767. static bool check25<T>(T val) {
  3768. Expression<Func<T>> e =
  3769. Expression.Lambda<Func<T>>(
  3770. Expression.Constant(val, typeof(T)),
  3771. new System.Collections.Generic.List<ParameterExpression>());
  3772. Func<T> f = e.Compile();
  3773. return object.Equals(f(), val);
  3774. }
  3775. }
  3776. public static class Ext {
  3777. public static void StartCapture() {
  3778. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3779. // m.Invoke(null, new object[] { "test.dll" });
  3780. }
  3781. public static void StopCapture() {
  3782. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3783. // m.Invoke(null, new object[0]);
  3784. }
  3785. public static bool IsIntegralOrEnum(Type type) {
  3786. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3787. case TypeCode.Byte:
  3788. case TypeCode.SByte:
  3789. case TypeCode.Int16:
  3790. case TypeCode.Int32:
  3791. case TypeCode.Int64:
  3792. case TypeCode.UInt16:
  3793. case TypeCode.UInt32:
  3794. case TypeCode.UInt64:
  3795. return true;
  3796. default:
  3797. return false;
  3798. }
  3799. }
  3800. public static bool IsFloating(Type type) {
  3801. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3802. case TypeCode.Single:
  3803. case TypeCode.Double:
  3804. return true;
  3805. default:
  3806. return false;
  3807. }
  3808. }
  3809. public static Type GetNonNullableType(Type type) {
  3810. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  3811. type.GetGenericArguments()[0] :
  3812. type;
  3813. }
  3814. }
  3815. public interface I {
  3816. void M();
  3817. }
  3818. public class C : IEquatable<C>, I {
  3819. void I.M() {
  3820. }
  3821. public override bool Equals(object o) {
  3822. return o is C && Equals((C) o);
  3823. }
  3824. public bool Equals(C c) {
  3825. return c != null;
  3826. }
  3827. public override int GetHashCode() {
  3828. return 0;
  3829. }
  3830. }
  3831. public class D : C, IEquatable<D> {
  3832. public int Val;
  3833. public D() {
  3834. }
  3835. public D(int val) {
  3836. Val = val;
  3837. }
  3838. public override bool Equals(object o) {
  3839. return o is D && Equals((D) o);
  3840. }
  3841. public bool Equals(D d) {
  3842. return d != null && d.Val == Val;
  3843. }
  3844. public override int GetHashCode() {
  3845. return Val;
  3846. }
  3847. }
  3848. public enum E {
  3849. A=1, B=2
  3850. }
  3851. public enum El : long {
  3852. A, B, C
  3853. }
  3854. public struct S : IEquatable<S> {
  3855. public override bool Equals(object o) {
  3856. return (o is S) && Equals((S) o);
  3857. }
  3858. public bool Equals(S other) {
  3859. return true;
  3860. }
  3861. public override int GetHashCode() {
  3862. return 0;
  3863. }
  3864. }
  3865. public struct Sp : IEquatable<Sp> {
  3866. public Sp(int i, double d) {
  3867. I = i;
  3868. D = d;
  3869. }
  3870. public int I;
  3871. public double D;
  3872. public override bool Equals(object o) {
  3873. return (o is Sp) && Equals((Sp) o);
  3874. }
  3875. public bool Equals(Sp other) {
  3876. return other.I == I && other.D == D;
  3877. }
  3878. public override int GetHashCode() {
  3879. return I.GetHashCode() ^ D.GetHashCode();
  3880. }
  3881. }
  3882. public struct Ss : IEquatable<Ss> {
  3883. public Ss(S s) {
  3884. Val = s;
  3885. }
  3886. public S Val;
  3887. public override bool Equals(object o) {
  3888. return (o is Ss) && Equals((Ss) o);
  3889. }
  3890. public bool Equals(Ss other) {
  3891. return other.Val.Equals(Val);
  3892. }
  3893. public override int GetHashCode() {
  3894. return Val.GetHashCode();
  3895. }
  3896. }
  3897. public struct Sc : IEquatable<Sc> {
  3898. public Sc(string s) {
  3899. S = s;
  3900. }
  3901. public string S;
  3902. public override bool Equals(object o) {
  3903. return (o is Sc) && Equals((Sc) o);
  3904. }
  3905. public bool Equals(Sc other) {
  3906. return other.S == S;
  3907. }
  3908. public override int GetHashCode() {
  3909. return S.GetHashCode();
  3910. }
  3911. }
  3912. public struct Scs : IEquatable<Scs> {
  3913. public Scs(string s, S val) {
  3914. S = s;
  3915. Val = val;
  3916. }
  3917. public string S;
  3918. public S Val;
  3919. public override bool Equals(object o) {
  3920. return (o is Scs) && Equals((Scs) o);
  3921. }
  3922. public bool Equals(Scs other) {
  3923. return other.S == S && other.Val.Equals(Val);
  3924. }
  3925. public override int GetHashCode() {
  3926. return S.GetHashCode() ^ Val.GetHashCode();
  3927. }
  3928. }
  3929. }
  3930. //-------- Scenario 1734
  3931. namespace Scenario1734{
  3932. public class Test
  3933. {
  3934. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check25_C___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  3935. public static Expression check25_C___() {
  3936. if(Main() != 0 ) {
  3937. throw new Exception();
  3938. } else {
  3939. return Expression.Constant(0);
  3940. }
  3941. }
  3942. public static int Main()
  3943. {
  3944. Ext.StartCapture();
  3945. bool success = false;
  3946. try
  3947. {
  3948. success = check25<C>();
  3949. }
  3950. finally
  3951. {
  3952. Ext.StopCapture();
  3953. }
  3954. return success ? 0 : 1;
  3955. }
  3956. static bool check25<T>() {
  3957. foreach (T val in new T[] { default(T) }) {
  3958. if (!check25<T>(val)) {
  3959. return false;
  3960. }
  3961. }
  3962. return true;
  3963. }
  3964. static bool check25<T>(T val) {
  3965. Expression<Func<T>> e =
  3966. Expression.Lambda<Func<T>>(
  3967. Expression.Constant(val, typeof(T)),
  3968. new System.Collections.Generic.List<ParameterExpression>());
  3969. Func<T> f = e.Compile();
  3970. return object.Equals(f(), val);
  3971. }
  3972. }
  3973. public static class Ext {
  3974. public static void StartCapture() {
  3975. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3976. // m.Invoke(null, new object[] { "test.dll" });
  3977. }
  3978. public static void StopCapture() {
  3979. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  3980. // m.Invoke(null, new object[0]);
  3981. }
  3982. public static bool IsIntegralOrEnum(Type type) {
  3983. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3984. case TypeCode.Byte:
  3985. case TypeCode.SByte:
  3986. case TypeCode.Int16:
  3987. case TypeCode.Int32:
  3988. case TypeCode.Int64:
  3989. case TypeCode.UInt16:
  3990. case TypeCode.UInt32:
  3991. case TypeCode.UInt64:
  3992. return true;
  3993. default:
  3994. return false;
  3995. }
  3996. }
  3997. public static bool IsFloating(Type type) {
  3998. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  3999. case TypeCode.Single:
  4000. case TypeCode.Double:
  4001. return true;
  4002. default:
  4003. return false;
  4004. }
  4005. }
  4006. public static Type GetNonNullableType(Type type) {
  4007. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  4008. type.GetGenericArguments()[0] :
  4009. type;
  4010. }
  4011. }
  4012. public interface I {
  4013. void M();
  4014. }
  4015. public class C : IEquatable<C>, I {
  4016. void I.M() {
  4017. }
  4018. public override bool Equals(object o) {
  4019. return o is C && Equals((C) o);
  4020. }
  4021. public bool Equals(C c) {
  4022. return c != null;
  4023. }
  4024. public override int GetHashCode() {
  4025. return 0;
  4026. }
  4027. }
  4028. public class D : C, IEquatable<D> {
  4029. public int Val;
  4030. public D() {
  4031. }
  4032. public D(int val) {
  4033. Val = val;
  4034. }
  4035. public override bool Equals(object o) {
  4036. return o is D && Equals((D) o);
  4037. }
  4038. public bool Equals(D d) {
  4039. return d != null && d.Val == Val;
  4040. }
  4041. public override int GetHashCode() {
  4042. return Val;
  4043. }
  4044. }
  4045. public enum E {
  4046. A=1, B=2
  4047. }
  4048. public enum El : long {
  4049. A, B, C
  4050. }
  4051. public struct S : IEquatable<S> {
  4052. public override bool Equals(object o) {
  4053. return (o is S) && Equals((S) o);
  4054. }
  4055. public bool Equals(S other) {
  4056. return true;
  4057. }
  4058. public override int GetHashCode() {
  4059. return 0;
  4060. }
  4061. }
  4062. public struct Sp : IEquatable<Sp> {
  4063. public Sp(int i, double d) {
  4064. I = i;
  4065. D = d;
  4066. }
  4067. public int I;
  4068. public double D;
  4069. public override bool Equals(object o) {
  4070. return (o is Sp) && Equals((Sp) o);
  4071. }
  4072. public bool Equals(Sp other) {
  4073. return other.I == I && other.D == D;
  4074. }
  4075. public override int GetHashCode() {
  4076. return I.GetHashCode() ^ D.GetHashCode();
  4077. }
  4078. }
  4079. public struct Ss : IEquatable<Ss> {
  4080. public Ss(S s) {
  4081. Val = s;
  4082. }
  4083. public S Val;
  4084. public override bool Equals(object o) {
  4085. return (o is Ss) && Equals((Ss) o);
  4086. }
  4087. public bool Equals(Ss other) {
  4088. return other.Val.Equals(Val);
  4089. }
  4090. public override int GetHashCode() {
  4091. return Val.GetHashCode();
  4092. }
  4093. }
  4094. public struct Sc : IEquatable<Sc> {
  4095. public Sc(string s) {
  4096. S = s;
  4097. }
  4098. public string S;
  4099. public override bool Equals(object o) {
  4100. return (o is Sc) && Equals((Sc) o);
  4101. }
  4102. public bool Equals(Sc other) {
  4103. return other.S == S;
  4104. }
  4105. public override int GetHashCode() {
  4106. return S.GetHashCode();
  4107. }
  4108. }
  4109. public struct Scs : IEquatable<Scs> {
  4110. public Scs(string s, S val) {
  4111. S = s;
  4112. Val = val;
  4113. }
  4114. public string S;
  4115. public S Val;
  4116. public override bool Equals(object o) {
  4117. return (o is Scs) && Equals((Scs) o);
  4118. }
  4119. public bool Equals(Scs other) {
  4120. return other.S == S && other.Val.Equals(Val);
  4121. }
  4122. public override int GetHashCode() {
  4123. return S.GetHashCode() ^ Val.GetHashCode();
  4124. }
  4125. }
  4126. }
  4127. //-------- Scenario 1735
  4128. namespace Scenario1735{
  4129. public class Test
  4130. {
  4131. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check25_S___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  4132. public static Expression check25_S___() {
  4133. if(Main() != 0 ) {
  4134. throw new Exception();
  4135. } else {
  4136. return Expression.Constant(0);
  4137. }
  4138. }
  4139. public static int Main()
  4140. {
  4141. Ext.StartCapture();
  4142. bool success = false;
  4143. try
  4144. {
  4145. success = check25<S>();
  4146. }
  4147. finally
  4148. {
  4149. Ext.StopCapture();
  4150. }
  4151. return success ? 0 : 1;
  4152. }
  4153. static bool check25<T>() {
  4154. foreach (T val in new T[] { default(T) }) {
  4155. if (!check25<T>(val)) {
  4156. return false;
  4157. }
  4158. }
  4159. return true;
  4160. }
  4161. static bool check25<T>(T val) {
  4162. Expression<Func<T>> e =
  4163. Expression.Lambda<Func<T>>(
  4164. Expression.Constant(val, typeof(T)),
  4165. new System.Collections.Generic.List<ParameterExpression>());
  4166. Func<T> f = e.Compile();
  4167. return object.Equals(f(), val);
  4168. }
  4169. }
  4170. public static class Ext {
  4171. public static void StartCapture() {
  4172. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4173. // m.Invoke(null, new object[] { "test.dll" });
  4174. }
  4175. public static void StopCapture() {
  4176. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4177. // m.Invoke(null, new object[0]);
  4178. }
  4179. public static bool IsIntegralOrEnum(Type type) {
  4180. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4181. case TypeCode.Byte:
  4182. case TypeCode.SByte:
  4183. case TypeCode.Int16:
  4184. case TypeCode.Int32:
  4185. case TypeCode.Int64:
  4186. case TypeCode.UInt16:
  4187. case TypeCode.UInt32:
  4188. case TypeCode.UInt64:
  4189. return true;
  4190. default:
  4191. return false;
  4192. }
  4193. }
  4194. public static bool IsFloating(Type type) {
  4195. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4196. case TypeCode.Single:
  4197. case TypeCode.Double:
  4198. return true;
  4199. default:
  4200. return false;
  4201. }
  4202. }
  4203. public static Type GetNonNullableType(Type type) {
  4204. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  4205. type.GetGenericArguments()[0] :
  4206. type;
  4207. }
  4208. }
  4209. public interface I {
  4210. void M();
  4211. }
  4212. public class C : IEquatable<C>, I {
  4213. void I.M() {
  4214. }
  4215. public override bool Equals(object o) {
  4216. return o is C && Equals((C) o);
  4217. }
  4218. public bool Equals(C c) {
  4219. return c != null;
  4220. }
  4221. public override int GetHashCode() {
  4222. return 0;
  4223. }
  4224. }
  4225. public class D : C, IEquatable<D> {
  4226. public int Val;
  4227. public D() {
  4228. }
  4229. public D(int val) {
  4230. Val = val;
  4231. }
  4232. public override bool Equals(object o) {
  4233. return o is D && Equals((D) o);
  4234. }
  4235. public bool Equals(D d) {
  4236. return d != null && d.Val == Val;
  4237. }
  4238. public override int GetHashCode() {
  4239. return Val;
  4240. }
  4241. }
  4242. public enum E {
  4243. A=1, B=2
  4244. }
  4245. public enum El : long {
  4246. A, B, C
  4247. }
  4248. public struct S : IEquatable<S> {
  4249. public override bool Equals(object o) {
  4250. return (o is S) && Equals((S) o);
  4251. }
  4252. public bool Equals(S other) {
  4253. return true;
  4254. }
  4255. public override int GetHashCode() {
  4256. return 0;
  4257. }
  4258. }
  4259. public struct Sp : IEquatable<Sp> {
  4260. public Sp(int i, double d) {
  4261. I = i;
  4262. D = d;
  4263. }
  4264. public int I;
  4265. public double D;
  4266. public override bool Equals(object o) {
  4267. return (o is Sp) && Equals((Sp) o);
  4268. }
  4269. public bool Equals(Sp other) {
  4270. return other.I == I && other.D == D;
  4271. }
  4272. public override int GetHashCode() {
  4273. return I.GetHashCode() ^ D.GetHashCode();
  4274. }
  4275. }
  4276. public struct Ss : IEquatable<Ss> {
  4277. public Ss(S s) {
  4278. Val = s;
  4279. }
  4280. public S Val;
  4281. public override bool Equals(object o) {
  4282. return (o is Ss) && Equals((Ss) o);
  4283. }
  4284. public bool Equals(Ss other) {
  4285. return other.Val.Equals(Val);
  4286. }
  4287. public override int GetHashCode() {
  4288. return Val.GetHashCode();
  4289. }
  4290. }
  4291. public struct Sc : IEquatable<Sc> {
  4292. public Sc(string s) {
  4293. S = s;
  4294. }
  4295. public string S;
  4296. public override bool Equals(object o) {
  4297. return (o is Sc) && Equals((Sc) o);
  4298. }
  4299. public bool Equals(Sc other) {
  4300. return other.S == S;
  4301. }
  4302. public override int GetHashCode() {
  4303. return S.GetHashCode();
  4304. }
  4305. }
  4306. public struct Scs : IEquatable<Scs> {
  4307. public Scs(string s, S val) {
  4308. S = s;
  4309. Val = val;
  4310. }
  4311. public string S;
  4312. public S Val;
  4313. public override bool Equals(object o) {
  4314. return (o is Scs) && Equals((Scs) o);
  4315. }
  4316. public bool Equals(Scs other) {
  4317. return other.S == S && other.Val.Equals(Val);
  4318. }
  4319. public override int GetHashCode() {
  4320. return S.GetHashCode() ^ Val.GetHashCode();
  4321. }
  4322. }
  4323. }
  4324. //-------- Scenario 1736
  4325. namespace Scenario1736{
  4326. public class Test
  4327. {
  4328. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check25_Scs___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  4329. public static Expression check25_Scs___() {
  4330. if(Main() != 0 ) {
  4331. throw new Exception();
  4332. } else {
  4333. return Expression.Constant(0);
  4334. }
  4335. }
  4336. public static int Main()
  4337. {
  4338. Ext.StartCapture();
  4339. bool success = false;
  4340. try
  4341. {
  4342. success = check25<Scs>();
  4343. }
  4344. finally
  4345. {
  4346. Ext.StopCapture();
  4347. }
  4348. return success ? 0 : 1;
  4349. }
  4350. static bool check25<T>() {
  4351. foreach (T val in new T[] { default(T) }) {
  4352. if (!check25<T>(val)) {
  4353. return false;
  4354. }
  4355. }
  4356. return true;
  4357. }
  4358. static bool check25<T>(T val) {
  4359. Expression<Func<T>> e =
  4360. Expression.Lambda<Func<T>>(
  4361. Expression.Constant(val, typeof(T)),
  4362. new System.Collections.Generic.List<ParameterExpression>());
  4363. Func<T> f = e.Compile();
  4364. return object.Equals(f(), val);
  4365. }
  4366. }
  4367. public static class Ext {
  4368. public static void StartCapture() {
  4369. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4370. // m.Invoke(null, new object[] { "test.dll" });
  4371. }
  4372. public static void StopCapture() {
  4373. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4374. // m.Invoke(null, new object[0]);
  4375. }
  4376. public static bool IsIntegralOrEnum(Type type) {
  4377. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4378. case TypeCode.Byte:
  4379. case TypeCode.SByte:
  4380. case TypeCode.Int16:
  4381. case TypeCode.Int32:
  4382. case TypeCode.Int64:
  4383. case TypeCode.UInt16:
  4384. case TypeCode.UInt32:
  4385. case TypeCode.UInt64:
  4386. return true;
  4387. default:
  4388. return false;
  4389. }
  4390. }
  4391. public static bool IsFloating(Type type) {
  4392. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4393. case TypeCode.Single:
  4394. case TypeCode.Double:
  4395. return true;
  4396. default:
  4397. return false;
  4398. }
  4399. }
  4400. public static Type GetNonNullableType(Type type) {
  4401. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  4402. type.GetGenericArguments()[0] :
  4403. type;
  4404. }
  4405. }
  4406. public interface I {
  4407. void M();
  4408. }
  4409. public class C : IEquatable<C>, I {
  4410. void I.M() {
  4411. }
  4412. public override bool Equals(object o) {
  4413. return o is C && Equals((C) o);
  4414. }
  4415. public bool Equals(C c) {
  4416. return c != null;
  4417. }
  4418. public override int GetHashCode() {
  4419. return 0;
  4420. }
  4421. }
  4422. public class D : C, IEquatable<D> {
  4423. public int Val;
  4424. public D() {
  4425. }
  4426. public D(int val) {
  4427. Val = val;
  4428. }
  4429. public override bool Equals(object o) {
  4430. return o is D && Equals((D) o);
  4431. }
  4432. public bool Equals(D d) {
  4433. return d != null && d.Val == Val;
  4434. }
  4435. public override int GetHashCode() {
  4436. return Val;
  4437. }
  4438. }
  4439. public enum E {
  4440. A=1, B=2
  4441. }
  4442. public enum El : long {
  4443. A, B, C
  4444. }
  4445. public struct S : IEquatable<S> {
  4446. public override bool Equals(object o) {
  4447. return (o is S) && Equals((S) o);
  4448. }
  4449. public bool Equals(S other) {
  4450. return true;
  4451. }
  4452. public override int GetHashCode() {
  4453. return 0;
  4454. }
  4455. }
  4456. public struct Sp : IEquatable<Sp> {
  4457. public Sp(int i, double d) {
  4458. I = i;
  4459. D = d;
  4460. }
  4461. public int I;
  4462. public double D;
  4463. public override bool Equals(object o) {
  4464. return (o is Sp) && Equals((Sp) o);
  4465. }
  4466. public bool Equals(Sp other) {
  4467. return other.I == I && other.D == D;
  4468. }
  4469. public override int GetHashCode() {
  4470. return I.GetHashCode() ^ D.GetHashCode();
  4471. }
  4472. }
  4473. public struct Ss : IEquatable<Ss> {
  4474. public Ss(S s) {
  4475. Val = s;
  4476. }
  4477. public S Val;
  4478. public override bool Equals(object o) {
  4479. return (o is Ss) && Equals((Ss) o);
  4480. }
  4481. public bool Equals(Ss other) {
  4482. return other.Val.Equals(Val);
  4483. }
  4484. public override int GetHashCode() {
  4485. return Val.GetHashCode();
  4486. }
  4487. }
  4488. public struct Sc : IEquatable<Sc> {
  4489. public Sc(string s) {
  4490. S = s;
  4491. }
  4492. public string S;
  4493. public override bool Equals(object o) {
  4494. return (o is Sc) && Equals((Sc) o);
  4495. }
  4496. public bool Equals(Sc other) {
  4497. return other.S == S;
  4498. }
  4499. public override int GetHashCode() {
  4500. return S.GetHashCode();
  4501. }
  4502. }
  4503. public struct Scs : IEquatable<Scs> {
  4504. public Scs(string s, S val) {
  4505. S = s;
  4506. Val = val;
  4507. }
  4508. public string S;
  4509. public S Val;
  4510. public override bool Equals(object o) {
  4511. return (o is Scs) && Equals((Scs) o);
  4512. }
  4513. public bool Equals(Scs other) {
  4514. return other.S == S && other.Val.Equals(Val);
  4515. }
  4516. public override int GetHashCode() {
  4517. return S.GetHashCode() ^ Val.GetHashCode();
  4518. }
  4519. }
  4520. }
  4521. //-------- Scenario 1737
  4522. namespace Scenario1737{
  4523. public class Test
  4524. {
  4525. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check25_E___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  4526. public static Expression check25_E___() {
  4527. if(Main() != 0 ) {
  4528. throw new Exception();
  4529. } else {
  4530. return Expression.Constant(0);
  4531. }
  4532. }
  4533. public static int Main()
  4534. {
  4535. Ext.StartCapture();
  4536. bool success = false;
  4537. try
  4538. {
  4539. success = check25<E>();
  4540. }
  4541. finally
  4542. {
  4543. Ext.StopCapture();
  4544. }
  4545. return success ? 0 : 1;
  4546. }
  4547. static bool check25<T>() {
  4548. foreach (T val in new T[] { default(T) }) {
  4549. if (!check25<T>(val)) {
  4550. return false;
  4551. }
  4552. }
  4553. return true;
  4554. }
  4555. static bool check25<T>(T val) {
  4556. Expression<Func<T>> e =
  4557. Expression.Lambda<Func<T>>(
  4558. Expression.Constant(val, typeof(T)),
  4559. new System.Collections.Generic.List<ParameterExpression>());
  4560. Func<T> f = e.Compile();
  4561. return object.Equals(f(), val);
  4562. }
  4563. }
  4564. public static class Ext {
  4565. public static void StartCapture() {
  4566. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4567. // m.Invoke(null, new object[] { "test.dll" });
  4568. }
  4569. public static void StopCapture() {
  4570. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4571. // m.Invoke(null, new object[0]);
  4572. }
  4573. public static bool IsIntegralOrEnum(Type type) {
  4574. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4575. case TypeCode.Byte:
  4576. case TypeCode.SByte:
  4577. case TypeCode.Int16:
  4578. case TypeCode.Int32:
  4579. case TypeCode.Int64:
  4580. case TypeCode.UInt16:
  4581. case TypeCode.UInt32:
  4582. case TypeCode.UInt64:
  4583. return true;
  4584. default:
  4585. return false;
  4586. }
  4587. }
  4588. public static bool IsFloating(Type type) {
  4589. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4590. case TypeCode.Single:
  4591. case TypeCode.Double:
  4592. return true;
  4593. default:
  4594. return false;
  4595. }
  4596. }
  4597. public static Type GetNonNullableType(Type type) {
  4598. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  4599. type.GetGenericArguments()[0] :
  4600. type;
  4601. }
  4602. }
  4603. public interface I {
  4604. void M();
  4605. }
  4606. public class C : IEquatable<C>, I {
  4607. void I.M() {
  4608. }
  4609. public override bool Equals(object o) {
  4610. return o is C && Equals((C) o);
  4611. }
  4612. public bool Equals(C c) {
  4613. return c != null;
  4614. }
  4615. public override int GetHashCode() {
  4616. return 0;
  4617. }
  4618. }
  4619. public class D : C, IEquatable<D> {
  4620. public int Val;
  4621. public D() {
  4622. }
  4623. public D(int val) {
  4624. Val = val;
  4625. }
  4626. public override bool Equals(object o) {
  4627. return o is D && Equals((D) o);
  4628. }
  4629. public bool Equals(D d) {
  4630. return d != null && d.Val == Val;
  4631. }
  4632. public override int GetHashCode() {
  4633. return Val;
  4634. }
  4635. }
  4636. public enum E {
  4637. A=1, B=2
  4638. }
  4639. public enum El : long {
  4640. A, B, C
  4641. }
  4642. public struct S : IEquatable<S> {
  4643. public override bool Equals(object o) {
  4644. return (o is S) && Equals((S) o);
  4645. }
  4646. public bool Equals(S other) {
  4647. return true;
  4648. }
  4649. public override int GetHashCode() {
  4650. return 0;
  4651. }
  4652. }
  4653. public struct Sp : IEquatable<Sp> {
  4654. public Sp(int i, double d) {
  4655. I = i;
  4656. D = d;
  4657. }
  4658. public int I;
  4659. public double D;
  4660. public override bool Equals(object o) {
  4661. return (o is Sp) && Equals((Sp) o);
  4662. }
  4663. public bool Equals(Sp other) {
  4664. return other.I == I && other.D == D;
  4665. }
  4666. public override int GetHashCode() {
  4667. return I.GetHashCode() ^ D.GetHashCode();
  4668. }
  4669. }
  4670. public struct Ss : IEquatable<Ss> {
  4671. public Ss(S s) {
  4672. Val = s;
  4673. }
  4674. public S Val;
  4675. public override bool Equals(object o) {
  4676. return (o is Ss) && Equals((Ss) o);
  4677. }
  4678. public bool Equals(Ss other) {
  4679. return other.Val.Equals(Val);
  4680. }
  4681. public override int GetHashCode() {
  4682. return Val.GetHashCode();
  4683. }
  4684. }
  4685. public struct Sc : IEquatable<Sc> {
  4686. public Sc(string s) {
  4687. S = s;
  4688. }
  4689. public string S;
  4690. public override bool Equals(object o) {
  4691. return (o is Sc) && Equals((Sc) o);
  4692. }
  4693. public bool Equals(Sc other) {
  4694. return other.S == S;
  4695. }
  4696. public override int GetHashCode() {
  4697. return S.GetHashCode();
  4698. }
  4699. }
  4700. public struct Scs : IEquatable<Scs> {
  4701. public Scs(string s, S val) {
  4702. S = s;
  4703. Val = val;
  4704. }
  4705. public string S;
  4706. public S Val;
  4707. public override bool Equals(object o) {
  4708. return (o is Scs) && Equals((Scs) o);
  4709. }
  4710. public bool Equals(Scs other) {
  4711. return other.S == S && other.Val.Equals(Val);
  4712. }
  4713. public override int GetHashCode() {
  4714. return S.GetHashCode() ^ Val.GetHashCode();
  4715. }
  4716. }
  4717. }
  4718. //-------- Scenario 1738
  4719. namespace Scenario1738{
  4720. public class Test
  4721. {
  4722. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check26_object___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  4723. public static Expression check26_object___() {
  4724. if(Main() != 0 ) {
  4725. throw new Exception();
  4726. } else {
  4727. return Expression.Constant(0);
  4728. }
  4729. }
  4730. public static int Main()
  4731. {
  4732. Ext.StartCapture();
  4733. bool success = false;
  4734. try
  4735. {
  4736. success = check26<object>();
  4737. }
  4738. finally
  4739. {
  4740. Ext.StopCapture();
  4741. }
  4742. return success ? 0 : 1;
  4743. }
  4744. static bool check26<Tc>() where Tc : class {
  4745. foreach (Tc val in new Tc[] { null, default(Tc) }) {
  4746. if (!check26<Tc>(val)) {
  4747. return false;
  4748. }
  4749. }
  4750. return true;
  4751. }
  4752. static bool check26<Tc>(Tc val) where Tc : class {
  4753. Expression<Func<Tc>> e =
  4754. Expression.Lambda<Func<Tc>>(
  4755. Expression.Constant(val, typeof(Tc)),
  4756. new System.Collections.Generic.List<ParameterExpression>());
  4757. Func<Tc> f = e.Compile();
  4758. return object.Equals(f(), val);
  4759. }
  4760. }
  4761. public static class Ext {
  4762. public static void StartCapture() {
  4763. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4764. // m.Invoke(null, new object[] { "test.dll" });
  4765. }
  4766. public static void StopCapture() {
  4767. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4768. // m.Invoke(null, new object[0]);
  4769. }
  4770. public static bool IsIntegralOrEnum(Type type) {
  4771. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4772. case TypeCode.Byte:
  4773. case TypeCode.SByte:
  4774. case TypeCode.Int16:
  4775. case TypeCode.Int32:
  4776. case TypeCode.Int64:
  4777. case TypeCode.UInt16:
  4778. case TypeCode.UInt32:
  4779. case TypeCode.UInt64:
  4780. return true;
  4781. default:
  4782. return false;
  4783. }
  4784. }
  4785. public static bool IsFloating(Type type) {
  4786. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4787. case TypeCode.Single:
  4788. case TypeCode.Double:
  4789. return true;
  4790. default:
  4791. return false;
  4792. }
  4793. }
  4794. public static Type GetNonNullableType(Type type) {
  4795. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  4796. type.GetGenericArguments()[0] :
  4797. type;
  4798. }
  4799. }
  4800. public interface I {
  4801. void M();
  4802. }
  4803. public class C : IEquatable<C>, I {
  4804. void I.M() {
  4805. }
  4806. public override bool Equals(object o) {
  4807. return o is C && Equals((C) o);
  4808. }
  4809. public bool Equals(C c) {
  4810. return c != null;
  4811. }
  4812. public override int GetHashCode() {
  4813. return 0;
  4814. }
  4815. }
  4816. public class D : C, IEquatable<D> {
  4817. public int Val;
  4818. public D() {
  4819. }
  4820. public D(int val) {
  4821. Val = val;
  4822. }
  4823. public override bool Equals(object o) {
  4824. return o is D && Equals((D) o);
  4825. }
  4826. public bool Equals(D d) {
  4827. return d != null && d.Val == Val;
  4828. }
  4829. public override int GetHashCode() {
  4830. return Val;
  4831. }
  4832. }
  4833. public enum E {
  4834. A=1, B=2
  4835. }
  4836. public enum El : long {
  4837. A, B, C
  4838. }
  4839. public struct S : IEquatable<S> {
  4840. public override bool Equals(object o) {
  4841. return (o is S) && Equals((S) o);
  4842. }
  4843. public bool Equals(S other) {
  4844. return true;
  4845. }
  4846. public override int GetHashCode() {
  4847. return 0;
  4848. }
  4849. }
  4850. public struct Sp : IEquatable<Sp> {
  4851. public Sp(int i, double d) {
  4852. I = i;
  4853. D = d;
  4854. }
  4855. public int I;
  4856. public double D;
  4857. public override bool Equals(object o) {
  4858. return (o is Sp) && Equals((Sp) o);
  4859. }
  4860. public bool Equals(Sp other) {
  4861. return other.I == I && other.D == D;
  4862. }
  4863. public override int GetHashCode() {
  4864. return I.GetHashCode() ^ D.GetHashCode();
  4865. }
  4866. }
  4867. public struct Ss : IEquatable<Ss> {
  4868. public Ss(S s) {
  4869. Val = s;
  4870. }
  4871. public S Val;
  4872. public override bool Equals(object o) {
  4873. return (o is Ss) && Equals((Ss) o);
  4874. }
  4875. public bool Equals(Ss other) {
  4876. return other.Val.Equals(Val);
  4877. }
  4878. public override int GetHashCode() {
  4879. return Val.GetHashCode();
  4880. }
  4881. }
  4882. public struct Sc : IEquatable<Sc> {
  4883. public Sc(string s) {
  4884. S = s;
  4885. }
  4886. public string S;
  4887. public override bool Equals(object o) {
  4888. return (o is Sc) && Equals((Sc) o);
  4889. }
  4890. public bool Equals(Sc other) {
  4891. return other.S == S;
  4892. }
  4893. public override int GetHashCode() {
  4894. return S.GetHashCode();
  4895. }
  4896. }
  4897. public struct Scs : IEquatable<Scs> {
  4898. public Scs(string s, S val) {
  4899. S = s;
  4900. Val = val;
  4901. }
  4902. public string S;
  4903. public S Val;
  4904. public override bool Equals(object o) {
  4905. return (o is Scs) && Equals((Scs) o);
  4906. }
  4907. public bool Equals(Scs other) {
  4908. return other.S == S && other.Val.Equals(Val);
  4909. }
  4910. public override int GetHashCode() {
  4911. return S.GetHashCode() ^ Val.GetHashCode();
  4912. }
  4913. }
  4914. }
  4915. //-------- Scenario 1739
  4916. namespace Scenario1739{
  4917. public class Test
  4918. {
  4919. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check26_C___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  4920. public static Expression check26_C___() {
  4921. if(Main() != 0 ) {
  4922. throw new Exception();
  4923. } else {
  4924. return Expression.Constant(0);
  4925. }
  4926. }
  4927. public static int Main()
  4928. {
  4929. Ext.StartCapture();
  4930. bool success = false;
  4931. try
  4932. {
  4933. success = check26<C>();
  4934. }
  4935. finally
  4936. {
  4937. Ext.StopCapture();
  4938. }
  4939. return success ? 0 : 1;
  4940. }
  4941. static bool check26<Tc>() where Tc : class {
  4942. foreach (Tc val in new Tc[] { null, default(Tc) }) {
  4943. if (!check26<Tc>(val)) {
  4944. return false;
  4945. }
  4946. }
  4947. return true;
  4948. }
  4949. static bool check26<Tc>(Tc val) where Tc : class {
  4950. Expression<Func<Tc>> e =
  4951. Expression.Lambda<Func<Tc>>(
  4952. Expression.Constant(val, typeof(Tc)),
  4953. new System.Collections.Generic.List<ParameterExpression>());
  4954. Func<Tc> f = e.Compile();
  4955. return object.Equals(f(), val);
  4956. }
  4957. }
  4958. public static class Ext {
  4959. public static void StartCapture() {
  4960. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4961. // m.Invoke(null, new object[] { "test.dll" });
  4962. }
  4963. public static void StopCapture() {
  4964. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  4965. // m.Invoke(null, new object[0]);
  4966. }
  4967. public static bool IsIntegralOrEnum(Type type) {
  4968. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4969. case TypeCode.Byte:
  4970. case TypeCode.SByte:
  4971. case TypeCode.Int16:
  4972. case TypeCode.Int32:
  4973. case TypeCode.Int64:
  4974. case TypeCode.UInt16:
  4975. case TypeCode.UInt32:
  4976. case TypeCode.UInt64:
  4977. return true;
  4978. default:
  4979. return false;
  4980. }
  4981. }
  4982. public static bool IsFloating(Type type) {
  4983. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  4984. case TypeCode.Single:
  4985. case TypeCode.Double:
  4986. return true;
  4987. default:
  4988. return false;
  4989. }
  4990. }
  4991. public static Type GetNonNullableType(Type type) {
  4992. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  4993. type.GetGenericArguments()[0] :
  4994. type;
  4995. }
  4996. }
  4997. public interface I {
  4998. void M();
  4999. }
  5000. public class C : IEquatable<C>, I {
  5001. void I.M() {
  5002. }
  5003. public override bool Equals(object o) {
  5004. return o is C && Equals((C) o);
  5005. }
  5006. public bool Equals(C c) {
  5007. return c != null;
  5008. }
  5009. public override int GetHashCode() {
  5010. return 0;
  5011. }
  5012. }
  5013. public class D : C, IEquatable<D> {
  5014. public int Val;
  5015. public D() {
  5016. }
  5017. public D(int val) {
  5018. Val = val;
  5019. }
  5020. public override bool Equals(object o) {
  5021. return o is D && Equals((D) o);
  5022. }
  5023. public bool Equals(D d) {
  5024. return d != null && d.Val == Val;
  5025. }
  5026. public override int GetHashCode() {
  5027. return Val;
  5028. }
  5029. }
  5030. public enum E {
  5031. A=1, B=2
  5032. }
  5033. public enum El : long {
  5034. A, B, C
  5035. }
  5036. public struct S : IEquatable<S> {
  5037. public override bool Equals(object o) {
  5038. return (o is S) && Equals((S) o);
  5039. }
  5040. public bool Equals(S other) {
  5041. return true;
  5042. }
  5043. public override int GetHashCode() {
  5044. return 0;
  5045. }
  5046. }
  5047. public struct Sp : IEquatable<Sp> {
  5048. public Sp(int i, double d) {
  5049. I = i;
  5050. D = d;
  5051. }
  5052. public int I;
  5053. public double D;
  5054. public override bool Equals(object o) {
  5055. return (o is Sp) && Equals((Sp) o);
  5056. }
  5057. public bool Equals(Sp other) {
  5058. return other.I == I && other.D == D;
  5059. }
  5060. public override int GetHashCode() {
  5061. return I.GetHashCode() ^ D.GetHashCode();
  5062. }
  5063. }
  5064. public struct Ss : IEquatable<Ss> {
  5065. public Ss(S s) {
  5066. Val = s;
  5067. }
  5068. public S Val;
  5069. public override bool Equals(object o) {
  5070. return (o is Ss) && Equals((Ss) o);
  5071. }
  5072. public bool Equals(Ss other) {
  5073. return other.Val.Equals(Val);
  5074. }
  5075. public override int GetHashCode() {
  5076. return Val.GetHashCode();
  5077. }
  5078. }
  5079. public struct Sc : IEquatable<Sc> {
  5080. public Sc(string s) {
  5081. S = s;
  5082. }
  5083. public string S;
  5084. public override bool Equals(object o) {
  5085. return (o is Sc) && Equals((Sc) o);
  5086. }
  5087. public bool Equals(Sc other) {
  5088. return other.S == S;
  5089. }
  5090. public override int GetHashCode() {
  5091. return S.GetHashCode();
  5092. }
  5093. }
  5094. public struct Scs : IEquatable<Scs> {
  5095. public Scs(string s, S val) {
  5096. S = s;
  5097. Val = val;
  5098. }
  5099. public string S;
  5100. public S Val;
  5101. public override bool Equals(object o) {
  5102. return (o is Scs) && Equals((Scs) o);
  5103. }
  5104. public bool Equals(Scs other) {
  5105. return other.S == S && other.Val.Equals(Val);
  5106. }
  5107. public override int GetHashCode() {
  5108. return S.GetHashCode() ^ Val.GetHashCode();
  5109. }
  5110. }
  5111. }
  5112. //-------- Scenario 1740
  5113. namespace Scenario1740{
  5114. public class Test
  5115. {
  5116. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check27_object___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  5117. public static Expression check27_object___() {
  5118. if(Main() != 0 ) {
  5119. throw new Exception();
  5120. } else {
  5121. return Expression.Constant(0);
  5122. }
  5123. }
  5124. public static int Main()
  5125. {
  5126. Ext.StartCapture();
  5127. bool success = false;
  5128. try
  5129. {
  5130. success = check27<object>();
  5131. }
  5132. finally
  5133. {
  5134. Ext.StopCapture();
  5135. }
  5136. return success ? 0 : 1;
  5137. }
  5138. static bool check27<Tcn>() where Tcn : class, new() {
  5139. foreach (Tcn val in new Tcn[] { null, default(Tcn), new Tcn() }) {
  5140. if (!check27<Tcn>(val)) {
  5141. return false;
  5142. }
  5143. }
  5144. return true;
  5145. }
  5146. static bool check27<Tcn>(Tcn val) where Tcn : class, new() {
  5147. Expression<Func<Tcn>> e =
  5148. Expression.Lambda<Func<Tcn>>(
  5149. Expression.Constant(val, typeof(Tcn)),
  5150. new System.Collections.Generic.List<ParameterExpression>());
  5151. Func<Tcn> f = e.Compile();
  5152. return object.Equals(f(), val);
  5153. }
  5154. }
  5155. public static class Ext {
  5156. public static void StartCapture() {
  5157. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5158. // m.Invoke(null, new object[] { "test.dll" });
  5159. }
  5160. public static void StopCapture() {
  5161. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5162. // m.Invoke(null, new object[0]);
  5163. }
  5164. public static bool IsIntegralOrEnum(Type type) {
  5165. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5166. case TypeCode.Byte:
  5167. case TypeCode.SByte:
  5168. case TypeCode.Int16:
  5169. case TypeCode.Int32:
  5170. case TypeCode.Int64:
  5171. case TypeCode.UInt16:
  5172. case TypeCode.UInt32:
  5173. case TypeCode.UInt64:
  5174. return true;
  5175. default:
  5176. return false;
  5177. }
  5178. }
  5179. public static bool IsFloating(Type type) {
  5180. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5181. case TypeCode.Single:
  5182. case TypeCode.Double:
  5183. return true;
  5184. default:
  5185. return false;
  5186. }
  5187. }
  5188. public static Type GetNonNullableType(Type type) {
  5189. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  5190. type.GetGenericArguments()[0] :
  5191. type;
  5192. }
  5193. }
  5194. public interface I {
  5195. void M();
  5196. }
  5197. public class C : IEquatable<C>, I {
  5198. void I.M() {
  5199. }
  5200. public override bool Equals(object o) {
  5201. return o is C && Equals((C) o);
  5202. }
  5203. public bool Equals(C c) {
  5204. return c != null;
  5205. }
  5206. public override int GetHashCode() {
  5207. return 0;
  5208. }
  5209. }
  5210. public class D : C, IEquatable<D> {
  5211. public int Val;
  5212. public D() {
  5213. }
  5214. public D(int val) {
  5215. Val = val;
  5216. }
  5217. public override bool Equals(object o) {
  5218. return o is D && Equals((D) o);
  5219. }
  5220. public bool Equals(D d) {
  5221. return d != null && d.Val == Val;
  5222. }
  5223. public override int GetHashCode() {
  5224. return Val;
  5225. }
  5226. }
  5227. public enum E {
  5228. A=1, B=2
  5229. }
  5230. public enum El : long {
  5231. A, B, C
  5232. }
  5233. public struct S : IEquatable<S> {
  5234. public override bool Equals(object o) {
  5235. return (o is S) && Equals((S) o);
  5236. }
  5237. public bool Equals(S other) {
  5238. return true;
  5239. }
  5240. public override int GetHashCode() {
  5241. return 0;
  5242. }
  5243. }
  5244. public struct Sp : IEquatable<Sp> {
  5245. public Sp(int i, double d) {
  5246. I = i;
  5247. D = d;
  5248. }
  5249. public int I;
  5250. public double D;
  5251. public override bool Equals(object o) {
  5252. return (o is Sp) && Equals((Sp) o);
  5253. }
  5254. public bool Equals(Sp other) {
  5255. return other.I == I && other.D == D;
  5256. }
  5257. public override int GetHashCode() {
  5258. return I.GetHashCode() ^ D.GetHashCode();
  5259. }
  5260. }
  5261. public struct Ss : IEquatable<Ss> {
  5262. public Ss(S s) {
  5263. Val = s;
  5264. }
  5265. public S Val;
  5266. public override bool Equals(object o) {
  5267. return (o is Ss) && Equals((Ss) o);
  5268. }
  5269. public bool Equals(Ss other) {
  5270. return other.Val.Equals(Val);
  5271. }
  5272. public override int GetHashCode() {
  5273. return Val.GetHashCode();
  5274. }
  5275. }
  5276. public struct Sc : IEquatable<Sc> {
  5277. public Sc(string s) {
  5278. S = s;
  5279. }
  5280. public string S;
  5281. public override bool Equals(object o) {
  5282. return (o is Sc) && Equals((Sc) o);
  5283. }
  5284. public bool Equals(Sc other) {
  5285. return other.S == S;
  5286. }
  5287. public override int GetHashCode() {
  5288. return S.GetHashCode();
  5289. }
  5290. }
  5291. public struct Scs : IEquatable<Scs> {
  5292. public Scs(string s, S val) {
  5293. S = s;
  5294. Val = val;
  5295. }
  5296. public string S;
  5297. public S Val;
  5298. public override bool Equals(object o) {
  5299. return (o is Scs) && Equals((Scs) o);
  5300. }
  5301. public bool Equals(Scs other) {
  5302. return other.S == S && other.Val.Equals(Val);
  5303. }
  5304. public override int GetHashCode() {
  5305. return S.GetHashCode() ^ Val.GetHashCode();
  5306. }
  5307. }
  5308. }
  5309. //-------- Scenario 1741
  5310. namespace Scenario1741{
  5311. public class Test
  5312. {
  5313. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check27_C___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  5314. public static Expression check27_C___() {
  5315. if(Main() != 0 ) {
  5316. throw new Exception();
  5317. } else {
  5318. return Expression.Constant(0);
  5319. }
  5320. }
  5321. public static int Main()
  5322. {
  5323. Ext.StartCapture();
  5324. bool success = false;
  5325. try
  5326. {
  5327. success = check27<C>();
  5328. }
  5329. finally
  5330. {
  5331. Ext.StopCapture();
  5332. }
  5333. return success ? 0 : 1;
  5334. }
  5335. static bool check27<Tcn>() where Tcn : class, new() {
  5336. foreach (Tcn val in new Tcn[] { null, default(Tcn), new Tcn() }) {
  5337. if (!check27<Tcn>(val)) {
  5338. return false;
  5339. }
  5340. }
  5341. return true;
  5342. }
  5343. static bool check27<Tcn>(Tcn val) where Tcn : class, new() {
  5344. Expression<Func<Tcn>> e =
  5345. Expression.Lambda<Func<Tcn>>(
  5346. Expression.Constant(val, typeof(Tcn)),
  5347. new System.Collections.Generic.List<ParameterExpression>());
  5348. Func<Tcn> f = e.Compile();
  5349. return object.Equals(f(), val);
  5350. }
  5351. }
  5352. public static class Ext {
  5353. public static void StartCapture() {
  5354. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5355. // m.Invoke(null, new object[] { "test.dll" });
  5356. }
  5357. public static void StopCapture() {
  5358. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5359. // m.Invoke(null, new object[0]);
  5360. }
  5361. public static bool IsIntegralOrEnum(Type type) {
  5362. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5363. case TypeCode.Byte:
  5364. case TypeCode.SByte:
  5365. case TypeCode.Int16:
  5366. case TypeCode.Int32:
  5367. case TypeCode.Int64:
  5368. case TypeCode.UInt16:
  5369. case TypeCode.UInt32:
  5370. case TypeCode.UInt64:
  5371. return true;
  5372. default:
  5373. return false;
  5374. }
  5375. }
  5376. public static bool IsFloating(Type type) {
  5377. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5378. case TypeCode.Single:
  5379. case TypeCode.Double:
  5380. return true;
  5381. default:
  5382. return false;
  5383. }
  5384. }
  5385. public static Type GetNonNullableType(Type type) {
  5386. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  5387. type.GetGenericArguments()[0] :
  5388. type;
  5389. }
  5390. }
  5391. public interface I {
  5392. void M();
  5393. }
  5394. public class C : IEquatable<C>, I {
  5395. void I.M() {
  5396. }
  5397. public override bool Equals(object o) {
  5398. return o is C && Equals((C) o);
  5399. }
  5400. public bool Equals(C c) {
  5401. return c != null;
  5402. }
  5403. public override int GetHashCode() {
  5404. return 0;
  5405. }
  5406. }
  5407. public class D : C, IEquatable<D> {
  5408. public int Val;
  5409. public D() {
  5410. }
  5411. public D(int val) {
  5412. Val = val;
  5413. }
  5414. public override bool Equals(object o) {
  5415. return o is D && Equals((D) o);
  5416. }
  5417. public bool Equals(D d) {
  5418. return d != null && d.Val == Val;
  5419. }
  5420. public override int GetHashCode() {
  5421. return Val;
  5422. }
  5423. }
  5424. public enum E {
  5425. A=1, B=2
  5426. }
  5427. public enum El : long {
  5428. A, B, C
  5429. }
  5430. public struct S : IEquatable<S> {
  5431. public override bool Equals(object o) {
  5432. return (o is S) && Equals((S) o);
  5433. }
  5434. public bool Equals(S other) {
  5435. return true;
  5436. }
  5437. public override int GetHashCode() {
  5438. return 0;
  5439. }
  5440. }
  5441. public struct Sp : IEquatable<Sp> {
  5442. public Sp(int i, double d) {
  5443. I = i;
  5444. D = d;
  5445. }
  5446. public int I;
  5447. public double D;
  5448. public override bool Equals(object o) {
  5449. return (o is Sp) && Equals((Sp) o);
  5450. }
  5451. public bool Equals(Sp other) {
  5452. return other.I == I && other.D == D;
  5453. }
  5454. public override int GetHashCode() {
  5455. return I.GetHashCode() ^ D.GetHashCode();
  5456. }
  5457. }
  5458. public struct Ss : IEquatable<Ss> {
  5459. public Ss(S s) {
  5460. Val = s;
  5461. }
  5462. public S Val;
  5463. public override bool Equals(object o) {
  5464. return (o is Ss) && Equals((Ss) o);
  5465. }
  5466. public bool Equals(Ss other) {
  5467. return other.Val.Equals(Val);
  5468. }
  5469. public override int GetHashCode() {
  5470. return Val.GetHashCode();
  5471. }
  5472. }
  5473. public struct Sc : IEquatable<Sc> {
  5474. public Sc(string s) {
  5475. S = s;
  5476. }
  5477. public string S;
  5478. public override bool Equals(object o) {
  5479. return (o is Sc) && Equals((Sc) o);
  5480. }
  5481. public bool Equals(Sc other) {
  5482. return other.S == S;
  5483. }
  5484. public override int GetHashCode() {
  5485. return S.GetHashCode();
  5486. }
  5487. }
  5488. public struct Scs : IEquatable<Scs> {
  5489. public Scs(string s, S val) {
  5490. S = s;
  5491. Val = val;
  5492. }
  5493. public string S;
  5494. public S Val;
  5495. public override bool Equals(object o) {
  5496. return (o is Scs) && Equals((Scs) o);
  5497. }
  5498. public bool Equals(Scs other) {
  5499. return other.S == S && other.Val.Equals(Val);
  5500. }
  5501. public override int GetHashCode() {
  5502. return S.GetHashCode() ^ Val.GetHashCode();
  5503. }
  5504. }
  5505. }
  5506. //-------- Scenario 1742
  5507. namespace Scenario1742{
  5508. public class Test
  5509. {
  5510. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check28_C___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  5511. public static Expression check28_C___() {
  5512. if(Main() != 0 ) {
  5513. throw new Exception();
  5514. } else {
  5515. return Expression.Constant(0);
  5516. }
  5517. }
  5518. public static int Main()
  5519. {
  5520. Ext.StartCapture();
  5521. bool success = false;
  5522. try
  5523. {
  5524. success = check28<C>();
  5525. }
  5526. finally
  5527. {
  5528. Ext.StopCapture();
  5529. }
  5530. return success ? 0 : 1;
  5531. }
  5532. static bool check28<TC>() where TC : C {
  5533. foreach (TC val in new TC[] { null, default(TC), (TC) new C() }) {
  5534. if (!check28<TC>(val)) {
  5535. return false;
  5536. }
  5537. }
  5538. return true;
  5539. }
  5540. static bool check28<TC>(TC val) where TC : C {
  5541. Expression<Func<TC>> e =
  5542. Expression.Lambda<Func<TC>>(
  5543. Expression.Constant(val, typeof(TC)),
  5544. new System.Collections.Generic.List<ParameterExpression>());
  5545. Func<TC> f = e.Compile();
  5546. return object.Equals(f(), val);
  5547. }
  5548. }
  5549. public static class Ext {
  5550. public static void StartCapture() {
  5551. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5552. // m.Invoke(null, new object[] { "test.dll" });
  5553. }
  5554. public static void StopCapture() {
  5555. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5556. // m.Invoke(null, new object[0]);
  5557. }
  5558. public static bool IsIntegralOrEnum(Type type) {
  5559. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5560. case TypeCode.Byte:
  5561. case TypeCode.SByte:
  5562. case TypeCode.Int16:
  5563. case TypeCode.Int32:
  5564. case TypeCode.Int64:
  5565. case TypeCode.UInt16:
  5566. case TypeCode.UInt32:
  5567. case TypeCode.UInt64:
  5568. return true;
  5569. default:
  5570. return false;
  5571. }
  5572. }
  5573. public static bool IsFloating(Type type) {
  5574. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5575. case TypeCode.Single:
  5576. case TypeCode.Double:
  5577. return true;
  5578. default:
  5579. return false;
  5580. }
  5581. }
  5582. public static Type GetNonNullableType(Type type) {
  5583. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  5584. type.GetGenericArguments()[0] :
  5585. type;
  5586. }
  5587. }
  5588. public interface I {
  5589. void M();
  5590. }
  5591. public class C : IEquatable<C>, I {
  5592. void I.M() {
  5593. }
  5594. public override bool Equals(object o) {
  5595. return o is C && Equals((C) o);
  5596. }
  5597. public bool Equals(C c) {
  5598. return c != null;
  5599. }
  5600. public override int GetHashCode() {
  5601. return 0;
  5602. }
  5603. }
  5604. public class D : C, IEquatable<D> {
  5605. public int Val;
  5606. public D() {
  5607. }
  5608. public D(int val) {
  5609. Val = val;
  5610. }
  5611. public override bool Equals(object o) {
  5612. return o is D && Equals((D) o);
  5613. }
  5614. public bool Equals(D d) {
  5615. return d != null && d.Val == Val;
  5616. }
  5617. public override int GetHashCode() {
  5618. return Val;
  5619. }
  5620. }
  5621. public enum E {
  5622. A=1, B=2
  5623. }
  5624. public enum El : long {
  5625. A, B, C
  5626. }
  5627. public struct S : IEquatable<S> {
  5628. public override bool Equals(object o) {
  5629. return (o is S) && Equals((S) o);
  5630. }
  5631. public bool Equals(S other) {
  5632. return true;
  5633. }
  5634. public override int GetHashCode() {
  5635. return 0;
  5636. }
  5637. }
  5638. public struct Sp : IEquatable<Sp> {
  5639. public Sp(int i, double d) {
  5640. I = i;
  5641. D = d;
  5642. }
  5643. public int I;
  5644. public double D;
  5645. public override bool Equals(object o) {
  5646. return (o is Sp) && Equals((Sp) o);
  5647. }
  5648. public bool Equals(Sp other) {
  5649. return other.I == I && other.D == D;
  5650. }
  5651. public override int GetHashCode() {
  5652. return I.GetHashCode() ^ D.GetHashCode();
  5653. }
  5654. }
  5655. public struct Ss : IEquatable<Ss> {
  5656. public Ss(S s) {
  5657. Val = s;
  5658. }
  5659. public S Val;
  5660. public override bool Equals(object o) {
  5661. return (o is Ss) && Equals((Ss) o);
  5662. }
  5663. public bool Equals(Ss other) {
  5664. return other.Val.Equals(Val);
  5665. }
  5666. public override int GetHashCode() {
  5667. return Val.GetHashCode();
  5668. }
  5669. }
  5670. public struct Sc : IEquatable<Sc> {
  5671. public Sc(string s) {
  5672. S = s;
  5673. }
  5674. public string S;
  5675. public override bool Equals(object o) {
  5676. return (o is Sc) && Equals((Sc) o);
  5677. }
  5678. public bool Equals(Sc other) {
  5679. return other.S == S;
  5680. }
  5681. public override int GetHashCode() {
  5682. return S.GetHashCode();
  5683. }
  5684. }
  5685. public struct Scs : IEquatable<Scs> {
  5686. public Scs(string s, S val) {
  5687. S = s;
  5688. Val = val;
  5689. }
  5690. public string S;
  5691. public S Val;
  5692. public override bool Equals(object o) {
  5693. return (o is Scs) && Equals((Scs) o);
  5694. }
  5695. public bool Equals(Scs other) {
  5696. return other.S == S && other.Val.Equals(Val);
  5697. }
  5698. public override int GetHashCode() {
  5699. return S.GetHashCode() ^ Val.GetHashCode();
  5700. }
  5701. }
  5702. }
  5703. //-------- Scenario 1743
  5704. namespace Scenario1743{
  5705. public class Test
  5706. {
  5707. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check29_C___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  5708. public static Expression check29_C___() {
  5709. if(Main() != 0 ) {
  5710. throw new Exception();
  5711. } else {
  5712. return Expression.Constant(0);
  5713. }
  5714. }
  5715. public static int Main()
  5716. {
  5717. Ext.StartCapture();
  5718. bool success = false;
  5719. try
  5720. {
  5721. success = check29<C>();
  5722. }
  5723. finally
  5724. {
  5725. Ext.StopCapture();
  5726. }
  5727. return success ? 0 : 1;
  5728. }
  5729. static bool check29<TCn>() where TCn : C, new() {
  5730. foreach (TCn val in new TCn[] { null, default(TCn), new TCn(), (TCn) new C() }) {
  5731. if (!check29<TCn>(val)) {
  5732. return false;
  5733. }
  5734. }
  5735. return true;
  5736. }
  5737. static bool check29<TCn>(TCn val) where TCn : C, new() {
  5738. Expression<Func<TCn>> e =
  5739. Expression.Lambda<Func<TCn>>(
  5740. Expression.Constant(val, typeof(TCn)),
  5741. new System.Collections.Generic.List<ParameterExpression>());
  5742. Func<TCn> f = e.Compile();
  5743. return object.Equals(f(), val);
  5744. }
  5745. }
  5746. public static class Ext {
  5747. public static void StartCapture() {
  5748. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5749. // m.Invoke(null, new object[] { "test.dll" });
  5750. }
  5751. public static void StopCapture() {
  5752. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5753. // m.Invoke(null, new object[0]);
  5754. }
  5755. public static bool IsIntegralOrEnum(Type type) {
  5756. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5757. case TypeCode.Byte:
  5758. case TypeCode.SByte:
  5759. case TypeCode.Int16:
  5760. case TypeCode.Int32:
  5761. case TypeCode.Int64:
  5762. case TypeCode.UInt16:
  5763. case TypeCode.UInt32:
  5764. case TypeCode.UInt64:
  5765. return true;
  5766. default:
  5767. return false;
  5768. }
  5769. }
  5770. public static bool IsFloating(Type type) {
  5771. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5772. case TypeCode.Single:
  5773. case TypeCode.Double:
  5774. return true;
  5775. default:
  5776. return false;
  5777. }
  5778. }
  5779. public static Type GetNonNullableType(Type type) {
  5780. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  5781. type.GetGenericArguments()[0] :
  5782. type;
  5783. }
  5784. }
  5785. public interface I {
  5786. void M();
  5787. }
  5788. public class C : IEquatable<C>, I {
  5789. void I.M() {
  5790. }
  5791. public override bool Equals(object o) {
  5792. return o is C && Equals((C) o);
  5793. }
  5794. public bool Equals(C c) {
  5795. return c != null;
  5796. }
  5797. public override int GetHashCode() {
  5798. return 0;
  5799. }
  5800. }
  5801. public class D : C, IEquatable<D> {
  5802. public int Val;
  5803. public D() {
  5804. }
  5805. public D(int val) {
  5806. Val = val;
  5807. }
  5808. public override bool Equals(object o) {
  5809. return o is D && Equals((D) o);
  5810. }
  5811. public bool Equals(D d) {
  5812. return d != null && d.Val == Val;
  5813. }
  5814. public override int GetHashCode() {
  5815. return Val;
  5816. }
  5817. }
  5818. public enum E {
  5819. A=1, B=2
  5820. }
  5821. public enum El : long {
  5822. A, B, C
  5823. }
  5824. public struct S : IEquatable<S> {
  5825. public override bool Equals(object o) {
  5826. return (o is S) && Equals((S) o);
  5827. }
  5828. public bool Equals(S other) {
  5829. return true;
  5830. }
  5831. public override int GetHashCode() {
  5832. return 0;
  5833. }
  5834. }
  5835. public struct Sp : IEquatable<Sp> {
  5836. public Sp(int i, double d) {
  5837. I = i;
  5838. D = d;
  5839. }
  5840. public int I;
  5841. public double D;
  5842. public override bool Equals(object o) {
  5843. return (o is Sp) && Equals((Sp) o);
  5844. }
  5845. public bool Equals(Sp other) {
  5846. return other.I == I && other.D == D;
  5847. }
  5848. public override int GetHashCode() {
  5849. return I.GetHashCode() ^ D.GetHashCode();
  5850. }
  5851. }
  5852. public struct Ss : IEquatable<Ss> {
  5853. public Ss(S s) {
  5854. Val = s;
  5855. }
  5856. public S Val;
  5857. public override bool Equals(object o) {
  5858. return (o is Ss) && Equals((Ss) o);
  5859. }
  5860. public bool Equals(Ss other) {
  5861. return other.Val.Equals(Val);
  5862. }
  5863. public override int GetHashCode() {
  5864. return Val.GetHashCode();
  5865. }
  5866. }
  5867. public struct Sc : IEquatable<Sc> {
  5868. public Sc(string s) {
  5869. S = s;
  5870. }
  5871. public string S;
  5872. public override bool Equals(object o) {
  5873. return (o is Sc) && Equals((Sc) o);
  5874. }
  5875. public bool Equals(Sc other) {
  5876. return other.S == S;
  5877. }
  5878. public override int GetHashCode() {
  5879. return S.GetHashCode();
  5880. }
  5881. }
  5882. public struct Scs : IEquatable<Scs> {
  5883. public Scs(string s, S val) {
  5884. S = s;
  5885. Val = val;
  5886. }
  5887. public string S;
  5888. public S Val;
  5889. public override bool Equals(object o) {
  5890. return (o is Scs) && Equals((Scs) o);
  5891. }
  5892. public bool Equals(Scs other) {
  5893. return other.S == S && other.Val.Equals(Val);
  5894. }
  5895. public override int GetHashCode() {
  5896. return S.GetHashCode() ^ Val.GetHashCode();
  5897. }
  5898. }
  5899. }
  5900. //-------- Scenario 1744
  5901. namespace Scenario1744{
  5902. public class Test
  5903. {
  5904. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check30__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  5905. public static Expression check30__() {
  5906. if(Main() != 0 ) {
  5907. throw new Exception();
  5908. } else {
  5909. return Expression.Constant(0);
  5910. }
  5911. }
  5912. public static int Main()
  5913. {
  5914. Ext.StartCapture();
  5915. bool success = false;
  5916. try
  5917. {
  5918. success = check30();
  5919. }
  5920. finally
  5921. {
  5922. Ext.StopCapture();
  5923. }
  5924. return success ? 0 : 1;
  5925. }
  5926. static bool check30() {
  5927. foreach (Delegate val in new Delegate[] { null, (Func<object>) delegate() { return null; }, (Func<int, int>) delegate(int i) { return i+1; }, (Action<object>) delegate { } }) {
  5928. if (!check30(val)) {
  5929. return false;
  5930. }
  5931. }
  5932. return true;
  5933. }
  5934. static bool check30(Delegate val) {
  5935. Expression<Func<Delegate>> e =
  5936. Expression.Lambda<Func<Delegate>>(
  5937. Expression.Constant(val, typeof(Delegate)),
  5938. new System.Collections.Generic.List<ParameterExpression>());
  5939. Func<Delegate> f = e.Compile();
  5940. return object.Equals(f(), val);
  5941. }
  5942. }
  5943. public static class Ext {
  5944. public static void StartCapture() {
  5945. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5946. // m.Invoke(null, new object[] { "test.dll" });
  5947. }
  5948. public static void StopCapture() {
  5949. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  5950. // m.Invoke(null, new object[0]);
  5951. }
  5952. public static bool IsIntegralOrEnum(Type type) {
  5953. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5954. case TypeCode.Byte:
  5955. case TypeCode.SByte:
  5956. case TypeCode.Int16:
  5957. case TypeCode.Int32:
  5958. case TypeCode.Int64:
  5959. case TypeCode.UInt16:
  5960. case TypeCode.UInt32:
  5961. case TypeCode.UInt64:
  5962. return true;
  5963. default:
  5964. return false;
  5965. }
  5966. }
  5967. public static bool IsFloating(Type type) {
  5968. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  5969. case TypeCode.Single:
  5970. case TypeCode.Double:
  5971. return true;
  5972. default:
  5973. return false;
  5974. }
  5975. }
  5976. public static Type GetNonNullableType(Type type) {
  5977. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  5978. type.GetGenericArguments()[0] :
  5979. type;
  5980. }
  5981. }
  5982. }
  5983. //-------- Scenario 1745
  5984. namespace Scenario1745{
  5985. public class Test
  5986. {
  5987. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check31__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  5988. public static Expression check31__() {
  5989. if(Main() != 0 ) {
  5990. throw new Exception();
  5991. } else {
  5992. return Expression.Constant(0);
  5993. }
  5994. }
  5995. public static int Main()
  5996. {
  5997. Ext.StartCapture();
  5998. bool success = false;
  5999. try
  6000. {
  6001. success = check31();
  6002. }
  6003. finally
  6004. {
  6005. Ext.StopCapture();
  6006. }
  6007. return success ? 0 : 1;
  6008. }
  6009. static bool check31() {
  6010. foreach (Func<object> val in new Func<object>[] { null, (Func<object>) delegate() { return null; } }) {
  6011. if (!check31(val)) {
  6012. return false;
  6013. }
  6014. }
  6015. return true;
  6016. }
  6017. static bool check31(Func<object> val) {
  6018. Expression<Func<Func<object>>> e =
  6019. Expression.Lambda<Func<Func<object>>>(
  6020. Expression.Constant(val, typeof(Func<object>)),
  6021. new System.Collections.Generic.List<ParameterExpression>());
  6022. Func<Func<object>> f = e.Compile();
  6023. return object.Equals(f(), val);
  6024. }
  6025. }
  6026. public static class Ext {
  6027. public static void StartCapture() {
  6028. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6029. // m.Invoke(null, new object[] { "test.dll" });
  6030. }
  6031. public static void StopCapture() {
  6032. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6033. // m.Invoke(null, new object[0]);
  6034. }
  6035. public static bool IsIntegralOrEnum(Type type) {
  6036. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6037. case TypeCode.Byte:
  6038. case TypeCode.SByte:
  6039. case TypeCode.Int16:
  6040. case TypeCode.Int32:
  6041. case TypeCode.Int64:
  6042. case TypeCode.UInt16:
  6043. case TypeCode.UInt32:
  6044. case TypeCode.UInt64:
  6045. return true;
  6046. default:
  6047. return false;
  6048. }
  6049. }
  6050. public static bool IsFloating(Type type) {
  6051. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6052. case TypeCode.Single:
  6053. case TypeCode.Double:
  6054. return true;
  6055. default:
  6056. return false;
  6057. }
  6058. }
  6059. public static Type GetNonNullableType(Type type) {
  6060. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  6061. type.GetGenericArguments()[0] :
  6062. type;
  6063. }
  6064. }
  6065. }
  6066. //-------- Scenario 1746
  6067. namespace Scenario1746{
  6068. public class Test
  6069. {
  6070. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check32__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  6071. public static Expression check32__() {
  6072. if(Main() != 0 ) {
  6073. throw new Exception();
  6074. } else {
  6075. return Expression.Constant(0);
  6076. }
  6077. }
  6078. public static int Main()
  6079. {
  6080. Ext.StartCapture();
  6081. bool success = false;
  6082. try
  6083. {
  6084. success = check32();
  6085. }
  6086. finally
  6087. {
  6088. Ext.StopCapture();
  6089. }
  6090. return success ? 0 : 1;
  6091. }
  6092. static bool check32() {
  6093. foreach (IEquatable<C> val in new IEquatable<C>[] { null, new C(), new D(), new D(0), new D(5) }) {
  6094. if (!check32(val)) {
  6095. return false;
  6096. }
  6097. }
  6098. return true;
  6099. }
  6100. static bool check32(IEquatable<C> val) {
  6101. Expression<Func<IEquatable<C>>> e =
  6102. Expression.Lambda<Func<IEquatable<C>>>(
  6103. Expression.Constant(val, typeof(IEquatable<C>)),
  6104. new System.Collections.Generic.List<ParameterExpression>());
  6105. Func<IEquatable<C>> f = e.Compile();
  6106. return object.Equals(f(), val);
  6107. }
  6108. }
  6109. public static class Ext {
  6110. public static void StartCapture() {
  6111. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6112. // m.Invoke(null, new object[] { "test.dll" });
  6113. }
  6114. public static void StopCapture() {
  6115. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6116. // m.Invoke(null, new object[0]);
  6117. }
  6118. public static bool IsIntegralOrEnum(Type type) {
  6119. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6120. case TypeCode.Byte:
  6121. case TypeCode.SByte:
  6122. case TypeCode.Int16:
  6123. case TypeCode.Int32:
  6124. case TypeCode.Int64:
  6125. case TypeCode.UInt16:
  6126. case TypeCode.UInt32:
  6127. case TypeCode.UInt64:
  6128. return true;
  6129. default:
  6130. return false;
  6131. }
  6132. }
  6133. public static bool IsFloating(Type type) {
  6134. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6135. case TypeCode.Single:
  6136. case TypeCode.Double:
  6137. return true;
  6138. default:
  6139. return false;
  6140. }
  6141. }
  6142. public static Type GetNonNullableType(Type type) {
  6143. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  6144. type.GetGenericArguments()[0] :
  6145. type;
  6146. }
  6147. }
  6148. public interface I {
  6149. void M();
  6150. }
  6151. public class C : IEquatable<C>, I {
  6152. void I.M() {
  6153. }
  6154. public override bool Equals(object o) {
  6155. return o is C && Equals((C) o);
  6156. }
  6157. public bool Equals(C c) {
  6158. return c != null;
  6159. }
  6160. public override int GetHashCode() {
  6161. return 0;
  6162. }
  6163. }
  6164. public class D : C, IEquatable<D> {
  6165. public int Val;
  6166. public D() {
  6167. }
  6168. public D(int val) {
  6169. Val = val;
  6170. }
  6171. public override bool Equals(object o) {
  6172. return o is D && Equals((D) o);
  6173. }
  6174. public bool Equals(D d) {
  6175. return d != null && d.Val == Val;
  6176. }
  6177. public override int GetHashCode() {
  6178. return Val;
  6179. }
  6180. }
  6181. public enum E {
  6182. A=1, B=2
  6183. }
  6184. public enum El : long {
  6185. A, B, C
  6186. }
  6187. public struct S : IEquatable<S> {
  6188. public override bool Equals(object o) {
  6189. return (o is S) && Equals((S) o);
  6190. }
  6191. public bool Equals(S other) {
  6192. return true;
  6193. }
  6194. public override int GetHashCode() {
  6195. return 0;
  6196. }
  6197. }
  6198. public struct Sp : IEquatable<Sp> {
  6199. public Sp(int i, double d) {
  6200. I = i;
  6201. D = d;
  6202. }
  6203. public int I;
  6204. public double D;
  6205. public override bool Equals(object o) {
  6206. return (o is Sp) && Equals((Sp) o);
  6207. }
  6208. public bool Equals(Sp other) {
  6209. return other.I == I && other.D == D;
  6210. }
  6211. public override int GetHashCode() {
  6212. return I.GetHashCode() ^ D.GetHashCode();
  6213. }
  6214. }
  6215. public struct Ss : IEquatable<Ss> {
  6216. public Ss(S s) {
  6217. Val = s;
  6218. }
  6219. public S Val;
  6220. public override bool Equals(object o) {
  6221. return (o is Ss) && Equals((Ss) o);
  6222. }
  6223. public bool Equals(Ss other) {
  6224. return other.Val.Equals(Val);
  6225. }
  6226. public override int GetHashCode() {
  6227. return Val.GetHashCode();
  6228. }
  6229. }
  6230. public struct Sc : IEquatable<Sc> {
  6231. public Sc(string s) {
  6232. S = s;
  6233. }
  6234. public string S;
  6235. public override bool Equals(object o) {
  6236. return (o is Sc) && Equals((Sc) o);
  6237. }
  6238. public bool Equals(Sc other) {
  6239. return other.S == S;
  6240. }
  6241. public override int GetHashCode() {
  6242. return S.GetHashCode();
  6243. }
  6244. }
  6245. public struct Scs : IEquatable<Scs> {
  6246. public Scs(string s, S val) {
  6247. S = s;
  6248. Val = val;
  6249. }
  6250. public string S;
  6251. public S Val;
  6252. public override bool Equals(object o) {
  6253. return (o is Scs) && Equals((Scs) o);
  6254. }
  6255. public bool Equals(Scs other) {
  6256. return other.S == S && other.Val.Equals(Val);
  6257. }
  6258. public override int GetHashCode() {
  6259. return S.GetHashCode() ^ Val.GetHashCode();
  6260. }
  6261. }
  6262. }
  6263. //-------- Scenario 1747
  6264. namespace Scenario1747{
  6265. public class Test
  6266. {
  6267. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check33__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  6268. public static Expression check33__() {
  6269. if(Main() != 0 ) {
  6270. throw new Exception();
  6271. } else {
  6272. return Expression.Constant(0);
  6273. }
  6274. }
  6275. public static int Main()
  6276. {
  6277. Ext.StartCapture();
  6278. bool success = false;
  6279. try
  6280. {
  6281. success = check33();
  6282. }
  6283. finally
  6284. {
  6285. Ext.StopCapture();
  6286. }
  6287. return success ? 0 : 1;
  6288. }
  6289. static bool check33() {
  6290. foreach (IEquatable<D> val in new IEquatable<D>[] { null, new D(), new D(0), new D(5) }) {
  6291. if (!check33(val)) {
  6292. return false;
  6293. }
  6294. }
  6295. return true;
  6296. }
  6297. static bool check33(IEquatable<D> val) {
  6298. Expression<Func<IEquatable<D>>> e =
  6299. Expression.Lambda<Func<IEquatable<D>>>(
  6300. Expression.Constant(val, typeof(IEquatable<D>)),
  6301. new System.Collections.Generic.List<ParameterExpression>());
  6302. Func<IEquatable<D>> f = e.Compile();
  6303. return object.Equals(f(), val);
  6304. }
  6305. }
  6306. public static class Ext {
  6307. public static void StartCapture() {
  6308. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6309. // m.Invoke(null, new object[] { "test.dll" });
  6310. }
  6311. public static void StopCapture() {
  6312. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6313. // m.Invoke(null, new object[0]);
  6314. }
  6315. public static bool IsIntegralOrEnum(Type type) {
  6316. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6317. case TypeCode.Byte:
  6318. case TypeCode.SByte:
  6319. case TypeCode.Int16:
  6320. case TypeCode.Int32:
  6321. case TypeCode.Int64:
  6322. case TypeCode.UInt16:
  6323. case TypeCode.UInt32:
  6324. case TypeCode.UInt64:
  6325. return true;
  6326. default:
  6327. return false;
  6328. }
  6329. }
  6330. public static bool IsFloating(Type type) {
  6331. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6332. case TypeCode.Single:
  6333. case TypeCode.Double:
  6334. return true;
  6335. default:
  6336. return false;
  6337. }
  6338. }
  6339. public static Type GetNonNullableType(Type type) {
  6340. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  6341. type.GetGenericArguments()[0] :
  6342. type;
  6343. }
  6344. }
  6345. public interface I {
  6346. void M();
  6347. }
  6348. public class C : IEquatable<C>, I {
  6349. void I.M() {
  6350. }
  6351. public override bool Equals(object o) {
  6352. return o is C && Equals((C) o);
  6353. }
  6354. public bool Equals(C c) {
  6355. return c != null;
  6356. }
  6357. public override int GetHashCode() {
  6358. return 0;
  6359. }
  6360. }
  6361. public class D : C, IEquatable<D> {
  6362. public int Val;
  6363. public D() {
  6364. }
  6365. public D(int val) {
  6366. Val = val;
  6367. }
  6368. public override bool Equals(object o) {
  6369. return o is D && Equals((D) o);
  6370. }
  6371. public bool Equals(D d) {
  6372. return d != null && d.Val == Val;
  6373. }
  6374. public override int GetHashCode() {
  6375. return Val;
  6376. }
  6377. }
  6378. public enum E {
  6379. A=1, B=2
  6380. }
  6381. public enum El : long {
  6382. A, B, C
  6383. }
  6384. public struct S : IEquatable<S> {
  6385. public override bool Equals(object o) {
  6386. return (o is S) && Equals((S) o);
  6387. }
  6388. public bool Equals(S other) {
  6389. return true;
  6390. }
  6391. public override int GetHashCode() {
  6392. return 0;
  6393. }
  6394. }
  6395. public struct Sp : IEquatable<Sp> {
  6396. public Sp(int i, double d) {
  6397. I = i;
  6398. D = d;
  6399. }
  6400. public int I;
  6401. public double D;
  6402. public override bool Equals(object o) {
  6403. return (o is Sp) && Equals((Sp) o);
  6404. }
  6405. public bool Equals(Sp other) {
  6406. return other.I == I && other.D == D;
  6407. }
  6408. public override int GetHashCode() {
  6409. return I.GetHashCode() ^ D.GetHashCode();
  6410. }
  6411. }
  6412. public struct Ss : IEquatable<Ss> {
  6413. public Ss(S s) {
  6414. Val = s;
  6415. }
  6416. public S Val;
  6417. public override bool Equals(object o) {
  6418. return (o is Ss) && Equals((Ss) o);
  6419. }
  6420. public bool Equals(Ss other) {
  6421. return other.Val.Equals(Val);
  6422. }
  6423. public override int GetHashCode() {
  6424. return Val.GetHashCode();
  6425. }
  6426. }
  6427. public struct Sc : IEquatable<Sc> {
  6428. public Sc(string s) {
  6429. S = s;
  6430. }
  6431. public string S;
  6432. public override bool Equals(object o) {
  6433. return (o is Sc) && Equals((Sc) o);
  6434. }
  6435. public bool Equals(Sc other) {
  6436. return other.S == S;
  6437. }
  6438. public override int GetHashCode() {
  6439. return S.GetHashCode();
  6440. }
  6441. }
  6442. public struct Scs : IEquatable<Scs> {
  6443. public Scs(string s, S val) {
  6444. S = s;
  6445. Val = val;
  6446. }
  6447. public string S;
  6448. public S Val;
  6449. public override bool Equals(object o) {
  6450. return (o is Scs) && Equals((Scs) o);
  6451. }
  6452. public bool Equals(Scs other) {
  6453. return other.S == S && other.Val.Equals(Val);
  6454. }
  6455. public override int GetHashCode() {
  6456. return S.GetHashCode() ^ Val.GetHashCode();
  6457. }
  6458. }
  6459. }
  6460. //-------- Scenario 1748
  6461. namespace Scenario1748{
  6462. public class Test
  6463. {
  6464. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check34__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  6465. public static Expression check34__() {
  6466. if(Main() != 0 ) {
  6467. throw new Exception();
  6468. } else {
  6469. return Expression.Constant(0);
  6470. }
  6471. }
  6472. public static int Main()
  6473. {
  6474. Ext.StartCapture();
  6475. bool success = false;
  6476. try
  6477. {
  6478. success = check34();
  6479. }
  6480. finally
  6481. {
  6482. Ext.StopCapture();
  6483. }
  6484. return success ? 0 : 1;
  6485. }
  6486. static bool check34() {
  6487. foreach (I val in new I[] { null, new C(), new D(), new D(0), new D(5) }) {
  6488. if (!check34(val)) {
  6489. return false;
  6490. }
  6491. }
  6492. return true;
  6493. }
  6494. static bool check34(I val) {
  6495. Expression<Func<I>> e =
  6496. Expression.Lambda<Func<I>>(
  6497. Expression.Constant(val, typeof(I)),
  6498. new System.Collections.Generic.List<ParameterExpression>());
  6499. Func<I> f = e.Compile();
  6500. return object.Equals(f(), val);
  6501. }
  6502. }
  6503. public static class Ext {
  6504. public static void StartCapture() {
  6505. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6506. // m.Invoke(null, new object[] { "test.dll" });
  6507. }
  6508. public static void StopCapture() {
  6509. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6510. // m.Invoke(null, new object[0]);
  6511. }
  6512. public static bool IsIntegralOrEnum(Type type) {
  6513. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6514. case TypeCode.Byte:
  6515. case TypeCode.SByte:
  6516. case TypeCode.Int16:
  6517. case TypeCode.Int32:
  6518. case TypeCode.Int64:
  6519. case TypeCode.UInt16:
  6520. case TypeCode.UInt32:
  6521. case TypeCode.UInt64:
  6522. return true;
  6523. default:
  6524. return false;
  6525. }
  6526. }
  6527. public static bool IsFloating(Type type) {
  6528. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6529. case TypeCode.Single:
  6530. case TypeCode.Double:
  6531. return true;
  6532. default:
  6533. return false;
  6534. }
  6535. }
  6536. public static Type GetNonNullableType(Type type) {
  6537. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  6538. type.GetGenericArguments()[0] :
  6539. type;
  6540. }
  6541. }
  6542. public interface I {
  6543. void M();
  6544. }
  6545. public class C : IEquatable<C>, I {
  6546. void I.M() {
  6547. }
  6548. public override bool Equals(object o) {
  6549. return o is C && Equals((C) o);
  6550. }
  6551. public bool Equals(C c) {
  6552. return c != null;
  6553. }
  6554. public override int GetHashCode() {
  6555. return 0;
  6556. }
  6557. }
  6558. public class D : C, IEquatable<D> {
  6559. public int Val;
  6560. public D() {
  6561. }
  6562. public D(int val) {
  6563. Val = val;
  6564. }
  6565. public override bool Equals(object o) {
  6566. return o is D && Equals((D) o);
  6567. }
  6568. public bool Equals(D d) {
  6569. return d != null && d.Val == Val;
  6570. }
  6571. public override int GetHashCode() {
  6572. return Val;
  6573. }
  6574. }
  6575. public enum E {
  6576. A=1, B=2
  6577. }
  6578. public enum El : long {
  6579. A, B, C
  6580. }
  6581. public struct S : IEquatable<S> {
  6582. public override bool Equals(object o) {
  6583. return (o is S) && Equals((S) o);
  6584. }
  6585. public bool Equals(S other) {
  6586. return true;
  6587. }
  6588. public override int GetHashCode() {
  6589. return 0;
  6590. }
  6591. }
  6592. public struct Sp : IEquatable<Sp> {
  6593. public Sp(int i, double d) {
  6594. I = i;
  6595. D = d;
  6596. }
  6597. public int I;
  6598. public double D;
  6599. public override bool Equals(object o) {
  6600. return (o is Sp) && Equals((Sp) o);
  6601. }
  6602. public bool Equals(Sp other) {
  6603. return other.I == I && other.D == D;
  6604. }
  6605. public override int GetHashCode() {
  6606. return I.GetHashCode() ^ D.GetHashCode();
  6607. }
  6608. }
  6609. public struct Ss : IEquatable<Ss> {
  6610. public Ss(S s) {
  6611. Val = s;
  6612. }
  6613. public S Val;
  6614. public override bool Equals(object o) {
  6615. return (o is Ss) && Equals((Ss) o);
  6616. }
  6617. public bool Equals(Ss other) {
  6618. return other.Val.Equals(Val);
  6619. }
  6620. public override int GetHashCode() {
  6621. return Val.GetHashCode();
  6622. }
  6623. }
  6624. public struct Sc : IEquatable<Sc> {
  6625. public Sc(string s) {
  6626. S = s;
  6627. }
  6628. public string S;
  6629. public override bool Equals(object o) {
  6630. return (o is Sc) && Equals((Sc) o);
  6631. }
  6632. public bool Equals(Sc other) {
  6633. return other.S == S;
  6634. }
  6635. public override int GetHashCode() {
  6636. return S.GetHashCode();
  6637. }
  6638. }
  6639. public struct Scs : IEquatable<Scs> {
  6640. public Scs(string s, S val) {
  6641. S = s;
  6642. Val = val;
  6643. }
  6644. public string S;
  6645. public S Val;
  6646. public override bool Equals(object o) {
  6647. return (o is Scs) && Equals((Scs) o);
  6648. }
  6649. public bool Equals(Scs other) {
  6650. return other.S == S && other.Val.Equals(Val);
  6651. }
  6652. public override int GetHashCode() {
  6653. return S.GetHashCode() ^ Val.GetHashCode();
  6654. }
  6655. }
  6656. }
  6657. //-------- Scenario 1749
  6658. namespace Scenario1749{
  6659. public class Test
  6660. {
  6661. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check35__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  6662. public static Expression check35__() {
  6663. if(Main() != 0 ) {
  6664. throw new Exception();
  6665. } else {
  6666. return Expression.Constant(0);
  6667. }
  6668. }
  6669. public static int Main()
  6670. {
  6671. Ext.StartCapture();
  6672. bool success = false;
  6673. try
  6674. {
  6675. success = check35();
  6676. }
  6677. finally
  6678. {
  6679. Ext.StopCapture();
  6680. }
  6681. return success ? 0 : 1;
  6682. }
  6683. static bool check35() {
  6684. foreach (byte? val in new byte?[] { null, 0, 1, byte.MaxValue }) {
  6685. if (!check35(val)) {
  6686. return false;
  6687. }
  6688. }
  6689. return true;
  6690. }
  6691. static bool check35(byte? val) {
  6692. Expression<Func<byte?>> e =
  6693. Expression.Lambda<Func<byte?>>(
  6694. Expression.Constant(val, typeof(byte?)),
  6695. new System.Collections.Generic.List<ParameterExpression>());
  6696. Func<byte?> f = e.Compile();
  6697. return object.Equals(f(), val);
  6698. }
  6699. }
  6700. public static class Ext {
  6701. public static void StartCapture() {
  6702. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6703. // m.Invoke(null, new object[] { "test.dll" });
  6704. }
  6705. public static void StopCapture() {
  6706. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6707. // m.Invoke(null, new object[0]);
  6708. }
  6709. public static bool IsIntegralOrEnum(Type type) {
  6710. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6711. case TypeCode.Byte:
  6712. case TypeCode.SByte:
  6713. case TypeCode.Int16:
  6714. case TypeCode.Int32:
  6715. case TypeCode.Int64:
  6716. case TypeCode.UInt16:
  6717. case TypeCode.UInt32:
  6718. case TypeCode.UInt64:
  6719. return true;
  6720. default:
  6721. return false;
  6722. }
  6723. }
  6724. public static bool IsFloating(Type type) {
  6725. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6726. case TypeCode.Single:
  6727. case TypeCode.Double:
  6728. return true;
  6729. default:
  6730. return false;
  6731. }
  6732. }
  6733. public static Type GetNonNullableType(Type type) {
  6734. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  6735. type.GetGenericArguments()[0] :
  6736. type;
  6737. }
  6738. }
  6739. }
  6740. //-------- Scenario 1750
  6741. namespace Scenario1750{
  6742. public class Test
  6743. {
  6744. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check36__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  6745. public static Expression check36__() {
  6746. if(Main() != 0 ) {
  6747. throw new Exception();
  6748. } else {
  6749. return Expression.Constant(0);
  6750. }
  6751. }
  6752. public static int Main()
  6753. {
  6754. Ext.StartCapture();
  6755. bool success = false;
  6756. try
  6757. {
  6758. success = check36();
  6759. }
  6760. finally
  6761. {
  6762. Ext.StopCapture();
  6763. }
  6764. return success ? 0 : 1;
  6765. }
  6766. static bool check36() {
  6767. foreach (ushort? val in new ushort?[] { null, 0, 1, ushort.MaxValue }) {
  6768. if (!check36(val)) {
  6769. return false;
  6770. }
  6771. }
  6772. return true;
  6773. }
  6774. static bool check36(ushort? val) {
  6775. Expression<Func<ushort?>> e =
  6776. Expression.Lambda<Func<ushort?>>(
  6777. Expression.Constant(val, typeof(ushort?)),
  6778. new System.Collections.Generic.List<ParameterExpression>());
  6779. Func<ushort?> f = e.Compile();
  6780. return object.Equals(f(), val);
  6781. }
  6782. }
  6783. public static class Ext {
  6784. public static void StartCapture() {
  6785. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6786. // m.Invoke(null, new object[] { "test.dll" });
  6787. }
  6788. public static void StopCapture() {
  6789. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6790. // m.Invoke(null, new object[0]);
  6791. }
  6792. public static bool IsIntegralOrEnum(Type type) {
  6793. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6794. case TypeCode.Byte:
  6795. case TypeCode.SByte:
  6796. case TypeCode.Int16:
  6797. case TypeCode.Int32:
  6798. case TypeCode.Int64:
  6799. case TypeCode.UInt16:
  6800. case TypeCode.UInt32:
  6801. case TypeCode.UInt64:
  6802. return true;
  6803. default:
  6804. return false;
  6805. }
  6806. }
  6807. public static bool IsFloating(Type type) {
  6808. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6809. case TypeCode.Single:
  6810. case TypeCode.Double:
  6811. return true;
  6812. default:
  6813. return false;
  6814. }
  6815. }
  6816. public static Type GetNonNullableType(Type type) {
  6817. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  6818. type.GetGenericArguments()[0] :
  6819. type;
  6820. }
  6821. }
  6822. }
  6823. //-------- Scenario 1751
  6824. namespace Scenario1751{
  6825. public class Test
  6826. {
  6827. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check37__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  6828. public static Expression check37__() {
  6829. if(Main() != 0 ) {
  6830. throw new Exception();
  6831. } else {
  6832. return Expression.Constant(0);
  6833. }
  6834. }
  6835. public static int Main()
  6836. {
  6837. Ext.StartCapture();
  6838. bool success = false;
  6839. try
  6840. {
  6841. success = check37();
  6842. }
  6843. finally
  6844. {
  6845. Ext.StopCapture();
  6846. }
  6847. return success ? 0 : 1;
  6848. }
  6849. static bool check37() {
  6850. foreach (uint? val in new uint?[] { null, 0, 1, uint.MaxValue }) {
  6851. if (!check37(val)) {
  6852. return false;
  6853. }
  6854. }
  6855. return true;
  6856. }
  6857. static bool check37(uint? val) {
  6858. Expression<Func<uint?>> e =
  6859. Expression.Lambda<Func<uint?>>(
  6860. Expression.Constant(val, typeof(uint?)),
  6861. new System.Collections.Generic.List<ParameterExpression>());
  6862. Func<uint?> f = e.Compile();
  6863. return object.Equals(f(), val);
  6864. }
  6865. }
  6866. public static class Ext {
  6867. public static void StartCapture() {
  6868. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6869. // m.Invoke(null, new object[] { "test.dll" });
  6870. }
  6871. public static void StopCapture() {
  6872. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6873. // m.Invoke(null, new object[0]);
  6874. }
  6875. public static bool IsIntegralOrEnum(Type type) {
  6876. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6877. case TypeCode.Byte:
  6878. case TypeCode.SByte:
  6879. case TypeCode.Int16:
  6880. case TypeCode.Int32:
  6881. case TypeCode.Int64:
  6882. case TypeCode.UInt16:
  6883. case TypeCode.UInt32:
  6884. case TypeCode.UInt64:
  6885. return true;
  6886. default:
  6887. return false;
  6888. }
  6889. }
  6890. public static bool IsFloating(Type type) {
  6891. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6892. case TypeCode.Single:
  6893. case TypeCode.Double:
  6894. return true;
  6895. default:
  6896. return false;
  6897. }
  6898. }
  6899. public static Type GetNonNullableType(Type type) {
  6900. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  6901. type.GetGenericArguments()[0] :
  6902. type;
  6903. }
  6904. }
  6905. }
  6906. //-------- Scenario 1752
  6907. namespace Scenario1752{
  6908. public class Test
  6909. {
  6910. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check38__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  6911. public static Expression check38__() {
  6912. if(Main() != 0 ) {
  6913. throw new Exception();
  6914. } else {
  6915. return Expression.Constant(0);
  6916. }
  6917. }
  6918. public static int Main()
  6919. {
  6920. Ext.StartCapture();
  6921. bool success = false;
  6922. try
  6923. {
  6924. success = check38();
  6925. }
  6926. finally
  6927. {
  6928. Ext.StopCapture();
  6929. }
  6930. return success ? 0 : 1;
  6931. }
  6932. static bool check38() {
  6933. foreach (ulong? val in new ulong?[] { null, 0, 1, ulong.MaxValue }) {
  6934. if (!check38(val)) {
  6935. return false;
  6936. }
  6937. }
  6938. return true;
  6939. }
  6940. static bool check38(ulong? val) {
  6941. Expression<Func<ulong?>> e =
  6942. Expression.Lambda<Func<ulong?>>(
  6943. Expression.Constant(val, typeof(ulong?)),
  6944. new System.Collections.Generic.List<ParameterExpression>());
  6945. Func<ulong?> f = e.Compile();
  6946. return object.Equals(f(), val);
  6947. }
  6948. }
  6949. public static class Ext {
  6950. public static void StartCapture() {
  6951. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6952. // m.Invoke(null, new object[] { "test.dll" });
  6953. }
  6954. public static void StopCapture() {
  6955. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  6956. // m.Invoke(null, new object[0]);
  6957. }
  6958. public static bool IsIntegralOrEnum(Type type) {
  6959. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6960. case TypeCode.Byte:
  6961. case TypeCode.SByte:
  6962. case TypeCode.Int16:
  6963. case TypeCode.Int32:
  6964. case TypeCode.Int64:
  6965. case TypeCode.UInt16:
  6966. case TypeCode.UInt32:
  6967. case TypeCode.UInt64:
  6968. return true;
  6969. default:
  6970. return false;
  6971. }
  6972. }
  6973. public static bool IsFloating(Type type) {
  6974. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  6975. case TypeCode.Single:
  6976. case TypeCode.Double:
  6977. return true;
  6978. default:
  6979. return false;
  6980. }
  6981. }
  6982. public static Type GetNonNullableType(Type type) {
  6983. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  6984. type.GetGenericArguments()[0] :
  6985. type;
  6986. }
  6987. }
  6988. }
  6989. //-------- Scenario 1753
  6990. namespace Scenario1753{
  6991. public class Test
  6992. {
  6993. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check39__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  6994. public static Expression check39__() {
  6995. if(Main() != 0 ) {
  6996. throw new Exception();
  6997. } else {
  6998. return Expression.Constant(0);
  6999. }
  7000. }
  7001. public static int Main()
  7002. {
  7003. Ext.StartCapture();
  7004. bool success = false;
  7005. try
  7006. {
  7007. success = check39();
  7008. }
  7009. finally
  7010. {
  7011. Ext.StopCapture();
  7012. }
  7013. return success ? 0 : 1;
  7014. }
  7015. static bool check39() {
  7016. foreach (sbyte? val in new sbyte?[] { null, 0, 1, -1, sbyte.MinValue, sbyte.MaxValue }) {
  7017. if (!check39(val)) {
  7018. return false;
  7019. }
  7020. }
  7021. return true;
  7022. }
  7023. static bool check39(sbyte? val) {
  7024. Expression<Func<sbyte?>> e =
  7025. Expression.Lambda<Func<sbyte?>>(
  7026. Expression.Constant(val, typeof(sbyte?)),
  7027. new System.Collections.Generic.List<ParameterExpression>());
  7028. Func<sbyte?> f = e.Compile();
  7029. return object.Equals(f(), val);
  7030. }
  7031. }
  7032. public static class Ext {
  7033. public static void StartCapture() {
  7034. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7035. // m.Invoke(null, new object[] { "test.dll" });
  7036. }
  7037. public static void StopCapture() {
  7038. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7039. // m.Invoke(null, new object[0]);
  7040. }
  7041. public static bool IsIntegralOrEnum(Type type) {
  7042. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7043. case TypeCode.Byte:
  7044. case TypeCode.SByte:
  7045. case TypeCode.Int16:
  7046. case TypeCode.Int32:
  7047. case TypeCode.Int64:
  7048. case TypeCode.UInt16:
  7049. case TypeCode.UInt32:
  7050. case TypeCode.UInt64:
  7051. return true;
  7052. default:
  7053. return false;
  7054. }
  7055. }
  7056. public static bool IsFloating(Type type) {
  7057. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7058. case TypeCode.Single:
  7059. case TypeCode.Double:
  7060. return true;
  7061. default:
  7062. return false;
  7063. }
  7064. }
  7065. public static Type GetNonNullableType(Type type) {
  7066. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7067. type.GetGenericArguments()[0] :
  7068. type;
  7069. }
  7070. }
  7071. }
  7072. //-------- Scenario 1754
  7073. namespace Scenario1754{
  7074. public class Test
  7075. {
  7076. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check40__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7077. public static Expression check40__() {
  7078. if(Main() != 0 ) {
  7079. throw new Exception();
  7080. } else {
  7081. return Expression.Constant(0);
  7082. }
  7083. }
  7084. public static int Main()
  7085. {
  7086. Ext.StartCapture();
  7087. bool success = false;
  7088. try
  7089. {
  7090. success = check40();
  7091. }
  7092. finally
  7093. {
  7094. Ext.StopCapture();
  7095. }
  7096. return success ? 0 : 1;
  7097. }
  7098. static bool check40() {
  7099. foreach (short? val in new short?[] { null, 0, 1, -1, short.MinValue, short.MaxValue }) {
  7100. if (!check40(val)) {
  7101. return false;
  7102. }
  7103. }
  7104. return true;
  7105. }
  7106. static bool check40(short? val) {
  7107. Expression<Func<short?>> e =
  7108. Expression.Lambda<Func<short?>>(
  7109. Expression.Constant(val, typeof(short?)),
  7110. new System.Collections.Generic.List<ParameterExpression>());
  7111. Func<short?> f = e.Compile();
  7112. return object.Equals(f(), val);
  7113. }
  7114. }
  7115. public static class Ext {
  7116. public static void StartCapture() {
  7117. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7118. // m.Invoke(null, new object[] { "test.dll" });
  7119. }
  7120. public static void StopCapture() {
  7121. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7122. // m.Invoke(null, new object[0]);
  7123. }
  7124. public static bool IsIntegralOrEnum(Type type) {
  7125. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7126. case TypeCode.Byte:
  7127. case TypeCode.SByte:
  7128. case TypeCode.Int16:
  7129. case TypeCode.Int32:
  7130. case TypeCode.Int64:
  7131. case TypeCode.UInt16:
  7132. case TypeCode.UInt32:
  7133. case TypeCode.UInt64:
  7134. return true;
  7135. default:
  7136. return false;
  7137. }
  7138. }
  7139. public static bool IsFloating(Type type) {
  7140. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7141. case TypeCode.Single:
  7142. case TypeCode.Double:
  7143. return true;
  7144. default:
  7145. return false;
  7146. }
  7147. }
  7148. public static Type GetNonNullableType(Type type) {
  7149. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7150. type.GetGenericArguments()[0] :
  7151. type;
  7152. }
  7153. }
  7154. }
  7155. //-------- Scenario 1755
  7156. namespace Scenario1755{
  7157. public class Test
  7158. {
  7159. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check41__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7160. public static Expression check41__() {
  7161. if(Main() != 0 ) {
  7162. throw new Exception();
  7163. } else {
  7164. return Expression.Constant(0);
  7165. }
  7166. }
  7167. public static int Main()
  7168. {
  7169. Ext.StartCapture();
  7170. bool success = false;
  7171. try
  7172. {
  7173. success = check41();
  7174. }
  7175. finally
  7176. {
  7177. Ext.StopCapture();
  7178. }
  7179. return success ? 0 : 1;
  7180. }
  7181. static bool check41() {
  7182. foreach (int? val in new int?[] { null, 0, 1, -1, int.MinValue, int.MaxValue }) {
  7183. if (!check41(val)) {
  7184. return false;
  7185. }
  7186. }
  7187. return true;
  7188. }
  7189. static bool check41(int? val) {
  7190. Expression<Func<int?>> e =
  7191. Expression.Lambda<Func<int?>>(
  7192. Expression.Constant(val, typeof(int?)),
  7193. new System.Collections.Generic.List<ParameterExpression>());
  7194. Func<int?> f = e.Compile();
  7195. return object.Equals(f(), val);
  7196. }
  7197. }
  7198. public static class Ext {
  7199. public static void StartCapture() {
  7200. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7201. // m.Invoke(null, new object[] { "test.dll" });
  7202. }
  7203. public static void StopCapture() {
  7204. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7205. // m.Invoke(null, new object[0]);
  7206. }
  7207. public static bool IsIntegralOrEnum(Type type) {
  7208. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7209. case TypeCode.Byte:
  7210. case TypeCode.SByte:
  7211. case TypeCode.Int16:
  7212. case TypeCode.Int32:
  7213. case TypeCode.Int64:
  7214. case TypeCode.UInt16:
  7215. case TypeCode.UInt32:
  7216. case TypeCode.UInt64:
  7217. return true;
  7218. default:
  7219. return false;
  7220. }
  7221. }
  7222. public static bool IsFloating(Type type) {
  7223. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7224. case TypeCode.Single:
  7225. case TypeCode.Double:
  7226. return true;
  7227. default:
  7228. return false;
  7229. }
  7230. }
  7231. public static Type GetNonNullableType(Type type) {
  7232. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7233. type.GetGenericArguments()[0] :
  7234. type;
  7235. }
  7236. }
  7237. }
  7238. //-------- Scenario 1756
  7239. namespace Scenario1756{
  7240. public class Test
  7241. {
  7242. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check42__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7243. public static Expression check42__() {
  7244. if(Main() != 0 ) {
  7245. throw new Exception();
  7246. } else {
  7247. return Expression.Constant(0);
  7248. }
  7249. }
  7250. public static int Main()
  7251. {
  7252. Ext.StartCapture();
  7253. bool success = false;
  7254. try
  7255. {
  7256. success = check42();
  7257. }
  7258. finally
  7259. {
  7260. Ext.StopCapture();
  7261. }
  7262. return success ? 0 : 1;
  7263. }
  7264. static bool check42() {
  7265. foreach (long? val in new long?[] { null, 0, 1, -1, long.MinValue, long.MaxValue }) {
  7266. if (!check42(val)) {
  7267. return false;
  7268. }
  7269. }
  7270. return true;
  7271. }
  7272. static bool check42(long? val) {
  7273. Expression<Func<long?>> e =
  7274. Expression.Lambda<Func<long?>>(
  7275. Expression.Constant(val, typeof(long?)),
  7276. new System.Collections.Generic.List<ParameterExpression>());
  7277. Func<long?> f = e.Compile();
  7278. return object.Equals(f(), val);
  7279. }
  7280. }
  7281. public static class Ext {
  7282. public static void StartCapture() {
  7283. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7284. // m.Invoke(null, new object[] { "test.dll" });
  7285. }
  7286. public static void StopCapture() {
  7287. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7288. // m.Invoke(null, new object[0]);
  7289. }
  7290. public static bool IsIntegralOrEnum(Type type) {
  7291. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7292. case TypeCode.Byte:
  7293. case TypeCode.SByte:
  7294. case TypeCode.Int16:
  7295. case TypeCode.Int32:
  7296. case TypeCode.Int64:
  7297. case TypeCode.UInt16:
  7298. case TypeCode.UInt32:
  7299. case TypeCode.UInt64:
  7300. return true;
  7301. default:
  7302. return false;
  7303. }
  7304. }
  7305. public static bool IsFloating(Type type) {
  7306. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7307. case TypeCode.Single:
  7308. case TypeCode.Double:
  7309. return true;
  7310. default:
  7311. return false;
  7312. }
  7313. }
  7314. public static Type GetNonNullableType(Type type) {
  7315. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7316. type.GetGenericArguments()[0] :
  7317. type;
  7318. }
  7319. }
  7320. }
  7321. //-------- Scenario 1757
  7322. namespace Scenario1757{
  7323. public class Test
  7324. {
  7325. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check43__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7326. public static Expression check43__() {
  7327. if(Main() != 0 ) {
  7328. throw new Exception();
  7329. } else {
  7330. return Expression.Constant(0);
  7331. }
  7332. }
  7333. public static int Main()
  7334. {
  7335. Ext.StartCapture();
  7336. bool success = false;
  7337. try
  7338. {
  7339. success = check43();
  7340. }
  7341. finally
  7342. {
  7343. Ext.StopCapture();
  7344. }
  7345. return success ? 0 : 1;
  7346. }
  7347. static bool check43() {
  7348. foreach (float? val in new float?[] { null, 0, 1, -1, float.MinValue, float.MaxValue, float.Epsilon, float.NegativeInfinity, float.PositiveInfinity, float.NaN }) {
  7349. if (!check43(val)) {
  7350. return false;
  7351. }
  7352. }
  7353. return true;
  7354. }
  7355. static bool check43(float? val) {
  7356. Expression<Func<float?>> e =
  7357. Expression.Lambda<Func<float?>>(
  7358. Expression.Constant(val, typeof(float?)),
  7359. new System.Collections.Generic.List<ParameterExpression>());
  7360. Func<float?> f = e.Compile();
  7361. return object.Equals(f(), val);
  7362. }
  7363. }
  7364. public static class Ext {
  7365. public static void StartCapture() {
  7366. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7367. // m.Invoke(null, new object[] { "test.dll" });
  7368. }
  7369. public static void StopCapture() {
  7370. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7371. // m.Invoke(null, new object[0]);
  7372. }
  7373. public static bool IsIntegralOrEnum(Type type) {
  7374. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7375. case TypeCode.Byte:
  7376. case TypeCode.SByte:
  7377. case TypeCode.Int16:
  7378. case TypeCode.Int32:
  7379. case TypeCode.Int64:
  7380. case TypeCode.UInt16:
  7381. case TypeCode.UInt32:
  7382. case TypeCode.UInt64:
  7383. return true;
  7384. default:
  7385. return false;
  7386. }
  7387. }
  7388. public static bool IsFloating(Type type) {
  7389. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7390. case TypeCode.Single:
  7391. case TypeCode.Double:
  7392. return true;
  7393. default:
  7394. return false;
  7395. }
  7396. }
  7397. public static Type GetNonNullableType(Type type) {
  7398. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7399. type.GetGenericArguments()[0] :
  7400. type;
  7401. }
  7402. }
  7403. }
  7404. //-------- Scenario 1758
  7405. namespace Scenario1758{
  7406. public class Test
  7407. {
  7408. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check44__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7409. public static Expression check44__() {
  7410. if(Main() != 0 ) {
  7411. throw new Exception();
  7412. } else {
  7413. return Expression.Constant(0);
  7414. }
  7415. }
  7416. public static int Main()
  7417. {
  7418. Ext.StartCapture();
  7419. bool success = false;
  7420. try
  7421. {
  7422. success = check44();
  7423. }
  7424. finally
  7425. {
  7426. Ext.StopCapture();
  7427. }
  7428. return success ? 0 : 1;
  7429. }
  7430. static bool check44() {
  7431. foreach (double? val in new double?[] { null, 0, 1, -1, double.MinValue, double.MaxValue, double.Epsilon, double.NegativeInfinity, double.PositiveInfinity, double.NaN }) {
  7432. if (!check44(val)) {
  7433. return false;
  7434. }
  7435. }
  7436. return true;
  7437. }
  7438. static bool check44(double? val) {
  7439. Expression<Func<double?>> e =
  7440. Expression.Lambda<Func<double?>>(
  7441. Expression.Constant(val, typeof(double?)),
  7442. new System.Collections.Generic.List<ParameterExpression>());
  7443. Func<double?> f = e.Compile();
  7444. return object.Equals(f(), val);
  7445. }
  7446. }
  7447. public static class Ext {
  7448. public static void StartCapture() {
  7449. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7450. // m.Invoke(null, new object[] { "test.dll" });
  7451. }
  7452. public static void StopCapture() {
  7453. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7454. // m.Invoke(null, new object[0]);
  7455. }
  7456. public static bool IsIntegralOrEnum(Type type) {
  7457. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7458. case TypeCode.Byte:
  7459. case TypeCode.SByte:
  7460. case TypeCode.Int16:
  7461. case TypeCode.Int32:
  7462. case TypeCode.Int64:
  7463. case TypeCode.UInt16:
  7464. case TypeCode.UInt32:
  7465. case TypeCode.UInt64:
  7466. return true;
  7467. default:
  7468. return false;
  7469. }
  7470. }
  7471. public static bool IsFloating(Type type) {
  7472. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7473. case TypeCode.Single:
  7474. case TypeCode.Double:
  7475. return true;
  7476. default:
  7477. return false;
  7478. }
  7479. }
  7480. public static Type GetNonNullableType(Type type) {
  7481. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7482. type.GetGenericArguments()[0] :
  7483. type;
  7484. }
  7485. }
  7486. }
  7487. //-------- Scenario 1759
  7488. namespace Scenario1759{
  7489. public class Test
  7490. {
  7491. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check45__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7492. public static Expression check45__() {
  7493. if(Main() != 0 ) {
  7494. throw new Exception();
  7495. } else {
  7496. return Expression.Constant(0);
  7497. }
  7498. }
  7499. public static int Main()
  7500. {
  7501. Ext.StartCapture();
  7502. bool success = false;
  7503. try
  7504. {
  7505. success = check45();
  7506. }
  7507. finally
  7508. {
  7509. Ext.StopCapture();
  7510. }
  7511. return success ? 0 : 1;
  7512. }
  7513. static bool check45() {
  7514. foreach (decimal? val in new decimal?[] { null, decimal.Zero, decimal.One, decimal.MinusOne, decimal.MinValue, decimal.MaxValue }) {
  7515. if (!check45(val)) {
  7516. return false;
  7517. }
  7518. }
  7519. return true;
  7520. }
  7521. static bool check45(decimal? val) {
  7522. Expression<Func<decimal?>> e =
  7523. Expression.Lambda<Func<decimal?>>(
  7524. Expression.Constant(val, typeof(decimal?)),
  7525. new System.Collections.Generic.List<ParameterExpression>());
  7526. Func<decimal?> f = e.Compile();
  7527. return object.Equals(f(), val);
  7528. }
  7529. }
  7530. public static class Ext {
  7531. public static void StartCapture() {
  7532. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7533. // m.Invoke(null, new object[] { "test.dll" });
  7534. }
  7535. public static void StopCapture() {
  7536. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7537. // m.Invoke(null, new object[0]);
  7538. }
  7539. public static bool IsIntegralOrEnum(Type type) {
  7540. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7541. case TypeCode.Byte:
  7542. case TypeCode.SByte:
  7543. case TypeCode.Int16:
  7544. case TypeCode.Int32:
  7545. case TypeCode.Int64:
  7546. case TypeCode.UInt16:
  7547. case TypeCode.UInt32:
  7548. case TypeCode.UInt64:
  7549. return true;
  7550. default:
  7551. return false;
  7552. }
  7553. }
  7554. public static bool IsFloating(Type type) {
  7555. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7556. case TypeCode.Single:
  7557. case TypeCode.Double:
  7558. return true;
  7559. default:
  7560. return false;
  7561. }
  7562. }
  7563. public static Type GetNonNullableType(Type type) {
  7564. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7565. type.GetGenericArguments()[0] :
  7566. type;
  7567. }
  7568. }
  7569. }
  7570. //-------- Scenario 1760
  7571. namespace Scenario1760{
  7572. public class Test
  7573. {
  7574. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check46__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7575. public static Expression check46__() {
  7576. if(Main() != 0 ) {
  7577. throw new Exception();
  7578. } else {
  7579. return Expression.Constant(0);
  7580. }
  7581. }
  7582. public static int Main()
  7583. {
  7584. Ext.StartCapture();
  7585. bool success = false;
  7586. try
  7587. {
  7588. success = check46();
  7589. }
  7590. finally
  7591. {
  7592. Ext.StopCapture();
  7593. }
  7594. return success ? 0 : 1;
  7595. }
  7596. static bool check46() {
  7597. foreach (char? val in new char?[] { null, '\0', '\b', 'A', '\uffff' }) {
  7598. if (!check46(val)) {
  7599. return false;
  7600. }
  7601. }
  7602. return true;
  7603. }
  7604. static bool check46(char? val) {
  7605. Expression<Func<char?>> e =
  7606. Expression.Lambda<Func<char?>>(
  7607. Expression.Constant(val, typeof(char?)),
  7608. new System.Collections.Generic.List<ParameterExpression>());
  7609. Func<char?> f = e.Compile();
  7610. return object.Equals(f(), val);
  7611. }
  7612. }
  7613. public static class Ext {
  7614. public static void StartCapture() {
  7615. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7616. // m.Invoke(null, new object[] { "test.dll" });
  7617. }
  7618. public static void StopCapture() {
  7619. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7620. // m.Invoke(null, new object[0]);
  7621. }
  7622. public static bool IsIntegralOrEnum(Type type) {
  7623. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7624. case TypeCode.Byte:
  7625. case TypeCode.SByte:
  7626. case TypeCode.Int16:
  7627. case TypeCode.Int32:
  7628. case TypeCode.Int64:
  7629. case TypeCode.UInt16:
  7630. case TypeCode.UInt32:
  7631. case TypeCode.UInt64:
  7632. return true;
  7633. default:
  7634. return false;
  7635. }
  7636. }
  7637. public static bool IsFloating(Type type) {
  7638. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7639. case TypeCode.Single:
  7640. case TypeCode.Double:
  7641. return true;
  7642. default:
  7643. return false;
  7644. }
  7645. }
  7646. public static Type GetNonNullableType(Type type) {
  7647. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7648. type.GetGenericArguments()[0] :
  7649. type;
  7650. }
  7651. }
  7652. }
  7653. //-------- Scenario 1761
  7654. namespace Scenario1761{
  7655. public class Test
  7656. {
  7657. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check47__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7658. public static Expression check47__() {
  7659. if(Main() != 0 ) {
  7660. throw new Exception();
  7661. } else {
  7662. return Expression.Constant(0);
  7663. }
  7664. }
  7665. public static int Main()
  7666. {
  7667. Ext.StartCapture();
  7668. bool success = false;
  7669. try
  7670. {
  7671. success = check47();
  7672. }
  7673. finally
  7674. {
  7675. Ext.StopCapture();
  7676. }
  7677. return success ? 0 : 1;
  7678. }
  7679. static bool check47() {
  7680. foreach (bool? val in new bool?[] { null, true, false }) {
  7681. if (!check47(val)) {
  7682. return false;
  7683. }
  7684. }
  7685. return true;
  7686. }
  7687. static bool check47(bool? val) {
  7688. Expression<Func<bool?>> e =
  7689. Expression.Lambda<Func<bool?>>(
  7690. Expression.Constant(val, typeof(bool?)),
  7691. new System.Collections.Generic.List<ParameterExpression>());
  7692. Func<bool?> f = e.Compile();
  7693. return object.Equals(f(), val);
  7694. }
  7695. }
  7696. public static class Ext {
  7697. public static void StartCapture() {
  7698. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7699. // m.Invoke(null, new object[] { "test.dll" });
  7700. }
  7701. public static void StopCapture() {
  7702. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7703. // m.Invoke(null, new object[0]);
  7704. }
  7705. public static bool IsIntegralOrEnum(Type type) {
  7706. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7707. case TypeCode.Byte:
  7708. case TypeCode.SByte:
  7709. case TypeCode.Int16:
  7710. case TypeCode.Int32:
  7711. case TypeCode.Int64:
  7712. case TypeCode.UInt16:
  7713. case TypeCode.UInt32:
  7714. case TypeCode.UInt64:
  7715. return true;
  7716. default:
  7717. return false;
  7718. }
  7719. }
  7720. public static bool IsFloating(Type type) {
  7721. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7722. case TypeCode.Single:
  7723. case TypeCode.Double:
  7724. return true;
  7725. default:
  7726. return false;
  7727. }
  7728. }
  7729. public static Type GetNonNullableType(Type type) {
  7730. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7731. type.GetGenericArguments()[0] :
  7732. type;
  7733. }
  7734. }
  7735. }
  7736. //-------- Scenario 1762
  7737. namespace Scenario1762{
  7738. public class Test
  7739. {
  7740. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check48__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7741. public static Expression check48__() {
  7742. if(Main() != 0 ) {
  7743. throw new Exception();
  7744. } else {
  7745. return Expression.Constant(0);
  7746. }
  7747. }
  7748. public static int Main()
  7749. {
  7750. Ext.StartCapture();
  7751. bool success = false;
  7752. try
  7753. {
  7754. success = check48();
  7755. }
  7756. finally
  7757. {
  7758. Ext.StopCapture();
  7759. }
  7760. return success ? 0 : 1;
  7761. }
  7762. static bool check48() {
  7763. foreach (S? val in new S?[] { null, default(S), new S() }) {
  7764. if (!check48(val)) {
  7765. return false;
  7766. }
  7767. }
  7768. return true;
  7769. }
  7770. static bool check48(S? val) {
  7771. Expression<Func<S?>> e =
  7772. Expression.Lambda<Func<S?>>(
  7773. Expression.Constant(val, typeof(S?)),
  7774. new System.Collections.Generic.List<ParameterExpression>());
  7775. Func<S?> f = e.Compile();
  7776. return object.Equals(f(), val);
  7777. }
  7778. }
  7779. public static class Ext {
  7780. public static void StartCapture() {
  7781. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7782. // m.Invoke(null, new object[] { "test.dll" });
  7783. }
  7784. public static void StopCapture() {
  7785. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7786. // m.Invoke(null, new object[0]);
  7787. }
  7788. public static bool IsIntegralOrEnum(Type type) {
  7789. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7790. case TypeCode.Byte:
  7791. case TypeCode.SByte:
  7792. case TypeCode.Int16:
  7793. case TypeCode.Int32:
  7794. case TypeCode.Int64:
  7795. case TypeCode.UInt16:
  7796. case TypeCode.UInt32:
  7797. case TypeCode.UInt64:
  7798. return true;
  7799. default:
  7800. return false;
  7801. }
  7802. }
  7803. public static bool IsFloating(Type type) {
  7804. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7805. case TypeCode.Single:
  7806. case TypeCode.Double:
  7807. return true;
  7808. default:
  7809. return false;
  7810. }
  7811. }
  7812. public static Type GetNonNullableType(Type type) {
  7813. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  7814. type.GetGenericArguments()[0] :
  7815. type;
  7816. }
  7817. }
  7818. public interface I {
  7819. void M();
  7820. }
  7821. public class C : IEquatable<C>, I {
  7822. void I.M() {
  7823. }
  7824. public override bool Equals(object o) {
  7825. return o is C && Equals((C) o);
  7826. }
  7827. public bool Equals(C c) {
  7828. return c != null;
  7829. }
  7830. public override int GetHashCode() {
  7831. return 0;
  7832. }
  7833. }
  7834. public class D : C, IEquatable<D> {
  7835. public int Val;
  7836. public D() {
  7837. }
  7838. public D(int val) {
  7839. Val = val;
  7840. }
  7841. public override bool Equals(object o) {
  7842. return o is D && Equals((D) o);
  7843. }
  7844. public bool Equals(D d) {
  7845. return d != null && d.Val == Val;
  7846. }
  7847. public override int GetHashCode() {
  7848. return Val;
  7849. }
  7850. }
  7851. public enum E {
  7852. A=1, B=2
  7853. }
  7854. public enum El : long {
  7855. A, B, C
  7856. }
  7857. public struct S : IEquatable<S> {
  7858. public override bool Equals(object o) {
  7859. return (o is S) && Equals((S) o);
  7860. }
  7861. public bool Equals(S other) {
  7862. return true;
  7863. }
  7864. public override int GetHashCode() {
  7865. return 0;
  7866. }
  7867. }
  7868. public struct Sp : IEquatable<Sp> {
  7869. public Sp(int i, double d) {
  7870. I = i;
  7871. D = d;
  7872. }
  7873. public int I;
  7874. public double D;
  7875. public override bool Equals(object o) {
  7876. return (o is Sp) && Equals((Sp) o);
  7877. }
  7878. public bool Equals(Sp other) {
  7879. return other.I == I && other.D == D;
  7880. }
  7881. public override int GetHashCode() {
  7882. return I.GetHashCode() ^ D.GetHashCode();
  7883. }
  7884. }
  7885. public struct Ss : IEquatable<Ss> {
  7886. public Ss(S s) {
  7887. Val = s;
  7888. }
  7889. public S Val;
  7890. public override bool Equals(object o) {
  7891. return (o is Ss) && Equals((Ss) o);
  7892. }
  7893. public bool Equals(Ss other) {
  7894. return other.Val.Equals(Val);
  7895. }
  7896. public override int GetHashCode() {
  7897. return Val.GetHashCode();
  7898. }
  7899. }
  7900. public struct Sc : IEquatable<Sc> {
  7901. public Sc(string s) {
  7902. S = s;
  7903. }
  7904. public string S;
  7905. public override bool Equals(object o) {
  7906. return (o is Sc) && Equals((Sc) o);
  7907. }
  7908. public bool Equals(Sc other) {
  7909. return other.S == S;
  7910. }
  7911. public override int GetHashCode() {
  7912. return S.GetHashCode();
  7913. }
  7914. }
  7915. public struct Scs : IEquatable<Scs> {
  7916. public Scs(string s, S val) {
  7917. S = s;
  7918. Val = val;
  7919. }
  7920. public string S;
  7921. public S Val;
  7922. public override bool Equals(object o) {
  7923. return (o is Scs) && Equals((Scs) o);
  7924. }
  7925. public bool Equals(Scs other) {
  7926. return other.S == S && other.Val.Equals(Val);
  7927. }
  7928. public override int GetHashCode() {
  7929. return S.GetHashCode() ^ Val.GetHashCode();
  7930. }
  7931. }
  7932. }
  7933. //-------- Scenario 1763
  7934. namespace Scenario1763{
  7935. public class Test
  7936. {
  7937. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check49__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  7938. public static Expression check49__() {
  7939. if(Main() != 0 ) {
  7940. throw new Exception();
  7941. } else {
  7942. return Expression.Constant(0);
  7943. }
  7944. }
  7945. public static int Main()
  7946. {
  7947. Ext.StartCapture();
  7948. bool success = false;
  7949. try
  7950. {
  7951. success = check49();
  7952. }
  7953. finally
  7954. {
  7955. Ext.StopCapture();
  7956. }
  7957. return success ? 0 : 1;
  7958. }
  7959. static bool check49() {
  7960. foreach (Sp? val in new Sp?[] { null, default(Sp), new Sp(), new Sp(5,5.0) }) {
  7961. if (!check49(val)) {
  7962. return false;
  7963. }
  7964. }
  7965. return true;
  7966. }
  7967. static bool check49(Sp? val) {
  7968. Expression<Func<Sp?>> e =
  7969. Expression.Lambda<Func<Sp?>>(
  7970. Expression.Constant(val, typeof(Sp?)),
  7971. new System.Collections.Generic.List<ParameterExpression>());
  7972. Func<Sp?> f = e.Compile();
  7973. return object.Equals(f(), val);
  7974. }
  7975. }
  7976. public static class Ext {
  7977. public static void StartCapture() {
  7978. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7979. // m.Invoke(null, new object[] { "test.dll" });
  7980. }
  7981. public static void StopCapture() {
  7982. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  7983. // m.Invoke(null, new object[0]);
  7984. }
  7985. public static bool IsIntegralOrEnum(Type type) {
  7986. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  7987. case TypeCode.Byte:
  7988. case TypeCode.SByte:
  7989. case TypeCode.Int16:
  7990. case TypeCode.Int32:
  7991. case TypeCode.Int64:
  7992. case TypeCode.UInt16:
  7993. case TypeCode.UInt32:
  7994. case TypeCode.UInt64:
  7995. return true;
  7996. default:
  7997. return false;
  7998. }
  7999. }
  8000. public static bool IsFloating(Type type) {
  8001. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8002. case TypeCode.Single:
  8003. case TypeCode.Double:
  8004. return true;
  8005. default:
  8006. return false;
  8007. }
  8008. }
  8009. public static Type GetNonNullableType(Type type) {
  8010. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  8011. type.GetGenericArguments()[0] :
  8012. type;
  8013. }
  8014. }
  8015. public interface I {
  8016. void M();
  8017. }
  8018. public class C : IEquatable<C>, I {
  8019. void I.M() {
  8020. }
  8021. public override bool Equals(object o) {
  8022. return o is C && Equals((C) o);
  8023. }
  8024. public bool Equals(C c) {
  8025. return c != null;
  8026. }
  8027. public override int GetHashCode() {
  8028. return 0;
  8029. }
  8030. }
  8031. public class D : C, IEquatable<D> {
  8032. public int Val;
  8033. public D() {
  8034. }
  8035. public D(int val) {
  8036. Val = val;
  8037. }
  8038. public override bool Equals(object o) {
  8039. return o is D && Equals((D) o);
  8040. }
  8041. public bool Equals(D d) {
  8042. return d != null && d.Val == Val;
  8043. }
  8044. public override int GetHashCode() {
  8045. return Val;
  8046. }
  8047. }
  8048. public enum E {
  8049. A=1, B=2
  8050. }
  8051. public enum El : long {
  8052. A, B, C
  8053. }
  8054. public struct S : IEquatable<S> {
  8055. public override bool Equals(object o) {
  8056. return (o is S) && Equals((S) o);
  8057. }
  8058. public bool Equals(S other) {
  8059. return true;
  8060. }
  8061. public override int GetHashCode() {
  8062. return 0;
  8063. }
  8064. }
  8065. public struct Sp : IEquatable<Sp> {
  8066. public Sp(int i, double d) {
  8067. I = i;
  8068. D = d;
  8069. }
  8070. public int I;
  8071. public double D;
  8072. public override bool Equals(object o) {
  8073. return (o is Sp) && Equals((Sp) o);
  8074. }
  8075. public bool Equals(Sp other) {
  8076. return other.I == I && other.D == D;
  8077. }
  8078. public override int GetHashCode() {
  8079. return I.GetHashCode() ^ D.GetHashCode();
  8080. }
  8081. }
  8082. public struct Ss : IEquatable<Ss> {
  8083. public Ss(S s) {
  8084. Val = s;
  8085. }
  8086. public S Val;
  8087. public override bool Equals(object o) {
  8088. return (o is Ss) && Equals((Ss) o);
  8089. }
  8090. public bool Equals(Ss other) {
  8091. return other.Val.Equals(Val);
  8092. }
  8093. public override int GetHashCode() {
  8094. return Val.GetHashCode();
  8095. }
  8096. }
  8097. public struct Sc : IEquatable<Sc> {
  8098. public Sc(string s) {
  8099. S = s;
  8100. }
  8101. public string S;
  8102. public override bool Equals(object o) {
  8103. return (o is Sc) && Equals((Sc) o);
  8104. }
  8105. public bool Equals(Sc other) {
  8106. return other.S == S;
  8107. }
  8108. public override int GetHashCode() {
  8109. return S.GetHashCode();
  8110. }
  8111. }
  8112. public struct Scs : IEquatable<Scs> {
  8113. public Scs(string s, S val) {
  8114. S = s;
  8115. Val = val;
  8116. }
  8117. public string S;
  8118. public S Val;
  8119. public override bool Equals(object o) {
  8120. return (o is Scs) && Equals((Scs) o);
  8121. }
  8122. public bool Equals(Scs other) {
  8123. return other.S == S && other.Val.Equals(Val);
  8124. }
  8125. public override int GetHashCode() {
  8126. return S.GetHashCode() ^ Val.GetHashCode();
  8127. }
  8128. }
  8129. }
  8130. //-------- Scenario 1764
  8131. namespace Scenario1764{
  8132. public class Test
  8133. {
  8134. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check50__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  8135. public static Expression check50__() {
  8136. if(Main() != 0 ) {
  8137. throw new Exception();
  8138. } else {
  8139. return Expression.Constant(0);
  8140. }
  8141. }
  8142. public static int Main()
  8143. {
  8144. Ext.StartCapture();
  8145. bool success = false;
  8146. try
  8147. {
  8148. success = check50();
  8149. }
  8150. finally
  8151. {
  8152. Ext.StopCapture();
  8153. }
  8154. return success ? 0 : 1;
  8155. }
  8156. static bool check50() {
  8157. foreach (Ss? val in new Ss?[] { null, default(Ss), new Ss(), new Ss(new S()) }) {
  8158. if (!check50(val)) {
  8159. return false;
  8160. }
  8161. }
  8162. return true;
  8163. }
  8164. static bool check50(Ss? val) {
  8165. Expression<Func<Ss?>> e =
  8166. Expression.Lambda<Func<Ss?>>(
  8167. Expression.Constant(val, typeof(Ss?)),
  8168. new System.Collections.Generic.List<ParameterExpression>());
  8169. Func<Ss?> f = e.Compile();
  8170. return object.Equals(f(), val);
  8171. }
  8172. }
  8173. public static class Ext {
  8174. public static void StartCapture() {
  8175. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8176. // m.Invoke(null, new object[] { "test.dll" });
  8177. }
  8178. public static void StopCapture() {
  8179. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8180. // m.Invoke(null, new object[0]);
  8181. }
  8182. public static bool IsIntegralOrEnum(Type type) {
  8183. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8184. case TypeCode.Byte:
  8185. case TypeCode.SByte:
  8186. case TypeCode.Int16:
  8187. case TypeCode.Int32:
  8188. case TypeCode.Int64:
  8189. case TypeCode.UInt16:
  8190. case TypeCode.UInt32:
  8191. case TypeCode.UInt64:
  8192. return true;
  8193. default:
  8194. return false;
  8195. }
  8196. }
  8197. public static bool IsFloating(Type type) {
  8198. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8199. case TypeCode.Single:
  8200. case TypeCode.Double:
  8201. return true;
  8202. default:
  8203. return false;
  8204. }
  8205. }
  8206. public static Type GetNonNullableType(Type type) {
  8207. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  8208. type.GetGenericArguments()[0] :
  8209. type;
  8210. }
  8211. }
  8212. public interface I {
  8213. void M();
  8214. }
  8215. public class C : IEquatable<C>, I {
  8216. void I.M() {
  8217. }
  8218. public override bool Equals(object o) {
  8219. return o is C && Equals((C) o);
  8220. }
  8221. public bool Equals(C c) {
  8222. return c != null;
  8223. }
  8224. public override int GetHashCode() {
  8225. return 0;
  8226. }
  8227. }
  8228. public class D : C, IEquatable<D> {
  8229. public int Val;
  8230. public D() {
  8231. }
  8232. public D(int val) {
  8233. Val = val;
  8234. }
  8235. public override bool Equals(object o) {
  8236. return o is D && Equals((D) o);
  8237. }
  8238. public bool Equals(D d) {
  8239. return d != null && d.Val == Val;
  8240. }
  8241. public override int GetHashCode() {
  8242. return Val;
  8243. }
  8244. }
  8245. public enum E {
  8246. A=1, B=2
  8247. }
  8248. public enum El : long {
  8249. A, B, C
  8250. }
  8251. public struct S : IEquatable<S> {
  8252. public override bool Equals(object o) {
  8253. return (o is S) && Equals((S) o);
  8254. }
  8255. public bool Equals(S other) {
  8256. return true;
  8257. }
  8258. public override int GetHashCode() {
  8259. return 0;
  8260. }
  8261. }
  8262. public struct Sp : IEquatable<Sp> {
  8263. public Sp(int i, double d) {
  8264. I = i;
  8265. D = d;
  8266. }
  8267. public int I;
  8268. public double D;
  8269. public override bool Equals(object o) {
  8270. return (o is Sp) && Equals((Sp) o);
  8271. }
  8272. public bool Equals(Sp other) {
  8273. return other.I == I && other.D == D;
  8274. }
  8275. public override int GetHashCode() {
  8276. return I.GetHashCode() ^ D.GetHashCode();
  8277. }
  8278. }
  8279. public struct Ss : IEquatable<Ss> {
  8280. public Ss(S s) {
  8281. Val = s;
  8282. }
  8283. public S Val;
  8284. public override bool Equals(object o) {
  8285. return (o is Ss) && Equals((Ss) o);
  8286. }
  8287. public bool Equals(Ss other) {
  8288. return other.Val.Equals(Val);
  8289. }
  8290. public override int GetHashCode() {
  8291. return Val.GetHashCode();
  8292. }
  8293. }
  8294. public struct Sc : IEquatable<Sc> {
  8295. public Sc(string s) {
  8296. S = s;
  8297. }
  8298. public string S;
  8299. public override bool Equals(object o) {
  8300. return (o is Sc) && Equals((Sc) o);
  8301. }
  8302. public bool Equals(Sc other) {
  8303. return other.S == S;
  8304. }
  8305. public override int GetHashCode() {
  8306. return S.GetHashCode();
  8307. }
  8308. }
  8309. public struct Scs : IEquatable<Scs> {
  8310. public Scs(string s, S val) {
  8311. S = s;
  8312. Val = val;
  8313. }
  8314. public string S;
  8315. public S Val;
  8316. public override bool Equals(object o) {
  8317. return (o is Scs) && Equals((Scs) o);
  8318. }
  8319. public bool Equals(Scs other) {
  8320. return other.S == S && other.Val.Equals(Val);
  8321. }
  8322. public override int GetHashCode() {
  8323. return S.GetHashCode() ^ Val.GetHashCode();
  8324. }
  8325. }
  8326. }
  8327. //-------- Scenario 1765
  8328. namespace Scenario1765{
  8329. public class Test
  8330. {
  8331. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check51__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  8332. public static Expression check51__() {
  8333. if(Main() != 0 ) {
  8334. throw new Exception();
  8335. } else {
  8336. return Expression.Constant(0);
  8337. }
  8338. }
  8339. public static int Main()
  8340. {
  8341. Ext.StartCapture();
  8342. bool success = false;
  8343. try
  8344. {
  8345. success = check51();
  8346. }
  8347. finally
  8348. {
  8349. Ext.StopCapture();
  8350. }
  8351. return success ? 0 : 1;
  8352. }
  8353. static bool check51() {
  8354. foreach (Sc? val in new Sc?[] { null, default(Sc), new Sc(), new Sc(null) }) {
  8355. if (!check51(val)) {
  8356. return false;
  8357. }
  8358. }
  8359. return true;
  8360. }
  8361. static bool check51(Sc? val) {
  8362. Expression<Func<Sc?>> e =
  8363. Expression.Lambda<Func<Sc?>>(
  8364. Expression.Constant(val, typeof(Sc?)),
  8365. new System.Collections.Generic.List<ParameterExpression>());
  8366. Func<Sc?> f = e.Compile();
  8367. return object.Equals(f(), val);
  8368. }
  8369. }
  8370. public static class Ext {
  8371. public static void StartCapture() {
  8372. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8373. // m.Invoke(null, new object[] { "test.dll" });
  8374. }
  8375. public static void StopCapture() {
  8376. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8377. // m.Invoke(null, new object[0]);
  8378. }
  8379. public static bool IsIntegralOrEnum(Type type) {
  8380. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8381. case TypeCode.Byte:
  8382. case TypeCode.SByte:
  8383. case TypeCode.Int16:
  8384. case TypeCode.Int32:
  8385. case TypeCode.Int64:
  8386. case TypeCode.UInt16:
  8387. case TypeCode.UInt32:
  8388. case TypeCode.UInt64:
  8389. return true;
  8390. default:
  8391. return false;
  8392. }
  8393. }
  8394. public static bool IsFloating(Type type) {
  8395. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8396. case TypeCode.Single:
  8397. case TypeCode.Double:
  8398. return true;
  8399. default:
  8400. return false;
  8401. }
  8402. }
  8403. public static Type GetNonNullableType(Type type) {
  8404. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  8405. type.GetGenericArguments()[0] :
  8406. type;
  8407. }
  8408. }
  8409. public interface I {
  8410. void M();
  8411. }
  8412. public class C : IEquatable<C>, I {
  8413. void I.M() {
  8414. }
  8415. public override bool Equals(object o) {
  8416. return o is C && Equals((C) o);
  8417. }
  8418. public bool Equals(C c) {
  8419. return c != null;
  8420. }
  8421. public override int GetHashCode() {
  8422. return 0;
  8423. }
  8424. }
  8425. public class D : C, IEquatable<D> {
  8426. public int Val;
  8427. public D() {
  8428. }
  8429. public D(int val) {
  8430. Val = val;
  8431. }
  8432. public override bool Equals(object o) {
  8433. return o is D && Equals((D) o);
  8434. }
  8435. public bool Equals(D d) {
  8436. return d != null && d.Val == Val;
  8437. }
  8438. public override int GetHashCode() {
  8439. return Val;
  8440. }
  8441. }
  8442. public enum E {
  8443. A=1, B=2
  8444. }
  8445. public enum El : long {
  8446. A, B, C
  8447. }
  8448. public struct S : IEquatable<S> {
  8449. public override bool Equals(object o) {
  8450. return (o is S) && Equals((S) o);
  8451. }
  8452. public bool Equals(S other) {
  8453. return true;
  8454. }
  8455. public override int GetHashCode() {
  8456. return 0;
  8457. }
  8458. }
  8459. public struct Sp : IEquatable<Sp> {
  8460. public Sp(int i, double d) {
  8461. I = i;
  8462. D = d;
  8463. }
  8464. public int I;
  8465. public double D;
  8466. public override bool Equals(object o) {
  8467. return (o is Sp) && Equals((Sp) o);
  8468. }
  8469. public bool Equals(Sp other) {
  8470. return other.I == I && other.D == D;
  8471. }
  8472. public override int GetHashCode() {
  8473. return I.GetHashCode() ^ D.GetHashCode();
  8474. }
  8475. }
  8476. public struct Ss : IEquatable<Ss> {
  8477. public Ss(S s) {
  8478. Val = s;
  8479. }
  8480. public S Val;
  8481. public override bool Equals(object o) {
  8482. return (o is Ss) && Equals((Ss) o);
  8483. }
  8484. public bool Equals(Ss other) {
  8485. return other.Val.Equals(Val);
  8486. }
  8487. public override int GetHashCode() {
  8488. return Val.GetHashCode();
  8489. }
  8490. }
  8491. public struct Sc : IEquatable<Sc> {
  8492. public Sc(string s) {
  8493. S = s;
  8494. }
  8495. public string S;
  8496. public override bool Equals(object o) {
  8497. return (o is Sc) && Equals((Sc) o);
  8498. }
  8499. public bool Equals(Sc other) {
  8500. return other.S == S;
  8501. }
  8502. public override int GetHashCode() {
  8503. return S.GetHashCode();
  8504. }
  8505. }
  8506. public struct Scs : IEquatable<Scs> {
  8507. public Scs(string s, S val) {
  8508. S = s;
  8509. Val = val;
  8510. }
  8511. public string S;
  8512. public S Val;
  8513. public override bool Equals(object o) {
  8514. return (o is Scs) && Equals((Scs) o);
  8515. }
  8516. public bool Equals(Scs other) {
  8517. return other.S == S && other.Val.Equals(Val);
  8518. }
  8519. public override int GetHashCode() {
  8520. return S.GetHashCode() ^ Val.GetHashCode();
  8521. }
  8522. }
  8523. }
  8524. //-------- Scenario 1766
  8525. namespace Scenario1766{
  8526. public class Test
  8527. {
  8528. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check52__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  8529. public static Expression check52__() {
  8530. if(Main() != 0 ) {
  8531. throw new Exception();
  8532. } else {
  8533. return Expression.Constant(0);
  8534. }
  8535. }
  8536. public static int Main()
  8537. {
  8538. Ext.StartCapture();
  8539. bool success = false;
  8540. try
  8541. {
  8542. success = check52();
  8543. }
  8544. finally
  8545. {
  8546. Ext.StopCapture();
  8547. }
  8548. return success ? 0 : 1;
  8549. }
  8550. static bool check52() {
  8551. foreach (Scs? val in new Scs?[] { null, default(Scs), new Scs(), new Scs(null,new S()) }) {
  8552. if (!check52(val)) {
  8553. return false;
  8554. }
  8555. }
  8556. return true;
  8557. }
  8558. static bool check52(Scs? val) {
  8559. Expression<Func<Scs?>> e =
  8560. Expression.Lambda<Func<Scs?>>(
  8561. Expression.Constant(val, typeof(Scs?)),
  8562. new System.Collections.Generic.List<ParameterExpression>());
  8563. Func<Scs?> f = e.Compile();
  8564. return object.Equals(f(), val);
  8565. }
  8566. }
  8567. public static class Ext {
  8568. public static void StartCapture() {
  8569. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8570. // m.Invoke(null, new object[] { "test.dll" });
  8571. }
  8572. public static void StopCapture() {
  8573. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8574. // m.Invoke(null, new object[0]);
  8575. }
  8576. public static bool IsIntegralOrEnum(Type type) {
  8577. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8578. case TypeCode.Byte:
  8579. case TypeCode.SByte:
  8580. case TypeCode.Int16:
  8581. case TypeCode.Int32:
  8582. case TypeCode.Int64:
  8583. case TypeCode.UInt16:
  8584. case TypeCode.UInt32:
  8585. case TypeCode.UInt64:
  8586. return true;
  8587. default:
  8588. return false;
  8589. }
  8590. }
  8591. public static bool IsFloating(Type type) {
  8592. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8593. case TypeCode.Single:
  8594. case TypeCode.Double:
  8595. return true;
  8596. default:
  8597. return false;
  8598. }
  8599. }
  8600. public static Type GetNonNullableType(Type type) {
  8601. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  8602. type.GetGenericArguments()[0] :
  8603. type;
  8604. }
  8605. }
  8606. public interface I {
  8607. void M();
  8608. }
  8609. public class C : IEquatable<C>, I {
  8610. void I.M() {
  8611. }
  8612. public override bool Equals(object o) {
  8613. return o is C && Equals((C) o);
  8614. }
  8615. public bool Equals(C c) {
  8616. return c != null;
  8617. }
  8618. public override int GetHashCode() {
  8619. return 0;
  8620. }
  8621. }
  8622. public class D : C, IEquatable<D> {
  8623. public int Val;
  8624. public D() {
  8625. }
  8626. public D(int val) {
  8627. Val = val;
  8628. }
  8629. public override bool Equals(object o) {
  8630. return o is D && Equals((D) o);
  8631. }
  8632. public bool Equals(D d) {
  8633. return d != null && d.Val == Val;
  8634. }
  8635. public override int GetHashCode() {
  8636. return Val;
  8637. }
  8638. }
  8639. public enum E {
  8640. A=1, B=2
  8641. }
  8642. public enum El : long {
  8643. A, B, C
  8644. }
  8645. public struct S : IEquatable<S> {
  8646. public override bool Equals(object o) {
  8647. return (o is S) && Equals((S) o);
  8648. }
  8649. public bool Equals(S other) {
  8650. return true;
  8651. }
  8652. public override int GetHashCode() {
  8653. return 0;
  8654. }
  8655. }
  8656. public struct Sp : IEquatable<Sp> {
  8657. public Sp(int i, double d) {
  8658. I = i;
  8659. D = d;
  8660. }
  8661. public int I;
  8662. public double D;
  8663. public override bool Equals(object o) {
  8664. return (o is Sp) && Equals((Sp) o);
  8665. }
  8666. public bool Equals(Sp other) {
  8667. return other.I == I && other.D == D;
  8668. }
  8669. public override int GetHashCode() {
  8670. return I.GetHashCode() ^ D.GetHashCode();
  8671. }
  8672. }
  8673. public struct Ss : IEquatable<Ss> {
  8674. public Ss(S s) {
  8675. Val = s;
  8676. }
  8677. public S Val;
  8678. public override bool Equals(object o) {
  8679. return (o is Ss) && Equals((Ss) o);
  8680. }
  8681. public bool Equals(Ss other) {
  8682. return other.Val.Equals(Val);
  8683. }
  8684. public override int GetHashCode() {
  8685. return Val.GetHashCode();
  8686. }
  8687. }
  8688. public struct Sc : IEquatable<Sc> {
  8689. public Sc(string s) {
  8690. S = s;
  8691. }
  8692. public string S;
  8693. public override bool Equals(object o) {
  8694. return (o is Sc) && Equals((Sc) o);
  8695. }
  8696. public bool Equals(Sc other) {
  8697. return other.S == S;
  8698. }
  8699. public override int GetHashCode() {
  8700. return S.GetHashCode();
  8701. }
  8702. }
  8703. public struct Scs : IEquatable<Scs> {
  8704. public Scs(string s, S val) {
  8705. S = s;
  8706. Val = val;
  8707. }
  8708. public string S;
  8709. public S Val;
  8710. public override bool Equals(object o) {
  8711. return (o is Scs) && Equals((Scs) o);
  8712. }
  8713. public bool Equals(Scs other) {
  8714. return other.S == S && other.Val.Equals(Val);
  8715. }
  8716. public override int GetHashCode() {
  8717. return S.GetHashCode() ^ Val.GetHashCode();
  8718. }
  8719. }
  8720. }
  8721. //-------- Scenario 1767
  8722. namespace Scenario1767{
  8723. public class Test
  8724. {
  8725. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check53_S___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  8726. public static Expression check53_S___() {
  8727. if(Main() != 0 ) {
  8728. throw new Exception();
  8729. } else {
  8730. return Expression.Constant(0);
  8731. }
  8732. }
  8733. public static int Main()
  8734. {
  8735. Ext.StartCapture();
  8736. bool success = false;
  8737. try
  8738. {
  8739. success = check53<S>();
  8740. }
  8741. finally
  8742. {
  8743. Ext.StopCapture();
  8744. }
  8745. return success ? 0 : 1;
  8746. }
  8747. static bool check53<Ts>() where Ts : struct {
  8748. foreach (Ts? val in new Ts?[] { null, default(Ts), new Ts() }) {
  8749. if (!check53<Ts>(val)) {
  8750. return false;
  8751. }
  8752. }
  8753. return true;
  8754. }
  8755. static bool check53<Ts>(Ts? val) where Ts : struct {
  8756. Expression<Func<Ts?>> e =
  8757. Expression.Lambda<Func<Ts?>>(
  8758. Expression.Constant(val, typeof(Ts?)),
  8759. new System.Collections.Generic.List<ParameterExpression>());
  8760. Func<Ts?> f = e.Compile();
  8761. return object.Equals(f(), val);
  8762. }
  8763. }
  8764. public static class Ext {
  8765. public static void StartCapture() {
  8766. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8767. // m.Invoke(null, new object[] { "test.dll" });
  8768. }
  8769. public static void StopCapture() {
  8770. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8771. // m.Invoke(null, new object[0]);
  8772. }
  8773. public static bool IsIntegralOrEnum(Type type) {
  8774. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8775. case TypeCode.Byte:
  8776. case TypeCode.SByte:
  8777. case TypeCode.Int16:
  8778. case TypeCode.Int32:
  8779. case TypeCode.Int64:
  8780. case TypeCode.UInt16:
  8781. case TypeCode.UInt32:
  8782. case TypeCode.UInt64:
  8783. return true;
  8784. default:
  8785. return false;
  8786. }
  8787. }
  8788. public static bool IsFloating(Type type) {
  8789. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8790. case TypeCode.Single:
  8791. case TypeCode.Double:
  8792. return true;
  8793. default:
  8794. return false;
  8795. }
  8796. }
  8797. public static Type GetNonNullableType(Type type) {
  8798. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  8799. type.GetGenericArguments()[0] :
  8800. type;
  8801. }
  8802. }
  8803. public interface I {
  8804. void M();
  8805. }
  8806. public class C : IEquatable<C>, I {
  8807. void I.M() {
  8808. }
  8809. public override bool Equals(object o) {
  8810. return o is C && Equals((C) o);
  8811. }
  8812. public bool Equals(C c) {
  8813. return c != null;
  8814. }
  8815. public override int GetHashCode() {
  8816. return 0;
  8817. }
  8818. }
  8819. public class D : C, IEquatable<D> {
  8820. public int Val;
  8821. public D() {
  8822. }
  8823. public D(int val) {
  8824. Val = val;
  8825. }
  8826. public override bool Equals(object o) {
  8827. return o is D && Equals((D) o);
  8828. }
  8829. public bool Equals(D d) {
  8830. return d != null && d.Val == Val;
  8831. }
  8832. public override int GetHashCode() {
  8833. return Val;
  8834. }
  8835. }
  8836. public enum E {
  8837. A=1, B=2
  8838. }
  8839. public enum El : long {
  8840. A, B, C
  8841. }
  8842. public struct S : IEquatable<S> {
  8843. public override bool Equals(object o) {
  8844. return (o is S) && Equals((S) o);
  8845. }
  8846. public bool Equals(S other) {
  8847. return true;
  8848. }
  8849. public override int GetHashCode() {
  8850. return 0;
  8851. }
  8852. }
  8853. public struct Sp : IEquatable<Sp> {
  8854. public Sp(int i, double d) {
  8855. I = i;
  8856. D = d;
  8857. }
  8858. public int I;
  8859. public double D;
  8860. public override bool Equals(object o) {
  8861. return (o is Sp) && Equals((Sp) o);
  8862. }
  8863. public bool Equals(Sp other) {
  8864. return other.I == I && other.D == D;
  8865. }
  8866. public override int GetHashCode() {
  8867. return I.GetHashCode() ^ D.GetHashCode();
  8868. }
  8869. }
  8870. public struct Ss : IEquatable<Ss> {
  8871. public Ss(S s) {
  8872. Val = s;
  8873. }
  8874. public S Val;
  8875. public override bool Equals(object o) {
  8876. return (o is Ss) && Equals((Ss) o);
  8877. }
  8878. public bool Equals(Ss other) {
  8879. return other.Val.Equals(Val);
  8880. }
  8881. public override int GetHashCode() {
  8882. return Val.GetHashCode();
  8883. }
  8884. }
  8885. public struct Sc : IEquatable<Sc> {
  8886. public Sc(string s) {
  8887. S = s;
  8888. }
  8889. public string S;
  8890. public override bool Equals(object o) {
  8891. return (o is Sc) && Equals((Sc) o);
  8892. }
  8893. public bool Equals(Sc other) {
  8894. return other.S == S;
  8895. }
  8896. public override int GetHashCode() {
  8897. return S.GetHashCode();
  8898. }
  8899. }
  8900. public struct Scs : IEquatable<Scs> {
  8901. public Scs(string s, S val) {
  8902. S = s;
  8903. Val = val;
  8904. }
  8905. public string S;
  8906. public S Val;
  8907. public override bool Equals(object o) {
  8908. return (o is Scs) && Equals((Scs) o);
  8909. }
  8910. public bool Equals(Scs other) {
  8911. return other.S == S && other.Val.Equals(Val);
  8912. }
  8913. public override int GetHashCode() {
  8914. return S.GetHashCode() ^ Val.GetHashCode();
  8915. }
  8916. }
  8917. }
  8918. //-------- Scenario 1768
  8919. namespace Scenario1768{
  8920. public class Test
  8921. {
  8922. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check53_Scs___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  8923. public static Expression check53_Scs___() {
  8924. if(Main() != 0 ) {
  8925. throw new Exception();
  8926. } else {
  8927. return Expression.Constant(0);
  8928. }
  8929. }
  8930. public static int Main()
  8931. {
  8932. Ext.StartCapture();
  8933. bool success = false;
  8934. try
  8935. {
  8936. success = check53<Scs>();
  8937. }
  8938. finally
  8939. {
  8940. Ext.StopCapture();
  8941. }
  8942. return success ? 0 : 1;
  8943. }
  8944. static bool check53<Ts>() where Ts : struct {
  8945. foreach (Ts? val in new Ts?[] { null, default(Ts), new Ts() }) {
  8946. if (!check53<Ts>(val)) {
  8947. return false;
  8948. }
  8949. }
  8950. return true;
  8951. }
  8952. static bool check53<Ts>(Ts? val) where Ts : struct {
  8953. Expression<Func<Ts?>> e =
  8954. Expression.Lambda<Func<Ts?>>(
  8955. Expression.Constant(val, typeof(Ts?)),
  8956. new System.Collections.Generic.List<ParameterExpression>());
  8957. Func<Ts?> f = e.Compile();
  8958. return object.Equals(f(), val);
  8959. }
  8960. }
  8961. public static class Ext {
  8962. public static void StartCapture() {
  8963. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8964. // m.Invoke(null, new object[] { "test.dll" });
  8965. }
  8966. public static void StopCapture() {
  8967. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  8968. // m.Invoke(null, new object[0]);
  8969. }
  8970. public static bool IsIntegralOrEnum(Type type) {
  8971. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8972. case TypeCode.Byte:
  8973. case TypeCode.SByte:
  8974. case TypeCode.Int16:
  8975. case TypeCode.Int32:
  8976. case TypeCode.Int64:
  8977. case TypeCode.UInt16:
  8978. case TypeCode.UInt32:
  8979. case TypeCode.UInt64:
  8980. return true;
  8981. default:
  8982. return false;
  8983. }
  8984. }
  8985. public static bool IsFloating(Type type) {
  8986. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  8987. case TypeCode.Single:
  8988. case TypeCode.Double:
  8989. return true;
  8990. default:
  8991. return false;
  8992. }
  8993. }
  8994. public static Type GetNonNullableType(Type type) {
  8995. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  8996. type.GetGenericArguments()[0] :
  8997. type;
  8998. }
  8999. }
  9000. public interface I {
  9001. void M();
  9002. }
  9003. public class C : IEquatable<C>, I {
  9004. void I.M() {
  9005. }
  9006. public override bool Equals(object o) {
  9007. return o is C && Equals((C) o);
  9008. }
  9009. public bool Equals(C c) {
  9010. return c != null;
  9011. }
  9012. public override int GetHashCode() {
  9013. return 0;
  9014. }
  9015. }
  9016. public class D : C, IEquatable<D> {
  9017. public int Val;
  9018. public D() {
  9019. }
  9020. public D(int val) {
  9021. Val = val;
  9022. }
  9023. public override bool Equals(object o) {
  9024. return o is D && Equals((D) o);
  9025. }
  9026. public bool Equals(D d) {
  9027. return d != null && d.Val == Val;
  9028. }
  9029. public override int GetHashCode() {
  9030. return Val;
  9031. }
  9032. }
  9033. public enum E {
  9034. A=1, B=2
  9035. }
  9036. public enum El : long {
  9037. A, B, C
  9038. }
  9039. public struct S : IEquatable<S> {
  9040. public override bool Equals(object o) {
  9041. return (o is S) && Equals((S) o);
  9042. }
  9043. public bool Equals(S other) {
  9044. return true;
  9045. }
  9046. public override int GetHashCode() {
  9047. return 0;
  9048. }
  9049. }
  9050. public struct Sp : IEquatable<Sp> {
  9051. public Sp(int i, double d) {
  9052. I = i;
  9053. D = d;
  9054. }
  9055. public int I;
  9056. public double D;
  9057. public override bool Equals(object o) {
  9058. return (o is Sp) && Equals((Sp) o);
  9059. }
  9060. public bool Equals(Sp other) {
  9061. return other.I == I && other.D == D;
  9062. }
  9063. public override int GetHashCode() {
  9064. return I.GetHashCode() ^ D.GetHashCode();
  9065. }
  9066. }
  9067. public struct Ss : IEquatable<Ss> {
  9068. public Ss(S s) {
  9069. Val = s;
  9070. }
  9071. public S Val;
  9072. public override bool Equals(object o) {
  9073. return (o is Ss) && Equals((Ss) o);
  9074. }
  9075. public bool Equals(Ss other) {
  9076. return other.Val.Equals(Val);
  9077. }
  9078. public override int GetHashCode() {
  9079. return Val.GetHashCode();
  9080. }
  9081. }
  9082. public struct Sc : IEquatable<Sc> {
  9083. public Sc(string s) {
  9084. S = s;
  9085. }
  9086. public string S;
  9087. public override bool Equals(object o) {
  9088. return (o is Sc) && Equals((Sc) o);
  9089. }
  9090. public bool Equals(Sc other) {
  9091. return other.S == S;
  9092. }
  9093. public override int GetHashCode() {
  9094. return S.GetHashCode();
  9095. }
  9096. }
  9097. public struct Scs : IEquatable<Scs> {
  9098. public Scs(string s, S val) {
  9099. S = s;
  9100. Val = val;
  9101. }
  9102. public string S;
  9103. public S Val;
  9104. public override bool Equals(object o) {
  9105. return (o is Scs) && Equals((Scs) o);
  9106. }
  9107. public bool Equals(Scs other) {
  9108. return other.S == S && other.Val.Equals(Val);
  9109. }
  9110. public override int GetHashCode() {
  9111. return S.GetHashCode() ^ Val.GetHashCode();
  9112. }
  9113. }
  9114. }
  9115. //-------- Scenario 1769
  9116. namespace Scenario1769{
  9117. public class Test
  9118. {
  9119. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check53_E___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  9120. public static Expression check53_E___() {
  9121. if(Main() != 0 ) {
  9122. throw new Exception();
  9123. } else {
  9124. return Expression.Constant(0);
  9125. }
  9126. }
  9127. public static int Main()
  9128. {
  9129. Ext.StartCapture();
  9130. bool success = false;
  9131. try
  9132. {
  9133. success = check53<E>();
  9134. }
  9135. finally
  9136. {
  9137. Ext.StopCapture();
  9138. }
  9139. return success ? 0 : 1;
  9140. }
  9141. static bool check53<Ts>() where Ts : struct {
  9142. foreach (Ts? val in new Ts?[] { null, default(Ts), new Ts() }) {
  9143. if (!check53<Ts>(val)) {
  9144. return false;
  9145. }
  9146. }
  9147. return true;
  9148. }
  9149. static bool check53<Ts>(Ts? val) where Ts : struct {
  9150. Expression<Func<Ts?>> e =
  9151. Expression.Lambda<Func<Ts?>>(
  9152. Expression.Constant(val, typeof(Ts?)),
  9153. new System.Collections.Generic.List<ParameterExpression>());
  9154. Func<Ts?> f = e.Compile();
  9155. return object.Equals(f(), val);
  9156. }
  9157. }
  9158. public static class Ext {
  9159. public static void StartCapture() {
  9160. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9161. // m.Invoke(null, new object[] { "test.dll" });
  9162. }
  9163. public static void StopCapture() {
  9164. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9165. // m.Invoke(null, new object[0]);
  9166. }
  9167. public static bool IsIntegralOrEnum(Type type) {
  9168. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9169. case TypeCode.Byte:
  9170. case TypeCode.SByte:
  9171. case TypeCode.Int16:
  9172. case TypeCode.Int32:
  9173. case TypeCode.Int64:
  9174. case TypeCode.UInt16:
  9175. case TypeCode.UInt32:
  9176. case TypeCode.UInt64:
  9177. return true;
  9178. default:
  9179. return false;
  9180. }
  9181. }
  9182. public static bool IsFloating(Type type) {
  9183. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9184. case TypeCode.Single:
  9185. case TypeCode.Double:
  9186. return true;
  9187. default:
  9188. return false;
  9189. }
  9190. }
  9191. public static Type GetNonNullableType(Type type) {
  9192. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  9193. type.GetGenericArguments()[0] :
  9194. type;
  9195. }
  9196. }
  9197. public interface I {
  9198. void M();
  9199. }
  9200. public class C : IEquatable<C>, I {
  9201. void I.M() {
  9202. }
  9203. public override bool Equals(object o) {
  9204. return o is C && Equals((C) o);
  9205. }
  9206. public bool Equals(C c) {
  9207. return c != null;
  9208. }
  9209. public override int GetHashCode() {
  9210. return 0;
  9211. }
  9212. }
  9213. public class D : C, IEquatable<D> {
  9214. public int Val;
  9215. public D() {
  9216. }
  9217. public D(int val) {
  9218. Val = val;
  9219. }
  9220. public override bool Equals(object o) {
  9221. return o is D && Equals((D) o);
  9222. }
  9223. public bool Equals(D d) {
  9224. return d != null && d.Val == Val;
  9225. }
  9226. public override int GetHashCode() {
  9227. return Val;
  9228. }
  9229. }
  9230. public enum E {
  9231. A=1, B=2
  9232. }
  9233. public enum El : long {
  9234. A, B, C
  9235. }
  9236. public struct S : IEquatable<S> {
  9237. public override bool Equals(object o) {
  9238. return (o is S) && Equals((S) o);
  9239. }
  9240. public bool Equals(S other) {
  9241. return true;
  9242. }
  9243. public override int GetHashCode() {
  9244. return 0;
  9245. }
  9246. }
  9247. public struct Sp : IEquatable<Sp> {
  9248. public Sp(int i, double d) {
  9249. I = i;
  9250. D = d;
  9251. }
  9252. public int I;
  9253. public double D;
  9254. public override bool Equals(object o) {
  9255. return (o is Sp) && Equals((Sp) o);
  9256. }
  9257. public bool Equals(Sp other) {
  9258. return other.I == I && other.D == D;
  9259. }
  9260. public override int GetHashCode() {
  9261. return I.GetHashCode() ^ D.GetHashCode();
  9262. }
  9263. }
  9264. public struct Ss : IEquatable<Ss> {
  9265. public Ss(S s) {
  9266. Val = s;
  9267. }
  9268. public S Val;
  9269. public override bool Equals(object o) {
  9270. return (o is Ss) && Equals((Ss) o);
  9271. }
  9272. public bool Equals(Ss other) {
  9273. return other.Val.Equals(Val);
  9274. }
  9275. public override int GetHashCode() {
  9276. return Val.GetHashCode();
  9277. }
  9278. }
  9279. public struct Sc : IEquatable<Sc> {
  9280. public Sc(string s) {
  9281. S = s;
  9282. }
  9283. public string S;
  9284. public override bool Equals(object o) {
  9285. return (o is Sc) && Equals((Sc) o);
  9286. }
  9287. public bool Equals(Sc other) {
  9288. return other.S == S;
  9289. }
  9290. public override int GetHashCode() {
  9291. return S.GetHashCode();
  9292. }
  9293. }
  9294. public struct Scs : IEquatable<Scs> {
  9295. public Scs(string s, S val) {
  9296. S = s;
  9297. Val = val;
  9298. }
  9299. public string S;
  9300. public S Val;
  9301. public override bool Equals(object o) {
  9302. return (o is Scs) && Equals((Scs) o);
  9303. }
  9304. public bool Equals(Scs other) {
  9305. return other.S == S && other.Val.Equals(Val);
  9306. }
  9307. public override int GetHashCode() {
  9308. return S.GetHashCode() ^ Val.GetHashCode();
  9309. }
  9310. }
  9311. }
  9312. //-------- Scenario 1770
  9313. namespace Scenario1770{
  9314. public class Test
  9315. {
  9316. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check54__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  9317. public static Expression check54__() {
  9318. if(Main() != 0 ) {
  9319. throw new Exception();
  9320. } else {
  9321. return Expression.Constant(0);
  9322. }
  9323. }
  9324. public static int Main()
  9325. {
  9326. Ext.StartCapture();
  9327. bool success = false;
  9328. try
  9329. {
  9330. success = check54();
  9331. }
  9332. finally
  9333. {
  9334. Ext.StopCapture();
  9335. }
  9336. return success ? 0 : 1;
  9337. }
  9338. static bool check54() {
  9339. foreach (E? val in new E?[] { null, (E) 0, E.A, E.B, (E) int.MaxValue, (E) int.MinValue }) {
  9340. if (!check54(val)) {
  9341. return false;
  9342. }
  9343. }
  9344. return true;
  9345. }
  9346. static bool check54(E? val) {
  9347. Expression<Func<E?>> e =
  9348. Expression.Lambda<Func<E?>>(
  9349. Expression.Constant(val, typeof(E?)),
  9350. new System.Collections.Generic.List<ParameterExpression>());
  9351. Func<E?> f = e.Compile();
  9352. return object.Equals(f(), val);
  9353. }
  9354. }
  9355. public static class Ext {
  9356. public static void StartCapture() {
  9357. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9358. // m.Invoke(null, new object[] { "test.dll" });
  9359. }
  9360. public static void StopCapture() {
  9361. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9362. // m.Invoke(null, new object[0]);
  9363. }
  9364. public static bool IsIntegralOrEnum(Type type) {
  9365. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9366. case TypeCode.Byte:
  9367. case TypeCode.SByte:
  9368. case TypeCode.Int16:
  9369. case TypeCode.Int32:
  9370. case TypeCode.Int64:
  9371. case TypeCode.UInt16:
  9372. case TypeCode.UInt32:
  9373. case TypeCode.UInt64:
  9374. return true;
  9375. default:
  9376. return false;
  9377. }
  9378. }
  9379. public static bool IsFloating(Type type) {
  9380. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9381. case TypeCode.Single:
  9382. case TypeCode.Double:
  9383. return true;
  9384. default:
  9385. return false;
  9386. }
  9387. }
  9388. public static Type GetNonNullableType(Type type) {
  9389. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  9390. type.GetGenericArguments()[0] :
  9391. type;
  9392. }
  9393. }
  9394. public interface I {
  9395. void M();
  9396. }
  9397. public class C : IEquatable<C>, I {
  9398. void I.M() {
  9399. }
  9400. public override bool Equals(object o) {
  9401. return o is C && Equals((C) o);
  9402. }
  9403. public bool Equals(C c) {
  9404. return c != null;
  9405. }
  9406. public override int GetHashCode() {
  9407. return 0;
  9408. }
  9409. }
  9410. public class D : C, IEquatable<D> {
  9411. public int Val;
  9412. public D() {
  9413. }
  9414. public D(int val) {
  9415. Val = val;
  9416. }
  9417. public override bool Equals(object o) {
  9418. return o is D && Equals((D) o);
  9419. }
  9420. public bool Equals(D d) {
  9421. return d != null && d.Val == Val;
  9422. }
  9423. public override int GetHashCode() {
  9424. return Val;
  9425. }
  9426. }
  9427. public enum E {
  9428. A=1, B=2
  9429. }
  9430. public enum El : long {
  9431. A, B, C
  9432. }
  9433. public struct S : IEquatable<S> {
  9434. public override bool Equals(object o) {
  9435. return (o is S) && Equals((S) o);
  9436. }
  9437. public bool Equals(S other) {
  9438. return true;
  9439. }
  9440. public override int GetHashCode() {
  9441. return 0;
  9442. }
  9443. }
  9444. public struct Sp : IEquatable<Sp> {
  9445. public Sp(int i, double d) {
  9446. I = i;
  9447. D = d;
  9448. }
  9449. public int I;
  9450. public double D;
  9451. public override bool Equals(object o) {
  9452. return (o is Sp) && Equals((Sp) o);
  9453. }
  9454. public bool Equals(Sp other) {
  9455. return other.I == I && other.D == D;
  9456. }
  9457. public override int GetHashCode() {
  9458. return I.GetHashCode() ^ D.GetHashCode();
  9459. }
  9460. }
  9461. public struct Ss : IEquatable<Ss> {
  9462. public Ss(S s) {
  9463. Val = s;
  9464. }
  9465. public S Val;
  9466. public override bool Equals(object o) {
  9467. return (o is Ss) && Equals((Ss) o);
  9468. }
  9469. public bool Equals(Ss other) {
  9470. return other.Val.Equals(Val);
  9471. }
  9472. public override int GetHashCode() {
  9473. return Val.GetHashCode();
  9474. }
  9475. }
  9476. public struct Sc : IEquatable<Sc> {
  9477. public Sc(string s) {
  9478. S = s;
  9479. }
  9480. public string S;
  9481. public override bool Equals(object o) {
  9482. return (o is Sc) && Equals((Sc) o);
  9483. }
  9484. public bool Equals(Sc other) {
  9485. return other.S == S;
  9486. }
  9487. public override int GetHashCode() {
  9488. return S.GetHashCode();
  9489. }
  9490. }
  9491. public struct Scs : IEquatable<Scs> {
  9492. public Scs(string s, S val) {
  9493. S = s;
  9494. Val = val;
  9495. }
  9496. public string S;
  9497. public S Val;
  9498. public override bool Equals(object o) {
  9499. return (o is Scs) && Equals((Scs) o);
  9500. }
  9501. public bool Equals(Scs other) {
  9502. return other.S == S && other.Val.Equals(Val);
  9503. }
  9504. public override int GetHashCode() {
  9505. return S.GetHashCode() ^ Val.GetHashCode();
  9506. }
  9507. }
  9508. }
  9509. //-------- Scenario 1771
  9510. namespace Scenario1771{
  9511. public class Test
  9512. {
  9513. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check55__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  9514. public static Expression check55__() {
  9515. if(Main() != 0 ) {
  9516. throw new Exception();
  9517. } else {
  9518. return Expression.Constant(0);
  9519. }
  9520. }
  9521. public static int Main()
  9522. {
  9523. Ext.StartCapture();
  9524. bool success = false;
  9525. try
  9526. {
  9527. success = check55();
  9528. }
  9529. finally
  9530. {
  9531. Ext.StopCapture();
  9532. }
  9533. return success ? 0 : 1;
  9534. }
  9535. static bool check55() {
  9536. foreach (El? val in new El?[] { null, (El) 0, El.A, El.B, (El) long.MaxValue, (El) long.MinValue }) {
  9537. if (!check55(val)) {
  9538. return false;
  9539. }
  9540. }
  9541. return true;
  9542. }
  9543. static bool check55(El? val) {
  9544. Expression<Func<El?>> e =
  9545. Expression.Lambda<Func<El?>>(
  9546. Expression.Constant(val, typeof(El?)),
  9547. new System.Collections.Generic.List<ParameterExpression>());
  9548. Func<El?> f = e.Compile();
  9549. return object.Equals(f(), val);
  9550. }
  9551. }
  9552. public static class Ext {
  9553. public static void StartCapture() {
  9554. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9555. // m.Invoke(null, new object[] { "test.dll" });
  9556. }
  9557. public static void StopCapture() {
  9558. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9559. // m.Invoke(null, new object[0]);
  9560. }
  9561. public static bool IsIntegralOrEnum(Type type) {
  9562. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9563. case TypeCode.Byte:
  9564. case TypeCode.SByte:
  9565. case TypeCode.Int16:
  9566. case TypeCode.Int32:
  9567. case TypeCode.Int64:
  9568. case TypeCode.UInt16:
  9569. case TypeCode.UInt32:
  9570. case TypeCode.UInt64:
  9571. return true;
  9572. default:
  9573. return false;
  9574. }
  9575. }
  9576. public static bool IsFloating(Type type) {
  9577. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9578. case TypeCode.Single:
  9579. case TypeCode.Double:
  9580. return true;
  9581. default:
  9582. return false;
  9583. }
  9584. }
  9585. public static Type GetNonNullableType(Type type) {
  9586. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  9587. type.GetGenericArguments()[0] :
  9588. type;
  9589. }
  9590. }
  9591. public interface I {
  9592. void M();
  9593. }
  9594. public class C : IEquatable<C>, I {
  9595. void I.M() {
  9596. }
  9597. public override bool Equals(object o) {
  9598. return o is C && Equals((C) o);
  9599. }
  9600. public bool Equals(C c) {
  9601. return c != null;
  9602. }
  9603. public override int GetHashCode() {
  9604. return 0;
  9605. }
  9606. }
  9607. public class D : C, IEquatable<D> {
  9608. public int Val;
  9609. public D() {
  9610. }
  9611. public D(int val) {
  9612. Val = val;
  9613. }
  9614. public override bool Equals(object o) {
  9615. return o is D && Equals((D) o);
  9616. }
  9617. public bool Equals(D d) {
  9618. return d != null && d.Val == Val;
  9619. }
  9620. public override int GetHashCode() {
  9621. return Val;
  9622. }
  9623. }
  9624. public enum E {
  9625. A=1, B=2
  9626. }
  9627. public enum El : long {
  9628. A, B, C
  9629. }
  9630. public struct S : IEquatable<S> {
  9631. public override bool Equals(object o) {
  9632. return (o is S) && Equals((S) o);
  9633. }
  9634. public bool Equals(S other) {
  9635. return true;
  9636. }
  9637. public override int GetHashCode() {
  9638. return 0;
  9639. }
  9640. }
  9641. public struct Sp : IEquatable<Sp> {
  9642. public Sp(int i, double d) {
  9643. I = i;
  9644. D = d;
  9645. }
  9646. public int I;
  9647. public double D;
  9648. public override bool Equals(object o) {
  9649. return (o is Sp) && Equals((Sp) o);
  9650. }
  9651. public bool Equals(Sp other) {
  9652. return other.I == I && other.D == D;
  9653. }
  9654. public override int GetHashCode() {
  9655. return I.GetHashCode() ^ D.GetHashCode();
  9656. }
  9657. }
  9658. public struct Ss : IEquatable<Ss> {
  9659. public Ss(S s) {
  9660. Val = s;
  9661. }
  9662. public S Val;
  9663. public override bool Equals(object o) {
  9664. return (o is Ss) && Equals((Ss) o);
  9665. }
  9666. public bool Equals(Ss other) {
  9667. return other.Val.Equals(Val);
  9668. }
  9669. public override int GetHashCode() {
  9670. return Val.GetHashCode();
  9671. }
  9672. }
  9673. public struct Sc : IEquatable<Sc> {
  9674. public Sc(string s) {
  9675. S = s;
  9676. }
  9677. public string S;
  9678. public override bool Equals(object o) {
  9679. return (o is Sc) && Equals((Sc) o);
  9680. }
  9681. public bool Equals(Sc other) {
  9682. return other.S == S;
  9683. }
  9684. public override int GetHashCode() {
  9685. return S.GetHashCode();
  9686. }
  9687. }
  9688. public struct Scs : IEquatable<Scs> {
  9689. public Scs(string s, S val) {
  9690. S = s;
  9691. Val = val;
  9692. }
  9693. public string S;
  9694. public S Val;
  9695. public override bool Equals(object o) {
  9696. return (o is Scs) && Equals((Scs) o);
  9697. }
  9698. public bool Equals(Scs other) {
  9699. return other.S == S && other.Val.Equals(Val);
  9700. }
  9701. public override int GetHashCode() {
  9702. return S.GetHashCode() ^ Val.GetHashCode();
  9703. }
  9704. }
  9705. }
  9706. //-------- Scenario 1772
  9707. namespace Scenario1772{
  9708. public class Test
  9709. {
  9710. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check56__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  9711. public static Expression check56__() {
  9712. if(Main() != 0 ) {
  9713. throw new Exception();
  9714. } else {
  9715. return Expression.Constant(0);
  9716. }
  9717. }
  9718. public static int Main()
  9719. {
  9720. Ext.StartCapture();
  9721. bool success = false;
  9722. try
  9723. {
  9724. success = check56();
  9725. }
  9726. finally
  9727. {
  9728. Ext.StopCapture();
  9729. }
  9730. return success ? 0 : 1;
  9731. }
  9732. static bool check56() {
  9733. foreach (byte[] val in new byte[][] { null, new byte[0], new byte[] { 0, 1, byte.MaxValue }, new byte[100] }) {
  9734. if (!check56(val)) {
  9735. return false;
  9736. }
  9737. }
  9738. return true;
  9739. }
  9740. static bool check56(byte[] val) {
  9741. Expression<Func<byte[]>> e =
  9742. Expression.Lambda<Func<byte[]>>(
  9743. Expression.Constant(val, typeof(byte[])),
  9744. new System.Collections.Generic.List<ParameterExpression>());
  9745. Func<byte[]> f = e.Compile();
  9746. return object.Equals(f(), val);
  9747. }
  9748. }
  9749. public static class Ext {
  9750. public static void StartCapture() {
  9751. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9752. // m.Invoke(null, new object[] { "test.dll" });
  9753. }
  9754. public static void StopCapture() {
  9755. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9756. // m.Invoke(null, new object[0]);
  9757. }
  9758. public static bool IsIntegralOrEnum(Type type) {
  9759. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9760. case TypeCode.Byte:
  9761. case TypeCode.SByte:
  9762. case TypeCode.Int16:
  9763. case TypeCode.Int32:
  9764. case TypeCode.Int64:
  9765. case TypeCode.UInt16:
  9766. case TypeCode.UInt32:
  9767. case TypeCode.UInt64:
  9768. return true;
  9769. default:
  9770. return false;
  9771. }
  9772. }
  9773. public static bool IsFloating(Type type) {
  9774. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9775. case TypeCode.Single:
  9776. case TypeCode.Double:
  9777. return true;
  9778. default:
  9779. return false;
  9780. }
  9781. }
  9782. public static Type GetNonNullableType(Type type) {
  9783. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  9784. type.GetGenericArguments()[0] :
  9785. type;
  9786. }
  9787. }
  9788. }
  9789. //-------- Scenario 1773
  9790. namespace Scenario1773{
  9791. public class Test
  9792. {
  9793. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check57__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  9794. public static Expression check57__() {
  9795. if(Main() != 0 ) {
  9796. throw new Exception();
  9797. } else {
  9798. return Expression.Constant(0);
  9799. }
  9800. }
  9801. public static int Main()
  9802. {
  9803. Ext.StartCapture();
  9804. bool success = false;
  9805. try
  9806. {
  9807. success = check57();
  9808. }
  9809. finally
  9810. {
  9811. Ext.StopCapture();
  9812. }
  9813. return success ? 0 : 1;
  9814. }
  9815. static bool check57() {
  9816. foreach (ushort[] val in new ushort[][] { null, new ushort[0], new ushort[] { 0, 1, ushort.MaxValue }, new ushort[100] }) {
  9817. if (!check57(val)) {
  9818. return false;
  9819. }
  9820. }
  9821. return true;
  9822. }
  9823. static bool check57(ushort[] val) {
  9824. Expression<Func<ushort[]>> e =
  9825. Expression.Lambda<Func<ushort[]>>(
  9826. Expression.Constant(val, typeof(ushort[])),
  9827. new System.Collections.Generic.List<ParameterExpression>());
  9828. Func<ushort[]> f = e.Compile();
  9829. return object.Equals(f(), val);
  9830. }
  9831. }
  9832. public static class Ext {
  9833. public static void StartCapture() {
  9834. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9835. // m.Invoke(null, new object[] { "test.dll" });
  9836. }
  9837. public static void StopCapture() {
  9838. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9839. // m.Invoke(null, new object[0]);
  9840. }
  9841. public static bool IsIntegralOrEnum(Type type) {
  9842. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9843. case TypeCode.Byte:
  9844. case TypeCode.SByte:
  9845. case TypeCode.Int16:
  9846. case TypeCode.Int32:
  9847. case TypeCode.Int64:
  9848. case TypeCode.UInt16:
  9849. case TypeCode.UInt32:
  9850. case TypeCode.UInt64:
  9851. return true;
  9852. default:
  9853. return false;
  9854. }
  9855. }
  9856. public static bool IsFloating(Type type) {
  9857. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9858. case TypeCode.Single:
  9859. case TypeCode.Double:
  9860. return true;
  9861. default:
  9862. return false;
  9863. }
  9864. }
  9865. public static Type GetNonNullableType(Type type) {
  9866. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  9867. type.GetGenericArguments()[0] :
  9868. type;
  9869. }
  9870. }
  9871. }
  9872. //-------- Scenario 1774
  9873. namespace Scenario1774{
  9874. public class Test
  9875. {
  9876. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check58__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  9877. public static Expression check58__() {
  9878. if(Main() != 0 ) {
  9879. throw new Exception();
  9880. } else {
  9881. return Expression.Constant(0);
  9882. }
  9883. }
  9884. public static int Main()
  9885. {
  9886. Ext.StartCapture();
  9887. bool success = false;
  9888. try
  9889. {
  9890. success = check58();
  9891. }
  9892. finally
  9893. {
  9894. Ext.StopCapture();
  9895. }
  9896. return success ? 0 : 1;
  9897. }
  9898. static bool check58() {
  9899. foreach (uint[] val in new uint[][] { null, new uint[0], new uint[] { 0, 1, uint.MaxValue }, new uint[100] }) {
  9900. if (!check58(val)) {
  9901. return false;
  9902. }
  9903. }
  9904. return true;
  9905. }
  9906. static bool check58(uint[] val) {
  9907. Expression<Func<uint[]>> e =
  9908. Expression.Lambda<Func<uint[]>>(
  9909. Expression.Constant(val, typeof(uint[])),
  9910. new System.Collections.Generic.List<ParameterExpression>());
  9911. Func<uint[]> f = e.Compile();
  9912. return object.Equals(f(), val);
  9913. }
  9914. }
  9915. public static class Ext {
  9916. public static void StartCapture() {
  9917. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9918. // m.Invoke(null, new object[] { "test.dll" });
  9919. }
  9920. public static void StopCapture() {
  9921. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  9922. // m.Invoke(null, new object[0]);
  9923. }
  9924. public static bool IsIntegralOrEnum(Type type) {
  9925. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9926. case TypeCode.Byte:
  9927. case TypeCode.SByte:
  9928. case TypeCode.Int16:
  9929. case TypeCode.Int32:
  9930. case TypeCode.Int64:
  9931. case TypeCode.UInt16:
  9932. case TypeCode.UInt32:
  9933. case TypeCode.UInt64:
  9934. return true;
  9935. default:
  9936. return false;
  9937. }
  9938. }
  9939. public static bool IsFloating(Type type) {
  9940. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  9941. case TypeCode.Single:
  9942. case TypeCode.Double:
  9943. return true;
  9944. default:
  9945. return false;
  9946. }
  9947. }
  9948. public static Type GetNonNullableType(Type type) {
  9949. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  9950. type.GetGenericArguments()[0] :
  9951. type;
  9952. }
  9953. }
  9954. }
  9955. //-------- Scenario 1775
  9956. namespace Scenario1775{
  9957. public class Test
  9958. {
  9959. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check59__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  9960. public static Expression check59__() {
  9961. if(Main() != 0 ) {
  9962. throw new Exception();
  9963. } else {
  9964. return Expression.Constant(0);
  9965. }
  9966. }
  9967. public static int Main()
  9968. {
  9969. Ext.StartCapture();
  9970. bool success = false;
  9971. try
  9972. {
  9973. success = check59();
  9974. }
  9975. finally
  9976. {
  9977. Ext.StopCapture();
  9978. }
  9979. return success ? 0 : 1;
  9980. }
  9981. static bool check59() {
  9982. foreach (ulong[] val in new ulong[][] { null, new ulong[0], new ulong[] { 0, 1, ulong.MaxValue }, new ulong[100] }) {
  9983. if (!check59(val)) {
  9984. return false;
  9985. }
  9986. }
  9987. return true;
  9988. }
  9989. static bool check59(ulong[] val) {
  9990. Expression<Func<ulong[]>> e =
  9991. Expression.Lambda<Func<ulong[]>>(
  9992. Expression.Constant(val, typeof(ulong[])),
  9993. new System.Collections.Generic.List<ParameterExpression>());
  9994. Func<ulong[]> f = e.Compile();
  9995. return object.Equals(f(), val);
  9996. }
  9997. }
  9998. public static class Ext {
  9999. public static void StartCapture() {
  10000. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10001. // m.Invoke(null, new object[] { "test.dll" });
  10002. }
  10003. public static void StopCapture() {
  10004. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10005. // m.Invoke(null, new object[0]);
  10006. }
  10007. public static bool IsIntegralOrEnum(Type type) {
  10008. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10009. case TypeCode.Byte:
  10010. case TypeCode.SByte:
  10011. case TypeCode.Int16:
  10012. case TypeCode.Int32:
  10013. case TypeCode.Int64:
  10014. case TypeCode.UInt16:
  10015. case TypeCode.UInt32:
  10016. case TypeCode.UInt64:
  10017. return true;
  10018. default:
  10019. return false;
  10020. }
  10021. }
  10022. public static bool IsFloating(Type type) {
  10023. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10024. case TypeCode.Single:
  10025. case TypeCode.Double:
  10026. return true;
  10027. default:
  10028. return false;
  10029. }
  10030. }
  10031. public static Type GetNonNullableType(Type type) {
  10032. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10033. type.GetGenericArguments()[0] :
  10034. type;
  10035. }
  10036. }
  10037. }
  10038. //-------- Scenario 1776
  10039. namespace Scenario1776{
  10040. public class Test
  10041. {
  10042. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check60__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10043. public static Expression check60__() {
  10044. if(Main() != 0 ) {
  10045. throw new Exception();
  10046. } else {
  10047. return Expression.Constant(0);
  10048. }
  10049. }
  10050. public static int Main()
  10051. {
  10052. Ext.StartCapture();
  10053. bool success = false;
  10054. try
  10055. {
  10056. success = check60();
  10057. }
  10058. finally
  10059. {
  10060. Ext.StopCapture();
  10061. }
  10062. return success ? 0 : 1;
  10063. }
  10064. static bool check60() {
  10065. foreach (sbyte[] val in new sbyte[][] { null, new sbyte[0], new sbyte[] { 0, 1, -1, sbyte.MinValue, sbyte.MaxValue }, new sbyte[100] }) {
  10066. if (!check60(val)) {
  10067. return false;
  10068. }
  10069. }
  10070. return true;
  10071. }
  10072. static bool check60(sbyte[] val) {
  10073. Expression<Func<sbyte[]>> e =
  10074. Expression.Lambda<Func<sbyte[]>>(
  10075. Expression.Constant(val, typeof(sbyte[])),
  10076. new System.Collections.Generic.List<ParameterExpression>());
  10077. Func<sbyte[]> f = e.Compile();
  10078. return object.Equals(f(), val);
  10079. }
  10080. }
  10081. public static class Ext {
  10082. public static void StartCapture() {
  10083. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10084. // m.Invoke(null, new object[] { "test.dll" });
  10085. }
  10086. public static void StopCapture() {
  10087. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10088. // m.Invoke(null, new object[0]);
  10089. }
  10090. public static bool IsIntegralOrEnum(Type type) {
  10091. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10092. case TypeCode.Byte:
  10093. case TypeCode.SByte:
  10094. case TypeCode.Int16:
  10095. case TypeCode.Int32:
  10096. case TypeCode.Int64:
  10097. case TypeCode.UInt16:
  10098. case TypeCode.UInt32:
  10099. case TypeCode.UInt64:
  10100. return true;
  10101. default:
  10102. return false;
  10103. }
  10104. }
  10105. public static bool IsFloating(Type type) {
  10106. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10107. case TypeCode.Single:
  10108. case TypeCode.Double:
  10109. return true;
  10110. default:
  10111. return false;
  10112. }
  10113. }
  10114. public static Type GetNonNullableType(Type type) {
  10115. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10116. type.GetGenericArguments()[0] :
  10117. type;
  10118. }
  10119. }
  10120. }
  10121. //-------- Scenario 1777
  10122. namespace Scenario1777{
  10123. public class Test
  10124. {
  10125. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check61__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10126. public static Expression check61__() {
  10127. if(Main() != 0 ) {
  10128. throw new Exception();
  10129. } else {
  10130. return Expression.Constant(0);
  10131. }
  10132. }
  10133. public static int Main()
  10134. {
  10135. Ext.StartCapture();
  10136. bool success = false;
  10137. try
  10138. {
  10139. success = check61();
  10140. }
  10141. finally
  10142. {
  10143. Ext.StopCapture();
  10144. }
  10145. return success ? 0 : 1;
  10146. }
  10147. static bool check61() {
  10148. foreach (short[] val in new short[][] { null, new short[0], new short[] { 0, 1, -1, short.MinValue, short.MaxValue }, new short[100] }) {
  10149. if (!check61(val)) {
  10150. return false;
  10151. }
  10152. }
  10153. return true;
  10154. }
  10155. static bool check61(short[] val) {
  10156. Expression<Func<short[]>> e =
  10157. Expression.Lambda<Func<short[]>>(
  10158. Expression.Constant(val, typeof(short[])),
  10159. new System.Collections.Generic.List<ParameterExpression>());
  10160. Func<short[]> f = e.Compile();
  10161. return object.Equals(f(), val);
  10162. }
  10163. }
  10164. public static class Ext {
  10165. public static void StartCapture() {
  10166. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10167. // m.Invoke(null, new object[] { "test.dll" });
  10168. }
  10169. public static void StopCapture() {
  10170. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10171. // m.Invoke(null, new object[0]);
  10172. }
  10173. public static bool IsIntegralOrEnum(Type type) {
  10174. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10175. case TypeCode.Byte:
  10176. case TypeCode.SByte:
  10177. case TypeCode.Int16:
  10178. case TypeCode.Int32:
  10179. case TypeCode.Int64:
  10180. case TypeCode.UInt16:
  10181. case TypeCode.UInt32:
  10182. case TypeCode.UInt64:
  10183. return true;
  10184. default:
  10185. return false;
  10186. }
  10187. }
  10188. public static bool IsFloating(Type type) {
  10189. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10190. case TypeCode.Single:
  10191. case TypeCode.Double:
  10192. return true;
  10193. default:
  10194. return false;
  10195. }
  10196. }
  10197. public static Type GetNonNullableType(Type type) {
  10198. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10199. type.GetGenericArguments()[0] :
  10200. type;
  10201. }
  10202. }
  10203. }
  10204. //-------- Scenario 1778
  10205. namespace Scenario1778{
  10206. public class Test
  10207. {
  10208. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check62__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10209. public static Expression check62__() {
  10210. if(Main() != 0 ) {
  10211. throw new Exception();
  10212. } else {
  10213. return Expression.Constant(0);
  10214. }
  10215. }
  10216. public static int Main()
  10217. {
  10218. Ext.StartCapture();
  10219. bool success = false;
  10220. try
  10221. {
  10222. success = check62();
  10223. }
  10224. finally
  10225. {
  10226. Ext.StopCapture();
  10227. }
  10228. return success ? 0 : 1;
  10229. }
  10230. static bool check62() {
  10231. foreach (int[] val in new int[][] { null, new int[0], new int[] { 0, 1, -1, int.MinValue, int.MaxValue }, new int[100] }) {
  10232. if (!check62(val)) {
  10233. return false;
  10234. }
  10235. }
  10236. return true;
  10237. }
  10238. static bool check62(int[] val) {
  10239. Expression<Func<int[]>> e =
  10240. Expression.Lambda<Func<int[]>>(
  10241. Expression.Constant(val, typeof(int[])),
  10242. new System.Collections.Generic.List<ParameterExpression>());
  10243. Func<int[]> f = e.Compile();
  10244. return object.Equals(f(), val);
  10245. }
  10246. }
  10247. public static class Ext {
  10248. public static void StartCapture() {
  10249. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10250. // m.Invoke(null, new object[] { "test.dll" });
  10251. }
  10252. public static void StopCapture() {
  10253. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10254. // m.Invoke(null, new object[0]);
  10255. }
  10256. public static bool IsIntegralOrEnum(Type type) {
  10257. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10258. case TypeCode.Byte:
  10259. case TypeCode.SByte:
  10260. case TypeCode.Int16:
  10261. case TypeCode.Int32:
  10262. case TypeCode.Int64:
  10263. case TypeCode.UInt16:
  10264. case TypeCode.UInt32:
  10265. case TypeCode.UInt64:
  10266. return true;
  10267. default:
  10268. return false;
  10269. }
  10270. }
  10271. public static bool IsFloating(Type type) {
  10272. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10273. case TypeCode.Single:
  10274. case TypeCode.Double:
  10275. return true;
  10276. default:
  10277. return false;
  10278. }
  10279. }
  10280. public static Type GetNonNullableType(Type type) {
  10281. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10282. type.GetGenericArguments()[0] :
  10283. type;
  10284. }
  10285. }
  10286. }
  10287. //-------- Scenario 1779
  10288. namespace Scenario1779{
  10289. public class Test
  10290. {
  10291. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check63__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10292. public static Expression check63__() {
  10293. if(Main() != 0 ) {
  10294. throw new Exception();
  10295. } else {
  10296. return Expression.Constant(0);
  10297. }
  10298. }
  10299. public static int Main()
  10300. {
  10301. Ext.StartCapture();
  10302. bool success = false;
  10303. try
  10304. {
  10305. success = check63();
  10306. }
  10307. finally
  10308. {
  10309. Ext.StopCapture();
  10310. }
  10311. return success ? 0 : 1;
  10312. }
  10313. static bool check63() {
  10314. foreach (long[] val in new long[][] { null, new long[0], new long[] { 0, 1, -1, long.MinValue, long.MaxValue }, new long[100] }) {
  10315. if (!check63(val)) {
  10316. return false;
  10317. }
  10318. }
  10319. return true;
  10320. }
  10321. static bool check63(long[] val) {
  10322. Expression<Func<long[]>> e =
  10323. Expression.Lambda<Func<long[]>>(
  10324. Expression.Constant(val, typeof(long[])),
  10325. new System.Collections.Generic.List<ParameterExpression>());
  10326. Func<long[]> f = e.Compile();
  10327. return object.Equals(f(), val);
  10328. }
  10329. }
  10330. public static class Ext {
  10331. public static void StartCapture() {
  10332. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10333. // m.Invoke(null, new object[] { "test.dll" });
  10334. }
  10335. public static void StopCapture() {
  10336. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10337. // m.Invoke(null, new object[0]);
  10338. }
  10339. public static bool IsIntegralOrEnum(Type type) {
  10340. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10341. case TypeCode.Byte:
  10342. case TypeCode.SByte:
  10343. case TypeCode.Int16:
  10344. case TypeCode.Int32:
  10345. case TypeCode.Int64:
  10346. case TypeCode.UInt16:
  10347. case TypeCode.UInt32:
  10348. case TypeCode.UInt64:
  10349. return true;
  10350. default:
  10351. return false;
  10352. }
  10353. }
  10354. public static bool IsFloating(Type type) {
  10355. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10356. case TypeCode.Single:
  10357. case TypeCode.Double:
  10358. return true;
  10359. default:
  10360. return false;
  10361. }
  10362. }
  10363. public static Type GetNonNullableType(Type type) {
  10364. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10365. type.GetGenericArguments()[0] :
  10366. type;
  10367. }
  10368. }
  10369. }
  10370. //-------- Scenario 1780
  10371. namespace Scenario1780{
  10372. public class Test
  10373. {
  10374. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check64__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10375. public static Expression check64__() {
  10376. if(Main() != 0 ) {
  10377. throw new Exception();
  10378. } else {
  10379. return Expression.Constant(0);
  10380. }
  10381. }
  10382. public static int Main()
  10383. {
  10384. Ext.StartCapture();
  10385. bool success = false;
  10386. try
  10387. {
  10388. success = check64();
  10389. }
  10390. finally
  10391. {
  10392. Ext.StopCapture();
  10393. }
  10394. return success ? 0 : 1;
  10395. }
  10396. static bool check64() {
  10397. foreach (float[] val in new float[][] { null, new float[0], new float[] { 0, 1, -1, float.MinValue, float.MaxValue, float.Epsilon, float.NegativeInfinity, float.PositiveInfinity, float.NaN }, new float[100] }) {
  10398. if (!check64(val)) {
  10399. return false;
  10400. }
  10401. }
  10402. return true;
  10403. }
  10404. static bool check64(float[] val) {
  10405. Expression<Func<float[]>> e =
  10406. Expression.Lambda<Func<float[]>>(
  10407. Expression.Constant(val, typeof(float[])),
  10408. new System.Collections.Generic.List<ParameterExpression>());
  10409. Func<float[]> f = e.Compile();
  10410. return object.Equals(f(), val);
  10411. }
  10412. }
  10413. public static class Ext {
  10414. public static void StartCapture() {
  10415. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10416. // m.Invoke(null, new object[] { "test.dll" });
  10417. }
  10418. public static void StopCapture() {
  10419. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10420. // m.Invoke(null, new object[0]);
  10421. }
  10422. public static bool IsIntegralOrEnum(Type type) {
  10423. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10424. case TypeCode.Byte:
  10425. case TypeCode.SByte:
  10426. case TypeCode.Int16:
  10427. case TypeCode.Int32:
  10428. case TypeCode.Int64:
  10429. case TypeCode.UInt16:
  10430. case TypeCode.UInt32:
  10431. case TypeCode.UInt64:
  10432. return true;
  10433. default:
  10434. return false;
  10435. }
  10436. }
  10437. public static bool IsFloating(Type type) {
  10438. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10439. case TypeCode.Single:
  10440. case TypeCode.Double:
  10441. return true;
  10442. default:
  10443. return false;
  10444. }
  10445. }
  10446. public static Type GetNonNullableType(Type type) {
  10447. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10448. type.GetGenericArguments()[0] :
  10449. type;
  10450. }
  10451. }
  10452. }
  10453. //-------- Scenario 1781
  10454. namespace Scenario1781{
  10455. public class Test
  10456. {
  10457. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check65__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10458. public static Expression check65__() {
  10459. if(Main() != 0 ) {
  10460. throw new Exception();
  10461. } else {
  10462. return Expression.Constant(0);
  10463. }
  10464. }
  10465. public static int Main()
  10466. {
  10467. Ext.StartCapture();
  10468. bool success = false;
  10469. try
  10470. {
  10471. success = check65();
  10472. }
  10473. finally
  10474. {
  10475. Ext.StopCapture();
  10476. }
  10477. return success ? 0 : 1;
  10478. }
  10479. static bool check65() {
  10480. foreach (double[] val in new double[][] { null, new double[0], new double[] { 0, 1, -1, double.MinValue, double.MaxValue, double.Epsilon, double.NegativeInfinity, double.PositiveInfinity, double.NaN }, new double[100] }) {
  10481. if (!check65(val)) {
  10482. return false;
  10483. }
  10484. }
  10485. return true;
  10486. }
  10487. static bool check65(double[] val) {
  10488. Expression<Func<double[]>> e =
  10489. Expression.Lambda<Func<double[]>>(
  10490. Expression.Constant(val, typeof(double[])),
  10491. new System.Collections.Generic.List<ParameterExpression>());
  10492. Func<double[]> f = e.Compile();
  10493. return object.Equals(f(), val);
  10494. }
  10495. }
  10496. public static class Ext {
  10497. public static void StartCapture() {
  10498. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10499. // m.Invoke(null, new object[] { "test.dll" });
  10500. }
  10501. public static void StopCapture() {
  10502. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10503. // m.Invoke(null, new object[0]);
  10504. }
  10505. public static bool IsIntegralOrEnum(Type type) {
  10506. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10507. case TypeCode.Byte:
  10508. case TypeCode.SByte:
  10509. case TypeCode.Int16:
  10510. case TypeCode.Int32:
  10511. case TypeCode.Int64:
  10512. case TypeCode.UInt16:
  10513. case TypeCode.UInt32:
  10514. case TypeCode.UInt64:
  10515. return true;
  10516. default:
  10517. return false;
  10518. }
  10519. }
  10520. public static bool IsFloating(Type type) {
  10521. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10522. case TypeCode.Single:
  10523. case TypeCode.Double:
  10524. return true;
  10525. default:
  10526. return false;
  10527. }
  10528. }
  10529. public static Type GetNonNullableType(Type type) {
  10530. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10531. type.GetGenericArguments()[0] :
  10532. type;
  10533. }
  10534. }
  10535. }
  10536. //-------- Scenario 1782
  10537. namespace Scenario1782{
  10538. public class Test
  10539. {
  10540. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check66__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10541. public static Expression check66__() {
  10542. if(Main() != 0 ) {
  10543. throw new Exception();
  10544. } else {
  10545. return Expression.Constant(0);
  10546. }
  10547. }
  10548. public static int Main()
  10549. {
  10550. Ext.StartCapture();
  10551. bool success = false;
  10552. try
  10553. {
  10554. success = check66();
  10555. }
  10556. finally
  10557. {
  10558. Ext.StopCapture();
  10559. }
  10560. return success ? 0 : 1;
  10561. }
  10562. static bool check66() {
  10563. foreach (decimal[] val in new decimal[][] { null, new decimal[0], new decimal[] { decimal.Zero, decimal.One, decimal.MinusOne, decimal.MinValue, decimal.MaxValue }, new decimal[100] }) {
  10564. if (!check66(val)) {
  10565. return false;
  10566. }
  10567. }
  10568. return true;
  10569. }
  10570. static bool check66(decimal[] val) {
  10571. Expression<Func<decimal[]>> e =
  10572. Expression.Lambda<Func<decimal[]>>(
  10573. Expression.Constant(val, typeof(decimal[])),
  10574. new System.Collections.Generic.List<ParameterExpression>());
  10575. Func<decimal[]> f = e.Compile();
  10576. return object.Equals(f(), val);
  10577. }
  10578. }
  10579. public static class Ext {
  10580. public static void StartCapture() {
  10581. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10582. // m.Invoke(null, new object[] { "test.dll" });
  10583. }
  10584. public static void StopCapture() {
  10585. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10586. // m.Invoke(null, new object[0]);
  10587. }
  10588. public static bool IsIntegralOrEnum(Type type) {
  10589. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10590. case TypeCode.Byte:
  10591. case TypeCode.SByte:
  10592. case TypeCode.Int16:
  10593. case TypeCode.Int32:
  10594. case TypeCode.Int64:
  10595. case TypeCode.UInt16:
  10596. case TypeCode.UInt32:
  10597. case TypeCode.UInt64:
  10598. return true;
  10599. default:
  10600. return false;
  10601. }
  10602. }
  10603. public static bool IsFloating(Type type) {
  10604. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10605. case TypeCode.Single:
  10606. case TypeCode.Double:
  10607. return true;
  10608. default:
  10609. return false;
  10610. }
  10611. }
  10612. public static Type GetNonNullableType(Type type) {
  10613. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10614. type.GetGenericArguments()[0] :
  10615. type;
  10616. }
  10617. }
  10618. }
  10619. //-------- Scenario 1783
  10620. namespace Scenario1783{
  10621. public class Test
  10622. {
  10623. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check67__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10624. public static Expression check67__() {
  10625. if(Main() != 0 ) {
  10626. throw new Exception();
  10627. } else {
  10628. return Expression.Constant(0);
  10629. }
  10630. }
  10631. public static int Main()
  10632. {
  10633. Ext.StartCapture();
  10634. bool success = false;
  10635. try
  10636. {
  10637. success = check67();
  10638. }
  10639. finally
  10640. {
  10641. Ext.StopCapture();
  10642. }
  10643. return success ? 0 : 1;
  10644. }
  10645. static bool check67() {
  10646. foreach (char[] val in new char[][] { null, new char[0], new char[] { '\0', '\b', 'A', '\uffff' }, new char[100] }) {
  10647. if (!check67(val)) {
  10648. return false;
  10649. }
  10650. }
  10651. return true;
  10652. }
  10653. static bool check67(char[] val) {
  10654. Expression<Func<char[]>> e =
  10655. Expression.Lambda<Func<char[]>>(
  10656. Expression.Constant(val, typeof(char[])),
  10657. new System.Collections.Generic.List<ParameterExpression>());
  10658. Func<char[]> f = e.Compile();
  10659. return object.Equals(f(), val);
  10660. }
  10661. }
  10662. public static class Ext {
  10663. public static void StartCapture() {
  10664. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10665. // m.Invoke(null, new object[] { "test.dll" });
  10666. }
  10667. public static void StopCapture() {
  10668. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10669. // m.Invoke(null, new object[0]);
  10670. }
  10671. public static bool IsIntegralOrEnum(Type type) {
  10672. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10673. case TypeCode.Byte:
  10674. case TypeCode.SByte:
  10675. case TypeCode.Int16:
  10676. case TypeCode.Int32:
  10677. case TypeCode.Int64:
  10678. case TypeCode.UInt16:
  10679. case TypeCode.UInt32:
  10680. case TypeCode.UInt64:
  10681. return true;
  10682. default:
  10683. return false;
  10684. }
  10685. }
  10686. public static bool IsFloating(Type type) {
  10687. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10688. case TypeCode.Single:
  10689. case TypeCode.Double:
  10690. return true;
  10691. default:
  10692. return false;
  10693. }
  10694. }
  10695. public static Type GetNonNullableType(Type type) {
  10696. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10697. type.GetGenericArguments()[0] :
  10698. type;
  10699. }
  10700. }
  10701. }
  10702. //-------- Scenario 1784
  10703. namespace Scenario1784{
  10704. public class Test
  10705. {
  10706. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check68__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10707. public static Expression check68__() {
  10708. if(Main() != 0 ) {
  10709. throw new Exception();
  10710. } else {
  10711. return Expression.Constant(0);
  10712. }
  10713. }
  10714. public static int Main()
  10715. {
  10716. Ext.StartCapture();
  10717. bool success = false;
  10718. try
  10719. {
  10720. success = check68();
  10721. }
  10722. finally
  10723. {
  10724. Ext.StopCapture();
  10725. }
  10726. return success ? 0 : 1;
  10727. }
  10728. static bool check68() {
  10729. foreach (bool[] val in new bool[][] { null, new bool[0], new bool[] { true, false }, new bool[100] }) {
  10730. if (!check68(val)) {
  10731. return false;
  10732. }
  10733. }
  10734. return true;
  10735. }
  10736. static bool check68(bool[] val) {
  10737. Expression<Func<bool[]>> e =
  10738. Expression.Lambda<Func<bool[]>>(
  10739. Expression.Constant(val, typeof(bool[])),
  10740. new System.Collections.Generic.List<ParameterExpression>());
  10741. Func<bool[]> f = e.Compile();
  10742. return object.Equals(f(), val);
  10743. }
  10744. }
  10745. public static class Ext {
  10746. public static void StartCapture() {
  10747. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10748. // m.Invoke(null, new object[] { "test.dll" });
  10749. }
  10750. public static void StopCapture() {
  10751. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10752. // m.Invoke(null, new object[0]);
  10753. }
  10754. public static bool IsIntegralOrEnum(Type type) {
  10755. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10756. case TypeCode.Byte:
  10757. case TypeCode.SByte:
  10758. case TypeCode.Int16:
  10759. case TypeCode.Int32:
  10760. case TypeCode.Int64:
  10761. case TypeCode.UInt16:
  10762. case TypeCode.UInt32:
  10763. case TypeCode.UInt64:
  10764. return true;
  10765. default:
  10766. return false;
  10767. }
  10768. }
  10769. public static bool IsFloating(Type type) {
  10770. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10771. case TypeCode.Single:
  10772. case TypeCode.Double:
  10773. return true;
  10774. default:
  10775. return false;
  10776. }
  10777. }
  10778. public static Type GetNonNullableType(Type type) {
  10779. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10780. type.GetGenericArguments()[0] :
  10781. type;
  10782. }
  10783. }
  10784. }
  10785. //-------- Scenario 1785
  10786. namespace Scenario1785{
  10787. public class Test
  10788. {
  10789. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check69__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10790. public static Expression check69__() {
  10791. if(Main() != 0 ) {
  10792. throw new Exception();
  10793. } else {
  10794. return Expression.Constant(0);
  10795. }
  10796. }
  10797. public static int Main()
  10798. {
  10799. Ext.StartCapture();
  10800. bool success = false;
  10801. try
  10802. {
  10803. success = check69();
  10804. }
  10805. finally
  10806. {
  10807. Ext.StopCapture();
  10808. }
  10809. return success ? 0 : 1;
  10810. }
  10811. static bool check69() {
  10812. foreach (S[] val in new S[][] { null, new S[0], new S[] { default(S), new S() }, new S[100] }) {
  10813. if (!check69(val)) {
  10814. return false;
  10815. }
  10816. }
  10817. return true;
  10818. }
  10819. static bool check69(S[] val) {
  10820. Expression<Func<S[]>> e =
  10821. Expression.Lambda<Func<S[]>>(
  10822. Expression.Constant(val, typeof(S[])),
  10823. new System.Collections.Generic.List<ParameterExpression>());
  10824. Func<S[]> f = e.Compile();
  10825. return object.Equals(f(), val);
  10826. }
  10827. }
  10828. public static class Ext {
  10829. public static void StartCapture() {
  10830. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10831. // m.Invoke(null, new object[] { "test.dll" });
  10832. }
  10833. public static void StopCapture() {
  10834. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  10835. // m.Invoke(null, new object[0]);
  10836. }
  10837. public static bool IsIntegralOrEnum(Type type) {
  10838. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10839. case TypeCode.Byte:
  10840. case TypeCode.SByte:
  10841. case TypeCode.Int16:
  10842. case TypeCode.Int32:
  10843. case TypeCode.Int64:
  10844. case TypeCode.UInt16:
  10845. case TypeCode.UInt32:
  10846. case TypeCode.UInt64:
  10847. return true;
  10848. default:
  10849. return false;
  10850. }
  10851. }
  10852. public static bool IsFloating(Type type) {
  10853. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  10854. case TypeCode.Single:
  10855. case TypeCode.Double:
  10856. return true;
  10857. default:
  10858. return false;
  10859. }
  10860. }
  10861. public static Type GetNonNullableType(Type type) {
  10862. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  10863. type.GetGenericArguments()[0] :
  10864. type;
  10865. }
  10866. }
  10867. public interface I {
  10868. void M();
  10869. }
  10870. public class C : IEquatable<C>, I {
  10871. void I.M() {
  10872. }
  10873. public override bool Equals(object o) {
  10874. return o is C && Equals((C) o);
  10875. }
  10876. public bool Equals(C c) {
  10877. return c != null;
  10878. }
  10879. public override int GetHashCode() {
  10880. return 0;
  10881. }
  10882. }
  10883. public class D : C, IEquatable<D> {
  10884. public int Val;
  10885. public D() {
  10886. }
  10887. public D(int val) {
  10888. Val = val;
  10889. }
  10890. public override bool Equals(object o) {
  10891. return o is D && Equals((D) o);
  10892. }
  10893. public bool Equals(D d) {
  10894. return d != null && d.Val == Val;
  10895. }
  10896. public override int GetHashCode() {
  10897. return Val;
  10898. }
  10899. }
  10900. public enum E {
  10901. A=1, B=2
  10902. }
  10903. public enum El : long {
  10904. A, B, C
  10905. }
  10906. public struct S : IEquatable<S> {
  10907. public override bool Equals(object o) {
  10908. return (o is S) && Equals((S) o);
  10909. }
  10910. public bool Equals(S other) {
  10911. return true;
  10912. }
  10913. public override int GetHashCode() {
  10914. return 0;
  10915. }
  10916. }
  10917. public struct Sp : IEquatable<Sp> {
  10918. public Sp(int i, double d) {
  10919. I = i;
  10920. D = d;
  10921. }
  10922. public int I;
  10923. public double D;
  10924. public override bool Equals(object o) {
  10925. return (o is Sp) && Equals((Sp) o);
  10926. }
  10927. public bool Equals(Sp other) {
  10928. return other.I == I && other.D == D;
  10929. }
  10930. public override int GetHashCode() {
  10931. return I.GetHashCode() ^ D.GetHashCode();
  10932. }
  10933. }
  10934. public struct Ss : IEquatable<Ss> {
  10935. public Ss(S s) {
  10936. Val = s;
  10937. }
  10938. public S Val;
  10939. public override bool Equals(object o) {
  10940. return (o is Ss) && Equals((Ss) o);
  10941. }
  10942. public bool Equals(Ss other) {
  10943. return other.Val.Equals(Val);
  10944. }
  10945. public override int GetHashCode() {
  10946. return Val.GetHashCode();
  10947. }
  10948. }
  10949. public struct Sc : IEquatable<Sc> {
  10950. public Sc(string s) {
  10951. S = s;
  10952. }
  10953. public string S;
  10954. public override bool Equals(object o) {
  10955. return (o is Sc) && Equals((Sc) o);
  10956. }
  10957. public bool Equals(Sc other) {
  10958. return other.S == S;
  10959. }
  10960. public override int GetHashCode() {
  10961. return S.GetHashCode();
  10962. }
  10963. }
  10964. public struct Scs : IEquatable<Scs> {
  10965. public Scs(string s, S val) {
  10966. S = s;
  10967. Val = val;
  10968. }
  10969. public string S;
  10970. public S Val;
  10971. public override bool Equals(object o) {
  10972. return (o is Scs) && Equals((Scs) o);
  10973. }
  10974. public bool Equals(Scs other) {
  10975. return other.S == S && other.Val.Equals(Val);
  10976. }
  10977. public override int GetHashCode() {
  10978. return S.GetHashCode() ^ Val.GetHashCode();
  10979. }
  10980. }
  10981. }
  10982. //-------- Scenario 1786
  10983. namespace Scenario1786{
  10984. public class Test
  10985. {
  10986. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check70__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  10987. public static Expression check70__() {
  10988. if(Main() != 0 ) {
  10989. throw new Exception();
  10990. } else {
  10991. return Expression.Constant(0);
  10992. }
  10993. }
  10994. public static int Main()
  10995. {
  10996. Ext.StartCapture();
  10997. bool success = false;
  10998. try
  10999. {
  11000. success = check70();
  11001. }
  11002. finally
  11003. {
  11004. Ext.StopCapture();
  11005. }
  11006. return success ? 0 : 1;
  11007. }
  11008. static bool check70() {
  11009. foreach (Sp[] val in new Sp[][] { null, new Sp[0], new Sp[] { default(Sp), new Sp(), new Sp(5,5.0) }, new Sp[100] }) {
  11010. if (!check70(val)) {
  11011. return false;
  11012. }
  11013. }
  11014. return true;
  11015. }
  11016. static bool check70(Sp[] val) {
  11017. Expression<Func<Sp[]>> e =
  11018. Expression.Lambda<Func<Sp[]>>(
  11019. Expression.Constant(val, typeof(Sp[])),
  11020. new System.Collections.Generic.List<ParameterExpression>());
  11021. Func<Sp[]> f = e.Compile();
  11022. return object.Equals(f(), val);
  11023. }
  11024. }
  11025. public static class Ext {
  11026. public static void StartCapture() {
  11027. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11028. // m.Invoke(null, new object[] { "test.dll" });
  11029. }
  11030. public static void StopCapture() {
  11031. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11032. // m.Invoke(null, new object[0]);
  11033. }
  11034. public static bool IsIntegralOrEnum(Type type) {
  11035. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11036. case TypeCode.Byte:
  11037. case TypeCode.SByte:
  11038. case TypeCode.Int16:
  11039. case TypeCode.Int32:
  11040. case TypeCode.Int64:
  11041. case TypeCode.UInt16:
  11042. case TypeCode.UInt32:
  11043. case TypeCode.UInt64:
  11044. return true;
  11045. default:
  11046. return false;
  11047. }
  11048. }
  11049. public static bool IsFloating(Type type) {
  11050. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11051. case TypeCode.Single:
  11052. case TypeCode.Double:
  11053. return true;
  11054. default:
  11055. return false;
  11056. }
  11057. }
  11058. public static Type GetNonNullableType(Type type) {
  11059. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  11060. type.GetGenericArguments()[0] :
  11061. type;
  11062. }
  11063. }
  11064. public interface I {
  11065. void M();
  11066. }
  11067. public class C : IEquatable<C>, I {
  11068. void I.M() {
  11069. }
  11070. public override bool Equals(object o) {
  11071. return o is C && Equals((C) o);
  11072. }
  11073. public bool Equals(C c) {
  11074. return c != null;
  11075. }
  11076. public override int GetHashCode() {
  11077. return 0;
  11078. }
  11079. }
  11080. public class D : C, IEquatable<D> {
  11081. public int Val;
  11082. public D() {
  11083. }
  11084. public D(int val) {
  11085. Val = val;
  11086. }
  11087. public override bool Equals(object o) {
  11088. return o is D && Equals((D) o);
  11089. }
  11090. public bool Equals(D d) {
  11091. return d != null && d.Val == Val;
  11092. }
  11093. public override int GetHashCode() {
  11094. return Val;
  11095. }
  11096. }
  11097. public enum E {
  11098. A=1, B=2
  11099. }
  11100. public enum El : long {
  11101. A, B, C
  11102. }
  11103. public struct S : IEquatable<S> {
  11104. public override bool Equals(object o) {
  11105. return (o is S) && Equals((S) o);
  11106. }
  11107. public bool Equals(S other) {
  11108. return true;
  11109. }
  11110. public override int GetHashCode() {
  11111. return 0;
  11112. }
  11113. }
  11114. public struct Sp : IEquatable<Sp> {
  11115. public Sp(int i, double d) {
  11116. I = i;
  11117. D = d;
  11118. }
  11119. public int I;
  11120. public double D;
  11121. public override bool Equals(object o) {
  11122. return (o is Sp) && Equals((Sp) o);
  11123. }
  11124. public bool Equals(Sp other) {
  11125. return other.I == I && other.D == D;
  11126. }
  11127. public override int GetHashCode() {
  11128. return I.GetHashCode() ^ D.GetHashCode();
  11129. }
  11130. }
  11131. public struct Ss : IEquatable<Ss> {
  11132. public Ss(S s) {
  11133. Val = s;
  11134. }
  11135. public S Val;
  11136. public override bool Equals(object o) {
  11137. return (o is Ss) && Equals((Ss) o);
  11138. }
  11139. public bool Equals(Ss other) {
  11140. return other.Val.Equals(Val);
  11141. }
  11142. public override int GetHashCode() {
  11143. return Val.GetHashCode();
  11144. }
  11145. }
  11146. public struct Sc : IEquatable<Sc> {
  11147. public Sc(string s) {
  11148. S = s;
  11149. }
  11150. public string S;
  11151. public override bool Equals(object o) {
  11152. return (o is Sc) && Equals((Sc) o);
  11153. }
  11154. public bool Equals(Sc other) {
  11155. return other.S == S;
  11156. }
  11157. public override int GetHashCode() {
  11158. return S.GetHashCode();
  11159. }
  11160. }
  11161. public struct Scs : IEquatable<Scs> {
  11162. public Scs(string s, S val) {
  11163. S = s;
  11164. Val = val;
  11165. }
  11166. public string S;
  11167. public S Val;
  11168. public override bool Equals(object o) {
  11169. return (o is Scs) && Equals((Scs) o);
  11170. }
  11171. public bool Equals(Scs other) {
  11172. return other.S == S && other.Val.Equals(Val);
  11173. }
  11174. public override int GetHashCode() {
  11175. return S.GetHashCode() ^ Val.GetHashCode();
  11176. }
  11177. }
  11178. }
  11179. //-------- Scenario 1787
  11180. namespace Scenario1787{
  11181. public class Test
  11182. {
  11183. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check71__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  11184. public static Expression check71__() {
  11185. if(Main() != 0 ) {
  11186. throw new Exception();
  11187. } else {
  11188. return Expression.Constant(0);
  11189. }
  11190. }
  11191. public static int Main()
  11192. {
  11193. Ext.StartCapture();
  11194. bool success = false;
  11195. try
  11196. {
  11197. success = check71();
  11198. }
  11199. finally
  11200. {
  11201. Ext.StopCapture();
  11202. }
  11203. return success ? 0 : 1;
  11204. }
  11205. static bool check71() {
  11206. foreach (Ss[] val in new Ss[][] { null, new Ss[0], new Ss[] { default(Ss), new Ss(), new Ss(new S()) }, new Ss[100] }) {
  11207. if (!check71(val)) {
  11208. return false;
  11209. }
  11210. }
  11211. return true;
  11212. }
  11213. static bool check71(Ss[] val) {
  11214. Expression<Func<Ss[]>> e =
  11215. Expression.Lambda<Func<Ss[]>>(
  11216. Expression.Constant(val, typeof(Ss[])),
  11217. new System.Collections.Generic.List<ParameterExpression>());
  11218. Func<Ss[]> f = e.Compile();
  11219. return object.Equals(f(), val);
  11220. }
  11221. }
  11222. public static class Ext {
  11223. public static void StartCapture() {
  11224. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11225. // m.Invoke(null, new object[] { "test.dll" });
  11226. }
  11227. public static void StopCapture() {
  11228. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11229. // m.Invoke(null, new object[0]);
  11230. }
  11231. public static bool IsIntegralOrEnum(Type type) {
  11232. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11233. case TypeCode.Byte:
  11234. case TypeCode.SByte:
  11235. case TypeCode.Int16:
  11236. case TypeCode.Int32:
  11237. case TypeCode.Int64:
  11238. case TypeCode.UInt16:
  11239. case TypeCode.UInt32:
  11240. case TypeCode.UInt64:
  11241. return true;
  11242. default:
  11243. return false;
  11244. }
  11245. }
  11246. public static bool IsFloating(Type type) {
  11247. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11248. case TypeCode.Single:
  11249. case TypeCode.Double:
  11250. return true;
  11251. default:
  11252. return false;
  11253. }
  11254. }
  11255. public static Type GetNonNullableType(Type type) {
  11256. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  11257. type.GetGenericArguments()[0] :
  11258. type;
  11259. }
  11260. }
  11261. public interface I {
  11262. void M();
  11263. }
  11264. public class C : IEquatable<C>, I {
  11265. void I.M() {
  11266. }
  11267. public override bool Equals(object o) {
  11268. return o is C && Equals((C) o);
  11269. }
  11270. public bool Equals(C c) {
  11271. return c != null;
  11272. }
  11273. public override int GetHashCode() {
  11274. return 0;
  11275. }
  11276. }
  11277. public class D : C, IEquatable<D> {
  11278. public int Val;
  11279. public D() {
  11280. }
  11281. public D(int val) {
  11282. Val = val;
  11283. }
  11284. public override bool Equals(object o) {
  11285. return o is D && Equals((D) o);
  11286. }
  11287. public bool Equals(D d) {
  11288. return d != null && d.Val == Val;
  11289. }
  11290. public override int GetHashCode() {
  11291. return Val;
  11292. }
  11293. }
  11294. public enum E {
  11295. A=1, B=2
  11296. }
  11297. public enum El : long {
  11298. A, B, C
  11299. }
  11300. public struct S : IEquatable<S> {
  11301. public override bool Equals(object o) {
  11302. return (o is S) && Equals((S) o);
  11303. }
  11304. public bool Equals(S other) {
  11305. return true;
  11306. }
  11307. public override int GetHashCode() {
  11308. return 0;
  11309. }
  11310. }
  11311. public struct Sp : IEquatable<Sp> {
  11312. public Sp(int i, double d) {
  11313. I = i;
  11314. D = d;
  11315. }
  11316. public int I;
  11317. public double D;
  11318. public override bool Equals(object o) {
  11319. return (o is Sp) && Equals((Sp) o);
  11320. }
  11321. public bool Equals(Sp other) {
  11322. return other.I == I && other.D == D;
  11323. }
  11324. public override int GetHashCode() {
  11325. return I.GetHashCode() ^ D.GetHashCode();
  11326. }
  11327. }
  11328. public struct Ss : IEquatable<Ss> {
  11329. public Ss(S s) {
  11330. Val = s;
  11331. }
  11332. public S Val;
  11333. public override bool Equals(object o) {
  11334. return (o is Ss) && Equals((Ss) o);
  11335. }
  11336. public bool Equals(Ss other) {
  11337. return other.Val.Equals(Val);
  11338. }
  11339. public override int GetHashCode() {
  11340. return Val.GetHashCode();
  11341. }
  11342. }
  11343. public struct Sc : IEquatable<Sc> {
  11344. public Sc(string s) {
  11345. S = s;
  11346. }
  11347. public string S;
  11348. public override bool Equals(object o) {
  11349. return (o is Sc) && Equals((Sc) o);
  11350. }
  11351. public bool Equals(Sc other) {
  11352. return other.S == S;
  11353. }
  11354. public override int GetHashCode() {
  11355. return S.GetHashCode();
  11356. }
  11357. }
  11358. public struct Scs : IEquatable<Scs> {
  11359. public Scs(string s, S val) {
  11360. S = s;
  11361. Val = val;
  11362. }
  11363. public string S;
  11364. public S Val;
  11365. public override bool Equals(object o) {
  11366. return (o is Scs) && Equals((Scs) o);
  11367. }
  11368. public bool Equals(Scs other) {
  11369. return other.S == S && other.Val.Equals(Val);
  11370. }
  11371. public override int GetHashCode() {
  11372. return S.GetHashCode() ^ Val.GetHashCode();
  11373. }
  11374. }
  11375. }
  11376. //-------- Scenario 1788
  11377. namespace Scenario1788{
  11378. public class Test
  11379. {
  11380. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check72__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  11381. public static Expression check72__() {
  11382. if(Main() != 0 ) {
  11383. throw new Exception();
  11384. } else {
  11385. return Expression.Constant(0);
  11386. }
  11387. }
  11388. public static int Main()
  11389. {
  11390. Ext.StartCapture();
  11391. bool success = false;
  11392. try
  11393. {
  11394. success = check72();
  11395. }
  11396. finally
  11397. {
  11398. Ext.StopCapture();
  11399. }
  11400. return success ? 0 : 1;
  11401. }
  11402. static bool check72() {
  11403. foreach (Sc[] val in new Sc[][] { null, new Sc[0], new Sc[] { default(Sc), new Sc(), new Sc(null) }, new Sc[100] }) {
  11404. if (!check72(val)) {
  11405. return false;
  11406. }
  11407. }
  11408. return true;
  11409. }
  11410. static bool check72(Sc[] val) {
  11411. Expression<Func<Sc[]>> e =
  11412. Expression.Lambda<Func<Sc[]>>(
  11413. Expression.Constant(val, typeof(Sc[])),
  11414. new System.Collections.Generic.List<ParameterExpression>());
  11415. Func<Sc[]> f = e.Compile();
  11416. return object.Equals(f(), val);
  11417. }
  11418. }
  11419. public static class Ext {
  11420. public static void StartCapture() {
  11421. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11422. // m.Invoke(null, new object[] { "test.dll" });
  11423. }
  11424. public static void StopCapture() {
  11425. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11426. // m.Invoke(null, new object[0]);
  11427. }
  11428. public static bool IsIntegralOrEnum(Type type) {
  11429. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11430. case TypeCode.Byte:
  11431. case TypeCode.SByte:
  11432. case TypeCode.Int16:
  11433. case TypeCode.Int32:
  11434. case TypeCode.Int64:
  11435. case TypeCode.UInt16:
  11436. case TypeCode.UInt32:
  11437. case TypeCode.UInt64:
  11438. return true;
  11439. default:
  11440. return false;
  11441. }
  11442. }
  11443. public static bool IsFloating(Type type) {
  11444. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11445. case TypeCode.Single:
  11446. case TypeCode.Double:
  11447. return true;
  11448. default:
  11449. return false;
  11450. }
  11451. }
  11452. public static Type GetNonNullableType(Type type) {
  11453. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  11454. type.GetGenericArguments()[0] :
  11455. type;
  11456. }
  11457. }
  11458. public interface I {
  11459. void M();
  11460. }
  11461. public class C : IEquatable<C>, I {
  11462. void I.M() {
  11463. }
  11464. public override bool Equals(object o) {
  11465. return o is C && Equals((C) o);
  11466. }
  11467. public bool Equals(C c) {
  11468. return c != null;
  11469. }
  11470. public override int GetHashCode() {
  11471. return 0;
  11472. }
  11473. }
  11474. public class D : C, IEquatable<D> {
  11475. public int Val;
  11476. public D() {
  11477. }
  11478. public D(int val) {
  11479. Val = val;
  11480. }
  11481. public override bool Equals(object o) {
  11482. return o is D && Equals((D) o);
  11483. }
  11484. public bool Equals(D d) {
  11485. return d != null && d.Val == Val;
  11486. }
  11487. public override int GetHashCode() {
  11488. return Val;
  11489. }
  11490. }
  11491. public enum E {
  11492. A=1, B=2
  11493. }
  11494. public enum El : long {
  11495. A, B, C
  11496. }
  11497. public struct S : IEquatable<S> {
  11498. public override bool Equals(object o) {
  11499. return (o is S) && Equals((S) o);
  11500. }
  11501. public bool Equals(S other) {
  11502. return true;
  11503. }
  11504. public override int GetHashCode() {
  11505. return 0;
  11506. }
  11507. }
  11508. public struct Sp : IEquatable<Sp> {
  11509. public Sp(int i, double d) {
  11510. I = i;
  11511. D = d;
  11512. }
  11513. public int I;
  11514. public double D;
  11515. public override bool Equals(object o) {
  11516. return (o is Sp) && Equals((Sp) o);
  11517. }
  11518. public bool Equals(Sp other) {
  11519. return other.I == I && other.D == D;
  11520. }
  11521. public override int GetHashCode() {
  11522. return I.GetHashCode() ^ D.GetHashCode();
  11523. }
  11524. }
  11525. public struct Ss : IEquatable<Ss> {
  11526. public Ss(S s) {
  11527. Val = s;
  11528. }
  11529. public S Val;
  11530. public override bool Equals(object o) {
  11531. return (o is Ss) && Equals((Ss) o);
  11532. }
  11533. public bool Equals(Ss other) {
  11534. return other.Val.Equals(Val);
  11535. }
  11536. public override int GetHashCode() {
  11537. return Val.GetHashCode();
  11538. }
  11539. }
  11540. public struct Sc : IEquatable<Sc> {
  11541. public Sc(string s) {
  11542. S = s;
  11543. }
  11544. public string S;
  11545. public override bool Equals(object o) {
  11546. return (o is Sc) && Equals((Sc) o);
  11547. }
  11548. public bool Equals(Sc other) {
  11549. return other.S == S;
  11550. }
  11551. public override int GetHashCode() {
  11552. return S.GetHashCode();
  11553. }
  11554. }
  11555. public struct Scs : IEquatable<Scs> {
  11556. public Scs(string s, S val) {
  11557. S = s;
  11558. Val = val;
  11559. }
  11560. public string S;
  11561. public S Val;
  11562. public override bool Equals(object o) {
  11563. return (o is Scs) && Equals((Scs) o);
  11564. }
  11565. public bool Equals(Scs other) {
  11566. return other.S == S && other.Val.Equals(Val);
  11567. }
  11568. public override int GetHashCode() {
  11569. return S.GetHashCode() ^ Val.GetHashCode();
  11570. }
  11571. }
  11572. }
  11573. //-------- Scenario 1789
  11574. namespace Scenario1789{
  11575. public class Test
  11576. {
  11577. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check73__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  11578. public static Expression check73__() {
  11579. if(Main() != 0 ) {
  11580. throw new Exception();
  11581. } else {
  11582. return Expression.Constant(0);
  11583. }
  11584. }
  11585. public static int Main()
  11586. {
  11587. Ext.StartCapture();
  11588. bool success = false;
  11589. try
  11590. {
  11591. success = check73();
  11592. }
  11593. finally
  11594. {
  11595. Ext.StopCapture();
  11596. }
  11597. return success ? 0 : 1;
  11598. }
  11599. static bool check73() {
  11600. foreach (Scs[] val in new Scs[][] { null, new Scs[0], new Scs[] { default(Scs), new Scs(), new Scs(null,new S()) }, new Scs[100] }) {
  11601. if (!check73(val)) {
  11602. return false;
  11603. }
  11604. }
  11605. return true;
  11606. }
  11607. static bool check73(Scs[] val) {
  11608. Expression<Func<Scs[]>> e =
  11609. Expression.Lambda<Func<Scs[]>>(
  11610. Expression.Constant(val, typeof(Scs[])),
  11611. new System.Collections.Generic.List<ParameterExpression>());
  11612. Func<Scs[]> f = e.Compile();
  11613. return object.Equals(f(), val);
  11614. }
  11615. }
  11616. public static class Ext {
  11617. public static void StartCapture() {
  11618. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11619. // m.Invoke(null, new object[] { "test.dll" });
  11620. }
  11621. public static void StopCapture() {
  11622. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11623. // m.Invoke(null, new object[0]);
  11624. }
  11625. public static bool IsIntegralOrEnum(Type type) {
  11626. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11627. case TypeCode.Byte:
  11628. case TypeCode.SByte:
  11629. case TypeCode.Int16:
  11630. case TypeCode.Int32:
  11631. case TypeCode.Int64:
  11632. case TypeCode.UInt16:
  11633. case TypeCode.UInt32:
  11634. case TypeCode.UInt64:
  11635. return true;
  11636. default:
  11637. return false;
  11638. }
  11639. }
  11640. public static bool IsFloating(Type type) {
  11641. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11642. case TypeCode.Single:
  11643. case TypeCode.Double:
  11644. return true;
  11645. default:
  11646. return false;
  11647. }
  11648. }
  11649. public static Type GetNonNullableType(Type type) {
  11650. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  11651. type.GetGenericArguments()[0] :
  11652. type;
  11653. }
  11654. }
  11655. public interface I {
  11656. void M();
  11657. }
  11658. public class C : IEquatable<C>, I {
  11659. void I.M() {
  11660. }
  11661. public override bool Equals(object o) {
  11662. return o is C && Equals((C) o);
  11663. }
  11664. public bool Equals(C c) {
  11665. return c != null;
  11666. }
  11667. public override int GetHashCode() {
  11668. return 0;
  11669. }
  11670. }
  11671. public class D : C, IEquatable<D> {
  11672. public int Val;
  11673. public D() {
  11674. }
  11675. public D(int val) {
  11676. Val = val;
  11677. }
  11678. public override bool Equals(object o) {
  11679. return o is D && Equals((D) o);
  11680. }
  11681. public bool Equals(D d) {
  11682. return d != null && d.Val == Val;
  11683. }
  11684. public override int GetHashCode() {
  11685. return Val;
  11686. }
  11687. }
  11688. public enum E {
  11689. A=1, B=2
  11690. }
  11691. public enum El : long {
  11692. A, B, C
  11693. }
  11694. public struct S : IEquatable<S> {
  11695. public override bool Equals(object o) {
  11696. return (o is S) && Equals((S) o);
  11697. }
  11698. public bool Equals(S other) {
  11699. return true;
  11700. }
  11701. public override int GetHashCode() {
  11702. return 0;
  11703. }
  11704. }
  11705. public struct Sp : IEquatable<Sp> {
  11706. public Sp(int i, double d) {
  11707. I = i;
  11708. D = d;
  11709. }
  11710. public int I;
  11711. public double D;
  11712. public override bool Equals(object o) {
  11713. return (o is Sp) && Equals((Sp) o);
  11714. }
  11715. public bool Equals(Sp other) {
  11716. return other.I == I && other.D == D;
  11717. }
  11718. public override int GetHashCode() {
  11719. return I.GetHashCode() ^ D.GetHashCode();
  11720. }
  11721. }
  11722. public struct Ss : IEquatable<Ss> {
  11723. public Ss(S s) {
  11724. Val = s;
  11725. }
  11726. public S Val;
  11727. public override bool Equals(object o) {
  11728. return (o is Ss) && Equals((Ss) o);
  11729. }
  11730. public bool Equals(Ss other) {
  11731. return other.Val.Equals(Val);
  11732. }
  11733. public override int GetHashCode() {
  11734. return Val.GetHashCode();
  11735. }
  11736. }
  11737. public struct Sc : IEquatable<Sc> {
  11738. public Sc(string s) {
  11739. S = s;
  11740. }
  11741. public string S;
  11742. public override bool Equals(object o) {
  11743. return (o is Sc) && Equals((Sc) o);
  11744. }
  11745. public bool Equals(Sc other) {
  11746. return other.S == S;
  11747. }
  11748. public override int GetHashCode() {
  11749. return S.GetHashCode();
  11750. }
  11751. }
  11752. public struct Scs : IEquatable<Scs> {
  11753. public Scs(string s, S val) {
  11754. S = s;
  11755. Val = val;
  11756. }
  11757. public string S;
  11758. public S Val;
  11759. public override bool Equals(object o) {
  11760. return (o is Scs) && Equals((Scs) o);
  11761. }
  11762. public bool Equals(Scs other) {
  11763. return other.S == S && other.Val.Equals(Val);
  11764. }
  11765. public override int GetHashCode() {
  11766. return S.GetHashCode() ^ Val.GetHashCode();
  11767. }
  11768. }
  11769. }
  11770. //-------- Scenario 1790
  11771. namespace Scenario1790{
  11772. public class Test
  11773. {
  11774. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check74_S___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  11775. public static Expression check74_S___() {
  11776. if(Main() != 0 ) {
  11777. throw new Exception();
  11778. } else {
  11779. return Expression.Constant(0);
  11780. }
  11781. }
  11782. public static int Main()
  11783. {
  11784. Ext.StartCapture();
  11785. bool success = false;
  11786. try
  11787. {
  11788. success = check74<S>();
  11789. }
  11790. finally
  11791. {
  11792. Ext.StopCapture();
  11793. }
  11794. return success ? 0 : 1;
  11795. }
  11796. static bool check74<Ts>() where Ts : struct {
  11797. foreach (Ts[] val in new Ts[][] { null, new Ts[0], new Ts[] { default(Ts), new Ts() }, new Ts[100] }) {
  11798. if (!check74<Ts>(val)) {
  11799. return false;
  11800. }
  11801. }
  11802. return true;
  11803. }
  11804. static bool check74<Ts>(Ts[] val) where Ts : struct {
  11805. Expression<Func<Ts[]>> e =
  11806. Expression.Lambda<Func<Ts[]>>(
  11807. Expression.Constant(val, typeof(Ts[])),
  11808. new System.Collections.Generic.List<ParameterExpression>());
  11809. Func<Ts[]> f = e.Compile();
  11810. return object.Equals(f(), val);
  11811. }
  11812. }
  11813. public static class Ext {
  11814. public static void StartCapture() {
  11815. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11816. // m.Invoke(null, new object[] { "test.dll" });
  11817. }
  11818. public static void StopCapture() {
  11819. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  11820. // m.Invoke(null, new object[0]);
  11821. }
  11822. public static bool IsIntegralOrEnum(Type type) {
  11823. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11824. case TypeCode.Byte:
  11825. case TypeCode.SByte:
  11826. case TypeCode.Int16:
  11827. case TypeCode.Int32:
  11828. case TypeCode.Int64:
  11829. case TypeCode.UInt16:
  11830. case TypeCode.UInt32:
  11831. case TypeCode.UInt64:
  11832. return true;
  11833. default:
  11834. return false;
  11835. }
  11836. }
  11837. public static bool IsFloating(Type type) {
  11838. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  11839. case TypeCode.Single:
  11840. case TypeCode.Double:
  11841. return true;
  11842. default:
  11843. return false;
  11844. }
  11845. }
  11846. public static Type GetNonNullableType(Type type) {
  11847. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  11848. type.GetGenericArguments()[0] :
  11849. type;
  11850. }
  11851. }
  11852. public interface I {
  11853. void M();
  11854. }
  11855. public class C : IEquatable<C>, I {
  11856. void I.M() {
  11857. }
  11858. public override bool Equals(object o) {
  11859. return o is C && Equals((C) o);
  11860. }
  11861. public bool Equals(C c) {
  11862. return c != null;
  11863. }
  11864. public override int GetHashCode() {
  11865. return 0;
  11866. }
  11867. }
  11868. public class D : C, IEquatable<D> {
  11869. public int Val;
  11870. public D() {
  11871. }
  11872. public D(int val) {
  11873. Val = val;
  11874. }
  11875. public override bool Equals(object o) {
  11876. return o is D && Equals((D) o);
  11877. }
  11878. public bool Equals(D d) {
  11879. return d != null && d.Val == Val;
  11880. }
  11881. public override int GetHashCode() {
  11882. return Val;
  11883. }
  11884. }
  11885. public enum E {
  11886. A=1, B=2
  11887. }
  11888. public enum El : long {
  11889. A, B, C
  11890. }
  11891. public struct S : IEquatable<S> {
  11892. public override bool Equals(object o) {
  11893. return (o is S) && Equals((S) o);
  11894. }
  11895. public bool Equals(S other) {
  11896. return true;
  11897. }
  11898. public override int GetHashCode() {
  11899. return 0;
  11900. }
  11901. }
  11902. public struct Sp : IEquatable<Sp> {
  11903. public Sp(int i, double d) {
  11904. I = i;
  11905. D = d;
  11906. }
  11907. public int I;
  11908. public double D;
  11909. public override bool Equals(object o) {
  11910. return (o is Sp) && Equals((Sp) o);
  11911. }
  11912. public bool Equals(Sp other) {
  11913. return other.I == I && other.D == D;
  11914. }
  11915. public override int GetHashCode() {
  11916. return I.GetHashCode() ^ D.GetHashCode();
  11917. }
  11918. }
  11919. public struct Ss : IEquatable<Ss> {
  11920. public Ss(S s) {
  11921. Val = s;
  11922. }
  11923. public S Val;
  11924. public override bool Equals(object o) {
  11925. return (o is Ss) && Equals((Ss) o);
  11926. }
  11927. public bool Equals(Ss other) {
  11928. return other.Val.Equals(Val);
  11929. }
  11930. public override int GetHashCode() {
  11931. return Val.GetHashCode();
  11932. }
  11933. }
  11934. public struct Sc : IEquatable<Sc> {
  11935. public Sc(string s) {
  11936. S = s;
  11937. }
  11938. public string S;
  11939. public override bool Equals(object o) {
  11940. return (o is Sc) && Equals((Sc) o);
  11941. }
  11942. public bool Equals(Sc other) {
  11943. return other.S == S;
  11944. }
  11945. public override int GetHashCode() {
  11946. return S.GetHashCode();
  11947. }
  11948. }
  11949. public struct Scs : IEquatable<Scs> {
  11950. public Scs(string s, S val) {
  11951. S = s;
  11952. Val = val;
  11953. }
  11954. public string S;
  11955. public S Val;
  11956. public override bool Equals(object o) {
  11957. return (o is Scs) && Equals((Scs) o);
  11958. }
  11959. public bool Equals(Scs other) {
  11960. return other.S == S && other.Val.Equals(Val);
  11961. }
  11962. public override int GetHashCode() {
  11963. return S.GetHashCode() ^ Val.GetHashCode();
  11964. }
  11965. }
  11966. }
  11967. //-------- Scenario 1791
  11968. namespace Scenario1791{
  11969. public class Test
  11970. {
  11971. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check74_Scs___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  11972. public static Expression check74_Scs___() {
  11973. if(Main() != 0 ) {
  11974. throw new Exception();
  11975. } else {
  11976. return Expression.Constant(0);
  11977. }
  11978. }
  11979. public static int Main()
  11980. {
  11981. Ext.StartCapture();
  11982. bool success = false;
  11983. try
  11984. {
  11985. success = check74<Scs>();
  11986. }
  11987. finally
  11988. {
  11989. Ext.StopCapture();
  11990. }
  11991. return success ? 0 : 1;
  11992. }
  11993. static bool check74<Ts>() where Ts : struct {
  11994. foreach (Ts[] val in new Ts[][] { null, new Ts[0], new Ts[] { default(Ts), new Ts() }, new Ts[100] }) {
  11995. if (!check74<Ts>(val)) {
  11996. return false;
  11997. }
  11998. }
  11999. return true;
  12000. }
  12001. static bool check74<Ts>(Ts[] val) where Ts : struct {
  12002. Expression<Func<Ts[]>> e =
  12003. Expression.Lambda<Func<Ts[]>>(
  12004. Expression.Constant(val, typeof(Ts[])),
  12005. new System.Collections.Generic.List<ParameterExpression>());
  12006. Func<Ts[]> f = e.Compile();
  12007. return object.Equals(f(), val);
  12008. }
  12009. }
  12010. public static class Ext {
  12011. public static void StartCapture() {
  12012. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12013. // m.Invoke(null, new object[] { "test.dll" });
  12014. }
  12015. public static void StopCapture() {
  12016. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12017. // m.Invoke(null, new object[0]);
  12018. }
  12019. public static bool IsIntegralOrEnum(Type type) {
  12020. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12021. case TypeCode.Byte:
  12022. case TypeCode.SByte:
  12023. case TypeCode.Int16:
  12024. case TypeCode.Int32:
  12025. case TypeCode.Int64:
  12026. case TypeCode.UInt16:
  12027. case TypeCode.UInt32:
  12028. case TypeCode.UInt64:
  12029. return true;
  12030. default:
  12031. return false;
  12032. }
  12033. }
  12034. public static bool IsFloating(Type type) {
  12035. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12036. case TypeCode.Single:
  12037. case TypeCode.Double:
  12038. return true;
  12039. default:
  12040. return false;
  12041. }
  12042. }
  12043. public static Type GetNonNullableType(Type type) {
  12044. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  12045. type.GetGenericArguments()[0] :
  12046. type;
  12047. }
  12048. }
  12049. public interface I {
  12050. void M();
  12051. }
  12052. public class C : IEquatable<C>, I {
  12053. void I.M() {
  12054. }
  12055. public override bool Equals(object o) {
  12056. return o is C && Equals((C) o);
  12057. }
  12058. public bool Equals(C c) {
  12059. return c != null;
  12060. }
  12061. public override int GetHashCode() {
  12062. return 0;
  12063. }
  12064. }
  12065. public class D : C, IEquatable<D> {
  12066. public int Val;
  12067. public D() {
  12068. }
  12069. public D(int val) {
  12070. Val = val;
  12071. }
  12072. public override bool Equals(object o) {
  12073. return o is D && Equals((D) o);
  12074. }
  12075. public bool Equals(D d) {
  12076. return d != null && d.Val == Val;
  12077. }
  12078. public override int GetHashCode() {
  12079. return Val;
  12080. }
  12081. }
  12082. public enum E {
  12083. A=1, B=2
  12084. }
  12085. public enum El : long {
  12086. A, B, C
  12087. }
  12088. public struct S : IEquatable<S> {
  12089. public override bool Equals(object o) {
  12090. return (o is S) && Equals((S) o);
  12091. }
  12092. public bool Equals(S other) {
  12093. return true;
  12094. }
  12095. public override int GetHashCode() {
  12096. return 0;
  12097. }
  12098. }
  12099. public struct Sp : IEquatable<Sp> {
  12100. public Sp(int i, double d) {
  12101. I = i;
  12102. D = d;
  12103. }
  12104. public int I;
  12105. public double D;
  12106. public override bool Equals(object o) {
  12107. return (o is Sp) && Equals((Sp) o);
  12108. }
  12109. public bool Equals(Sp other) {
  12110. return other.I == I && other.D == D;
  12111. }
  12112. public override int GetHashCode() {
  12113. return I.GetHashCode() ^ D.GetHashCode();
  12114. }
  12115. }
  12116. public struct Ss : IEquatable<Ss> {
  12117. public Ss(S s) {
  12118. Val = s;
  12119. }
  12120. public S Val;
  12121. public override bool Equals(object o) {
  12122. return (o is Ss) && Equals((Ss) o);
  12123. }
  12124. public bool Equals(Ss other) {
  12125. return other.Val.Equals(Val);
  12126. }
  12127. public override int GetHashCode() {
  12128. return Val.GetHashCode();
  12129. }
  12130. }
  12131. public struct Sc : IEquatable<Sc> {
  12132. public Sc(string s) {
  12133. S = s;
  12134. }
  12135. public string S;
  12136. public override bool Equals(object o) {
  12137. return (o is Sc) && Equals((Sc) o);
  12138. }
  12139. public bool Equals(Sc other) {
  12140. return other.S == S;
  12141. }
  12142. public override int GetHashCode() {
  12143. return S.GetHashCode();
  12144. }
  12145. }
  12146. public struct Scs : IEquatable<Scs> {
  12147. public Scs(string s, S val) {
  12148. S = s;
  12149. Val = val;
  12150. }
  12151. public string S;
  12152. public S Val;
  12153. public override bool Equals(object o) {
  12154. return (o is Scs) && Equals((Scs) o);
  12155. }
  12156. public bool Equals(Scs other) {
  12157. return other.S == S && other.Val.Equals(Val);
  12158. }
  12159. public override int GetHashCode() {
  12160. return S.GetHashCode() ^ Val.GetHashCode();
  12161. }
  12162. }
  12163. }
  12164. //-------- Scenario 1792
  12165. namespace Scenario1792{
  12166. public class Test
  12167. {
  12168. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check74_E___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  12169. public static Expression check74_E___() {
  12170. if(Main() != 0 ) {
  12171. throw new Exception();
  12172. } else {
  12173. return Expression.Constant(0);
  12174. }
  12175. }
  12176. public static int Main()
  12177. {
  12178. Ext.StartCapture();
  12179. bool success = false;
  12180. try
  12181. {
  12182. success = check74<E>();
  12183. }
  12184. finally
  12185. {
  12186. Ext.StopCapture();
  12187. }
  12188. return success ? 0 : 1;
  12189. }
  12190. static bool check74<Ts>() where Ts : struct {
  12191. foreach (Ts[] val in new Ts[][] { null, new Ts[0], new Ts[] { default(Ts), new Ts() }, new Ts[100] }) {
  12192. if (!check74<Ts>(val)) {
  12193. return false;
  12194. }
  12195. }
  12196. return true;
  12197. }
  12198. static bool check74<Ts>(Ts[] val) where Ts : struct {
  12199. Expression<Func<Ts[]>> e =
  12200. Expression.Lambda<Func<Ts[]>>(
  12201. Expression.Constant(val, typeof(Ts[])),
  12202. new System.Collections.Generic.List<ParameterExpression>());
  12203. Func<Ts[]> f = e.Compile();
  12204. return object.Equals(f(), val);
  12205. }
  12206. }
  12207. public static class Ext {
  12208. public static void StartCapture() {
  12209. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12210. // m.Invoke(null, new object[] { "test.dll" });
  12211. }
  12212. public static void StopCapture() {
  12213. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12214. // m.Invoke(null, new object[0]);
  12215. }
  12216. public static bool IsIntegralOrEnum(Type type) {
  12217. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12218. case TypeCode.Byte:
  12219. case TypeCode.SByte:
  12220. case TypeCode.Int16:
  12221. case TypeCode.Int32:
  12222. case TypeCode.Int64:
  12223. case TypeCode.UInt16:
  12224. case TypeCode.UInt32:
  12225. case TypeCode.UInt64:
  12226. return true;
  12227. default:
  12228. return false;
  12229. }
  12230. }
  12231. public static bool IsFloating(Type type) {
  12232. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12233. case TypeCode.Single:
  12234. case TypeCode.Double:
  12235. return true;
  12236. default:
  12237. return false;
  12238. }
  12239. }
  12240. public static Type GetNonNullableType(Type type) {
  12241. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  12242. type.GetGenericArguments()[0] :
  12243. type;
  12244. }
  12245. }
  12246. public interface I {
  12247. void M();
  12248. }
  12249. public class C : IEquatable<C>, I {
  12250. void I.M() {
  12251. }
  12252. public override bool Equals(object o) {
  12253. return o is C && Equals((C) o);
  12254. }
  12255. public bool Equals(C c) {
  12256. return c != null;
  12257. }
  12258. public override int GetHashCode() {
  12259. return 0;
  12260. }
  12261. }
  12262. public class D : C, IEquatable<D> {
  12263. public int Val;
  12264. public D() {
  12265. }
  12266. public D(int val) {
  12267. Val = val;
  12268. }
  12269. public override bool Equals(object o) {
  12270. return o is D && Equals((D) o);
  12271. }
  12272. public bool Equals(D d) {
  12273. return d != null && d.Val == Val;
  12274. }
  12275. public override int GetHashCode() {
  12276. return Val;
  12277. }
  12278. }
  12279. public enum E {
  12280. A=1, B=2
  12281. }
  12282. public enum El : long {
  12283. A, B, C
  12284. }
  12285. public struct S : IEquatable<S> {
  12286. public override bool Equals(object o) {
  12287. return (o is S) && Equals((S) o);
  12288. }
  12289. public bool Equals(S other) {
  12290. return true;
  12291. }
  12292. public override int GetHashCode() {
  12293. return 0;
  12294. }
  12295. }
  12296. public struct Sp : IEquatable<Sp> {
  12297. public Sp(int i, double d) {
  12298. I = i;
  12299. D = d;
  12300. }
  12301. public int I;
  12302. public double D;
  12303. public override bool Equals(object o) {
  12304. return (o is Sp) && Equals((Sp) o);
  12305. }
  12306. public bool Equals(Sp other) {
  12307. return other.I == I && other.D == D;
  12308. }
  12309. public override int GetHashCode() {
  12310. return I.GetHashCode() ^ D.GetHashCode();
  12311. }
  12312. }
  12313. public struct Ss : IEquatable<Ss> {
  12314. public Ss(S s) {
  12315. Val = s;
  12316. }
  12317. public S Val;
  12318. public override bool Equals(object o) {
  12319. return (o is Ss) && Equals((Ss) o);
  12320. }
  12321. public bool Equals(Ss other) {
  12322. return other.Val.Equals(Val);
  12323. }
  12324. public override int GetHashCode() {
  12325. return Val.GetHashCode();
  12326. }
  12327. }
  12328. public struct Sc : IEquatable<Sc> {
  12329. public Sc(string s) {
  12330. S = s;
  12331. }
  12332. public string S;
  12333. public override bool Equals(object o) {
  12334. return (o is Sc) && Equals((Sc) o);
  12335. }
  12336. public bool Equals(Sc other) {
  12337. return other.S == S;
  12338. }
  12339. public override int GetHashCode() {
  12340. return S.GetHashCode();
  12341. }
  12342. }
  12343. public struct Scs : IEquatable<Scs> {
  12344. public Scs(string s, S val) {
  12345. S = s;
  12346. Val = val;
  12347. }
  12348. public string S;
  12349. public S Val;
  12350. public override bool Equals(object o) {
  12351. return (o is Scs) && Equals((Scs) o);
  12352. }
  12353. public bool Equals(Scs other) {
  12354. return other.S == S && other.Val.Equals(Val);
  12355. }
  12356. public override int GetHashCode() {
  12357. return S.GetHashCode() ^ Val.GetHashCode();
  12358. }
  12359. }
  12360. }
  12361. //-------- Scenario 1793
  12362. namespace Scenario1793{
  12363. public class Test
  12364. {
  12365. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check75__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  12366. public static Expression check75__() {
  12367. if(Main() != 0 ) {
  12368. throw new Exception();
  12369. } else {
  12370. return Expression.Constant(0);
  12371. }
  12372. }
  12373. public static int Main()
  12374. {
  12375. Ext.StartCapture();
  12376. bool success = false;
  12377. try
  12378. {
  12379. success = check75();
  12380. }
  12381. finally
  12382. {
  12383. Ext.StopCapture();
  12384. }
  12385. return success ? 0 : 1;
  12386. }
  12387. static bool check75() {
  12388. foreach (E[] val in new E[][] { null, new E[0], new E[] { (E) 0, E.A, E.B, (E) int.MaxValue, (E) int.MinValue }, new E[100] }) {
  12389. if (!check75(val)) {
  12390. return false;
  12391. }
  12392. }
  12393. return true;
  12394. }
  12395. static bool check75(E[] val) {
  12396. Expression<Func<E[]>> e =
  12397. Expression.Lambda<Func<E[]>>(
  12398. Expression.Constant(val, typeof(E[])),
  12399. new System.Collections.Generic.List<ParameterExpression>());
  12400. Func<E[]> f = e.Compile();
  12401. return object.Equals(f(), val);
  12402. }
  12403. }
  12404. public static class Ext {
  12405. public static void StartCapture() {
  12406. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12407. // m.Invoke(null, new object[] { "test.dll" });
  12408. }
  12409. public static void StopCapture() {
  12410. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12411. // m.Invoke(null, new object[0]);
  12412. }
  12413. public static bool IsIntegralOrEnum(Type type) {
  12414. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12415. case TypeCode.Byte:
  12416. case TypeCode.SByte:
  12417. case TypeCode.Int16:
  12418. case TypeCode.Int32:
  12419. case TypeCode.Int64:
  12420. case TypeCode.UInt16:
  12421. case TypeCode.UInt32:
  12422. case TypeCode.UInt64:
  12423. return true;
  12424. default:
  12425. return false;
  12426. }
  12427. }
  12428. public static bool IsFloating(Type type) {
  12429. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12430. case TypeCode.Single:
  12431. case TypeCode.Double:
  12432. return true;
  12433. default:
  12434. return false;
  12435. }
  12436. }
  12437. public static Type GetNonNullableType(Type type) {
  12438. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  12439. type.GetGenericArguments()[0] :
  12440. type;
  12441. }
  12442. }
  12443. public interface I {
  12444. void M();
  12445. }
  12446. public class C : IEquatable<C>, I {
  12447. void I.M() {
  12448. }
  12449. public override bool Equals(object o) {
  12450. return o is C && Equals((C) o);
  12451. }
  12452. public bool Equals(C c) {
  12453. return c != null;
  12454. }
  12455. public override int GetHashCode() {
  12456. return 0;
  12457. }
  12458. }
  12459. public class D : C, IEquatable<D> {
  12460. public int Val;
  12461. public D() {
  12462. }
  12463. public D(int val) {
  12464. Val = val;
  12465. }
  12466. public override bool Equals(object o) {
  12467. return o is D && Equals((D) o);
  12468. }
  12469. public bool Equals(D d) {
  12470. return d != null && d.Val == Val;
  12471. }
  12472. public override int GetHashCode() {
  12473. return Val;
  12474. }
  12475. }
  12476. public enum E {
  12477. A=1, B=2
  12478. }
  12479. public enum El : long {
  12480. A, B, C
  12481. }
  12482. public struct S : IEquatable<S> {
  12483. public override bool Equals(object o) {
  12484. return (o is S) && Equals((S) o);
  12485. }
  12486. public bool Equals(S other) {
  12487. return true;
  12488. }
  12489. public override int GetHashCode() {
  12490. return 0;
  12491. }
  12492. }
  12493. public struct Sp : IEquatable<Sp> {
  12494. public Sp(int i, double d) {
  12495. I = i;
  12496. D = d;
  12497. }
  12498. public int I;
  12499. public double D;
  12500. public override bool Equals(object o) {
  12501. return (o is Sp) && Equals((Sp) o);
  12502. }
  12503. public bool Equals(Sp other) {
  12504. return other.I == I && other.D == D;
  12505. }
  12506. public override int GetHashCode() {
  12507. return I.GetHashCode() ^ D.GetHashCode();
  12508. }
  12509. }
  12510. public struct Ss : IEquatable<Ss> {
  12511. public Ss(S s) {
  12512. Val = s;
  12513. }
  12514. public S Val;
  12515. public override bool Equals(object o) {
  12516. return (o is Ss) && Equals((Ss) o);
  12517. }
  12518. public bool Equals(Ss other) {
  12519. return other.Val.Equals(Val);
  12520. }
  12521. public override int GetHashCode() {
  12522. return Val.GetHashCode();
  12523. }
  12524. }
  12525. public struct Sc : IEquatable<Sc> {
  12526. public Sc(string s) {
  12527. S = s;
  12528. }
  12529. public string S;
  12530. public override bool Equals(object o) {
  12531. return (o is Sc) && Equals((Sc) o);
  12532. }
  12533. public bool Equals(Sc other) {
  12534. return other.S == S;
  12535. }
  12536. public override int GetHashCode() {
  12537. return S.GetHashCode();
  12538. }
  12539. }
  12540. public struct Scs : IEquatable<Scs> {
  12541. public Scs(string s, S val) {
  12542. S = s;
  12543. Val = val;
  12544. }
  12545. public string S;
  12546. public S Val;
  12547. public override bool Equals(object o) {
  12548. return (o is Scs) && Equals((Scs) o);
  12549. }
  12550. public bool Equals(Scs other) {
  12551. return other.S == S && other.Val.Equals(Val);
  12552. }
  12553. public override int GetHashCode() {
  12554. return S.GetHashCode() ^ Val.GetHashCode();
  12555. }
  12556. }
  12557. }
  12558. //-------- Scenario 1794
  12559. namespace Scenario1794{
  12560. public class Test
  12561. {
  12562. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check76__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  12563. public static Expression check76__() {
  12564. if(Main() != 0 ) {
  12565. throw new Exception();
  12566. } else {
  12567. return Expression.Constant(0);
  12568. }
  12569. }
  12570. public static int Main()
  12571. {
  12572. Ext.StartCapture();
  12573. bool success = false;
  12574. try
  12575. {
  12576. success = check76();
  12577. }
  12578. finally
  12579. {
  12580. Ext.StopCapture();
  12581. }
  12582. return success ? 0 : 1;
  12583. }
  12584. static bool check76() {
  12585. foreach (El[] val in new El[][] { null, new El[0], new El[] { (El) 0, El.A, El.B, (El) long.MaxValue, (El) long.MinValue }, new El[100] }) {
  12586. if (!check76(val)) {
  12587. return false;
  12588. }
  12589. }
  12590. return true;
  12591. }
  12592. static bool check76(El[] val) {
  12593. Expression<Func<El[]>> e =
  12594. Expression.Lambda<Func<El[]>>(
  12595. Expression.Constant(val, typeof(El[])),
  12596. new System.Collections.Generic.List<ParameterExpression>());
  12597. Func<El[]> f = e.Compile();
  12598. return object.Equals(f(), val);
  12599. }
  12600. }
  12601. public static class Ext {
  12602. public static void StartCapture() {
  12603. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12604. // m.Invoke(null, new object[] { "test.dll" });
  12605. }
  12606. public static void StopCapture() {
  12607. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12608. // m.Invoke(null, new object[0]);
  12609. }
  12610. public static bool IsIntegralOrEnum(Type type) {
  12611. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12612. case TypeCode.Byte:
  12613. case TypeCode.SByte:
  12614. case TypeCode.Int16:
  12615. case TypeCode.Int32:
  12616. case TypeCode.Int64:
  12617. case TypeCode.UInt16:
  12618. case TypeCode.UInt32:
  12619. case TypeCode.UInt64:
  12620. return true;
  12621. default:
  12622. return false;
  12623. }
  12624. }
  12625. public static bool IsFloating(Type type) {
  12626. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12627. case TypeCode.Single:
  12628. case TypeCode.Double:
  12629. return true;
  12630. default:
  12631. return false;
  12632. }
  12633. }
  12634. public static Type GetNonNullableType(Type type) {
  12635. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  12636. type.GetGenericArguments()[0] :
  12637. type;
  12638. }
  12639. }
  12640. public interface I {
  12641. void M();
  12642. }
  12643. public class C : IEquatable<C>, I {
  12644. void I.M() {
  12645. }
  12646. public override bool Equals(object o) {
  12647. return o is C && Equals((C) o);
  12648. }
  12649. public bool Equals(C c) {
  12650. return c != null;
  12651. }
  12652. public override int GetHashCode() {
  12653. return 0;
  12654. }
  12655. }
  12656. public class D : C, IEquatable<D> {
  12657. public int Val;
  12658. public D() {
  12659. }
  12660. public D(int val) {
  12661. Val = val;
  12662. }
  12663. public override bool Equals(object o) {
  12664. return o is D && Equals((D) o);
  12665. }
  12666. public bool Equals(D d) {
  12667. return d != null && d.Val == Val;
  12668. }
  12669. public override int GetHashCode() {
  12670. return Val;
  12671. }
  12672. }
  12673. public enum E {
  12674. A=1, B=2
  12675. }
  12676. public enum El : long {
  12677. A, B, C
  12678. }
  12679. public struct S : IEquatable<S> {
  12680. public override bool Equals(object o) {
  12681. return (o is S) && Equals((S) o);
  12682. }
  12683. public bool Equals(S other) {
  12684. return true;
  12685. }
  12686. public override int GetHashCode() {
  12687. return 0;
  12688. }
  12689. }
  12690. public struct Sp : IEquatable<Sp> {
  12691. public Sp(int i, double d) {
  12692. I = i;
  12693. D = d;
  12694. }
  12695. public int I;
  12696. public double D;
  12697. public override bool Equals(object o) {
  12698. return (o is Sp) && Equals((Sp) o);
  12699. }
  12700. public bool Equals(Sp other) {
  12701. return other.I == I && other.D == D;
  12702. }
  12703. public override int GetHashCode() {
  12704. return I.GetHashCode() ^ D.GetHashCode();
  12705. }
  12706. }
  12707. public struct Ss : IEquatable<Ss> {
  12708. public Ss(S s) {
  12709. Val = s;
  12710. }
  12711. public S Val;
  12712. public override bool Equals(object o) {
  12713. return (o is Ss) && Equals((Ss) o);
  12714. }
  12715. public bool Equals(Ss other) {
  12716. return other.Val.Equals(Val);
  12717. }
  12718. public override int GetHashCode() {
  12719. return Val.GetHashCode();
  12720. }
  12721. }
  12722. public struct Sc : IEquatable<Sc> {
  12723. public Sc(string s) {
  12724. S = s;
  12725. }
  12726. public string S;
  12727. public override bool Equals(object o) {
  12728. return (o is Sc) && Equals((Sc) o);
  12729. }
  12730. public bool Equals(Sc other) {
  12731. return other.S == S;
  12732. }
  12733. public override int GetHashCode() {
  12734. return S.GetHashCode();
  12735. }
  12736. }
  12737. public struct Scs : IEquatable<Scs> {
  12738. public Scs(string s, S val) {
  12739. S = s;
  12740. Val = val;
  12741. }
  12742. public string S;
  12743. public S Val;
  12744. public override bool Equals(object o) {
  12745. return (o is Scs) && Equals((Scs) o);
  12746. }
  12747. public bool Equals(Scs other) {
  12748. return other.S == S && other.Val.Equals(Val);
  12749. }
  12750. public override int GetHashCode() {
  12751. return S.GetHashCode() ^ Val.GetHashCode();
  12752. }
  12753. }
  12754. }
  12755. //-------- Scenario 1795
  12756. namespace Scenario1795{
  12757. public class Test
  12758. {
  12759. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check77__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  12760. public static Expression check77__() {
  12761. if(Main() != 0 ) {
  12762. throw new Exception();
  12763. } else {
  12764. return Expression.Constant(0);
  12765. }
  12766. }
  12767. public static int Main()
  12768. {
  12769. Ext.StartCapture();
  12770. bool success = false;
  12771. try
  12772. {
  12773. success = check77();
  12774. }
  12775. finally
  12776. {
  12777. Ext.StopCapture();
  12778. }
  12779. return success ? 0 : 1;
  12780. }
  12781. static bool check77() {
  12782. foreach (string[] val in new string[][] { null, new string[0], new string[] { null, "", "a", "foo" }, new string[100] }) {
  12783. if (!check77(val)) {
  12784. return false;
  12785. }
  12786. }
  12787. return true;
  12788. }
  12789. static bool check77(string[] val) {
  12790. Expression<Func<string[]>> e =
  12791. Expression.Lambda<Func<string[]>>(
  12792. Expression.Constant(val, typeof(string[])),
  12793. new System.Collections.Generic.List<ParameterExpression>());
  12794. Func<string[]> f = e.Compile();
  12795. return object.Equals(f(), val);
  12796. }
  12797. }
  12798. public static class Ext {
  12799. public static void StartCapture() {
  12800. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12801. // m.Invoke(null, new object[] { "test.dll" });
  12802. }
  12803. public static void StopCapture() {
  12804. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12805. // m.Invoke(null, new object[0]);
  12806. }
  12807. public static bool IsIntegralOrEnum(Type type) {
  12808. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12809. case TypeCode.Byte:
  12810. case TypeCode.SByte:
  12811. case TypeCode.Int16:
  12812. case TypeCode.Int32:
  12813. case TypeCode.Int64:
  12814. case TypeCode.UInt16:
  12815. case TypeCode.UInt32:
  12816. case TypeCode.UInt64:
  12817. return true;
  12818. default:
  12819. return false;
  12820. }
  12821. }
  12822. public static bool IsFloating(Type type) {
  12823. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12824. case TypeCode.Single:
  12825. case TypeCode.Double:
  12826. return true;
  12827. default:
  12828. return false;
  12829. }
  12830. }
  12831. public static Type GetNonNullableType(Type type) {
  12832. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  12833. type.GetGenericArguments()[0] :
  12834. type;
  12835. }
  12836. }
  12837. }
  12838. //-------- Scenario 1796
  12839. namespace Scenario1796{
  12840. public class Test
  12841. {
  12842. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check78__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  12843. public static Expression check78__() {
  12844. if(Main() != 0 ) {
  12845. throw new Exception();
  12846. } else {
  12847. return Expression.Constant(0);
  12848. }
  12849. }
  12850. public static int Main()
  12851. {
  12852. Ext.StartCapture();
  12853. bool success = false;
  12854. try
  12855. {
  12856. success = check78();
  12857. }
  12858. finally
  12859. {
  12860. Ext.StopCapture();
  12861. }
  12862. return success ? 0 : 1;
  12863. }
  12864. static bool check78() {
  12865. foreach (object[] val in new object[][] { null, new object[0], new object[] { null, new object(), new C(), new D(3) }, new object[100] }) {
  12866. if (!check78(val)) {
  12867. return false;
  12868. }
  12869. }
  12870. return true;
  12871. }
  12872. static bool check78(object[] val) {
  12873. Expression<Func<object[]>> e =
  12874. Expression.Lambda<Func<object[]>>(
  12875. Expression.Constant(val, typeof(object[])),
  12876. new System.Collections.Generic.List<ParameterExpression>());
  12877. Func<object[]> f = e.Compile();
  12878. return object.Equals(f(), val);
  12879. }
  12880. }
  12881. public static class Ext {
  12882. public static void StartCapture() {
  12883. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12884. // m.Invoke(null, new object[] { "test.dll" });
  12885. }
  12886. public static void StopCapture() {
  12887. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  12888. // m.Invoke(null, new object[0]);
  12889. }
  12890. public static bool IsIntegralOrEnum(Type type) {
  12891. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12892. case TypeCode.Byte:
  12893. case TypeCode.SByte:
  12894. case TypeCode.Int16:
  12895. case TypeCode.Int32:
  12896. case TypeCode.Int64:
  12897. case TypeCode.UInt16:
  12898. case TypeCode.UInt32:
  12899. case TypeCode.UInt64:
  12900. return true;
  12901. default:
  12902. return false;
  12903. }
  12904. }
  12905. public static bool IsFloating(Type type) {
  12906. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  12907. case TypeCode.Single:
  12908. case TypeCode.Double:
  12909. return true;
  12910. default:
  12911. return false;
  12912. }
  12913. }
  12914. public static Type GetNonNullableType(Type type) {
  12915. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  12916. type.GetGenericArguments()[0] :
  12917. type;
  12918. }
  12919. }
  12920. public interface I {
  12921. void M();
  12922. }
  12923. public class C : IEquatable<C>, I {
  12924. void I.M() {
  12925. }
  12926. public override bool Equals(object o) {
  12927. return o is C && Equals((C) o);
  12928. }
  12929. public bool Equals(C c) {
  12930. return c != null;
  12931. }
  12932. public override int GetHashCode() {
  12933. return 0;
  12934. }
  12935. }
  12936. public class D : C, IEquatable<D> {
  12937. public int Val;
  12938. public D() {
  12939. }
  12940. public D(int val) {
  12941. Val = val;
  12942. }
  12943. public override bool Equals(object o) {
  12944. return o is D && Equals((D) o);
  12945. }
  12946. public bool Equals(D d) {
  12947. return d != null && d.Val == Val;
  12948. }
  12949. public override int GetHashCode() {
  12950. return Val;
  12951. }
  12952. }
  12953. public enum E {
  12954. A=1, B=2
  12955. }
  12956. public enum El : long {
  12957. A, B, C
  12958. }
  12959. public struct S : IEquatable<S> {
  12960. public override bool Equals(object o) {
  12961. return (o is S) && Equals((S) o);
  12962. }
  12963. public bool Equals(S other) {
  12964. return true;
  12965. }
  12966. public override int GetHashCode() {
  12967. return 0;
  12968. }
  12969. }
  12970. public struct Sp : IEquatable<Sp> {
  12971. public Sp(int i, double d) {
  12972. I = i;
  12973. D = d;
  12974. }
  12975. public int I;
  12976. public double D;
  12977. public override bool Equals(object o) {
  12978. return (o is Sp) && Equals((Sp) o);
  12979. }
  12980. public bool Equals(Sp other) {
  12981. return other.I == I && other.D == D;
  12982. }
  12983. public override int GetHashCode() {
  12984. return I.GetHashCode() ^ D.GetHashCode();
  12985. }
  12986. }
  12987. public struct Ss : IEquatable<Ss> {
  12988. public Ss(S s) {
  12989. Val = s;
  12990. }
  12991. public S Val;
  12992. public override bool Equals(object o) {
  12993. return (o is Ss) && Equals((Ss) o);
  12994. }
  12995. public bool Equals(Ss other) {
  12996. return other.Val.Equals(Val);
  12997. }
  12998. public override int GetHashCode() {
  12999. return Val.GetHashCode();
  13000. }
  13001. }
  13002. public struct Sc : IEquatable<Sc> {
  13003. public Sc(string s) {
  13004. S = s;
  13005. }
  13006. public string S;
  13007. public override bool Equals(object o) {
  13008. return (o is Sc) && Equals((Sc) o);
  13009. }
  13010. public bool Equals(Sc other) {
  13011. return other.S == S;
  13012. }
  13013. public override int GetHashCode() {
  13014. return S.GetHashCode();
  13015. }
  13016. }
  13017. public struct Scs : IEquatable<Scs> {
  13018. public Scs(string s, S val) {
  13019. S = s;
  13020. Val = val;
  13021. }
  13022. public string S;
  13023. public S Val;
  13024. public override bool Equals(object o) {
  13025. return (o is Scs) && Equals((Scs) o);
  13026. }
  13027. public bool Equals(Scs other) {
  13028. return other.S == S && other.Val.Equals(Val);
  13029. }
  13030. public override int GetHashCode() {
  13031. return S.GetHashCode() ^ Val.GetHashCode();
  13032. }
  13033. }
  13034. }
  13035. //-------- Scenario 1797
  13036. namespace Scenario1797{
  13037. public class Test
  13038. {
  13039. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check79__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  13040. public static Expression check79__() {
  13041. if(Main() != 0 ) {
  13042. throw new Exception();
  13043. } else {
  13044. return Expression.Constant(0);
  13045. }
  13046. }
  13047. public static int Main()
  13048. {
  13049. Ext.StartCapture();
  13050. bool success = false;
  13051. try
  13052. {
  13053. success = check79();
  13054. }
  13055. finally
  13056. {
  13057. Ext.StopCapture();
  13058. }
  13059. return success ? 0 : 1;
  13060. }
  13061. static bool check79() {
  13062. foreach (C[] val in new C[][] { null, new C[0], new C[] { null, new C(), new D(), new D(0), new D(5) }, new C[100] }) {
  13063. if (!check79(val)) {
  13064. return false;
  13065. }
  13066. }
  13067. return true;
  13068. }
  13069. static bool check79(C[] val) {
  13070. Expression<Func<C[]>> e =
  13071. Expression.Lambda<Func<C[]>>(
  13072. Expression.Constant(val, typeof(C[])),
  13073. new System.Collections.Generic.List<ParameterExpression>());
  13074. Func<C[]> f = e.Compile();
  13075. return object.Equals(f(), val);
  13076. }
  13077. }
  13078. public static class Ext {
  13079. public static void StartCapture() {
  13080. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13081. // m.Invoke(null, new object[] { "test.dll" });
  13082. }
  13083. public static void StopCapture() {
  13084. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13085. // m.Invoke(null, new object[0]);
  13086. }
  13087. public static bool IsIntegralOrEnum(Type type) {
  13088. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13089. case TypeCode.Byte:
  13090. case TypeCode.SByte:
  13091. case TypeCode.Int16:
  13092. case TypeCode.Int32:
  13093. case TypeCode.Int64:
  13094. case TypeCode.UInt16:
  13095. case TypeCode.UInt32:
  13096. case TypeCode.UInt64:
  13097. return true;
  13098. default:
  13099. return false;
  13100. }
  13101. }
  13102. public static bool IsFloating(Type type) {
  13103. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13104. case TypeCode.Single:
  13105. case TypeCode.Double:
  13106. return true;
  13107. default:
  13108. return false;
  13109. }
  13110. }
  13111. public static Type GetNonNullableType(Type type) {
  13112. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  13113. type.GetGenericArguments()[0] :
  13114. type;
  13115. }
  13116. }
  13117. public interface I {
  13118. void M();
  13119. }
  13120. public class C : IEquatable<C>, I {
  13121. void I.M() {
  13122. }
  13123. public override bool Equals(object o) {
  13124. return o is C && Equals((C) o);
  13125. }
  13126. public bool Equals(C c) {
  13127. return c != null;
  13128. }
  13129. public override int GetHashCode() {
  13130. return 0;
  13131. }
  13132. }
  13133. public class D : C, IEquatable<D> {
  13134. public int Val;
  13135. public D() {
  13136. }
  13137. public D(int val) {
  13138. Val = val;
  13139. }
  13140. public override bool Equals(object o) {
  13141. return o is D && Equals((D) o);
  13142. }
  13143. public bool Equals(D d) {
  13144. return d != null && d.Val == Val;
  13145. }
  13146. public override int GetHashCode() {
  13147. return Val;
  13148. }
  13149. }
  13150. public enum E {
  13151. A=1, B=2
  13152. }
  13153. public enum El : long {
  13154. A, B, C
  13155. }
  13156. public struct S : IEquatable<S> {
  13157. public override bool Equals(object o) {
  13158. return (o is S) && Equals((S) o);
  13159. }
  13160. public bool Equals(S other) {
  13161. return true;
  13162. }
  13163. public override int GetHashCode() {
  13164. return 0;
  13165. }
  13166. }
  13167. public struct Sp : IEquatable<Sp> {
  13168. public Sp(int i, double d) {
  13169. I = i;
  13170. D = d;
  13171. }
  13172. public int I;
  13173. public double D;
  13174. public override bool Equals(object o) {
  13175. return (o is Sp) && Equals((Sp) o);
  13176. }
  13177. public bool Equals(Sp other) {
  13178. return other.I == I && other.D == D;
  13179. }
  13180. public override int GetHashCode() {
  13181. return I.GetHashCode() ^ D.GetHashCode();
  13182. }
  13183. }
  13184. public struct Ss : IEquatable<Ss> {
  13185. public Ss(S s) {
  13186. Val = s;
  13187. }
  13188. public S Val;
  13189. public override bool Equals(object o) {
  13190. return (o is Ss) && Equals((Ss) o);
  13191. }
  13192. public bool Equals(Ss other) {
  13193. return other.Val.Equals(Val);
  13194. }
  13195. public override int GetHashCode() {
  13196. return Val.GetHashCode();
  13197. }
  13198. }
  13199. public struct Sc : IEquatable<Sc> {
  13200. public Sc(string s) {
  13201. S = s;
  13202. }
  13203. public string S;
  13204. public override bool Equals(object o) {
  13205. return (o is Sc) && Equals((Sc) o);
  13206. }
  13207. public bool Equals(Sc other) {
  13208. return other.S == S;
  13209. }
  13210. public override int GetHashCode() {
  13211. return S.GetHashCode();
  13212. }
  13213. }
  13214. public struct Scs : IEquatable<Scs> {
  13215. public Scs(string s, S val) {
  13216. S = s;
  13217. Val = val;
  13218. }
  13219. public string S;
  13220. public S Val;
  13221. public override bool Equals(object o) {
  13222. return (o is Scs) && Equals((Scs) o);
  13223. }
  13224. public bool Equals(Scs other) {
  13225. return other.S == S && other.Val.Equals(Val);
  13226. }
  13227. public override int GetHashCode() {
  13228. return S.GetHashCode() ^ Val.GetHashCode();
  13229. }
  13230. }
  13231. }
  13232. //-------- Scenario 1798
  13233. namespace Scenario1798{
  13234. public class Test
  13235. {
  13236. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check80__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  13237. public static Expression check80__() {
  13238. if(Main() != 0 ) {
  13239. throw new Exception();
  13240. } else {
  13241. return Expression.Constant(0);
  13242. }
  13243. }
  13244. public static int Main()
  13245. {
  13246. Ext.StartCapture();
  13247. bool success = false;
  13248. try
  13249. {
  13250. success = check80();
  13251. }
  13252. finally
  13253. {
  13254. Ext.StopCapture();
  13255. }
  13256. return success ? 0 : 1;
  13257. }
  13258. static bool check80() {
  13259. foreach (D[] val in new D[][] { null, new D[0], new D[] { null, new D(), new D(0), new D(5) }, new D[100] }) {
  13260. if (!check80(val)) {
  13261. return false;
  13262. }
  13263. }
  13264. return true;
  13265. }
  13266. static bool check80(D[] val) {
  13267. Expression<Func<D[]>> e =
  13268. Expression.Lambda<Func<D[]>>(
  13269. Expression.Constant(val, typeof(D[])),
  13270. new System.Collections.Generic.List<ParameterExpression>());
  13271. Func<D[]> f = e.Compile();
  13272. return object.Equals(f(), val);
  13273. }
  13274. }
  13275. public static class Ext {
  13276. public static void StartCapture() {
  13277. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13278. // m.Invoke(null, new object[] { "test.dll" });
  13279. }
  13280. public static void StopCapture() {
  13281. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13282. // m.Invoke(null, new object[0]);
  13283. }
  13284. public static bool IsIntegralOrEnum(Type type) {
  13285. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13286. case TypeCode.Byte:
  13287. case TypeCode.SByte:
  13288. case TypeCode.Int16:
  13289. case TypeCode.Int32:
  13290. case TypeCode.Int64:
  13291. case TypeCode.UInt16:
  13292. case TypeCode.UInt32:
  13293. case TypeCode.UInt64:
  13294. return true;
  13295. default:
  13296. return false;
  13297. }
  13298. }
  13299. public static bool IsFloating(Type type) {
  13300. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13301. case TypeCode.Single:
  13302. case TypeCode.Double:
  13303. return true;
  13304. default:
  13305. return false;
  13306. }
  13307. }
  13308. public static Type GetNonNullableType(Type type) {
  13309. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  13310. type.GetGenericArguments()[0] :
  13311. type;
  13312. }
  13313. }
  13314. public interface I {
  13315. void M();
  13316. }
  13317. public class C : IEquatable<C>, I {
  13318. void I.M() {
  13319. }
  13320. public override bool Equals(object o) {
  13321. return o is C && Equals((C) o);
  13322. }
  13323. public bool Equals(C c) {
  13324. return c != null;
  13325. }
  13326. public override int GetHashCode() {
  13327. return 0;
  13328. }
  13329. }
  13330. public class D : C, IEquatable<D> {
  13331. public int Val;
  13332. public D() {
  13333. }
  13334. public D(int val) {
  13335. Val = val;
  13336. }
  13337. public override bool Equals(object o) {
  13338. return o is D && Equals((D) o);
  13339. }
  13340. public bool Equals(D d) {
  13341. return d != null && d.Val == Val;
  13342. }
  13343. public override int GetHashCode() {
  13344. return Val;
  13345. }
  13346. }
  13347. public enum E {
  13348. A=1, B=2
  13349. }
  13350. public enum El : long {
  13351. A, B, C
  13352. }
  13353. public struct S : IEquatable<S> {
  13354. public override bool Equals(object o) {
  13355. return (o is S) && Equals((S) o);
  13356. }
  13357. public bool Equals(S other) {
  13358. return true;
  13359. }
  13360. public override int GetHashCode() {
  13361. return 0;
  13362. }
  13363. }
  13364. public struct Sp : IEquatable<Sp> {
  13365. public Sp(int i, double d) {
  13366. I = i;
  13367. D = d;
  13368. }
  13369. public int I;
  13370. public double D;
  13371. public override bool Equals(object o) {
  13372. return (o is Sp) && Equals((Sp) o);
  13373. }
  13374. public bool Equals(Sp other) {
  13375. return other.I == I && other.D == D;
  13376. }
  13377. public override int GetHashCode() {
  13378. return I.GetHashCode() ^ D.GetHashCode();
  13379. }
  13380. }
  13381. public struct Ss : IEquatable<Ss> {
  13382. public Ss(S s) {
  13383. Val = s;
  13384. }
  13385. public S Val;
  13386. public override bool Equals(object o) {
  13387. return (o is Ss) && Equals((Ss) o);
  13388. }
  13389. public bool Equals(Ss other) {
  13390. return other.Val.Equals(Val);
  13391. }
  13392. public override int GetHashCode() {
  13393. return Val.GetHashCode();
  13394. }
  13395. }
  13396. public struct Sc : IEquatable<Sc> {
  13397. public Sc(string s) {
  13398. S = s;
  13399. }
  13400. public string S;
  13401. public override bool Equals(object o) {
  13402. return (o is Sc) && Equals((Sc) o);
  13403. }
  13404. public bool Equals(Sc other) {
  13405. return other.S == S;
  13406. }
  13407. public override int GetHashCode() {
  13408. return S.GetHashCode();
  13409. }
  13410. }
  13411. public struct Scs : IEquatable<Scs> {
  13412. public Scs(string s, S val) {
  13413. S = s;
  13414. Val = val;
  13415. }
  13416. public string S;
  13417. public S Val;
  13418. public override bool Equals(object o) {
  13419. return (o is Scs) && Equals((Scs) o);
  13420. }
  13421. public bool Equals(Scs other) {
  13422. return other.S == S && other.Val.Equals(Val);
  13423. }
  13424. public override int GetHashCode() {
  13425. return S.GetHashCode() ^ Val.GetHashCode();
  13426. }
  13427. }
  13428. }
  13429. //-------- Scenario 1799
  13430. namespace Scenario1799{
  13431. public class Test
  13432. {
  13433. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check81_object___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  13434. public static Expression check81_object___() {
  13435. if(Main() != 0 ) {
  13436. throw new Exception();
  13437. } else {
  13438. return Expression.Constant(0);
  13439. }
  13440. }
  13441. public static int Main()
  13442. {
  13443. Ext.StartCapture();
  13444. bool success = false;
  13445. try
  13446. {
  13447. success = check81<object>();
  13448. }
  13449. finally
  13450. {
  13451. Ext.StopCapture();
  13452. }
  13453. return success ? 0 : 1;
  13454. }
  13455. static bool check81<T>() {
  13456. foreach (T[] val in new T[][] { null, new T[0], new T[] { default(T) }, new T[100] }) {
  13457. if (!check81<T>(val)) {
  13458. return false;
  13459. }
  13460. }
  13461. return true;
  13462. }
  13463. static bool check81<T>(T[] val) {
  13464. Expression<Func<T[]>> e =
  13465. Expression.Lambda<Func<T[]>>(
  13466. Expression.Constant(val, typeof(T[])),
  13467. new System.Collections.Generic.List<ParameterExpression>());
  13468. Func<T[]> f = e.Compile();
  13469. return object.Equals(f(), val);
  13470. }
  13471. }
  13472. public static class Ext {
  13473. public static void StartCapture() {
  13474. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13475. // m.Invoke(null, new object[] { "test.dll" });
  13476. }
  13477. public static void StopCapture() {
  13478. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13479. // m.Invoke(null, new object[0]);
  13480. }
  13481. public static bool IsIntegralOrEnum(Type type) {
  13482. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13483. case TypeCode.Byte:
  13484. case TypeCode.SByte:
  13485. case TypeCode.Int16:
  13486. case TypeCode.Int32:
  13487. case TypeCode.Int64:
  13488. case TypeCode.UInt16:
  13489. case TypeCode.UInt32:
  13490. case TypeCode.UInt64:
  13491. return true;
  13492. default:
  13493. return false;
  13494. }
  13495. }
  13496. public static bool IsFloating(Type type) {
  13497. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13498. case TypeCode.Single:
  13499. case TypeCode.Double:
  13500. return true;
  13501. default:
  13502. return false;
  13503. }
  13504. }
  13505. public static Type GetNonNullableType(Type type) {
  13506. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  13507. type.GetGenericArguments()[0] :
  13508. type;
  13509. }
  13510. }
  13511. public interface I {
  13512. void M();
  13513. }
  13514. public class C : IEquatable<C>, I {
  13515. void I.M() {
  13516. }
  13517. public override bool Equals(object o) {
  13518. return o is C && Equals((C) o);
  13519. }
  13520. public bool Equals(C c) {
  13521. return c != null;
  13522. }
  13523. public override int GetHashCode() {
  13524. return 0;
  13525. }
  13526. }
  13527. public class D : C, IEquatable<D> {
  13528. public int Val;
  13529. public D() {
  13530. }
  13531. public D(int val) {
  13532. Val = val;
  13533. }
  13534. public override bool Equals(object o) {
  13535. return o is D && Equals((D) o);
  13536. }
  13537. public bool Equals(D d) {
  13538. return d != null && d.Val == Val;
  13539. }
  13540. public override int GetHashCode() {
  13541. return Val;
  13542. }
  13543. }
  13544. public enum E {
  13545. A=1, B=2
  13546. }
  13547. public enum El : long {
  13548. A, B, C
  13549. }
  13550. public struct S : IEquatable<S> {
  13551. public override bool Equals(object o) {
  13552. return (o is S) && Equals((S) o);
  13553. }
  13554. public bool Equals(S other) {
  13555. return true;
  13556. }
  13557. public override int GetHashCode() {
  13558. return 0;
  13559. }
  13560. }
  13561. public struct Sp : IEquatable<Sp> {
  13562. public Sp(int i, double d) {
  13563. I = i;
  13564. D = d;
  13565. }
  13566. public int I;
  13567. public double D;
  13568. public override bool Equals(object o) {
  13569. return (o is Sp) && Equals((Sp) o);
  13570. }
  13571. public bool Equals(Sp other) {
  13572. return other.I == I && other.D == D;
  13573. }
  13574. public override int GetHashCode() {
  13575. return I.GetHashCode() ^ D.GetHashCode();
  13576. }
  13577. }
  13578. public struct Ss : IEquatable<Ss> {
  13579. public Ss(S s) {
  13580. Val = s;
  13581. }
  13582. public S Val;
  13583. public override bool Equals(object o) {
  13584. return (o is Ss) && Equals((Ss) o);
  13585. }
  13586. public bool Equals(Ss other) {
  13587. return other.Val.Equals(Val);
  13588. }
  13589. public override int GetHashCode() {
  13590. return Val.GetHashCode();
  13591. }
  13592. }
  13593. public struct Sc : IEquatable<Sc> {
  13594. public Sc(string s) {
  13595. S = s;
  13596. }
  13597. public string S;
  13598. public override bool Equals(object o) {
  13599. return (o is Sc) && Equals((Sc) o);
  13600. }
  13601. public bool Equals(Sc other) {
  13602. return other.S == S;
  13603. }
  13604. public override int GetHashCode() {
  13605. return S.GetHashCode();
  13606. }
  13607. }
  13608. public struct Scs : IEquatable<Scs> {
  13609. public Scs(string s, S val) {
  13610. S = s;
  13611. Val = val;
  13612. }
  13613. public string S;
  13614. public S Val;
  13615. public override bool Equals(object o) {
  13616. return (o is Scs) && Equals((Scs) o);
  13617. }
  13618. public bool Equals(Scs other) {
  13619. return other.S == S && other.Val.Equals(Val);
  13620. }
  13621. public override int GetHashCode() {
  13622. return S.GetHashCode() ^ Val.GetHashCode();
  13623. }
  13624. }
  13625. }
  13626. //-------- Scenario 1800
  13627. namespace Scenario1800{
  13628. public class Test
  13629. {
  13630. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check81_C___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  13631. public static Expression check81_C___() {
  13632. if(Main() != 0 ) {
  13633. throw new Exception();
  13634. } else {
  13635. return Expression.Constant(0);
  13636. }
  13637. }
  13638. public static int Main()
  13639. {
  13640. Ext.StartCapture();
  13641. bool success = false;
  13642. try
  13643. {
  13644. success = check81<C>();
  13645. }
  13646. finally
  13647. {
  13648. Ext.StopCapture();
  13649. }
  13650. return success ? 0 : 1;
  13651. }
  13652. static bool check81<T>() {
  13653. foreach (T[] val in new T[][] { null, new T[0], new T[] { default(T) }, new T[100] }) {
  13654. if (!check81<T>(val)) {
  13655. return false;
  13656. }
  13657. }
  13658. return true;
  13659. }
  13660. static bool check81<T>(T[] val) {
  13661. Expression<Func<T[]>> e =
  13662. Expression.Lambda<Func<T[]>>(
  13663. Expression.Constant(val, typeof(T[])),
  13664. new System.Collections.Generic.List<ParameterExpression>());
  13665. Func<T[]> f = e.Compile();
  13666. return object.Equals(f(), val);
  13667. }
  13668. }
  13669. public static class Ext {
  13670. public static void StartCapture() {
  13671. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13672. // m.Invoke(null, new object[] { "test.dll" });
  13673. }
  13674. public static void StopCapture() {
  13675. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13676. // m.Invoke(null, new object[0]);
  13677. }
  13678. public static bool IsIntegralOrEnum(Type type) {
  13679. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13680. case TypeCode.Byte:
  13681. case TypeCode.SByte:
  13682. case TypeCode.Int16:
  13683. case TypeCode.Int32:
  13684. case TypeCode.Int64:
  13685. case TypeCode.UInt16:
  13686. case TypeCode.UInt32:
  13687. case TypeCode.UInt64:
  13688. return true;
  13689. default:
  13690. return false;
  13691. }
  13692. }
  13693. public static bool IsFloating(Type type) {
  13694. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13695. case TypeCode.Single:
  13696. case TypeCode.Double:
  13697. return true;
  13698. default:
  13699. return false;
  13700. }
  13701. }
  13702. public static Type GetNonNullableType(Type type) {
  13703. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  13704. type.GetGenericArguments()[0] :
  13705. type;
  13706. }
  13707. }
  13708. public interface I {
  13709. void M();
  13710. }
  13711. public class C : IEquatable<C>, I {
  13712. void I.M() {
  13713. }
  13714. public override bool Equals(object o) {
  13715. return o is C && Equals((C) o);
  13716. }
  13717. public bool Equals(C c) {
  13718. return c != null;
  13719. }
  13720. public override int GetHashCode() {
  13721. return 0;
  13722. }
  13723. }
  13724. public class D : C, IEquatable<D> {
  13725. public int Val;
  13726. public D() {
  13727. }
  13728. public D(int val) {
  13729. Val = val;
  13730. }
  13731. public override bool Equals(object o) {
  13732. return o is D && Equals((D) o);
  13733. }
  13734. public bool Equals(D d) {
  13735. return d != null && d.Val == Val;
  13736. }
  13737. public override int GetHashCode() {
  13738. return Val;
  13739. }
  13740. }
  13741. public enum E {
  13742. A=1, B=2
  13743. }
  13744. public enum El : long {
  13745. A, B, C
  13746. }
  13747. public struct S : IEquatable<S> {
  13748. public override bool Equals(object o) {
  13749. return (o is S) && Equals((S) o);
  13750. }
  13751. public bool Equals(S other) {
  13752. return true;
  13753. }
  13754. public override int GetHashCode() {
  13755. return 0;
  13756. }
  13757. }
  13758. public struct Sp : IEquatable<Sp> {
  13759. public Sp(int i, double d) {
  13760. I = i;
  13761. D = d;
  13762. }
  13763. public int I;
  13764. public double D;
  13765. public override bool Equals(object o) {
  13766. return (o is Sp) && Equals((Sp) o);
  13767. }
  13768. public bool Equals(Sp other) {
  13769. return other.I == I && other.D == D;
  13770. }
  13771. public override int GetHashCode() {
  13772. return I.GetHashCode() ^ D.GetHashCode();
  13773. }
  13774. }
  13775. public struct Ss : IEquatable<Ss> {
  13776. public Ss(S s) {
  13777. Val = s;
  13778. }
  13779. public S Val;
  13780. public override bool Equals(object o) {
  13781. return (o is Ss) && Equals((Ss) o);
  13782. }
  13783. public bool Equals(Ss other) {
  13784. return other.Val.Equals(Val);
  13785. }
  13786. public override int GetHashCode() {
  13787. return Val.GetHashCode();
  13788. }
  13789. }
  13790. public struct Sc : IEquatable<Sc> {
  13791. public Sc(string s) {
  13792. S = s;
  13793. }
  13794. public string S;
  13795. public override bool Equals(object o) {
  13796. return (o is Sc) && Equals((Sc) o);
  13797. }
  13798. public bool Equals(Sc other) {
  13799. return other.S == S;
  13800. }
  13801. public override int GetHashCode() {
  13802. return S.GetHashCode();
  13803. }
  13804. }
  13805. public struct Scs : IEquatable<Scs> {
  13806. public Scs(string s, S val) {
  13807. S = s;
  13808. Val = val;
  13809. }
  13810. public string S;
  13811. public S Val;
  13812. public override bool Equals(object o) {
  13813. return (o is Scs) && Equals((Scs) o);
  13814. }
  13815. public bool Equals(Scs other) {
  13816. return other.S == S && other.Val.Equals(Val);
  13817. }
  13818. public override int GetHashCode() {
  13819. return S.GetHashCode() ^ Val.GetHashCode();
  13820. }
  13821. }
  13822. }
  13823. //-------- Scenario 1801
  13824. namespace Scenario1801{
  13825. public class Test
  13826. {
  13827. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check81_S___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  13828. public static Expression check81_S___() {
  13829. if(Main() != 0 ) {
  13830. throw new Exception();
  13831. } else {
  13832. return Expression.Constant(0);
  13833. }
  13834. }
  13835. public static int Main()
  13836. {
  13837. Ext.StartCapture();
  13838. bool success = false;
  13839. try
  13840. {
  13841. success = check81<S>();
  13842. }
  13843. finally
  13844. {
  13845. Ext.StopCapture();
  13846. }
  13847. return success ? 0 : 1;
  13848. }
  13849. static bool check81<T>() {
  13850. foreach (T[] val in new T[][] { null, new T[0], new T[] { default(T) }, new T[100] }) {
  13851. if (!check81<T>(val)) {
  13852. return false;
  13853. }
  13854. }
  13855. return true;
  13856. }
  13857. static bool check81<T>(T[] val) {
  13858. Expression<Func<T[]>> e =
  13859. Expression.Lambda<Func<T[]>>(
  13860. Expression.Constant(val, typeof(T[])),
  13861. new System.Collections.Generic.List<ParameterExpression>());
  13862. Func<T[]> f = e.Compile();
  13863. return object.Equals(f(), val);
  13864. }
  13865. }
  13866. public static class Ext {
  13867. public static void StartCapture() {
  13868. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13869. // m.Invoke(null, new object[] { "test.dll" });
  13870. }
  13871. public static void StopCapture() {
  13872. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  13873. // m.Invoke(null, new object[0]);
  13874. }
  13875. public static bool IsIntegralOrEnum(Type type) {
  13876. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13877. case TypeCode.Byte:
  13878. case TypeCode.SByte:
  13879. case TypeCode.Int16:
  13880. case TypeCode.Int32:
  13881. case TypeCode.Int64:
  13882. case TypeCode.UInt16:
  13883. case TypeCode.UInt32:
  13884. case TypeCode.UInt64:
  13885. return true;
  13886. default:
  13887. return false;
  13888. }
  13889. }
  13890. public static bool IsFloating(Type type) {
  13891. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  13892. case TypeCode.Single:
  13893. case TypeCode.Double:
  13894. return true;
  13895. default:
  13896. return false;
  13897. }
  13898. }
  13899. public static Type GetNonNullableType(Type type) {
  13900. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  13901. type.GetGenericArguments()[0] :
  13902. type;
  13903. }
  13904. }
  13905. public interface I {
  13906. void M();
  13907. }
  13908. public class C : IEquatable<C>, I {
  13909. void I.M() {
  13910. }
  13911. public override bool Equals(object o) {
  13912. return o is C && Equals((C) o);
  13913. }
  13914. public bool Equals(C c) {
  13915. return c != null;
  13916. }
  13917. public override int GetHashCode() {
  13918. return 0;
  13919. }
  13920. }
  13921. public class D : C, IEquatable<D> {
  13922. public int Val;
  13923. public D() {
  13924. }
  13925. public D(int val) {
  13926. Val = val;
  13927. }
  13928. public override bool Equals(object o) {
  13929. return o is D && Equals((D) o);
  13930. }
  13931. public bool Equals(D d) {
  13932. return d != null && d.Val == Val;
  13933. }
  13934. public override int GetHashCode() {
  13935. return Val;
  13936. }
  13937. }
  13938. public enum E {
  13939. A=1, B=2
  13940. }
  13941. public enum El : long {
  13942. A, B, C
  13943. }
  13944. public struct S : IEquatable<S> {
  13945. public override bool Equals(object o) {
  13946. return (o is S) && Equals((S) o);
  13947. }
  13948. public bool Equals(S other) {
  13949. return true;
  13950. }
  13951. public override int GetHashCode() {
  13952. return 0;
  13953. }
  13954. }
  13955. public struct Sp : IEquatable<Sp> {
  13956. public Sp(int i, double d) {
  13957. I = i;
  13958. D = d;
  13959. }
  13960. public int I;
  13961. public double D;
  13962. public override bool Equals(object o) {
  13963. return (o is Sp) && Equals((Sp) o);
  13964. }
  13965. public bool Equals(Sp other) {
  13966. return other.I == I && other.D == D;
  13967. }
  13968. public override int GetHashCode() {
  13969. return I.GetHashCode() ^ D.GetHashCode();
  13970. }
  13971. }
  13972. public struct Ss : IEquatable<Ss> {
  13973. public Ss(S s) {
  13974. Val = s;
  13975. }
  13976. public S Val;
  13977. public override bool Equals(object o) {
  13978. return (o is Ss) && Equals((Ss) o);
  13979. }
  13980. public bool Equals(Ss other) {
  13981. return other.Val.Equals(Val);
  13982. }
  13983. public override int GetHashCode() {
  13984. return Val.GetHashCode();
  13985. }
  13986. }
  13987. public struct Sc : IEquatable<Sc> {
  13988. public Sc(string s) {
  13989. S = s;
  13990. }
  13991. public string S;
  13992. public override bool Equals(object o) {
  13993. return (o is Sc) && Equals((Sc) o);
  13994. }
  13995. public bool Equals(Sc other) {
  13996. return other.S == S;
  13997. }
  13998. public override int GetHashCode() {
  13999. return S.GetHashCode();
  14000. }
  14001. }
  14002. public struct Scs : IEquatable<Scs> {
  14003. public Scs(string s, S val) {
  14004. S = s;
  14005. Val = val;
  14006. }
  14007. public string S;
  14008. public S Val;
  14009. public override bool Equals(object o) {
  14010. return (o is Scs) && Equals((Scs) o);
  14011. }
  14012. public bool Equals(Scs other) {
  14013. return other.S == S && other.Val.Equals(Val);
  14014. }
  14015. public override int GetHashCode() {
  14016. return S.GetHashCode() ^ Val.GetHashCode();
  14017. }
  14018. }
  14019. }
  14020. //-------- Scenario 1802
  14021. namespace Scenario1802{
  14022. public class Test
  14023. {
  14024. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check81_Scs___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  14025. public static Expression check81_Scs___() {
  14026. if(Main() != 0 ) {
  14027. throw new Exception();
  14028. } else {
  14029. return Expression.Constant(0);
  14030. }
  14031. }
  14032. public static int Main()
  14033. {
  14034. Ext.StartCapture();
  14035. bool success = false;
  14036. try
  14037. {
  14038. success = check81<Scs>();
  14039. }
  14040. finally
  14041. {
  14042. Ext.StopCapture();
  14043. }
  14044. return success ? 0 : 1;
  14045. }
  14046. static bool check81<T>() {
  14047. foreach (T[] val in new T[][] { null, new T[0], new T[] { default(T) }, new T[100] }) {
  14048. if (!check81<T>(val)) {
  14049. return false;
  14050. }
  14051. }
  14052. return true;
  14053. }
  14054. static bool check81<T>(T[] val) {
  14055. Expression<Func<T[]>> e =
  14056. Expression.Lambda<Func<T[]>>(
  14057. Expression.Constant(val, typeof(T[])),
  14058. new System.Collections.Generic.List<ParameterExpression>());
  14059. Func<T[]> f = e.Compile();
  14060. return object.Equals(f(), val);
  14061. }
  14062. }
  14063. public static class Ext {
  14064. public static void StartCapture() {
  14065. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  14066. // m.Invoke(null, new object[] { "test.dll" });
  14067. }
  14068. public static void StopCapture() {
  14069. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  14070. // m.Invoke(null, new object[0]);
  14071. }
  14072. public static bool IsIntegralOrEnum(Type type) {
  14073. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  14074. case TypeCode.Byte:
  14075. case TypeCode.SByte:
  14076. case TypeCode.Int16:
  14077. case TypeCode.Int32:
  14078. case TypeCode.Int64:
  14079. case TypeCode.UInt16:
  14080. case TypeCode.UInt32:
  14081. case TypeCode.UInt64:
  14082. return true;
  14083. default:
  14084. return false;
  14085. }
  14086. }
  14087. public static bool IsFloating(Type type) {
  14088. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  14089. case TypeCode.Single:
  14090. case TypeCode.Double:
  14091. return true;
  14092. default:
  14093. return false;
  14094. }
  14095. }
  14096. public static Type GetNonNullableType(Type type) {
  14097. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  14098. type.GetGenericArguments()[0] :
  14099. type;
  14100. }
  14101. }
  14102. public interface I {
  14103. void M();
  14104. }
  14105. public class C : IEquatable<C>, I {
  14106. void I.M() {
  14107. }
  14108. public override bool Equals(object o) {
  14109. return o is C && Equals((C) o);
  14110. }
  14111. public bool Equals(C c) {
  14112. return c != null;
  14113. }
  14114. public override int GetHashCode() {
  14115. return 0;
  14116. }
  14117. }
  14118. public class D : C, IEquatable<D> {
  14119. public int Val;
  14120. public D() {
  14121. }
  14122. public D(int val) {
  14123. Val = val;
  14124. }
  14125. public override bool Equals(object o) {
  14126. return o is D && Equals((D) o);
  14127. }
  14128. public bool Equals(D d) {
  14129. return d != null && d.Val == Val;
  14130. }
  14131. public override int GetHashCode() {
  14132. return Val;
  14133. }
  14134. }
  14135. public enum E {
  14136. A=1, B=2
  14137. }
  14138. public enum El : long {
  14139. A, B, C
  14140. }
  14141. public struct S : IEquatable<S> {
  14142. public override bool Equals(object o) {
  14143. return (o is S) && Equals((S) o);
  14144. }
  14145. public bool Equals(S other) {
  14146. return true;
  14147. }
  14148. public override int GetHashCode() {
  14149. return 0;
  14150. }
  14151. }
  14152. public struct Sp : IEquatable<Sp> {
  14153. public Sp(int i, double d) {
  14154. I = i;
  14155. D = d;
  14156. }
  14157. public int I;
  14158. public double D;
  14159. public override bool Equals(object o) {
  14160. return (o is Sp) && Equals((Sp) o);
  14161. }
  14162. public bool Equals(Sp other) {
  14163. return other.I == I && other.D == D;
  14164. }
  14165. public override int GetHashCode() {
  14166. return I.GetHashCode() ^ D.GetHashCode();
  14167. }
  14168. }
  14169. public struct Ss : IEquatable<Ss> {
  14170. public Ss(S s) {
  14171. Val = s;
  14172. }
  14173. public S Val;
  14174. public override bool Equals(object o) {
  14175. return (o is Ss) && Equals((Ss) o);
  14176. }
  14177. public bool Equals(Ss other) {
  14178. return other.Val.Equals(Val);
  14179. }
  14180. public override int GetHashCode() {
  14181. return Val.GetHashCode();
  14182. }
  14183. }
  14184. public struct Sc : IEquatable<Sc> {
  14185. public Sc(string s) {
  14186. S = s;
  14187. }
  14188. public string S;
  14189. public override bool Equals(object o) {
  14190. return (o is Sc) && Equals((Sc) o);
  14191. }
  14192. public bool Equals(Sc other) {
  14193. return other.S == S;
  14194. }
  14195. public override int GetHashCode() {
  14196. return S.GetHashCode();
  14197. }
  14198. }
  14199. public struct Scs : IEquatable<Scs> {
  14200. public Scs(string s, S val) {
  14201. S = s;
  14202. Val = val;
  14203. }
  14204. public string S;
  14205. public S Val;
  14206. public override bool Equals(object o) {
  14207. return (o is Scs) && Equals((Scs) o);
  14208. }
  14209. public bool Equals(Scs other) {
  14210. return other.S == S && other.Val.Equals(Val);
  14211. }
  14212. public override int GetHashCode() {
  14213. return S.GetHashCode() ^ Val.GetHashCode();
  14214. }
  14215. }
  14216. }
  14217. //-------- Scenario 1803
  14218. namespace Scenario1803{
  14219. public class Test
  14220. {
  14221. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check81_E___", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  14222. public static Expression check81_E___() {
  14223. if(Main() != 0 ) {
  14224. throw new Exception();
  14225. } else {
  14226. return Expression.Constant(0);
  14227. }
  14228. }
  14229. public static int Main()
  14230. {
  14231. Ext.StartCapture();
  14232. bool success = false;
  14233. try
  14234. {
  14235. success = check81<E>();
  14236. }
  14237. finally
  14238. {
  14239. Ext.StopCapture();
  14240. }
  14241. return success ? 0 : 1;
  14242. }
  14243. static bool check81<T>() {
  14244. foreach (T[] val in new T[][] { null, new T[0], new T[] { default(T) }, new T[100] }) {
  14245. if (!check81<T>(val)) {
  14246. return false;
  14247. }
  14248. }
  14249. return true;
  14250. }
  14251. static bool check81<T>(T[] val) {
  14252. Expression<Func<T[]>> e =
  14253. Expression.Lambda<Func<T[]>>(
  14254. Expression.Constant(val, typeof(T[])),
  14255. new System.Collections.Generic.List<ParameterExpression>());
  14256. Func<T[]> f = e.Compile();
  14257. return object.Equals(f(), val);
  14258. }
  14259. }
  14260. public static class Ext {
  14261. public static void StartCapture() {
  14262. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  14263. // m.Invoke(null, new object[] { "test.dll" });
  14264. }
  14265. public static void StopCapture() {
  14266. // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  14267. // m.Invoke(null, new object[0]);
  14268. }
  14269. public static bool IsIntegralOrEnum(Type type) {
  14270. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  14271. case TypeCode.Byte:
  14272. case TypeCode.SByte:
  14273. case TypeCode.Int16:
  14274. case TypeCode.Int32:
  14275. case TypeCode.Int64:
  14276. case TypeCode.UInt16:
  14277. case TypeCode.UInt32:
  14278. case TypeCode.UInt64:
  14279. return true;
  14280. default:
  14281. return false;
  14282. }
  14283. }
  14284. public static bool IsFloating(Type type) {
  14285. switch (Type.GetTypeCode(GetNonNullableType(type))) {
  14286. case TypeCode.Single:
  14287. case TypeCode.Double:
  14288. return true;
  14289. default:
  14290. return false;
  14291. }
  14292. }
  14293. public static Type GetNonNullableType(Type type) {
  14294. return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
  14295. type.GetGenericArguments()[0] :
  14296. type;
  14297. }
  14298. }
  14299. public interface I {
  14300. void M();
  14301. }
  14302. public class C : IEquatable<C>, I {
  14303. void I.M() {
  14304. }
  14305. public override bool Equals(object o) {
  14306. return o is C && Equals((C) o);
  14307. }
  14308. public bool Equals(C c) {
  14309. return c != null;
  14310. }
  14311. public override int GetHashCode() {
  14312. return 0;
  14313. }
  14314. }
  14315. public class D : C, IEquatable<D> {
  14316. public int Val;
  14317. public D() {
  14318. }
  14319. public D(int val) {
  14320. Val = val;
  14321. }
  14322. public override bool Equals(object o) {
  14323. return o is D && Equals((D) o);
  14324. }
  14325. public bool Equals(D d) {
  14326. return d != null && d.Val == Val;
  14327. }
  14328. public override int GetHashCode() {
  14329. return Val;
  14330. }
  14331. }
  14332. public enum E {
  14333. A=1, B=2
  14334. }
  14335. public enum El : long {
  14336. A, B, C
  14337. }
  14338. public struct S : IEquatable<S> {
  14339. public override bool Equals(object o) {
  14340. return (o is S) && Equals((S) o);
  14341. }
  14342. public bool Equals(S other) {
  14343. return true;
  14344. }
  14345. public override int GetHashCode() {
  14346. return 0;
  14347. }
  14348. }
  14349. public struct Sp : IEquatable<Sp> {
  14350. public Sp(int i, double d) {
  14351. I = i;
  14352. D = d;
  14353. }
  14354. public int I;
  14355. public double D;
  14356. public override bool Equals(object o) {
  14357. return (o is Sp) && Equals((Sp) o);
  14358. }
  14359. public bool Equals(Sp other) {
  14360. return other.I == I && other.D == D;
  14361. }
  14362. public override int GetHashCode() {
  14363. return I.GetHashCode() ^ D.GetHashCode();
  14364. }
  14365. }
  14366. public struct Ss : IEquatable<Ss> {
  14367. public Ss(S s) {
  14368. Val = s;
  14369. }
  14370. public S Val;
  14371. public override bool Equals(object o) {
  14372. return (o is Ss) && Equals((Ss) o);
  14373. }
  14374. public bool Equals(Ss other) {
  14375. return other.Val.Equals(Val);
  14376. }
  14377. public override int GetHashCode() {
  14378. return Val.GetHashCode();
  14379. }
  14380. }
  14381. public struct Sc : IEquatable<Sc> {
  14382. public Sc(string s) {
  14383. S = s;
  14384. }
  14385. public string S;
  14386. public override bool Equals(object o) {
  14387. return (o is Sc) && Equals((Sc) o);
  14388. }
  14389. public bool Equals(Sc other) {
  14390. return other.S == S;
  14391. }
  14392. public override int GetHashCode() {
  14393. return S.GetHashCode();
  14394. }
  14395. }
  14396. public struct Scs : IEquatable<Scs> {
  14397. public Scs(string s, S val) {
  14398. S = s;
  14399. Val = val;
  14400. }
  14401. public string S;
  14402. public S Val;
  14403. public override bool Equals(object o) {
  14404. return (o is Scs) && Equals((Scs) o);
  14405. }
  14406. public bool Equals(Scs other) {