diff --git a/docs/core/testing/microsoft-testing-platform-troubleshooting.md b/docs/core/testing/microsoft-testing-platform-troubleshooting.md index 31e6f2cbd9842..162a3f15bb156 100644 --- a/docs/core/testing/microsoft-testing-platform-troubleshooting.md +++ b/docs/core/testing/microsoft-testing-platform-troubleshooting.md @@ -3,7 +3,7 @@ title: Microsoft.Testing.Platform (MTP) troubleshooting description: Troubleshoot MTP issues, exit codes, and known problems. author: Evangelink ms.author: amauryleve -ms.date: 02/24/2026 +ms.date: 05/25/2026 ai-usage: ai-assisted --- @@ -86,6 +86,22 @@ Manually defining an entry point (`Main`) in a test project or referencing a tes - Completely disable the transitive dependency to `Microsoft.Testing.Platform.MSBuild` by setting the `false` MSBuild property in the project that references a test project. This is needed when you reference a test project from a non-test project, for example, a console app that references a test application. +#### Generated code namespace conflicts with a referenced type + +`Microsoft.Testing.Platform.MSBuild` generates the `SelfRegisteredExtensions` and `TestingPlatformEntryPoint` types inside the project's `$(RootNamespace)`. By default, `RootNamespace` matches the project name, which can collide with a type of the same fully qualified name exposed by a referenced assembly. + +For example, a project named `System.Security.Cryptography.ProtectedData.Tests` ends up generating code in the `System.Security.Cryptography.ProtectedData` namespace. If the project also references the `System.Security.Cryptography.ProtectedData` NuGet package, which contains a public `ProtectedData` type under the `System.Security.Cryptography` namespace, the compiler can no longer disambiguate between the generated namespace and the referenced type, and emits errors such as `CS0118` ("'ProtectedData' is a namespace but is used like a type"). + +To resolve the conflict, override `RootNamespace` in your test project to a value that doesn't collide with any referenced type: + +```xml + + System.Security.Cryptography.ProtectedDataTests + +``` + +You can also clear `RootNamespace` entirely (``), in which case the generated types are emitted into the global namespace. + ### Microsoft.Testing.Extensions.Fakes #### Fakes error Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables