Skip to content

Commit

Permalink
If Controller Attribute is set, use it for the controller's name
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierjohn authored and commonsensesoftware committed Nov 22, 2023
1 parent 471eb04 commit 948f281
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ jobs:

- name: Setup .NET
uses: actions/setup-dotnet@v3
id: installdotnet
with:
dotnet-version: 7.0.x

- name: Create temporary global.json
run: echo '{"sdk":{"version":"${{ steps.installdotnet.outputs.dotnet-version }}"}}' > ./global.json

# build a temporary *.slnf file that only contains source projects and put it in ~/obj
# so that it is not tracked by git. then run 'dotnet build' using the *.slnf, which
# will preserve the dependency order and configuration of the *.sln
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ public virtual void OnProvidersExecuting( ApplicationModelProviderContext contex
{
var controller = controllers[i];

controller.ControllerName = NamingConvention.NormalizeName( controller.ControllerName );
if ( controller.RouteValues.TryGetValue( "controller", out var name ) )
{
controller.ControllerName = name!;
}
else
{
controller.ControllerName = NamingConvention.NormalizeName( controller.ControllerName );
}

if ( !ConventionBuilder.ApplyTo( controller ) )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>7.1.0</VersionPrefix>
<VersionPrefix>7.1.1</VersionPrefix>
<AssemblyVersion>7.1.0.0</AssemblyVersion>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Asp.Versioning</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@

If Controller Attribute is set, use it for the controller name ([#1033](https://github.com/dotnet/aspnet-api-versioning/issues/1033))

0 comments on commit 948f281

Please sign in to comment.