App layout
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -28,6 +29,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DotNetSolutionTools.Core\DotNetSolutionTools.Core.csproj" />
|
<ProjectReference Include="..\DotNetSolutionTools.Core\DotNetSolutionTools.Core.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
40
DotNetSolutionTools.App/Services/FileService.cs
Normal file
40
DotNetSolutionTools.App/Services/FileService.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Platform.Storage;
|
||||||
|
|
||||||
|
namespace DotNetSolutionTools.App.Services;
|
||||||
|
|
||||||
|
public class FileService
|
||||||
|
{
|
||||||
|
public async Task<IStorageFile?> DoOpenFilePickerAsync()
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
Application.Current?.ApplicationLifetime
|
||||||
|
is not IClassicDesktopStyleApplicationLifetime desktop
|
||||||
|
|| desktop.MainWindow?.StorageProvider is not { } provider
|
||||||
|
)
|
||||||
|
throw new NullReferenceException("Missing StorageProvider instance.");
|
||||||
|
|
||||||
|
var files = await provider.OpenFilePickerAsync(
|
||||||
|
new FilePickerOpenOptions() { Title = "Open Text File", AllowMultiple = false }
|
||||||
|
);
|
||||||
|
|
||||||
|
return files?.Count >= 1 ? files[0] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IStorageFolder?> DoOpenFolderPickerAsync()
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
Application.Current?.ApplicationLifetime
|
||||||
|
is not IClassicDesktopStyleApplicationLifetime desktop
|
||||||
|
|| desktop.MainWindow?.StorageProvider is not { } provider
|
||||||
|
)
|
||||||
|
throw new NullReferenceException("Missing StorageProvider instance.");
|
||||||
|
|
||||||
|
var folder = await provider.OpenFolderPickerAsync(
|
||||||
|
new FolderPickerOpenOptions() { Title = "Open Text File", AllowMultiple = false }
|
||||||
|
);
|
||||||
|
|
||||||
|
return folder?.Count >= 1 ? folder[0] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +1,15 @@
|
|||||||
using System;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
|
||||||
using Avalonia.Platform.Storage;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using DotNetSolutionTools.App.Services;
|
||||||
using DotNetSolutionTools.Core;
|
using DotNetSolutionTools.Core;
|
||||||
|
|
||||||
namespace DotNetSolutionTools.App.ViewModels;
|
namespace DotNetSolutionTools.App.ViewModels;
|
||||||
|
|
||||||
public partial class MainWindowViewModel : ViewModelBase
|
public partial class MainWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
private readonly FileService _fileService = new();
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string _solutionFolderPath;
|
private string _solutionFolderPath;
|
||||||
|
|
||||||
@@ -23,33 +17,57 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
private string _solutionFilePath;
|
private string _solutionFilePath;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? _fileText;
|
private string _csprojFilePath;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private ObservableCollection<string> _parityResults = new ObservableCollection<string>()
|
private ObservableCollection<string> _parityResults = new() { };
|
||||||
{
|
|
||||||
"Test"
|
|
||||||
};
|
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task ExecuteParityChecker(CancellationToken token)
|
private async Task ExecuteParityChecker(CancellationToken token)
|
||||||
{
|
{
|
||||||
var results =
|
var results = SolutionProjectParity.CompareSolutionAndCSharpProjects(
|
||||||
DotNetSolutionTools.Core.SolutionParityChecker.CompareSolutionAndCSharpProjects(
|
SolutionFolderPath,
|
||||||
SolutionFolderPath,
|
SolutionFilePath
|
||||||
SolutionFilePath
|
);
|
||||||
);
|
|
||||||
ParityResults.Clear();
|
ParityResults.Clear();
|
||||||
foreach (var result in results)
|
foreach (var result in results)
|
||||||
{
|
|
||||||
ParityResults.Add(result);
|
ParityResults.Add(result);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task FormatCsProjFile(CancellationToken token)
|
private async Task FormatCsProjFile(CancellationToken token)
|
||||||
{
|
{
|
||||||
FormatCsproj.FormatCsprojFile(SolutionFilePath);
|
FormatCsproj.FormatCsprojFile(CsprojFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task FormatAllCsprojFilesInSolutionFile(CancellationToken token)
|
||||||
|
{
|
||||||
|
var csprojList = SolutionProjectParity.RetrieveAllCSharpProjectFullPathsFromFolder(
|
||||||
|
SolutionFolderPath
|
||||||
|
);
|
||||||
|
foreach (var csproj in csprojList)
|
||||||
|
{
|
||||||
|
FormatCsproj.FormatCsprojFile(csproj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task FormatAllCsprojFilesInSolutionFolder(CancellationToken token)
|
||||||
|
{
|
||||||
|
var csprojList = SolutionProjectParity.RetrieveAllCSharpProjectFullPathsFromFolder(
|
||||||
|
SolutionFolderPath
|
||||||
|
);
|
||||||
|
foreach (var csproj in csprojList)
|
||||||
|
{
|
||||||
|
FormatCsproj.FormatCsprojFile(csproj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task CheckForMissingImplicitUsingsInSolutionFile(CancellationToken token)
|
||||||
|
{
|
||||||
|
ImplicitUsings.FindCSharpProjectsMissingImplicitUsings(SolutionFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
@@ -58,7 +76,7 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
ErrorMessages?.Clear();
|
ErrorMessages?.Clear();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var file = await DoOpenFilePickerAsync();
|
var file = await _fileService.DoOpenFilePickerAsync();
|
||||||
if (file is null)
|
if (file is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -70,13 +88,19 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task ClearSolutionFile(CancellationToken token)
|
||||||
|
{
|
||||||
|
SolutionFilePath = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task LoadSolutionFolder(CancellationToken token)
|
private async Task LoadSolutionFolder(CancellationToken token)
|
||||||
{
|
{
|
||||||
ErrorMessages?.Clear();
|
ErrorMessages?.Clear();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var folder = await DoOpenFolderPickerAsync();
|
var folder = await _fileService.DoOpenFolderPickerAsync();
|
||||||
if (folder is null)
|
if (folder is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -88,49 +112,33 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IStorageFile?> DoOpenFilePickerAsync()
|
[RelayCommand]
|
||||||
|
private async Task ClearSolutionFolder(CancellationToken token)
|
||||||
{
|
{
|
||||||
// For learning purposes, we opted to directly get the reference
|
SolutionFolderPath = string.Empty;
|
||||||
// for StorageProvider APIs here inside the ViewModel.
|
|
||||||
|
|
||||||
// For your real-world apps, you should follow the MVVM principles
|
|
||||||
// by making service classes and locating them with DI/IoC.
|
|
||||||
|
|
||||||
// See IoCFileOps project for an example of how to accomplish this.
|
|
||||||
if (
|
|
||||||
Application.Current?.ApplicationLifetime
|
|
||||||
is not IClassicDesktopStyleApplicationLifetime desktop
|
|
||||||
|| desktop.MainWindow?.StorageProvider is not { } provider
|
|
||||||
)
|
|
||||||
throw new NullReferenceException("Missing StorageProvider instance.");
|
|
||||||
|
|
||||||
var files = await provider.OpenFilePickerAsync(
|
|
||||||
new FilePickerOpenOptions() { Title = "Open Text File", AllowMultiple = false }
|
|
||||||
);
|
|
||||||
|
|
||||||
return files?.Count >= 1 ? files[0] : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IStorageFolder?> DoOpenFolderPickerAsync()
|
[RelayCommand]
|
||||||
|
private async Task LoadCsprojFile(CancellationToken token)
|
||||||
{
|
{
|
||||||
// For learning purposes, we opted to directly get the reference
|
ErrorMessages?.Clear();
|
||||||
// for StorageProvider APIs here inside the ViewModel.
|
try
|
||||||
|
{
|
||||||
|
var folder = await _fileService.DoOpenFilePickerAsync();
|
||||||
|
if (folder is null)
|
||||||
|
return;
|
||||||
|
|
||||||
// For your real-world apps, you should follow the MVVM principles
|
CsprojFilePath = folder.Path.AbsolutePath;
|
||||||
// by making service classes and locating them with DI/IoC.
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ErrorMessages?.Add(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// See IoCFileOps project for an example of how to accomplish this.
|
[RelayCommand]
|
||||||
if (
|
private async Task ClearCsprojFile(CancellationToken token)
|
||||||
Application.Current?.ApplicationLifetime
|
{
|
||||||
is not IClassicDesktopStyleApplicationLifetime desktop
|
CsprojFilePath = string.Empty;
|
||||||
|| desktop.MainWindow?.StorageProvider is not { } provider
|
|
||||||
)
|
|
||||||
throw new NullReferenceException("Missing StorageProvider instance.");
|
|
||||||
|
|
||||||
var folder = await provider.OpenFolderPickerAsync(
|
|
||||||
new FolderPickerOpenOptions() { Title = "Open Text File", AllowMultiple = false }
|
|
||||||
);
|
|
||||||
|
|
||||||
return folder?.Count >= 1 ? folder[0] : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
|
||||||
|
namespace DotNetSolutionTools.App.ViewModels;
|
||||||
|
|
||||||
|
public partial class PreviewMainWindowViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private string _solutionFolderPath =
|
||||||
|
"C:\\Users\\matt\\source\\repos\\DotNetSolutionTools\\DotNetSolutionTools.App";
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string _solutionFilePath =
|
||||||
|
"C:\\Users\\matt\\source\\repos\\DotNetSolutionTools\\DotNetSolutionTools.App.sln";
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string _csprojFilePath =
|
||||||
|
"C:\\Users\\matt\\source\\repos\\DotNetSolutionTools\\DotNetSolutionTools.App.csproj";
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private ObservableCollection<string> _parityResults = new() { "Error Message" };
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task ExecuteParityChecker(CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task FormatCsProjFile(CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task LoadSolutionFile(CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task LoadSolutionFolder(CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task LoadCsprojFile(CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,27 +4,86 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="clr-namespace:DotNetSolutionTools.App.ViewModels"
|
xmlns:viewModels="clr-namespace:DotNetSolutionTools.App.ViewModels"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
Width="800" Height="450"
|
||||||
x:Class="DotNetSolutionTools.App.Views.MainWindow"
|
x:Class="DotNetSolutionTools.App.Views.MainWindow"
|
||||||
x:DataType="viewModels:MainWindowViewModel"
|
x:DataType="viewModels:MainWindowViewModel"
|
||||||
Icon="/Assets/avalonia-logo.ico"
|
Icon="/Assets/avalonia-logo.ico"
|
||||||
Title="FileOps">
|
Title="DotNetSolutionTools">
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||||
<viewModels:MainWindowViewModel />
|
<viewModels:MainWindowViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
<Panel>
|
<Panel>
|
||||||
<StackPanel>
|
<StackPanel VerticalAlignment="Stretch" Margin="10">
|
||||||
<TextBlock>Welcome to Avalonia!</TextBlock>
|
<StackPanel Orientation="Horizontal">
|
||||||
<Button Command="{Binding LoadSolutionFolderCommand}" >Select Solution Folder</Button>
|
<Button Width="200" HorizontalContentAlignment="Center" Command="{Binding LoadSolutionFolderCommand}">Select Solution Folder</Button>
|
||||||
<Button Command="{Binding LoadSolutionFileCommand}">Select Solution File</Button>
|
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Background="Gray" Name="SolutionFolderPath" Text="{Binding SolutionFolderPath}" />
|
||||||
<Button Command="{Binding ExecuteParityCheckerCommand}">Check Solution Parity</Button>
|
<Button Width="60" HorizontalContentAlignment="Center" Command="{Binding ClearSolutionFolderCommand}">Clear</Button>
|
||||||
<Button Command="{Binding FormatCsProjFileCommand}">Format CSharp Project File</Button>
|
</StackPanel>
|
||||||
<TextBlock Name="SolutionFilePath" Text="{Binding SolutionFilePath}" />
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Name="SolutionFolderPath" Text="{Binding SolutionFolderPath}" />
|
<Button Width="200" HorizontalContentAlignment="Center" Command="{Binding LoadSolutionFileCommand}">Select Solution File</Button>
|
||||||
<ListBox Name="Results" ItemsSource="{Binding ParityResults}"/>
|
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Name="SolutionFilePath" Text="{Binding SolutionFilePath}" />
|
||||||
<ListBox ItemsSource="{Binding ErrorMessages}"/>
|
<Button Width="60" HorizontalContentAlignment="Center" Command="{Binding ClearSolutionFileCommand}">Clear</Button>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Button Width="200" HorizontalContentAlignment="Center" Command="{Binding LoadCsprojFileCommand}">Select CSharp Project File</Button>
|
||||||
|
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Background="Gray" Name="CsprojFilePath" Text="{Binding CsprojFilePath}" />
|
||||||
|
<Button Width="60" HorizontalContentAlignment="Center" Command="{Binding ClearCsprojFileCommand}">Clear</Button>
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
<Separator Margin="0 10 0 0" />
|
||||||
|
<Grid VerticalAlignment="Stretch" ShowGridLines="False" RowDefinitions="*,*" ColumnDefinitions="*,*,*">
|
||||||
|
<Button Grid.Row="0" Grid.Column="0" MinHeight="130" Padding="10" Margin="10"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||||
|
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||||
|
IsEnabled="{Binding SolutionFolderPath, Mode=OneWay, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
|
Command="{Binding ExecuteParityCheckerCommand}">
|
||||||
|
<TextBlock TextWrapping="Wrap">
|
||||||
|
Check Solution Parity
|
||||||
|
</TextBlock>
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Row="0" Grid.Column="1" MinHeight="130" Padding="10" Margin="10"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||||
|
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||||
|
IsEnabled="{Binding CsprojFilePath, Mode=OneWay, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
|
Command="{Binding FormatCsProjFileCommand}">
|
||||||
|
<TextBlock TextWrapping="Wrap">
|
||||||
|
Format CSharp Project File
|
||||||
|
</TextBlock>
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Row="0" Grid.Column="2" MinHeight="130" Padding="10" Margin="10"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||||
|
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||||
|
IsEnabled="{Binding SolutionFilePath, Mode=OneWay, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
|
Command="{Binding FormatAllCsprojFilesInSolutionFileCommand}">
|
||||||
|
<TextBlock TextWrapping="Wrap">
|
||||||
|
Format All CSharp Project Files in Solution
|
||||||
|
</TextBlock>
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Row="1" Grid.Column="0" MinHeight="130" Padding="10" Margin="10"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||||
|
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||||
|
IsEnabled="{Binding SolutionFolderPath, Mode=OneWay, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
|
Command="{Binding FormatAllCsprojFilesInSolutionFolderCommand}">
|
||||||
|
<TextBlock TextWrapping="Wrap">
|
||||||
|
Format All CSharp Project Files in Folder
|
||||||
|
</TextBlock>
|
||||||
|
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Row="1" Grid.Column="1" MinHeight="130" Padding="10" Margin="10"
|
||||||
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||||
|
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||||
|
IsEnabled="{Binding SolutionFilePath, Mode=OneWay, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
|
Command="{Binding CheckForMissingImplicitUsingsInSolutionFileCommand}">
|
||||||
|
<TextBlock TextWrapping="Wrap">
|
||||||
|
Check For Missing Implicit Usings
|
||||||
|
</TextBlock>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
<ListBox Name="Results" ItemsSource="{Binding ParityResults}" />
|
||||||
|
<ListBox ItemsSource="{Binding ErrorMessages}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|
||||||
</Window>
|
</Window>
|
||||||
@@ -28,7 +28,7 @@ public class CompareCommand : Command<CompareCommand.Settings>
|
|||||||
var pathToSolutionFile = settings.SolutionFilePath;
|
var pathToSolutionFile = settings.SolutionFilePath;
|
||||||
Console.WriteLine($"Retrieving C# Projects from {folderDirectory}");
|
Console.WriteLine($"Retrieving C# Projects from {folderDirectory}");
|
||||||
|
|
||||||
var csprojList = SolutionParityChecker.RetrieveAllCSharpProjectNamesFromFolder(
|
var csprojList = SolutionProjectParity.RetrieveAllCSharpProjectNamesFromFolder(
|
||||||
folderDirectory
|
folderDirectory
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class CompareCommand : Command<CompareCommand.Settings>
|
|||||||
|
|
||||||
Console.WriteLine($"Parsing Solution File: {pathToSolutionFile}");
|
Console.WriteLine($"Parsing Solution File: {pathToSolutionFile}");
|
||||||
// Load the solution file
|
// Load the solution file
|
||||||
var solutionFile = SolutionParityChecker.ParseSolutionFileFromPath(pathToSolutionFile);
|
var solutionFile = SolutionProjectParity.ParseSolutionFileFromPath(pathToSolutionFile);
|
||||||
if (solutionFile == null)
|
if (solutionFile == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
@@ -55,7 +55,7 @@ public class CompareCommand : Command<CompareCommand.Settings>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the list of projects
|
// Get the list of projects
|
||||||
var projectsMissingFromSolution = SolutionParityChecker.FindProjectsMissingFromSolution(
|
var projectsMissingFromSolution = SolutionProjectParity.FindProjectsMissingFromSolution(
|
||||||
csprojList,
|
csprojList,
|
||||||
solutionFile
|
solutionFile
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class FormatCsprojCommand : Command<FormatCsprojCommand.Settings>
|
|||||||
}
|
}
|
||||||
else if (!string.IsNullOrWhiteSpace(settings.SolutionFilePath))
|
else if (!string.IsNullOrWhiteSpace(settings.SolutionFilePath))
|
||||||
{
|
{
|
||||||
var test = SolutionParityChecker.ParseSolutionFileFromPath(settings.SolutionFilePath);
|
var test = SolutionProjectParity.ParseSolutionFileFromPath(settings.SolutionFilePath);
|
||||||
if (test == null)
|
if (test == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
@@ -37,7 +37,7 @@ public class FormatCsprojCommand : Command<FormatCsprojCommand.Settings>
|
|||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
var cSharpProjects = SolutionParityChecker.GetCSharpProjectObjectsFromSolutionFile(
|
var cSharpProjects = SolutionProjectParity.GetCSharpProjectObjectsFromSolutionFile(
|
||||||
test
|
test
|
||||||
);
|
);
|
||||||
Console.WriteLine($"Found {cSharpProjects.Count} C# Projects");
|
Console.WriteLine($"Found {cSharpProjects.Count} C# Projects");
|
||||||
@@ -54,7 +54,7 @@ public class FormatCsprojCommand : Command<FormatCsprojCommand.Settings>
|
|||||||
var folderDirectory = settings.SolutionFolderPath; // Include the trailing slash
|
var folderDirectory = settings.SolutionFolderPath; // Include the trailing slash
|
||||||
Console.WriteLine($"Retrieving C# Projects from {folderDirectory}");
|
Console.WriteLine($"Retrieving C# Projects from {folderDirectory}");
|
||||||
|
|
||||||
var csprojList = SolutionParityChecker.RetrieveAllCSharpProjectFullPathsFromFolder(
|
var csprojList = SolutionProjectParity.RetrieveAllCSharpProjectFullPathsFromFolder(
|
||||||
folderDirectory
|
folderDirectory
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class ImplicitUsingsCommand : Command<ImplicitUsingsCommand.Settings>
|
|||||||
var pathToSolutionFile = settings.SolutionFilePath;
|
var pathToSolutionFile = settings.SolutionFilePath;
|
||||||
Console.WriteLine($"Retrieving Solution from {pathToSolutionFile}");
|
Console.WriteLine($"Retrieving Solution from {pathToSolutionFile}");
|
||||||
|
|
||||||
var solutionFile = SolutionParityChecker.ParseSolutionFileFromPath(pathToSolutionFile);
|
var solutionFile = SolutionProjectParity.ParseSolutionFileFromPath(pathToSolutionFile);
|
||||||
if (solutionFile == null)
|
if (solutionFile == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
@@ -42,7 +42,7 @@ public class ImplicitUsingsCommand : Command<ImplicitUsingsCommand.Settings>
|
|||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
var cSharpProjects = SolutionParityChecker.GetCSharpProjectObjectsFromSolutionFile(
|
var cSharpProjects = SolutionProjectParity.GetCSharpProjectObjectsFromSolutionFile(
|
||||||
solutionFile
|
solutionFile
|
||||||
);
|
);
|
||||||
Console.WriteLine($"Found {cSharpProjects.Count} C# Projects");
|
Console.WriteLine($"Found {cSharpProjects.Count} C# Projects");
|
||||||
@@ -67,7 +67,7 @@ public class ImplicitUsingsCommand : Command<ImplicitUsingsCommand.Settings>
|
|||||||
Console.WriteLine("==================================================");
|
Console.WriteLine("==================================================");
|
||||||
Console.WriteLine("Adding missing implicit usings");
|
Console.WriteLine("Adding missing implicit usings");
|
||||||
ImplicitUsings.AddMissingImplicitUsings(projectsMissingImplicitUsings);
|
ImplicitUsings.AddMissingImplicitUsings(projectsMissingImplicitUsings);
|
||||||
var updatedProjects = SolutionParityChecker.GetCSharpProjectObjectsFromSolutionFile(
|
var updatedProjects = SolutionProjectParity.GetCSharpProjectObjectsFromSolutionFile(
|
||||||
solutionFile
|
solutionFile
|
||||||
);
|
);
|
||||||
var projectsWithMissing = ImplicitUsings.FindCSharpProjectsMissingImplicitUsings(
|
var projectsWithMissing = ImplicitUsings.FindCSharpProjectsMissingImplicitUsings(
|
||||||
|
|||||||
@@ -19,14 +19,13 @@ public static class FormatCsproj
|
|||||||
|
|
||||||
using var wr = new StreamWriter(csprojFilePath, false, Encoding.Default);
|
using var wr = new StreamWriter(csprojFilePath, false, Encoding.Default);
|
||||||
|
|
||||||
var settings =
|
var settings = new XmlWriterSettings
|
||||||
new XmlWriterSettings
|
{
|
||||||
{
|
Indent = true,
|
||||||
Indent = true,
|
IndentChars = "\t",
|
||||||
IndentChars = "\t",
|
NewLineOnAttributes = false,
|
||||||
NewLineOnAttributes = false,
|
OmitXmlDeclaration = true
|
||||||
OmitXmlDeclaration = true
|
};
|
||||||
};
|
|
||||||
|
|
||||||
using (var writer = XmlWriter.Create(wr, settings))
|
using (var writer = XmlWriter.Create(wr, settings))
|
||||||
{
|
{
|
||||||
@@ -34,4 +33,4 @@ public static class FormatCsproj
|
|||||||
writer.Close();
|
writer.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,26 @@ namespace DotNetSolutionTools.Core;
|
|||||||
|
|
||||||
public static class ImplicitUsings
|
public static class ImplicitUsings
|
||||||
{
|
{
|
||||||
public static List<ProjectRootElement> FindCSharpProjectsMissingImplicitUsings(List<ProjectRootElement> projectList)
|
public static List<string> FindCSharpProjectsMissingImplicitUsings(string solutionFilePath)
|
||||||
|
{
|
||||||
|
var solutionFile = SolutionFile.Parse(solutionFilePath);
|
||||||
|
var csprojList = SolutionProjectParity.GetCSharpProjectObjectsFromSolutionFile(
|
||||||
|
solutionFile
|
||||||
|
);
|
||||||
|
var projectsMissingImplicitUsings = FindCSharpProjectsMissingImplicitUsings(csprojList);
|
||||||
|
var projectsMissingImplicitUsingsStringList = projectsMissingImplicitUsings
|
||||||
|
.Select(x => x.FullPath)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return projectsMissingImplicitUsingsStringList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ProjectRootElement> FindCSharpProjectsMissingImplicitUsings(
|
||||||
|
List<ProjectRootElement> projectList
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var projectsMissingImplicitUsings = new List<ProjectRootElement>();
|
var projectsMissingImplicitUsings = new List<ProjectRootElement>();
|
||||||
|
|
||||||
foreach (var project in projectList)
|
foreach (var project in projectList)
|
||||||
{
|
{
|
||||||
var implicitUsings = project.PropertyGroups
|
var implicitUsings = project.PropertyGroups
|
||||||
@@ -22,7 +38,9 @@ public static class ImplicitUsings
|
|||||||
return projectsMissingImplicitUsings;
|
return projectsMissingImplicitUsings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddMissingImplicitUsings(List<ProjectRootElement> projectsMissingImplicitUsings)
|
public static void AddMissingImplicitUsings(
|
||||||
|
List<ProjectRootElement> projectsMissingImplicitUsings
|
||||||
|
)
|
||||||
{
|
{
|
||||||
foreach (var project in projectsMissingImplicitUsings)
|
foreach (var project in projectsMissingImplicitUsings)
|
||||||
{
|
{
|
||||||
@@ -35,16 +53,20 @@ public static class ImplicitUsings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableDisabledImplicitUsings(List<ProjectRootElement> projectsMissingImplicitUsings)
|
public static void EnableDisabledImplicitUsings(
|
||||||
|
List<ProjectRootElement> projectsMissingImplicitUsings
|
||||||
|
)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableAllImplicitUsings(List<ProjectRootElement> projectsMissingImplicitUsings)
|
public static void EnableAllImplicitUsings(
|
||||||
|
List<ProjectRootElement> projectsMissingImplicitUsings
|
||||||
|
)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ProjectIsMissingImplicitUsings(ProjectRootElement project)
|
public static bool ProjectIsMissingImplicitUsings(ProjectRootElement project)
|
||||||
{
|
{
|
||||||
var implicitUsings = project.PropertyGroups
|
var implicitUsings = project.PropertyGroups
|
||||||
@@ -57,4 +79,4 @@ public static class ImplicitUsings
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace DotNetSolutionTools.Core;
|
namespace DotNetSolutionTools.Core;
|
||||||
|
|
||||||
public static class SolutionParityChecker
|
public static class SolutionProjectParity
|
||||||
{
|
{
|
||||||
public static List<string> CompareSolutionAndCSharpProjects(
|
public static List<string> CompareSolutionAndCSharpProjects(
|
||||||
string solutionFolderPath,
|
string solutionFolderPath,
|
||||||
Reference in New Issue
Block a user