dotnet / dotnet/dotnet-api-docs
Type.GetInterfaceMap(Type) does not throw for open generic types
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
### Description
According to [the docs](https://learn.microsoft.com/en-us/dotnet/api/system.type.getinterfacemap?view=net-7.0):
> Exceptions
> [ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception?view=net-7.0)
> ...
> The current instance or interfaceType argument is an open generic type; that is, the [ContainsGenericParameters](https://learn.microsoft.com/en-us/dotnet/api/system.type.containsgenericparameters?view=net-7.0#system-type-containsgenericparameters) property returns true.
The `current instance` I guess it refers to the type on which the method is called, which in my examples below is always an open type, and it does not throw for that.
While the `interfaceType argument` only throws if I manually write it as an open generic, while if I retrieve it through reflection it does not.
### Reproduction Steps
See fiddle: https://dotnetfiddle.net/8698i5
### Expected behavior
According to the docs it should always throw
### Actual behavior
It throws only if both types are specified as open generics through `typeof()` and not via reflection
### Regression?
_No response_
### Known Workarounds
_No response_
### Configuration
_No response_
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.