Skip to content

Remove warning for base type with RequiresUnreferencedCode #117944

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 4 commits into from
Jul 29, 2025

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Jul 22, 2025

Removes the IL2109 warning about a type without RUC derived from a type with RUC. This existed for RequiresUnreferencedCode but not RequiresDynamicCode.
The warning on the class should not be necessary because there will be a warning for the base ctor call.

Fixes #107660.

@sbomer sbomer requested review from a team and Copilot July 22, 2025 19:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes IL2109 warnings that occurred when a type without RequiresUnreferencedCode (RUC) derived from a type with RUC. The change makes the behavior consistent between RequiresUnreferencedCode and RequiresDynamicCode, where the latter did not have this warning. The warning is considered unnecessary because constructor calls to the base type will still generate appropriate warnings.

  • Removes IL2109 diagnostic code generation from multiple components (ILLink, Roslyn analyzer, and NativeAOT compiler)
  • Updates test cases to remove expected IL2109 warnings and related suppressions
  • Adds a new test file to verify the behavior with base classes having RUC/RDC attributes

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
DiagnosticId.cs Marks IL2109 diagnostic ID as unused
MarkStep.cs Removes logic that generates IL2109 warnings for base type inheritance
RequiresUnreferencedCodeAnalyzer.cs Removes Roslyn analyzer logic for IL2109 warnings
DataflowAnalyzedTypeDefinitionNode.cs Removes NativeAOT compiler logic for IL2109 warnings
RequiresOnClass.cs Removes expected IL2109 warnings from test cases and updates class names
RequiresOnBaseClass.cs New test file demonstrating expected behavior with RUC/RDC base classes
GenericParameterDataFlow.cs Removes expected IL2109 warning from generic type test
RequiresCapabilityTests.cs Adds test method for new RequiresOnBaseClass test case
SuppressWarningsViaXml.xml Removes IL2109 suppression attribute from XML configuration

@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Jul 22, 2025
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Jul 22, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/illink
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@jtschuster jtschuster left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Not needed in this PR, but for the unused warnings, should we remove the related unused strings from the .xlfs?

@sbomer
Copy link
Member Author

sbomer commented Jul 29, 2025

/ba-g "timeouts"

@sbomer sbomer merged commit 8ea8809 into dotnet:main Jul 29, 2025
108 of 116 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent warning behavior for RUC/RDC on base types
2 participants