Skip to content

Commit 2da8209

Browse files
committed
Remove duplication by delegating calls to CreateDefaultImmutableInstance<T>(Type[]) to the overloaded function CreateDefaultImmutableInstance(Type, Type[]) which has the same code and logic.
1 parent 0158942 commit 2da8209

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Diff for: src/CommandLine/Infrastructure/ReflectionHelper.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,8 @@ public static bool IsFSharpOptionType(Type type)
8484

8585
public static T CreateDefaultImmutableInstance<T>(Type[] constructorTypes)
8686
{
87-
var t = typeof(T);
88-
var ctor = t.GetTypeInfo().GetConstructor(constructorTypes);
89-
var values = (from prms in ctor.GetParameters()
90-
select prms.ParameterType.CreateDefaultForImmutable()).ToArray();
91-
return (T)ctor.Invoke(values);
87+
var t = typeof(T);
88+
return (T)CreateDefaultImmutableInstance(t, constructorTypes);
9289
}
9390

9491
public static object CreateDefaultImmutableInstance(Type type, Type[] constructorTypes)

0 commit comments

Comments
 (0)