From 7e99d44b52eb1f5d6cbd8797ebf6c9ac8c4b1e7d Mon Sep 17 00:00:00 2001 From: Thomas Nind <31306100+tznind@users.noreply.github.com> Date: Wed, 24 Mar 2021 17:15:03 +0000 Subject: [PATCH] Fixed CreateClass to create a generic MyClass when MyClass is passed (#1153) --- UICatalog/Scenarios/AllViewsTester.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs index 635eae25f..4cea78d2f 100644 --- a/UICatalog/Scenarios/AllViewsTester.cs +++ b/UICatalog/Scenarios/AllViewsTester.cs @@ -344,6 +344,20 @@ namespace UICatalog { View CreateClass (Type type) { + // If we are to create a generic Type + if (type.IsGenericType) { + + // For each of the arguments + List typeArguments = new List (); + + // use + foreach (var arg in type.GetGenericArguments ()) { + typeArguments.Add (typeof (object)); + } + + // And change what type we are instantiating from MyClass to MyClass + type = type.MakeGenericType (typeArguments.ToArray ()); + } // Instantiate view var view = (View)Activator.CreateInstance (type);