Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Enable nullable on annotations - #2278

Merged
tlakollo merged 3 commits into
dotnet:mainfrom
tlakollo:EnableNullableOnAnnotations
Sep 17, 2021
Merged

tlakollo merged 3 commits into
dotnet:mainfrom
tlakollo:EnableNullableOnAnnotations

Conversation

@tlakollo

Copy link
Copy Markdown
Contributor

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

Change the MarkStep condition to check for null after TryResolve
@tlakollo
tlakollo requested a review from sbomer September 16, 2021 21:47
@tlakollo tlakollo self-assigned this Sep 16, 2021
Comment thread src/linker/Linker/Annotations.cs Resolved

@sbomer sbomer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@tlakollo
tlakollo merged commit 8977a27 into dotnet:main Sep 17, 2021
@tlakollo
tlakollo deleted the EnableNullableOnAnnotations branch September 17, 2021 03:48
MarkSecurityDeclarations (type, new DependencyInfo (DependencyKind.CustomAttribute, type));

if (type.BaseType is not null &&
if (_context.TryResolve (type.BaseType) is TypeDefinition baseType &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is nullable actually enabled in this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Port to 6.0 the fix #2278 for #2274
Enable nullable on Annotations.cs
Check for null after TryResolve using 'is' keyword in MarkStep()
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash in linker building with .NET 6 RC1

3 participants