Skip to content

Commit 893f794

Browse files
authored
chore: add System.Text.Json attributes (#9341)
* chore: add JsonExtensionData attribute of System.Text.Json * chore: add JsonIgnore attribute of System.Text.Json * chore: add JsonConstructor attribute of System.Text.Json * chore: add Newtonsoft.Json namespace qualifier of JsonConverter * chore: add JsonPropertyName attribute of System.Text.Json
1 parent 0af0b34 commit 893f794

File tree

100 files changed

+941
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+941
-131
lines changed

src/Docfx.App/Config/BuildJsonConfig.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Text.Json.Serialization;
45
using Docfx.Common;
56
using Docfx.Plugins;
67

@@ -18,24 +19,28 @@ internal class BuildJsonConfig
1819
/// Contains all the files to generate documentation, including metadata yml files and conceptual md files.
1920
/// </summary>
2021
[JsonProperty("content")]
22+
[JsonPropertyName("content")]
2123
public FileMapping Content { get; set; }
2224

2325
/// <summary>
2426
/// Contains all the resource files that conceptual and metadata files dependent on, e.g. image files.
2527
/// </summary>
2628
[JsonProperty("resource")]
29+
[JsonPropertyName("resource")]
2730
public FileMapping Resource { get; set; }
2831

2932
/// <summary>
3033
/// Contains all the conceptual files which contains yaml header with uid and is intended to override the existing metadata yml files.
3134
/// </summary>
3235
[JsonProperty("overwrite")]
36+
[JsonPropertyName("overwrite")]
3337
public FileMapping Overwrite { get; set; }
3438

3539
/// <summary>
3640
/// Specifies the urls of xrefmap used by content files. Supports local file path and HTTP/HTTPS urls.
3741
/// </summary>
3842
[JsonProperty("xref")]
43+
[JsonPropertyName("xref")]
3944
public ListWithStringFallback Xref { get; set; }
4045

4146
/// <summary>
@@ -44,26 +49,30 @@ internal class BuildJsonConfig
4449
/// </summary>
4550
[Obsolete("Use output instead.")]
4651
[JsonProperty("dest")]
52+
[JsonPropertyName("dest")]
4753
public string Dest { get; set; }
4854

4955
/// <summary>
5056
/// Defines the output folder of the generated build files.
5157
/// Command line --output argument override this value.
5258
/// </summary>
5359
[JsonProperty("output")]
60+
[JsonPropertyName("output")]
5461
public string Output { get; set; }
5562

5663
/// <summary>
5764
/// Contains metadata that will be applied to every file, in key-value pair format.
5865
/// </summary>
5966
[JsonProperty("globalMetadata")]
60-
[JsonConverter(typeof(JObjectDictionaryToObjectDictionaryConverter))]
67+
[JsonPropertyName("globalMetadata")]
68+
[Newtonsoft.Json.JsonConverter(typeof(JObjectDictionaryToObjectDictionaryConverter))]
6169
public Dictionary<string, object> GlobalMetadata { get; set; }
6270

6371
/// <summary>
6472
/// Specify a list of JSON file path containing globalMetadata settings.
6573
/// </summary>
6674
[JsonProperty("globalMetadataFiles")]
75+
[JsonPropertyName("globalMetadataFiles")]
6776
public ListWithStringFallback GlobalMetadataFiles { get; set; } = new ListWithStringFallback();
6877

6978
/// <summary>
@@ -74,12 +83,14 @@ internal class BuildJsonConfig
7483
/// The value is the value of the metadata.
7584
/// </summary>
7685
[JsonProperty("fileMetadata")]
86+
[JsonPropertyName("fileMetadata")]
7787
public Dictionary<string, FileMetadataPairs> FileMetadata { get; set; }
7888

7989
/// <summary>
8090
/// Specify a list of JSON file path containing fileMetadata settings.
8191
/// </summary>
8292
[JsonProperty("fileMetadataFiles")]
93+
[JsonPropertyName("fileMetadataFiles")]
8394
public ListWithStringFallback FileMetadataFiles { get; set; } = new ListWithStringFallback();
8495

8596
/// <summary>
@@ -88,6 +99,7 @@ internal class BuildJsonConfig
8899
/// If omitted, embedded default template will be used.
89100
/// </summary>
90101
[JsonProperty("template")]
102+
[JsonPropertyName("template")]
91103
public ListWithStringFallback Template { get; set; } = new ListWithStringFallback();
92104

93105
/// <summary>
@@ -98,6 +110,7 @@ internal class BuildJsonConfig
98110
/// If omitted, no theme will be applied, the default theme inside the template will be used.
99111
/// </summary>
100112
[JsonProperty("theme")]
113+
[JsonPropertyName("theme")]
101114
public ListWithStringFallback Theme { get; set; }
102115

103116
/// <summary>
@@ -110,6 +123,7 @@ internal class BuildJsonConfig
110123
/// </code>
111124
/// </example>
112125
[JsonProperty("postProcessors")]
126+
[JsonPropertyName("postProcessors")]
113127
public ListWithStringFallback PostProcessors { get; set; } = new ListWithStringFallback();
114128

115129
/// <summary>
@@ -118,64 +132,74 @@ internal class BuildJsonConfig
118132
/// If not specified, it is false
119133
/// </summary>
120134
[JsonProperty("debug")]
135+
[JsonPropertyName("debug")]
121136
public bool? Debug { get; set; }
122137

123138
/// <summary>
124139
/// The output folder for files generated for debugging purpose when in debug mode.
125140
/// If not specified, it is ${TempPath}/docfx
126141
/// </summary>
127142
[JsonProperty("debugOutput")]
143+
[JsonPropertyName("debugOutput")]
128144
public string DebugOutput { get; set; }
129145

130146
/// <summary>
131147
/// If set to true, data model to run template script will be extracted in .raw.model.json extension.
132148
/// </summary>
133149
[JsonProperty("exportRawModel")]
150+
[JsonPropertyName("exportRawModel")]
134151
public bool? ExportRawModel { get; set; }
135152

136153
/// <summary>
137154
/// Specify the output folder for the raw model.
138155
/// If not set, the raw model will be generated to the same folder as the output documentation.
139156
/// </summary>
140157
[JsonProperty("rawModelOutputFolder")]
158+
[JsonPropertyName("rawModelOutputFolder")]
141159
public string RawModelOutputFolder { get; set; }
142160

143161
/// <summary>
144162
/// If set to true, data model to apply template will be extracted in .view.model.json extension.
145163
/// </summary>
146164
[JsonProperty("exportViewModel")]
165+
[JsonPropertyName("exportViewModel")]
147166
public bool? ExportViewModel { get; set; }
148167

149168
/// <summary>
150169
/// Specify the output folder for the view model.
151170
/// If not set, the view model will be generated to the same folder as the output documentation.
152171
/// </summary>
153172
[JsonProperty("viewModelOutputFolder")]
173+
[JsonPropertyName("viewModelOutputFolder")]
154174
public string ViewModelOutputFolder { get; set; }
155175

156176
/// <summary>
157177
/// If set to true, template will not be actually applied to the documents.
158178
/// This option is always used with --exportRawModel or --exportViewModel is set so that only raw model files or view model files are generated.
159179
/// </summary>
160180
[JsonProperty("dryRun")]
181+
[JsonPropertyName("dryRun")]
161182
public bool? DryRun { get; set; }
162183

163184
/// <summary>
164185
/// Set the max parallelism, 0 is auto.
165186
/// </summary>
166187
[JsonProperty("maxParallelism")]
188+
[JsonPropertyName("maxParallelism")]
167189
public int? MaxParallelism { get; set; }
168190

169191
/// <summary>
170192
/// Set the parameters for markdown engine, value should be a JSON string.
171193
/// </summary>
172194
[JsonProperty("markdownEngineProperties")]
195+
[JsonPropertyName("markdownEngineProperties")]
173196
public MarkdownServiceProperties MarkdownEngineProperties { get; set; }
174197

175198
/// <summary>
176199
/// Set the name of ICustomHrefGenerator derived class.
177200
/// </summary>
178201
[JsonProperty("customLinkResolver")]
202+
[JsonPropertyName("customLinkResolver")]
179203
public string CustomLinkResolver { get; set; }
180204

181205
/// <summary>
@@ -192,25 +216,29 @@ internal class BuildJsonConfig
192216
/// </code>
193217
/// </example>
194218
[JsonProperty("groups")]
219+
[JsonPropertyName("groups")]
195220
public Dictionary<string, GroupConfig> Groups { get; set; }
196221

197222
/// <summary>
198223
/// If set to true, docfx does not dereference (aka. copy) file to the output folder.
199224
/// Instead, it saves a link_to_path property inside manifest.json to indicate the physical location of that file.
200225
/// </summary>
201226
[JsonProperty("keepFileLink")]
227+
[JsonPropertyName("keepFileLink")]
202228
public bool KeepFileLink { get; set; }
203229

204230
/// <summary>
205231
/// Specifies the options for the sitemap.xml file.
206232
/// </summary>
207233
[JsonProperty("sitemap")]
234+
[JsonPropertyName("sitemap")]
208235
public SitemapOptions Sitemap { get; set; }
209236

210237
/// <summary>
211238
/// Disable fetching Git related information for articles.
212239
/// By default it is enabled and may have side effect on performance when the repo is large.
213240
/// </summary>
214241
[JsonProperty("disableGitFeatures")]
242+
[JsonPropertyName("disableGitFeatures")]
215243
public bool DisableGitFeatures { get; set; }
216244
}

