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

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

Open
kevinms99 opened this issue Jan 24, 2025 · 0 comments
Labels
area-System.Reflection untriaged New issue has not been triaged by the area owner

Comments

@kevinms99
Copy link

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:

interface IInterface<T> { }
interface ISecond<T> {
  IInterface<T> 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<T> 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

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Reflection untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

1 participant