From a38b75c9c1e0b005ad00b7838686d30cbf8d2f86 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sat, 30 Nov 2019 07:21:09 +0100 Subject: [PATCH] Output: struct/class must be the first generic type constraint (CS0449) --- Il2CppInspector/Reflection/TypeInfo.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Il2CppInspector/Reflection/TypeInfo.cs b/Il2CppInspector/Reflection/TypeInfo.cs index c4ebe14..6c07d0a 100644 --- a/Il2CppInspector/Reflection/TypeInfo.cs +++ b/Il2CppInspector/Reflection/TypeInfo.cs @@ -865,10 +865,12 @@ namespace Il2CppInspector.Reflection { var constraintList = typeConstraints.Where(c => c.FullName != "System.ValueType").Select(c => c.GetScopedCSharpName(scope)).ToList(); + // struct or class must be the first constraint specified if ((GenericParameterAttributes & GenericParameterAttributes.NotNullableValueTypeConstraint) == GenericParameterAttributes.NotNullableValueTypeConstraint) - constraintList.Add("struct"); + constraintList.Insert(0, "struct"); if ((GenericParameterAttributes & GenericParameterAttributes.ReferenceTypeConstraint) == GenericParameterAttributes.ReferenceTypeConstraint) - constraintList.Add("class"); + constraintList.Insert(0, "class"); + if ((GenericParameterAttributes & GenericParameterAttributes.DefaultConstructorConstraint) == GenericParameterAttributes.DefaultConstructorConstraint && !constraintList.Contains("struct")) // new() must be the last constraint specified