Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove usage of Newtonsoft.Json #2017

Merged
merged 10 commits into from
Jan 20, 2020
16 changes: 4 additions & 12 deletions src/GitVersionCore/BuildServers/AppVeyor.cs
Expand Up @@ -2,7 +2,6 @@
using System.Net.Http;
using GitVersion.OutputVariables;
using GitVersion.Logging;
using Newtonsoft.Json;
using System.Text;

namespace GitVersion.BuildServers
Expand All @@ -23,12 +22,9 @@ public override string GenerateSetVersionMessage(VersionVariables variables)

using var httpClient = GetHttpClient();

var body = new
{
version = $"{variables.FullSemVer}.build.{buildNumber}",
};
var body = $"{{\"version\":\"{variables.FullSemVer}.build.{buildNumber}\"}}";

var stringContent = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
var stringContent = new StringContent(body, Encoding.UTF8, "application/json");
var response = httpClient.PutAsync("api/build", stringContent).GetAwaiter().GetResult();
response.EnsureSuccessStatusCode();

Expand All @@ -39,13 +35,9 @@ public override string[] GenerateSetParameterMessage(string name, string value)
{
var httpClient = GetHttpClient();

var body = new
{
name = $"GitVersion_{name}",
value = $"{value}"
};
var body = $"{{\"name\": \"GitVersion_{name}\",\"value\": \"{value}\"}}";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt we need to evaluate whether value is an Integer or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure?

Copy link
Contributor Author

@jetersen jetersen Jan 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before it was going through JsonConvert.SerializeObject as object with the value of value = $"{value}" ergo it was turned into strings. The serialized JSON is unchanged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Let's tackle that in a separate PR, if at all.


var stringContent = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
var stringContent = new StringContent(body, Encoding.UTF8, "application/json");
var response = httpClient.PostAsync("api/build/variables", stringContent).GetAwaiter().GetResult();
response.EnsureSuccessStatusCode();

Expand Down
1 change: 0 additions & 1 deletion src/GitVersionCore/GitVersionCore.csproj
Expand Up @@ -25,7 +25,6 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Newtonsoft.Json" Version="$(PackageVersion_NewtonsoftJson)" />
<PackageReference Include="System.Net.Requests" Version="4.3.0" />
</ItemGroup>

Expand Down
1 change: 0 additions & 1 deletion src/GitVersionTask/nuget-files.props
Expand Up @@ -17,7 +17,6 @@

<None Include="$(CorePublish)/GitVersion*" Pack="true" PackagePath="$(CoreTarget)" />
<None Include="$(CorePublish)/LibGit2Sharp.dll" Pack="true" PackagePath="$(CoreTarget)" />
<None Include="$(CorePublish)/Newtonsoft.Json.dll" Pack="true" PackagePath="$(CoreTarget)" />
<None Include="$(CorePublish)/YamlDotNet.dll" Pack="true" PackagePath="$(CoreTarget)" />
<None Include="$(CorePublish)/Microsoft.Extensions*" Pack="true" PackagePath="$(CoreTarget)" />

Expand Down