Skip to content

Commit

Permalink
Fix indexed property visiting
Browse files Browse the repository at this point in the history
Fixes #22.
  • Loading branch information
kzu committed Jan 28, 2021
1 parent eba967c commit ad4e732
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/NuDoq.Tests/ReaderFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,17 @@ public void when_reading_with_keep_lines_then_preserves_original_text()
lines", method.Elements.OfType<Summary>().First().Elements.OfType<Text>().First().Content);
}

[Fact]
public void when_reading_indexer_property_then_succeeds()
{
var member = DocReader.Read(Assembly.GetExecutingAssembly(), new ReaderOptions { KeepNewLinesInText = true });
var method = member.Elements.OfType<Property>()
.FirstOrDefault(m => m.Info?.DeclaringType == typeof(CustomXml) && ((PropertyInfo)m.Info!).GetIndexParameters().Length > 0);

Assert.NotNull(method);
Assert.Equal("indexed", method.ToText());
}

class CountingVisitor : Visitor
{
readonly string platform;
Expand Down Expand Up @@ -737,6 +748,13 @@ public void Out(out int p1)
/// lines
/// </summary>
public string NewLines { get; set; }

/// <summary>indexed</summary>
public int this[int index]
{
get => 0;
set => Console.WriteLine(value);
}
}
}
}
1 change: 1 addition & 0 deletions src/NuDoq/MemberIdMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ void Append(PropertyInfo property)
{
AppendType(sb, property.DeclaringType);
sb.Append('.').Append(property.Name);
Append(property.GetIndexParameters());
}

void Append(MethodInfo method)
Expand Down

0 comments on commit ad4e732

Please sign in to comment.