Skip to content

Commit 2a1a7a3

Browse files
committed
Added Json.Net for Standard 1.5 JSON serialization
1 parent a016947 commit 2a1a7a3

File tree

4 files changed

+364
-25
lines changed

4 files changed

+364
-25
lines changed

src/TestStack.BDDfy/Reporters/Html/ClassicReportBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
45
using System.Net;
56
using System.Text;
@@ -45,7 +46,7 @@ private void HtmlHead()
4546
EmbedCssFile(HtmlReportResources.classic_css_min);
4647
EmbedCssFile(_model.CustomStylesheet, HtmlReportResources.CustomStylesheetComment);
4748

48-
AddLine(string.Format("<title>BDDfy Test Result {0}</title>", _model.RunDate.ToShortDateString()));
49+
AddLine(string.Format("<title>BDDfy Test Result {0}</title>", _model.RunDate.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)));
4950
}
5051
}
5152

src/TestStack.BDDfy/Reporters/Serializers/JsonSerializer.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
using System.Web.Script.Serialization;
2-
31
namespace TestStack.BDDfy.Reporters.Serializers
42
{
3+
#if NET40
4+
using System.Web.Script.Serialization;
5+
56
public class JsonSerializer : ISerializer
67
{
78
public string Serialize(object obj)
@@ -12,4 +13,23 @@ public string Serialize(object obj)
1213
return new JsonFormatter(json).Format();
1314
}
1415
}
16+
17+
#else
18+
using Newtonsoft.Json;
19+
20+
public class JsonSerializer : ISerializer
21+
{
22+
public string Serialize(object obj)
23+
{
24+
return JsonConvert.SerializeObject(obj, Formatting.Indented,
25+
new JsonSerializerSettings
26+
{
27+
NullValueHandling = NullValueHandling.Ignore,
28+
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
29+
});
30+
}
31+
}
32+
33+
#endif
34+
1535
}

src/TestStack.BDDfy/project.json

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
{
2-
"version": "1.0.0-*",
3-
"packOptions": {
4-
},
2+
"version": "1.0.0-*",
3+
"packOptions": {
4+
},
55

6-
"dependencies": {
6+
"dependencies": {
77

8-
},
8+
},
99

10-
"frameworks": {
11-
"net40": {
12-
"dependencies": {
10+
"frameworks": {
11+
"net40": {
12+
"dependencies": {
1313

14-
},
15-
"frameworkAssemblies": {
16-
"System.Web": "4.0.0.0",
17-
"System.Web.Extensions": "4.0.0.0"
18-
}
19-
},
20-
"netstandard1.5": {
21-
"imports": "dnxcore50",
22-
"dependencies": {
23-
"NETStandard.Library": "1.5.0-rc2-24027",
24-
"System.Linq.Expressions": "4.0.11-rc2-24027",
25-
"System.Runtime.Extensions": "4.1.0-rc2-24027"
26-
}
27-
}
14+
},
15+
"frameworkAssemblies": {
16+
"System.Web": "4.0.0.0",
17+
"System.Web.Extensions": "4.0.0.0"
18+
}
19+
},
20+
"netstandard1.5": {
21+
"imports": "dnxcore50",
22+
"dependencies": {
23+
"NETStandard.Library": "1.5.0-rc2-24027",
24+
"Newtonsoft.Json": "9.0.1-beta1",
25+
"System.Linq.Expressions": "4.0.11-rc2-24027",
26+
"System.Runtime.Extensions": "4.1.0-rc2-24027"
27+
}
2828
}
29+
}
2930
}

0 commit comments

Comments
 (0)