dotnet / dotnet/docfx

Merge section in docfx.json does not support more than one merge operation

Open
#2,286 1 comment 3 reactions 0 assignees View on GitHub
dotnet
Dominant language
C#
Stars
4.4k
Forks
890
Avg merge
2h 11m
Merged PRs (30d)
10

Description

**DocFX Version Used**: 2.28.2

**Steps to Reproduce**:

I am combining two C# projects into a single web site, so I use the following `docfx.json`,
```
{
"metadata": [
{
"src": [
{
"files": [
"sharpsnmplib/SharpSnmpLib/*.csproj"
],
"exclude": [
"**/bin/**",
"**/obj/**"
],
"cwd": "."
}
],
"properties": {
"TargetFramework": "net452"
},
"dest": "obj/lib/10.0.2_net452/api",
"shouldSkipMarkup": true
},
{
"src": [
{
"files": [
"sharpsnmplib/SharpSnmpLib/*.csproj"
],
"exclude": [
"**/bin/**",
"**/obj/**"
],
"cwd": "."
}
],
"properties": {
"TargetFramework": "netstandard1.3"
},
"dest": "obj/lib/10.0.2_netstandard1.3/api",
"shouldSkipMarkup": true
},
{
"src": [
{
"files": [
"sharpmibsuite/SharpSnmpPro.Mib/*.csproj"
],
"exclude": [
"**/bin/**",
"**/obj/**"
],
"cwd": "."
}
],
"properties": {
"TargetFramework": "net452"
},
"dest": "obj/pro/2.0.0_net452/api",
"shouldSkipMarkup": true,
"filter": "filterConfig.yml"
},
{
"src": [
{
"files": [
"sharpmibsuite/SharpSnmpPro.Mib/*.csproj"
],
"exclude": [
"**/bin/**",
"**/obj/**"
],
"cwd": "."
}
],
"properties": {
"TargetFramework": "netstandard2.0"
},
"dest": "obj/pro/2.0.0_netstandard2.0/api",
"shouldSkipMarkup": true,
"filter": "filterConfig.yml"
}
],
...
```
Then I can use the following to merge the documents for sharpsnmplib,
```
"merge": {
"content": [
{
"files": "*.yml",
"src": "obj/lib/10.0.2_netstandard1.3/api"
},
{
"files": "*.yml",
"src": "obj/lib/10.0.2_net452/api"
}
],
"fileMetadata": {
"platform": {
"obj/lib/10.0.2_netstandard1.3/api/*.yml": [
"netstandard1.3"
],
"obj/lib/10.0.2_net452/api/*.yml": [
"net452"
]
}
},
"dest": "obj/lib/10.0.2/api"
},
```

> I hit a null reference exception (which should have been fixed 17 days ago, but not shipped in this release).

**Expected Behavior**:
I should be able to specify another merge operation, to merge metadata for sharpmibsuite.

**Actual Behavior**:
I cannot use multiple "merge" sections, which makes docfx stop working miserably. It is surprising the docfx does not generate any error but just stops in the middle of something.

I cannot use `[]` either. The following changes in docfx.json would lead to an error,
```
"merge": [
{
"content": [
{
"files": "*.yml",
"src": "obj/lib/10.0.2_netstandard1.3/api"
},
{
"files": "*.yml",
"src": "obj/lib/10.0.2_net452/api"
}
],
"fileMetadata": {
"platform": {
"obj/lib/10.0.2_netstandard1.3/api/*.yml": [
"netstandard1.3"
],
"obj/lib/10.0.2_net452/api/*.yml": [
"net452"
]
}
},
"dest": "obj/lib/10.0.2/api"
},
{
"content": [
{
"files": "*.yml",
"src": "obj/pro/2.0.0_netstandard2.0/api"
},
{
"files": "*.yml",
"src": "obj/pro/2.0.0_net452/api"
}
],
"fileMetadata": {
"platform": {
"obj/pro/2.0.0_netstandard2.0/api/*.yml": [
"netstandard2.0"
],
"obj/pro/2.0.0_net452/api/*.yml": [
"net452"
]
}
},
"dest": "obj/pro/2.0.0/api"
}
],
```
The error message is
```
[17-12-10 11:01:08.132]Info:Config file docfx.json found, start generating metadata...
[17-12-10 11:01:08.165]Error:Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Microsoft.DocAsCode.MergeJsonConfig' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from
a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path 'merge', line 82, position 12.
```
You should support multiple merge operations somehow, as you already support multiple metadata operations.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.