From 4124b7cc8a6e659e7ce6c8909d5c316b5eb7aeb2 Mon Sep 17 00:00:00 2001 From: Dave Transom Date: Fri, 8 May 2020 15:10:43 +1200 Subject: [PATCH] Documentation improvements, version bump --- .../CSharpVitamins.ShortGuid.csproj | 7 ++-- CSharpVitamins.ShortGuid/ShortGuid.cs | 40 ++++++++++--------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/CSharpVitamins.ShortGuid/CSharpVitamins.ShortGuid.csproj b/CSharpVitamins.ShortGuid/CSharpVitamins.ShortGuid.csproj index 1532bed..6391663 100644 --- a/CSharpVitamins.ShortGuid/CSharpVitamins.ShortGuid.csproj +++ b/CSharpVitamins.ShortGuid/CSharpVitamins.ShortGuid.csproj @@ -6,16 +6,17 @@ CSharpVitamins Dave Transom CSharpVitamins - A convenience wrapper struct for dealing with URL-safe base64 encoded globally unique identifier (GUID), making a shorter string value (22 vs 36 characters long). + A convenience wrapper struct for dealing with URL-safe Base64 encoded globally unique identifiers (GUID), making a shorter string value (22 vs 36 characters long). LICENSE.md https://github.com/csharpvitamins/csharpvitamins.shortguid/ https://github.com/csharpvitamins/csharpvitamins.shortguid/ Guid ShortGuid Identifiers Base64 - - 1.0.1 Target netstandard2.0 and net40 + - 1.0.2 Fix: Ambiguous use of `==` operator when comparing Guid and ShortGuid instances +- 1.0.1 Target netstandard2.0 and net40 - 1.0.0 Initial release Copyright 2007 - 1.0.1 + 1.0.2 diff --git a/CSharpVitamins.ShortGuid/ShortGuid.cs b/CSharpVitamins.ShortGuid/ShortGuid.cs index 209ffa9..4d415e8 100644 --- a/CSharpVitamins.ShortGuid/ShortGuid.cs +++ b/CSharpVitamins.ShortGuid/ShortGuid.cs @@ -4,17 +4,19 @@ namespace CSharpVitamins { /// - /// A convenience wrapper struct for dealing with URL-safe Base64 encoded globally unique identifier (GUID), + /// A convenience wrapper struct for dealing with URL-safe Base64 encoded globally unique identifiers (GUID), /// making a shorter string value (22 vs 36 characters long). /// /// - /// URL-safe Base64? That's just a Base64 string with well known special characters replaced (/, +) or removed (==). + /// What is URL-safe Base64? That's just a Base64 string with well known special characters replaced (/, +) + /// or removed (==). /// [DebuggerDisplay("{Value}")] public struct ShortGuid { /// - /// A read-only instance of the ShortGuid struct whose value is guaranteed to be all zeroes. + /// A read-only instance of the ShortGuid struct whose value is guaranteed to be all zeroes i.e. equivilent + /// to . /// public static readonly ShortGuid Empty = new ShortGuid(Guid.Empty); @@ -22,10 +24,11 @@ public struct ShortGuid string encodedString; /// - /// Creates a new instance with the given Base64 encoded string. - /// (See also ) + /// Creates a new instance with the given URL-safe Base64 encoded string. + /// See also which will try to coerce the + /// the value from URL-safe Base64 or normal Guid string /// - /// A ShortGuid encoded string. + /// A ShortGuid encoded string e.g. URL-safe Base64. public ShortGuid(string value) { encodedString = value; @@ -33,7 +36,7 @@ public ShortGuid(string value) } /// - /// Creates a new instance with the given Guid. + /// Creates a new instance with the given . /// /// The Guid to encode. public ShortGuid(Guid guid) @@ -43,17 +46,17 @@ public ShortGuid(Guid guid) } /// - /// Gets the underlying Guid for the encoded ShortGuid. + /// Gets the underlying for the encoded ShortGuid. /// public Guid Guid => underlyingGuid; /// - /// Gets the encoded string value of the Guid. + /// Gets the encoded string value of the i.e. a URL-safe Base64 string. /// public string Value => encodedString; /// - /// Returns the encoded string value. + /// Returns the encoded URL-safe Base64 string. /// /// public override string ToString() => encodedString; @@ -91,7 +94,7 @@ public override bool Equals(object obj) } /// - /// Returns the HashCode for the underlying Guid. + /// Returns the hash code for the underlying . /// /// public override int GetHashCode() => underlyingGuid.GetHashCode(); @@ -107,7 +110,7 @@ public override bool Equals(object obj) /// Base64, with some non-URL safe characters replaced, and padding removed. /// /// Any valid string. - /// A 22 character ShortGuid string. + /// A 22 character ShortGuid URL-safe Base64 string. public static string Encode(string value) { var guid = new Guid(value); @@ -119,7 +122,7 @@ public static string Encode(string value) /// Base64, with some non-URL safe characters replaced, and padding removed. /// /// The to encode. - /// A 22 character ShortGuid string. + /// A 22 character ShortGuid URL-safe Base64 string. public static string Encode(Guid guid) { string encoded = Convert.ToBase64String(guid.ToByteArray()); @@ -218,7 +221,7 @@ public static bool TryDecode(string value, out Guid guid) public static implicit operator string(ShortGuid shortGuid) => shortGuid.encodedString; /// - /// Implicitly converts the ShortGuid to its Guid equivalent. + /// Implicitly converts the ShortGuid to its equivalent. /// public static implicit operator Guid(ShortGuid shortGuid) => shortGuid.underlyingGuid; @@ -233,11 +236,12 @@ public static implicit operator ShortGuid(string value) if (TryParse(value, out ShortGuid shortGuid)) return shortGuid; - throw new FormatException("ShortGuid should contain 22 Base64 characters or Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."); + throw new FormatException("ShortGuid should contain 22 Base64 characters or " + + "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."); } /// - /// Implicitly converts the Guid to a ShortGuid. + /// Implicitly converts the to a ShortGuid. /// public static implicit operator ShortGuid(Guid guid) { @@ -250,7 +254,7 @@ public static implicit operator ShortGuid(Guid guid) #endregion /// - /// Tries to parse the value as a ShortGuid or Guid string. + /// Tries to parse the value as a ShortGuid or string. /// /// The ShortGuid encoded string or string representation of a Guid. /// A new instance from the parsed string. @@ -276,7 +280,7 @@ public static bool TryParse(string value, out ShortGuid shortGuid) } /// - /// Tries to parse the value as a ShortGuid or Guid string, and outputs the underlying Guid value. + /// Tries to parse the value as a ShortGuid or string, and outputs the underlying value. /// /// The ShortGuid encoded string or string representation of a Guid. /// A new instance from the parsed string.