Skip to content

Commit

Permalink
Merge pull request #22 from net8
Browse files Browse the repository at this point in the history
Upgrade Target Framework from Net6 to Net8
  • Loading branch information
kevinboon3288 authored Mar 28, 2024
2 parents 82e5942 + 0db7ba2 commit a87c864
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 46 deletions.
24 changes: 13 additions & 11 deletions Core/DirectoryUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,42 @@ public DirectoryUtils(ILogger logger)
_logger = logger;
}

public List<string> GetNugetPackages()
public List<(string, string?)> GetNugetPackages()
{
List<string> nugetPackages = ReadPackages(Directory.GetDirectories(ConstantFilePaths.NugetX86FilePath));
List<(string, string?)> nugetPackages = ReadPackages(Directory.GetDirectories(ConstantFilePaths.NugetX86FilePath));

_logger.Information("NuGetPackages Folders loaded successfully");

return nugetPackages;
}

public List<string> GetDotNugetPackages()
public List<(string, string?)> GetDotNugetPackages()
{
List<string> dotNugetPackages = ReadPackages(Directory.GetDirectories(ConstantFilePaths.DotNugetFilePath));
List<(string, string?)> dotNugetPackages = ReadPackages(Directory.GetDirectories(ConstantFilePaths.DotNugetFilePath));

_logger.Information(".nuget Folders loaded successfully");

return dotNugetPackages;
}

public List<string> GetFilterPackages(string filterFileNames)
{
List<string> packages = ReadPackages(Directory.GetDirectories(ConstantFilePaths.DotNugetFilePath));
return packages.FindAll(x => x.Contains(filterFileNames.ToUpper())).ToList();
public List<(string, string?)> GetFilterPackages(string filterFileNames)
{
List<(string fileName, string? version)> packages = ReadPackages(Directory.GetDirectories(ConstantFilePaths.DotNugetFilePath));
return packages.FindAll(x => x.fileName.Contains(filterFileNames.ToUpper())).ToList();
}

private List<string> ReadPackages(string[] filterFolderPaths)
private List<(string, string?)> ReadPackages(string[] filterFolderPaths)
{
List<string> folders = new();
List<(string, string?)> folders = new();

foreach (string folder in filterFolderPaths)
{
string? version = Path.GetFileName(Directory.GetDirectories(folder, "*", SearchOption.TopDirectoryOnly).FirstOrDefault());

Match match = Regex.Match(folder, _folderPattern);
if (match.Success)
{
folders.Add(Path.GetFileName(folder));
folders.Add((Path.GetFileName(folder), version));
}
}

Expand Down
6 changes: 3 additions & 3 deletions Core/IDirectoryUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace VersionController.Core
{
public interface IDirectoryUtils
{
List<string> GetNugetPackages();
List<string> GetDotNugetPackages();
List<string> GetFilterPackages(string filterFileNames);
List<(string, string?)> GetNugetPackages();
List<(string, string?)> GetDotNugetPackages();
List<(string, string?)> GetFilterPackages(string filterFileNames);
void Delete(List<string> filterFileNames, string filePath);
void Publish(string directory, string fileName);
}
Expand Down
2 changes: 1 addition & 1 deletion LoggerService/Events/LogEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace VersionController.Services.Events
{
public class LogEventArgs: EventArgs
{
public string LogMessage { get; set; }
public required string LogMessage { get; set; }
}
}
2 changes: 1 addition & 1 deletion Main/Views/MainView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public MainView()
vm.LogReceived += OnLogReceived;
}

private void OnLogReceived(object sender, EventArgs e)
private void OnLogReceived(object? sender, EventArgs e)
{
if (e is LogEventArgs eventArgs)
{
Expand Down
13 changes: 11 additions & 2 deletions PackageModule/Models/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace VersionController.PackageModule.Models
{
public class Package : BindableBase
{
private string _name;
private string _name;
private string? _version;
private bool _isChecked;

public string Name
Expand All @@ -14,6 +15,13 @@ public string Name
set { SetProperty(ref _name, value); }
}

public string? Version
{
get => _version;
set { SetProperty(ref _version, value); }
}


public bool IsChecked
{
get => _isChecked;
Expand All @@ -28,9 +36,10 @@ public Package()
_name = string.Empty;
}

public Package(string name)
public Package(string name, string? version)
{
_name = name;
_version = version;
_isChecked = false;
}
}
Expand Down
12 changes: 6 additions & 6 deletions PackageModule/ViewModels/DotNugetPackageListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ private void Refresh()
IsVisible = false;
DotNuGetPackages.Clear();

List<string> dotNuGetPackages = _directoryUtils.GetDotNugetPackages();
List<(string, string?)> dotNuGetPackages = _directoryUtils.GetDotNugetPackages();

foreach (string package in dotNuGetPackages)
foreach ((string package, string? version) in dotNuGetPackages)
{
DotNuGetPackages.Add(new Package(package));
DotNuGetPackages.Add(new Package(package, version));
}
}

Expand All @@ -117,11 +117,11 @@ private void OnSearch(string token)

DotNuGetPackages.Clear();

List<string> filterPackages = _directoryUtils.GetFilterPackages(token);
List<(string, string?)> filterPackages = _directoryUtils.GetFilterPackages(token);

foreach (string filterPackage in filterPackages)
foreach ((string filterPackage, string? version) in filterPackages)
{
DotNuGetPackages.Add(new Package(filterPackage));
DotNuGetPackages.Add(new Package(filterPackage, version));
}
}

Expand Down
12 changes: 6 additions & 6 deletions PackageModule/ViewModels/PackageListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ private void Refresh()
IsVisible = false;
Packages.Clear();

List<string> packages = _directoryUtils.GetNugetPackages();
List<(string, string?)> packages = _directoryUtils.GetNugetPackages();

foreach (string package in packages)
foreach ((string fileName, string? version) in packages)
{
Packages.Add(new Package(package));
Packages.Add(new Package(fileName, version));
}
}

Expand All @@ -117,11 +117,11 @@ private void OnSearch(string token)

Packages.Clear();

List<string> filterPackages = _directoryUtils.GetFilterPackages(token);
List<(string, string?)> filterPackages = _directoryUtils.GetFilterPackages(token);

foreach (string filterPackage in filterPackages)
foreach ((string filterPackage, string? version) in filterPackages)
{
Packages.Add(new Package(filterPackage));
Packages.Add(new Package(filterPackage, version));
}
}

