Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/net8 #222

Merged
merged 9 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,4 @@ coverage.*
/redis-64
/.sonarlint
/.dccache
/global.json
7 changes: 4 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ image:
environment:
GH_TOKEN:
secure: 0NJdORJRFjpB0dwUYv7bVNsbkldkoBhnvWik/CTOwAF/k9kP+/uTWMFnDcpEpt8E
donetsdk: 7.0.401
donetsdk: 8.0.100-rc.2.23502.2
JAVA_HOME: C:\Program Files\Java\jdk14
init:
- cmd: git config --global core.autocrlf true
Expand All @@ -27,9 +27,10 @@ install:
- sh: sudo chmod +x ./dotnet-install.sh
- sh: sudo ./dotnet-install.sh -Channel Current -Version $donetsdk -InstallDir ./dotnetsdk -NoPath
- sh: export PATH=/home/appveyor/projects/dymamicauthproviders/dotnetsdk:$PATH
- sh: sudo ./dotnet-install.sh -Channel Current -Version 6.0.403 -InstallDir ./dotnetsdk -NoPath
- sh: sudo ./dotnet-install.sh -Channel Current -Version 7.0.402 -InstallDir ./dotnetsdk -NoPath
- sh: sudo apt -y install nuget
- cmd: pwsh .\dotnet-install.ps1 -Version 6.0.403
- cmd: pwsh .\dotnet-install.ps1 -Version %donetsdk%
- cmd: pwsh .\dotnet-install.ps1 -Version 7.0.402
- ps: dotnet tool install --global GitVersion.Tool
- ps: dotnet gitversion /l console /output buildserver
- ps: if ($isWindows) { .\dotnet-install.ps1 -Version $env:donetsdk }
Expand Down
90 changes: 90 additions & 0 deletions bump-ms-dependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Update one project packages
function UpdatePackages {
param (
$project
)

$currentDirectoy = Get-Location
$return = $false

$dir = Split-Path $project
Write-Host 'Set-Location' $dir

Set-Location $dir

# Get outdated packages
$packageLineList = dotnet list package --outdated --include-prerelease

foreach($line in $packageLineList) {
Write-Host $line

$match = $line -match '>\s(Microsoft.\S*)\s*\S*\s*\S*\s*(\S*)'
if (!$match) {
# the line doesn't contain a package information, continue
continue
}

# update an outdated package
$added = dotnet add package $Matches.1 --version $Matches.2

if ($LASTEXITCODE -ne 0) {
# error while updating the package
Write-Error "dotnet add $project package $Matches.1 --version $Matches.2 exit with code $LASTEXITCODE"
Write-Host $added
break
}

Write-Host 'package' $Matches.1 'version' $Matches.2 'updated'
$return = $true
}

Set-Location $currentDirectoy
return $return
}

# get branches names
$dest = "master"
if (Test-Path env:DEST_BRANCH) {
$dest = $env:DEST_BRANCH
}
$src = "fix/dependencies"
if (Test-Path env:SRC_BRANCH) {
$src = $env:SRC_BRANCH
}

Write-Host "src:$src dest: $dest"

# Restore dependencies
dotnet restore

# Get all project list in the solution
$projectList = dotnet sln list
$updated = $false

foreach($path in $projectList) {
if ($path -eq "Project(s)" -or $path -eq "----------") {
# The line doesn't contain a path, continue
continue
}

# Update project dependencies
$projectUpdated = UpdatePackages -project $path

if ($LASTEXITCODE -ne 0) {
#The update fail, exit
exit $LASTEXITCODE
}

$updated = $updated -or $projectUpdated
}

if (!$updated) {
# No packages to update found, exit
Write-Host "nothing to update"
exit 0
}

# Try build the solution with new packages
Write-Host "dotnet build -c Release"
dotnet build -c Release

90 changes: 90 additions & 0 deletions bump-system-dependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Update one project packages
function UpdatePackages {
param (
$project
)

$currentDirectoy = Get-Location
$return = $false

$dir = Split-Path $project
Write-Host 'Set-Location' $dir

Set-Location $dir

# Get outdated packages
$packageLineList = dotnet list package --outdated --include-prerelease

foreach($line in $packageLineList) {
Write-Host $line

$match = $line -match '>\s(System.\S*)\s*\S*\s*\S*\s*(\S*)'
if (!$match) {
# the line doesn't contain a package information, continue
continue
}

# update an outdated package
$added = dotnet add package $Matches.1 --version $Matches.2

Write-Host $Matches.1 'version' $Matches.2 $added

if ($LASTEXITCODE -ne 0) {
# error while updating the package
Write-Error "dotnet add $project package $Matches.1 --version $Matches.2 exit with code $LASTEXITCODE"
Write-Host $added
break
}

$return = $true
}

Set-Location $currentDirectoy
return $return
}

# get branches names
$dest = "master"
if (Test-Path env:DEST_BRANCH) {
$dest = $env:DEST_BRANCH
}
$src = "fix/dependencies"
if (Test-Path env:SRC_BRANCH) {
$src = $env:SRC_BRANCH
}

Write-Host "src:$src dest: $dest"

# Restore dependencies
dotnet restore

# Get all project list in the solution
$projectList = dotnet sln list
$updated = $false

