Skip to content

Commit

Permalink
1.5.0 Release
Browse files Browse the repository at this point in the history
Co-authored-by: Farthom <4826945+Farthom@users.noreply.github.com>
  • Loading branch information
JustinCanton and Farthom authored Jun 4, 2023
2 parents 5461f0b + 23e3569 commit 6a124c2
Show file tree
Hide file tree
Showing 49 changed files with 469 additions and 162 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0

# Setup .Net SDKs
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
Expand All @@ -31,12 +33,16 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'

# Perform the dotnet actions
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-restore --configuration Release

# Get the version information
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.7
if: ${{ contains(github.event_name, 'push') }}
Expand All @@ -51,6 +57,8 @@ jobs:
if: ${{ contains(github.event_name, 'push') }}
run: |
echo "SemVer: $GITVERSION_SEMVER"
# Package and publish
- name: Package
if: ${{ contains(github.event_name, 'push') }}
run: dotnet pack --no-build --configuration Release --output ./Packages -p:PackageVersion=$GITVERSION_SEMVER
Expand Down
2 changes: 1 addition & 1 deletion src/Geo.ArcGIS/Abstractions/IArcGISTokenContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public interface IArcGISTokenContainer
/// </summary>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> used to cancel the request.</param>
/// <returns>A <see cref="string"/> with the ArcGIS API token.</returns>
public Task<string> GetTokenAsync(CancellationToken cancellationToken);
Task<string> GetTokenAsync(CancellationToken cancellationToken);
}
}
2 changes: 1 addition & 1 deletion src/Geo.ArcGIS/Geo.ArcGIS.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<Authors>Justin Canton</Authors>
<Company>Geo.NET</Company>
<Product>Geo.NET ArcGIS</Product>
Expand Down
11 changes: 6 additions & 5 deletions src/Geo.ArcGIS/Services/ArcGISGeocoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ internal async Task<Uri> ValidateAndBuildUri<TParameters>(
TParameters parameters,
Func<TParameters, CancellationToken, Task<Uri>> uriBuilderFunction,
CancellationToken cancellationToken)
where TParameters : class
{
if (parameters is null)
{
Expand Down Expand Up @@ -180,7 +181,7 @@ internal async Task<Uri> BuildAddressCandidateRequest(AddressCandidateParameters

query = await AddArcGISToken(query, cancellationToken).ConfigureAwait(false);

uriBuilder.Query = query.ToString();
uriBuilder.AddQuery(query);

return uriBuilder.Uri;
}
Expand Down Expand Up @@ -229,7 +230,7 @@ internal async Task<Uri> BuildPlaceCandidateRequest(PlaceCandidateParameters par

query = await AddArcGISToken(query, cancellationToken).ConfigureAwait(false);

uriBuilder.Query = query.ToString();
uriBuilder.AddQuery(query);

return uriBuilder.Uri;
}
Expand Down Expand Up @@ -291,7 +292,7 @@ internal Task<Uri> BuildSuggestRequest(SuggestParameters parameters, Cancellatio
_logger.ArcGISWarning(_resourceStringProvider.GetString("Invalid Maximum Locations"));
}

uriBuilder.Query = query.ToString();
uriBuilder.AddQuery(query);

return Task.FromResult<Uri>(uriBuilder.Uri);
}
Expand Down Expand Up @@ -372,7 +373,7 @@ internal async Task<Uri> BuildReverseGeocodingRequest(ReverseGeocodingParameters

query = await AddArcGISToken(query, cancellationToken).ConfigureAwait(false);

uriBuilder.Query = query.ToString();
uriBuilder.AddQuery(query);

return uriBuilder.Uri;
}
Expand Down Expand Up @@ -482,7 +483,7 @@ internal async Task<Uri> BuildGeocodingRequest(GeocodingParameters parameters, C

query = await AddArcGISToken(query, cancellationToken).ConfigureAwait(false);

uriBuilder.Query = query.ToString();
uriBuilder.AddQuery(query);

return uriBuilder.Uri;
}
Expand Down
12 changes: 7 additions & 5 deletions src/Geo.ArcGIS/Services/ArcGISTokenRetrevial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ public async Task<Token> GetTokenAsync(CancellationToken cancellationToken)
};
}

using var content = BuildContent();
var response = await _client.PostAsync(_tokenRefreshAddress, content, cancellationToken).ConfigureAwait(false);
using (var content = BuildContent())
{
var response = await _client.PostAsync(_tokenRefreshAddress, content, cancellationToken).ConfigureAwait(false);

#if NET5_0_OR_GREATER
var json = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
var json = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
#else
var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
#endif

return JsonConvert.DeserializeObject<Token>(json);
return JsonConvert.DeserializeObject<Token>(json);
}
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Geo.Bing/Geo.Bing.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<Authors>Justin Canton</Authors>
<Company>Geo.NET</Company>
<Product>Geo.NET Bing</Product>
Expand Down
8 changes: 5 additions & 3 deletions src/Geo.Bing/Services/BingGeocoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Geo.Bing.Services
using Geo.Bing.Models.Parameters;
using Geo.Bing.Models.Responses;
using Geo.Core;
using Geo.Core.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

Expand Down Expand Up @@ -88,6 +89,7 @@ public async Task<Response> AddressGeocodingAsync(AddressGeocodingParameters par
/// <param name="uriBuilderFunction">The method to use to create the uri.</param>
/// <returns>A <see cref="Uri"/> with the uri crafted from the parameters.</returns>
internal Uri ValidateAndBuildUri<TParameters>(TParameters parameters, Func<TParameters, Uri> uriBuilderFunction)
where TParameters : class
{
if (parameters is null)
{
Expand Down Expand Up @@ -132,7 +134,7 @@ internal Uri BuildGeocodingRequest(GeocodingParameters parameters)

AddBingKey(ref query);

uriBuilder.Query = query.ToString();
uriBuilder.AddQuery(query);

return uriBuilder.Uri;
}
Expand Down Expand Up @@ -204,7 +206,7 @@ internal Uri BuildReverseGeocodingRequest(ReverseGeocodingParameters parameters)

AddBingKey(ref query);

uriBuilder.Query = query.ToString();
uriBuilder.AddQuery(query);

return uriBuilder.Uri;
}
Expand Down Expand Up @@ -280,7 +282,7 @@ internal Uri BuildAddressGeocodingRequest(AddressGeocodingParameters parameters)

AddBingKey(ref query);

uriBuilder.Query = query.ToString();
uriBuilder.AddQuery(query);

return uriBuilder.Uri;
}
Expand Down
34 changes: 34 additions & 0 deletions src/Geo.Core/Extensions/UriBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// <copyright file="UriBuilderExtensions.cs" company="Geo.NET">
// Copyright (c) Geo.NET.
// Licensed under the MIT license. See the LICENSE file in the solution root for full license information.
// </copyright>

namespace Geo.Core.Extensions
{
using System;

/// <summary>
/// Extension methods on the <see cref="UriBuilder"/> class.
/// </summary>
public static class UriBuilderExtensions
{
/// <summary>
/// Adds a <see cref="QueryString"/> to a <see cref="UriBuilder"/>.
/// </summary>
/// <param name="builder">The <see cref="UriBuilder"/> to add the query to.</param>
/// <param name="query">The <see cref="QueryString"/> to add.</param>
/// <returns>The <see cref="UriBuilder"/> with the added query.</returns>
public static UriBuilder AddQuery(this UriBuilder builder, QueryString query)
{
#if NETSTANDARD2_1_OR_GREATER
builder.Query = query.ToString();
#else
// There is an issue in the netstandard2.0 UriBuilder where it just adds the ? no matter what.
// See https://github.com/microsoft/referencesource/blob/4.6.2/System/net/System/uribuilder.cs line 277
builder.Query = query.ToString().Substring(1);
#endif

return builder;
}
}
}
11 changes: 10 additions & 1 deletion src/Geo.Core/Geo.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<Authors>Justin Canton</Authors>
<Company>Geo.NET</Company>
<Product>Geo.NET Core</Product>
Expand All @@ -12,6 +12,10 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Localization" Version="6.0.0" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" />
Expand All @@ -27,6 +31,11 @@
<PackageReference Include="System.Text.Encodings.Web" Version="5.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Localization" Version="3.1.0" />
<PackageReference Include="System.Text.Encodings.Web" Version="4.7.2" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions src/Geo.Core/GeoNETResourceStringProviderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace Geo.Core
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reflection;
using System.Resources;

Expand All @@ -16,7 +15,8 @@ namespace Geo.Core
/// </summary>
public sealed class GeoNETResourceStringProviderFactory : IGeoNETResourceStringProviderFactory
{
private static IDictionary<(string resourceFileName, Assembly assembly), ResourceManager> _resourceManagers = new ConcurrentDictionary<(string resourceFileName, Assembly assembly), ResourceManager>();
private static ConcurrentDictionary<(string resourceFileName, Assembly assembly), ResourceManager> _resourceManagers =
new ConcurrentDictionary<(string resourceFileName, Assembly assembly), ResourceManager>();

/// <inheritdoc/>
public IGeoNETResourceStringProvider CreateResourceStringProvider<TResource>()
Expand All @@ -43,13 +43,9 @@ public IGeoNETResourceStringProvider CreateResourceStringProvider(string resourc
throw new ArgumentException("The resource file name cannot be null or empty", nameof(resourceFileName));
}

if (_resourceManagers.TryGetValue((resourceFileName, assembly), out var resourceManager))
{
return new GeoNETResourceStringProvider(resourceManager);
}

resourceManager = new ResourceManager(resourceFileName, assembly == null ? Assembly.GetCallingAssembly() : assembly);
_resourceManagers.Add((resourceFileName, assembly), resourceManager);
var resourceManager = _resourceManagers.GetOrAdd(
(resourceFileName, assembly),
new ResourceManager(resourceFileName, assembly ?? Assembly.GetCallingAssembly()));

return new GeoNETResourceStringProvider(resourceManager);
}
Expand All @@ -59,7 +55,11 @@ private static string CreateResourceBaseName(Type resourceType)
var assemblyName = resourceType.Assembly.GetName().Name;
var resourceName = resourceType.FullName;
var resourceFolderName = assemblyName + ".Resources";
#if NETSTANDARD2_1_OR_GREATER
return resourceName.Replace(assemblyName, resourceFolderName, StringComparison.InvariantCultureIgnoreCase);
#else
return resourceName.Replace(assemblyName, resourceFolderName);
#endif
}
}
}
Loading

0 comments on commit 6a124c2

Please sign in to comment.