Expand Down
3 changes: 3 additions & 0 deletions PackageModule/Views/DotNugetPackageListView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<ToggleButton Grid.Column="0" IsChecked="{Binding Path=IsChecked}" Style="{StaticResource PackageIconToggleButtonStyle}" IsEnabled="False"/>
<TextBlock Grid.Column="1" Text="{Binding Path=Name}" TextWrapping="NoWrap" ToolTip="{Binding Path=Name}" Style="{StaticResource FolderTextBlockStyle}"/>
<TextBlock Grid.Column="2" Text="{Binding Path=Version}" TextWrapping="NoWrap" ToolTip="{Binding Path=Version}"
Style="{StaticResource FolderTextBlockStyle}" HorizontalAlignment="Right"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
Expand Down
3 changes: 3 additions & 0 deletions PackageModule/Views/PackageListView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<ToggleButton Grid.Column="0" IsChecked="{Binding Path=IsChecked}" Style="{StaticResource PackageIconToggleButtonStyle}" IsEnabled="False"/>
<TextBlock Grid.Column="1" Text="{Binding Path=Name}" TextWrapping="NoWrap" ToolTip="{Binding Path=Name}" Style="{StaticResource FolderTextBlockStyle}"/>
<TextBlock Grid.Column="2" Text="{Binding Path=Version}" TextWrapping="NoWrap" ToolTip="{Binding Path=Version}"
Style="{StaticResource FolderTextBlockStyle}" HorizontalAlignment="Right"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
Expand Down
9 changes: 3 additions & 6 deletions Resource/Resource.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<None Remove="Icons\Checked32x32.png" />
<None Remove="Icons\Delete16x16.png" />
Expand All @@ -19,7 +18,6 @@
<None Remove="Images\Rebuild.gif" />
<None Remove="Images\Upload.gif" />
</ItemGroup>

<ItemGroup>
<Resource Include="Icons\Checked32x32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -55,5 +53,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>

</Project>
</Project>
11 changes: 3 additions & 8 deletions VersionController.csproj
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<LangVersion>10.0</LangVersion>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<Product>Version Controller</Product>
<Authors>Tan Chee Boon</Authors>
<Copyright>Copyright @ 2023</Copyright>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Resource\**" />
<EmbeddedResource Remove="Resource\**" />
<None Remove="Resource\**" />
<Page Remove="Resource\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Prism.Logging.Serilog" Version="7.2.0.1423" />
<PackageReference Include="Prism.Unity" Version="8.1.97" />
<PackageReference Include="Serilog" Version="3.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="Resource\Resource.csproj" />
</ItemGroup>

</Project>
</Project>
4 changes: 2 additions & 2 deletions VersionController.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VersionController", "VersionController.csproj", "{27F1B3A0-D90F-4F35-9BD2-41AA6DB7FEAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Resource", "Resource\Resource.csproj", "{6C425B37-E9E5-4657-8130-61D2848DFC89}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Resource", "Resource\Resource.csproj", "{6C425B37-E9E5-4657-8130-61D2848DFC89}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

0 comments on commit a87c864

Please sign in to comment.