-
Notifications
You must be signed in to change notification settings - Fork 884
Description
Is your feature request related to a problem? Please describe.
It seems C# file based API metadata generation are used by users who use Unity.
- [Bug] How to use the latest docfx with unity / Generate documentation using only source files #9675
- Multiple errors. NormandErwan/DocFxForUnity#28
In this case. It needs to reference additional DLLs that are provided by Unity. (e.g. UnityEngine.dll)
But It seems currently not possible by docfx.json config.
It can generate API metadata partially. When setting "allowCompilationErrors": true.
But some metadata that depends on external DLLs are not generated.
Describe the solution you'd like
Allow additional DLL file references when using C# file based build.
Additional context
Currently CreateCompilationFromCSharpFiles don't support additional references.
But CreateCompilationFromCSharpCode that used test code supports additional DLL references.
docfx/src/Docfx.Dotnet/CompilationHelper.cs
Lines 55 to 71 in 841fcdf
| public static Compilation CreateCompilationFromCSharpFiles(IEnumerable<string> files) | |
| { | |
| return CS.CSharpCompilation.Create( | |
| assemblyName: null, | |
| options: new CS.CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, xmlReferenceResolver: XmlFileResolver.Default), | |
| syntaxTrees: files.Select(path => CS.SyntaxFactory.ParseSyntaxTree(File.ReadAllText(path), path: path)), | |
| references: GetDefaultMetadataReferences("C#")); | |
| } | |
| public static Compilation CreateCompilationFromCSharpCode(string code, string name = null, params MetadataReference[] references) | |
| { | |
| return CS.CSharpCompilation.Create( | |
| name, | |
| options: new CS.CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, xmlReferenceResolver: XmlFileResolver.Default), | |
| syntaxTrees: new[] { CS.SyntaxFactory.ParseSyntaxTree(code) }, | |
| references: GetDefaultMetadataReferences("C#").Concat(references)); | |
| } |