Fix commands

This commit is contained in:
Matthew Parker [SSW]
2024-01-21 13:46:14 +10:00
parent 3bd688966b
commit b704258b78
3 changed files with 14 additions and 4 deletions

View File

@@ -45,8 +45,9 @@ public partial class MainWindowViewModel : ViewModelBase
} }
catch (Exception e) catch (Exception e)
{ {
ResultsLabel = "Error"; ResultsLabel = "Failed to compare solution and csharp projects";
OperationResults?.Add(e.Message); OperationResults?.Add(e.Message);
OperationResults?.Add(e.ToString());
} }
} }
@@ -83,12 +84,14 @@ public partial class MainWindowViewModel : ViewModelBase
ResultsLabel = "Running..."; ResultsLabel = "Running...";
await Task.Run(() => await Task.Run(() =>
{ {
var csprojList = SolutionProjectParity.RetrieveAllCSharpProjectFullPathsFromFolder(SolutionFolderPath); var solutionFile = SolutionProjectParity.ParseSolutionFileFromPath(SolutionFilePath);
var csprojList = SolutionProjectParity.RetrieveAllCSharpProjectFullPathsFromSolution(solutionFile);
foreach (var csproj in csprojList) foreach (var csproj in csprojList)
{ {
FormatCsproj.FormatCsprojFile(csproj); FormatCsproj.FormatCsprojFile(csproj);
} }
}, token); }, token);
ResultsLabel = "Successfully formatted all csproj files in solution file";
} }
catch (Exception e) catch (Exception e)
{ {
@@ -113,7 +116,7 @@ public partial class MainWindowViewModel : ViewModelBase
FormatCsproj.FormatCsprojFile(csproj); FormatCsproj.FormatCsprojFile(csproj);
} }
}, token); }, token);
ResultsLabel = "Successfully formatted all csproj files in folder";
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -110,7 +110,7 @@
<Button Grid.Row="2" Grid.Column="2" MinHeight="100" Padding="10" Margin="5" <Button Grid.Row="2" Grid.Column="2" MinHeight="100" Padding="10" Margin="5"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
IsEnabled="{Binding SolutionFilePath, Mode=OneWay, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" IsEnabled="{Binding CsprojFilePath, Mode=OneWay, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Command="{Binding UpdateProjectToNet80Command}"> Command="{Binding UpdateProjectToNet80Command}">
<TextBlock TextWrapping="Wrap"> <TextBlock TextWrapping="Wrap">
Update C# Project to .NET 8.0 Update C# Project to .NET 8.0

View File

@@ -38,6 +38,13 @@ public static class SolutionProjectParity
); );
return csprojList; return csprojList;
} }
public static string[] RetrieveAllCSharpProjectFullPathsFromSolution(SolutionFile solution)
{
var result = GetCSharpProjectObjectsFromSolutionFile(solution);
var csprojList = result.Select(x => x.FullPath).ToArray();
return csprojList;
}
public static SolutionFile? ParseSolutionFileFromPath(string solutionFilePath) public static SolutionFile? ParseSolutionFileFromPath(string solutionFilePath)
{ {