-
Notifications
You must be signed in to change notification settings - Fork 35
feat: support C# 11 required modifier during validation (Closes #76) #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Moha-sami
wants to merge
6
commits into
DamianEdwards:main
Choose a base branch
from
Moha-sami:feature-support-required-modifier
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8bf9293
docs: add XML code usage example for MiniValidator.TryValidate
Moha-sami 1445c0f
feat: support C# 11 required modifier during validation (Closes #76)
Moha-sami d9f2843
refactor: gate RequiredAttribute on non-nullable members, match full …
Moha-sami 2278ea1
fix: multi-target NullabilityInfoContext under #if NET6_0_OR_GREATER …
Moha-sami c991425
refactor: exclude value types, ensure thread-safe NullabilityInfoCont…
Moha-sami ca6b644
refactor: extract target-independent IsReferenceTypeNullableFallback …
Moha-sami File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
4 changes: 2 additions & 2 deletions
4
tests/MiniValidation.UnitTests/MiniValidation.UnitTests.csproj
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
netstandard2.0path still differs fromNullabilityInfoContextfor nullable flow annotations. For example,[AllowNull] public required string Valuehas nullable write state, and[MaybeNull]has nullable read state; this fallback currently sees neither and synthesizes[Required], so the same model validates differently depending on which target asset is loaded.Please mirror the modern path before falling back to
NullableAttribute/NullableContextAttribute: detectSystem.Diagnostics.CodeAnalysis.AllowNullAttributefor the write side andSystem.Diagnostics.CodeAnalysis.MaybeNullAttributefor the read side, inspecting the property and the setter value/getter return metadata thatNullabilityInfoContextconsiders. Comparing full type names keeps this compatible where those attribute types are not directly referenceable. If either side permits null, returntrue.Please also cover both annotations through the fallback path. Since the current test project targets only .NET 8+, it always selects the
NullabilityInfoContextbranch; either exercise thenetstandard2.0asset from a consumer test or extract the metadata parser into target-independent code that can be tested directly.