You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingMicrosoft.CodeAnalysis;namespaceGenerator{[Generator]publicclassGenerator:IIncrementalGenerator{publicvoidInitialize(IncrementalGeneratorInitializationContextcontext)=>context.RegisterSourceOutput(context.CompilationProvider,(sourceCtx,_)=>{sourceCtx.AddSource("GeneratedTest.cs",""" using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace GeneratedTests { [TestClass] public sealed class GeneratedTest { [TestMethod] public void TestMethod() { Assert.IsTrue(true); } } } """);});}}
(of course in reality this actually generates something)
If I now click Run All Tests on the Runner project, the tests are found, and run correctly. However, clicking on the TestMethod in Test Explorer
leads to this exception seen in the Test Output window
[20/02/2025 11:32:04.319 AM] Source location lookup for Source: D:\temp\Runner\bin\Debug\net8.0\Runner.dll by ManagedType: GeneratedTests.GeneratedTest and ManagedMethod: TestMethod
[20/02/2025 11:32:04.557 AM] [Error] System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at EnvDTE.ItemOperations.OpenFile(String FileName, String ViewKind)
at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.Internal.TestWindowViewModel.<<OnNavigationRequested>b__140_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__12.MoveNext()
[20/02/2025 11:32:05.374 AM] [Error] System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at EnvDTE.ItemOperations.OpenFile(String FileName, String ViewKind)
at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.Internal.TestWindowViewModel.<<OnNavigationRequested>b__140_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__12.MoveNext()
and nothing happens.
Expected behavior: the generated source file is opened (I emit them if that matters, but possibly more is needed?).
Actual behavior: nothing happens
The text was updated successfully, but these errors were encountered:
@mjvh80 this is not the best repo to report this issue, if you post on https://developercommunity.visualstudio.com/home you will have a better luck getting this tracked by Test Explorer team. I tagged Abhitej above, so it is up to you if you decide to file it on visual studio, or keep it here. :)
Summary: Cannot open Roslyn generated tests via Test Explorer
The Roslyn generator project looks like
and something like
(of course in reality this actually generates something)
The consuming project looks like
If I now click Run All Tests on the Runner project, the tests are found, and run correctly. However, clicking on the
TestMethod
in Test Explorerleads to this exception seen in the Test Output window
and nothing happens.
Expected behavior: the generated source file is opened (I emit them if that matters, but possibly more is needed?).
Actual behavior: nothing happens
The text was updated successfully, but these errors were encountered: