-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small DesktopApplier fix and VersionHelper
Also added CanApplyUpdates tests and moving around some classes into their own files
- Loading branch information
Showing
22 changed files
with
172 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 1 addition & 14 deletions
15
src/TinyUpdate.Core/Abstract/UpdatePackage/IUpdatePackage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/TinyUpdate.Core/Abstract/UpdatePackage/IUpdatePackageFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace TinyUpdate.Core.Abstract.UpdatePackage; | ||
|
||
public record LoadResult | ||
{ | ||
public static LoadResult Failed(string message) => new() { Successful = false, Message = message }; | ||
|
||
public static readonly LoadResult Success = new() { Successful = true }; | ||
|
||
[MemberNotNullWhen(false, nameof(Message))] | ||
public bool Successful { get; protected init; } | ||
|
||
public string? Message { get; protected init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using TinyUpdate.Core.Abstract.UpdatePackage; | ||
|
||
namespace TinyUpdate.Core.Model; | ||
|
||
public record LoadUpdatePackageResult | ||
{ | ||
public LoadUpdatePackageResult(bool successful, string? message, IUpdatePackage? updatePackage) | ||
{ | ||
Successful = successful; | ||
Message = message; | ||
UpdatePackage = updatePackage; | ||
} | ||
|
||
public static LoadUpdatePackageResult Failed(string message) => new(false, message, null); | ||
|
||
public static LoadUpdatePackageResult Success(IUpdatePackage updatePackage) => new(true, null, updatePackage); | ||
|
||
[MemberNotNullWhen(true, nameof(UpdatePackage))] | ||
[MemberNotNullWhen(false, nameof(Message))] | ||
public bool Successful { get; } | ||
|
||
public string? Message { get; } | ||
|
||
public IUpdatePackage? UpdatePackage { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace TinyUpdate.Core.Model; | ||
|
||
public ref struct VersionDetails | ||
{ | ||
public VersionDetails(ReadOnlySpan<char> version) | ||
{ | ||
Version = version; | ||
} | ||
|
||
public ReadOnlySpan<char> Version { get; internal set; } = ReadOnlySpan<char>.Empty; | ||
public ReadOnlySpan<char> SourceRevisionId { get; internal set; } = ReadOnlySpan<char>.Empty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Reflection; | ||
using SemVersion; | ||
using TinyUpdate.Core.Model; | ||
|
||
namespace TinyUpdate.Core; | ||
|
||
public static class VersionHelper | ||
{ | ||
public static SemanticVersion GetSemanticVersion(this ReadOnlySpan<char> version) => SemanticVersion.Parse(GetVersionDetails(version).Version.ToString()); | ||
public static ReadOnlySpan<char> GetVersion(this ReadOnlySpan<char> version) => GetVersionDetails(version).Version; | ||
public static ReadOnlySpan<char> GetSourceRevisionId(this ReadOnlySpan<char> version) => GetVersionDetails(version).SourceRevisionId; | ||
|
||
public static VersionDetails GetVersionDetails() => GetVersionDetails(Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly()); | ||
public static VersionDetails GetVersionDetails(this Assembly assembly) | ||
{ | ||
var versionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>(); | ||
|
||
var version = versionAttribute?.InformationalVersion; | ||
return string.IsNullOrWhiteSpace(version) ? new VersionDetails() : GetVersionDetails(version); | ||
} | ||
|
||
public static VersionDetails GetVersionDetails(this ReadOnlySpan<char> version) | ||
{ | ||
var versionDetails = new VersionDetails(version); | ||
|
||
var plusIndex = version.IndexOf('+'); | ||
if (plusIndex != -1) | ||
{ | ||
var tmpSpan = version[++plusIndex..]; | ||
var dotIndex = tmpSpan.IndexOf('.'); | ||
var hasDot = dotIndex != -1; | ||
|
||
if (hasDot) | ||
{ | ||
versionDetails.SourceRevisionId = tmpSpan[(dotIndex + 1)..]; | ||
versionDetails.Version = version[..^(versionDetails.SourceRevisionId.Length + 1)]; | ||
} | ||
else if (tmpSpan.Length == 40) | ||
{ | ||
versionDetails.SourceRevisionId = tmpSpan; | ||
versionDetails.Version = version[..^41]; | ||
} | ||
} | ||
|
||
return versionDetails; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters