container icon indicating copy to clipboard operation
container copied to clipboard

Optional ref & out parameters

Open ENikS opened this issue 6 years ago • 0 comments

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)
        }

ENikS avatar Sep 10 '20 19:09 ENikS