예제 #1
0
        static void Main(string[] args)
        {
            var result = Parser.Default.ParseArguments<DependecyOptions, AssemblyAnalyzerOptions>(args)
                .WithParsed<DependecyOptions>(options =>
                {
                    var assemblyProcessor = new AssemblyProcessor(options.Path, options.RecursionLimit);
                    ProcessAssemblyGraph(options, assemblyProcessor);
                    ProcessTypeGraph(options, assemblyProcessor);

                    Logger.Info("Done.");
                })
                .WithParsed<AssemblyAnalyzerOptions>(options =>
                {
                    var assemblyProcessor = new AssemblyProcessor(options.Path);
                    var assembly = assemblyProcessor.Assembly;

                    var info = new Dictionary<string, string>
                    {
                        { "Assembly name", assembly.FullyQualifiedName},
                        { "Architecture", assembly.Module.Architecture.ToString() },
                        { "Runtime version", assembly.Module.RuntimeVersion },
                        { "Has resources", assembly.Module.HasResources.ToString() }
                    };


                    foreach (var entry in info)
                    {
                        Logger.Info($"{entry.Key}: {entry.Value}");
                    }

                    Logger.Info("Done.");
                });
        }
예제 #2
0
 static void ProcessTypeGraph(DependecyOptions options, AssemblyProcessor assemblyProcessor)
 {
     if (options.GenerateTypeGraph)
     {
         Logger.Info("Generating type reference graph...");
         var graph = assemblyProcessor.GetReferencedTypesGraph();
         if (!string.IsNullOrWhiteSpace(options.TypeGraphFileName))
         {
             Logger.Debug($"Writing type reference graph into file: {options.AssemblyGraphFileName}");
             File.WriteAllText(options.AssemblyGraphFileName, graph);
         }
         else
         {
             Logger.Info(graph);
         }
     }
 }