src/Docfx.App/Config/FileMetadataPairs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Docfx;
1010
/// </summary>
1111
/// <see cref="BuildJsonConfig.FileMetadata"/>
1212
/// <see cref="MergeJsonItemConfig.FileMetadata"/>
13-
[JsonConverter(typeof(FileMetadataPairsConverter))]
13+
[Newtonsoft.Json.JsonConverter(typeof(FileMetadataPairsConverter))]
1414
internal class FileMetadataPairs
1515
{
1616
// Order matters, the latter one overrides the former one

src/Docfx.App/Config/GroupConfig.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Text.Json.Serialization;
45
using Newtonsoft.Json;
56

67
namespace Docfx;
@@ -14,11 +15,13 @@ internal class GroupConfig
1415
/// Defines the output folder of the generated build files.
1516
/// </summary>
1617
[JsonProperty("dest")]
18+
[JsonPropertyName("dest")]
1719
public string Destination { get; set; }
1820

1921
/// <summary>
2022
/// Extension metadata.
2123
/// </summary>
22-
[JsonExtensionData]
24+
[Newtonsoft.Json.JsonExtensionData]
25+
[System.Text.Json.Serialization.JsonExtensionData]
2326
public Dictionary<string, object> Metadata { get; set; } = new Dictionary<string, object>();
2427
}

