Open
Description
ref
& out
parameters
Unity does not provide support for methods and constructors with ref
& out
parameters.
Problem
If parameter is annotated with OptionalDependency
attribute, the container allows selection of ref
and out
parameters for injection. Neither one of these should be allowed:
public class Optional_Dependency_RefStruct
{
public Optional_Dependency_RefStruct([OptionalDependency] Ref_Struct value)
[InjectionMethod]
public void Method([OptionalDependency] Ref_Struct value) { }
}
public class Optional_Dependency_Ref
{
public Optional_Dependency_Ref([OptionalDependency] ref SomeType value)
[InjectionMethod]
public void Method([OptionalDependency] ref SomeType value)
}
public class Optional_Dependency_Out
{
public Optional_Dependency_Out([OptionalDependency] out SomeType value)
[InjectionMethod]
public void Method([OptionalDependency] out SomeType value)
}