Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 5, 2025

  • Understand the issue: Type.IsVisible and Type.ContainsGenericParameters don't handle function pointers correctly
  • Modify ContainsGenericParameters in Type.Helpers.cs to check function pointer return and parameter types
  • Modify IsVisible in Type.Helpers.cs to check function pointer return and parameter types
  • Add tests for function pointer visibility with private types
  • Add tests for function pointer ContainsGenericParameters with generic types
  • Build and test the changes
  • Run code review and address feedback
  • Run CodeQL checker
Original prompt

This section details on the original issue you should resolve

<issue_title>Abstract implementations of Type.IsVisible and Type.ContainsGenericParameters do not handle function pointers</issue_title>
<issue_description>### Description

Abstract implementations of Type.IsVisible and Type.ContainsGenericParameters do not handle function pointers

Reproduction Steps

unsafe
{
    Console.WriteLine(typeof(delegate* <string>).IsVisible);
    Console.WriteLine(typeof(delegate* <PrivateType>).IsVisible);
}


class PrivateType { }

Expected behavior

true false with dotnet run (correct).

Actual behavior

true true with PublishAot=true

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response</issue_description>

<agent_instructions>Handle function pointers in these two methods in Type.Helpers.cs. Make sure to add tests</agent_instructions>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix Type.IsVisible and Type.ContainsGenericParameters for function pointers Fix Type.IsVisible and Type.ContainsGenericParameters for function pointers Dec 5, 2025
Copilot AI requested a review from jkotas December 5, 2025 14:44
Copilot finished work on behalf of jkotas December 5, 2025 14:45
@jkotas jkotas marked this pull request as ready for review December 5, 2025 14:48
Copilot AI review requested due to automatic review settings December 5, 2025 14:48
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Dec 5, 2025

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copilot finished reviewing on behalf of jkotas December 5, 2025 14:50
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 fixes bugs in the abstract implementations of Type.IsVisible and Type.ContainsGenericParameters that caused incorrect results for function pointer types in NativeAOT.

Key Changes:

  • Added function pointer handling to ContainsGenericParameters to check return and parameter types
  • Added function pointer handling to IsVisible to validate visibility of return and parameter types
  • Added comprehensive test coverage for function pointer visibility scenarios

Reviewed changes

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

File Description
src/libraries/System.Private.CoreLib/src/System/Type.Helpers.cs Adds function pointer checks to ContainsGenericParameters and IsVisible properties to recursively validate return and parameter types
src/libraries/Common/tests/System/FunctionPointerTests.cs Adds FunctionPointerVisibility test with scenarios for public/private return types and parameters, plus supporting test fields in FunctionPointerHolder

Copilot AI requested a review from jkotas December 6, 2025 05:58
Copilot AI requested a review from jkotas December 7, 2025 00:31
Copilot finished work on behalf of jkotas December 7, 2025 00:31
Copilot AI requested a review from jkotas December 7, 2025 00:57
Copilot finished work on behalf of jkotas December 7, 2025 00:57
Copilot AI requested a review from stephentoub December 7, 2025 13:38
Copilot finished work on behalf of stephentoub December 7, 2025 13:38
@stephentoub stephentoub enabled auto-merge (squash) December 7, 2025 13:41
@stephentoub stephentoub merged commit 3114f8e into main Dec 7, 2025
137 of 142 checks passed
@jkotas jkotas deleted the copilot/fix-function-pointer-visibility branch December 7, 2025 15:59
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.

Abstract implementations of Type.IsVisible and Type.ContainsGenericParameters do not handle function pointers

3 participants