Skip to content

[Bug]: Wrong exception thrown by MemberInfoExtensions.IsDictionaryValueNonNullable #3070

@mywyb2

Description

@mywyb2

Describe the bug

Starting from version 6.7.2, MemberInfoExtensions.IsDictionaryValueNonNullable contains a bug that throws an exception when the declaring type of a class property that is assignable to Dictionary{TKey,TValue} has a number of generic type arguments that is not 2. This is easily possible when the declaring type extends Dictionary{TKey,TValue}, e.g.

public class MyDictionary: Dictionary<string, string>

Instead of picking the generic type arguments of the declaring type, you need to look at the type arguments of the IDictionary-interface of the declaring type.

Expected behavior

That no exception is thrown, just like in versions <= 6.7.1.

Actual behavior

An exception is thrown on initialization, causing Swagger to fail to load API definition.

Steps to reproduce

No response

Exception(s) (if any)

No response

Swashbuckle.AspNetCore version

6.7.2

.NET Version

8

Anything else?

No response

Metadata

Metadata

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions