Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 13, 2025

Fixes #48902

This PR adds documentation for a breaking change in .NET 10 Preview 3 where Type.MakeGenericSignatureType now validates that the genericTypeDefinition argument is actually a generic type definition.

Changes

Previous Behavior

The Type.MakeGenericSignatureType API accepted any type for the genericTypeDefinition argument, including non-generic types, which resulted in non-sensical behavior.

New Behavior

Starting in .NET 10, the API requires the genericTypeDefinition argument to be a generic type definition and throws an ArgumentException if the validation fails.

Recommended Action

Developers should check if a type is a generic type definition before calling the API:

// Before
Type instantiatedType = Type.MakeGenericSignatureType(originalType, instantiation);

// After
Type instantiatedType = originalType.IsGenericTypeDefinition 
    ? Type.MakeGenericSignatureType(originalType, instantiation) 
    : originalType;

Files Changed

  • Created new breaking change document: docs/core/compatibility/reflection/10/makegeneric-signaturetype-validation.md
  • Updated docs/core/compatibility/10.0.md to add entry in Core .NET libraries section
  • Updated docs/core/compatibility/toc.yml to add new Reflection section under .NET 10

This is a behavioral breaking change that affects the System.Type.MakeGenericSignatureType API.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Breaking change] Type.MakeGenericSignatureType argument validation</issue_title>
<issue_description>### Description

Starting in .NET 10 Preview 3, Type.MakeGenericSignatureType API validates that the genericTypeDefinition argument is in fact a generic type definition.

Version

.NET 10 Preview 3

Previous behavior

Type.MakeGenericSignatureType accepted any type for the genericTypeDefinition argument.

New behavior

Type.MakeGenericSignatureType requires genericTypeDefinition argument to be a generic type definition and throws ArgumentException otherwise.

Type of breaking change

  • Behavioral change: Existing binaries might behave differently at runtime.

Reason for change

The type created by Type.MakeGenericSignatureType had non-sensical behavior when the genericTypeDefinition argument was not a generic type definition.

Recommended action

Avoid calling Type.MakeGenericSignatureType for types that are not generic type definitions. For example:

// Before
Type instantiatedType = Type.MakeGenericSignatureType(originalType, instantiation);

// After
Type instantiatedType = originalType.IsGenericTypeDefinition ? Type.MakeGenericSignatureType(originalType, instantiation) : originalType;

Affected APIs

  • System.Type.MakeGenericSignatureType

Associated WorkItem - 496357</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #48902


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/core/compatibility/10.0.md docs/core/compatibility/10.0
docs/core/compatibility/reflection/10/makegeneric-signaturetype-validation.md docs/core/compatibility/reflection/10/makegeneric-signaturetype-validation
docs/core/compatibility/toc.yml docs/core/compatibility/toc

Copilot AI changed the title [WIP] Fix argument validation for Type.MakeGenericSignatureType Document breaking change for Type.MakeGenericSignatureType argument validation in .NET 10 Preview 3 Oct 13, 2025
Copilot AI requested a review from gewarren October 13, 2025 19:59
Copilot finished work on behalf of gewarren October 13, 2025 19:59
…d remove Preview 3 from New behavior section

Co-authored-by: gewarren <[email protected]>
Copilot AI requested a review from gewarren October 14, 2025 01:14
Copilot finished work on behalf of gewarren October 14, 2025 01:14
@gewarren gewarren requested a review from jkotas October 14, 2025 01:49
@gewarren gewarren marked this pull request as ready for review October 14, 2025 01:49
@gewarren gewarren requested a review from a team as a code owner October 14, 2025 01:49
@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 01:49
Copy link
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

This PR documents a breaking change in .NET 10 Preview 3 where Type.MakeGenericSignatureType now validates that the genericTypeDefinition argument is actually a generic type definition, throwing an ArgumentException if validation fails.

  • Creates comprehensive documentation for the breaking change with proper API references and code examples
  • Updates the compatibility documentation index to include the new breaking change entry
  • Adds a new Reflection section to the .NET 10 compatibility table of contents

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
docs/core/compatibility/toc.yml Adds new Reflection section under .NET 10 with entry for the breaking change
docs/core/compatibility/reflection/10/makegeneric-signaturetype-validation.md Creates the main breaking change documentation with detailed explanation and examples
docs/core/compatibility/10.0.md Adds entry to the Core .NET libraries section referencing the new breaking change document

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks

@jkotas jkotas merged commit 806fd67 into main Oct 14, 2025
18 checks passed
@jkotas jkotas deleted the copilot/fix-type-makegeneric-signaturetype branch October 14, 2025 02:18
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.

[Breaking change] Type.MakeGenericSignatureType argument validation

3 participants