diff --git a/build.ps1 b/build.ps1
index dc59c6d..0065375 100755
--- a/build.ps1
+++ b/build.ps1
@@ -9,10 +9,20 @@ if ($null -eq (Get-Command "dotnet" -ErrorAction Ignore)) {
}
dotnet tool restore
+if ($LastExitCode -ne 0) { exit $LastExitCode }
+
dotnet restore
+if ($LastExitCode -ne 0) { exit $LastExitCode }
+
dotnet build --no-restore --configuration Release
+if ($LastExitCode -ne 0) { exit $LastExitCode }
+
dotnet test --no-build --configuration Release --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml --coverage-settings .runsettings
+if ($LastExitCode -ne 0) { exit $LastExitCode }
+
dotnet reportgenerator -reports:**/TestResults/**/coverage.cobertura.xml -targetdir:CoverageReport -reporttypes:"TextSummary" -verbosity:off
+if ($LastExitCode -ne 0) { exit $LastExitCode }
+
Write-Host ""
Write-Host "Code coverage report:" -ForegroundColor DarkGreen
Write-Host ""
diff --git a/samples/EnvSample/EnvSample.csproj b/samples/EnvSample/EnvSample.csproj
index 13d169a..f6328af 100644
--- a/samples/EnvSample/EnvSample.csproj
+++ b/samples/EnvSample/EnvSample.csproj
@@ -22,7 +22,6 @@
-
diff --git a/samples/LinkSample/LinkSample.csproj b/samples/LinkSample/LinkSample.csproj
index 531440f..d95999c 100644
--- a/samples/LinkSample/LinkSample.csproj
+++ b/samples/LinkSample/LinkSample.csproj
@@ -24,7 +24,6 @@
-
diff --git a/samples/NetInfoSample/NetInfoSample.csproj b/samples/NetInfoSample/NetInfoSample.csproj
index 531440f..d95999c 100644
--- a/samples/NetInfoSample/NetInfoSample.csproj
+++ b/samples/NetInfoSample/NetInfoSample.csproj
@@ -24,7 +24,6 @@
-
diff --git a/src/Hyphen.Sdk/Abstractions/IEnv.cs b/src/Hyphen.Sdk/Abstractions/IEnv.cs
index 5d946fc..f026cd7 100644
--- a/src/Hyphen.Sdk/Abstractions/IEnv.cs
+++ b/src/Hyphen.Sdk/Abstractions/IEnv.cs
@@ -12,8 +12,8 @@ public interface IEnv
/// Gets a value from the given environment variable.
///
/// The environment variable name
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -33,8 +33,8 @@ public interface IEnv
/// The environment variable name
/// A bitwise combination of enumeration values that indicates the permitted format.
/// An object that supplies culture-specific parsing information.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -46,8 +46,8 @@ public interface IEnv
/// The environment variable name
/// A bitwise combination of enumeration values that indicates the permitted format.
/// An object that supplies culture-specific parsing information.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -59,8 +59,8 @@ public interface IEnv
/// The environment variable name
/// A bitwise combination of enumeration values that indicates the permitted format.
/// An object that supplies culture-specific parsing information.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -72,8 +72,8 @@ public interface IEnv
/// The environment variable name
/// A bitwise combination of enumeration values that indicates the permitted format.
/// An object that supplies culture-specific parsing information.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -83,8 +83,8 @@ public interface IEnv
/// Gets a value from the given environment variable.
///
/// The environment variable name
- /// When true and the variable does not exist, will throw;
- /// when false, will return null instead.
+ /// When and the variable does not exist, will throw;
+ /// when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
diff --git a/src/Hyphen.Sdk/Abstractions/ILink.cs b/src/Hyphen.Sdk/Abstractions/ILink.cs
index 216c5a6..8bebd6d 100644
--- a/src/Hyphen.Sdk/Abstractions/ILink.cs
+++ b/src/Hyphen.Sdk/Abstractions/ILink.cs
@@ -55,7 +55,7 @@ public interface ILink
/// The short code ID. (Example: "code_686bed403c3991bd676bba4d")
/// The QR code ID. (Example: "lqr_66fc51fe144cf3a1bd2a35b1")
/// The cancellation token to cancel the request early
- /// Returns the QR code, if present; returns null for an unknown short code ID
+ /// Returns the QR code, if present; returns for an unknown short code ID
/// or QR code ID or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
@@ -67,7 +67,7 @@ public interface ILink
/// The short code ID. (Example: "code_686bed403c3991bd676bba4d")
/// Optional parameters for getting the list of QR codes.
/// The cancellation token to cancel the request early
- /// The list of QR codes that match the search options; returns null for an unknown
+ /// The list of QR codes that match the search options; returns for an unknown
/// short code ID or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
@@ -78,7 +78,7 @@ public interface ILink
///
/// The short code ID. (Example: "code_686bed403c3991bd676bba4d")
/// The cancellation token to cancel the request early
- /// Returns the short code, if available; returns null for an unknown code or organization ID.
+ /// Returns the short code, if available; returns for an unknown code or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
Task GetShortCode(string shortCodeId, CancellationToken cancellationToken);
@@ -88,7 +88,7 @@ public interface ILink
///
/// Optional parameters for getting the list of short codes.
/// The cancellation token to cancel the request early
- /// The list of short codes that match the search options; returns null for an unknown organization ID.
+ /// The list of short codes that match the search options; returns for an unknown organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
Task?> GetShortCodes(GetShortCodesParams? parms, CancellationToken cancellationToken);
@@ -100,7 +100,7 @@ public interface ILink
/// The start date.
/// The end date.
/// The cancellation token to cancel the request early
- /// The statistics for the given short code, if present; returns null
+ /// The statistics for the given short code, if present; returns
/// for an unknown short code ID or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
@@ -110,7 +110,7 @@ public interface ILink
/// Gets a list of all the tags used by the organization's short codes.
///
/// The cancellation token to cancel the request early
- /// The combined list of tags, if present; returns null for an unknown organization ID.
+ /// The combined list of tags, if present; returns for an unknown organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
Task GetTags(CancellationToken cancellationToken);
diff --git a/src/Hyphen.Sdk/Extensions/HyphenSdkColorExtensions.cs b/src/Hyphen.Sdk/Extensions/HyphenSdkColorExtensions.cs
deleted file mode 100644
index 85cd945..0000000
--- a/src/Hyphen.Sdk/Extensions/HyphenSdkColorExtensions.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace System.Drawing;
-
-internal static class HyphenSdkColorExtensions
-{
- public static string ToCss(this Color color)
- {
- var result = "#"
- + ToHexChar(color.R >> 4) + ToHexChar(color.R & 0xF)
- + ToHexChar(color.G >> 4) + ToHexChar(color.G & 0xF)
- + ToHexChar(color.B >> 4) + ToHexChar(color.B & 0xF);
-
- if (color.A != 255)
- result = result + ToHexChar(color.A >> 4) + ToHexChar(color.A & 0xF);
-
- return result;
- }
-
- static char ToHexChar(int b) => (char)(b < 10 ? b + '0' : b - 10 + 'a');
-}
diff --git a/src/Hyphen.Sdk/Extensions/HyphenSdkDateTimeOffsetExtensions.cs b/src/Hyphen.Sdk/Extensions/HyphenSdkDateTimeOffsetExtensions.cs
deleted file mode 100644
index ff80f0a..0000000
--- a/src/Hyphen.Sdk/Extensions/HyphenSdkDateTimeOffsetExtensions.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System.Globalization;
-
-namespace System;
-
-internal static class HyphenSdkDateTimeOffsetExtensions
-{
- public static string ToISO8601(this DateTimeOffset dateTime) =>
- dateTime.ToString(@"yyyy-MM-ddTHH\:mm\:ss.fff\Z", CultureInfo.InvariantCulture);
-}
diff --git a/src/Hyphen.Sdk/Extensions/HyphenSdkEnumExtensions.cs b/src/Hyphen.Sdk/Extensions/HyphenSdkEnumExtensions.cs
deleted file mode 100644
index 13a3fe2..0000000
--- a/src/Hyphen.Sdk/Extensions/HyphenSdkEnumExtensions.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Hyphen.Sdk;
-
-internal static class HyphenSdkEnumExtensions
-{
- public static string ToFormString(this QrCodeSize size) =>
- size switch
- {
- QrCodeSize.Small => "small",
- QrCodeSize.Medium => "medium",
- QrCodeSize.Large => "large",
- _ => throw new ArgumentException("Unknown QrCodeSize value: " + size.ToString()),
- };
-}
diff --git a/src/Hyphen.Sdk/Extensions/HyphenSdkEnvExtensions.cs b/src/Hyphen.Sdk/Extensions/HyphenSdkEnvExtensions.cs
index 7365227..4d5ea1f 100644
--- a/src/Hyphen.Sdk/Extensions/HyphenSdkEnvExtensions.cs
+++ b/src/Hyphen.Sdk/Extensions/HyphenSdkEnvExtensions.cs
@@ -32,8 +32,8 @@ public static class HyphenSdkEnvExtensions
///
///
/// The environment variable name
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -56,8 +56,8 @@ public static class HyphenSdkEnvExtensions
///
/// The environment variable name
/// An object that supplies culture-specific parsing information.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -80,8 +80,8 @@ public static class HyphenSdkEnvExtensions
///
/// The environment variable name
/// A bitwise combination of enumeration values that indicates the permitted format.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -102,8 +102,8 @@ public static class HyphenSdkEnvExtensions
///
///
/// The environment variable name
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -126,8 +126,8 @@ public static class HyphenSdkEnvExtensions
///
/// The environment variable name
/// An object that supplies culture-specific parsing information.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -150,8 +150,8 @@ public static class HyphenSdkEnvExtensions
///
/// The environment variable name
/// A bitwise combination of enumeration values that indicates the permitted format.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -172,8 +172,8 @@ public static class HyphenSdkEnvExtensions
///
///
/// The environment variable name
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -196,8 +196,8 @@ public static class HyphenSdkEnvExtensions
///
/// The environment variable name
/// An object that supplies culture-specific parsing information.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -220,8 +220,8 @@ public static class HyphenSdkEnvExtensions
///
/// The environment variable name
/// A bitwise combination of enumeration values that indicates the permitted format.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -242,8 +242,8 @@ public static class HyphenSdkEnvExtensions
///
///
/// The environment variable name
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -266,8 +266,8 @@ public static class HyphenSdkEnvExtensions
///
/// The environment variable name
/// An object that supplies culture-specific parsing information.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
@@ -290,8 +290,8 @@ public static class HyphenSdkEnvExtensions
///
/// The environment variable name
/// A bitwise combination of enumeration values that indicates the permitted format.
- /// When true and the variable does not exist (or is in the wrong
- /// format), will throw; when false, will return null instead.
+ /// When and the variable does not exist (or is in the wrong
+ /// format), will throw; when , will return instead.
/// The value
/// Thrown when is true
/// and the variable does not exist (or is in the wrong format).
diff --git a/src/Hyphen.Sdk/Extensions/HyphenSdkHttpClientExtensions.cs b/src/Hyphen.Sdk/Extensions/HyphenSdkHttpClientExtensions.cs
deleted file mode 100644
index 4950b01..0000000
--- a/src/Hyphen.Sdk/Extensions/HyphenSdkHttpClientExtensions.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace System.Net.Http;
-
-internal static class HyphenSdkHttpClientExtensions
-{
- public static void SetHyphenApiKey(this HttpClient client, string apiKey) =>
- client.DefaultRequestHeaders.Add("x-api-key", apiKey);
-}
diff --git a/src/Hyphen.Sdk/Extensions/HyphenSdkLinkExtensions.cs b/src/Hyphen.Sdk/Extensions/HyphenSdkLinkExtensions.cs
index ffb059d..2988847 100644
--- a/src/Hyphen.Sdk/Extensions/HyphenSdkLinkExtensions.cs
+++ b/src/Hyphen.Sdk/Extensions/HyphenSdkLinkExtensions.cs
@@ -114,7 +114,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
///
/// The short code ID. (Example: "code_686bed403c3991bd676bba4d")
/// The QR code ID. (Example: "lqr_66fc51fe144cf3a1bd2a35b1")
- /// Returns the QR code, if present, returns default for an unknown short code ID
+ /// Returns the QR code, if present, returns for an unknown short code ID
/// or QR code ID or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
@@ -126,7 +126,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
///
///
/// The short code ID. (Example: "code_686bed403c3991bd676bba4d")
- /// The list of QR codes that match the search options; returns null for an unknown
+ /// The list of QR codes that match the search options; returns for an unknown
/// short code ID or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
@@ -139,7 +139,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
///
/// The short code ID. (Example: "code_686bed403c3991bd676bba4d")
/// The cancellation token to cancel the request early
- /// The list of QR codes that match the search options; returns null for an unknown
+ /// The list of QR codes that match the search options; returns for an unknown
/// short code ID or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
@@ -152,7 +152,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
///
/// The short code ID. (Example: "code_686bed403c3991bd676bba4d")
/// Optional parameters for getting the list of QR codes.
- /// The list of QR codes that match the search options; returns null for an unknown
+ /// The list of QR codes that match the search options; returns for an unknown
/// short code ID or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
@@ -164,7 +164,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
///
///
/// The short code ID. (Example: "code_686bed403c3991bd676bba4d")
- /// Returns the short code, if available; returns null for an unknown code or organization ID.
+ /// Returns the short code, if available; returns for an unknown code or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
public static Task GetShortCode(this ILink link, string shortCodeId) =>
@@ -174,7 +174,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
/// Gets a list of short codes.
///
///
- /// The list of short codes that match the search options; returns null for an unknown organization ID.
+ /// The list of short codes that match the search options; returns for an unknown organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
public static Task?> GetShortCodes(this ILink link) =>
@@ -185,7 +185,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
///
///
/// The cancellation token to cancel the request early
- /// The list of short codes that match the search options; returns null for an unknown organization ID.
+ /// The list of short codes that match the search options; returns for an unknown organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
public static Task?> GetShortCodes(this ILink link, CancellationToken cancellationToken) =>
@@ -196,7 +196,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
///
///
/// Optional parameters for getting the list of short codes.
- /// The list of short codes that match the search options; returns null for an unknown organization ID.
+ /// The list of short codes that match the search options; returns for an unknown organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
public static Task?> GetShortCodes(this ILink link, GetShortCodesParams? parms) =>
@@ -209,7 +209,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
/// The short code ID. (Example: "code_686bed403c3991bd676bba4d")
/// The start date.
/// The end date.
- /// The statistics for the given short code, if present; returns null
+ /// The statistics for the given short code, if present; returns
/// for an unknown short code ID or organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
@@ -220,7 +220,7 @@ public static Task DeleteShortCode(this ILink link, string shortCodeId) =>
/// Gets a list of all the tags used by the organization's short codes.
///
///
- /// The combined list of tags, if present; returns null for an unknown organization ID.
+ /// The combined list of tags, if present; returns for an unknown organization ID.
/// Thrown if the API key is not valid.
/// Thrown if the API returned an unexpected status code.
public static Task GetTags(this ILink link) =>
diff --git a/src/Hyphen.Sdk/Extensions/HyphenSdkPolyfills.cs b/src/Hyphen.Sdk/Extensions/HyphenSdkPolyfills.cs
new file mode 100644
index 0000000..62cdc1a
--- /dev/null
+++ b/src/Hyphen.Sdk/Extensions/HyphenSdkPolyfills.cs
@@ -0,0 +1,85 @@
+using System.Drawing;
+using System.Globalization;
+using Hyphen.Sdk;
+
+namespace System;
+
+internal static class HyphenSdkPolyfills
+{
+ extension(Color color)
+ {
+ public string ToCss()
+ {
+ var result = "#"
+ + ToHexChar(color.R >> 4) + ToHexChar(color.R & 0xF)
+ + ToHexChar(color.G >> 4) + ToHexChar(color.G & 0xF)
+ + ToHexChar(color.B >> 4) + ToHexChar(color.B & 0xF);
+
+ if (color.A != 255)
+ result = result + ToHexChar(color.A >> 4) + ToHexChar(color.A & 0xF);
+
+ return result;
+ }
+ }
+
+ extension(DateTimeOffset dateTimeOffset)
+ {
+ public string ToISO8601() =>
+ dateTimeOffset.ToString(@"yyyy-MM-ddTHH\:mm\:ss.fff\Z", CultureInfo.InvariantCulture);
+ }
+
+ extension(File)
+ {
+#if NETSTANDARD
+ public static Task WriteAllBytesAsync(string path, byte[] bytes, CancellationToken cancellationToken)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ File.WriteAllBytes(path, bytes);
+ return Task.CompletedTask;
+ }
+#endif
+ }
+
+ extension(HttpClient client)
+ {
+ public void SetHyphenApiKey(string apiKey) =>
+ client.DefaultRequestHeaders.Add("x-api-key", apiKey);
+ }
+
+ extension(QrCodeSize size)
+ {
+ public string ToFormString() =>
+ size switch
+ {
+ QrCodeSize.Small => "small",
+ QrCodeSize.Medium => "medium",
+ QrCodeSize.Large => "large",
+ _ => throw new ArgumentException("Unknown QrCodeSize value: " + size.ToString()),
+ };
+ }
+
+ extension(string str)
+ {
+#if NETSTANDARD
+ public bool EndsWith(char value) => str.Length != 0 && str[str.Length - 1] == value;
+#endif
+
+ public string ReplaceInvariant(string oldValue, string newValue)
+#if NETSTANDARD
+ => str.Replace(oldValue, newValue);
+#else
+ => str.Replace(oldValue, newValue, StringComparison.InvariantCulture);
+#endif
+
+#if NETSTANDARD
+ public bool StartsWith(char value) => str.Length != 0 && str[0] == value;
+#endif
+ }
+
+ extension(string? str)
+ {
+ public string Quoted => str is null ? "null" : $@"""{str}""";
+ }
+
+ static char ToHexChar(int b) => (char)(b < 10 ? b + '0' : b - 10 + 'a');
+}
diff --git a/src/Hyphen.Sdk/Extensions/HyphenSdkResourcesExtensions.cs b/src/Hyphen.Sdk/Extensions/HyphenSdkResourcesExtensions.cs
index 887d8d5..1158e9f 100644
--- a/src/Hyphen.Sdk/Extensions/HyphenSdkResourcesExtensions.cs
+++ b/src/Hyphen.Sdk/Extensions/HyphenSdkResourcesExtensions.cs
@@ -26,7 +26,7 @@ public static string Env_InvalidValue(string name, string? value) =>
env_InvalidValueComposite,
#endif
name,
- value.Quoted()
+ value.Quoted
);
public static string Env_InvalidValueType(string name, string typeName, string? value) =>
@@ -39,7 +39,7 @@ public static string Env_InvalidValueType(string name, string typeName, string?
#endif
name,
typeName,
- value.Quoted()
+ value.Quoted
);
public static string Http_StatusCodeError(HttpStatusCode statusCode) =>
diff --git a/src/Hyphen.Sdk/Extensions/HyphenSdkStringExtensions.cs b/src/Hyphen.Sdk/Extensions/HyphenSdkStringExtensions.cs
deleted file mode 100644
index 7a86562..0000000
--- a/src/Hyphen.Sdk/Extensions/HyphenSdkStringExtensions.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace System;
-
-internal static class HyphenSdkStringExtensions
-{
-#if NETSTANDARD
- public static bool EndsWith(this string str, char value)
- => str.Length != 0 && str[str.Length - 1] == value;
-#endif
-
- public static string Quoted(this string? str) =>
- str is null ? "null" : $@"""{str}""";
-
- public static string ReplaceInvariant(this string str, string oldValue, string newValue)
-#if NETSTANDARD
- => str.Replace(oldValue, newValue);
-#else
- => str.Replace(oldValue, newValue, StringComparison.InvariantCulture);
-#endif
-
-#if NETSTANDARD
- public static bool StartsWith(this string str, char value)
- => str.Length != 0 && str[0] == value;
-#endif
-}
diff --git a/src/Hyphen.Sdk/Options/EnvOptions.cs b/src/Hyphen.Sdk/Options/EnvOptions.cs
index 45dd80d..75c69ea 100644
--- a/src/Hyphen.Sdk/Options/EnvOptions.cs
+++ b/src/Hyphen.Sdk/Options/EnvOptions.cs
@@ -25,7 +25,7 @@ public class EnvOptions
/// set) to be loaded.
///
///
- /// If this value remains unset, then true will be used.
+ /// If this value remains unset, then will be used.
///
public bool? Local { get; set; } = true;
diff --git a/src/Hyphen.Sdk/Services/Env.cs b/src/Hyphen.Sdk/Services/Env.cs
index 566a447..1bdabf2 100644
--- a/src/Hyphen.Sdk/Services/Env.cs
+++ b/src/Hyphen.Sdk/Services/Env.cs
@@ -218,7 +218,7 @@ void ParseEnvFile(string path)
if (required)
throw new ArgumentException(HyphenSdkResources.Env_InvalidValueType(name, typeName, value), nameof(name));
- Logger.LogWarning(HyphenSdkResources.Env_InvalidValueTypeFmt, name, typeName, value.Quoted());
+ Logger.LogWarning(HyphenSdkResources.Env_InvalidValueTypeFmt, name, typeName, value.Quoted);
return null;
}
diff --git a/src/Hyphen.Sdk/Services/Link.cs b/src/Hyphen.Sdk/Services/Link.cs
index 7d8bdf9..07f52eb 100644
--- a/src/Hyphen.Sdk/Services/Link.cs
+++ b/src/Hyphen.Sdk/Services/Link.cs
@@ -1,4 +1,3 @@
-using System.Drawing;
using System.Net;
using System.Net.Http.Headers;
using System.Net.Http.Json;
diff --git a/src/Hyphen.Sdk/Types/Exceptions/NotFoundException.cs b/src/Hyphen.Sdk/Types/Exceptions/NotFoundException.cs
index e60c591..2f01ca8 100644
--- a/src/Hyphen.Sdk/Types/Exceptions/NotFoundException.cs
+++ b/src/Hyphen.Sdk/Types/Exceptions/NotFoundException.cs
@@ -5,7 +5,7 @@ namespace Hyphen.Sdk;
///
///
/// This exception will only be thrown for update operations like POST, PUT, or PATCH.
-/// GET operations which result in a 404 will typically return null values.
+/// GET operations which result in a 404 will typically return values.
/// DELETE operations which result in a 404 will typically be silently ignored.
///
/// The error message that explains the reason for the exception.
diff --git a/src/Hyphen.Sdk/Types/Link/QrCodeResult.cs b/src/Hyphen.Sdk/Types/Link/QrCodeResult.cs
index 2c52ae5..895fb09 100644
--- a/src/Hyphen.Sdk/Types/Link/QrCodeResult.cs
+++ b/src/Hyphen.Sdk/Types/Link/QrCodeResult.cs
@@ -75,14 +75,6 @@ public Task SaveQrCode(string fileName) =>
/// The QR code images are in PNG format, so it is recommended that the file name end with ".png".
///
[ExcludeFromCodeCoverage] // Not testing due to file I/O (and simple implementation)
- public Task SaveQrCode(string fileName, CancellationToken cancellationToken)
- {
-#if NETSTANDARD
- cancellationToken.ThrowIfCancellationRequested();
- File.WriteAllBytes(fileName, GetQrCodeBytes());
- return Task.CompletedTask;
-#else
- return File.WriteAllBytesAsync(fileName, GetQrCodeBytes(), cancellationToken);
-#endif
- }
+ public Task SaveQrCode(string fileName, CancellationToken cancellationToken) =>
+ File.WriteAllBytesAsync(fileName, GetQrCodeBytes(), cancellationToken);
}
diff --git a/test/Hyphen.Sdk.Tests/Services/EnvTests.cs b/test/Hyphen.Sdk.Tests/Services/EnvTests.cs
index f8ef4b9..3718438 100644
--- a/test/Hyphen.Sdk.Tests/Services/EnvTests.cs
+++ b/test/Hyphen.Sdk.Tests/Services/EnvTests.cs
@@ -120,7 +120,7 @@ a back quoted
Assert.Empty(logger.Messages);
Assert.Collection(
- helper.SetEnvValues.OrderBy(kvp => kvp.Key).Select(kvp => $"{kvp.Key} = {kvp.Value.Quoted()}"),
+ helper.SetEnvValues.OrderBy(kvp => kvp.Key).Select(kvp => $"{kvp.Key} = {kvp.Value.Quoted}"),
item => Assert.Equal(@"BACK_QUOTED = ""Value""", item),
item => Assert.Equal(@"BACK_QUOTED_ALT = ""Value# not a comment""", item),
item => Assert.Equal(@"BACK_QUOTED_JSON = ""{ ""foo"": ""2112"" }""", item),
@@ -174,7 +174,7 @@ public void LocalOverrides()
Assert.Empty(logger.Messages);
Assert.Collection(
- helper.SetEnvValues.OrderBy(kvp => kvp.Key).Select(kvp => $"{kvp.Key} = {kvp.Value.Quoted()}"),
+ helper.SetEnvValues.OrderBy(kvp => kvp.Key).Select(kvp => $"{kvp.Key} = {kvp.Value.Quoted}"),
item => Assert.Equal(@"GLOBAL = ""bar""", item),
item => Assert.Equal(@"LOCAL = ""biff""", item),
item => Assert.Equal(@"OVERRIDE = ""baz""", item)
@@ -208,7 +208,7 @@ public void EnvironmentOverrides()
Assert.Empty(logger.Messages);
Assert.Collection(
- helper.SetEnvValues.OrderBy(kvp => kvp.Key).Select(kvp => $"{kvp.Key} = {kvp.Value.Quoted()}"),
+ helper.SetEnvValues.OrderBy(kvp => kvp.Key).Select(kvp => $"{kvp.Key} = {kvp.Value.Quoted}"),
item => Assert.Equal(@"NAME1 = ""global""", item),
item => Assert.Equal(@"NAME2 = ""local""", item),
item => Assert.Equal(@"NAME3 = ""environment""", item),