[Mono]: DllImport using MarshalAs and SizeParamIndex set to an enum parameter not implemented
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- operating-systems, testing-qa
Research direction
Start with src/mono/mono/component/marshal-ilgen.c around lines 474-487, then inspect the existing SizeParamIndex tests under src/tests/. Run the relevant interop tests on the Mono runtime and add coverage using an enum parameter. Done means the test no longer raises MarshalDirectiveException and the interop test passes on Mono.
Written by the indexing model from the issue text.
Description
Description
When using an enum for a SizeParamIndex using Mono runtime, the following exception will be thrown:
MarshalDirectiveException: Array size control parameter must be an integral type.
In src/tests/ I searched for SizeParamIndex and found no test which used an enum for it.
EDIT: I think related is #35225 which covers interop tests which fail in Mono runtime but pass in CoreCLR, but a test doesn't currently exist for this enum issue.
Background context
I found this problem when building and running OmniSharp, which surfaces there in the use of microsoft/MSBuildLocator. Relevant MSBuildLocator code here:
https://github.com/microsoft/MSBuildLocator/blob/0bbf4988996176904ecc0dabb73165919fac605f/src/MSBuildLocator/NativeMethods.cs#L32
Reproduction Steps
Modify a test to use an enum for SizeParamIndex and test on Mono runtime.
Expected behavior
No exception. microsoft/MSBuildLocator wrote in issues that Mono isn't supported, it works fine on CoreCLR.
Actual behavior
See above MarshalDirectiveException.
Regression?
No response
Known Workarounds
No response
Configuration
dotnet core compiled with --use-mono-runtime.
On Android using Termux.
Other information
I think it is a one line fix, add case MONO_TYPE_ENUM to the switch here:
https://github.com/dotnet/runtime/blob/1713d65316467e3eaf23514b6642eba5869f1b70/src/mono/mono/component/marshal-ilgen.c#L474-L487
And add a SizeParamIndex test which uses an enum.
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
area-System.Reflection blocking-clean-ci-optional Known Build Error os-mac-os-x untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
agentic-workflows untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
area-VM-meta-mono untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PowerShell/PSResourceGet#2056 ·