Skip to content

Commit 126f25c

Browse files
author
Martin Boje Carpentier
committed
Updated so it will run with .net standard 2.0
1 parent d0bd715 commit 126f25c

6 files changed

Lines changed: 39 additions & 10 deletions

File tree

.github/workflows/ci-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
with:
2525
dotnet-version: |
2626
3.1.x
27+
4.6.x
2728
5.0.x
2829
6.0.x
2930
- name: Install dependencies

src/GeoJSON.Text.Test.Unit/CoordinateReferenceSystem/DefaultCrsTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public void Can_Deserialize_CRS_issue_89()
4444
public void Can_Serialize_CRS_issue_89()
4545
{
4646
var expected =
47-
"{\"type\":\"Point\",\"coordinates\":[34.56,12.34],\"crs\":{\"properties\":{\"name\":\"TEST NAME\"},\"type\":\"name\"}}";
48-
var point = new Point(new Position(12.34, 34.56)) { CRS = new NamedCRS("TEST NAME") };
47+
"{\"type\":\"Point\",\"coordinates\":[34.57,12.35],\"crs\":{\"properties\":{\"name\":\"TEST NAME\"},\"type\":\"name\"}}";
48+
var point = new Point(new Position(12.35, 34.57)) { CRS = new NamedCRS("TEST NAME") };
4949

5050
var json = JsonSerializer.Serialize(point);
5151

@@ -57,8 +57,8 @@ public void Can_Serialize_CRS_issue_89()
5757
public void Can_Serialize_DefaultCRS_issue_89()
5858
{
5959
var expected =
60-
"{\"type\":\"Point\",\"coordinates\":[34.56,12.34],\"crs\":{\"properties\":{\"name\":\"urn:ogc:def:crs:OGC::CRS84\"},\"type\":\"name\"}}";
61-
var point = new Point(new Position(12.34, 34.56)) { CRS = new NamedCRS("urn:ogc:def:crs:OGC::CRS84") };
60+
"{\"type\":\"Point\",\"coordinates\":[34.57,12.35],\"crs\":{\"properties\":{\"name\":\"urn:ogc:def:crs:OGC::CRS84\"},\"type\":\"name\"}}";
61+
var point = new Point(new Position(12.35, 34.57)) { CRS = new NamedCRS("urn:ogc:def:crs:OGC::CRS84") };
6262

6363
var json = JsonSerializer.Serialize(point);
6464

src/GeoJSON.Text.Test.Unit/GeoJSON.Text.Test.Unit.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ProjectGuid>{6C93B314-9208-4684-B873-172F7EC81689}</ProjectGuid>
55
<RootNamespace>GeoJSON.Text.Tests</RootNamespace>
66
<AssemblyName>GeoJSON.Text.Tests</AssemblyName>
7-
<TargetFrameworks>netcoreapp3.1;net5;net6</TargetFrameworks>
7+
<TargetFrameworks>net462;netcoreapp3.1;net5;net6</TargetFrameworks>
88
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
99
</PropertyGroup>
1010
<ItemGroup>
@@ -66,6 +66,7 @@
6666
<PrivateAssets>all</PrivateAssets>
6767
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6868
</PackageReference>
69+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
6970
<PackageReference Include="NUnit" Version="3.13.2" />
7071
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
7172
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright © Joerg Battermann 2014, Matt Hunt 2017
2+
3+
using System;
4+
using System.Collections.Generic;
5+
6+
namespace GeoJSON.Text
7+
{
8+
/// <summary>
9+
/// Compares doubles for equality.
10+
/// </summary>
11+
/// <remarks>
12+
/// 10 decimal places equates to accuracy to 11.1 μm.
13+
/// </remarks>
14+
public class DoubleTenDecimalPlaceComparer : IEqualityComparer<double>
15+
{
16+
public bool Equals(double x, double y)
17+
{
18+
return Math.Abs(x - y) < 0.0000000001;
19+
}
20+
21+
public int GetHashCode(double obj)
22+
{
23+
return obj.GetHashCode();
24+
}
25+
}
26+
}

src/GeoJSON.Text/DoubleTenDecimalPlaceComparer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ namespace GeoJSON.Text
1111
/// <remarks>
1212
/// 10 decimal places equates to accuracy to 11.1 μm.
1313
/// </remarks>
14-
public class DoubleTenDecimalPlaceComparer : IEqualityComparer<double>
14+
public class DecimalTenDecimalPlaceComparer : IEqualityComparer<decimal>
1515
{
16-
public bool Equals(double x, double y)
16+
public bool Equals(decimal x, decimal y)
1717
{
18-
return Math.Abs(x - y) < 0.0000000001;
18+
return Math.Abs(x - y) < 0.0000000001m;
1919
}
2020

21-
public int GetHashCode(double obj)
21+
public int GetHashCode(decimal obj)
2222
{
2323
return obj.GetHashCode();
2424
}

src/GeoJSON.Text/GeoJSON.Text.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5;net6</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55
<LangVersion>Latest</LangVersion>
66
<Description>.Net types for the GeoJSON RFC to be used with System.Text.Json</Description>
77
<Authors>Matt Hunt</Authors>
@@ -20,6 +20,7 @@
2020
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2121
<EmbedUntrackedSources>true</EmbedUntrackedSources>
2222
<PublishRepositoryUrl>true</PublishRepositoryUrl>
23+
2324
</PropertyGroup>
2425

2526
<ItemGroup>

0 commit comments

Comments
 (0)