This commit is contained in:
Matthew Parker [SSW]
2024-01-21 15:42:42 +10:00
parent 284641b98c
commit c5921cc0d3

View File

@@ -8,6 +8,7 @@ using DotNetSolutionTools.App.Models;
using DotNetSolutionTools.App.Services; using DotNetSolutionTools.App.Services;
using DotNetSolutionTools.Core; using DotNetSolutionTools.Core;
using DotNetSolutionTools.Core.Common; using DotNetSolutionTools.Core.Common;
using NuGet.Packaging;
namespace DotNetSolutionTools.App.ViewModels; namespace DotNetSolutionTools.App.ViewModels;
@@ -45,10 +46,12 @@ public partial class MainWindowViewModel : ObservableObject
ResultsLabelColor = new ImmutableSolidColorBrush(Colors.Black); ResultsLabelColor = new ImmutableSolidColorBrush(Colors.Black);
} }
private void SetCommandSuccessState(string message) private void SetCommandSuccessState(string message, IEnumerable<string>? results = null)
{ {
ResultsLabel = message; ResultsLabel = message;
ResultsLabelColor = new ImmutableSolidColorBrush(Colors.Green); ResultsLabelColor = new ImmutableSolidColorBrush(Colors.Green);
if (results is not null)
OperationResults.AddRange(results);
} }
private void SetCommandFailureState(string message, Exception e) private void SetCommandFailureState(string message, Exception e)
@@ -72,9 +75,7 @@ public partial class MainWindowViewModel : ObservableObject
SolutionFolderPath, SolutionFolderPath,
SolutionFilePath SolutionFilePath
); );
foreach (var result in results) SetCommandSuccessState($"{results.Count} Projects in folder missing from solution", results);
OperationResults.Add(result);
SetCommandSuccessState($"{results.Count} Projects in folder missing from solution");
}, },
token token
); );
@@ -167,8 +168,7 @@ public partial class MainWindowViewModel : ObservableObject
() => () =>
{ {
var results = ImplicitUsings.FindCSharpProjectsMissingImplicitUsings(SolutionFilePath); var results = ImplicitUsings.FindCSharpProjectsMissingImplicitUsings(SolutionFilePath);
results.ForEach(s => OperationResults.Add(s)); SetCommandSuccessState($"{results.Count} Projects missing ImplicitUsings", results);
SetCommandSuccessState($"{results.Count} Projects missing ImplicitUsings");
}, },
token token
); );
@@ -189,8 +189,7 @@ public partial class MainWindowViewModel : ObservableObject
() => () =>
{ {
var results = WarningsAsErrors.FindCSharpProjectsMissingTreatWarningsAsErrors(SolutionFilePath); var results = WarningsAsErrors.FindCSharpProjectsMissingTreatWarningsAsErrors(SolutionFilePath);
results.ForEach(s => OperationResults.Add(s)); SetCommandSuccessState($"{results.Count} Projects missing TreatWarningsAsErrors", results);
SetCommandSuccessState($"{results.Count} Projects missing TreatWarningsAsErrors");
}, },
token token
); );