Skip to content

[dotnet-sdk-10.0.100-preview.2.25125.6] IAuthenticationService.ImplementationType returns Microsoft.AspNetCore.Authentication.AuthenticationServiceImpl instead #60645

Closed
@Junjun-zhao

Description

@Junjun-zhao

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When we run unittest Ocelot by command dotnet vstest with the latest version dotnet-sdk-10.0.100-preview.2.25125.6, it failed with error: The provided expression should be of type Microsoft.AspNetCore.Authentication.AuthenticationService but was Microsoft.AspNetCore.Authentication.AuthenticationServiceImpl.

Application Name: Ocelot
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-10.0.100-preview.2.25125.6
App & Source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2399787
Github Link: https://github.com/ThreeMammals/Ocelot

Verify Scenarios:
1). Windows10 21h2 x64 + dotnet-sdk-8.0.400: Pass
2). Windows10 21h2 x64 + dotnet-sdk-9.0.104: Pass
3). Windows10 21h2 x64 + dotnet-sdk-10.0.100-preview.2.25104.2: Pass
4). Windows10 21h2 x64 + dotnet-sdk-10.0.100-preview.2.25115.1: Fail
5). Windows10 21h2 x64 + dotnet-sdk-10.0.100-preview.2.25125.6: Fail

Expected Behavior

All cases passed.

Steps To Reproduce

Minimal Repro Steps:(The machine has dotnet-sdk-10.0.100-preview.2.25125.6 installed.)

(Attached Demo:WebDemo.zip)

  1. Create a .NET 8.0 ASP .NET project.
  2. Copy the following code to Program.cs:
builder.Services.AddAuthentication();
var ser = builder.Services.Where(s => s.ServiceType == typeof(IAuthenticationService)).FirstOrDefault();
Console.WriteLine("Service ImplementationType: " + ser.ImplementationType);
  1. Build the project.
  2. Change the runtime to let it runs with dotnet-sdk-10.0.100-preview.2.25125.6:
{
        "name": "Microsoft.NETCore.App",
        "version": "10.0.0-preview.2.25121.10"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "10.0.0-preview.2.25124.13"
      }
  1. Launch the project.

Expected Result:
We will see Service ImplementationType in top of Command prompt window:
Microsoft.AspNetCore.Authentication.AuthenticationService

Actual Result:
We will see Service ImplementationType in top of Command prompt window: Microsoft.AspNetCore.Authentication.AuthenticationServiceImpl

App Repro Steps:(The machine has only dotnet-sdk-10.0.100-preview.2.25125.6 installed.)

  1. Change the Ocelot.UnitTests.runtimeconfig.json to let it runs with dotnet-sdk-10.0.100-preview.2.25125.6:
{
        "name": "Microsoft.NETCore.App",
        "version": "10.0.0-preview.2.25121.10"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "10.0.0-preview.2.25124.13"
      }

2.Type “cd Ocelot\App\OcelotTest01” in command, keyboard Enter.
3.Type “dotnet vstest Ocelot.UnitTests.dll” in command, keyboard Enter.

Exceptions (if any)

There is a case failed with error:

Error Message:

   Shouldly.ShouldAssertException : Shouldly uses your source code to generate its great error messages, build your test project with full debug information to get better error messages
The provided expression
    should be of type
Microsoft.AspNetCore.Authentication.AuthenticationService
    but was
Microsoft.AspNetCore.Authentication.AuthenticationServiceImpl
  Stack Trace:
     at Ocelot.UnitTests.DependencyInjection.OcelotBuilderTests.CstorShouldUseDefaultBuilderToInitMvcCoreBuilder() in D:\source\Ocelot\test\Ocelot.UnitTests\DependencyInjection\OcelotBuilderTests.cs:line 256
   at TestStack.BDDfy.StepActionFactory.<>c__DisplayClass1_0`1.<GetStepAction>b__0(Object o)
   at TestStack.BDDfy.StepExecutor.Execute(Step step, Object testObject)
   at TestStack.BDDfy.Processors.ScenarioExecutor.<>c__DisplayClass3_0.<ExecuteStep>b__0()
   at TestStack.BDDfy.Processors.AsyncTestRunner.Run(Func`1 performStep)
   at TestStack.BDDfy.Processors.ScenarioExecutor.ExecuteStep(Step step)

.NET Version

10.0.100-preview.2.25125.6

Anything else?

Findings:
In previous version of sdk, the ImplementationType property of IAuthenticationService service returns "Microsoft.AspNetCore.Authentication.AuthenticationService``". But start from dotnet-sdk-10.0.100-preview.2.25115.1, it returns "Microsoft.AspNetCore.Authentication.AuthenticationServiceImpl" instead. Compare the Microsoft.AspNetCore.Authentication.Core.dll in ILSpy between previous sdk and the sdk version after 10.0.100-preview.2.25115.1, we found that there is a new type Microsoft.AspNetCore.Authentication.AuthenticationServiceImpl``` added in the sdk version after 10.0.100-preview.2.25115.1 and it is returned when getting the ImplementationType property of IAuthenticationService.

dotnet info:

.NET SDK:
 Version:           10.0.100-preview.2.25125.6
 Commit:            ff311001a6
 Workload version:  10.0.100-manifests.2280ad1c
 MSBuild version:   17.14.0-preview-25124-03+63aefc3dc

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\10.0.100-preview.2.25125.6\

Host:
  Version:      10.0.0-preview.2.25121.10
  Architecture: x64
  Commit:       8ed081e7dd

.NET SDKs installed:
  10.0.100-preview.2.25125.6 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 10.0.0-preview.2.25124.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 10.0.0-preview.2.25121.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 10.0.0-preview.2.25124.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@dotnet-actwx-bot @dotnet/compat

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions