Esempio n. 1
0
        private void ProcessGenericType(ITypeDefinition cl, StreamWriter classesSW,
                                        IModule mod, ISet <ITypeDefinition> processedTypes)
        {
            IGenericTypeInstance gcl = cl as IGenericTypeInstance;

            if (gcl != null && !processedTypes.Contains(gcl))
            {
                INamedTypeDefinition         templateType = gcl.GenericType.ResolvedType;
                IEnumerable <ITypeReference> genArgs      = gcl.GenericArguments;
                string argStr = "";
                foreach (ITypeReference ty in genArgs)
                {
                    ITypeDefinition tyDefn = ty.ResolvedType;
                    if (tyDefn is IGenericTypeInstance)
                    {
                        IModule mod1 = TypeHelper.GetDefiningUnit(tyDefn) as IModule;
                        ProcessGenericType(tyDefn, classesSW, mod1, processedTypes);
                    }
                    else
                    {
                        if (!processedTypes.Contains(tyDefn))
                        {
                            IModule mod1 = TypeHelper.GetDefiningUnit(tyDefn) as IModule;
                            classesSW.WriteLine("CLASS:" + tyDefn.FullName() + " ARGS:" + " MODULE:" + mod1.Name.Value);
                            processedTypes.Add(tyDefn);
                        }
                    }
                    argStr += tyDefn.FullName() + ";";
                }
                if (!argStr.Equals(""))
                {
                    argStr = argStr.TrimEnd(';');
                }

                IDictionary <string, ITypeDefinition> nestedTypeMap = new Dictionary <string, ITypeDefinition>();
                FillNestedTypeMap(gcl, nestedTypeMap, "", false);
                int nestedCnt = nestedTypeMap.Count;
                if (nestedCnt > 0)
                {
                    classesSW.WriteLine("CLASS:" + templateType.FullName() + " ARGS:" + argStr + " MODULE:" + mod.Name.Value +
                                        " NESTED_CNT:" + nestedCnt);
                }
                else
                {
                    classesSW.WriteLine("CLASS:" + templateType.FullName() + " ARGS:" + argStr + " MODULE:" + mod.Name.Value);
                }
                processedTypes.Add(gcl);
                foreach (KeyValuePair <string, ITypeDefinition> entry in nestedTypeMap)
                {
                    classesSW.WriteLine("CLASS:" + templateType.FullName() + " ARGS:" + argStr + " MODULE:" + mod.Name.Value +
                                        " NESTED_CLASS:" + entry.Key);
                    processedTypes.Add(entry.Value);
                }
            }
        }
Esempio n. 2
0
 protected override TypeMetricsReport AnalyzeType(INamedTypeDefinition type, PdbReader pdb, IEnumerable<MethodMetricsReport> methods)
 {
     return new TypeMetricsReport
     {
         Name = type.Name(),
         FullName = type.FullName(),
         Namespaces = type.Namespaces(),
         CompilerGenerated = type.IsGeneratedCode(),
         NumberOfNonStaticPublicFields = NumberOfNonStaticPublicFields.Of(type),
         NumberOfMethods = NumberOfMethods.Of(type),
         DirectDependencies = DirectDependencies.Of(type, methods)
     };
 }
Esempio n. 3
0
        public static IEnumerable <string> Of(INamedTypeDefinition type, IEnumerable <MethodMetricsReport> methods)
        {
            var typesOfMethods   = GetMethodTypes(methods).ToList();
            var typesOfFields    = GetFieldTypes(type.Fields).ToList();
            var typesOfAncestors = GetAncestorTypes(type).ToList();
            var typesOfGenerics  = GetGenericConstraints(type).ToList();

            return(Enumerable.Empty <string>()
                   .Union(type.FullName().Return())
                   .Union(typesOfMethods)
                   .Union(typesOfFields)
                   .Union(typesOfAncestors)
                   .Union(typesOfGenerics)
                   .ToList());
        }
Esempio n. 4
0
 protected override TypeMetricsReport AnalyzeType(INamedTypeDefinition type, PdbReader pdb, IEnumerable <MethodMetricsReport> methods)
 {
     return(new TypeMetricsReport
     {
         Name = type.Name(),
         FullName = type.FullName(),
         SourceLocation = SourceCodeLocating.OfType(type, pdb),
         Namespaces = type.Namespaces(),
         CompilerGenerated = type.IsGeneratedCode(),
         NumberOfFields = NumberOfFields.Of(type),
         NumberOfNonStaticPublicFields = NumberOfFields.NotStaticAndPublic(type),
         NumberOfMethods = NumberOfMethods.Of(type),
         DirectDependencies = DirectDependencies.Of(type, methods)
     });
 }
Esempio n. 5
0
        public static IEnumerable<string> Of(INamedTypeDefinition type, IEnumerable<MethodMetricsReport> methods)
        {
            var typesOfMethods = GetMethodTypes(methods).ToList();
            var typesOfFields = GetFieldTypes(type.Fields).ToList();
            var typesOfAncestors = GetAncestorTypes(type).ToList();
            var typesOfGenerics = GetGenericConstraints(type).ToList();

            return Enumerable.Empty<string>()
                .Union(type.FullName().Return())
                .Union(typesOfMethods)
                .Union(typesOfFields)
                .Union(typesOfAncestors)
                .Union(typesOfGenerics)
                .ToList();
        }
Esempio n. 6
0
            private void AddTypeForward(Assembly assembly, INamedTypeDefinition seedType)
            {
                var alias = new NamespaceAliasForType();

                alias.AliasedType = ConvertDefinitionToReferenceIfTypeIsNested(seedType, _seedHost);
                alias.IsPublic    = true;

                if (assembly.ExportedTypes == null)
                {
                    assembly.ExportedTypes = new List <IAliasForType>();
                }
                // Make sure that the typeforward doesn't already exist in the ExportedTypes
                if (!assembly.ExportedTypes.Any(t => t.AliasedType.RefDocId() == alias.AliasedType.RefDocId()))
                {
                    assembly.ExportedTypes.Add(alias);
                }
                else
                {
                    throw new FacadeGenerationException($"{seedType.FullName()} typeforward already exists");
                }
            }
Esempio n. 7
0
            private void AddTypeForward(Assembly assembly, INamedTypeDefinition seedType)
            {
                var alias = new NamespaceAliasForType();
                alias.AliasedType = ConvertDefinitionToReferenceIfTypeIsNested(seedType, _seedHost);
                alias.IsPublic = true;

                if (assembly.ExportedTypes == null)
                    assembly.ExportedTypes = new List<IAliasForType>();
                // Make sure that the typeforward doesn't already exist in the ExportedTypes
                if (!assembly.ExportedTypes.Any(t => t.AliasedType.RefDocId() == alias.AliasedType.RefDocId()))
                    assembly.ExportedTypes.Add(alias);
                else
                    throw new FacadeGenerationException($"{seedType.FullName()} typeforward already exists");
            }