private TypeReference Fix()

in ILRepack/ReferenceFixator.cs [62:95]


        private TypeReference Fix(TypeReference type)
        {
            if (type == null || type.IsDefinition)
                return type;

            if (type.IsGenericParameter)
            {
                var genPar = (GenericParameter)type;
                if (!fixedGenericParameters.Contains(genPar))
                {
                    fixedGenericParameters.Add(genPar);
                    FixReferences(genPar.Constraints);
                    FixReferences(genPar.CustomAttributes);
                }
                return type;
            }

            if (type is TypeSpecification)
                return Fix((TypeSpecification)type);

            type = _repackContext.GetExportedTypeFromTypeRef(type);

            var t2 = _repackContext.GetMergedTypeFromTypeRef(type);
            if (t2 != null)
                return t2;

            if (type.IsNested)
                type.DeclaringType = Fix(type.DeclaringType);

            if (type.DeclaringType is TypeDefinition)
                return ((TypeDefinition)type.DeclaringType).NestedTypes.FirstOrDefault(x => x.FullName == type.FullName);

            return type;
        }