From c7438448231bbdfb34070f308c4dfb3fbddbcbee Mon Sep 17 00:00:00 2001 From: Oluwatoni Solarin-Sodara Date: Mon, 5 Feb 2018 10:29:23 +0100 Subject: [PATCH] add ToJson method to CoverageResult class --- src/coverlet.core/CoverageResult.cs | 12 ++++++++++++ src/coverlet.core/coverlet.core.csproj | 1 + 2 files changed, 13 insertions(+) diff --git a/src/coverlet.core/CoverageResult.cs b/src/coverlet.core/CoverageResult.cs index 74a0f51..9e35027 100644 --- a/src/coverlet.core/CoverageResult.cs +++ b/src/coverlet.core/CoverageResult.cs @@ -1,4 +1,7 @@ using System.Collections.Generic; +using System.IO; + +using Jil; namespace Coverlet.Core { @@ -10,5 +13,14 @@ namespace Coverlet.Core { public string Identifier; public Data Data; + + public string ToJson() + { + using (var writer = new StringWriter()) + { + JSON.Serialize(this.Data, writer, Options.PrettyPrint); + return writer.ToString(); + } + } } } \ No newline at end of file diff --git a/src/coverlet.core/coverlet.core.csproj b/src/coverlet.core/coverlet.core.csproj index 8cd7244..b869432 100644 --- a/src/coverlet.core/coverlet.core.csproj +++ b/src/coverlet.core/coverlet.core.csproj @@ -5,6 +5,7 @@ +