diff --git a/src/ViewFactory.cs b/src/ViewFactory.cs index 94713d32..ac906cd7 100644 --- a/src/ViewFactory.cs +++ b/src/ViewFactory.cs @@ -259,6 +259,14 @@ static void SetDefaultDimensions( T v, int width = 5, int height = 1 ) [Obsolete( "Migrate to using generic Create method" )] public static View Create( Type requestedType ) { + if (requestedType.IsGenericType) + { + var method = typeof(ViewFactory).GetMethods().Single(m=>m.Name=="Create" && m.IsGenericMethodDefinition); + method = method.MakeGenericMethod(requestedType) ?? throw new Exception("Could not find Create method on ViewFactory"); + + return (View)(method.Invoke(null, new object?[] { null, null, null }) ?? throw new Exception("ViewFactory.Create resulted in null")); + } + return requestedType switch { null => throw new ArgumentNullException( nameof( requestedType ) ),