Closed
Description
Property indexers raises ' System.Reflection.AmbiguousMatchException: Ambiguous match found.' exception.
Interface IndexerInterface
ReadOnly Property SystemDefault() As Boolean
Property Value() As Boolean
Property Value(ByVal OverrideLevel As Integer) As Boolean
Property Value(ByVal OverrideLevel As Integer, ByVal OverrideID As String) As Boolean
End Interface
Dim failClassMock = New Mock(Of IndexerInterface)()
failClassMock.SetupAllProperties()
Assert.False(failClassMock.Object.Value)
Using the class above, after SetupAllProperties are called Value
raises the exception in line.
This line should call GetProperty(name,new Type[0])
with zero parameters. As there are 2 get_Value method.
Version: 4.15.2
Activity
stakx commentedon Jan 14, 2021
Interesting find! Are you sure that's the correct line of code? After all,
type.GetProperty
is looking for properties, not for methods. I would expect that method to identify properties through their own metadata and not through their accessor methods...?mujdatdinc commentedon Jan 14, 2021
VB can create indexer properites. C# can do it as a method. I fixed it in my local and my tests are working.
Isssue unit test devlooped#1129
mujdatdinc commentedon Jan 15, 2021
I created the unit test and fix.
mujdatdinc:issue/1129
I am changing the initial post for details.
stakx commentedon Jan 16, 2021
@mujdatdinc, ah yes, that makes sense now! 👍
Would you like to submit a PR with your bug fix?
If so, it would be great if you could do the following (as explained in more detail in the contribution guidelines):
Add your repro to
tests/Moq.Tests.VisualBasic/IssueReports.vb
like you did in your commit. (Please pay attention to indentation: This project uses tabs, not spaces; so there should be no change to existing code.)Put the actual bug fix in
src/Moq/Interception/InterceptionAspects.cs
. (Again, please don't change indentation of existing code. Also, you can useType.EmptyTypes
instead ofnew Type[0]
; there's no need to allocate a new array when we can use an existing one.)Add a new entry to
CHANGELOG.md
describing your bug fix.(P.S.: Seeing that this is your first issue on GitHub, please don't hesitate to ask for guidance, if needed.)
issue devlooped#1129
issu devlooped#1129
mujdatdinc commentedon Jan 17, 2021
Thanks. I send the PR. Hope its ok.
Actualy I have one more bug that breaks some of our unit tests. I fixed with work around but work around its annoying. I will open when i have time.
AmbiguousMatchException
when interface has indexer besides property #1131issue devlooped#1129
issue devlooped#1129
6 remaining items