public CallableCodeGenerator(IGeneratorRegistry generators, IDocumentationLinker documentation, ExternalDocCommentsReader docReader, GlobalNamespaceProvider globalNamespace, Logger logger)
     : base(documentation, docReader)
 {
     Generators           = generators;
     this.globalNamespace = globalNamespace;
     this.logger          = logger;
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TransformManager"/> class.
        /// </summary>
        public TransformManager(
            GlobalNamespaceProvider globalNamespace,
            NamingRulesManager namingRules,
            Logger logger,
            TypeRegistry typeRegistry,
            IDocumentationLinker docLinker,
            ConstantManager constantManager,
            AssemblyManager assemblyManager)
        {
            GlobalNamespace          = globalNamespace;
            Logger                   = logger;
            NamingRules              = namingRules;
            this.docLinker           = docLinker;
            this.typeRegistry        = typeRegistry;
            this.constantManager     = constantManager;
            this.assemblyManager     = assemblyManager;
            namespaceRegistry        = new NamespaceRegistry(logger, assemblyManager);
            marshalledElementFactory = new MarshalledElementFactory(Logger, GlobalNamespace, typeRegistry);

            EnumTransform = new EnumTransform(namingRules, logger, namespaceRegistry, typeRegistry);

            StructTransform = new StructTransform(namingRules, logger, namespaceRegistry, typeRegistry, marshalledElementFactory);

            FunctionTransform = new MethodTransform(namingRules, logger, groupRegistry, marshalledElementFactory, globalNamespace, typeRegistry);

            InterfaceTransform = new InterfaceTransform(namingRules, logger, globalNamespace, FunctionTransform, FunctionTransform, typeRegistry, namespaceRegistry);
        }
        public static string ReplaceCRefReferences(this IDocumentationLinker linker, Match match)
        {
            var matchName = match.Groups[1].Value;
            var csName    = linker.FindDocName(matchName);

            // Tries to match with W::
            if (csName == null && regexWithMethodW.Match(matchName).Success)
            {
                csName = linker.FindDocName(regexWithMethodW.Replace(matchName, "$1W::"));
            }

            // Or with W
            if (csName == null && regexWithTypeW.Match(matchName).Success)
            {
                csName = linker.FindDocName(regexWithTypeW.Replace(matchName, "$1W"));
            }

            if (csName == null)
            {
                return(matchName);
            }

            if (csName.StartsWith("<"))
            {
                return(csName);
            }
            return(string.Format(CultureInfo.InvariantCulture, "<see cref=\"{0}\"/>", csName));
        }
Example #4
0
 public DefaultGenerators(
     GlobalNamespaceProvider globalNamespace,
     IDocumentationLinker documentation,
     ExternalDocCommentsReader docReader,
     GeneratorConfig config,
     Logger logger)
 {
     Constant              = new ConstantCodeGenerator();
     Property              = new PropertyCodeGenerator(this, documentation, docReader);
     Enum                  = new EnumCodeGenerator(documentation, docReader);
     ExplicitOffsetField   = new FieldCodeGenerator(documentation, docReader, true);
     AutoLayoutField       = new FieldCodeGenerator(documentation, docReader, false);
     Struct                = new StructCodeGenerator(this, documentation, docReader);
     NativeStruct          = new NativeStructCodeGenerator(this, globalNamespace);
     NativeInvocation      = new NativeInvocationCodeGenerator(this, globalNamespace);
     Callable              = new CallableCodeGenerator(this, documentation, docReader, globalNamespace, logger);
     Method                = new MethodCodeGenerator(this);
     Function              = new FunctionCodeGenerator(this);
     Interface             = new InterfaceCodeGenerator(this, documentation, docReader, globalNamespace);
     Group                 = new GroupCodeGenerator(this, documentation, docReader);
     LocalInterop          = new LocalInteropCodeGenerator(this);
     InteropMethod         = new InteropMethodCodeGenerator();
     ShadowCallable        = new ShadowCallbackGenerator(this, globalNamespace);
     ReverseCallableProlog = new ReverseCallablePrologCodeGenerator(this, globalNamespace);
     Vtbl                  = new VtblGenerator(this, globalNamespace);
     Shadow                = new ShadowGenerator(this, globalNamespace);
     Marshalling           = new MarshallingRegistry(globalNamespace, logger);
     Config                = config;
 }
Example #5
0
    public override void FillDocItems(IList <string> docItems, IDocumentationLinker manager)
    {
        string doc;

        foreach (var param in PublicParameters)
        {
            doc = manager.GetSingleDoc(param);
            if (string.IsNullOrEmpty(doc) || doc == DefaultNoDescription)
            {
                continue;
            }

            docItems.Add("<param name=\"" + param.Name + "\">" + doc + "</param>");
        }

        if (!HasReturnType)
        {
            return;
        }

        doc = manager.GetSingleDoc(ActualReturnValue);
        if (string.IsNullOrEmpty(doc) || doc == DefaultNoDescription)
        {
            return;
        }

        docItems.Add("<returns>" + doc + "</returns>");
    }
Example #6
0
        public override void FillDocItems(IList <string> docItems, IDocumentationLinker manager)
        {
            foreach (var param in PublicParameters)
            {
                docItems.Add("<param name=\"" + param.Name + "\">" + manager.GetSingleDoc(param) + "</param>");
            }

            if (HasReturnType)
            {
                docItems.Add("<returns>" + GetReturnTypeDoc(manager) + "</returns>");
            }
        }
Example #7
0
        private void GenerateCode(IDocumentationLinker docAggregator, CsAssembly asm, ExternalDocCommentsReader docCommentsReader)
        {
            var generator = new RoslynGenerator(Logger, GlobalNamespace, docAggregator, docCommentsReader, new GeneratorConfig {
                Platforms = PlatformDetectionType.Any
            });

            generator.Run(asm, _generatedPath, GeneratedCodeFolder);

            // Update check files for all assemblies
            var processTime = DateTime.Now;

            File.WriteAllText(Path.Combine(IntermediateOutputPath, asm.CheckFileName), "");
            File.SetLastWriteTime(Path.Combine(IntermediateOutputPath, asm.CheckFileName), processTime);
        }
        public static IEnumerable <string> GetDocItems(this IDocumentationLinker aggregator, ExternalDocCommentsReader reader, CsBase element)
        {
            var docItems = new List <string>();

            var externalCommentsPath = reader.GetDocumentWithExternalComments(element);

            if (externalCommentsPath == null)
            {
                var description = element.Description;
                var remarks     = element.Remarks;

                description = RegexSpaceBegin.Replace(description, "$1");

                description = RegexLink.Replace(description, aggregator.ReplaceCRefReferences);
                // evaluator => "<see cref=\"$1\"/>"

                docItems.Add("<summary>");
                docItems.AddRange(description.Split('\n'));
                docItems.Add("</summary>");

                element.FillDocItems(docItems, aggregator);

                if (!string.IsNullOrEmpty(remarks))
                {
                    remarks = RegexSpaceBegin.Replace(remarks, "$1");
                    remarks = RegexLink.Replace(remarks, aggregator.ReplaceCRefReferences);

                    docItems.Add("<remarks>");
                    docItems.AddRange(remarks.Split('\n'));
                    docItems.Add("</remarks>");
                }
            }
            else
            {
                docItems.Add($"<include file='{externalCommentsPath}' path=\"{ExternalDocCommentsReader.GetCodeCommentsXPath(element)}/*\" />");
            }

            if (element.CppElementName != null)
            {
                if (element.DocId != null)
                {
                    docItems.Add("<doc-id>" + EscapeXml(element.DocId) + "</doc-id>");
                }
                docItems.Add("<unmanaged>" + EscapeXml(element.DocUnmanagedName) + "</unmanaged>");
                docItems.Add("<unmanaged-short>" + EscapeXml(element.DocUnmanagedShortName) + "</unmanaged-short>");
            }

            return(docItems);
        }
Example #9
0
        private void GenerateCode(IDocumentationLinker docAggregator, CsSolution solution, ExternalDocCommentsReader docCommentsReader)
        {
            var generator = new RoslynGenerator(Logger, GlobalNamespace, docAggregator, docCommentsReader);

            generator.Run(solution, _generatedPath, GeneratedCodeFolder, IncludeAssemblyNameFolder);

            // Update check files for all assemblies
            var processTime = DateTime.Now;

            foreach (CsAssembly assembly in solution.Assemblies)
            {
                File.WriteAllText(Path.Combine(IntermediateOutputPath, assembly.CheckFileName), "");
                File.SetLastWriteTime(Path.Combine(IntermediateOutputPath, assembly.CheckFileName), processTime);
            }
        }
        public static string GetSingleDoc(this IDocumentationLinker aggregator, CsBase element)
        {
            var description = element.Description;

            if (RegexLinkStart.Match(description).Success)
            {
                description = RegexLinkStart.Replace(description, "$1");
            }

            description = RegexSpaceBegin.Replace(description, "$1");

            description = RegexLink.Replace(description, aggregator.ReplaceCRefReferences);

            var docItems = new StringBuilder();

            foreach (var line in description.Split('\n'))
            {
                docItems.Append(line);
            }

            return(docItems.ToString());
        }
Example #11
0
 public GroupCodeGenerator(IGeneratorRegistry generators, IDocumentationLinker documentation, ExternalDocCommentsReader reader)
     : base(documentation, reader)
 {
     Generators = generators;
 }
Example #12
0
 public StructCodeGenerator(IGeneratorRegistry generators, IDocumentationLinker documentation, ExternalDocCommentsReader docReader)
     : base(documentation, docReader)
 {
     Generators = generators;
 }
 protected MemberCodeGeneratorBase(IDocumentationLinker documentation, ExternalDocCommentsReader docReader)
 {
     docAggregator  = documentation;
     this.docReader = docReader;
 }
Example #14
0
 public RoslynGenerator(Logger logger, GlobalNamespaceProvider globalNamespace, IDocumentationLinker documentation, ExternalDocCommentsReader docReader)
 {
     Logger = logger;
     this.globalNamespace = globalNamespace;
     Generators = new DefaultGenerators(globalNamespace, documentation, docReader, logger);
 }
 public EnumCodeGenerator(IDocumentationLinker documentation, ExternalDocCommentsReader docReader) : base(documentation, docReader)
 {
 }
 public FieldCodeGenerator(IDocumentationLinker documentation, ExternalDocCommentsReader docReader, bool explicitLayout)
     : base(documentation, docReader)
 {
     this.explicitLayout = explicitLayout;
 }
Example #17
0
 public virtual void FillDocItems(IList <string> docItems, IDocumentationLinker manager)
 {
 }
Example #18
0
 public RoslynGenerator(Logger logger, GlobalNamespaceProvider globalNamespace, IDocumentationLinker documentation, ExternalDocCommentsReader docReader, GeneratorConfig config)
 {
     this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
     generators  = new DefaultGenerators(globalNamespace, documentation, docReader, config, logger);
 }
Example #19
0
 public ConstantManager(NamingRulesManager namingRules, IDocumentationLinker linker)
 {
     NamingRules         = namingRules;
     DocumentationLinker = linker;
 }
Example #20
0
 public InterfaceCodeGenerator(IGeneratorRegistry generators, IDocumentationLinker documentation, ExternalDocCommentsReader docReader, GlobalNamespaceProvider globalNamespace)
     : base(documentation, docReader)
 {
     Generators           = generators;
     this.globalNamespace = globalNamespace;
 }