Skip to content

Commit b63c33e

Browse files
committed
Moved solution manifest lookup from ExportFeatureBase to ExportSolutionFeature
1 parent ccf9531 commit b63c33e

5 files changed

Lines changed: 21 additions & 33 deletions

File tree

src/ExtensionManager.UI/DialogService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public DialogService(IVSThreads threads)
4646
}
4747
}
4848

49-
public Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions)
49+
public Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IEnumerable<IVSExtension> selectedExtensions)
5050
=> ShowExportDialogAsync(worker, manifest, installedExtensions, selectedExtensions, forSolution: false);
51-
public Task ShowExportForSolutionDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions)
51+
public Task ShowExportForSolutionDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IEnumerable<IVSExtension> selectedExtensions)
5252
=> ShowExportDialogAsync(worker, manifest, installedExtensions, selectedExtensions, forSolution: true);
53-
private async Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions, bool forSolution)
53+
private async Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IEnumerable<IVSExtension> selectedExtensions, bool forSolution)
5454
{
5555
var vm = new ExportDialogViewModel(worker, manifest, forSolution);
5656

src/ExtensionManager.UI/IDialogService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public interface IDialogService
99
Task<string?> ShowSaveVsextFileDialogAsync();
1010
Task<string?> ShowOpenVsextFileDialogAsync();
1111

12-
Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions);
13-
Task ShowExportForSolutionDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions);
12+
Task ShowExportDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IEnumerable<IVSExtension> selectedExtensions);
13+
Task ShowExportForSolutionDialogAsync(IExportWorker worker, IManifest manifest, IReadOnlyCollection<IVSExtension> installedExtensions, IEnumerable<IVSExtension> selectedExtensions);
1414
Task ShowInstallDialogAsync(IInstallWorker worker, IManifest manifest, IReadOnlyCollection<VSExtensionToInstall> extensions);
1515
Task ShowInstallForSolutionDialogAsync(IInstallWorker worker, IManifest manifest, IReadOnlyCollection<VSExtensionToInstall> extensions);
1616
}

src/ExtensionManager/Features/Export/ExportFeature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public ExportFeature(Args args)
1414
protected override async Task<string?> GetFilePathAsync()
1515
=> await DialogService.ShowSaveVsextFileDialogAsync();
1616

17-
protected override async Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> extensions, IReadOnlyCollection<IVSExtension> selectedExtensions)
18-
=> await DialogService.ShowExportDialogAsync(worker, manifest, extensions, selectedExtensions);
17+
protected override async Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> extensions)
18+
=> await DialogService.ShowExportDialogAsync(worker, manifest, extensions, []);
1919

2020
protected override async Task OnManifestWrittenAsync(string filePath)
2121
=> await Documents.OpenAsync(filePath);

src/ExtensionManager/Features/Export/ExportFeatureBase.cs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@ public sealed class Args
2020
public IVSExtensions Extensions { get; }
2121
public IDialogService DialogService { get; }
2222
public IManifestService ManifestService { get; }
23-
public IVSSolutions Solutions { get; }
2423

25-
public Args(IThisVsixInfo vsixInfo, IVSDocuments documents, IVSMessageBox messageBox, IVSExtensions extensions, IDialogService dialogService, IManifestService manifestService, IVSSolutions solutions)
24+
public Args(IThisVsixInfo vsixInfo, IVSDocuments documents, IVSMessageBox messageBox, IVSExtensions extensions, IDialogService dialogService, IManifestService manifestService)
2625
{
2726
VsixInfo = vsixInfo;
2827
Documents = documents;
2928
MessageBox = messageBox;
3029
Extensions = extensions;
3130
DialogService = dialogService;
3231
ManifestService = manifestService;
33-
Solutions = solutions;
3432
}
3533
}
3634

@@ -42,7 +40,6 @@ public Args(IThisVsixInfo vsixInfo, IVSDocuments documents, IVSMessageBox messag
4240
protected IVSExtensions Extensions => _args.Extensions;
4341
protected IDialogService DialogService => _args.DialogService;
4442
protected IManifestService ManifestService => _args.ManifestService;
45-
protected IVSSolutions Solutions => _args.Solutions;
4643

4744
protected ExportFeatureBase(Args args)
4845
{
@@ -51,31 +48,15 @@ protected ExportFeatureBase(Args args)
5148

5249
public async Task ExecuteAsync()
5350
{
54-
IManifest manifest;
55-
56-
var vsextFile = await Solutions.GetCurrentSolutionExtensionsManifestFilePathAsync(MessageBox).ConfigureAwait(false);
57-
58-
if (vsextFile != null && !string.IsNullOrEmpty(vsextFile))
59-
{
60-
// Attempt to read manifest from the found .vsext file
61-
manifest = await ManifestService.ReadAsync(vsextFile).ConfigureAwait(false);
62-
}
63-
else
64-
{
65-
// No .vsext found: create new manifest
66-
manifest = ManifestService.CreateNew();
67-
}
68-
51+
var manifest = ManifestService.CreateNew();
6952
var installedExtensions = await Extensions.GetInstalledExtensionsAsync().ConfigureAwait(false);
7053

7154
var installedExtensionsList = installedExtensions as List<IVSExtension>
7255
?? installedExtensions.ToList();
7356

7457
installedExtensionsList.RemoveAll(vsix => vsix.Id == VsixInfo.Id);
7558

76-
var selectedExtensions = manifest.Extensions;
77-
78-
await ShowExportDialogAsync(manifest, this, installedExtensions, new ReadOnlyCollection<IVSExtension>(selectedExtensions));
59+
await ShowExportDialogAsync(manifest, this, installedExtensions);
7960
}
8061

8162
async Task IExportWorker.ExportAsync(IManifest manifest, IProgress<ProgressStep<ExportStep>> progress, CancellationToken cancellationToken)
@@ -93,7 +74,6 @@ async Task IExportWorker.ExportAsync(IManifest manifest, IProgress<ProgressStep<
9374
}
9475

9576
protected abstract Task<string?> GetFilePathAsync();
96-
protected abstract Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions);
77+
protected abstract Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> installedExtensions);
9778
protected abstract Task OnManifestWrittenAsync(string filePath);
9879
}
99-

src/ExtensionManager/Features/Export/ExportSolutionFeature.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ public ExportSolutionFeature(Args args, IVSSolutions solutions)
1818
protected override async Task<string?> GetFilePathAsync()
1919
=> await _solutions.GetCurrentSolutionExtensionsManifestFilePathAsync(MessageBox);
2020

21-
protected override async Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> installedExtensions, IReadOnlyCollection<IVSExtension> selectedExtensions)
22-
=> await DialogService.ShowExportForSolutionDialogAsync(worker, manifest, installedExtensions, selectedExtensions);
21+
protected override async Task ShowExportDialogAsync(IManifest manifest, IExportWorker worker, IReadOnlyCollection<IVSExtension> installedExtensions)
22+
{
23+
var existingManifestFile = await _solutions.GetCurrentSolutionExtensionsManifestFilePathAsync(MessageBox).ConfigureAwait(false);
24+
25+
var existingManifest = existingManifestFile?.Length > 0
26+
? await ManifestService.ReadAsync(existingManifestFile).ConfigureAwait(false)
27+
: null;
28+
29+
await DialogService.ShowExportForSolutionDialogAsync(worker, manifest, installedExtensions, existingManifest?.Extensions ?? []);
30+
}
2331

2432
protected override async Task OnManifestWrittenAsync(string filePath)
2533
{

0 commit comments

Comments
 (0)