-
Notifications
You must be signed in to change notification settings - Fork 29
/
Indexer_properties.cs
59 lines (54 loc) · 1.46 KB
/
Indexer_properties.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Runtime.CompilerServices;
using PublicApiGeneratorTests.Examples;
using Xunit;
namespace PublicApiGeneratorTests
{
public class Indexer_properties : ApiGeneratorTestsBase
{
[Fact]
public void Should_output_indexer()
{
AssertPublicApi<ClassWithIndexer>(
@"namespace PublicApiGeneratorTests.Examples
{
public class ClassWithIndexer
{
public ClassWithIndexer() { }
public int this[int x] { get; }
}
}");
}
[Fact]
public void Should_output_named_indexer()
{
AssertPublicApi<ClassWithNamedIndexer>(
@"namespace PublicApiGeneratorTests.Examples
{
public class ClassWithNamedIndexer
{
public ClassWithNamedIndexer() { }
[System.Runtime.CompilerServices.IndexerName(""Bar"")]
public int this[int x] { get; }
}
}");
}
}
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable ValueParameterNotUsed
namespace Examples
{
public class ClassWithIndexer
{
public int this[int x] => x;
}
public class ClassWithNamedIndexer
{
[IndexerName("Bar")]
public int this[int x] => x;
}
}
// ReSharper restore ValueParameterNotUsed
// ReSharper restore UnusedMember.Global
// ReSharper restore ClassNeverInstantiated.Global
}