Mono.Cecil.TypeResolver.HandleOwnerlessInvalidILCode C# (CSharp) Method

HandleOwnerlessInvalidILCode() private method

private HandleOwnerlessInvalidILCode ( Mono.Cecil.GenericParameter genericParameter ) : TypeReference
genericParameter Mono.Cecil.GenericParameter
return TypeReference
        private TypeReference HandleOwnerlessInvalidILCode(GenericParameter genericParameter)
        {
            // NOTE: If owner is null and we have a method parameter, then we'll assume that the method parameter
            // is actually a type parameter, and we'll use the type parameter from the corresponding position. I think
            // this assumption is valid, but if you're visiting this code then I might have been proven wrong.
            if (genericParameter.Type == GenericParameterType.Method && (_typeDefinitionContext != null && genericParameter.Position < _typeDefinitionContext.GenericArguments.Count))
                return _typeDefinitionContext.GenericArguments[genericParameter.Position];

            // NOTE: Owner cannot be null, but sometimes the Mono compiler generates invalid IL and we
            // end up in this situation.
            // When we do, we assume that the runtime doesn't care about the resolved type of the GenericParameter,
            // thus we return a reference to System.Object.
            return genericParameter.Module.TypeSystem.Object;
        }