Skip to content

Commit

Permalink
Update packages and change target frameworks (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
glucaci authored Apr 13, 2021
1 parent c0a1b25 commit fb54f50
Show file tree
Hide file tree
Showing 42 changed files with 320 additions and 173 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,4 @@ tools/**

__mismatch__/
*.Development.json
appsettings.*.json
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.1.401"
"version": "5.0.103"
}
}
10 changes: 4 additions & 6 deletions src/Clients/src/AspNetCore/AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.0" />
</ItemGroup>

Expand Down
5 changes: 2 additions & 3 deletions src/Clients/src/AspNetCore/ClaimsPrincipalExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.IdentityModel.Tokens.Jwt;
using System;
using System.Linq;
using System.Security.Claims;

Expand All @@ -10,7 +9,7 @@ internal static class ClaimsPrincipalExtensions
public static Guid? GetId(this ClaimsPrincipal user)
{
string rawUserId = user?.Claims?
.Where(c => c.Type == JwtRegisteredClaimNames.Sub)
.Where(c => c.Type == "sub")
.Select(c => c.Value)
.FirstOrDefault();

Expand Down
2 changes: 1 addition & 1 deletion src/Clients/src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; netstandard2.1; netstandard2.0</TargetFrameworks>
<TargetFrameworks>net5.0; netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
</Project>
6 changes: 5 additions & 1 deletion src/Clients/src/GenericHost/GenericHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.0" />
</ItemGroup>

Expand Down
6 changes: 5 additions & 1 deletion src/Clients/src/Hosting/Hosting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.0" />
</ItemGroup>

Expand Down
9 changes: 1 addition & 8 deletions src/Clients/src/HotChocolate/HotChocolate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="HotChocolate" Version="11.0.0" />
</ItemGroup>

Expand Down
6 changes: 5 additions & 1 deletion src/Clients/src/Http/Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<AssemblyName>Thor.Hosting.AspNetCore.FunctionalTest</AssemblyName>
Expand Down
17 changes: 16 additions & 1 deletion src/Clients/test/AspNetCore.FunctionalTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@ public static void Main(string[] args)

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(c => c.ClearProviders())
.ConfigureLogging(c => c
.ClearProviders()
.AddConsole().AddFilter((provider, category, logLevel) =>
{
if (category.Contains("Thor"))
{
return true;
}

if (logLevel > LogLevel.Information)
{
return true;
}

return false;
}))
.UseStartup<Startup>()
.Build();
}
Expand Down
5 changes: 4 additions & 1 deletion src/Clients/test/AspNetCore.FunctionalTest/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"Level": "Info"
}
],
"AllowedPrefixes": [
"Thor."
],
"SkipRequestFilter": "_health",
"Events": {
"Buffer": {
Expand All @@ -27,7 +30,7 @@
},
"Storage": {
"DequeueBatchSize": 500
}
}
},
"Attachments": {
"Buffer": {
Expand Down
9 changes: 4 additions & 5 deletions src/Clients/test/AspNetCore.Tests/AspNetCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.5" />
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.0.3" />
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.5" />
</ItemGroup>

<ItemGroup>
Expand All @@ -20,7 +20,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeCoverage" Version="16.6.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Moq" Version="4.14.5" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ItemGroup>
<PackageReference Include="coveralls.io" Version="1.4.2" />
<PackageReference Include="Microsoft.CodeCoverage" Version="16.6.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Moq" Version="4.14.5" />
Expand Down
2 changes: 0 additions & 2 deletions src/Clients/test/Hosting.Tests/Hosting.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<AssemblyName>Thor.Extensions.Hosting.Tests</AssemblyName>
<RootNamespace>Thor.Extensions.Hosting.Tests</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -14,7 +13,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="HotChocolate.AspNetCore" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
<PackageReference Include="Microsoft.CodeCoverage" Version="16.6.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
Expand Down
10 changes: 4 additions & 6 deletions src/Clients/test/HotChocolate.Tests/HotChocolate.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
<AssemblyName>Thor.Extensions.HotChocolate.Tests</AssemblyName>
<RootNamespace>Thor.Extensions.HotChocolate.Tests</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.5" />
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.0.3" />
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.5" />
</ItemGroup>

<ItemGroup>
Expand All @@ -21,7 +20,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="HotChocolate.AspNetCore" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
<PackageReference Include="Microsoft.CodeCoverage" Version="16.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Moq" Version="4.14.5" />
Expand Down
1 change: 0 additions & 1 deletion src/Clients/test/Http.Tests/Http.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
<PackageReference Include="Microsoft.CodeCoverage" Version="16.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Moq" Version="4.14.5" />
Expand Down
6 changes: 4 additions & 2 deletions src/Core/src/Core/AssemblyAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;

[assembly:InternalsVisibleTo("Thor.Core.Tests")]
[assembly:InternalsVisibleTo("Thor.Core.Http.Tests")]
[assembly:InternalsVisibleTo("Thor.Extensions.HotChocolate.Tests")]
[assembly:InternalsVisibleTo("Thor.Extensions.Hosting.Tests")]
[assembly:InternalsVisibleTo("Thor.Hosting.AspNetCore.Tests")]
[assembly:InternalsVisibleTo("Thor.Hosting.AspNetCore.Tests")]
[assembly:InternalsVisibleTo("Thor.Core.Transmission.EventHub")]
[assembly:InternalsVisibleTo("Thor.Core.Transmission.BlobStorage")]
14 changes: 13 additions & 1 deletion src/Core/src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.7.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.7.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
56 changes: 56 additions & 0 deletions src/Core/src/Core/ErrorLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Diagnostics;
using System.Threading;
using Microsoft.Extensions.Logging;

namespace Thor.Core.Transmission.EventHub
{
/// <summary>
/// Creates a log entry limited per interval
/// </summary>
/// <typeparam name="T"></typeparam>
internal class ErrorLogger<T>
{
private readonly ILogger<T> _logger;
private readonly string _instance;

private readonly TimeSpan _interval = TimeSpan.FromMinutes(10);
private readonly Stopwatch _errorWatch;
private int _errorsPerInterval = 1;
private int _errorCount;

/// <summary>
/// The watcher ctor
/// </summary>
public ErrorLogger(ILogger<T> logger)
{
_logger = logger;
_errorWatch = new Stopwatch();
_instance = typeof(T).Name;
}

/// <summary>
/// Create a error log entry if interval elapsed or number of errors per interval not exceeded
/// </summary>
/// <param name="exception"></param>
public void Log(Exception exception)
{
if (_errorCount < _errorsPerInterval)
{
_logger.LogError(exception, $"{_instance} failed");
Interlocked.Increment(ref _errorCount);
}

if (!_errorWatch.IsRunning)
{
_errorWatch.Restart();
}

if (_errorWatch.Elapsed > _interval)
{
Interlocked.Exchange(ref _errorCount, 0);
_errorWatch.Restart();
}
}
}
}
2 changes: 1 addition & 1 deletion src/Core/src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; netstandard2.1; netstandard2.0</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
Loading

0 comments on commit fb54f50

Please sign in to comment.