Ejemplo n.º 1
0
        static private ISet <T> ReadDefinitionsFromIdentifierFile <T>(string path, DocumentationCommentDefinitionIdStringMap idMap)
        {
            ISet <T> result = new HashSet <T>();

            try {
                using (StreamReader infile = new StreamReader(path)) {
                    string identifier;
                    while (null != (identifier = infile.ReadLine()))
                    {
                        if (identifier != "")
                        {
                            IEnumerable <IDefinition> definitionsWithIdentifier = idMap.GetDefinitionsWithIdentifier(identifier);

                            if (definitionsWithIdentifier.Count() == 1)
                            {
                                IDefinition definition = definitionsWithIdentifier.First();
                                result.Add((T)definition);
                            }
                            else
                            {
                                throw new System.Exception("Found " + definitionsWithIdentifier.Count() + " definitions with identifier " + identifier);
                            }
                        }
                    }
                }
            }
            catch (IOException) {
                Console.WriteLine("Couldn't read definitions from {0}", path);
                Environment.Exit(-1);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public ISet <IMethodReference> GetEntryPoints(WholeProgram wholeProgram)
        {
            // Read entry points from provided file
            string entrypointsFileContents = System.IO.File.ReadAllText(pathToFile);

            // Creating the map is expensive; perhaps should cache in wholeProgram?

            DocumentationCommentDefinitionIdStringMap idMap = new DocumentationCommentDefinitionIdStringMap(wholeProgram.AllAssemblies());

            return(new HashSet <IMethodReference>(idMap.CreateEntryPointListFromString(entrypointsFileContents)));
        }
Ejemplo n.º 3
0
        static internal AssemblyReport CreateAssemblyReportFromPath(IAssembly assembly, string pathToReportsDirectory, DocumentationCommentDefinitionIdStringMap idMap)
        {
            AssemblyReport report = new AssemblyReport(assembly);

            string assemblyReportDirectory = GetAssemblyReportDirectory(assembly, pathToReportsDirectory);

            report.reachableTypes.UnionWith(ReadDefinitionsFromIdentifierFile <ITypeDefinition>(assemblyReportDirectory + @"\" + ReachableTypesFileName, idMap));
            report.unreachableTypes.UnionWith(ReadDefinitionsFromIdentifierFile <ITypeDefinition>(assemblyReportDirectory + @"\" + UnusedTypesFileName, idMap));

            report.reachableMethods.UnionWith(ReadDefinitionsFromIdentifierFile <IMethodDefinition>(assemblyReportDirectory + @"\" + ReachableMethodsFileName, idMap));
            report.unreachableMethods.UnionWith(ReadDefinitionsFromIdentifierFile <IMethodDefinition>(assemblyReportDirectory + @"\" + UnusedMethodsFileName, idMap));

            report.reachableFields.UnionWith(ReadDefinitionsFromIdentifierFile <IFieldDefinition>(assemblyReportDirectory + @"\" + ReachableFieldsFileName, idMap));
            report.unreachableFields.UnionWith(ReadDefinitionsFromIdentifierFile <IFieldDefinition>(assemblyReportDirectory + @"\" + UnusedFieldsFileName, idMap));

            return(report);
        }