Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add support to reference additional DLLs when build metadata with C# source files #9706

Closed
filzrev opened this issue Feb 19, 2024 · 1 comment
Labels
dotnet Generate .NET API reference docs

Comments

@filzrev
Copy link
Contributor

filzrev commented Feb 19, 2024

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.

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.

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));
}

@filzrev
Copy link
Contributor Author

filzrev commented Apr 9, 2024

Close this issue.
#9825 is merged and docfx v2.76.0 is released.

@filzrev filzrev closed this as completed Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet Generate .NET API reference docs
Projects
None yet
Development

No branches or pull requests

2 participants