forked from serilog-contrib/serilog-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build): missing sonarcloud csharp coverage (serilog-contrib#92)
- Loading branch information
1 parent
44fc5c7
commit 44b8c6c
Showing
10 changed files
with
107 additions
and
72 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
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
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
110 changes: 55 additions & 55 deletions
110
src/Serilog.Ui.ElasticSearchProvider/Extensions/VanillaSerializer.cs
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,56 +1,56 @@ | ||
using Elasticsearch.Net; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Serilog.Ui.ElasticSearchProvider | ||
{ | ||
internal class VanillaSerializer : IElasticsearchSerializer | ||
{ | ||
public T Deserialize<T>(Stream stream) => (T)Deserialize(typeof(T), stream); | ||
|
||
public object Deserialize(Type type, Stream stream) | ||
{ | ||
var reader = new StreamReader(stream); | ||
|
||
using (var jsonTextReader = new JsonTextReader(reader)) | ||
{ | ||
var serializer = new JsonSerializer(); | ||
return serializer.Deserialize(jsonTextReader, type); | ||
} | ||
} | ||
|
||
public Task<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default) => | ||
Task.FromResult(Deserialize<T>(stream)); | ||
|
||
public Task<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default) => | ||
Task.FromResult(Deserialize(type, stream)); | ||
|
||
public void Serialize<T>(T data, Stream stream, SerializationFormatting formatting = SerializationFormatting.Indented) | ||
{ | ||
var writer = new StreamWriter(stream); | ||
|
||
using (var jWriter = new JsonTextWriter(writer)) | ||
{ | ||
var serializer = new JsonSerializer | ||
{ | ||
Formatting = formatting == SerializationFormatting.Indented ? Formatting.Indented : Formatting.None | ||
}; | ||
serializer.Serialize(jWriter, data); | ||
} | ||
} | ||
|
||
public Task SerializeAsync<T>( | ||
T data, | ||
Stream stream, | ||
SerializationFormatting formatting = SerializationFormatting.Indented, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
Serialize(data, stream, formatting); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
using Elasticsearch.Net; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Serilog.Ui.ElasticSearchProvider | ||
{ | ||
internal class VanillaSerializer : IElasticsearchSerializer | ||
{ | ||
public T Deserialize<T>(Stream stream) => (T)Deserialize(typeof(T), stream); | ||
|
||
public object Deserialize(Type type, Stream stream) | ||
{ | ||
var reader = new StreamReader(stream); | ||
|
||
using (var jsonTextReader = new JsonTextReader(reader)) | ||
{ | ||
var serializer = new JsonSerializer(); | ||
return serializer.Deserialize(jsonTextReader, type); | ||
} | ||
} | ||
|
||
public Task<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default) => | ||
Task.FromResult(Deserialize<T>(stream)); | ||
|
||
public Task<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default) => | ||
Task.FromResult(Deserialize(type, stream)); | ||
|
||
public void Serialize<T>(T data, Stream stream, SerializationFormatting formatting = SerializationFormatting.None) | ||
{ | ||
var writer = new StreamWriter(stream); | ||
|
||
using (var jWriter = new JsonTextWriter(writer)) | ||
{ | ||
var serializer = new JsonSerializer | ||
{ | ||
Formatting = formatting == SerializationFormatting.Indented ? Formatting.Indented : Formatting.None | ||
}; | ||
serializer.Serialize(jWriter, data); | ||
} | ||
} | ||
|
||
public Task SerializeAsync<T>( | ||
T data, | ||
Stream stream, | ||
SerializationFormatting formatting = SerializationFormatting.None, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
Serialize(data, stream, formatting); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
} |