Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Add XML comments for public members and turn on doc gen
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Dec 31, 2021
1 parent 503c403 commit 53d3846
Show file tree
Hide file tree
Showing 22 changed files with 307 additions and 26 deletions.
8 changes: 8 additions & 0 deletions src/Squirrel/AssemblyRuntimeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@

namespace Squirrel
{
/// <summary>
/// Convenience class which provides runtime information about the current executing process,
/// in a way that is safe in older and newer versions of the framework, including SingleFileBundles
/// </summary>
public static class AssemblyRuntimeInfo
{
/// <summary> The path on disk of the entry assembly </summary>
public static string EntryExePath { get; }
/// <summary> Gets the directory that the assembly resolver uses to probe for assemblies. </summary>
public static string BaseDirectory { get; }
/// <summary> The name of the currently executing assembly </summary>
public static AssemblyName ExecutingAssemblyName => Assembly.GetExecutingAssembly().GetName();
/// <summary> Check if the current application is a published SingleFileBundle </summary>
public static bool IsSingleFile { get; }

static AssemblyRuntimeInfo()
Expand Down
17 changes: 17 additions & 0 deletions src/Squirrel/FileDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,37 @@

namespace Squirrel
{
/// <summary>
/// A simple abstractable file downloader
/// </summary>
public interface IFileDownloader
{

/// <summary>
/// Download a file at the specified url to the specified local file
/// </summary>
Task DownloadFile(string url, string targetFile, Action<int> progress);

/// <summary>
/// Returns a byte array containing the contents of the file at the specified url
/// </summary>
Task<byte[]> DownloadUrl(string url);
}

/// <inheritdoc cref="IFileDownloader"/>
public class FileDownloader : IFileDownloader, IEnableLogger
{
private readonly WebClient _providedClient;

/// <summary>
/// Create a new <see cref="FileDownloader"/>, optionally providing a custom WebClient
/// </summary>
public FileDownloader(WebClient providedClient = null)
{
_providedClient = providedClient;
}

/// <inheritdoc />
public async Task DownloadFile(string url, string targetFile, Action<int> progress)
{
using (var wc = _providedClient ?? Utility.CreateWebClient()) {
Expand Down Expand Up @@ -57,6 +73,7 @@ await this.WarnIfThrows(
}
}

/// <inheritdoc />
public async Task<byte[]> DownloadUrl(string url)
{
using (var wc = _providedClient ?? Utility.CreateWebClient()) {
Expand Down
38 changes: 35 additions & 3 deletions src/Squirrel/IUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@

namespace Squirrel
{
/// <summary>
/// Specifies several common places where shortcuts can be installed on a user's system
/// </summary>
[Flags]
public enum ShortcutLocation
{

/// <summary>
/// A shortcut in ProgramFiles within a publisher sub-directory
/// </summary>
Expand All @@ -43,12 +45,28 @@ public enum ShortcutLocation
StartMenuRoot = 1 << 4,
}

/// <summary>
/// Indicates whether the UpdateManager is used in a Install or Update scenario.
/// </summary>
public enum UpdaterIntention
{
/// <summary>
/// The current intent is to perform a full app install, and overwrite or
/// repair any app already installed of the same name.
/// </summary>
Install,

/// <summary>
/// The current intent is to perform an app update, and to do nothing if there
/// is no newer version available to install.
/// </summary>
Update
}

/// <summary>
/// An object providing update functionality to applications, and general helper
/// functions for managing installed shortcuts and registry entries.
/// </summary>
public interface IUpdateManager : IDisposable, IEnableLogger
{
/// <summary>
Expand Down Expand Up @@ -96,13 +114,11 @@ public interface IUpdateManager : IDisposable, IEnableLogger
/// <param name="silentInstall">If true, don't run the app once install completes.</param>
/// <param name="progress">A Observer which can be used to report Progress -
/// will return values from 0-100 and Complete, or Throw</param>
/// <returns>Completion</returns>
Task FullInstall(bool silentInstall, Action<int> progress = null);

/// <summary>
/// Completely uninstalls the targeted app
/// </summary>
/// <returns>Completion</returns>
Task FullUninstall();

/// <summary>
Expand Down Expand Up @@ -161,8 +177,17 @@ public interface IUpdateManager : IDisposable, IEnableLogger
void RemoveShortcutsForExecutable(string exeName, ShortcutLocation locations);
}

/// <summary>
/// Contains extension methods for <see cref="IUpdateManager"/> which provide simplified functionality
/// </summary>
public static class EasyModeMixin
{
/// <summary>
/// This will check for updates, download any new available updates, and apply those
/// updates in a single step. The same task can be accomplished by using <see cref="IUpdateManager.CheckForUpdate"/>,
/// followed by <see cref="IUpdateManager.DownloadReleases"/> and <see cref="IUpdateManager.ApplyReleases"/>.
/// </summary>
/// <returns>The installed update, or null if there were no updates available</returns>
public static async Task<ReleaseEntry> UpdateApp(this IUpdateManager This, Action<int> progress = null)
{
progress = progress ?? (_ => { });
Expand Down Expand Up @@ -202,6 +227,10 @@ await This.ErrorIfThrows(() =>
default(ReleaseEntry);
}

/// <summary>
/// Create a shortcut to the currently running executable at the specified locations.
/// See <see cref="IUpdateManager.CreateShortcutsForExecutable"/> to create a shortcut to a different program
/// </summary>
public static void CreateShortcutForThisExe(this IUpdateManager This, ShortcutLocation location = ShortcutLocation.Desktop | ShortcutLocation.StartMenu)
{
This.CreateShortcutsForExecutable(
Expand All @@ -212,6 +241,9 @@ public static void CreateShortcutForThisExe(this IUpdateManager This, ShortcutLo
null); // shortcut icon
}

/// <summary>
/// Removes a shortcut for the currently running executable at the specified locations.
/// </summary>
public static void RemoveShortcutForThisExe(this IUpdateManager This, ShortcutLocation location = ShortcutLocation.Desktop | ShortcutLocation.StartMenu)
{
This.RemoveShortcutsForExecutable(
Expand Down
8 changes: 4 additions & 4 deletions src/Squirrel/Internal/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ internal static extern bool CreateDelta(
}

[Flags]
public enum ProcessAccess : uint
internal enum ProcessAccess : uint
{
All = 0x001F0FFF,
Terminate = 0x00000001,
Expand All @@ -212,7 +212,7 @@ public enum ProcessAccess : uint
Synchronize = 0x00100000
}

public enum PROCESSINFOCLASS : int
internal enum PROCESSINFOCLASS : int
{
ProcessBasicInformation = 0, // 0, q: PROCESS_BASIC_INFORMATION, PROCESS_EXTENDED_BASIC_INFORMATION
ProcessQuotaLimits, // qs: QUOTA_LIMITS, QUOTA_LIMITS_EX
Expand Down Expand Up @@ -275,7 +275,7 @@ public enum PROCESSINFOCLASS : int
};

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct PROCESS_BASIC_INFORMATION
internal struct PROCESS_BASIC_INFORMATION
{
public IntPtr ExitStatus;
public IntPtr PebBaseAddress;
Expand All @@ -289,7 +289,7 @@ public int Size {
}
}

public enum StandardHandles : int
internal enum StandardHandles : int
{
STD_INPUT_HANDLE = -10,
STD_OUTPUT_HANDLE = -11,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Squirrel
{
public static class VersionExtensions
internal static class VersionExtensions
{
static readonly Regex _suffixRegex = new Regex(@"(-full|-delta)?\.nupkg$", RegexOptions.Compiled);
static readonly Regex _versionRegex = new Regex(@"\d+(\.\d+){0,3}(-[A-Za-z][0-9A-Za-z-]*)?$", RegexOptions.Compiled);
Expand Down
2 changes: 1 addition & 1 deletion src/Squirrel/Internal/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public static T Retry<T>(this Func<T> block, int retries = 2, int retryDelay = 2
/// <remarks>
/// The string is only valid for passing directly to a process. If the target process is invoked by passing the
/// process name + arguments to cmd.exe then further escaping is required, to counteract cmd.exe's interpretation
/// of additional special characters. See <see cref="EscapeCmdExeMetachars"/>.</remarks>
/// of additional special characters. See CommandRunner.cs-EscapeCmdExeMetachars.</remarks>
public static string ArgsToCommandLine(IEnumerable<string> args)
{
var sb = new StringBuilder();
Expand Down
4 changes: 3 additions & 1 deletion src/Squirrel/Lib/MarkdownSharp.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
#pragma warning disable CS1591

/*
* MarkdownSharp
* -------------
* a C# Markdown processor
Expand Down
4 changes: 3 additions & 1 deletion src/Squirrel/Lib/Mono.Options.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//
#pragma warning disable CS1591

//
// Options.cs
//
// Authors:
Expand Down
20 changes: 20 additions & 0 deletions src/Squirrel/NuGet/SemanticVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public sealed class SemanticVersion : IComparable, IComparable<SemanticVersion>,
private static readonly Regex _preReleaseVersionRegex = new Regex(@"(?<PreReleaseString>[a-z]+)(?<PreReleaseNumber>[0-9]+)$", _flags);
private readonly string _originalString;

/// <summary> Create a new instance of <see cref="SemanticVersion"/> with the specified version </summary>
public SemanticVersion(string version)
: this(Parse(version))
{
Expand All @@ -28,21 +29,25 @@ public SemanticVersion(string version)
_originalString = version;
}

/// <inheritdoc cref="SemanticVersion(string)"/>
public SemanticVersion(int major, int minor, int build, int revision)
: this(new Version(major, minor, build, revision))
{
}

/// <inheritdoc cref="SemanticVersion(string)"/>
public SemanticVersion(int major, int minor, int build, string specialVersion)
: this(new Version(major, minor, build), specialVersion)
{
}

/// <inheritdoc cref="SemanticVersion(string)"/>
public SemanticVersion(Version version)
: this(version, String.Empty)
{
}

/// <inheritdoc cref="SemanticVersion(string)"/>
public SemanticVersion(Version version, string specialVersion)
: this(version, specialVersion, null)
{
Expand Down Expand Up @@ -81,6 +86,9 @@ public string SpecialVersion {
private set;
}

/// <summary>
/// Gets the components of the original string used to construct this version instance.
/// </summary>
public string[] GetOriginalVersionComponents()
{
if (!String.IsNullOrEmpty(_originalString)) {
Expand Down Expand Up @@ -183,6 +191,7 @@ private static Version NormalizeVersionValue(Version version)
Math.Max(version.Revision, 0));
}

/// <inheritdoc/>
public int CompareTo(object obj)
{
if (Object.ReferenceEquals(obj, null)) {
Expand All @@ -195,6 +204,7 @@ public int CompareTo(object obj)
return CompareTo(other);
}

/// <inheritdoc/>
public int CompareTo(SemanticVersion other)
{
if (Object.ReferenceEquals(other, null)) {
Expand Down Expand Up @@ -236,6 +246,7 @@ public int CompareTo(SemanticVersion other)
return StringComparer.OrdinalIgnoreCase.Compare(SpecialVersion, other.SpecialVersion);
}

/// <inheritdoc/>
public static bool operator ==(SemanticVersion version1, SemanticVersion version2)
{
if (Object.ReferenceEquals(version1, null)) {
Expand All @@ -244,11 +255,13 @@ public int CompareTo(SemanticVersion other)
return version1.Equals(version2);
}

/// <inheritdoc/>
public static bool operator !=(SemanticVersion version1, SemanticVersion version2)
{
return !(version1 == version2);
}

/// <inheritdoc/>
public static bool operator <(SemanticVersion version1, SemanticVersion version2)
{
if (version1 == null) {
Expand All @@ -257,11 +270,13 @@ public int CompareTo(SemanticVersion other)
return version1.CompareTo(version2) < 0;
}

/// <inheritdoc/>
public static bool operator <=(SemanticVersion version1, SemanticVersion version2)
{
return (version1 == version2) || (version1 < version2);
}

/// <inheritdoc/>
public static bool operator >(SemanticVersion version1, SemanticVersion version2)
{
if (version1 == null) {
Expand All @@ -270,29 +285,34 @@ public int CompareTo(SemanticVersion other)
return version2 < version1;
}

/// <inheritdoc/>
public static bool operator >=(SemanticVersion version1, SemanticVersion version2)
{
return (version1 == version2) || (version1 > version2);
}

/// <inheritdoc/>
public override string ToString()
{
return _originalString;
}

/// <inheritdoc/>
public bool Equals(SemanticVersion other)
{
return !Object.ReferenceEquals(null, other) &&
Version.Equals(other.Version) &&
SpecialVersion.Equals(other.SpecialVersion, StringComparison.OrdinalIgnoreCase);
}

/// <inheritdoc/>
public override bool Equals(object obj)
{
SemanticVersion semVer = obj as SemanticVersion;
return !Object.ReferenceEquals(null, semVer) && Equals(semVer);
}

/// <inheritdoc/>
public override int GetHashCode()
{
int hashCode = Version.GetHashCode();
Expand Down
Loading

0 comments on commit 53d3846

Please sign in to comment.