Skip to content

Dependency with a default (null) argument result in InvalidProgramException when targeting net6.0 #386

@WGroenestein

Description

@WGroenestein

When you have a dependency with a default (null) argument and have null injection enabled on the kernel, when targeting net6.0, it will throw an InvalidProgramException (Common Language Runtime detected an invalid program). On net5.0 it succeeds happily.

An example of a dependency with the scenario:

class ClassWithOptionalArgument
{
	public ClassWithOptionalArgument(string keyPrefix = null)
	{
		Console.WriteLine(keyPrefix);
	}
}

A full repro can be found here: Repro repo

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions