Skip to content

Commit

Permalink
Update NuGet Packages
Browse files Browse the repository at this point in the history
- Update all NuGet Packages
- Use "ConfigurePrimaryHttpMessageHandler" as directed
- Fix errors & warnings
  • Loading branch information
AdrianJSClark committed Apr 20, 2024
1 parent ba7deaf commit bd071e6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.9.28">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// © 2023 Adrian Clark
// © 2023-2024 Adrian Clark
// This file is licensed to you under the MIT license.

namespace Aydsko.iRacingData.IntegrationTests.Member;
Expand All @@ -8,19 +8,21 @@ internal sealed class CachingMemberInfoTest : CachingIntegrationFixture
[Test]
public async Task TestMemberInfoAsync()
{
var iRacingUsername = Configuration["iRacingData:Username"] ?? throw new InvalidOperationException("iRacing Username not found in configuration.");

var memberInfo = await Client.GetMyInfoAsync().ConfigureAwait(false);

Assert.That(memberInfo, Is.Not.Null);
Assert.That(memberInfo.Data, Is.Not.Null);

Assert.That(memberInfo.Data.Username, Is.EqualTo(Security.ObfuscateUsernameOrEmail(Configuration["iRacingData:Username"])));
Assert.That(memberInfo.Data.Username, Is.EqualTo(Security.ObfuscateUsernameOrEmail(iRacingUsername)));

var memberInfo2 = await Client.GetMyInfoAsync().ConfigureAwait(false);

Assert.That(memberInfo2, Is.Not.Null);
Assert.That(memberInfo2.Data, Is.Not.Null);

Assert.That(memberInfo2.Data.Username, Is.EqualTo(Security.ObfuscateUsernameOrEmail(Configuration["iRacingData:Username"])));
Assert.That(memberInfo2.Data.Username, Is.EqualTo(Security.ObfuscateUsernameOrEmail(iRacingUsername)));

var stats = MemoryCache.GetCurrentStatistics();
Assert.Multiple(() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// © 2023 Adrian Clark
// © 2023-2024 Adrian Clark
// This file is licensed to you under the MIT license.

namespace Aydsko.iRacingData.IntegrationTests.Member;
Expand All @@ -8,11 +8,13 @@ internal sealed class MemberInfoTest : DataClientIntegrationFixture
[Test]
public async Task TestMemberInfoAsync()
{
var iRacingUsername = Configuration["iRacingData:Username"] ?? throw new InvalidOperationException("iRacing Username not found in configuration.");

var memberInfo = await Client.GetMyInfoAsync().ConfigureAwait(false);

Assert.That(memberInfo, Is.Not.Null);
Assert.That(memberInfo.Data, Is.Not.Null);

Assert.That(memberInfo.Data.Username, Is.EqualTo(Security.ObfuscateUsernameOrEmail(Configuration["iRacingData:Username"])));
Assert.That(memberInfo.Data.Username, Is.EqualTo(Security.ObfuscateUsernameOrEmail(iRacingUsername)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.9.28">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/Aydsko.iRacingData.UnitTests/TestLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// © 2023 Adrian Clark
// © 2023-2024 Adrian Clark
// This file is licensed to you under the MIT license.

using Microsoft.Extensions.Logging;
Expand All @@ -7,7 +7,7 @@ namespace Aydsko.iRacingData.UnitTests;

public class TestLogger<T> : ILogger<T>
{
public IDisposable BeginScope<TState>(TState state)
public IDisposable? BeginScope<TState>(TState state) where TState : notnull
{
return new TestScope();
}
Expand Down
12 changes: 6 additions & 6 deletions src/Aydsko.iRacingData/Aydsko.iRacingData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.9.28">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MinVer" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="6.0.5" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="System.Text.Json" Version="8.0.3" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 8 additions & 7 deletions src/Aydsko.iRacingData/ServicesExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// © 2023 Adrian Clark
// © 2023-2024 Adrian Clark
// This file is licensed to you under the MIT license.

using System.Net;
Expand Down Expand Up @@ -101,7 +101,7 @@ public static IServiceCollection AddIRacingDataApiWithCaching(this IServiceColle
return services;
}

static internal IHttpClientBuilder AddIRacingDataApiInternal(this IServiceCollection services,
internal static IHttpClientBuilder AddIRacingDataApiInternal(this IServiceCollection services,
Action<iRacingDataClientOptions> configureOptions,
bool includeCaching)
{
Expand All @@ -127,13 +127,14 @@ public static IServiceCollection AddIRacingDataApiWithCaching(this IServiceColle

var httpClientBuilder = (includeCaching ? services.AddHttpClient<IDataClient, CachingDataClient>() : services.AddHttpClient<IDataClient, DataClient>())
.ConfigureHttpClient(httpClient => httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(userAgentValue))
.ConfigureHttpMessageHandlerBuilder(msgHandlerBuilder =>
.ConfigurePrimaryHttpMessageHandler(() =>
{
if (msgHandlerBuilder.PrimaryHandler is HttpClientHandler httpClientHandler)
var handler = new HttpClientHandler
{
httpClientHandler.UseCookies = true;
httpClientHandler.CookieContainer = msgHandlerBuilder.Services.GetRequiredService<CookieContainer>();
}
UseCookies = true,
CookieContainer = services.BuildServiceProvider().GetRequiredService<CookieContainer>()
};
return handler;
});

return httpClientBuilder;
Expand Down

0 comments on commit bd071e6

Please sign in to comment.