Skip to content

Trim analyzer: Implement type name parsing #95118

Description

@vitek-karas

For example:

// Should produce warning because we should be able to parse the type name, resolve it
// and find the method with RUC and thus issue a warning due to potential access to that method.
Type.GetType("TypeWithRUCMethod").GetMethods();

This is also happening in places with annotated string values.

There's a TODO in the code about this:

// TODO: Implement type name resolution to type symbol
// Important corner cases:
// IL2105 (see it's occurences in the tests) - non-assembly qualified type name which doesn't resolve warns
// - will need to figure out what analyzer should do around this.

Activity

  1. added
    area-Tools-ILLink
    on Nov 22, 2023
  2. ghost added
    untriaged
    on Nov 22, 2023
  3. added this to the 9.0.0 milestone on Feb 5, 2024
  4. ghost removed
    untriaged
    on Feb 5, 2024
  5. added
    in-pr
    on Aug 9, 2024
  6. sbomer commented on Aug 9, 2024

    @sbomer
    Member

    The note about IL2105 is out of date with #104060 - analyzer should produce the new IL2122 whenever a non-assembly-qualified type name is passed to a location with annotations, same as the other tools.

  7. self-assigned this
    on Aug 12, 2024
  8. modified the milestones: 9.0.0, 10.0.0 on Aug 13, 2024
  9. reopened this on Aug 13, 2024
  10. sbomer commented on Aug 13, 2024

    @sbomer
    Member

    Reopening since the fix was reverted: #106343

  11. sbomer commented on Aug 19, 2024

    @sbomer
    Member

    I think this needs Roslyn to update the version of System.Reflection.Metadata here: https://github.com/dotnet/roslyn/blame/d3ba1144d3d8dd41f1c0a5d84729ba46c5625a54/eng/Versions.props#L32C3-L32C3. I believe that will update the binding redirects so that we can use the 9.0 version of TypeNameParseOptions. See the relevant comments #106209 (comment) and #106321 (comment).

  12. sbomer commented on Jun 10, 2025

    @sbomer
    Member

    Looks like Roslyn bumped System.Reflection.Metadata to 9.0.0 so we can go ahead with this.

  13. locked and limited conversation to collaborators on Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-Tools-ILLinkin-pr

Type

No type

Projects

  • Status
    No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions