Skip to content
This repository was archived by the owner on Aug 24, 2026. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2a746a0
Xunit v3 initial work
Youssef1313 Feb 23, 2025
3bdeede
Progress
Youssef1313 Feb 23, 2025
9d5be9d
Progress
Youssef1313 Feb 23, 2025
fcd5064
Progress
Youssef1313 Feb 23, 2025
3ece072
Progres......
Youssef1313 Feb 23, 2025
11158ed
Progress...
Youssef1313 Feb 23, 2025
dda0863
More progress..
Youssef1313 Feb 23, 2025
8f74a16
Progress...
Youssef1313 Feb 24, 2025
6518250
Progress
Youssef1313 Feb 24, 2025
259ca42
Progress
Youssef1313 Feb 24, 2025
6f4bb37
Add TODO
Youssef1313 Feb 24, 2025
7082cef
Small progress
Youssef1313 Feb 24, 2025
644c8aa
Progress
Youssef1313 Feb 25, 2025
0b1566a
Progress
Youssef1313 Feb 25, 2025
717cb52
A bit of progress
Youssef1313 Mar 1, 2025
46fd171
Progress
Youssef1313 Mar 1, 2025
e88a3f2
Progress
Youssef1313 Mar 1, 2025
f132aee
Progress
Youssef1313 Mar 1, 2025
7912ab5
Revert unintentional change
Youssef1313 Mar 1, 2025
cdca8aa
Packaging
Youssef1313 Mar 1, 2025
46f480a
Add test project for v3
Youssef1313 Mar 1, 2025
222861f
Update gen
Youssef1313 Mar 1, 2025
2e0300c
Update gen
Youssef1313 Mar 1, 2025
11d5d3b
Adjust doc comments in gen
Youssef1313 Mar 1, 2025
203288b
Wrap in marshal by ref to allow serialization
Youssef1313 Mar 2, 2025
ce9f4a3
Cleanup
Youssef1313 Mar 2, 2025
73b2077
Adjust for TestContext when executing in devenv
Youssef1313 Mar 2, 2025
9997152
Preserve older solution structure
Youssef1313 Mar 2, 2025
d8990a8
Fix build race
Youssef1313 Mar 2, 2025
dfa4496
Cleanup
Youssef1313 Mar 2, 2025
a9a9b6e
Missing semicolon
Youssef1313 Mar 2, 2025
127f8aa
Fix build error
Youssef1313 Mar 2, 2025
0ca0392
Progress - doesn't yet compile
Youssef1313 Mar 30, 2025
5c37094
Progress
Youssef1313 Mar 30, 2025
f08b9b8
Progress
Youssef1313 Mar 30, 2025
aad1f8c
Progress
Youssef1313 Mar 30, 2025
8c96f59
Progress more
Youssef1313 Mar 30, 2025
e4841db
Fixes for v2
Youssef1313 Mar 30, 2025
f507aaa
Fix
Youssef1313 Mar 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 37 additions & 18 deletions ExtensionTesting.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Exte
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Extensibility.Testing.SourceGenerator.UnitTests", "src\Microsoft.VisualStudio.Extensibility.Testing.SourceGenerator.UnitTests\Microsoft.VisualStudio.Extensibility.Testing.SourceGenerator.UnitTests.csproj", "{DA9797F0-F158-42AB-BE2B-922588756941}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.VisualStudio.Extensibility.Testing.Xunit.v3", "src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.v3\Microsoft.VisualStudio.Extensibility.Testing.Xunit.v3.csproj", "{076FCA31-75AF-4DE5-BD54-A3D057D8F2BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.VisualStudio.Extensibility.Testing.Xunit.v3.IntegrationTests", "src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.v3.IntegrationTests\Microsoft.VisualStudio.Extensibility.Testing.Xunit.v3.IntegrationTests.csproj", "{073D4E58-1EA3-463B-BE40-F636B3F98593}"
ProjectSection(ProjectDependencies) = postProject
{25E61E07-E449-4ABB-A197-BD5C8EE3347F} = {25E61E07-E449-4ABB-A197-BD5C8EE3347F}
EndProjectSection
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared.projitems*{346081a2-a088-4486-94b3-b586bd6fd888}*SharedItemsImports = 5
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{4232a7ba-a7b7-4c65-b7a1-17fb5cded299}*SharedItemsImports = 5
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{43cc037c-8ebc-424c-ab73-9dd4047924a1}*SharedItemsImports = 5
src\Microsoft.VisualStudio.IntegrationTestService.Shared\Microsoft.VisualStudio.IntegrationTestService.Shared.projitems*{56550d99-71d3-44fe-804c-944d82d639f6}*SharedItemsImports = 5
src\Microsoft.VisualStudio.IntegrationTestService.Shared\Microsoft.VisualStudio.IntegrationTestService.Shared.projitems*{5a516b07-7b9c-4ce1-9ddc-e59800919d64}*SharedItemsImports = 5
src\Microsoft.VisualStudio.IntegrationTestService.Shared\Microsoft.VisualStudio.IntegrationTestService.Shared.projitems*{629938e1-1c2c-4f01-8038-90a34a940ac8}*SharedItemsImports = 13
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{6a12cff7-2499-4671-8ebe-ec3f2ff2adf0}*SharedItemsImports = 5
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{75edeb61-db9d-4f12-b922-ecef8081cef1}*SharedItemsImports = 5
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{784cb5c8-6258-499d-8efb-7a601a6f7e46}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared.projitems*{8bda92b2-e2e0-4607-94f6-444f56ad0582}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared.projitems*{9b5759ad-4eff-4e2d-921b-d617bb8cfa22}*SharedItemsImports = 13
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{b3bed6cb-abfe-4bb8-8af7-901ff0c6f027}*SharedItemsImports = 13
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared.projitems*{c4c38eae-b6b1-4ee5-9f01-03b4d9249bbd}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared.projitems*{ce32d863-e8c3-461f-80c7-32d0b0853217}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared.projitems*{d7647395-129b-4f45-8c78-10e6f92fc8ad}*SharedItemsImports = 13
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{da8322bc-e135-41bb-838a-d87551092e1a}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -145,6 +134,14 @@ Global
{DA9797F0-F158-42AB-BE2B-922588756941}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA9797F0-F158-42AB-BE2B-922588756941}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA9797F0-F158-42AB-BE2B-922588756941}.Release|Any CPU.Build.0 = Release|Any CPU
{076FCA31-75AF-4DE5-BD54-A3D057D8F2BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{076FCA31-75AF-4DE5-BD54-A3D057D8F2BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{076FCA31-75AF-4DE5-BD54-A3D057D8F2BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{076FCA31-75AF-4DE5-BD54-A3D057D8F2BD}.Release|Any CPU.Build.0 = Release|Any CPU
{073D4E58-1EA3-463B-BE40-F636B3F98593}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{073D4E58-1EA3-463B-BE40-F636B3F98593}.Debug|Any CPU.Build.0 = Debug|Any CPU
{073D4E58-1EA3-463B-BE40-F636B3F98593}.Release|Any CPU.ActiveCfg = Release|Any CPU
{073D4E58-1EA3-463B-BE40-F636B3F98593}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -168,8 +165,30 @@ Global
{CE32D863-E8C3-461F-80C7-32D0B0853217} = {7A983C88-A0B8-4A6C-8837-E45ADD6C01EE}
{25E61E07-E449-4ABB-A197-BD5C8EE3347F} = {D2869BF7-27E8-42B9-BF23-8790C0CE08C2}
{DA9797F0-F158-42AB-BE2B-922588756941} = {D2869BF7-27E8-42B9-BF23-8790C0CE08C2}
{076FCA31-75AF-4DE5-BD54-A3D057D8F2BD} = {9ED7BE6A-BDEE-44CF-B5C8-EA5F6E212CFD}
{073D4E58-1EA3-463B-BE40-F636B3F98593} = {7A983C88-A0B8-4A6C-8837-E45ADD6C01EE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BEAADCC8-C5EB-46B6-8AA8-0242304BE240}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared.projitems*{073d4e58-1ea3-463b-be40-f636b3f98593}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared.projitems*{076fca31-75af-4de5-bd54-a3d057d8f2bd}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared.projitems*{346081a2-a088-4486-94b3-b586bd6fd888}*SharedItemsImports = 5
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{4232a7ba-a7b7-4c65-b7a1-17fb5cded299}*SharedItemsImports = 5
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{43cc037c-8ebc-424c-ab73-9dd4047924a1}*SharedItemsImports = 5
src\Microsoft.VisualStudio.IntegrationTestService.Shared\Microsoft.VisualStudio.IntegrationTestService.Shared.projitems*{56550d99-71d3-44fe-804c-944d82d639f6}*SharedItemsImports = 5
src\Microsoft.VisualStudio.IntegrationTestService.Shared\Microsoft.VisualStudio.IntegrationTestService.Shared.projitems*{5a516b07-7b9c-4ce1-9ddc-e59800919d64}*SharedItemsImports = 5
src\Microsoft.VisualStudio.IntegrationTestService.Shared\Microsoft.VisualStudio.IntegrationTestService.Shared.projitems*{629938e1-1c2c-4f01-8038-90a34a940ac8}*SharedItemsImports = 13
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{6a12cff7-2499-4671-8ebe-ec3f2ff2adf0}*SharedItemsImports = 5
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{75edeb61-db9d-4f12-b922-ecef8081cef1}*SharedItemsImports = 5
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{784cb5c8-6258-499d-8efb-7a601a6f7e46}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared.projitems*{8bda92b2-e2e0-4607-94f6-444f56ad0582}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared.projitems*{9b5759ad-4eff-4e2d-921b-d617bb8cfa22}*SharedItemsImports = 13
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{b3bed6cb-abfe-4bb8-8af7-901ff0c6f027}*SharedItemsImports = 13
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared.projitems*{c4c38eae-b6b1-4ee5-9f01-03b4d9249bbd}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.IntegrationTests.Shared.projitems*{ce32d863-e8c3-461f-80c7-32d0b0853217}*SharedItemsImports = 5
src\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared\Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared.projitems*{d7647395-129b-4f45-8c78-10e6f92fc8ad}*SharedItemsImports = 13
src\Microsoft.VisualStudio.VsixInstaller.Shared\Microsoft.VisualStudio.VsixInstaller.Shared.projitems*{da8322bc-e135-41bb-838a-d87551092e1a}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json"/>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must NOT be merged. I'll mirror the packages following https://github.com/dotnet/arcade/blob/main/Documentation/MirroringPackages.md once the PR is closer.

<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
<add key="vs-impl" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
}
}

var isXunit3 = compilation.ReferencedAssemblyNames.Any(assemblyName => assemblyName.Name.StartsWith("xunit.v3", StringComparison.Ordinal));

return new ReferenceDataModel(
hasSAsyncServiceProvider,
hasThreadHelperJoinableTaskContext,
Expand All @@ -1430,7 +1432,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
hasOperationProgress,
hasOperationProgressStatusService,
hasEditorConstants,
editorConstantsCommandIDMissingGuid);
editorConstantsCommandIDMissingGuid,
isXunit3);
});

