-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-markdig-extension-override2
- Loading branch information
Showing
12 changed files
with
229 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Text.Json.Serialization; | ||
using Newtonsoft.Json; | ||
using YamlDotNet.Serialization; | ||
|
||
namespace Docfx.Build.Engine; | ||
|
||
public class XRefMapRedirection | ||
{ | ||
[YamlMember(Alias = "uidPrefix")] | ||
[JsonProperty("uidPrefix")] | ||
[JsonPropertyName("uidPrefix")] | ||
public string UidPrefix { get; set; } | ||
|
||
[YamlMember(Alias = "href")] | ||
[JsonProperty("Href")] | ||
[JsonPropertyName("href")] | ||
public string Href { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"references": [ | ||
{ | ||
"fullName": "str", | ||
"href": "https://docs.python.org/3.5/library/stdtypes.html#str", | ||
"name": "str", | ||
"uid": "str" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Text; | ||
using Docfx.Common; | ||
using Docfx.Plugins; | ||
using FluentAssertions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Docfx.Build.Engine.Tests; | ||
|
||
public class XRefMapSerializationTest | ||
{ | ||
[Fact] | ||
public void XRefMapSerializationRoundTripTest() | ||
{ | ||
var model = new XRefMap | ||
{ | ||
BaseUrl = "http://localhost", | ||
Sorted = true, | ||
HrefUpdated = null, | ||
Redirections = new List<XRefMapRedirection> | ||
{ | ||
new XRefMapRedirection | ||
{ | ||
Href = "Dummy", | ||
UidPrefix = "Dummy" | ||
}, | ||
}, | ||
References = new List<XRefSpec> | ||
{ | ||
new XRefSpec(new Dictionary<string,object> | ||
{ | ||
["Additional1"] = "Dummy", | ||
}) | ||
{ | ||
Uid = "Dummy", | ||
Name = "Dummy", | ||
Href = "Dummy", | ||
CommentId ="Dummy", | ||
IsSpec = true, | ||
}, | ||
}, | ||
Others = new Dictionary<string, object> | ||
{ | ||
["Other1"] = "Dummy", | ||
} | ||
}; | ||
|
||
// Arrange | ||
var jsonResult = RoundtripByNewtonsoftJson(model); | ||
var yamlResult = RoundtripWithYamlDotNet(model); | ||
|
||
// Assert | ||
jsonResult.Should().BeEquivalentTo(model); | ||
yamlResult.Should().BeEquivalentTo(model); | ||
} | ||
|
||
private static T RoundtripByNewtonsoftJson<T>(T model) | ||
{ | ||
var json = JsonUtility.Serialize(model); | ||
return JsonUtility.Deserialize<T>(new StringReader(json)); | ||
} | ||
|
||
private static T RoundtripWithYamlDotNet<T>(T model) | ||
{ | ||
var sb = new StringBuilder(); | ||
using var sw = new StringWriter(sb); | ||
YamlUtility.Serialize(sw, model); | ||
var json = sb.ToString(); | ||
return YamlUtility.Deserialize<T>(new StringReader(json)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.