Skip to content

Fix indexer detection logic to cover indexers with more than one parameter#1107

Merged
tom-englert merged 1 commit into
masterfrom
indexer-fix
Jul 4, 2026
Merged

Fix indexer detection logic to cover indexers with more than one parameter#1107
tom-englert merged 1 commit into
masterfrom
indexer-fix

Conversation

@tom-englert

Copy link
Copy Markdown
Member

might be nitpicking, just changes the warning from "Property takes more than one parameter" to "Property is an indexer" for indexers with more than one index parameter.

Copilot AI review requested due to automatic review settings July 3, 2026 12:06
@tom-englert tom-englert requested a review from ltrzesniewski July 3, 2026 12:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the weaver’s warning classification so indexer properties with multiple index parameters are detected as indexers (and produce the “Property is an indexer.” warning) rather than being reported as “takes more than one parameter,” and expands the unit test coverage to include a multi-parameter indexer.

Changes:

  • Broadened indexer detection to allow set_Item setters with more than one index parameter.
  • Updated the indexer warning test to validate the warning for all indexers on the test type.
  • Added an additional indexer overload (multiple index parameters) to the test fixture.

Reviewed changes

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

File Description
Tests/PropertyInfoCheckers/IndexerCheckerTest.cs Adds a multi-parameter indexer and asserts the indexer warning for each indexer property.
PropertyChanged.Fody/WarningChecker.cs Adjusts indexer detection logic to recognize indexers with multiple parameters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ricaun

ricaun commented Jul 3, 2026

Copy link
Copy Markdown

I wonder when this happen?!

if (setMethod.Parameters.Count > 1)
{
return "Property takes more than one parameter.";
}

There is some case when a Property setMethod with more the one parameter is not an indexer?

@tom-englert

Copy link
Copy Markdown
Member Author

I think in VB you can create such weird properties

@ricaun

ricaun commented Jul 3, 2026

Copy link
Copy Markdown

I think in VB you can create such weird properties

Looks like in VB you can use any name in the property indexer, usually is Item but you can set any name.

Default Public Property CustomIndexer(key As String) As Double

@tom-englert tom-englert merged commit afdffbb into master Jul 4, 2026
3 checks passed
@tom-englert tom-englert deleted the indexer-fix branch July 4, 2026 13:54
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