using System; using System.Collections.Generic; // Test edge cases with generic parameters as mentioned in the diff public class GenericParameterEdgeCases { // Test method with multiple generic parameters public static T2 Convert(T1 input, Func converter) { return converter(input); } // Test nested generic method calls public static List WrapInList(T item) { var list = new List(); list.Add(item); return list; } public static int TestMultipleGenericParameters() { // Test Convert method with different type combinations string result1 = Convert(42, x => x.ToString()); if (result1 != "42") return 1; int result2 = Convert("123", x => int.Parse(x)); if (result2 != 123) return 2; return 0; } public static int TestNestedGenericMethodCalls() { // Test calling generic method from within another generic method var intList = WrapInList(42); if (intList.Count != 1) return 1; if (intList[0] != 42) return 2; var stringList = WrapInList("test"); if (stringList.Count != 1) return 3; if (stringList[0] != "test") return 4; return 0; } } // Test deeply nested generic types public class DeepNestingTest { public static int TestDeeplyNestedGenerics() { // Test Dictionary>> var complexType = new Dictionary>>(); var innerDict = new Dictionary(); innerDict[1] = "one"; innerDict[2] = "two"; var listOfDicts = new List>(); listOfDicts.Add(innerDict); complexType["test"] = listOfDicts; if (complexType["test"].Count != 1) return 1; if (complexType["test"][0][1] != "one") return 2; if (complexType["test"][0][2] != "two") return 3; return 0; } } // Test generic constraints and inheritance scenarios public class GenericConstraintTest where T : class { private T value; public GenericConstraintTest(T val) { value = val; } public bool IsNull() { return value == null; } public static int TestGenericConstraints() { var test = new GenericConstraintTest("hello"); if (test.IsNull()) return 1; var nullTest = new GenericConstraintTest(null); if (!nullTest.IsNull()) return 2; return 0; } } // Test generic field access scenarios mentioned in the diff public class GenericFieldAccess { public static T DefaultValue = default(T); public static int TestStaticGenericField() { // Test that static fields work correctly with generics if (GenericFieldAccess.DefaultValue != 0) return 1; // Test that different instantiations have different static fields GenericFieldAccess.DefaultValue = 42; if (GenericFieldAccess.DefaultValue != 42) return 2; if (GenericFieldAccess.DefaultValue != null) return 3; return 0; } } class Program { static int Main(string[] args) { int result; result = GenericParameterEdgeCases.TestMultipleGenericParameters(); if (result != 0) return 100 + result; result = GenericParameterEdgeCases.TestNestedGenericMethodCalls(); if (result != 0) return 200 + result; result = DeepNestingTest.TestDeeplyNestedGenerics(); if (result != 0) return 300 + result; result = GenericConstraintTest.TestGenericConstraints(); if (result != 0) return 400 + result; result = GenericFieldAccess.TestStaticGenericField(); if (result != 0) return 500 + result; return 0; // All tests passed } }