Skip to content

Commit

Permalink
Reduce allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sondergaard committed Nov 16, 2023
1 parent ca21554 commit db684de
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ private static Func<bool> ValidateConstructorForType()
/// Creates an instance of <typeparamref name="T" /> using the constructor
/// </summary>
/// <exception cref="InvalidOperationException">is thrown if <typeparamref name="T"/> contains more then one constructor</exception>
public static Func<object?[], T> CreateWithValues =>
typeof(T).GetConstructors().Length > 1 ?
throw new InvalidOperationException("Only one constructor is supported.") :
BuildExpressionForObjectCreation();
public static readonly Func<object?[], T> CreateWithValues = BuildExpressionForObjectCreation();

/// <summary>
/// Builds an expression that creates an instance of <typeparamref name="T" /> using the constructor
Expand Down

0 comments on commit db684de

Please sign in to comment.