Repository navigation
Non-nullable property warning (CS8618): net10.0, MSTest 4, MemberNotNull and field keyword samples - #2293
Open
Conversation
…ssage text, MemberNotNull and field keyword samples
- Retarget both projects from net7.0 to net10.0.
- Microsoft.NET.Test.Sdk 18.10.1, MSTest.TestAdapter and MSTest.TestFramework 4.5.1, coverlet.collector 10.1.0.
- MSTest 4 removed [ExpectedException]: the dereference test now uses Assert.ThrowsExactly<NullReferenceException> with _address! instead of _address?.
- Both #pragma comments now carry the current CS8618 title ("Consider adding the 'required' modifier or declaring as nullable.").
- Address gains Region, a field-keyword property inside the CS8618 pragma that still reports CS9264, and Town, the field-keyword property resolved in its get accessor.
- New HelperMethod.Address shows [MemberNotNull] on a helper shared by two constructors.
- Four new tests, one per new member and constructor.
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.
Sample update for the article "Non-nullable Property Must Contain a Non-null Value When Exiting Constructor (CS8618)" (https://code-maze.com/csharp-resolve-non-nullable-property-must-contain-a-non-null-value-warning/).
Folder: csharp-basic-topics/NonNullablePropertyMustContainANonNullValueWarning (only this folder changes).
Changes:
Build (SDK 10.0.302, Release): 0 errors, 2 warnings, both deliberate: CS8618 on Address.FirstName and CS9264 on Address.Region. These are the article's demonstrations.
Tests: 11 passed, 0 failed.
dotnet list package --vulnerable --include-transitive: no vulnerable packages in either project.