dotnet/runtime

[mono] System.Reflection.Emit doesn't propagate marshalling attributes to the created type

Open

#58,783 创建于 2021年9月8日

在 GitHub 查看
 (13 评论) (0 反应) (0 负责人)C# (5,445 fork)batch import
area-VM-reflection-monohelp wanted

仓库指标

Star
 (17,886 star)
PR 合并指标
 (平均合并 12天 11小时) (30 天内合并 661 个 PR)

描述

See the comment below for a concise repro: https://github.com/dotnet/runtime/issues/58783#issuecomment-915439461

Some values relevant to marshaling from a StructLayoutAttribute and MarshalAsAttribute are not propagated to the dynamically created type.


Original bug report:

I tested it in Xamarin, but dotnet runtime also exists:

B8e011799c6fc43a1b8891993a90da9ac637658856013765092_20210830-100000-image B9efe2a3af0c148e0b69db8730f9537f8637658856958724359_20210830-100135-image Bf65da309c9ed4158be6cbdc4474836fe637658858144282684_20210830-100333-image

The correct size should be 100, which is correct on .net framework but wrong on mono. When I debug this code with mono on win, I found that this error is related to mono’s implementation of DynamicImage, which is caused by the attribute not being successfully applied during marshal.

贡献者指南