This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
Enable nullable on annotations - #2278
Merged
Merged
Conversation
Change the MarkStep condition to check for null after TryResolve
sbomer
reviewed
Sep 16, 2021
PR feedback
sbomer
approved these changes
Sep 16, 2021
sbomer
left a comment
Member
There was a problem hiding this comment.
Thanks, LGTM! I think we will need to make a separate change in the 6.0 branch that's a more targeted fix for the BaseType issue (since none of the nullable annotation changes exist in that branch).
agocke
reviewed
Sep 17, 2021
| MarkSecurityDeclarations (type, new DependencyInfo (DependencyKind.CustomAttribute, type)); | ||
|
|
||
| if (type.BaseType is not null && | ||
| if (_context.TryResolve (type.BaseType) is TypeDefinition baseType && |
Member
There was a problem hiding this comment.
Is nullable actually enabled in this file?
Contributor
Author
There was a problem hiding this comment.
Nullable is not enabled on MarkStep, but methods in Annotations.cs that have non-nullable parameters are flagged when called with a possible null. The warning is on callsite so the warning appears in MarkStep even if nullable has not been enabled.
tlakollo
added a commit
that referenced
this pull request
Sep 17, 2021
agocke
pushed a commit
to dotnet/runtime
that referenced
this pull request
Nov 16, 2022
Enable nullable on Annotations.cs Check for null after TryResolve using 'is' keyword in MarkStep() Commit migrated from dotnet/linker@8977a27
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Enable nullable on Annotations.cs
Change the MarkStep condition to check for null after TryResolve
Fixes #2274
I couldn't add a test case because I couldn't come up with a scenario in which the TypeReference Type.BaseType is not null but resolving the TypeReference is null