Skip to content

Fix analyzer nullref on assembly attribute #2534

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

Merged
merged 1 commit into from
Jan 21, 2022
Merged

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Jan 21, 2022

Porting #2530 to main.

The analyzer runs for property assignment operations, including those in
attributes. To check whether the property assignment should warn, we
look for RUC on the containing symbol. However, assembly-level attributes
are contained in the global namespace, which has a null containing type.
Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@sbomer sbomer merged commit 58a0c60 into dotnet:main Jan 21, 2022
jtschuster added a commit to jtschuster/linker that referenced this pull request Jan 24, 2022
Design proposal for DAM-on-type and RUC interactions (dotnet#2168)

Co-authored-by: Sven Boemer <sbomer@gmail.com>

Fix analyzer nullref on assembly attribute (dotnet#2534)

The analyzer runs for property assignment operations, including those in
attributes. To check whether the property assignment should warn, we
look for RUC on the containing symbol. However, assembly-level attributes
are contained in the global namespace, which has a null containing type.

Create a schema for the LinkAttribute XML files (dotnet#2500)

Adds xml schema for ILLink.LinkAttributes.xml, and adds relative paths to the schema in xml used in unit tests to enable linting.

[main] Update dependencies from dotnet/runtime (dotnet#2539)

[main] Update dependencies from dotnet/runtime

Title and message resources should be enforced to exist to prevent printing empty messages (dotnet#2538)

Currently, missing resources will default to an empty string printing an empty message for the diagnostics. Code should not try to gracefully handle errors.

Included in this PR:
- DiagnosticString should be able to locate a title and message resource strings otherwise it throws
- Add title resource strings for all missing diagnostic Ids

Update dependencies from https://github.com/dotnet/runtime build 20220123.5 (dotnet#2542)

[main] Update dependencies from dotnet/runtime

Update dependencies from https://github.com/dotnet/arcade build 20220121.6 (dotnet#2541)

[main] Update dependencies from dotnet/arcade

Analyzer warns when Requires... Attribute is on a static constructor (dotnet#2455)

Adds warnings in the analyzer for IL2116 (RUC not allowed on static ctor) and adds IL2117 (RequiresDynamicCode not allowed on static ctor) and IL2118 (RequiresAssemblyFiles not allowed on static ctor).

Fixes ExpectedWarning not having effects on constructors by adding a Visit override in the compilation tree walker in the test infra.

Adds case in GetDisplayName to differentiate .cctor's and .ctor's.

Linker doesn't seem to be checking ctors for calls to methods with RUC.
This commit removes the check for the expected warnings in the linker
until the bug is fixed.
@sbomer sbomer deleted the port2530ToMain branch February 22, 2022 18:13
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
The analyzer runs for property assignment operations, including those in
attributes. To check whether the property assignment should warn, we
look for RUC on the containing symbol. However, assembly-level attributes
are contained in the global namespace, which has a null containing type.

Commit migrated from dotnet/linker@58a0c60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants