Skip to content

Virtual Methods in C#: .NET 10, MSTest 4.5.1, Moq failure test, virtual call benchmarks - #2305

Merged
vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/90138-virtual-methods-csharp
Oct 24, 2026
Merged

vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/90138-virtual-methods-csharp

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Sample for https://code-maze.com/virtual-methods-csharp/

  • Both projects move from net7.0 to net10.0.
  • Test packages: Microsoft.NET.Test.Sdk 18.11.0, Moq 4.21.0, MSTest.TestAdapter and MSTest.TestFramework 4.5.1, coverlet.collector 10.1.0. MSTest.TestAdapter 2.2.10 pulled Newtonsoft.Json 10.0.3, which the .NET 10 SDK flags as NU1903.
  • New test WhenCircleClassDrawMock_ThenNotSupportedException: a Moq setup on the non-virtual Draw() throws NotSupportedException with the message the article prints.
  • Program.cs: the circle area comment now shows 12.566370614359172.
  • New Benchmarks project (BenchmarkDotNet 0.15.8) measuring non-virtual, virtual with one and two types, sealed, interface and delegate calls. Run with dotnet run -c Release --project Benchmarks.

Local: SDK 10.0.302, runtime 10.0.10. Build 0 warnings, 0 errors; tests 11 of 11 passing; no vulnerable packages.

…al call benchmarks

- Both projects net7.0 to net10.0
- Microsoft.NET.Test.Sdk 18.11.0, Moq 4.21.0, MSTest 4.5.1, coverlet.collector 10.1.0
  (MSTest.TestAdapter 2.2.10 pulled Newtonsoft.Json 10.0.3, flagged NU1903)
- New test: a Moq setup on the non-virtual Draw() throws NotSupportedException
- Program.cs: circle area comment uses the en-US decimal point
- New Benchmarks project (BenchmarkDotNet 0.15.8): non-virtual, virtual with one
  and two types, sealed, interface and delegate calls
@vladimir-pecanac-main
vladimir-pecanac-main merged commit 6df1fcb into CodeMazeBlog:main Oct 24, 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