Skip to content

Commit c5921cc

Browse files
committed
dry
1 parent 284641b commit c5921cc

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

DotNetSolutionTools.App/ViewModels/MainWindowViewModel.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using DotNetSolutionTools.App.Services;
99
using DotNetSolutionTools.Core;
1010
using DotNetSolutionTools.Core.Common;
11+
using NuGet.Packaging;
1112

1213
namespace DotNetSolutionTools.App.ViewModels;
1314

@@ -45,10 +46,12 @@ private void SetBeginCommandState()
4546
ResultsLabelColor = new ImmutableSolidColorBrush(Colors.Black);
4647
}
4748

48-
private void SetCommandSuccessState(string message)
49+
private void SetCommandSuccessState(string message, IEnumerable<string>? results = null)
4950
{
5051
ResultsLabel = message;
5152
ResultsLabelColor = new ImmutableSolidColorBrush(Colors.Green);
53+
if (results is not null)
54+
OperationResults.AddRange(results);
5255
}
5356

5457
private void SetCommandFailureState(string message, Exception e)
@@ -72,9 +75,7 @@ await Task.Run(
7275
SolutionFolderPath,
7376
SolutionFilePath
7477
);
75-
foreach (var result in results)
76-
OperationResults.Add(result);
77-
SetCommandSuccessState($"{results.Count} Projects in folder missing from solution");
78+
SetCommandSuccessState($"{results.Count} Projects in folder missing from solution", results);
7879
},
7980
token
8081
);
@@ -167,8 +168,7 @@ await Task.Run(
167168
() =>
168169
{
169170
var results = ImplicitUsings.FindCSharpProjectsMissingImplicitUsings(SolutionFilePath);
170-
results.ForEach(s => OperationResults.Add(s));
171-
SetCommandSuccessState($"{results.Count} Projects missing ImplicitUsings");
171+
SetCommandSuccessState($"{results.Count} Projects missing ImplicitUsings", results);
172172
},
173173
token
174174
);
@@ -189,8 +189,7 @@ await Task.Run(
189189
() =>
190190
{
191191
var results = WarningsAsErrors.FindCSharpProjectsMissingTreatWarningsAsErrors(SolutionFilePath);
192-
results.ForEach(s => OperationResults.Add(s));
193-
SetCommandSuccessState($"{results.Count} Projects missing TreatWarningsAsErrors");
192+
SetCommandSuccessState($"{results.Count} Projects missing TreatWarningsAsErrors", results);
194193
},
195194
token
196195
);

0 commit comments

Comments
 (0)