src/Docfx.App/Config/ListWithStringFallback.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Docfx;
88
/// <summary>
99
/// ListWithStringFallback.
1010
/// </summary>
11-
[JsonConverter(typeof(ListWithStringFallbackConverter))]
11+
[Newtonsoft.Json.JsonConverter(typeof(ListWithStringFallbackConverter))]
1212
internal class ListWithStringFallback : List<string>
1313
{
1414
/// <summary>

src/Docfx.App/Config/MergeJsonConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Docfx;
88
/// <summary>
99
/// MergeJsonConfig.
1010
/// </summary>
11-
[JsonConverter(typeof(MergeJsonConfigConverter))]
11+
[Newtonsoft.Json.JsonConverter(typeof(MergeJsonConfigConverter))]
1212
internal class MergeJsonConfig : List<MergeJsonItemConfig>
1313
{
1414
/// <summary>

src/Docfx.App/Config/MergeJsonItemConfig.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Text.Json.Serialization;
45
using Docfx.Common;
56

67
using Newtonsoft.Json;
@@ -16,19 +17,22 @@ internal class MergeJsonItemConfig
1617
/// Defines the files to merge.
1718
/// </summary>
1819
[JsonProperty("content")]
20+
[JsonPropertyName("content")]
1921
public FileMapping Content { get; set; }
2022

2123
/// <summary>
2224
/// Defines the output folder of the generated merge files.
2325
/// </summary>
2426
[JsonProperty("dest")]
27+
[JsonPropertyName("dest")]
2528
public string Destination { get; set; }
2629

2730
/// <summary>
2831
/// Contains metadata that will be applied to every file, in key-value pair format.
2932
/// </summary>
3033
[JsonProperty("globalMetadata")]
31-
[JsonConverter(typeof(JObjectDictionaryToObjectDictionaryConverter))]
34+
[JsonPropertyName("globalMetadata")]
35+
[Newtonsoft.Json.JsonConverter(typeof(JObjectDictionaryToObjectDictionaryConverter))]
3236
public Dictionary<string, object> GlobalMetadata { get; set; }
3337

3438
/// <summary>
@@ -39,11 +43,13 @@ internal class MergeJsonItemConfig
3943
/// The value is the value of the metadata.
4044
/// </summary>
4145
[JsonProperty("fileMetadata")]
46+
[JsonPropertyName("fileMetadata")]
4247
public Dictionary<string, FileMetadataPairs> FileMetadata { get; set; }
4348

4449
/// <summary>
4550
/// Metadata that applies to toc files.
4651
/// </summary>
4752
[JsonProperty("tocMetadata")]
53+
[JsonPropertyName("tocMetadata")]
4854
public ListWithStringFallback TocMetadata { get; set; }
4955
}

0 commit comments

Comments
 (0)