From ee6db0a56e680c75676e84bf5defb6de0fee76fb Mon Sep 17 00:00:00 2001 From: Marco Minerva Date: Wed, 9 Sep 2026 12:22:19 +0200 Subject: [PATCH] Update style, workflows, structure, and dependencies .editorconfig: Add new C# style/formatting rules (implicit lambdas, unbound generics in nameof, static anonymous functions). GitHub Actions: Switch publish workflow to NuGet OIDC login, removing static API key. Solution: Refactor SimpleAuthentication.slnx to use lowercase folder names and group src projects under /src/. Dependencies: Upgrade Nerdbank.GitVersioning to 3.10.94 in Directory.Build.props. Code: Refactor PermissionAttribute to use a primary constructor and file-scoped namespace. Packages: Update Microsoft.AspNetCore.Authentication.JwtBearer references in SimpleAuthentication.Abstractions.csproj to latest patch versions for .NET 8, 9, and 10. --- .editorconfig | 3 +++ .github/workflows/publish_abstractions.yml | 11 +++++++++-- SimpleAuthentication.slnx | 14 ++++++++------ src/Directory.Build.props | 2 +- .../Permissions/PermissionAttribute.cs | 4 +--- .../SimpleAuthentication.Abstractions.csproj | 6 +++--- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8f8512a..430f71b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -124,6 +124,7 @@ csharp_style_prefer_null_check_over_type_check = true:suggestion # Modifier preferences csharp_prefer_static_local_function = true:suggestion +csharp_prefer_static_anonymous_function = true:suggestion csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent # Code-block preferences @@ -139,9 +140,11 @@ csharp_prefer_system_threading_lock = true:suggestion csharp_prefer_simple_default_expression = true:suggestion csharp_style_deconstructed_variable_declaration = false:suggestion csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_prefer_implicitly_typed_lambda_expression = true:suggestion csharp_style_pattern_local_over_anonymous_function = true:suggestion csharp_style_prefer_index_operator = true:suggestion csharp_style_prefer_range_operator = true:suggestion +csharp_style_prefer_unbound_generic_type_in_nameof = true:suggestion csharp_style_throw_expression = true:suggestion csharp_style_unused_value_assignment_preference = discard_variable:none csharp_style_unused_value_expression_statement_preference = discard_variable:none diff --git a/.github/workflows/publish_abstractions.yml b/.github/workflows/publish_abstractions.yml index a585fae..43c2781 100644 --- a/.github/workflows/publish_abstractions.yml +++ b/.github/workflows/publish_abstractions.yml @@ -2,7 +2,8 @@ name: Publish Abstractions on NuGet permissions: contents: write - + id-token: write + on: push: branches: [ master ] @@ -42,8 +43,14 @@ jobs: - name: Package run: dotnet pack -c Release -o . '${{ env.PROJECT_NAME }}/${{ env.PROJECT_FILE }}' + - name: NuGet login (OIDC → temp API key) + uses: NuGet/login@v1 + id: login + with: + user: ${{ secrets.NUGET_USER }} + - name: Publish on NuGet - run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json + run: dotnet nuget push *.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json - name: Create release uses: softprops/action-gh-release@v2 diff --git a/SimpleAuthentication.slnx b/SimpleAuthentication.slnx index a2c7293..4b09762 100644 --- a/SimpleAuthentication.slnx +++ b/SimpleAuthentication.slnx @@ -1,11 +1,11 @@ - - + + - + @@ -15,7 +15,9 @@ - - - + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 18d1785..268fee9 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -9,7 +9,7 @@ - + diff --git a/src/SimpleAuthentication.Abstractions/Permissions/PermissionAttribute.cs b/src/SimpleAuthentication.Abstractions/Permissions/PermissionAttribute.cs index 4a05b7a..800c1d9 100644 --- a/src/SimpleAuthentication.Abstractions/Permissions/PermissionAttribute.cs +++ b/src/SimpleAuthentication.Abstractions/Permissions/PermissionAttribute.cs @@ -10,6 +10,4 @@ namespace SimpleAuthentication.Permissions; /// /// The permission list to require for authorization. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] -public class PermissionAttribute(params string[] permissions) : AuthorizeAttribute(string.Join(",", permissions)) -{ -} +public class PermissionAttribute(params string[] permissions) : AuthorizeAttribute(string.Join(",", permissions)); \ No newline at end of file diff --git a/src/SimpleAuthentication.Abstractions/SimpleAuthentication.Abstractions.csproj b/src/SimpleAuthentication.Abstractions/SimpleAuthentication.Abstractions.csproj index 43aec2e..8b5d1ac 100644 --- a/src/SimpleAuthentication.Abstractions/SimpleAuthentication.Abstractions.csproj +++ b/src/SimpleAuthentication.Abstractions/SimpleAuthentication.Abstractions.csproj @@ -28,15 +28,15 @@ - + - + - +