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 for AllowUnsafeBlocks in properties #10174

Closed
andywiecko opened this issue Aug 29, 2024 · 0 comments · Fixed by #10175
Closed

[Feature Request] Add support for AllowUnsafeBlocks in properties #10174

andywiecko opened this issue Aug 29, 2024 · 0 comments · Fixed by #10175

Comments

@andywiecko
Copy link

Hi,
I would like to request a feature enhancement to add support for the "AllowUnsafeBlocks" within the "properties" section of docfx.json.

According to the documentation, the "properties" section:

Specifies an optional set of MSBuild properties used when interpreting project files. These are the same properties that are passed to MSBuild via the /property:name=value command line argument.

However, it seems that "AllowUnsafeBlocks" is currently not supported. From my understanding, adding support for this would require a small modification in the following file:

private static CS.CSharpParseOptions GetCSharpParseOptions(IDictionary<string, string> msbuildProperties)
{
var preprocessorSymbols = (msbuildProperties.TryGetValue("DefineConstants", out var defineConstants))
? defineConstants.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
: null;
return new CS.CSharpParseOptions(preprocessorSymbols: preprocessorSymbols);
}

Here’s a minimal working example that demonstrates the issue:

  • Program.cs
namespace Test
{
    public static class Program
    {
        public static unsafe void Main() { }
    }
}
  • docfx.json
{
  "metadata": [
    {
      "src": [{"src": "./", "files": ["Program.cs"]}],
      "dest": "api",
      "properties": { "AllowUnsafeBlocks": true }
    }
  ]
}

Expected behavior:

The api documentation should generate correctly without any errors or warnings.

Current behavior:

The build fails with errors/warnings, (unless one set "allowCompilationErrors": true).


Thank you for considering this request. I believe it would be a valuable addition.

Best,
Andrzej

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant