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

Upgrade to .NET 6, switch to System.Text.Json #17

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
16 changes: 9 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: 2.0.{build}
os: Visual Studio 2017
version: 3.0.{build}
os: Visual Studio 2022
configuration: Release
assembly_info:
dotnet_csproj:
patch: true
file: '**\AssemblyInfo.*'
file: '**\*.csproj'
version: '{version}'
package_version: '{version}'
assembly_version: '{version}'
assembly_file_version: '{version}'
assembly_informational_version: '{version}'
file_version: '{version}'
informational_version: '{version}'

before_build:
- cmd: dotnet --version
Expand All @@ -23,4 +25,4 @@ test: off

artifacts:
- path: .\src\nuget\*.nupkg
name: Libraries NuGet packages
name: Libraries NuGet packages
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ Task("Default")
.Does(()=> {
});

RunTarget(target);
RunTarget(target);
5 changes: 0 additions & 5 deletions global.json

This file was deleted.

10 changes: 2 additions & 8 deletions src/HarSharp.UnitTests/HarSharp.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.7.0">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -15,15 +12,12 @@
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HarSharp\HarSharp.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="Hars\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</Content>
</ItemGroup>

</Project>
4 changes: 0 additions & 4 deletions src/HarSharp.UnitTests/packages.config

This file was deleted.

108 changes: 54 additions & 54 deletions src/HarSharp.sln
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{70A15BB4-14C0-449C-B0A7-B06506F2ED43}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HarSharp", "HarSharp\HarSharp.csproj", "{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HarSharp.UnitTests", "HarSharp.UnitTests\HarSharp.UnitTests.csproj", "{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|x64.ActiveCfg = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|x64.Build.0 = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|x86.ActiveCfg = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|x86.Build.0 = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|Any CPU.Build.0 = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|x64.ActiveCfg = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|x64.Build.0 = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|x86.ActiveCfg = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|x86.Build.0 = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|x64.ActiveCfg = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|x64.Build.0 = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|x86.ActiveCfg = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|x86.Build.0 = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|Any CPU.Build.0 = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|x64.ActiveCfg = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|x64.Build.0 = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|x86.ActiveCfg = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3} = {70A15BB4-14C0-449C-B0A7-B06506F2ED43}
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3} = {70A15BB4-14C0-449C-B0A7-B06506F2ED43}
EndGlobalSection
EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{70A15BB4-14C0-449C-B0A7-B06506F2ED43}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HarSharp", "HarSharp\HarSharp.csproj", "{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HarSharp.UnitTests", "HarSharp.UnitTests\HarSharp.UnitTests.csproj", "{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|x64.ActiveCfg = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|x64.Build.0 = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|x86.ActiveCfg = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Debug|x86.Build.0 = Debug|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|Any CPU.Build.0 = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|x64.ActiveCfg = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|x64.Build.0 = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|x86.ActiveCfg = Release|Any CPU
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3}.Release|x86.Build.0 = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|x64.ActiveCfg = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|x64.Build.0 = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|x86.ActiveCfg = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Debug|x86.Build.0 = Debug|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|Any CPU.Build.0 = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|x64.ActiveCfg = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|x64.Build.0 = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|x86.ActiveCfg = Release|Any CPU
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{22FBDC05-C3A1-44E1-867E-737E59A3F4E3} = {70A15BB4-14C0-449C-B0A7-B06506F2ED43}
{41BAC9B8-18EC-4781-AF33-4D0B820DF9B3} = {70A15BB4-14C0-449C-B0A7-B06506F2ED43}
EndGlobalSection
EndGlobal
17 changes: 14 additions & 3 deletions src/HarSharp/HarConvert.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using System.Text.Json;

namespace HarSharp
{
Expand All @@ -10,6 +10,12 @@ namespace HarSharp
/// </summary>
public static class HarConvert
{
private static readonly JsonSerializerOptions _options = new()
{
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull
};

/// <summary>
/// Deserialize HAR content to a HAR entity.
/// </summary>
Expand All @@ -22,7 +28,7 @@ public static Har Deserialize(string harJson)
throw new ArgumentNullException(nameof(harJson));
}

var result = JsonConvert.DeserializeObject<Har>(harJson);
var result = JsonSerializer.Deserialize<Har>(harJson, _options);

TransformPartialRedirectUrlToFull(result);

Expand All @@ -36,7 +42,12 @@ public static Har Deserialize(string harJson)
/// <returns>The HAR entity.</returns>
public static Har DeserializeFromFile(string fileName)
{
return Deserialize(File.ReadAllText(fileName));
using var stream = File.OpenRead(fileName);
var result = JsonSerializer.Deserialize<Har>(stream, _options);

TransformPartialRedirectUrlToFull(result);

return result;
}

/// <summary>
Expand Down
7 changes: 1 addition & 6 deletions src/HarSharp/HarSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/HarSharp/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public Log()
/// <summary>
/// Gets the pages.
/// </summary>
public IList<Page> Pages { get; private set; }
public IList<Page> Pages { get; set; }

/// <summary>
/// Gets the entries.
/// </summary>
public IList<Entry> Entries { get; private set; }
public IList<Entry> Entries { get; set; }
#endregion
}
}
4 changes: 2 additions & 2 deletions src/HarSharp/MessageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ protected MessageBase()
/// <summary>
/// Gets the list of cookie objects.
/// </summary>
public IList<Cookie> Cookies { get; private set; }
public IList<Cookie> Cookies { get; set; }

/// <summary>
/// Gets the list of header objects.
/// </summary>
public IList<Header> Headers { get; private set; }
public IList<Header> Headers { get; set; }

/// <summary>
/// Gets or sets the total number of bytes from the start of the HTTP request message until (and including) the double CRLF before the body.
Expand Down
2 changes: 1 addition & 1 deletion src/HarSharp/PostData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public PostData()
/// <summary>
/// Gets the list of posted parameters (in case of URL encoded parameters).
/// </summary>
public IList<PostDataParameter> Params { get; private set; }
public IList<PostDataParameter> Params { get; set; }

/// <summary>
/// Gets or sets the plain text posted data.
Expand Down
2 changes: 1 addition & 1 deletion src/HarSharp/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Request()
/// <summary>
/// Gets the list of query parameter objects.
/// </summary>
public IList<QueryStringParameter> QueryString { get; private set; }
public IList<QueryStringParameter> QueryString { get; set; }

/// <summary>
/// Gets or sets the posted data info.
Expand Down