Skip to content

Commit

Permalink
Merge pull request #61 from Rans4ckeR/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
Rans4ckeR authored Jan 24, 2023
2 parents e5f0688 + c210799 commit fcea704
Show file tree
Hide file tree
Showing 76 changed files with 557 additions and 410 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
uses: actions/setup-dotnet@main
with:
dotnet-version: '7.x.x'
include-prerelease: true
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@main
with:
Expand All @@ -28,16 +27,12 @@ jobs:
uses: gittools/actions/gitversion/execute@main
- name: Publish
run: |
dotnet publish RS.Fritz.Manager.UI/RS.Fritz.Manager.UI.csproj --configuration Release --no-self-contained --framework net6.0-windows10.0.22000.0 --runtime win-x64 -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish RS.Fritz.Manager.UI/RS.Fritz.Manager.UI.csproj --configuration Release --no-self-contained --framework net7.0-windows10.0.22000.0 --runtime win-x64 -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish RS.Fritz.Manager.UI/RS.Fritz.Manager.UI.csproj --configuration Release --no-self-contained --framework net6.0-windows10.0.22000.0 --runtime win-arm64 -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish RS.Fritz.Manager.UI/RS.Fritz.Manager.UI.csproj --configuration Release --no-self-contained --framework net7.0-windows10.0.22000.0 --runtime win-arm64 -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish RS.Fritz.Manager.UI/RS.Fritz.Manager.UI.csproj --configuration Release --no-self-contained --framework net7.0-windows10.0.22621.0 --runtime win-x64 -p:PublishReadyToRun=true -p:PublishReadyToRunComposite=true -p:PublishSingleFile=true -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish RS.Fritz.Manager.UI/RS.Fritz.Manager.UI.csproj --configuration Release --no-self-contained --framework net7.0-windows10.0.22621.0 --runtime win-arm64 -p:PublishReadyToRun=true -p:PublishReadyToRunComposite=true -p:PublishSingleFile=true -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
- name: Zip
run: |
7z a -r ${{ format('RS.Fritz.Manager-v{0}-net6.0-windows-x64.zip', env.GitVersion_SemVer) }} ./RS.Fritz.Manager.UI/bin/Release/net6.0-windows10.0.22000.0/win-x64/publish/*.*
7z a -r ${{ format('RS.Fritz.Manager-v{0}-net7.0-windows-x64.zip', env.GitVersion_SemVer) }} ./RS.Fritz.Manager.UI/bin/Release/net7.0-windows10.0.22000.0/win-x64/publish/*.*
7z a -r ${{ format('RS.Fritz.Manager-v{0}-net6.0-windows-ARM64.zip', env.GitVersion_SemVer) }} ./RS.Fritz.Manager.UI/bin/Release/net6.0-windows10.0.22000.0/win-arm64/publish/*.*
7z a -r ${{ format('RS.Fritz.Manager-v{0}-net7.0-windows-ARM64.zip', env.GitVersion_SemVer) }} ./RS.Fritz.Manager.UI/bin/Release/net7.0-windows10.0.22000.0/win-arm64/publish/*.*
7z a -r ${{ format('RS.Fritz.Manager-v{0}-net7.0-windows-x64.zip', env.GitVersion_SemVer) }} ./RS.Fritz.Manager.UI/bin/Release/net7.0-windows10.0.22621.0/win-x64/publish/*.*
7z a -r ${{ format('RS.Fritz.Manager-v{0}-net7.0-windows-ARM64.zip', env.GitVersion_SemVer) }} ./RS.Fritz.Manager.UI/bin/Release/net7.0-windows10.0.22621.0/win-arm64/publish/*.*
- name: Prerelease
if: ${{ env.GitVersion_PreReleaseTag != '' }}
run: gh release create ${{ format('v{0}', env.GitVersion_SemVer) }} (get-item *.zip) --generate-notes --target ${{ github.sha }} --prerelease
Expand All @@ -49,7 +44,7 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
- name: Package
run: dotnet pack RS.Fritz.Manager.API/RS.Fritz.Manager.API.csproj --no-restore --no-build --configuration Release -p:PackageVersion=$env:GitVersion_NuGetVersionV2
run: dotnet pack RS.Fritz.Manager.API/RS.Fritz.Manager.API.csproj --no-restore --configuration Release -p:PackageVersion=$env:GitVersion_NuGetVersionV2
- name: NuGet Push
run: dotnet nuget push ${{ format('RS.Fritz.Manager.API/bin/Release/RS.Fritz.Manager.API.{0}.nupkg', env.GitVersion_NuGetVersionV2) }} --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: GitHub Push
Expand Down
46 changes: 0 additions & 46 deletions .runsettings

This file was deleted.

8 changes: 0 additions & 8 deletions .stylecop.json

This file was deleted.

3 changes: 1 addition & 2 deletions RS.Fritz.Manager.API/Constants/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

internal static class Constants
{
public const string HttpClientName = "HttpClientName";
public const string NonValidatingHttpsClientName = "NonValidatingHttpsClient";
public const string DefaultHttpClientName = nameof(DefaultHttpClientName);
}
2 changes: 1 addition & 1 deletion RS.Fritz.Manager.API/Entities/InternetGatewayDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using System.Net;

public sealed record InternetGatewayDevice(IFritzServiceOperationHandler FritzServiceOperationHandler, IUsersService UsersService, IEnumerable<Uri> Locations, string Server, string CacheControl, string? Ext, string SearchTarget, string UniqueServiceName, UPnPDescription UPnPDescription, Uri PreferredLocation)
public sealed record InternetGatewayDevice(IFritzServiceOperationHandler FritzServiceOperationHandler, IUsersService UsersService, IEnumerable<Uri> Locations, string Server, string CacheControl, string? Ext, string SearchTarget, string UniqueServiceName, UPnPDescription UPnPDescription, Uri PreferredLocation, IReadOnlyCollection<IPAddress> LocalIpAddresses)
{
private IReadOnlyCollection<ServiceListItem>? services;

Expand Down
2 changes: 1 addition & 1 deletion RS.Fritz.Manager.API/Extensions/LoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public static class LoggerExtensions
{
private static readonly Action<ILogger, string, Exception?> ExceptionDetails = LoggerMessage.Define<string>(LogLevel.Error, new EventId(1, nameof(ExceptionThrown)), "{Exception}");
private static readonly Action<ILogger, string, Exception?> ExceptionDetails = LoggerMessage.Define<string>(LogLevel.Error, new(1, nameof(ExceptionThrown)), "{Exception}");

public static void ExceptionThrown(this ILogger logger, Exception exception)
{
Expand Down
26 changes: 12 additions & 14 deletions RS.Fritz.Manager.API/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static IServiceCollection AddFritzApi(this IServiceCollection serviceColl
.AddSingleton<IFritzServiceOperationHandler, FritzServiceOperationHandler>()
.AddSingleton<IUsersService, UsersService>()
.AddSingleton<IWebUiService, WebUiService>()
.AddSingleton<INetworkService, NetworkService>()
.AddSingleton<IClientFactory<IFritzLanConfigSecurityService>, ClientFactory<IFritzLanConfigSecurityService>>()
.AddSingleton<IClientFactory<IFritzDeviceInfoService>, ClientFactory<IFritzDeviceInfoService>>()
.AddSingleton<IClientFactory<IFritzWanDslInterfaceConfigService>, ClientFactory<IFritzWanDslInterfaceConfigService>>()
Expand All @@ -42,25 +43,22 @@ public static IServiceCollection AddFritzApi(this IServiceCollection serviceColl

private static IServiceCollection ConfigureHttpClients(this IServiceCollection serviceCollection)
{
_ = serviceCollection.AddHttpClient(Constants.HttpClientName)
.ConfigureHttpClient((_, httpClient) =>
{
httpClient.Timeout = TimeSpan.FromSeconds(60);
httpClient.DefaultRequestVersion = Version.Parse("2.0");
})
.ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler
{
AutomaticDecompression = DecompressionMethods.All
});
_ = serviceCollection.AddHttpClient(Constants.NonValidatingHttpsClientName)
_ = serviceCollection.AddHttpClient(Constants.DefaultHttpClientName)
.ConfigureHttpClient((_, httpClient) =>
{
httpClient.Timeout = TimeSpan.FromSeconds(10);
httpClient.DefaultRequestVersion = Version.Parse("2.0");
httpClient.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher;
})
.ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler
.ConfigurePrimaryHttpMessageHandler(_ => new SocketsHttpHandler
{
ServerCertificateCustomValidationCallback = (_, _, _, sslPolicyErrors) => (sslPolicyErrors & SslPolicyErrors.RemoteCertificateNotAvailable) == 0,
SslOptions = new()
{
RemoteCertificateValidationCallback = (_, _, _, sslPolicyErrors) => (sslPolicyErrors & SslPolicyErrors.RemoteCertificateNotAvailable) == 0,
CertificateChainPolicy = new()
{
DisableCertificateDownloads = true
}
},
AutomaticDecompression = DecompressionMethods.All
});

Expand Down
35 changes: 22 additions & 13 deletions RS.Fritz.Manager.API/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

public static class TaskExtensions
{
public static async Task<TResult[]> WhenAllSafe<TResult>(IEnumerable<Task<TResult>> tasks)
/// <summary>
/// Executes a list of tasks and waits for all of them to complete and throws an <see cref="AggregateException"/> containing all exceptions from all tasks.
/// When using <see cref="Task.WhenAll(IEnumerable{Task})"/> only the first thrown exception from a single <see cref="Task"/> may be observed.
/// </summary>
/// <typeparam name="T">The type of <paramref name="tasks"/>'s return value.</typeparam>
/// <param name="tasks">The list of <see cref="Task"/>s who's exceptions will be handled.</param>
/// <returns>Returns a <see cref="Task"/> that awaited and handled the original <paramref name="tasks"/>.</returns>
public static async Task<T[]> WhenAllSafe<T>(IEnumerable<Task<T>> tasks)
{
var whenAllTask = Task.WhenAll(tasks);

Expand All @@ -12,31 +19,33 @@ public static async Task<TResult[]> WhenAllSafe<TResult>(IEnumerable<Task<TResul
}
catch
{
// Ignore individual task exceptions
}
if (whenAllTask.Exception is null)
throw;

#pragma warning disable CS8597 // Thrown value may be null.
throw whenAllTask.Exception;
#pragma warning restore CS8597 // Thrown value may be null.
throw whenAllTask.Exception;
}
}

/// <summary>
/// Executes a list of tasks and waits for all of them to complete and throws an <see cref="AggregateException"/> containing all exceptions from all tasks.
/// When using <see cref="Task.WhenAll(IEnumerable{Task})"/> only the first thrown exception from a single <see cref="Task"/> may be observed.
/// </summary>
/// <param name="tasks">The list of <see cref="Task"/>s who's exceptions will be handled.</param>
/// <returns>Returns a <see cref="Task"/> that awaited and handled the original <paramref name="tasks"/>.</returns>
public static async Task WhenAllSafe(IEnumerable<Task> tasks)
{
var whenAllTask = Task.WhenAll(tasks);

try
{
await whenAllTask;

return;
}
catch
{
// Ignore individual task exceptions
}
if (whenAllTask.Exception is null)
throw;

#pragma warning disable CS8597 // Thrown value may be null.
throw whenAllTask.Exception;
#pragma warning restore CS8597 // Thrown value may be null.
throw whenAllTask.Exception;
}
}
}
6 changes: 2 additions & 4 deletions RS.Fritz.Manager.API/Properties/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#pragma warning disable IDE0065 // Misplaced using directive
#pragma warning disable SA1200 // Using directives should be placed correctly
#pragma warning disable SA1200 // Using directives should be placed correctly
global using System.ServiceModel;
#pragma warning restore SA1200 // Using directives should be placed correctly
#pragma warning restore IDE0065 // Misplaced using directive
#pragma warning restore SA1200 // Using directives should be placed correctly
21 changes: 6 additions & 15 deletions RS.Fritz.Manager.API/RS.Fritz.Manager.API.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFramework>net7.0</TargetFramework>
<AssemblyName>RS.Fritz.Manager.API</AssemblyName>
<RootNamespace>RS.Fritz.Manager.API</RootNamespace>
<Title>RS.Fritz.Manager.API</Title>
<Product>RS.Fritz.Manager.API</Product>
<Copyright>Copyright 2022 (c) RS. All rights reserved.</Copyright>
<Company>RS</Company>
<Copyright>Copyright 2023 (c) RS. All rights reserved.</Copyright>
<Company>Rans4ckeR</Company>
<Configuration></Configuration>
<Trademark></Trademark>
<Culture></Culture>
<Authors>RS</Authors>
<ComVisible>false</ComVisible>
<CLSCompliant>false</CLSCompliant>
<AnalysisLevel>preview-all</AnalysisLevel>
Expand All @@ -37,23 +36,15 @@
<Platform>AnyCPU</Platform>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="..\.stylecop.json" Link=".stylecop.json" />
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0-preview.2.22152.2" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="7.0.0-preview.2.22152.2" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.406">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.ServiceModel.Http" Version="4.9.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="System.ServiceModel.Http" Version="6.0.0-preview1.23060.3" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
</Project>
Loading

0 comments on commit fcea704

Please sign in to comment.