Exemplo n.º 1
0
        private static async Task Main(string[] args)
        {
            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(r => Options = r);

            var assembly = Assembly.LoadFrom(Options.AssemblyPath);

            var generator = new ModuleDocumentationGenerator(assembly, Options.OutputPath);
            await generator.GenerateDocumentationAsync();
        }
Exemplo n.º 2
0
        private static async Task Main(string[] args)
        {
            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(r => _options = r);

            if (_options is null)
            {
                return;
            }

            var modules   = _options.AssemblyPaths.Select(ModuleDefinition.ReadModule);
            var generator = new ModuleDocumentationGenerator(modules, _options.OutputPath);
            await generator.GenerateDocumentationAsync();
        }
Exemplo n.º 3
0
        private static async Task Main(string[] args)
        {
            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(r => _options = r);

            if (_options is null)
            {
                return;
            }

            // Set up the assembly resolver
            var additionalResolverPaths = _options.AssemblyPaths.Select(Path.GetDirectoryName).Distinct();
            var resolver = new DefaultAssemblyResolver();

            foreach (var additionalResolverPath in additionalResolverPaths)
            {
                resolver.AddSearchDirectory(additionalResolverPath);
            }

            var placeholderData = new PlaceholderData();

            var modules = _options.AssemblyPaths.Select
                          (
                ap => ModuleDefinition.ReadModule(ap, new ReaderParameters {
                AssemblyResolver = resolver
            })
                          ).ToArray();

            var placeholderDataAttributes = modules
                                            .Where(m => m.Assembly.HasCustomAttributes)
                                            .SelectMany(m => m.Assembly.CustomAttributes)
                                            .Where(c => c.AttributeType.FullName == typeof(PlaceholderDataAttribute).FullName);

            foreach (var placeholderDataAttribute in placeholderDataAttributes)
            {
                var dataType     = ((TypeReference)placeholderDataAttribute.ConstructorArguments[0].Value).Resolve();
                var placeholders = ((CustomAttributeArgument[])placeholderDataAttribute.ConstructorArguments[1].Value)
                                   .Select(a => (string)a.Value).ToArray();

                placeholderData.RegisterPlaceholderData(dataType, placeholders);
            }

            var generator = new ModuleDocumentationGenerator(modules, _options.OutputPath, placeholderData);
            await generator.GenerateDocumentationAsync();
        }