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

WithoutTypeInspector<TTypeInspector> throws KeyNotFoundException when trying to remove an existing inspector #507

Closed
John-Welch opened this issue Jun 25, 2020 · 2 comments

Comments

@John-Welch
Copy link

John-Welch commented Jun 25, 2020

I was trying to remove the ReadableAndWritablePropertiesTypeInspector from a new Deserializer using:

var deserializer = new DeserializerBuilder()
    .WithoutTypeInspector<ReadableAndWritablePropertiesTypeInspector>()
    .Build();

This throws a KeyNotFoundException, saying that no component of type ITypeInspector is registered.
On looking through the code, BuilderSkeleton.cs around line 270 contains

        public TBuilder WithoutTypeInspector<TTypeInspector>()
            where TTypeInspector : ITypeInspector
        {
            return WithoutTypeInspector(typeof(ITypeInspector));
        }

I think that the last line should read

            return WithoutTypeInspector(typeof(TTypeInspector));

with TTypeInspector, not ITypeInspector.

@John-Welch
Copy link
Author

Fortunately, there's an easy workaround: just call the non-generic overload that takes a type parameter. In my case:

var deserializer = new DeserializerBuilder()
    .WithoutTypeInspector(typeof(ReadableAndWritablePropertiesTypeInspector))
    .Build();

@aaubry aaubry closed this as completed in b34a3e8 Jun 26, 2020
@aaubry
Copy link
Owner

aaubry commented Jun 26, 2020

Thanks for reporting this, it was clearly a bug and your analysis was correct.

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