Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Oct 12, 2022
1 parent 5c6fda6 commit 3e64050
Show file tree
Hide file tree
Showing 39 changed files with 79 additions and 81 deletions.
2 changes: 1 addition & 1 deletion Onova.Updater/Onova.Updater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net46</TargetFramework>
<TargetFramework>net35</TargetFramework>
<ApplicationIcon>../favicon.ico</ApplicationIcon>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion Onova.Updater/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Onova.Updater.Internal;
using Onova.Updater.Utils;

namespace Onova.Updater;
// This executable applies the update by copying over new files.
Expand Down
2 changes: 1 addition & 1 deletion Onova.Updater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO;
using System.Reflection;
using System.Threading;
using Onova.Updater.Internal;
using Onova.Updater.Utils;

namespace Onova.Updater;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.IO;

namespace Onova.Updater.Internal;
namespace Onova.Updater.Utils;

internal static class DirectoryEx
{
Expand All @@ -9,7 +9,7 @@ public static void Copy(string sourceDirPath, string destDirPath, bool overwrite
Directory.CreateDirectory(destDirPath);

// Get all files in source directory
var sourceFilePaths = Directory.EnumerateFiles(sourceDirPath);
var sourceFilePaths = Directory.GetFiles(sourceDirPath);

// Copy them
foreach (var sourceFilePath in sourceFilePaths)
Expand All @@ -21,7 +21,7 @@ public static void Copy(string sourceDirPath, string destDirPath, bool overwrite
}

// Get all subdirectories in source directory
var sourceSubDirPaths = Directory.EnumerateDirectories(sourceDirPath);
var sourceSubDirPaths = Directory.GetDirectories(sourceDirPath);

// Recursively copy them
foreach (var sourceSubDirPath in sourceSubDirPaths)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Text;

namespace Onova.Updater.Internal;
namespace Onova.Updater.Utils;

internal static class Extensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.IO;

namespace Onova.Updater.Internal;
namespace Onova.Updater.Utils;

internal static class FileEx
{
Expand Down
2 changes: 1 addition & 1 deletion Onova/Exceptions/LockFileNotAcquiredException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Onova.Exceptions;
public class LockFileNotAcquiredException : Exception
{
/// <summary>
/// Initializes an instance of <see cref="LockFileNotAcquiredException"/>.
/// Initializes an instance of <see cref="LockFileNotAcquiredException" />.
/// </summary>
public LockFileNotAcquiredException()
: base("Could not acquire a lock file. Most likely, another instance of this application currently owns the lock file.")
Expand Down
2 changes: 1 addition & 1 deletion Onova/Exceptions/PackageNotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class PackageNotFoundException : Exception
public Version Version { get; }

/// <summary>
/// Initializes an instance of <see cref="PackageNotFoundException"/>.
/// Initializes an instance of <see cref="PackageNotFoundException" />.
/// </summary>
public PackageNotFoundException(Version version)
: base($"Package version '{version}' was not found by the configured package resolver.")
Expand Down
2 changes: 1 addition & 1 deletion Onova/Exceptions/UpdateNotPreparedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class UpdateNotPreparedException : Exception
public Version Version { get; }

/// <summary>
/// Initializes an instance of <see cref="UpdateNotPreparedException"/>.
/// Initializes an instance of <see cref="UpdateNotPreparedException" />.
/// </summary>
public UpdateNotPreparedException(Version version)
: base($"Update to version '{version}' is not prepared. Please prepare an update before applying it.")
Expand Down
2 changes: 1 addition & 1 deletion Onova/Exceptions/UpdaterAlreadyLaunchedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Onova.Exceptions;
public class UpdaterAlreadyLaunchedException : Exception
{
/// <summary>
/// Initializes an instance of <see cref="UpdaterAlreadyLaunchedException"/>.
/// Initializes an instance of <see cref="UpdaterAlreadyLaunchedException" />.
/// </summary>
public UpdaterAlreadyLaunchedException()
: base("Updater has already been launched, either by this or another instance of this application.")
Expand Down
4 changes: 2 additions & 2 deletions Onova/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Onova.Internal;
using Onova.Utils;

namespace Onova;

/// <summary>
/// Extensions for <see cref="Onova"/>.
/// Extensions for <see cref="Onova" />.
/// </summary>
public static class Extensions
{
Expand Down
2 changes: 1 addition & 1 deletion Onova/IUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Onova;

/// <summary>
/// Interface for <see cref="UpdateManager"/>.
/// Interface for <see cref="UpdateManager" />.
/// </summary>
public interface IUpdateManager : IDisposable
{
Expand Down
27 changes: 12 additions & 15 deletions Onova/Models/AssemblyMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class AssemblyMetadata
public string FilePath { get; }

/// <summary>
/// Initializes a new instance of <see cref="AssemblyMetadata"/>.
/// Initializes a new instance of <see cref="AssemblyMetadata" />.
/// </summary>
public AssemblyMetadata(string name, Version version, string filePath)
{
Expand All @@ -40,26 +40,23 @@ public partial class AssemblyMetadata
/// Extracts assembly metadata from given assembly.
/// The specified path is used to override the executable file path in case the assembly is not meant to run directly.
/// </summary>
public static AssemblyMetadata FromAssembly(Assembly assembly, string assemblyFilePath)
{
var name = assembly.GetName().Name!;
var version = assembly.GetName().Version!;
var filePath = assemblyFilePath;

return new AssemblyMetadata(name, version, filePath);
}
public static AssemblyMetadata FromAssembly(Assembly assembly, string assemblyFilePath) => new(
assembly.GetName().Name!,
assembly.GetName().Version!,
assemblyFilePath
);

/// <summary>
/// Extracts assembly metadata from given assembly.
/// </summary>
public static AssemblyMetadata FromAssembly(Assembly assembly) => FromAssembly(assembly, assembly.Location);
public static AssemblyMetadata FromAssembly(Assembly assembly) =>
FromAssembly(assembly, assembly.Location);

/// <summary>
/// Extracts assembly metadata from entry assembly.
/// </summary>
public static AssemblyMetadata FromEntryAssembly()
{
var assembly = Assembly.GetEntryAssembly() ?? throw new InvalidOperationException("Can't get entry assembly.");
return FromAssembly(assembly);
}
public static AssemblyMetadata FromEntryAssembly() => FromAssembly(
Assembly.GetEntryAssembly() ??
throw new InvalidOperationException("Can't get entry assembly.")
);
}
2 changes: 1 addition & 1 deletion Onova/Models/CheckForUpdatesResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CheckForUpdatesResult
public bool CanUpdate { get; }

/// <summary>
/// Initializes a new instance of <see cref="CheckForUpdatesResult"/>.
/// Initializes a new instance of <see cref="CheckForUpdatesResult" />.
/// </summary>
public CheckForUpdatesResult(IReadOnlyList<Version> versions, Version? lastVersion, bool canUpdate)
{
Expand Down
2 changes: 1 addition & 1 deletion Onova/Onova.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="../Onova.Updater/bin/$(Configuration)/net46/Onova.Updater.exe">
<EmbeddedResource Include="../Onova.Updater/bin/$(Configuration)/net35/Onova.Updater.exe">
<Link>Updater.exe</Link>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<Visible>false</Visible>
Expand Down
6 changes: 3 additions & 3 deletions Onova/Services/AggregatePackageResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Threading;
using System.Threading.Tasks;
using Onova.Exceptions;
using Onova.Internal.Extensions;
using Onova.Utils.Extensions;

namespace Onova.Services;

Expand All @@ -16,15 +16,15 @@ public class AggregatePackageResolver : IPackageResolver
private readonly IReadOnlyList<IPackageResolver> _resolvers;

/// <summary>
/// Initializes an instance of <see cref="AggregatePackageResolver"/>.
/// Initializes an instance of <see cref="AggregatePackageResolver" />.
/// </summary>
public AggregatePackageResolver(IReadOnlyList<IPackageResolver> resolvers)
{
_resolvers = resolvers;
}

/// <summary>
/// Initializes an instance of <see cref="AggregatePackageResolver"/>.
/// Initializes an instance of <see cref="AggregatePackageResolver" />.
/// </summary>
public AggregatePackageResolver(params IPackageResolver[] resolvers)
: this((IReadOnlyList<IPackageResolver>) resolvers)
Expand Down
12 changes: 6 additions & 6 deletions Onova/Services/GithubPackageResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
using System.Threading;
using System.Threading.Tasks;
using Onova.Exceptions;
using Onova.Internal;
using Onova.Internal.Extensions;
using Onova.Utils;
using Onova.Utils.Extensions;

namespace Onova.Services;

Expand All @@ -31,7 +31,7 @@ public class GithubPackageResolver : IPackageResolver
private IReadOnlyDictionary<Version, string>? _cachedPackageVersionUrlMap;

/// <summary>
/// Initializes an instance of <see cref="GithubPackageResolver"/>.
/// Initializes an instance of <see cref="GithubPackageResolver" />.
/// </summary>
public GithubPackageResolver(
HttpClient httpClient,
Expand All @@ -48,7 +48,7 @@ public class GithubPackageResolver : IPackageResolver
}

/// <summary>
/// Initializes an instance of <see cref="GithubPackageResolver"/>.
/// Initializes an instance of <see cref="GithubPackageResolver" />.
/// </summary>
public GithubPackageResolver(
HttpClient httpClient,
Expand All @@ -60,7 +60,7 @@ public class GithubPackageResolver : IPackageResolver
}

/// <summary>
/// Initializes an instance of <see cref="GithubPackageResolver"/>.
/// Initializes an instance of <see cref="GithubPackageResolver" />.
/// </summary>
public GithubPackageResolver(
string apiBaseAddress,
Expand All @@ -72,7 +72,7 @@ public class GithubPackageResolver : IPackageResolver
}

/// <summary>
/// Initializes an instance of <see cref="GithubPackageResolver"/>.
/// Initializes an instance of <see cref="GithubPackageResolver" />.
/// </summary>
public GithubPackageResolver(
string repositoryOwner,
Expand Down
6 changes: 3 additions & 3 deletions Onova/Services/LocalPackageResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using System.Threading;
using System.Threading.Tasks;
using Onova.Exceptions;
using Onova.Internal;
using Onova.Internal.Extensions;
using Onova.Utils;
using Onova.Utils.Extensions;

namespace Onova.Services;

Expand All @@ -21,7 +21,7 @@ public class LocalPackageResolver : IPackageResolver
private readonly string _fileNamePattern;

/// <summary>
/// Initializes an instance of <see cref="LocalPackageResolver"/>.
/// Initializes an instance of <see cref="LocalPackageResolver" />.
/// </summary>
public LocalPackageResolver(string repositoryDirPath, string fileNamePattern = "*")
{
Expand Down
6 changes: 3 additions & 3 deletions Onova/Services/NugetPackageExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Onova.Internal;
using Onova.Internal.Extensions;
using Onova.Utils;
using Onova.Utils.Extensions;

namespace Onova.Services;

Expand All @@ -17,7 +17,7 @@ public class NugetPackageExtractor : IPackageExtractor
private readonly string _rootDirPath;

/// <summary>
/// Initializes an instance of <see cref="NugetPackageExtractor"/>.
/// Initializes an instance of <see cref="NugetPackageExtractor" />.
/// </summary>
public NugetPackageExtractor(string rootDirPath)
{
Expand Down
8 changes: 4 additions & 4 deletions Onova/Services/NugetPackageResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using System.Threading;
using System.Threading.Tasks;
using Onova.Exceptions;
using Onova.Internal;
using Onova.Internal.Extensions;
using Onova.Utils;
using Onova.Utils.Extensions;

namespace Onova.Services;

Expand All @@ -24,7 +24,7 @@ public class NugetPackageResolver : IPackageResolver
private string PackageIdNormalized => _packageId.ToLowerInvariant();

/// <summary>
/// Initializes an instance of <see cref="NugetPackageResolver"/>.
/// Initializes an instance of <see cref="NugetPackageResolver" />.
/// </summary>
public NugetPackageResolver(HttpClient httpClient, string serviceIndexUrl, string packageId)
{
Expand All @@ -34,7 +34,7 @@ public NugetPackageResolver(HttpClient httpClient, string serviceIndexUrl, strin
}

/// <summary>
/// Initializes an instance of <see cref="NugetPackageResolver"/>.
/// Initializes an instance of <see cref="NugetPackageResolver" />.
/// </summary>
public NugetPackageResolver(string serviceIndexUrl, string packageId)
: this(Http.Client, serviceIndexUrl, packageId)
Expand Down
8 changes: 4 additions & 4 deletions Onova/Services/WebPackageResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using System.Threading;
using System.Threading.Tasks;
using Onova.Exceptions;
using Onova.Internal;
using Onova.Internal.Extensions;
using Onova.Utils;
using Onova.Utils.Extensions;

namespace Onova.Services;

Expand All @@ -21,7 +21,7 @@ public class WebPackageResolver : IPackageResolver
private readonly string _manifestUrl;

/// <summary>
/// Initializes an instance of <see cref="WebPackageResolver"/>.
/// Initializes an instance of <see cref="WebPackageResolver" />.
/// </summary>
public WebPackageResolver(HttpClient httpClient, string manifestUrl)
{
Expand All @@ -30,7 +30,7 @@ public WebPackageResolver(HttpClient httpClient, string manifestUrl)
}

/// <summary>
/// Initializes an instance of <see cref="WebPackageResolver"/>.
/// Initializes an instance of <see cref="WebPackageResolver" />.
/// </summary>
public WebPackageResolver(string manifestUrl)
: this(Http.Client, manifestUrl)
Expand Down
4 changes: 2 additions & 2 deletions Onova/Services/ZipPackageExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Onova.Internal;
using Onova.Internal.Extensions;
using Onova.Utils;
using Onova.Utils.Extensions;

namespace Onova.Services;

Expand Down

0 comments on commit 3e64050

Please sign in to comment.