Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PropertyChanged.Fody/WarningChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
}
Expand Down
27 changes: 19 additions & 8 deletions Tests/PropertyInfoCheckers/IndexerCheckerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ public class IndexerCheckerTest
public void IsIndexer()
{
var weaver = new ModuleWeaver();
var propertyDefinition = DefinitionFinder.FindType<IndexerClass>()
.Properties
.First();
var propertyDefinitions = DefinitionFinder.FindType<IndexerClass>()
.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
Expand All @@ -28,5 +31,13 @@ public string this[string i]
{
}
}

public double this[int x, int y, int z]
{
get => 0.0;
set
{
}
}
}
}