Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

Backports #121603 to release/10.0. Fixes #121546.

The RoslynAnalyzer crashes when analyzing indexer property parameter initializers because it assumes all parameters belong to methods, but Roslyn provides operation blocks for property indexer parameters that don't have a direct IL equivalent.

Changes

  • TrimAnalysisVisitor.cs: Guard against null parameterMethod in GetParameterTargetValue. Returns TopValue for parameters not owned by methods (e.g., indexer parameter initializers), preventing crashes while preserving correct analysis for method parameters.

  • PropertyDataFlow.cs: Add test coverage for annotated indexer parameters and indexers with default arguments to verify the analyzer handles these cases without crashing.

// Previously crashed on this pattern:
public Type this[[DynamicallyAccessedMembers(...)] Type index]
{
    get { ... }
    set { ... }
}
Original prompt

Backport #121603 to the release/10.0 branch.


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

@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Nov 20, 2025
Copilot AI changed the title [WIP] Backport runtime fix from PR 121603 to release/10.0 Backport PR #121603: Fix RoslynAnalyzer crash on indexer property parameters Nov 20, 2025
Copilot AI requested a review from sbomer November 20, 2025 22:44
Copilot finished work on behalf of sbomer November 20, 2025 22:44
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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants