Skip to content

Document .NET 11 ConstructorInfo.GetGenericArguments behavior change#12616

Merged
max-charlamb merged 3 commits into
dotnet:mainfrom
max-charlamb:fix-getgenericarguments-constructorinfo
May 13, 2026
Merged

Document .NET 11 ConstructorInfo.GetGenericArguments behavior change#12616
max-charlamb merged 3 commits into
dotnet:mainfrom
max-charlamb:fix-getgenericarguments-constructorinfo

Conversation

@max-charlamb
Copy link
Copy Markdown
Member

@max-charlamb max-charlamb commented May 12, 2026

Summary

Updates the MethodBase.GetGenericArguments reference docs to reflect the .NET 11 behavior change in dotnet/runtime#128059 (which fixes dotnet/runtime#128041).

Previously, MethodBase.GetGenericArguments docs claimed the method throws NotSupportedException when invoked on a ConstructorInfo. As of .NET 11, ConstructorInfo overrides this method to return an empty array.

The remarks and exception text are updated to describe both behaviors:

  • .NET Framework and .NET (Core) 5.0 through 10.0: throws NotSupportedException on a ConstructorInfo.
  • .NET 11+: returns an empty array.

Notes for reviewers

…ehavior

MethodBase.GetGenericArguments docs claim that the method throws NotSupportedException when invoked on a ConstructorInfo. As of .NET 11, ConstructorInfo overrides this method to return an empty array (dotnet/runtime commit 6f0b75bf277, fixes #128041).

Update the remarks and exception text to describe both behaviors: .NET Framework and .NET 5-10 throw on a ConstructorInfo; .NET 11+ returns an empty array.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 12, 2026
@max-charlamb max-charlamb added area-System.Reflection and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels May 12, 2026
Comment thread xml/System.Reflection/MethodBase.xml Outdated
Comment thread xml/System.Reflection/MethodBase.xml Outdated
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Comment thread xml/System.Reflection/MethodBase.xml Outdated
@steveisok steveisok self-requested a review May 13, 2026 00:11
@max-charlamb max-charlamb marked this pull request as ready for review May 13, 2026 00:22
@max-charlamb max-charlamb requested a review from a team as a code owner May 13, 2026 00:22
Copilot AI review requested due to automatic review settings May 13, 2026 00:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the API reference documentation for System.Reflection.MethodBase.GetGenericArguments() to reflect the .NET 11 runtime behavior change where calling it on a ConstructorInfo now returns an empty array (instead of throwing NotSupportedException in earlier versions).

Changes:

  • Add remarks describing constructor-specific behavior differences between .NET 11+ and .NET 10 and earlier.
  • Adjust the NotSupportedException documentation text for GetGenericArguments().
Comments suppressed due to low confidence (1)

xml/System.Reflection/MethodBase.xml:515

  • The NotSupportedException description is now too generic and no longer explains the real-world case that triggers it (historically: calling on a ConstructorInfo in .NET Framework / .NET 10 and earlier). Please describe the actual condition(s) under which this exception is thrown, and consider adding version-qualified wording so the exception docs remain accurate for .NET 11+ where ConstructorInfo returns an empty array.
        <exception cref="T:System.NotSupportedException">This method is not overridden in a derived class.</exception>

Comment thread xml/System.Reflection/MethodBase.xml
@max-charlamb max-charlamb merged commit 29b218e into dotnet:main May 13, 2026
10 checks passed
@max-charlamb max-charlamb deleted the fix-getgenericarguments-constructorinfo branch May 13, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetGenericArguments throws NotSupportedException on ConstructorInfo

5 participants