diff --git a/PropertyChanged.Fody/WarningChecker.cs b/PropertyChanged.Fody/WarningChecker.cs index 1b891773..f5bf83fe 100644 --- a/PropertyChanged.Fody/WarningChecker.cs +++ b/PropertyChanged.Fody/WarningChecker.cs @@ -27,7 +27,7 @@ public string CheckForWarning(PropertyData propertyData, InvokerTypes invokerTyp var propertyDefinition = propertyData.PropertyDefinition; var setMethod = propertyDefinition.SetMethod; - if (setMethod.Name == "set_Item" && setMethod.Parameters.Count == 2 && setMethod.Parameters[1].Name == "value") + if (setMethod.Name == "set_Item" && setMethod.Parameters.Count > 1 && setMethod.Parameters.Last().Name == "value") { return "Property is an indexer."; } diff --git a/Tests/PropertyInfoCheckers/IndexerCheckerTest.cs b/Tests/PropertyInfoCheckers/IndexerCheckerTest.cs index b324f044..cd207604 100644 --- a/Tests/PropertyInfoCheckers/IndexerCheckerTest.cs +++ b/Tests/PropertyInfoCheckers/IndexerCheckerTest.cs @@ -7,16 +7,19 @@ public class IndexerCheckerTest public void IsIndexer() { var weaver = new ModuleWeaver(); - var propertyDefinition = DefinitionFinder.FindType() - .Properties - .First(); + var propertyDefinitions = DefinitionFinder.FindType() + .Properties; - var propertyData = new PropertyData + foreach (var propertyDefinition in propertyDefinitions) { - PropertyDefinition = propertyDefinition, - }; - var message = weaver.CheckForWarning(propertyData, InvokerTypes.String); - Assert.Equal("Property is an indexer.", message); + var propertyData = new PropertyData + { + PropertyDefinition = propertyDefinition, + }; + + var message = weaver.CheckForWarning(propertyData, InvokerTypes.String); + Assert.Equal("Property is an indexer.", message); + } } public abstract class IndexerClass @@ -28,5 +31,13 @@ public string this[string i] { } } + + public double this[int x, int y, int z] + { + get => 0.0; + set + { + } + } } } \ No newline at end of file