context.RegisterSourceOutput(
Expand Down Expand Up @@ -1515,19 +1518,19 @@ protected InProcComponent(TestServices testServices)

protected JoinableTaskFactory JoinableTaskFactory => TestServices.JoinableTaskFactory;

Task IAsyncLifetime.InitializeAsync()
{(referenceDataModel.IsXUnit3 ? "ValueTask" : "Task")} IAsyncLifetime.InitializeAsync()
{{
return InitializeCoreAsync();
}}

Task IAsyncLifetime.DisposeAsync()
{(referenceDataModel.IsXUnit3 ? "ValueTask" : "Task")} {(referenceDataModel.IsXUnit3 ? "global::System.IAsyncDisposable" : "IAsyncLifetime")}.DisposeAsync()
{{
return Task.CompletedTask;
return {(referenceDataModel.IsXUnit3 ? "default" : "Task.CompletedTask")};
}}

protected virtual Task InitializeCoreAsync()
protected virtual {(referenceDataModel.IsXUnit3 ? "ValueTask" : "Task")} InitializeCoreAsync()
{{
return Task.CompletedTask;
return {(referenceDataModel.IsXUnit3 ? "default" : "Task.CompletedTask")};
}}

protected async Task<TInterface> GetRequiredGlobalServiceAsync<TService, TInterface>(CancellationToken cancellationToken)
Expand Down Expand Up @@ -1744,6 +1747,10 @@ namespace Microsoft.VisualStudio.Extensibility.Testing
}

usings2.Add("global::Xunit");
if (referenceDataModel.IsXUnit3)
{
usings2.Add("global::Xunit.v3");
}

if (!referenceDataModel.HasThreadHelperJoinableTaskContext)
{
Expand Down Expand Up @@ -1810,7 +1817,7 @@ namespace Microsoft.VisualStudio.Extensibility.Testing
/// <item><description><see cref=""BeforeAfterTestAttribute.Before""/></description></item>
/// <item><description>Test method</description></item>
/// <item><description><see cref=""BeforeAfterTestAttribute.After""/></description></item>
/// <item><description><see cref=""IAsyncLifetime.DisposeAsync""/></description></item>
/// <item><description><see cref=""{(referenceDataModel.IsXUnit3 ? "global::System.IAsyncDisposable" : "IAsyncLifetime")}.DisposeAsync""/></description></item>
/// <item><description><see cref=""IDisposable.Dispose""/></description></item>
/// </list>
/// </remarks>
Expand Down Expand Up @@ -1917,17 +1924,17 @@ private CancellationToken CleanupCancellationToken
=> _cleanupCancellationTokenSource.Token;

/// <inheritdoc/>
public virtual async Task InitializeAsync()
public virtual async {(referenceDataModel.IsXUnit3 ? "ValueTask" : "Task")} InitializeAsync()
{{
TestServices = await CreateTestServicesAsync();
}}

/// <summary>
/// This method implements <see cref=""IAsyncLifetime.DisposeAsync""/>, and is used for releasing resources
/// This method implements <see cref=""{(referenceDataModel.IsXUnit3 ? "global::System.IAsyncDisposable" : "IAsyncLifetime")}.DisposeAsync""/>, and is used for releasing resources
/// created by <see cref=""IAsyncLifetime.InitializeAsync""/>. This method is only called if
/// <see cref=""InitializeAsync""/> completes successfully.
/// </summary>
public virtual async Task DisposeAsync()
public virtual async {(referenceDataModel.IsXUnit3 ? "ValueTask" : "Task")} DisposeAsync()
{{
_cleanupCancellationTokenSource.CancelAfter(CleanupHangMitigatingTimeout);

Expand Down Expand Up @@ -2123,6 +2130,7 @@ private sealed record ReferenceDataModel(
bool HasOperationProgress,
bool HasOperationProgressStatusService,
bool HasEditorConstants,
bool EditorConstantsCommandIDMissingGuid);
bool EditorConstantsCommandIDMissingGuid,
bool IsXUnit3);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ namespace Xunit.Harness
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
#if !USES_XUNIT_3
using Xunit.Abstractions;
#endif
using Xunit.Sdk;

public static class DataCollectionService
Expand Down Expand Up @@ -96,13 +98,26 @@ public static void RegisterCustomLogger(Action<string> callback, string logId, s

internal static string GetTestName(ITestCase testCase)
{
#if USES_XUNIT_3
var testMethod = testCase.TestMethod;
var testClass = testMethod!.TestClass.TestClassName;
return $"{testClass}.{testMethod.MethodName}";
#else
var testMethod = testCase.TestMethod.Method;
var testClass = testMethod.Type.Name;
var lastDot = testClass.LastIndexOf('.');
testClass = testClass.Substring(lastDot + 1);
return $"{testClass}.{testMethod.Name}";
#endif
}

internal static string GetTestName(ITestCaseStarting testCaseStarting)
#if USES_XUNIT_3
=> $"{testCaseStarting.TestClassName}.{testCaseStarting.TestMethodName}";
#else
=> GetTestName(testCaseStarting.TestCase);
#endif

internal static void InstallFirstChanceExceptionHandler()
{
if (!_firstChanceExceptionHandlerInstalled)
Expand Down
Loading