ModelState validation: retarget net10.0, fix async void tests, fix filter filename - #2180
Open
vladimir-pecanac-main wants to merge 1 commit into
Conversation
…lter filename - Retarget both projects from net6.0 to net10.0. - Lift test packages to current stable: Microsoft.AspNetCore.Mvc.Testing 10.0.11, Microsoft.NET.Test.Sdk 18.9.0, xunit 2.9.3, xunit.runner.visualstudio 4.0.0, coverlet.collector 10.0.1. - Both integration tests were public async void, which xUnit cannot await, so an assertion failing after the first await passed silently. Changed to public async Task. xUnit already flags this as xUnit1048 and v3 drops async void support entirely. - Renamed ValidationFilterAtribute.cs to ValidationFilterAttribute.cs so the filename matches the class inside it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refreshes the
aspnetcore-webapi/ModelStateValidationsample alongside the republished article.Retarget. Both projects move from
net6.0tonet10.0. Test packages lifted to current stable, read from NuGet at prep time:Microsoft.AspNetCore.Mvc.Testing10.0.11,Microsoft.NET.Test.Sdk18.9.0,xunit2.9.3,xunit.runner.visualstudio4.0.0,coverlet.collector10.0.1.Both integration tests were
public async void. xUnit cannot await anasync voidtest, so an assertion that fails after the firstawaitpasses silently. Both are nowpublic async Task. This still compiled before the change: xunit 2.9.3 emitsxUnit1048("Support for 'async void' unit tests is being removed from xUnit.net v3"), so it was a live correctness defect rather than a build break, and it gets worse rather than better on the v3 line.Filename spelling.
ValidationFilterAtribute.cs(onet) held a correctly spelledValidationFilterAttributeclass. Renamed the file so searching the download by class name finds it.No behavioural change to the sample: it keeps the
SuppressModelStateInvalidFilter+ValidationFilterAttributeapproach the article walks through.Verified on SDK 10.0.302:
dotnet build -c Releaseclean (0 warnings, 0 errors) anddotnet testgreen, 2 passed / 0 failed.