Skip to content

Factory could be replaced with new TThis(); #31

@dbarwikowski

Description

@dbarwikowski

Code could be simplified.

TThis x = Factory();

TThis x = new TThis();

Contents of constructor could be removed then:

static ValueOf()
{
ConstructorInfo ctor = typeof(TThis)
.GetTypeInfo()
.DeclaredConstructors
.First();
var argsExp = new Expression[0];
NewExpression newExp = Expression.New(ctor, argsExp);
LambdaExpression lambda = Expression.Lambda(typeof(Func<TThis>), newExp);
Factory = (Func<TThis>)lambda.Compile();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions