Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of COM/process based ISP wrapper #49

Merged
merged 7 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: ✓ ensure format
run: dotnet format --verify-no-changes -v:diag --exclude ~/.nuget

- name: ⚙ msbuild
uses: microsoft/setup-msbuild@v1.1

Expand All @@ -53,11 +50,11 @@ jobs:
run: dotnet pack --no-build -m:1

- name: 🧪 test
timeout-minutes: 15
timeout-minutes: 10
uses: ./.github/workflows/test

- name: 📦 artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: failure()
with:
name: dumps-${{ github.run_number }}
Expand All @@ -71,6 +68,9 @@ jobs:
dotnet tool install -g --version 4.0.18 sleet
sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found"

- name: ✓ ensure format
run: dotnet format --verify-no-changes -v:diag --exclude ~/.nuget

# Only push CI package to nuget.org for releases
- name: 🚀 nuget
if: github.event_name == 'release'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ runs:
if [ $filter ]
then
echo -e "${warn}Retry $counter for $filter ${reset}"
dotnet test --no-build -m:1 --blame-hang --blame-hang-timeout 5m --filter=$filter | tee ./output.log
dotnet test --no-build -m:1 --blame-hang --blame-hang-timeout 3m --filter=$filter | tee ./output.log
else
dotnet test --no-build -m:1 --blame-hang --blame-hang-timeout 5m | tee ./output.log
dotnet test --no-build -m:1 --blame-hang --blame-hang-timeout 3m | tee ./output.log
fi
# capture dotnet test exit status, different from tee
exitcode=${PIPESTATUS[0]}
Expand Down
1 change: 1 addition & 0 deletions Xunit.Vsix.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 14.0.23107.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2AF55F73-4FE0-46B1-B5C4-534F028A90C1}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\test\action.yml = .github\workflows\test\action.yml
.github\workflows\build.yml = .github\workflows\build.yml
src\Directory.Build.props = src\Directory.Build.props
src\Directory.Build.targets = src\Directory.Build.targets
Expand Down
19 changes: 12 additions & 7 deletions src/Xunit.Vsix.Tests/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Threading;
using Microsoft.VisualStudio.Utilities;
using Xunit.Abstractions;

Expand All @@ -32,14 +33,13 @@ public async System.Threading.Tasks.Task SanityCheck()
var service = ServiceProvider.GlobalProvider.GetService<DTE>();
Assert.NotNull(service);

service = GlobalServiceProvider.GetService<DTE>();
Assert.NotNull(service);
var components = await ServiceProvider.GetGlobalServiceAsync<SComponentModel, IComponentModel>();

var hierarchy = GlobalServiceProvider.GetExport<IVsHierarchyItemManager>();
var hierarchy = components.GetService<IVsHierarchyItemManager>();

Assert.NotNull(hierarchy);

var items = GlobalServiceProvider.GetExports<ContentTypeDefinition>();
var items = components.GetExtensions<ContentTypeDefinition>();

Assert.NotEmpty(items);
}
Expand Down Expand Up @@ -67,22 +67,27 @@ public async Task when_reopenening_solution_then_hierarchy_item_is_same()
var dte = await ServiceProvider.GetGlobalServiceAsync<SDTE, DTE>();
var solutionEmpty = await ServiceProvider.GetGlobalServiceAsync<SVsSolution, IVsSolution>();
var components = await ServiceProvider.GetGlobalServiceAsync<SComponentModel, IComponentModel>();
var manager = components.GetService<IVsHierarchyItemManager>();

await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
var manager = components.GetService<IVsHierarchyItemManager>();

var solutionEmptyItem = manager.GetHierarchyItem(solutionEmpty as IVsHierarchy, (uint)VSConstants.VSITEMID.Root);
await TaskScheduler.Default;

Assert.NotNull(solutionEmptyItem);

dte.Solution.Open(Path.Combine(BaseDir, "Content", "Blank.sln"));

var solution1 = ServiceProvider.GlobalProvider.GetService<SVsSolution, IVsSolution>();
var solution1 = await ServiceProvider.GetGlobalServiceAsync<SVsSolution, IVsSolution>();

var solution1Item = manager.GetHierarchyItem(solution1 as IVsHierarchy, (uint)VSConstants.VSITEMID.Root);

dte.Solution.Close();

dte.Solution.Open(Path.Combine(BaseDir, "Content", "Blank.sln"));

var solution2 = ServiceProvider.GlobalProvider.GetService<SVsSolution, IVsSolution>();
var solution2 = await ServiceProvider.GetGlobalServiceAsync<SVsSolution, IVsSolution>();
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
var solution2Item = manager.GetHierarchyItem(solution2 as IVsHierarchy, (uint)VSConstants.VSITEMID.Root);

Assert.NotNull(solution1Item);
Expand Down
10 changes: 6 additions & 4 deletions src/Xunit.Vsix.Tests/SolutionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Microsoft.VisualStudio.Shell;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -73,9 +75,9 @@ public void when_succeeding_then_reports()
}

[VsixFact]
public void when_loading_solution_then_succeeds()
public async Task when_loading_solution_then_succeedsAsync()
{
var dte = GlobalServiceProvider.GetService<EnvDTE.DTE>();
var dte = await ServiceProvider.GetGlobalServiceAsync<EnvDTE.DTE, EnvDTE.DTE>();

Assert.NotNull(dte);

Expand All @@ -87,9 +89,9 @@ public void when_loading_solution_then_succeeds()
}

[VsixFact(VisualStudioVersion.VS2017)]
public void when_specific_version_then_runs_on_it()
public async Task when_specific_version_then_runs_on_itAsync()
{
var dte = GlobalServiceProvider.GetService<EnvDTE.DTE>();
var dte = await ServiceProvider.GetGlobalServiceAsync<EnvDTE.DTE, EnvDTE.DTE>();

Assert.NotNull(dte);

Expand Down
80 changes: 0 additions & 80 deletions src/Xunit.Vsix/GlobalServiceProvider.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Xunit.Vsix/VsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ bool EnsureStarted(VsixTestCase testCase, IMessageBus messageBus)
s_tracer.TraceEvent(TraceEventType.Error, 0, Strings.VsClient.FailedToStart(_visualStudioVersion, _rootSuffix));
messageBus.QueueMessage(new TestFailed(new XunitTest(testCase, testCase.DisplayName), 0,
Strings.VsClient.FailedToStart(_visualStudioVersion, _rootSuffix),
new TimeoutException()));
new TimeoutException("Failed to start Visual Studio " + _visualStudioVersion + " " + _rootSuffix)));

return false;
}
Expand Down
34 changes: 29 additions & 5 deletions src/Xunit.Vsix/VsRemoteRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Runtime.Remoting.Channels;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Threading;
Expand Down Expand Up @@ -60,12 +61,35 @@ public VsixRunSummary Run(VsixTestCase testCase, IMessageBus messageBus)
// Before the first test is run, ensure VS is properly initialized.
if (_jtc == null)
{
// Retrieve the component model service, which could also now take time depending on new
// extensions being installed or updated before the first launch.
_jtc = GlobalServiceProvider.GetExport<JoinableTaskContext>();

var ev = new ManualResetEventSlim();

UIContext.FromUIContextGuid(new(UIContextGuids.NoSolution)).WhenActivated(() =>
{
Task.Run(async () =>
{
var shell = await ServiceProvider.GetGlobalServiceAsync<SVsShell, IVsShell>();
while (true)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
shell.GetProperty((int)__VSSPROPID4.VSSPROPID_ShellInitialized, out var value);
if (value is bool initialized && initialized)
break;

await Task.Delay(200);
}

// Retrieve the component model service, which could also now take time depending on new
// extensions being installed or updated before the first launch.
var components = await ServiceProvider.GetGlobalServiceAsync<SComponentModel, IComponentModel>();
_jtc = components.GetService<JoinableTaskContext>();
ev.Set();

}).Forget();
});

ev.Wait(testCase.TimeoutSeconds * 1000);
ev.Reset();

_jtc.Factory.RunAsync(async () =>
{
await _jtc.Factory.SwitchToMainThreadAsync();
Expand All @@ -81,7 +105,7 @@ public VsixRunSummary Run(VsixTestCase testCase, IMessageBus messageBus)

}).Task.ContinueWith(_ => ev.Set(), TaskScheduler.Default).Forget();

ev.Wait();
ev.Wait(testCase.TimeoutSeconds * 1000);
}

messageBus.QueueMessage(new DiagnosticMessage("Running {0}", testCase.DisplayName));
Expand Down