Skip to content

Commit b7e26b4

Browse files
committed
NuGet governance remediation for Mapbox.Api
1 parent f805873 commit b7e26b4

15 files changed

Lines changed: 165 additions & 57 deletions

Directory.Packages.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.5" />
1212
<PackageVersion Include="Neovolve.Logging.Xunit.v3" Version="7.2.0" />
1313
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.9.50" />
14-
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
1514
<PackageVersion Include="refit" Version="10.1.6" />
16-
<PackageVersion Include="Refit.Newtonsoft.Json" Version="10.1.6" />
1715
<PackageVersion Include="SecurityCodeScan.VS2019" Version="5.6.7" />
1816
<PackageVersion Include="xunit.v3" Version="3.2.2" />
1917
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />

Mapbox.Api.Test/Config/Configuration.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
using Mapbox.Api.Exceptions;
2-
using System.Runtime.Serialization;
32

43
namespace Mapbox.Api.Test.Config;
54

65
/// <summary>
76
/// Test configuration
87
/// </summary>
9-
[DataContract]
108
public class Configuration
119
{
1210
/// <summary>
1311
/// Mapbox client options
1412
/// </summary>
15-
[DataMember(Name = "MapboxClientOptions")]
1613
public MapboxClientOptions MapboxClientOptions { get; set; } = null!;
1714

1815
public void Validate()

Mapbox.Api.Test/Mapbox.Api.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<OutputType>Exe</OutputType>
77
<IsPackable>false</IsPackable>
88
<ImplicitUsings>enable</ImplicitUsings>
9+
<GenerateDocumentationFile>false</GenerateDocumentationFile>
910
</PropertyGroup>
1011
<ItemGroup>
1112
<PackageReference Include="AwesomeAssertions" />
@@ -18,7 +19,6 @@
1819
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1920
</PackageReference>
2021
<PackageReference Include="Neovolve.Logging.Xunit.v3" />
21-
<PackageReference Include="Newtonsoft.Json" />
2222
<PackageReference Include="SecurityCodeScan.VS2019">
2323
<PrivateAssets>all</PrivateAssets>
2424
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Mapbox.Api.Test/MapboxClientTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using Mapbox.Api.Exceptions;
22
using Mapbox.Api.Test.Config;
33
using Neovolve.Logging.Xunit;
4-
using Newtonsoft.Json;
54
using System;
65
using System.IO;
6+
using System.Text.Json;
77
using Xunit;
88

99
namespace Mapbox.Api.Test;
@@ -36,7 +36,7 @@ protected Configuration GetConfiguration()
3636
// Yes
3737

3838
// Load in the config
39-
_configuration = JsonConvert.DeserializeObject<Configuration>(File.ReadAllText(fileInfo.FullName))
39+
_configuration = JsonSerializer.Deserialize<Configuration>(File.ReadAllText(fileInfo.FullName))
4040
?? throw new FormatException("Invalid configuration format.");
4141

4242
_configuration.Validate();

Mapbox.Api/AuthenticatedBackingOffHttpClientHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private async Task LogResponseAsync(HttpResponseMessage response, string logPref
103103
var headers = response.Headers;
104104
var foundHeader = headers.TryGetValues("Retry-After", out var retryAfterHeaders);
105105
var retryAfterSecondsString = foundHeader
106-
? retryAfterHeaders.FirstOrDefault() ?? "1"
106+
? retryAfterHeaders!.FirstOrDefault() ?? "1"
107107
: "1";
108108
if (!int.TryParse(retryAfterSecondsString, out var retryAfterSeconds))
109109
{

Mapbox.Api/Data/Context.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
1-
using System.Collections.Generic;
2-
using System.Runtime.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Mapbox.Api.Data;
54

6-
[DataContract]
5+
/// <summary>
6+
/// A context element providing hierarchy information for a geocoding result.
7+
/// </summary>
78
public class Context
89
{
9-
[DataMember(Name = "id")]
10+
/// <summary>
11+
/// The context identifier.
12+
/// </summary>
13+
[JsonPropertyName("id")]
1014
public string Id { get; set; } = null!;
1115

12-
[DataMember(Name = "text")]
16+
/// <summary>
17+
/// The context text.
18+
/// </summary>
19+
[JsonPropertyName("text")]
1320
public string Text { get; set; } = null!;
1421

15-
[DataMember(Name = "wikidata")]
22+
/// <summary>
23+
/// The Wikidata identifier.
24+
/// </summary>
25+
[JsonPropertyName("wikidata")]
1626
public string Wikidata { get; set; } = null!;
1727

18-
[DataMember(Name = "short_code")]
28+
/// <summary>
29+
/// The short code (e.g. region or country code).
30+
/// </summary>
31+
[JsonPropertyName("short_code")]
1932
public string ShortCode { get; set; } = null!;
2033
}

Mapbox.Api/Data/Feature.cs

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,94 @@
11
using System.Collections.Generic;
2-
using System.Runtime.Serialization;
2+
using System.Text.Json.Serialization;
33

44
namespace Mapbox.Api.Data;
55

6-
[DataContract]
6+
/// <summary>
7+
/// A geocoding feature result.
8+
/// </summary>
79
public class Feature
810
{
9-
[DataMember(Name = "id")]
11+
/// <summary>
12+
/// The feature identifier.
13+
/// </summary>
14+
[JsonPropertyName("id")]
1015
public string Id { get; set; } = null!;
1116

12-
[DataMember(Name = "type")]
17+
/// <summary>
18+
/// The GeoJSON type.
19+
/// </summary>
20+
[JsonPropertyName("type")]
1321
public string Type { get; set; } = null!;
1422

15-
[DataMember(Name = "place_type")]
23+
/// <summary>
24+
/// The place type(s).
25+
/// </summary>
26+
[JsonPropertyName("place_type")]
1627
public IList<string> PlaceType { get; set; } = null!;
1728

18-
[DataMember(Name = "relevance")]
29+
/// <summary>
30+
/// The relevance score.
31+
/// </summary>
32+
[JsonPropertyName("relevance")]
1933
public double Relevance { get; set; }
2034

21-
[DataMember(Name = "properties")]
35+
/// <summary>
36+
/// The feature properties.
37+
/// </summary>
38+
[JsonPropertyName("properties")]
2239
public Properties Properties { get; set; } = null!;
2340

24-
[DataMember(Name = "text")]
41+
/// <summary>
42+
/// The feature text.
43+
/// </summary>
44+
[JsonPropertyName("text")]
2545
public string Text { get; set; } = null!;
2646

27-
[DataMember(Name = "place_name")]
47+
/// <summary>
48+
/// The full place name.
49+
/// </summary>
50+
[JsonPropertyName("place_name")]
2851
public string PlaceName { get; set; } = null!;
2952

30-
[DataMember(Name = "matching_text")]
53+
/// <summary>
54+
/// The matching text.
55+
/// </summary>
56+
[JsonPropertyName("matching_text")]
3157
public string MatchingText { get; set; } = null!;
3258

33-
[DataMember(Name = "matching_place_name")]
59+
/// <summary>
60+
/// The matching place name.
61+
/// </summary>
62+
[JsonPropertyName("matching_place_name")]
3463
public string MatchingPlaceName { get; set; } = null!;
3564

36-
[DataMember(Name = "center")]
65+
/// <summary>
66+
/// The center coordinates.
67+
/// </summary>
68+
[JsonPropertyName("center")]
3769
public IList<double> Center { get; set; } = null!;
3870

39-
[DataMember(Name = "geometry")]
71+
/// <summary>
72+
/// The feature geometry.
73+
/// </summary>
74+
[JsonPropertyName("geometry")]
4075
public Geometry Geometry { get; set; } = null!;
4176

42-
[DataMember(Name = "address")]
77+
/// <summary>
78+
/// The address.
79+
/// </summary>
80+
[JsonPropertyName("address")]
4381
public string Address { get; set; } = null!;
4482

45-
[DataMember(Name = "context")]
83+
/// <summary>
84+
/// The context hierarchy.
85+
/// </summary>
86+
[JsonPropertyName("context")]
4687
public IList<Context> Context { get; set; } = null!;
4788

48-
[DataMember(Name = "bbox")]
89+
/// <summary>
90+
/// The bounding box.
91+
/// </summary>
92+
[JsonPropertyName("bbox")]
4993
public IList<double> Bbox { get; set; } = null!;
5094
}

Mapbox.Api/Data/Geocoding.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
using System.Collections.Generic;
2-
using System.Runtime.Serialization;
2+
using System.Text.Json.Serialization;
33

44
namespace Mapbox.Api.Data;
55

6-
[DataContract]
6+
/// <summary>
7+
/// A geocoding response from the Mapbox API.
8+
/// </summary>
79
public class Geocoding
810
{
9-
[DataMember(Name = "type")]
11+
/// <summary>
12+
/// The GeoJSON type.
13+
/// </summary>
14+
[JsonPropertyName("type")]
1015
public string Type { get; set; } = null!;
1116

12-
[DataMember(Name = "query")]
17+
/// <summary>
18+
/// The query terms.
19+
/// </summary>
20+
[JsonPropertyName("query")]
1321
public IList<string> Query { get; set; } = null!;
1422

15-
[DataMember(Name = "features")]
23+
/// <summary>
24+
/// The returned features.
25+
/// </summary>
26+
[JsonPropertyName("features")]
1627
public IList<Feature> Features { get; set; } = null!;
1728

18-
[DataMember(Name = "attribution")]
29+
/// <summary>
30+
/// The attribution string.
31+
/// </summary>
32+
[JsonPropertyName("attribution")]
1933
public string Attribution { get; set; } = null!;
2034
}

Mapbox.Api/Data/Geometry.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
using System.Collections.Generic;
2-
using System.Runtime.Serialization;
2+
using System.Text.Json.Serialization;
33

44
namespace Mapbox.Api.Data;
55

6-
[DataContract]
6+
/// <summary>
7+
/// A GeoJSON geometry object.
8+
/// </summary>
79
public class Geometry
810
{
9-
[DataMember(Name = "type")]
11+
/// <summary>
12+
/// The geometry type.
13+
/// </summary>
14+
[JsonPropertyName("type")]
1015
public string Type { get; set; } = null!;
1116

12-
[DataMember(Name = "coordinates")]
17+
/// <summary>
18+
/// The coordinates of the geometry.
19+
/// </summary>
20+
[JsonPropertyName("coordinates")]
1321
public IList<double> Coordinates { get; set; } = null!;
1422

15-
[DataMember(Name = "interpolated")]
23+
/// <summary>
24+
/// Whether the result is interpolated.
25+
/// </summary>
26+
[JsonPropertyName("interpolated")]
1627
public bool? Interpolated { get; set; }
1728
}

Mapbox.Api/Data/Properties.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
using System.Collections.Generic;
2-
using System.Runtime.Serialization;
1+
using System.Text.Json.Serialization;
32

43
namespace Mapbox.Api.Data;
54

6-
[DataContract]
5+
/// <summary>
6+
/// Properties associated with a geocoding feature.
7+
/// </summary>
78
public class Properties
89
{
9-
[DataMember(Name = "accuracy")]
10+
/// <summary>
11+
/// The accuracy of the geocoding result.
12+
/// </summary>
13+
[JsonPropertyName("accuracy")]
1014
public string Accuracy { get; set; } = null!;
1115
}

0 commit comments

Comments
 (0)