Skip to content

Commit 7e50dcc

Browse files
authored
Fix "ambiguous match" error when exporting interface with multiple indexers (#197)
Co-authored-by: Manuel Leßmann <[email protected]>
1 parent fda665c commit 7e50dcc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/dscom.demo/assembly3/IDemoInterfaceComInvisible.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,12 @@ public interface IDemoInterfaceComVisible
2626
{
2727
void DoSomething(IDemoInterfaceComInvisible param);
2828
}
29+
30+
[ComVisible(true)]
31+
public interface IDemoInterfaceIndexerInvisible
32+
{
33+
public string this[int x] { get; }
34+
35+
[ComVisible(false)]
36+
public string this[string s] { get; }
37+
}

src/dscom/writer/PropertyMethodWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class PropertyMethodWriter : MethodWriter
2222
private readonly PropertyInfo? _propertyInfo;
2323
public PropertyMethodWriter(InterfaceWriter interfaceWriter, MethodInfo methodInfo, WriterContext context, string methodName) : base(interfaceWriter, methodInfo, context, methodName)
2424
{
25-
_propertyInfo = methodInfo.DeclaringType!.GetProperty(GetPropertyName());
25+
_propertyInfo = methodInfo.DeclaringType!.GetProperties().First(p => p.GetGetMethod() == methodInfo || p.GetSetMethod() == methodInfo);
2626
MemberInfo = _propertyInfo!;
2727
}
2828

0 commit comments

Comments
 (0)