Skip to content

TimeSpan in C#: retarget to net10.0, MSTest 4.4.0, readable constructor values, four new tests - #2212

Merged
vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/83222-csharp-timespan
Sep 20, 2026
Merged

vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/83222-csharp-timespan

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Updates the dotnet-datetime/TimeSpanInCSharp sample for the article rewrite.

  • Both projects retargeted from net7.0 to net10.0.
  • Microsoft.NET.Test.Sdk 17.3.2 to 18.10.1, MSTest.TestAdapter and MSTest.TestFramework 2.2.10 to 4.4.0, coverlet.collector 3.1.2 to 10.0.1 (versions re-queried on NuGet on 2026-09-15; 18.10.1 is the newest stable Test.Sdk).
  • Divide (both tests), Duration, Multiply and Subtract now build their values with readable arguments (new TimeSpan(4, 0, 0) instead of new TimeSpan(2, 60, 3600)), so the numbers in the article can be checked without arithmetic.
  • Two swapped Assert.AreEqual argument pairs fixed (MSTEST0017 in the Duration and Negate tests).
  • Four new tests: standard and custom format specifiers, TryParse behaviour, MinValue/MaxValue/Zero range behaviour, and the .NET 9 integer FromSeconds overload.

Build: 0 warnings, 0 errors. Tests: 17/17 passing on .NET 10.0.10, SDK 10.0.302.

@vladimir-pecanac-main
vladimir-pecanac-main merged commit 7235df4 into CodeMazeBlog:main Sep 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant