Closed xiaomi7732 closed 1 year ago
Hi sloncho, thanks for reporting the error. I can't reproduce the issue on my end. Need more info for troubleshooting. To help me understand the scenario, do you mind taking a look at this repository:
https://github.com/xiaomi7732/Profiler-WebApplicationFactory-tests-troubleshooting
and help me understand the difference between that project and yours and why there is no issue on my side.
Command logs FYI:
PS D:\Demo\ProfilerWithWebApplicationFactory\UnitTestsNet3> dotnet test
CSC : warning CS8032: An instance of analyzer System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from C:\Users\user\.nuget\packages\system.text.json\6.0.1\analyzers\dotnet\roslyn3.11\cs\System.Text.Json.SourceGeneration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [D:\Demo\ProfilerWithWebApplicationFactory\UnitTestsNet3\UnitTestsNet3.csproj]
CSC : warning CS8032: An instance of analyzer System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from C:\Users\user\.nuget\packages\system.text.json\6.0.1\analyzers\dotnet\roslyn4.0\cs\System.Text.Json.SourceGeneration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [D:\Demo\ProfilerWithWebApplicationFactory\UnitTestsNet3\UnitTestsNet3.csproj]
Test run for D:\Demo\ProfilerWithWebApplicationFactory\UnitTestsNet3\bin\Debug\netcoreapp3.1\UnitTestsNet3.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.7.1
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Test Run Successful.
Total tests: 2
Passed: 2
Total time: 9.8030 Seconds
PS D:\Demo\ProfilerWithWebApplicationFactory\UnitTestsNet3>
Since the process id, in this case, isn't critical to have, I have a workaround baked into the next release. ETA to ship with 2.5.1.
@sloncho, just so that you know, the workaround should have been released in this beta package: https://www.nuget.org/packages/Microsoft.ApplicationInsights.Profiler.AspNetCore/2.5.1-beta2
Stable package released: https://www.nuget.org/packages/Microsoft.ApplicationInsights.Profiler.AspNetCore/2.5.1
This is reported in #182. Since it looks like a different bug, I moved it here.
Basically, sloncho reported that Enabling Profiler in WebApplicationFactory scenario breaks the DI graph due to lack of process id.
Here's the attached callstack:
This is initially found on 2.5.0. I have a hunch that it is due to the fix of #140 and #167. I'll investigate.