Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caught AmbigousMatch in System.RuntimeType.GetMethodImpl #38

Open
pkese opened this issue Nov 7, 2022 · 1 comment
Open

Caught AmbigousMatch in System.RuntimeType.GetMethodImpl #38

pkese opened this issue Nov 7, 2022 · 1 comment

Comments

@pkese
Copy link

pkese commented Nov 7, 2022

I have found an issue with Legivel and I'm providing reproduction code below.

#!/usr/bin/env -S dotnet fsi

#r "nuget: Open.Collections, 3.1.2"
//#r "nuget: Open.Collections, 2.11.3"
#r "nuget: Legivel, 0.4.6"

open Open.Collections
open Legivel.Serialization

type Document = {
    ages: OrderedDictionary<string,int>
}

"""
ages:
    john: 30
    mary: 25
    paul: 51
"""
|> Deserialize<Document>
|> Seq.iter (function
    | Success successInfo ->
        for kv in successInfo.Data.ages do
            printfn $"{kv.Key} -> {kv.Value}"
    | Error error ->
        printfn "Error: %A" error)

After updating an external library that I'm using for OrderedDictionary, the code suddenly started throwing an exception:

System.Reflection.AmbiguousMatchException: Ambiguous match found.
   at System.RuntimeType.GetMethodImplCommon(String name, Int32 genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.Type.GetMethod(String name, BindingFlags bindingAttr)
   at System.Type.GetMethod(String name)
   at Legivel.Customization.Mapping.Legivel-Mapper-Model-IYamlToNativeMapping-map@456-17.Invoke(Tuple`2 tupledArg)
   at Microsoft.FSharp.Collections.ListModule.Iterate[T](FSharpFunc`2 action, FSharpList`1 list) in /build/dotnet6-vdouV1/dotnet6-6.0.110/src/fsharp/artifacts/source-build/self/src/src/fsharp/FSharp.Core/list.fs:line 102
   at Legivel.Customization.Mapping.Legivel-Mapper-Model-IYamlToNativeMapping-map@444-14.Invoke(FSharpList`1 possibleData)
   at [email protected](RecordFieldMapping fm)
   at Legivel.Customization.Mapping.mapKeyValue@209(RecordMappingInfo this, ProcessMessages msgList, AllTryFindIdiomaticMappers mappers, ProcessMessages pm, Node org, String kn, Node v)
   at Legivel.Customization.Mapping.Legivel-Mapper-Model-IYamlToNativeMapping-map@229-7.Invoke(NodeData`1 kf)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x) in /build/dotnet6-vdouV1/dotnet6-6.0.110/src/fsharp/artifacts/source-build/self/src/src/fsharp/FSharp.Core/local.fs:line 244
...

My workaround for was to pin the Open.Collections library to an older version, however I'm sharing this reproduction here, because I assume it might be a bug in Legivel:
OrderedDictionary<'K,'V> properly implements System.Collections.Generic.IDictionary<'K,'V> interface, so there's no reason Legivel wouldn't recognize it as such and call dictionary methods on its instances.

@fjoppe
Copy link
Owner

fjoppe commented Dec 16, 2022

Hi pkese,

I have started looking into this. But it first pulls me into upgrade issues...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants