Skip to content

Commit 8b0a70d

Browse files
xavierjohncommonsensesoftware
authored andcommitted
If Controller Attribute is set, use it for the controller's name
1 parent 471eb04 commit 8b0a70d

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ jobs:
2929

3030
- name: Setup .NET
3131
uses: actions/setup-dotnet@v3
32+
id: installdotnet
3233
with:
3334
dotnet-version: 7.0.x
3435

36+
- name: Create temporary global.json
37+
run: echo '{"sdk":{"version":"${{ steps.installdotnet.outputs.dotnet-version }}"}}' > ./global.json
38+
3539
# build a temporary *.slnf file that only contains source projects and put it in ~/obj
3640
# so that it is not tracked by git. then run 'dotnet build' using the *.slnf, which
3741
# will preserve the dependency order and configuration of the *.sln

src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/ApiVersioningApplicationModelProvider.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,14 @@ public virtual void OnProvidersExecuting( ApplicationModelProviderContext contex
8181
{
8282
var controller = controllers[i];
8383

84-
controller.ControllerName = NamingConvention.NormalizeName( controller.ControllerName );
84+
if ( controller.RouteValues.TryGetValue( "controller", out var name ) )
85+
{
86+
controller.ControllerName = name!;
87+
}
88+
else
89+
{
90+
controller.ControllerName = NamingConvention.NormalizeName( controller.ControllerName );
91+
}
8592

8693
if ( !ConventionBuilder.ApplyTo( controller ) )
8794
{

src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/Asp.Versioning.Mvc.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<VersionPrefix>7.1.0</VersionPrefix>
4+
<VersionPrefix>7.1.1</VersionPrefix>
55
<AssemblyVersion>7.1.0.0</AssemblyVersion>
66
<TargetFramework>net7.0</TargetFramework>
77
<RootNamespace>Asp.Versioning</RootNamespace>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-

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

0 commit comments

Comments
 (0)