Skip to content

Commit

Permalink
use Newtonsoft instead of System.Text.Json (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: vdungsrikaew <[email protected]>
  • Loading branch information
virasak and virasakagoda authored Jul 6, 2023
1 parent 80ff768 commit d4cc6b8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
5 changes: 4 additions & 1 deletion src/Agoda.DevFeedback.Common/Agoda.DevFeedback.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.2" />
<InternalsVisibleTo Include="Agoda.DevFeedback.Common.Tests" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
30 changes: 15 additions & 15 deletions src/Agoda.DevFeedback.Common/DevFeedbackData.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
using System;
using System.Text.Json.Serialization;
using Newtonsoft.Json;

namespace Agoda.DevFeedback.Common
{
public class DevFeedbackData
{
[JsonPropertyName("id")]
[JsonProperty("id")]
public Guid Id { get; set; }

[JsonPropertyName("metricsVersion")]
[JsonProperty("metricsVersion")]
public string MetricsVersion { get; set; }

[JsonPropertyName("userName")]
[JsonProperty("userName")]
public string UserName { get; set; }

[JsonPropertyName("cpuCount")]
[JsonProperty("cpuCount")]
public int CpuCount { get; set; }

[JsonPropertyName("hostname")]
[JsonProperty("hostname")]
public string Hostname { get; set; }

[JsonPropertyName("platform")]
[JsonProperty("platform")]
public PlatformID Platform { get; set; }

[JsonPropertyName("os")]
[JsonProperty("os")]
public string Os { get; set; }

[JsonPropertyName("timeTaken")]
[JsonProperty("timeTaken")]
public string TimeTaken { get; set; }

[JsonPropertyName("branch")]
[JsonProperty("branch")]
public string Branch { get; set; }

[JsonPropertyName("type")]
[JsonProperty("type")]
public string Type { get; set; }

[JsonPropertyName("projectName")]
[JsonProperty("projectName")]
public string ProjectName { get; set; }

[JsonPropertyName("repository")]
[JsonProperty("repository")]
public string Repository { get; set; }

[JsonPropertyName("repositoryName")]
[JsonProperty("repositoryName")]
public string RepositoryName { get; set; }

[JsonPropertyName("date")]
[JsonProperty("date")]
public DateTime Date { get; set; }

public DevFeedbackData(
Expand Down
4 changes: 2 additions & 2 deletions src/Agoda.DevFeedback.Common/DevFeedbackPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Agoda.DevFeedback.Common
{
Expand Down Expand Up @@ -46,7 +46,7 @@ public static async Task PublishAsync(string apiEndpoint, object data, DevLocalD
using (var httpClient = new HttpClient())
{
httpClient.Timeout = TimeSpan.FromSeconds(2);
var content = new StringContent(JsonSerializer.Serialize(data), Encoding.UTF8, "application/json");
var content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
var response = await httpClient.PostAsync(targetEndpoint, content);
response.EnsureSuccessStatusCode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="nunit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="nunit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
Expand Down

0 comments on commit d4cc6b8

Please sign in to comment.