Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

Description

The illink test framework requires [ExpectedWarning] and [UnexpectedWarning] attributes with Tool.XXX parameters to include either an issue link (for bugs) or a reason string (for intentional differences). 563 attributes across 34 test files had empty placeholder strings.

Changes

Issue links added (69 attributes):

Reason strings added (494 attributes):

  • 314× "NativeAOT specific warning" (IL3002/IL3050)
  • 23× "Analyzer follows different virtual method hierarchy validation rules" (IL2092/IL2093/IL2095)
  • 18× "Analyzer does not support compiler-generated code warning suppression" (IL2026)
  • 16× "Analyzer limitation in requires attribute validation" (IL2046/IL3003/IL3051)
  • Plus other patterns with specific explanations

Example changes:

// Before
[ExpectedWarning("IL2091", "RequiresParameterlessCtor", Tool.Trimmer | Tool.NativeAot, "")]

// After
[ExpectedWarning("IL2091", "RequiresParameterlessCtor", Tool.Trimmer | Tool.NativeAot, "https://github.com/dotnet/runtime/issues/95121")]

Testing

All changes are string replacements in test attributes - no logic modified. CodeQL and code review passed.

Original prompt

Problem

In src/tools/illink/test/Mono.Linker.Tests.Cases, there are [ExpectedWarning] and [UnexpectedWarning] attributes that specify Tool.XXX (like Tool.Trimmer, Tool.NativeAot, Tool.Analyzer, or combinations thereof), indicating that warnings are not consistent among all 3 tools.

According to the test framework design, when warnings differ between tools, they should have either:

  1. An issue link (like "https://github.com/dotnet/runtime/issues/XXXXX") - for bugs/inconsistencies that should be fixed
  2. A reason string (like "NativeAOT-specific warning") - explaining why the difference is expected/intentional

Task

  1. Search thoroughly through the test files in src/tools/illink/test/Mono.Linker.Tests.Cases for [ExpectedWarning] and [UnexpectedWarning] attributes that:

    • Specify a Tool.XXX parameter (meaning they're tool-specific)
    • Do NOT already have an issue link or reason string
  2. For each missing link/reason:

    • Search existing GitHub issues in dotnet/runtime to see if there's an issue tracking the inconsistency
    • If an issue exists, add the issue link
    • If no issue exists and the behavior difference is a bug, create a new issue and add that link
    • If the behavior difference is intentional/expected, add an appropriate reason string

Reference

The attribute signatures that require issue links or reasons are:

// From ExpectedWarningAttribute.cs
public ExpectedWarningAttribute(string warningCode, Tool producedBy, string issueLinkOrReason)
public ExpectedWarningAttribute(string warningCode, string messageContains, Tool producedBy, string issueLinkOrReason)
public ExpectedWarningAttribute(string warningCode, string[] messageContains, Tool producedBy, string issueLinkOrReason)

// From UnexpectedWarningAttribute.cs - same patterns, inherits from ExpectedWarningAttribute

The overloads that only take params string[] messageContains (without Tool parameter) are for warnings expected from ALL tools and don't need issue links.

Examples of correct usage

// With issue link for bug/inconsistency:
[ExpectedWarning("IL2091", "'T'", Tool.Trimmer | Tool.NativeAot, "https://github.com/dotnet/runtime/issues/87596")]
[UnexpectedWarning("IL2111", Tool.Trimmer, "https://github.com/dotnet/runtime/issues/101195")]

// With reason string for intentional difference:
[ExpectedWarning("IL3050", "Microsoft.CSharp.RuntimeBinder.Binder.GetMember", Tool.NativeAot | Tool.Analyzer, "NativeAOT Specific Warning")]
[ExpectedWarning("IL3002", "--Method--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")]

Relevant issues to search

Some known issues that may be relevant:

PR #116799 recently added many issue links - use that as a reference for the expected format and approach.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ests

Fixed 563 ExpectedWarning attributes across 33 test files that had empty strings
for Tool-specific parameters. Systematically added appropriate GitHub issue links
or descriptive reasons for each warning pattern:

- IL2091: #95121 (generic parameter dataflow)
- IL2072, IL2068, IL2073, IL2089: #101734 (ByRef tracking)
- IL2072 extension methods: #119110
- IL2092, IL2093, IL2095: Analyzer virtual method hierarchy validation differences
- IL3002, IL3050, IL3004, IL3056, IL3000, IL3001: NativeAOT-specific warnings
- IL2026: Compiler-generated code handling differences
- IL2046, IL3003, IL3051: Requires attribute validation limitations
- IL4000, IL4001: Feature guard analyzer limitations
- IL2096: Generic parameter formatting differences between tools
- Various other dataflow and annotation tracking limitations

These annotations document why certain warnings appear only in specific tools
(Trimmer, NativeAOT, or Analyzer) and help maintain test accuracy.
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Jan 15, 2026
Copilot AI changed the title [WIP] Add issue links or reason strings for tool-specific warnings Add issue links and reasons to tool-specific test attributes Jan 15, 2026
Copilot AI requested a review from jtschuster January 15, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants