示例#1
0
        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);
#if !NETSTANDARD
                    FixReferences(genPar.Constraints);
#else
                    FixReferences(genPar);
#endif
                    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);
        }