We're experiencing an issue similar to #626 "ArgumentNullException when defining a null value for a Nullable parameter", but with a string parameter.
The class we're injecting has a default parameter that sets the string to null: https://github.com/SteeltoeOSS/Management/blob/434c6a10a8bbe79964e3b1c1ab0ebf80c0d70621/src/Steeltoe.Management.EndpointBase/HeapDump/HeapDumper.cs#L34
Because the value is null, we get an exception in the plan builder code here:
|
public static IDependencySource SourceFor(Policies policies, string ctorOrSetter, string name, Type dependencyType, object value) |
`StructureMapBuildPlanException: Unable to create a build plan for concrete type Steeltoe.Management.Endpoint.HeapDump.HeapDumper
new HeapDumper(IHeapDumpOptions, String basePathOverride, ILogger)
┗ IHeapDumpOptions = Default
String basePathOverride = Required primitive dependency is not explicitly defined
ILogger = Default
`
If we set the parameter to default to an empty string, it works fine.
The same behavior occurs with nullable types. We're a bit confused by this behavior -- the default value of strings and nullable types is null, so why is a null value considered an error condition? The same class injects fine using ASP.NET Core built-in DI.
Was considering a PR to allow null strings and nullable types, but that would seem to contradict one of the PR's already merged: e48668a
I not fully following the reasoning behind that PR - if you define a parameter as nullable, doesn't that mean you intend for it to be optional, so a null should be expected and valid? (whether making parameters optional nullable types is a good idea in the first place is a totally separate conversation)
We're experiencing an issue similar to #626 "ArgumentNullException when defining a null value for a Nullable parameter", but with a string parameter.
The class we're injecting has a default parameter that sets the string to null: https://github.com/SteeltoeOSS/Management/blob/434c6a10a8bbe79964e3b1c1ab0ebf80c0d70621/src/Steeltoe.Management.EndpointBase/HeapDump/HeapDumper.cs#L34
Because the value is null, we get an exception in the plan builder code here:
structuremap/src/StructureMap/Building/ConcreteType.cs
Line 133 in a6bf0af
`StructureMapBuildPlanException: Unable to create a build plan for concrete type Steeltoe.Management.Endpoint.HeapDump.HeapDumper
new HeapDumper(IHeapDumpOptions, String basePathOverride, ILogger)
┗ IHeapDumpOptions = Default
String basePathOverride = Required primitive dependency is not explicitly defined
ILogger = Default
`
If we set the parameter to default to an empty string, it works fine.
The same behavior occurs with nullable types. We're a bit confused by this behavior -- the default value of strings and nullable types is null, so why is a null value considered an error condition? The same class injects fine using ASP.NET Core built-in DI.
Was considering a PR to allow null strings and nullable types, but that would seem to contradict one of the PR's already merged: e48668a
I not fully following the reasoning behind that PR - if you define a parameter as nullable, doesn't that mean you intend for it to be optional, so a null should be expected and valid? (whether making parameters optional nullable types is a good idea in the first place is a totally separate conversation)