Cleanup CurrentTestApplicationModuleInfo#7693
Conversation
There was a problem hiding this comment.
Pull request overview
This PR cleans up CurrentTestApplicationModuleInfo in Microsoft.Testing.Platform by simplifying argument selection logic and calling out suspicious executable-detection behavior.
Changes:
- Removes the redundant
isMonoMuxerlocal/switch arm inGetCurrentExecutableInfo. - Adds a TODO noting suspicious logic in
IsCurrentTestApplicationModuleExecutable.
src/Platform/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs
Show resolved
Hide resolved
Evangelink
left a comment
There was a problem hiding this comment.
Review Summary
Thanks for the cleanup, @Youssef1313! I reviewed both changes in detail.
1. Mono muxer arm removal — Correct ✅
I verified that the (_, _, true) => commandLineArguments arm was provably redundant. When mono is active, both isAppHost and isDotnetMuxer are false, so the default arm _ => commandLineArguments produces the identical result. The removal also eliminates a redundant IsCurrentTestApplicationHostMonoMuxer evaluation (which called GetProcessPath() + Path.GetFileNameWithoutExtension() a second time). Clean improvement.
2. TODO on IsCurrentTestApplicationModuleExecutable — Valid bug identification ⚠️
The processPath != ".dll" check compares a full file path to the literal ".dll", which will never match — making the property always return true. This cascades into IsAppHostOrSingleFileOrNativeAot effectively becoming !isDotnet && !isMono.
The TODO is a reasonable approach for a cleanup PR, though I'd suggest making it more descriptive (see inline comment) and/or filing an issue to track it, since the fix has behavioral implications for RetryOrchestrator and TestHostControllersTestHost.
Non-blocking suggestions
- Make TODO text more specific about why it's always true and what callers are affected
- Add a brief
// includes mono muxernote to the default switch arm to preserve documentation value - Consider adding unit tests with mocked
IEnvironment/IProcessHandlerfor the executable info switch branches (pre-existing gap)
Overall this is a clean, low-risk change. LGTM with minor suggestions.
isMonoMuxerlocal variable. The fallback already returnscommandLineArgumentsso there is no need to special case mono per the existing logic.