From 55ce08abf9831b225dae3016ab022203a01b0ab7 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 9 Jul 2026 20:31:07 -0700 Subject: [PATCH 1/2] Rename namespace and package to ptr727.Utilities (#384) Fold the namespace/package rename into the breaking 3.7 release, aligning with the ptr727.* style of the sibling LanguageTags project. - Rename InsaneGenius.Utilities -> ptr727.Utilities (namespace, PackageId, RootNamespace); bare AssemblyName (Utilities / UtilitiesTests) and InternalsVisibleTo (breaking). - Move localized library suppressions (CA1024/CA1034/CA1054/CA5394) to symbol-scoped [SuppressMessage] attributes; drop dead test suppressions (CA1307/CA2007) and the unused IClassFixture fixture (CA1823/IDE0052/CA1063). - Make Format.BytesToKibi/BytesToKilo culture-invariant. - Derive the HttpClient User-Agent from the consuming application (AOT-safe), always setting a header. - Add GlobalUsings.cs per project; document both breaking 3.7 changes (namespace and logging) in README and HISTORY. --- AGENTS.md | 4 +- HISTORY.md | 1 + README.md | 12 +++--- Sandbox/GlobalUsings.cs | 1 + Sandbox/LoggerFactory.cs | 3 +- Sandbox/Program.cs | 5 +-- Sandbox/Sandbox.csproj | 2 +- Utilities/.editorconfig | 14 ++----- Utilities/CommandLineEx.cs | 2 +- Utilities/ConsoleEx.cs | 2 +- Utilities/Download.cs | 42 +++++++++++++++---- Utilities/Extensions.cs | 8 +++- Utilities/FileEx.cs | 13 +++++- Utilities/FileExOptions.cs | 2 +- Utilities/Format.cs | 14 ++++--- Utilities/GlobalUsings.cs | 1 + Utilities/LogOptions.cs | 3 +- Utilities/StringCompression.cs | 2 +- Utilities/StringHistory.cs | 2 +- Utilities/Utilities.csproj | 8 ++-- UtilitiesTests/.editorconfig | 12 ------ UtilitiesTests/CommandLineTests.cs | 8 +--- UtilitiesTests/ConsoleTests.cs | 8 +--- UtilitiesTests/DownloadAsyncTests.cs | 8 +--- UtilitiesTests/DownloadTests.cs | 8 +--- UtilitiesTests/ExtensionsTests.cs | 7 +--- UtilitiesTests/FileExAsyncTests.cs | 8 +--- UtilitiesTests/FileTests.cs | 7 +--- UtilitiesTests/FormatTests.cs | 8 +--- UtilitiesTests/GlobalUsings.cs | 1 + UtilitiesTests/LogOptionsTests.cs | 3 +- UtilitiesTests/StringCompressionAsyncTests.cs | 7 +--- UtilitiesTests/StringCompressionTests.cs | 8 +--- UtilitiesTests/StringHistoryTests.cs | 8 +--- UtilitiesTests/UtilitiesTests.cs | 6 --- UtilitiesTests/UtilitiesTests.csproj | 6 +-- codecov.yml | 4 +- 37 files changed, 119 insertions(+), 139 deletions(-) create mode 100644 Sandbox/GlobalUsings.cs create mode 100644 Utilities/GlobalUsings.cs delete mode 100644 UtilitiesTests/UtilitiesTests.cs diff --git a/AGENTS.md b/AGENTS.md index 66feba5..dfab58b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # Instructions for AI Coding Agents -**Utilities** is a C# .NET library of general-purpose utility classes, published as the NuGet package `InsaneGenius.Utilities` and consumed directly from `main`. The library ships under [`Utilities/`](./Utilities/), with a `Sandbox/` console app for experimentation and an xUnit test project (`UtilitiesTests/`). +**Utilities** is a C# .NET library of general-purpose utility classes, published as the NuGet package `ptr727.Utilities` and consumed directly from `main`. The library ships under [`Utilities/`](./Utilities/), with a `Sandbox/` console app for experimentation and an xUnit test project (`UtilitiesTests/`). This file is the canonical reference for cross-cutting AI-agent rules. The CI/CD workflow contract and conventions live in [`WORKFLOW.md`](./WORKFLOW.md); C# code-style conventions live in [`CODESTYLE.md`](./CODESTYLE.md). Copilot review *mechanics* are owned by [`.github/copilot-instructions.md`](./.github/copilot-instructions.md) - this file delegates them there explicitly (see "PR Review Etiquette" below). High-level summaries in other docs (e.g. README's Contributing section) are allowed when they link back here; don't duplicate the rules themselves. The library's **project-specific conventions and public-API/behavioral contracts** also live here (the [Library API Conventions](#library-api-conventions) section), **not** in `.github/copilot-instructions.md` - that file targets GitHub Copilot / VS Code specifically, while this file is the agent-agnostic one every coding agent reads, so any rule a reviewer must honor has to live here to be provider-independent. @@ -173,7 +173,7 @@ The conventions for everything under `.github/workflows/` - action pinning, file ## Project Structure - **Utilities** (`Utilities/Utilities.csproj`) - - Core library project, published as NuGet `InsaneGenius.Utilities`. Target framework: .NET 10.0. + - Core library project, published as NuGet `ptr727.Utilities`. Target framework: .NET 10.0. - **Sandbox** (`Sandbox/Sandbox.csproj`) - Console app for experimentation; not packaged or published. - **UtilitiesTests** (`UtilitiesTests/UtilitiesTests.csproj`) diff --git a/HISTORY.md b/HISTORY.md index 6131598..ddf89b0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,6 +5,7 @@ Some useful and not so useful C# .NET utility classes. ## Release History - v3.7: + - Renamed the NuGet package and root namespace from `InsaneGenius.Utilities` to `ptr727.Utilities` (a breaking change), aligning with the `ptr727.*` package naming used by the sibling `LanguageTags` project; consumers must update their package reference and change `using InsaneGenius.Utilities;` directives to `using ptr727.Utilities;`. The assembly is now named `Utilities`. - Replaced the Serilog-coupled logging model with the backend-agnostic `Microsoft.Extensions.Logging` abstraction, matching the sibling `LanguageTags` project. - Removed the global Serilog `LogOptions.Logger` property (a breaking API change) in favor of a thread-safe, injectable `ILoggerFactory` configured via `LogOptions.SetFactory(...)` / `TrySetFactory(...)`; the library now depends only on `Microsoft.Extensions.Logging.Abstractions`. - Reworked `FileEx` and `Download` to resolve per-class cached loggers through `LogOptions.CreateLogger(...)` and to emit source-generated `[LoggerMessage]` messages, keeping the build clean under `AnalysisMode=All` and `TreatWarningsAsErrors`. diff --git a/README.md b/README.md index 0f28263..99deb1b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ Some useful and not so useful C# .NET utility classes. **Summary**: -- Adopted an injectable `Microsoft.Extensions.Logging` logging model. +- Renamed the NuGet package and namespace from `InsaneGenius.Utilities` to `ptr727.Utilities` (breaking). + - Update your package reference to `ptr727.Utilities` and change `using InsaneGenius.Utilities;` to `using ptr727.Utilities;`. +- Adopted an injectable `Microsoft.Extensions.Logging` logging model (breaking). - Configure logging with `LogOptions.SetFactory(ILoggerFactory)` instead of the removed Serilog-typed `LogOptions.Logger` property. - The library now depends on `Microsoft.Extensions.Logging.Abstractions` and is backend-agnostic; the `Sandbox` shows Serilog console wiring. @@ -35,12 +37,12 @@ See [Release History](./HISTORY.md) for complete release notes and older version ```shell # Add the package to your project -dotnet add package InsaneGenius.Utilities +dotnet add package ptr727.Utilities ``` ```csharp // Include the namespace -using InsaneGenius.Utilities; +using ptr727.Utilities; ``` ## Contributing @@ -69,8 +71,8 @@ Licensed under the [MIT License][license-link]\ [lastcommit-shield]: https://img.shields.io/github/last-commit/ptr727/Utilities?logo=github&label=Last%20Commit [license-link]: ./LICENSE [license-shield]: https://img.shields.io/github/license/ptr727/Utilities?label=License -[nuget-link]: https://www.nuget.org/packages/InsaneGenius.Utilities/ -[nugetreleaseversion-shield]: https://img.shields.io/nuget/v/InsaneGenius.Utilities?logo=nuget&label=NuGet%20Release +[nuget-link]: https://www.nuget.org/packages/ptr727.Utilities/ +[nugetreleaseversion-shield]: https://img.shields.io/nuget/v/ptr727.Utilities?logo=nuget&label=NuGet%20Release [prereleaseversion-shield]: https://img.shields.io/github/v/release/ptr727/Utilities?include_prereleases&filter=*-g*&label=GitHub%20Pre-Release&logo=github [releasebuildstatus-shield]: https://img.shields.io/github/actions/workflow/status/ptr727/Utilities/publish-release.yml?logo=github&label=Releases%20Build [releases-link]: https://github.com/ptr727/Utilities/releases diff --git a/Sandbox/GlobalUsings.cs b/Sandbox/GlobalUsings.cs new file mode 100644 index 0000000..5100741 --- /dev/null +++ b/Sandbox/GlobalUsings.cs @@ -0,0 +1 @@ +global using Serilog; diff --git a/Sandbox/LoggerFactory.cs b/Sandbox/LoggerFactory.cs index 7bebd64..e132113 100644 --- a/Sandbox/LoggerFactory.cs +++ b/Sandbox/LoggerFactory.cs @@ -1,9 +1,8 @@ using System.Globalization; -using Serilog; using Serilog.Extensions.Logging; using Serilog.Sinks.SystemConsole.Themes; -namespace InsaneGenius.Utilities.Sandbox; +namespace ptr727.Utilities.Sandbox; /// /// Configures a Serilog console logger and exposes it as a diff --git a/Sandbox/Program.cs b/Sandbox/Program.cs index 5d32cf1..043de8b 100644 --- a/Sandbox/Program.cs +++ b/Sandbox/Program.cs @@ -1,8 +1,7 @@ using System.Diagnostics; using System.Reflection; -using InsaneGenius.Utilities; -using InsaneGenius.Utilities.Sandbox; -using Serilog; +using ptr727.Utilities; +using ptr727.Utilities.Sandbox; // Configure logging: build a Serilog console logger and inject it into the library. Log.Logger = LoggerFactory.Create(); diff --git a/Sandbox/Sandbox.csproj b/Sandbox/Sandbox.csproj index db9ae56..18006dc 100644 --- a/Sandbox/Sandbox.csproj +++ b/Sandbox/Sandbox.csproj @@ -1,7 +1,7 @@ Exe - InsaneGenius.Utilities.Sandbox + ptr727.Utilities.Sandbox true false true diff --git a/Utilities/.editorconfig b/Utilities/.editorconfig index 0ab9e9a..3f7e6ab 100644 --- a/Utilities/.editorconfig +++ b/Utilities/.editorconfig @@ -8,20 +8,14 @@ dotnet_diagnostic.CA1711.severity = none # Library-scoped analyzer exceptions. Each is a deliberate, documented decision # for this published library, not a brownfield blanket-relax (see CODESTYLE.md -# "Analyzer Diagnostics and Suppressions"). -# CA1002: the published InsaneGenius.Utilities surface intentionally exposes +# "Analyzer Diagnostics and Suppressions"). Localized single-symbol exceptions +# (CA1024, CA1034, CA1054, CA5394) are suppressed with [SuppressMessage] +# attributes at the specific symbol instead of here. +# CA1002: the published ptr727.Utilities surface intentionally exposes # List (FileEx.EnumerateDirectory, StringHistory.StringList); changing to # Collection is a breaking API change. dotnet_diagnostic.CA1002.severity = suggestion -# CA1024: Download.GetHttpClient() is intentionally a method, not a property. -dotnet_diagnostic.CA1024.severity = suggestion -# CA1034: nested types generated by the C# extension members in Extensions.cs. -dotnet_diagnostic.CA1034.severity = suggestion -# CA1054: Download URL parameters are intentionally string, not System.Uri. -dotnet_diagnostic.CA1054.severity = suggestion # CA2007: await using / await foreach disposal sites; the awaited async calls # already use ConfigureAwait(false) and a ConfiguredAsyncDisposable rewrite # hurts readability. dotnet_diagnostic.CA2007.severity = suggestion -# CA5394: Random is used for retry jitter and temp-name generation, not security. -dotnet_diagnostic.CA5394.severity = suggestion diff --git a/Utilities/CommandLineEx.cs b/Utilities/CommandLineEx.cs index 5a2fd1d..560c72b 100644 --- a/Utilities/CommandLineEx.cs +++ b/Utilities/CommandLineEx.cs @@ -1,4 +1,4 @@ -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; /// /// Provides command-line argument parsing utilities. diff --git a/Utilities/ConsoleEx.cs b/Utilities/ConsoleEx.cs index 1471259..3c9cede 100644 --- a/Utilities/ConsoleEx.cs +++ b/Utilities/ConsoleEx.cs @@ -1,6 +1,6 @@ using System.Globalization; -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; /// /// Provides enhanced console output utilities with color and timestamp support. diff --git a/Utilities/Download.cs b/Utilities/Download.cs index b910702..3e7d549 100644 --- a/Utilities/Download.cs +++ b/Utilities/Download.cs @@ -1,8 +1,7 @@ using System.Net.Http.Headers; using System.Reflection; -using Microsoft.Extensions.Logging; -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; /// /// Provides HTTP download utilities for files and strings. @@ -201,6 +200,11 @@ public static bool DownloadString(Uri uri, out string value) /// Gets the shared HttpClient instance. /// /// The HttpClient instance. + [System.Diagnostics.CodeAnalysis.SuppressMessage( + "Design", + "CA1024:Use properties where appropriate", + Justification = "Exposed as a method so callers see they receive the shared, lazily-initialized HttpClient rather than a lightweight property value." + )] public static HttpClient GetHttpClient() => s_httpClient.Value; /// @@ -211,6 +215,11 @@ public static bool DownloadString(Uri uri, out string value) /// The password (optional). /// The constructed URI. /// Thrown when is null. + [System.Diagnostics.CodeAnalysis.SuppressMessage( + "Design", + "CA1054:URI parameters should not be strings", + Justification = "The url parameter is intentionally a string; CreateUri builds the Uri from raw string input supplied by callers." + )] public static Uri CreateUri(string url, string? userName = null, string? password = null) { ArgumentNullException.ThrowIfNull(url); @@ -233,13 +242,30 @@ private static HttpClient CreateHttpClient() { HttpClient client = new() { Timeout = TimeSpan.FromSeconds(TimeoutSeconds) }; - Assembly assembly = Assembly.GetExecutingAssembly(); - string productName = assembly.GetName().Name ?? "InsaneGenius.Utilities"; - string productVersion = assembly.GetName().Version?.ToString() ?? "1.0.0"; + // Identify the consuming application (the caller), never this library. Assembly-to-file + // metadata is unreliable under NativeAOT, so try the managed entry assembly name, then + // the OS-level process executable name, then a generic value. + Assembly? entryAssembly = Assembly.GetEntryAssembly(); + string? processPath = Environment.ProcessPath; + string? processName = string.IsNullOrEmpty(processPath) + ? null + : Path.GetFileNameWithoutExtension(processPath); + string productName = entryAssembly?.GetName().Name ?? processName ?? "Unknown"; + string productVersion = entryAssembly?.GetName().Version?.ToString() ?? "1.0.0"; - client.DefaultRequestHeaders.UserAgent.Add( - new ProductInfoHeaderValue(productName, productVersion) - ); + // The derived name may not be a valid HTTP token (e.g. a process name with spaces); + // fall back to a guaranteed-valid token so a User-Agent is always set. + if ( + !ProductInfoHeaderValue.TryParse( + $"{productName}/{productVersion}", + out ProductInfoHeaderValue? userAgent + ) + ) + { + userAgent = new ProductInfoHeaderValue("Unknown", productVersion); + } + + client.DefaultRequestHeaders.UserAgent.Add(userAgent); return client; } diff --git a/Utilities/Extensions.cs b/Utilities/Extensions.cs index c001e77..7cec63c 100644 --- a/Utilities/Extensions.cs +++ b/Utilities/Extensions.cs @@ -1,12 +1,16 @@ using System.IO.Compression; using System.Runtime.CompilerServices; -using Microsoft.Extensions.Logging; -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; /// /// Provides extension methods for string compression. /// +[System.Diagnostics.CodeAnalysis.SuppressMessage( + "Design", + "CA1034:Nested types should not be visible", + Justification = "The visible nested type is generated by the C# extension members feature; https://github.com/dotnet/sdk/issues/51681" +)] public static class CompressExtensions { /// diff --git a/Utilities/FileEx.cs b/Utilities/FileEx.cs index 668e9a0..8bea69b 100644 --- a/Utilities/FileEx.cs +++ b/Utilities/FileEx.cs @@ -1,9 +1,8 @@ using System.Runtime.InteropServices; using System.Security.AccessControl; using System.Security.Principal; -using Microsoft.Extensions.Logging; -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; /// /// Provides extended file and directory operation utilities with retry logic and cancellation support. @@ -1097,6 +1096,11 @@ public static string TimeStampFileName(string filePath, DateTime timeStamp) /// The file path to create. /// The size of the file in bytes. /// True if successful, false otherwise. + [System.Diagnostics.CodeAnalysis.SuppressMessage( + "Security", + "CA5394:Do not use insecure randomness", + Justification = "Random fills the file with non-cryptographic placeholder data, not security-sensitive values." + )] public static bool CreateRandomFilledFile(string name, long size) { try @@ -1149,6 +1153,11 @@ public static bool CreateRandomFilledFile(string name, long size) /// The size of the file in bytes. /// The cancellation token. /// True if successful, false otherwise. + [System.Diagnostics.CodeAnalysis.SuppressMessage( + "Security", + "CA5394:Do not use insecure randomness", + Justification = "Random fills the file with non-cryptographic placeholder data, not security-sensitive values." + )] public static async Task CreateRandomFilledFileAsync( string name, long size, diff --git a/Utilities/FileExOptions.cs b/Utilities/FileExOptions.cs index fb15492..25d7132 100644 --- a/Utilities/FileExOptions.cs +++ b/Utilities/FileExOptions.cs @@ -1,4 +1,4 @@ -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; /// /// Configuration options for FileEx operations. diff --git a/Utilities/Format.cs b/Utilities/Format.cs index 91675fd..de5b395 100644 --- a/Utilities/Format.cs +++ b/Utilities/Format.cs @@ -1,4 +1,4 @@ -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; /// /// Provides formatting utilities for byte sizes and size constants. @@ -70,8 +70,10 @@ public static string BytesToKibi(long value, string units = "B") double fraction = Math.Round(value / Math.Pow(KiB, magnitude), 1); double truncate = Math.Truncate(fraction); return fraction.Equals(truncate) - ? $"{Convert.ToInt64(truncate):D}{s_kibiSuffix[magnitude]}{units}" - : $"{fraction:F}{s_kibiSuffix[magnitude]}{units}"; + ? FormattableString.Invariant( + $"{Convert.ToInt64(truncate):D}{s_kibiSuffix[magnitude]}{units}" + ) + : FormattableString.Invariant($"{fraction:F}{s_kibiSuffix[magnitude]}{units}"); } private static readonly string[] s_kibiSuffix = ["", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei"]; @@ -101,8 +103,10 @@ public static string BytesToKilo(long value, string units = "B") double fraction = Math.Round(value / Math.Pow(KB, magnitude), 1); double truncate = Math.Truncate(fraction); return fraction.Equals(truncate) - ? $"{Convert.ToInt64(truncate):D}{s_kiloSuffix[magnitude]}{units}" - : $"{fraction:F}{s_kiloSuffix[magnitude]}{units}"; + ? FormattableString.Invariant( + $"{Convert.ToInt64(truncate):D}{s_kiloSuffix[magnitude]}{units}" + ) + : FormattableString.Invariant($"{fraction:F}{s_kiloSuffix[magnitude]}{units}"); } private static readonly string[] s_kiloSuffix = ["", "K", "M", "G", "T", "P", "E"]; diff --git a/Utilities/GlobalUsings.cs b/Utilities/GlobalUsings.cs new file mode 100644 index 0000000..9a4100d --- /dev/null +++ b/Utilities/GlobalUsings.cs @@ -0,0 +1 @@ +global using Microsoft.Extensions.Logging; diff --git a/Utilities/LogOptions.cs b/Utilities/LogOptions.cs index da8e2dd..3603693 100644 --- a/Utilities/LogOptions.cs +++ b/Utilities/LogOptions.cs @@ -1,7 +1,6 @@ -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; /// /// Provides global logging configuration for the library. diff --git a/Utilities/StringCompression.cs b/Utilities/StringCompression.cs index fee7f79..daf375a 100644 --- a/Utilities/StringCompression.cs +++ b/Utilities/StringCompression.cs @@ -1,7 +1,7 @@ using System.IO.Compression; using System.Text; -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; // https://stackoverflow.com/questions/7343465/compression-decompression-string-with-c-sharp diff --git a/Utilities/StringHistory.cs b/Utilities/StringHistory.cs index 2b238b8..986e4af 100644 --- a/Utilities/StringHistory.cs +++ b/Utilities/StringHistory.cs @@ -1,4 +1,4 @@ -namespace InsaneGenius.Utilities; +namespace ptr727.Utilities; /// /// Manages a history of strings with configurable limits on the number of first and last lines to retain. diff --git a/Utilities/Utilities.csproj b/Utilities/Utilities.csproj index b2ef063..e85a60e 100644 --- a/Utilities/Utilities.csproj +++ b/Utilities/Utilities.csproj @@ -13,9 +13,9 @@ 1.1.1.1 1.1.1.1 1.1.1.0 - InsaneGenius.Utilities - InsaneGenius.Utilities - InsaneGenius.Utilities + ptr727.Utilities + Utilities + ptr727.Utilities en https://github.com/ptr727/Utilities MIT @@ -30,7 +30,7 @@ - + diff --git a/UtilitiesTests/.editorconfig b/UtilitiesTests/.editorconfig index 4601a6c..f2c538f 100644 --- a/UtilitiesTests/.editorconfig +++ b/UtilitiesTests/.editorconfig @@ -6,27 +6,15 @@ root = false # Allow underscores in test method names dotnet_diagnostic.CA1707.severity = none -# Ignore unused private members -dotnet_diagnostic.IDE0052.severity = none - # Test-scoped analyzer exceptions: rules that target production-code concerns # and don't apply to xUnit test code. Each is documented, not a brownfield # blanket-relax (see CODESTYLE.md "Analyzer Diagnostics and Suppressions"). -# CA1063: test IDisposable implementations are intentionally simple. -dotnet_diagnostic.CA1063.severity = suggestion -# CA1307: test string operations use the default comparison intentionally. -dotnet_diagnostic.CA1307.severity = suggestion # CA1515: xUnit requires public test classes, so they can't be made internal. dotnet_diagnostic.CA1515.severity = suggestion -# CA1823: xUnit fixture fields are injected for lifetime/collection wiring and -# are not always referenced directly. -dotnet_diagnostic.CA1823.severity = suggestion # CA1849: synchronous calls inside async test paths are kept intentionally. dotnet_diagnostic.CA1849.severity = suggestion # CA2000: test disposable ownership is transferred or scoped to the test, so # scope-based disposal analysis reports false positives. dotnet_diagnostic.CA2000.severity = suggestion -# CA2007: ConfigureAwait(false) is not used in xUnit tests (see xUnit1030). -dotnet_diagnostic.CA2007.severity = suggestion # CA5394: Random in tests is for test data, not security. dotnet_diagnostic.CA5394.severity = suggestion diff --git a/UtilitiesTests/CommandLineTests.cs b/UtilitiesTests/CommandLineTests.cs index d56d74b..2bc9bb7 100644 --- a/UtilitiesTests/CommandLineTests.cs +++ b/UtilitiesTests/CommandLineTests.cs @@ -1,11 +1,7 @@ -using Xunit; +namespace ptr727.Utilities.Tests; -namespace InsaneGenius.Utilities.Tests; - -public class CommandLineTests(UtilitiesTests fixture) : IClassFixture +public class CommandLineTests { - private readonly UtilitiesTests _fixture = fixture; - [Fact] public void ParseArguments() { diff --git a/UtilitiesTests/ConsoleTests.cs b/UtilitiesTests/ConsoleTests.cs index 8dc38b0..64a1366 100644 --- a/UtilitiesTests/ConsoleTests.cs +++ b/UtilitiesTests/ConsoleTests.cs @@ -1,11 +1,7 @@ -using Xunit; +namespace ptr727.Utilities.Tests; -namespace InsaneGenius.Utilities.Tests; - -public class ConsoleTests(UtilitiesTests fixture) : IClassFixture +public class ConsoleTests { - private readonly UtilitiesTests _fixture = fixture; - [Fact] public void WriteLineColor_WithValidString_ShouldContainMessage() { diff --git a/UtilitiesTests/DownloadAsyncTests.cs b/UtilitiesTests/DownloadAsyncTests.cs index 66fe65b..7e74294 100644 --- a/UtilitiesTests/DownloadAsyncTests.cs +++ b/UtilitiesTests/DownloadAsyncTests.cs @@ -1,11 +1,7 @@ -using Xunit; +namespace ptr727.Utilities.Tests; -namespace InsaneGenius.Utilities.Tests; - -public class DownloadAsyncTests(UtilitiesTests fixture) : IClassFixture +public class DownloadAsyncTests { - private readonly UtilitiesTests _fixture = fixture; - [Fact] public async Task GetContentInfoAsync_WithValidUri_ShouldReturnSuccess() { diff --git a/UtilitiesTests/DownloadTests.cs b/UtilitiesTests/DownloadTests.cs index c4a310d..5faf73a 100644 --- a/UtilitiesTests/DownloadTests.cs +++ b/UtilitiesTests/DownloadTests.cs @@ -1,11 +1,7 @@ -using Xunit; +namespace ptr727.Utilities.Tests; -namespace InsaneGenius.Utilities.Tests; - -public class DownloadTests(UtilitiesTests fixture) : IClassFixture +public class DownloadTests { - private readonly UtilitiesTests _fixture = fixture; - [Fact] public void GetUriInformation() { diff --git a/UtilitiesTests/ExtensionsTests.cs b/UtilitiesTests/ExtensionsTests.cs index 3786b7c..a11c560 100644 --- a/UtilitiesTests/ExtensionsTests.cs +++ b/UtilitiesTests/ExtensionsTests.cs @@ -1,14 +1,11 @@ using System.IO.Compression; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Xunit; -namespace InsaneGenius.Utilities.Tests; +namespace ptr727.Utilities.Tests; -public class ExtensionsTests(UtilitiesTests fixture) : IClassFixture +public class ExtensionsTests { - private readonly UtilitiesTests _fixture = fixture; - #region String Compression Extension Tests [Fact] diff --git a/UtilitiesTests/FileExAsyncTests.cs b/UtilitiesTests/FileExAsyncTests.cs index 7963bba..0917b7a 100644 --- a/UtilitiesTests/FileExAsyncTests.cs +++ b/UtilitiesTests/FileExAsyncTests.cs @@ -1,11 +1,7 @@ -using Xunit; +namespace ptr727.Utilities.Tests; -namespace InsaneGenius.Utilities.Tests; - -public class FileExAsyncTests(UtilitiesTests fixture) : IClassFixture +public class FileExAsyncTests { - private readonly UtilitiesTests _fixture = fixture; - [Fact] public async Task DeleteFileAsync_WithExistingFile_ShouldReturnTrue() { diff --git a/UtilitiesTests/FileTests.cs b/UtilitiesTests/FileTests.cs index da260fe..fa8f227 100644 --- a/UtilitiesTests/FileTests.cs +++ b/UtilitiesTests/FileTests.cs @@ -1,12 +1,9 @@ using System.Runtime.InteropServices; -using Xunit; -namespace InsaneGenius.Utilities.Tests; +namespace ptr727.Utilities.Tests; -public class FileTests(UtilitiesTests fixture) : IClassFixture +public class FileTests { - private readonly UtilitiesTests _fixture = fixture; - [Theory] [InlineData(@"C:\Path One", @"Path Two", @"C:\Path One\Path Two")] [InlineData(@"C:\Path One\", @"\Path Two", @"C:\Path One\Path Two")] diff --git a/UtilitiesTests/FormatTests.cs b/UtilitiesTests/FormatTests.cs index bd8e2f2..66e4598 100644 --- a/UtilitiesTests/FormatTests.cs +++ b/UtilitiesTests/FormatTests.cs @@ -1,11 +1,7 @@ -using Xunit; +namespace ptr727.Utilities.Tests; -namespace InsaneGenius.Utilities.Tests; - -public class FormatTests(UtilitiesTests fixture) : IClassFixture +public class FormatTests { - private readonly UtilitiesTests _fixture = fixture; - [Theory] [InlineData(0, "0B")] [InlineData(1, "1B")] diff --git a/UtilitiesTests/GlobalUsings.cs b/UtilitiesTests/GlobalUsings.cs index 892cfab..d85913e 100644 --- a/UtilitiesTests/GlobalUsings.cs +++ b/UtilitiesTests/GlobalUsings.cs @@ -1 +1,2 @@ global using AwesomeAssertions; +global using Xunit; diff --git a/UtilitiesTests/LogOptionsTests.cs b/UtilitiesTests/LogOptionsTests.cs index 324f7d1..99c34ca 100644 --- a/UtilitiesTests/LogOptionsTests.cs +++ b/UtilitiesTests/LogOptionsTests.cs @@ -1,8 +1,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Xunit; -namespace InsaneGenius.Utilities.Tests; +namespace ptr727.Utilities.Tests; /// /// Serializes tests that mutate the process-global state. diff --git a/UtilitiesTests/StringCompressionAsyncTests.cs b/UtilitiesTests/StringCompressionAsyncTests.cs index 56c9866..ff73ac1 100644 --- a/UtilitiesTests/StringCompressionAsyncTests.cs +++ b/UtilitiesTests/StringCompressionAsyncTests.cs @@ -1,12 +1,9 @@ using System.IO.Compression; -using Xunit; -namespace InsaneGenius.Utilities.Tests; +namespace ptr727.Utilities.Tests; -public class StringCompressionAsyncTests(UtilitiesTests fixture) : IClassFixture +public class StringCompressionAsyncTests { - private readonly UtilitiesTests _fixture = fixture; - [Fact] public async Task CompressDecompressAsync() { diff --git a/UtilitiesTests/StringCompressionTests.cs b/UtilitiesTests/StringCompressionTests.cs index 69d32b0..f12e23b 100644 --- a/UtilitiesTests/StringCompressionTests.cs +++ b/UtilitiesTests/StringCompressionTests.cs @@ -1,11 +1,7 @@ -using Xunit; +namespace ptr727.Utilities.Tests; -namespace InsaneGenius.Utilities.Tests; - -public class StringCompressionTests(UtilitiesTests fixture) : IClassFixture +public class StringCompressionTests { - private readonly UtilitiesTests _fixture = fixture; - [Fact] public void CompressDecompress() { diff --git a/UtilitiesTests/StringHistoryTests.cs b/UtilitiesTests/StringHistoryTests.cs index 00e08c9..73abbdc 100644 --- a/UtilitiesTests/StringHistoryTests.cs +++ b/UtilitiesTests/StringHistoryTests.cs @@ -1,11 +1,7 @@ -using Xunit; +namespace ptr727.Utilities.Tests; -namespace InsaneGenius.Utilities.Tests; - -public class StringHistoryTests(UtilitiesTests fixture) : IClassFixture +public class StringHistoryTests { - private readonly UtilitiesTests _fixture = fixture; - [Fact] public void Constructor_Default_ShouldInitialize() { diff --git a/UtilitiesTests/UtilitiesTests.cs b/UtilitiesTests/UtilitiesTests.cs deleted file mode 100644 index 4c9fcf6..0000000 --- a/UtilitiesTests/UtilitiesTests.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace InsaneGenius.Utilities.Tests; - -public class UtilitiesTests : IDisposable -{ - public void Dispose() => GC.SuppressFinalize(this); -} diff --git a/UtilitiesTests/UtilitiesTests.csproj b/UtilitiesTests/UtilitiesTests.csproj index 7c31295..6dfd086 100644 --- a/UtilitiesTests/UtilitiesTests.csproj +++ b/UtilitiesTests/UtilitiesTests.csproj @@ -8,9 +8,9 @@ 1.1.0.1 1.1.0.1 1.1.0.0 - InsaneGenius.Utilities.Tests - InsaneGenius.Utilities.Tests - InsaneGenius.Utilities.Tests + ptr727.Utilities.Tests + UtilitiesTests + ptr727.Utilities.Tests en https://dev.azure.com/pieterv/ true diff --git a/codecov.yml b/codecov.yml index f781e07..927bef4 100644 --- a/codecov.yml +++ b/codecov.yml @@ -13,7 +13,7 @@ coverage: default: informational: true -# The Sandbox is an example/demo console app, not the shipped -# InsaneGenius.Utilities library, and is intentionally not unit-tested. +# The Sandbox is an example/demo console app, not the shipped ptr727.Utilities library, +# and is intentionally not unit-tested. ignore: - "Sandbox/**" From 5b38db41c093431a47cbbb2e7de1f9d4669be032 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Thu, 9 Jul 2026 20:49:04 -0700 Subject: [PATCH 2/2] Remove stale PackageProjectUrl from the test project (#386) The non-packable UtilitiesTests project publishes nothing, so its stale Azure DevOps PackageProjectUrl is dead metadata. The library keeps its GitHub PackageProjectUrl. --- UtilitiesTests/UtilitiesTests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/UtilitiesTests/UtilitiesTests.csproj b/UtilitiesTests/UtilitiesTests.csproj index 6dfd086..ab15043 100644 --- a/UtilitiesTests/UtilitiesTests.csproj +++ b/UtilitiesTests/UtilitiesTests.csproj @@ -12,7 +12,6 @@ UtilitiesTests ptr727.Utilities.Tests en - https://dev.azure.com/pieterv/ true true true