示例#1
0
        static void Run(CommandLineOptions options)
        {
            // Load assemblies.
            var assemblies = new AssemblyCollection(options);

            foreach (var assembly in assemblies.InputAssemblies)
            {
                // Generate C# code containing only the public API surface of each assembly.
                using (var generator = new CodeGenerator(options, assemblies, assembly))
                {
                    generator.GenerateAPISurface(assembly);
                }
            }

            CodeGenerator.WritePlaceholderNamespaceSummaries(options);
        }
示例#2
0
        public AssemblyCollection(CommandLineOptions options)
        {
            // Tell the CLR how to resolve missing assemblies and namespaces.
            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += ReflectionOnlyAssemblyResolve;
            WindowsRuntimeMetadata.ReflectionOnlyNamespaceResolve += ReflectionOnlyNamespaceResolve;

            // Load reference assemblies. We won't process these directly, but need them to resolve symbols used by the main input assemblies.
            referenceAssemblies = options.ReferenceAssemblies.Select(LoadAssembly).ToList();

            // Load the main set of input assemblies.
            inputAssemblies = new List<Assembly>();

            foreach (var input in options.InputAssemblies)
            {
                var assembly = LoadAssembly(input);

                // Force the assembly to resolve all dependent types, to avoid infinite
                // recursion if future assemblies depend on types defined by this one.
                foreach (var type in assembly.DefinedTypes) { }

                inputAssemblies.Add(assembly);
            }
        }
示例#3
0
        static int Main(string[] args)
        {
            // Parse commandline options.
            var options = new CommandLineOptions();
            var parser = new CommandLineParser(options);

            if (!parser.ParseCommandLine(args))
            {
                return 1;
            }

            // Run the program logic.
            try
            {
                Run(options);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error: {0}\n\n{1}:\n{2}", e.Message, e.GetType(), e.StackTrace);
                return 1;
            }

            return 0;
        }