dotnet / dotnet/dotnet-api-docs

Type.IsConstructedGenericType documentation is wrong -- at least for Framework 4.8

Open
#10,874 0 comments 0 reactions 1 assignee Claimed by @steveharter View on GitHub
area-System.Reflection untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### Type of issue

Other (describe below)

### Description

The documentation for `Type.IsConstructedGenericType` indicates that a `Type` that returns `true` for this property is creatable. However, this is not necessarily true.

The example I've run into was something like:

```csharp
interface IInterface { }
interface ISecond {
IInterface Get();
}
```

`typeof(IInterface<>).IsConstructedGenericType` is `false` as I would expect.
`typeof(ISecond<>).GetMethod("Get").ReturnType.IsConstructedGenericType` is `true` which is _not_ what I expected since that `IInterface` return type is not creatable.

It turns out that the property that _does_ indicate whether a generic type is creatable is `ContainsGenericParameters`. For generic types (`Type.IsGeneric`), I can figure out if a type is creatable when `ContainsGenericParameters` is `false`. At least, I haven't found a case when that isn't correct.

### Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.type.isconstructedgenerictype?view=netframework-4.8.1

### Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System/Type.xml

### Document Version Independent Id

f2ac3506-b8f2-890e-ec0a-d77d9a1782a3

### Article author

@dotnet-bot

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.