Skip to content

Comments

Modernize library: target net8.0/net10.0, modern C# idioms, xUnit v3#121

Merged
niemyjski merged 3 commits intomainfrom
modernize/net8-net10
Feb 20, 2026
Merged

Modernize library: target net8.0/net10.0, modern C# idioms, xUnit v3#121
niemyjski merged 3 commits intomainfrom
modernize/net8-net10

Conversation

@niemyjski
Copy link
Member

Summary

  • Drop netstandard2.0, target net8.0 and net10.0 LTS only
  • Use Random.Shared instead of a static new Random() instance — thread-safe by default
  • Replace RandomNumberGenerator.Create() + disposal with RandomNumberGenerator.Fill() static method
  • Use ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual, ThrowIfLessThan, ThrowIfGreaterThan guard APIs everywhere instead of manual throw statements
  • Add where T : struct, Enum constraint on GetEnum<T>() to eliminate runtime typeof(T).IsEnum check
  • Use Math.Clamp instead of separate Math.Min/Math.Max in GetBool
  • Rewrite UpperCaseFirstCharacter with stackalloc Span<char> for zero-allocation path
  • Convert to file-scoped namespace, collection expressions, expression-bodied members, string interpolation
  • Add nullable annotations to GetVersion parameters and EnumerableExtensions
  • Enable nullable reference types and implicit usings
  • Upgrade build packages: SourceLink 10.0.103, AsyncFixer 2.1.0, MinVer 7.0.0
  • Use dynamic copyright year MSBuild expression: $([System.DateTime]::Now.ToString(yyyy))
  • Upgrade test project to xUnit v3 with Microsoft Testing Platform (xunit.v3.mtp-v2 3.2.2, Foundatio.Xunit.v3 13.0.0-beta3)
  • Add TestingPlatformDotnetTestSupport and new-test-runner: true for CI
  • Restore test parallelization disabling via AssemblyInfo.cs
  • Add codeql-analysis.yml, copilot-setup-steps.yml, global.json, AGENTS.md
  • Update README with comprehensive usage examples (all snippets verified to compile clean)

Public API changes

  • GetEnum<T>(): added where T : struct, Enum constraint — callers passing non-enum type arguments will now get a compile-time error instead of a runtime ArgumentException
  • GetVersion(string, string): parameters are now nullable (string?) — callers passing null now behave consistently with empty string (defaults applied)
  • EnumerableExtensions.Random<T>(): return type is now T? (was T) — callers must handle possible null

Test plan

  • dotnet build Exceptionless.RandomData.slnx --configuration Release — 0 warnings, 0 errors (both net8.0 and net10.0)
  • dotnet run --project test/Exceptionless.RandomData.Tests -f net8.0 — 4 tests pass
  • dotnet run --project test/Exceptionless.RandomData.Tests -f net10.0 — 4 tests pass
  • All README code snippets verified to compile with 0 warnings

- Drop netstandard2.0, target net8.0 and net10.0 LTS only
- Enable nullable reference types and implicit usings
- Replace static Random instance with Random.Shared (thread-safe)
- Replace RandomNumberGenerator.Create() + disposal with RandomNumberGenerator.Fill()
- Use ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual/ThrowIfLessThan/ThrowIfGreaterThan guard APIs everywhere instead of manual throws
- Add where T : struct, Enum constraint on GetEnum<T>() to eliminate runtime type check
- Use Math.Clamp instead of separate Math.Min/Math.Max in GetBool
- Rewrite UpperCaseFirstCharacter with stackalloc Span<char> for zero-allocation
- Convert to file-scoped namespace, collection expressions, expression-bodied members
- Use string interpolation instead of concatenation
- Add nullable annotations to GetVersion parameters and EnumerableExtensions
- Upgrade build packages: SourceLink 10.0.103, AsyncFixer 2.1.0, MinVer 7.0.0
- Use dynamic copyright year expression matching project convention
- Upgrade test project to xUnit v3 with Microsoft Testing Platform
- Add Foundatio.Xunit.v3 13.0.0-beta3, xunit.v3.mtp-v2 3.2.2
- Add TestingPlatformDotnetTestSupport and new-test-runner: true for CI
- Restore test parallelization disabling via AssemblyInfo.cs
- Add codeql-analysis.yml, copilot-setup-steps.yml, global.json, AGENTS.md
- Update README with comprehensive usage examples (all snippets compile clean)

Co-authored-by: Cursor <cursoragent@cursor.com>
@CLAassistant
Copy link

CLAassistant commented Feb 20, 2026

CLA assistant check
All committers have signed the CLA.

@niemyjski niemyjski requested review from Copilot and ejsmith and removed request for ejsmith February 20, 2026 20:49
@niemyjski niemyjski self-assigned this Feb 20, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the Exceptionless.RandomData library by targeting .NET 8.0 and .NET 10.0 (dropping .NET Standard 2.0), adopting modern C# idioms, and upgrading to xUnit v3 with the Microsoft Testing Platform. The changes focus on using newer .NET APIs like Random.Shared, RandomNumberGenerator.Fill(), guard methods (ArgumentOutOfRangeException.ThrowIf*), and performance improvements with stackalloc Span<char>. The PR also enables nullable reference types, adds comprehensive README examples, and includes new documentation (AGENTS.md) and GitHub workflows.

Changes:

  • Modernized to .NET 8.0/10.0 with nullable reference types, implicit usings, file-scoped namespaces, and collection expressions
  • Replaced custom Random instance with Random.Shared and updated to use modern guard APIs and RandomNumberGenerator.Fill()
  • Upgraded test infrastructure to xUnit v3 with Microsoft Testing Platform
  • Updated build packages (SourceLink, AsyncFixer, MinVer) and added GitHub Actions workflows for CodeQL and Copilot setup

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Exceptionless.RandomData/RandomData.cs Core library modernized with Random.Shared, guard APIs, stackalloc Span, nullable annotations, and expression-bodied members
test/Exceptionless.RandomData.Tests/RandomDataTests.cs Tests updated to file-scoped namespace, collection expressions, and fixed String casing
test/Exceptionless.RandomData.Tests/Properties/AssemblyInfo.cs Updated xUnit attribute name for test parallelization settings
test/Exceptionless.RandomData.Tests/Exceptionless.RandomData.Tests.csproj Upgraded to xUnit v3 packages and Microsoft Testing Platform with multi-targeting
build/common.props Updated target frameworks, enabled nullable/implicit usings, dynamic copyright year, upgraded build packages
global.json Added test runner configuration for Microsoft Testing Platform
README.md Enhanced with comprehensive usage examples for all API methods
AGENTS.md New agent guidelines document with coding standards and repository conventions
.github/workflows/codeql-analysis.yml New CodeQL analysis workflow
.github/workflows/copilot-setup-steps.yml New Copilot setup workflow
.github/workflows/build.yml Added new-test-runner flag for Microsoft Testing Platform

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

niemyjski and others added 2 commits February 20, 2026 15:03
… when equal is allowed; add XML docs to all public API

Co-authored-by: Cursor <cursoragent@cursor.com>
Refactors enum test to use a more descriptive name.

Improves code readability by explicitly declaring the type of the result variable in the GetSentencesTest method and marking the _numbers array as readonly.
@niemyjski niemyjski requested a review from ejsmith February 20, 2026 21:15
@niemyjski niemyjski merged commit fed61ac into main Feb 20, 2026
3 of 4 checks passed
@niemyjski niemyjski deleted the modernize/net8-net10 branch February 20, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants