Skip to content

Conversation

tmds
Copy link

@tmds tmds commented Sep 26, 2025

This changes the array size type to 'int' so it matches the 'int32_t' native type.

This was typed as an enum.
The enum type is accepted by CoreCLR.
Mono throws a MarshalDirectiveException because it requires the array size to be an integral type.

Fixes dotnet/runtime#119991.

@rainersigwald ptal

cc @jkotas @medhatiwari @giritrivedi

This changes the array size type to 'int' so it matches the 'int32_t' native type.

This was typed as an enum.
The enum type is accepted by CoreCLR.
Mono throws a MarshalDirectiveException because it requires the array size to be an integral type.
Copy link

@Copilot 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

Fixes a marshaling compatibility issue between CoreCLR and Mono by changing the array size parameter type from an enum to int in the hostfxr_get_available_sdks_result_fn delegate. This change ensures Mono can properly marshal the unmanaged function pointer, as Mono requires array size parameters to be integral types while CoreCLR accepts enum types.

  • Changes array size parameter type from hostfxr_resolve_sdk2_result_key_t enum to int
  • Maintains compatibility with the native int32_t type
  • Resolves MarshalDirectiveException thrown by Mono runtime

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Mono] System.Runtime.InteropServices.MarshalDirectiveException
3 participants