foreach($path in $projectList) {
if ($path -eq "Project(s)" -or $path -eq "----------") {
# The line doesn't contain a path, continue
continue
}

# Update project dependencies
$projectUpdated = UpdatePackages -project $path

if ($LASTEXITCODE -ne 0) {
#The update fail, exit
exit $LASTEXITCODE
}

$updated = $updated -or $projectUpdated
}

if (!$updated) {
# No packages to update found, exit
Write-Host "nothing to update"
exit 0
}

# Try build the solution with new packages
Write-Host "dotnet build -c Release"
dotnet build -c Release
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<Authors>Olivier Lefebvre</Authors>
<Copyright>Copyright (c) 2018 @Olivier Lefebvre</Copyright>
Expand All @@ -14,15 +14,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.12">
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0-rc.2.23480.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0-rc.2.23480.1" />
<PackageReference Include="Aguacongas.AspNetCore.Authentication.EntityFramework" Version="4.1.1" />
<PackageReference Include="Aguacongas.AspNetCore.Authentication.Redis" Version="4.1.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Authors>Olivier Lefebvre</Authors>
<Copyright>Copyright (c) 2018 @Olivier Lefebvre</Copyright>
<PackageLicense>https://raw.githubusercontent.com/aguacongas/DymamicAuthProviders/master/LICENSE</PackageLicense>
Expand All @@ -12,7 +12,6 @@
<Description>Provider for DinamicAuthProviders that uses Entity Framework Core.</Description>
<DebugType>Full</DebugType>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>C:\Projects\Perso\DymamicAuthProviders\src\Aguacongas.AspNetCore.Authentication.EntityFramework\Aguacongas.AspNetCore.Authentication.EntityFramework.xml</DocumentationFile>
<CodeAnalysisRuleSet>Aguacongas.AspNetCore.Authentication.EntityFramework.ruleset</CodeAnalysisRuleSet>
Expand All @@ -28,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0-rc.2.23480.1" />
</ItemGroup>

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

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Authors>Olivier Lefebvre</Authors>
<Copyright>Copyright (c) 2018 @Olivier Lefebvre</Copyright>
<PackageLicense>https://raw.githubusercontent.com/aguacongas/DymamicAuthProviders/master/LICENSE</PackageLicense>
Expand All @@ -27,17 +27,17 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.WsFederation" Version="7.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.WsFederation" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit.analyzers" Version="1.4.0" />
<PackageReference Include="xunit.assert" Version="2.5.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ protected virtual IServiceProvider CreateServiceProvider(Action<AuthenticationBu
class FakeGenericHandler<TOptions> : AuthenticationHandler<TOptions>
where TOptions : AuthenticationSchemeOptions, new()
{
public FakeGenericHandler(IOptionsMonitor<TOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock)
public FakeGenericHandler(IOptionsMonitor<TOptions> options, ILoggerFactory logger, UrlEncoder encoder) : base(options, logger, encoder)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<DebugType>Full</DebugType>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net8.0'">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>C:\Projects\Perso\DymamicAuthProviders\src\Aguacongas.AspNetCore.Authentication\Aguacongas.AspNetCore.Authentication.xml</DocumentationFile>
<CodeAnalysisRuleSet>Aguacongas.AspNetCore.Authentication.ruleset</CodeAnalysisRuleSet>
Expand All @@ -29,7 +33,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OAuth" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
10 changes: 5 additions & 5 deletions src/Aguacongas.AspNetCore.Authentication/ContractResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ
var property = base.CreateProperty(member, memberSerialization);
var propertyInfo = member as PropertyInfo;
var propertyType = propertyInfo?.PropertyType;
property.ShouldSerialize = instance => propertyType != null &&
(!propertyType.IsInterface ||
property.ShouldSerialize = instance => propertyType != null &&
(!propertyType.IsInterface ||
(typeof(IEnumerable).IsAssignableFrom(propertyType) &&
propertyType.IsGenericType
&& propertyType.GetGenericArguments().Any(a => !a.IsInterface)))
propertyType.IsGenericType
&& propertyType.GetGenericArguments().Any(a => !a.IsInterface && !a.IsAbstract)))
&& !propertyType.IsSubclassOf(typeof(Delegate));

return property;
}
}
}
}
7 changes: 7 additions & 0 deletions src/Aguacongas.AspNetCore.Authentication/TypeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Project: aguacongas/DymamicAuthProviders
// Copyright (c) 2021 @Olivier Lefebvre
using Microsoft.AspNetCore.Authentication;
#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif

namespace System
{
Expand All @@ -15,7 +18,11 @@ public static class TypeExtensions
/// <param name="handlerType">Type of the handler.</param>
/// <returns></returns>
/// <exception cref="ArgumentException">Parameter handlerType should be a <see cref="AuthenticationHandler{AuthenticationSchemeOptions}"/>}</exception>
#if NET8_0_OR_GREATER
public static Type GetAuthenticationSchemeOptionsType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] this Type handlerType)
#else
public static Type GetAuthenticationSchemeOptionsType(this Type handlerType)
#endif
{
if (handlerType.GetInterface(nameof(IAuthenticationHandler)) == null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DebugType>Full</DebugType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -11,8 +11,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0-rc.2.23480.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23503-02" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
Loading