Skip to content

Add unit test for issue #7346 (custom attribute constructor crash on null array of enums)#120641

Merged
jkotas merged 5 commits intomainfrom
copilot/add-unit-test-for-enum-crash
Oct 12, 2025
Merged

Add unit test for issue #7346 (custom attribute constructor crash on null array of enums)#120641
jkotas merged 5 commits intomainfrom
copilot/add-unit-test-for-enum-crash

Conversation

Copy link
Contributor

Copilot AI commented Oct 11, 2025

Plan to add unit test for issue #7346 (custom attribute constructor crash on null array of enums):

  • Understand the issue: Issue Additional BotR Chapters #7346 was about a crash when a custom attribute constructor has a null array of enums
  • Baseline setup: Build clr+libs successfully
  • Configure PATH and verify SDK version
  • Add a custom attribute class that accepts null enum array in constructor
  • Add test method to verify the attribute can be retrieved without crashing
  • Build the System.Runtime tests
  • Run the tests to verify they pass - all CustomAttributeDataTests pass (8 tests)
  • Apply code review suggestions - improved test coverage with multiple array scenarios
  • Fix build break by adding using statement for ReadOnlyCollection
  • Commit the changes
Original prompt

This section details on the original issue you should resolve

<issue_title>Add unit test for issue #7346 (custom attribute constructor crash on null array of enums)</issue_title>
<issue_description>Just need to wait for the fix in coreclr to propagate over to corefx.

https://github.com/dotnet/coreclr/issues/7346
</issue_description>

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

@karelz @atsushikan I unassigned it from you to reflect 'up for grabs'. If/when you work on it, please assign it to yourself. Thanks!

Fixes #18847


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit test for custom attribute constructor crash Add unit test for issue #7346 (custom attribute constructor crash on null array of enums) Oct 11, 2025
Copilot AI requested a review from stephentoub October 11, 2025 18:51
@stephentoub stephentoub marked this pull request as ready for review October 11, 2025 19:36
Copilot AI review requested due to automatic review settings October 11, 2025 19:36
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 adds a unit test to verify that a crash issue with custom attribute constructors receiving null arrays of enums has been fixed. The issue (dotnet/coreclr#7346) caused crashes when custom attributes with null enum array parameters were processed through reflection.

  • Adds a test case that applies a custom attribute with a null enum array parameter and verifies it can be retrieved safely
  • Introduces supporting types (MyTestEnum and MyEnumArrayAttribute) for the test
  • Validates that the fix prevents crashes and correctly handles null array values in custom attribute reflection

@stephentoub stephentoub added area-System.Reflection test-enhancement Improvements of test source code labels Oct 11, 2025
@stephentoub stephentoub enabled auto-merge (squash) October 11, 2025 19:45
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
auto-merge was automatically disabled October 12, 2025 00:51

Head branch was pushed to by a user without write access

Copilot AI requested a review from jkotas October 12, 2025 00:52
@jkotas jkotas merged commit 7999785 into main Oct 12, 2025
83 of 86 checks passed
@jkotas jkotas deleted the copilot/add-unit-test-for-enum-crash branch October 12, 2025 05:44
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Reflection test-enhancement Improvements of test source code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit test for issue #7346 (custom attribute constructor crash on null array of enums)

4 participants