Skip to content

Commit a4b7505

Browse files
committed
feat: Removed GenericScriptableObject.CreateInstance(Type genericTypeWithoutTypeParams, params Type[] paramTypes)
The generic type can be easily assembled outside of the method with help of genericTypeDefinition.MakeGenericType(paramTypes). There is no need in this specific method overload.
1 parent 3ae2b20 commit a4b7505

1 file changed

Lines changed: 0 additions & 32 deletions

File tree

Runtime/GenericScriptableObject.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,5 @@ public class GenericScriptableObject : ScriptableObject
4242
{
4343
return (T) CreateInstance(typeof(T));
4444
}
45-
46-
/// <summary>
47-
/// Creates an instance of <see cref="GenericScriptableObject"/> using a generic type definition
48-
/// (generic type without generic argument types) and an array of generic argument types.
49-
/// </summary>
50-
/// <param name="genericTypeWithoutTypeParams">
51-
/// Generic type derived from <see cref="GenericScriptableObject"/> without generic argument types (e.g. Generic&lt;,>).
52-
/// </param>
53-
/// <param name="paramTypes">Types of the generic arguments.</param>
54-
/// <returns>
55-
/// Instance of <paramref name="genericTypeWithoutTypeParams"/> with param types <paramref name="paramTypes"/>>.
56-
/// </returns>
57-
/// <exception cref="ArgumentException">
58-
/// If the number of generic argument types passed into the method is not equal to the number of generic
59-
/// arguments the type can take.
60-
/// </exception>
61-
[PublicAPI, CanBeNull, Pure]
62-
public static GenericScriptableObject CreateInstance(Type genericTypeWithoutTypeParams, params Type[] paramTypes)
63-
{
64-
int genericArgCount = genericTypeWithoutTypeParams.GetGenericArguments().Length;
65-
int paramTypesCount = paramTypes.Length;
66-
67-
if (genericArgCount != paramTypesCount)
68-
{
69-
throw new ArgumentException(
70-
$"Number of generic argument types ({paramTypesCount}) is not equal to the number of " +
71-
$"generic arguments the type can take ({genericArgCount}).", nameof(genericTypeWithoutTypeParams));
72-
}
73-
74-
Type genericType = genericTypeWithoutTypeParams.MakeGenericType(paramTypes);
75-
return (GenericScriptableObject) CreateInstance(genericType);
76-
}
7745
}
7846
}

0 commit comments

Comments
 (0)