Skip to content

Commit c62a025

Browse files
committed
chore: add MetadataJsonConfig JSON roundtrip test
1 parent 80d10a7 commit c62a025

File tree

5 files changed

+132
-0
lines changed

5 files changed

+132
-0
lines changed

src/Docfx.Common/Json/JsonUtility.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ private static bool IsSupported()
9191
{
9292
// TODO: Return `true` for types that support serialize/deserializenon with System.Text.Json.
9393
case "Docfx.BuildJsonConfig":
94+
case "Docfx.MetadataJsonConfig":
9495
case "Docfx.MergeJsonConfig":
9596

9697
case "Docfx.Build.Engine.XRefMap":

src/Docfx.Dotnet/MetadataJsonConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ internal class MetadataJsonItemConfig
272272
/// </summary>
273273
internal class MetadataJsonConfig : List<MetadataJsonItemConfig>
274274
{
275+
// Constructor that required for System.Text.Json deserialization.
276+
public MetadataJsonConfig() { }
277+
275278
/// <summary>
276279
/// Initializes a new instance of the <see cref="MetadataJsonConfig"/> class.
277280
/// </summary>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Docfx;
5+
using Docfx.Common;
6+
using FluentAssertions;
7+
8+
namespace docfx.Tests;
9+
10+
public partial class JsonSerializationTest
11+
{
12+
[Theory]
13+
[TestData<MetadataJsonConfig>]
14+
public void JsonSerializationTest_MetadataJsonConfig(string path)
15+
{
16+
// Arrange
17+
var model = TestData.Load<MetadataJsonConfig>(path);
18+
19+
// Act/Assert
20+
ValidateJsonRoundTrip(model);
21+
}
22+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[
2+
{
3+
"src": [
4+
{
5+
"files": [
6+
"assembly/bin/**/*.dll",
7+
"project/**/*.csproj",
8+
"solution/**/*.sln",
9+
"csharp/**/*.cs",
10+
"vb/**/*.vb"
11+
],
12+
"exclude": [
13+
"project/Project.Core/**"
14+
],
15+
"src": "dotnet"
16+
}
17+
],
18+
"output": "obj/api",
19+
"outputFormat": "apiPage",
20+
"shouldSkipMarkup": false,
21+
"references": [
22+
"refs/dummy.dll"
23+
],
24+
"filter": "filterConfig.yml",
25+
"includePrivateMembers": true,
26+
"includeExplicitInterfaceImplementations": true,
27+
"globalNamespaceId": "Global",
28+
"properties": {
29+
"DefineConstants": "dummy1, dummy2",
30+
"TargetFrameworks": "dummy"
31+
},
32+
"disableGitFeatures": false,
33+
"codeSourceBasePath": "dummy",
34+
"disableDefaultFilter": true,
35+
"noRestore": true,
36+
"categoryLayout": "nested",
37+
"namespaceLayout": "nested",
38+
"memberLayout": "separatePages",
39+
"enumSortOrder": "declaringOrder",
40+
"allowCompilationErrors": true
41+
}
42+
]
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[
2+
{
3+
"src": [
4+
{
5+
"files": [
6+
"assembly/bin/**/*.dll",
7+
"project/**/*.csproj",
8+
"solution/**/*.sln",
9+
"csharp/**/*.cs",
10+
"vb/**/*.vb"
11+
],
12+
"exclude": [
13+
"project/Project.Core/**"
14+
],
15+
"src": "dotnet"
16+
}
17+
],
18+
"namespaceLayout": "nested",
19+
"enumSortOrder": "declaringOrder",
20+
"output": "obj/api"
21+
},
22+
{
23+
"src": [
24+
{
25+
"files": [
26+
"assembly/bin/**/*.dll",
27+
"project/**/*.csproj",
28+
"solution/**/*.sln",
29+
"csharp/**/*.cs",
30+
"vb/**/*.vb"
31+
],
32+
"exclude": [
33+
"project/Project.Core/**"
34+
],
35+
"src": "dotnet"
36+
}
37+
],
38+
"namespaceLayout": "nested",
39+
"enumSortOrder": "declaringOrder",
40+
"outputFormat": "markdown",
41+
"output": "obj/md"
42+
},
43+
{
44+
"src": [
45+
{
46+
"files": [
47+
"assembly/bin/**/*.dll",
48+
"project/**/*.csproj",
49+
"solution/**/*.sln",
50+
"csharp/**/*.cs",
51+
"vb/**/*.vb"
52+
],
53+
"exclude": [
54+
"project/Project.Core/**"
55+
],
56+
"src": "dotnet"
57+
}
58+
],
59+
"namespaceLayout": "nested",
60+
"enumSortOrder": "declaringOrder",
61+
"outputFormat": "apiPage",
62+
"output": "obj/apipage"
63+
}
64+
]

0 commit comments

Comments
 (0)