Skip to content

Commit

Permalink
add tfm net8.0; remove tfm netcoreapp3.1 and net5.0;
Browse files Browse the repository at this point in the history
  • Loading branch information
stratosblue committed Nov 15, 2023
1 parent dc3c6e8 commit 7e148e9
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/PublishNugetPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'
- name: restore dependencies
run: dotnet restore
- name: build
Expand Down
110 changes: 110 additions & 0 deletions CodeMaid.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="SteveCadwallader.CodeMaid.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</sectionGroup>
</configSections>
<userSettings>
<SteveCadwallader.CodeMaid.Properties.Settings>
<setting name="Reorganizing_MemberTypeFields" serializeAs="String">
<value>Fields||3||字段</value>
</setting>
<setting name="Reorganizing_MemberTypeProperties" serializeAs="String">
<value>Properties||4||属性</value>
</setting>
<setting name="Reorganizing_MemberTypeMethods" serializeAs="String">
<value>Methods||9||方法</value>
</setting>
<setting name="Reorganizing_MemberTypeDelegates" serializeAs="String">
<value>Delegates||1||委托</value>
</setting>
<setting name="Reorganizing_MemberTypeEvents" serializeAs="String">
<value>Events||2||事件</value>
</setting>
<setting name="Reorganizing_MemberTypeInterfaces" serializeAs="String">
<value>Interfaces||8||接口</value>
</setting>
<setting name="Reorganizing_MemberTypeConstructors" serializeAs="String">
<value>Constructors||6||构造函数</value>
</setting>
<setting name="Reorganizing_MemberTypeEnums" serializeAs="String">
<value>Enums||10||枚举</value>
</setting>
<setting name="Reorganizing_MemberTypeDestructors" serializeAs="String">
<value>Destructors||7||析构函数</value>
</setting>
<setting name="Reorganizing_MemberTypeIndexers" serializeAs="String">
<value>Indexers||5||索引器</value>
</setting>
<setting name="Reorganizing_MemberTypeClasses" serializeAs="String">
<value>Classes||12||类</value>
</setting>
<setting name="Reorganizing_MemberTypeStructs" serializeAs="String">
<value>Structs||11||结构体</value>
</setting>
<setting name="Reorganizing_RegionsInsertNewRegions" serializeAs="String">
<value>True</value>
</setting>
<setting name="Reorganizing_RunAtStartOfCleanup" serializeAs="String">
<value>True</value>
</setting>
<setting name="Reorganizing_RegionsRemoveExistingRegions" serializeAs="String">
<value>False</value>
</setting>
<setting name="Digging_PrimarySortOrder" serializeAs="String">
<value>0</value>
</setting>
<setting name="Reorganizing_RegionsIncludeAccessLevel" serializeAs="String">
<value>True</value>
</setting>
<setting name="General_Font" serializeAs="String">
<value>Consolas</value>
</setting>
<setting name="Reorganizing_ReverseOrderByAccessLevel" serializeAs="String">
<value>False</value>
</setting>
<setting name="Reorganizing_ExplicitMembersAtEnd" serializeAs="String">
<value>True</value>
</setting>
<setting name="General_Theme" serializeAs="String">
<value>1</value>
</setting>
<setting name="Cleaning_AutoSaveAndCloseIfOpenedByCleanup" serializeAs="String">
<value>False</value>
</setting>
<setting name="Collapsing_CollapseSolutionWhenOpened" serializeAs="String">
<value>False</value>
</setting>
<setting name="Collapsing_KeepSoloProjectExpanded" serializeAs="String">
<value>False</value>
</setting>
<setting name="Cleaning_RemoveEndOfFileTrailingNewLine" serializeAs="String">
<value>False</value>
</setting>
<setting name="Cleaning_InsertEndOfFileTrailingNewLine" serializeAs="String">
<value>True</value>
</setting>
<setting name="Cleaning_InsertBlankLinePaddingBeforePropertiesSingleLine"
serializeAs="String">
<value>True</value>
</setting>
<setting name="Cleaning_InsertBlankLinePaddingBeforeFieldsSingleLine"
serializeAs="String">
<value>True</value>
</setting>
<setting name="Feature_SettingCleanupOnSave" serializeAs="String">
<value>True</value>
</setting>
<setting name="Finding_TemporarilyOpenSolutionFolders" serializeAs="String">
<value>False</value>
</setting>
<setting name="Progressing_HideBuildProgressOnBuildStop" serializeAs="String">
<value>True</value>
</setting>
<setting name="Feature_FindInSolutionExplorer" serializeAs="String">
<value>False</value>
</setting>
</SteveCadwallader.CodeMaid.Properties.Settings>
</userSettings>
</configuration>
11 changes: 1 addition & 10 deletions Cuture.AspNetCore.ResponseAutoWrapper.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cuture.AspNetCore.ResponseA
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResponseAutoWrapper.BenchmarkHost", "test\ResponseAutoWrapper.BenchmarkHost\ResponseAutoWrapper.BenchmarkHost.csproj", "{5D1825E3-5801-45B2-9423-8BE58E69C1AC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{08A4E6D1-373E-4E59-B0AD-E78E711793F3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{10375BEE-CD2F-4DE6-891F-26590777E429}"
ProjectSection(SolutionItems) = preProject
.github\workflows\PublishNugetPackage.yml = .github\workflows\PublishNugetPackage.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomStructureWebApplication", "sample\CustomStructureWebApplication\CustomStructureWebApplication.csproj", "{ADD4ADD6-A3FF-44FE-AEE8-B8758E1F13F5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomStructureWebApplication", "sample\CustomStructureWebApplication\CustomStructureWebApplication.csproj", "{ADD4ADD6-A3FF-44FE-AEE8-B8758E1F13F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -74,8 +67,6 @@ Global
{69144DD5-E0FB-4FCF-8763-579D0A16E7D5} = {617DB063-D28A-4F46-A93F-FF89ADD787AC}
{BB62B5BF-27B1-4DEC-90EC-75E48B11E886} = {E536BBD4-DBE4-4C31-A179-837B78A29A8B}
{5D1825E3-5801-45B2-9423-8BE58E69C1AC} = {64317A26-58AF-45C1-A285-4EBB0A678BCC}
{08A4E6D1-373E-4E59-B0AD-E78E711793F3} = {20964519-17B2-4D4B-9E75-E83D57AAB3B7}
{10375BEE-CD2F-4DE6-891F-26590777E429} = {08A4E6D1-373E-4E59-B0AD-E78E711793F3}
{ADD4ADD6-A3FF-44FE-AEE8-B8758E1F13F5} = {617DB063-D28A-4F46-A93F-FF89ADD787AC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>

<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
![执行流程概览](./execution_flow.png)

## 2. 注意项
- 目标框架`net6.0``net5.0``netcoreapp3.1`
- 目标框架`net6.0+`
- 包装功能由两个包装器实现:
- 基于`ResultFilter``ActionResult`包装器:针对方法的返回值包装;
- 基于`中间件`的包装器:针对异常、非200响应包装;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net5.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>

<OpenApiGenerateDocuments>false</OpenApiGenerateDocuments>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion sample/SimpleWebApplication/SimpleWebApplication.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net5.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>

<OpenApiGenerateDocuments>false</OpenApiGenerateDocuments>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<IsPackable>true</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<Version>1.1.1</Version>
<Description>用于`asp.net core`的响应和异常自动包装器,使`Action`提供一致的响应内容格式</Description>
<Version>1.2.0</Version>
<Description>Response and exception automatic wrapper for `asp.net core` to provide a consistent response content format for `Action`. 用于`asp.net core`的响应和异常自动包装器,使`Action`提供一致的响应内容格式</Description>

<PackageIdPrefix>Cuture.AspNetCore.ResponseAutoWrapper</PackageIdPrefix>
<Authors>Stratos</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;

#if NET5_0_OR_GREATER
using Microsoft.AspNetCore.Authorization;
#endif

namespace Microsoft.Extensions.DependencyInjection;

Expand Down Expand Up @@ -95,15 +93,8 @@ public static IResponseAutoWrapperBuilder<TResponse, TCode, TMessage> AddRespons
public static IResponseAutoWrapperBuilder<TResponse, TCode, TMessage> AddResponseAutoWrapper<TResponse, TCode, TMessage>(this IServiceCollection services, ResponseAutoWrapperOptions options)
where TResponse : class
{
if (services is null)
{
throw new ArgumentNullException(nameof(services));
}

if (options is null)
{
throw new ArgumentNullException(nameof(options));
}
ArgumentNullException.ThrowIfNull(services);
ArgumentNullException.ThrowIfNull(options);

services.AddControllers();

Expand All @@ -119,12 +110,10 @@ public static IResponseAutoWrapperBuilder<TResponse, TCode, TMessage> AddRespons
options.Filters.AddService<ResponseAutoWrapResultFilter<TResponse, TCode, TMessage>>(Constants.DefaultFilterOrder);
});

#if NET5_0_OR_GREATER
if (options.HandleAuthorizationResult)
{
services.TryAddEnumerable(ServiceDescriptor.Singleton<IAuthorizationMiddlewareResultHandler, AutoWrapperAuthorizationMiddlewareResultHandler>());
}
#endif

if (options.HandleInvalidModelState)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if NET5_0_OR_GREATER
using System.Threading.Tasks;
using System.Threading.Tasks;

using Microsoft.AspNetCore.Authorization.Policy;
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -33,4 +32,3 @@ public Task HandleAsync(RequestDelegate next, HttpContext context, Authorization

#endregion Public 方法
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

#if NET5_0_OR_GREATER

using Microsoft.AspNetCore.Authorization;

#endif

namespace Cuture.AspNetCore.ResponseAutoWrapper;

/// <summary>
Expand Down Expand Up @@ -39,8 +35,6 @@ public class ResponseAutoWrapperOptions
/// <value>default value is 'false'</value>
public bool DisableOpenAPISupport { get; set; } = false;

#if NET5_0_OR_GREATER

/// <summary>
/// 处理授权失败响应<para/>
/// 注册 <see cref="AutoWrapperAuthorizationMiddlewareResultHandler"/> 为 <see cref="IAuthorizationMiddlewareResultHandler"/><para/>
Expand All @@ -49,8 +43,6 @@ public class ResponseAutoWrapperOptions
/// <value>default value is 'false'</value>
public bool HandleAuthorizationResult { get; set; } = false;

#endif

/// <summary>
/// 处理无效模型绑定状态<para/>
/// 设置 <see cref="ApiBehaviorOptions.InvalidModelStateResponseFactory"/> 为使用 <see cref="IInvalidModelStateWrapper{TResponse, TCode, TMessage}"/> 处理的委托<para/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFrameworks>net5.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0</TargetFrameworks>

<OpenApiGenerateDocuments>false</OpenApiGenerateDocuments>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public string Jwt([FromQuery] bool canAccess)
{
new Claim("CanAccess",canAccess?"1":"0"),
};
var key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("123456789123456789"));
var key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("123456789123456789_123456789123456789"));
var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
var jwtToken = new JwtSecurityToken("Issuer", "Audience", claims, expires: DateTime.Now.AddMinutes(600), signingCredentials: credentials);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Cuture.Http" Version="2.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Cuture.Http" Version="2.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Cuture.Http" Version="2.*" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.*" />
Expand All @@ -36,10 +24,16 @@

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Cuture.Http" Version="2.*" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.*-*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.*-*" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Cuture.Http" Version="2.*" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Cuture.AspNetCore.ResponseAutoWrapper\Cuture.AspNetCore.ResponseAutoWrapper.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/ResponseAutoWrapper.TestHost/Startups/BaseStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public virtual void ConfigureServices(IServiceCollection services)
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("123456789123456789")),
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("123456789123456789_123456789123456789")),
ValidIssuer = "Issuer",
ValidAudience = "Audience",
ValidateIssuer = false,
Expand Down

0 comments on commit 7e148e9

Please sign in to comment.