dotnet / dotnet/command-line-api

User-Types not Being Instantiated when using CommandHandler.Create(MethodInfo method)

Open
#637 0 comments 0 reactions 0 assignees View on GitHub
Area-Parser and Binder
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

From #632 :

Even if the constructor requirement for user types is fully satisfied (i.e. it has a public constructor accepting just `string` as its only parameter), commands whose handler has been created via `CommandHandler.Create(MethodInfo method)`, or equivalently any other Func/Action-based overload thereof, do not still instantiate user types when those types are used as arguments, i.e.:

```
public static void CustomCommand(UserTypedArgument arg1, bool option1 = true) {
//UserTypedArgument is null here even if it has a public constructor accepting string that has been called
}
```

The constructors do get called, however the created instances are never passed onto the method, which receives them as nulls.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.