Skip to content

Commit

Permalink
Merge pull request #189 from stakx/abstract-indexers
Browse files Browse the repository at this point in the history
Fix output for abstract get-set indexers
  • Loading branch information
danielmarbach committed May 16, 2020
2 parents 4dfb9f6 + 2b522a7 commit a2a2490
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PublicApiGenerator/PropertyNameBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class PropertyNameBuilder
MemberAttributes getAccessorAttributes, MemberAttributes setAccessorAttributes)
{
string name = propertyDefinition.Name;
if (getAccessorAttributes != setAccessorAttributes || propertyDefinition.DeclaringType.IsInterface)
if (getAccessorAttributes != setAccessorAttributes || propertyDefinition.DeclaringType.IsInterface || propertyDefinition.HasParameters)
{
return name;
}
Expand Down
57 changes: 57 additions & 0 deletions src/PublicApiGeneratorTests/Indexer_properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,48 @@ public class ClassWithIndexer
}");
}

[Fact]
public void Should_output_abstract_read_only_indexer()
{
AssertPublicApi<ClassWithAbstractReadOnlyIndexer>(
@"namespace PublicApiGeneratorTests.Examples
{
public abstract class ClassWithAbstractReadOnlyIndexer
{
protected ClassWithAbstractReadOnlyIndexer() { }
public abstract int this[int x] { get; }
}
}");
}

[Fact]
public void Should_output_abstract_read_write_indexer()
{
AssertPublicApi<ClassWithAbstractReadWriteIndexer>(
@"namespace PublicApiGeneratorTests.Examples
{
public abstract class ClassWithAbstractReadWriteIndexer
{
protected ClassWithAbstractReadWriteIndexer() { }
public abstract int this[int x] { get; set; }
}
}");
}

[Fact]
public void Should_output_abstract_write_only_indexer()
{
AssertPublicApi<ClassWithAbstractWriteOnlyIndexer>(
@"namespace PublicApiGeneratorTests.Examples
{
public abstract class ClassWithAbstractWriteOnlyIndexer
{
protected ClassWithAbstractWriteOnlyIndexer() { }
public abstract int this[int x] { set; }
}
}");
}

[Fact]
public void Should_output_named_indexer()
{
Expand Down Expand Up @@ -91,6 +133,21 @@ public class ClassWithIndexer
public int this[int x] => x;
}

public abstract class ClassWithAbstractReadOnlyIndexer
{
public abstract int this[int x] { get; }
}

public abstract class ClassWithAbstractReadWriteIndexer
{
public abstract int this[int x] { get; set; }
}

public abstract class ClassWithAbstractWriteOnlyIndexer
{
public abstract int this[int x] { set; }
}

public class ClassWithNamedIndexer
{
[IndexerName("Bar")]
Expand Down

0 comments on commit a2a2490

Please sign in to comment.