示例#1
0
        private static void ReadingTypes(IlReader ilReader, out List <IType> newListOfITypes, out SortedDictionary <string, IType> genDefinitionsByMetadataName, out SortedDictionary <IType, IEnumerable <IMethod> > genericMethodSpecializationsSorted)
        {
            // types in current assembly
            var genericTypeSpecializations   = new HashSet <IType>();
            var genericMethodSpecializations = new HashSet <IMethod>();
            var types    = ilReader.Types().Where(t => !t.IsGenericTypeDefinition).ToList();
            var allTypes = ilReader.AllTypes().ToList();

#if !FOR_MSCORLIBTEST_DISABLE_RESORT
            newListOfITypes = ResortITypes(types, genericTypeSpecializations, genericMethodSpecializations);
#else
            var newListOfITypes = allTypes;
#endif
            // build quick access array for Generic Definitions
            genDefinitionsByMetadataName = new SortedDictionary <string, IType>();
            foreach (var genDef in allTypes.Where(t => t.IsGenericTypeDefinition))
            {
                genDefinitionsByMetadataName[genDef.MetadataFullName] = genDef;
            }

            DiscoverAllGenericVirtualMethods(allTypes, genericMethodSpecializations);

            DiscoverAllGenericMethodsOfInterfaces(allTypes, genericMethodSpecializations);

            genericMethodSpecializationsSorted = GroupGenericMethodsByType(genericMethodSpecializations);
        }
示例#2
0
        private static void ReadingTypes(
            IlReader ilReader,
            string[] filter,
            out IList <IType> usedTypes,
            out IDictionary <IType, IEnumerable <IMethod> > genericMethodSpecializationsSorted)
        {
            // clean it as you are using IlReader
            IlReader.GenericMethodSpecializations = null;

            // types in current assembly
            var readingTypesContext = ReadingTypesContext.New();
            var types = ilReader.Types().Where(t => !t.IsGenericTypeDefinition);

            if (filter != null)
            {
                types = types.Where(t => CheckFilter(filter, t));
            }

            var allTypes = ilReader.AllTypes().ToList();

            // TODO: temp hack to initialize ThisType for TypeResolver
            _codeWriter.Initialize(allTypes.First());

            usedTypes = FindUsedTypes(types.ToList(), allTypes, readingTypesContext);

            genericMethodSpecializationsSorted = GroupGenericMethodsByType(readingTypesContext.GenericMethodSpecializations);

            Debug.Assert(usedTypes.All(t => !t.IsByRef), "Type is used with flag IsByRef");
        }