Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Runtime
提交
414e1a74
R
Runtime
项目概览
jobily
/
Runtime
9 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
414e1a74
编写于
9月 01, 2023
作者:
F
Fan Yang
提交者:
GitHub
9月 01, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix offset calculation for nested struct, when pinvoke is enabled (#91422)
上级
483490d4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
137 addition
and
2 deletion
+137
-2
src/mono/mono/mini/mini-amd64.c
src/mono/mono/mini/mini-amd64.c
+2
-2
src/tests/Interop/StructMarshalling/PInvoke/GameControllerButtonBind.cs
...rop/StructMarshalling/PInvoke/GameControllerButtonBind.cs
+63
-0
src/tests/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.cpp
...rop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.cpp
+5
-0
src/tests/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h
...terop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h
+23
-0
src/tests/Interop/StructMarshalling/PInvoke/NestedStruct.cs
src/tests/Interop/StructMarshalling/PInvoke/NestedStruct.cs
+27
-0
src/tests/Interop/StructMarshalling/PInvoke/NestedStruct.csproj
...sts/Interop/StructMarshalling/PInvoke/NestedStruct.csproj
+14
-0
src/tests/issues.targets
src/tests/issues.targets
+3
-0
未找到文件。
src/mono/mono/mini/mini-amd64.c
浏览文件 @
414e1a74
...
...
@@ -355,7 +355,7 @@ collect_field_info_nested (MonoClass *klass, GArray *fields_array, int offset, g
g_assert
(
info
);
for
(
guint32
i
=
0
;
i
<
info
->
num_fields
;
++
i
)
{
if
(
MONO_TYPE_ISSTRUCT
(
info
->
fields
[
i
].
field
->
type
))
{
collect_field_info_nested
(
mono_class_from_mono_type_internal
(
info
->
fields
[
i
].
field
->
type
),
fields_array
,
info
->
fields
[
i
].
offset
,
pinvoke
,
unicode
);
collect_field_info_nested
(
mono_class_from_mono_type_internal
(
info
->
fields
[
i
].
field
->
type
),
fields_array
,
(
offset
+
info
->
fields
[
i
].
offset
)
,
pinvoke
,
unicode
);
}
else
{
guint32
align
;
StructFieldInfo
f
;
...
...
@@ -365,7 +365,7 @@ collect_field_info_nested (MonoClass *klass, GArray *fields_array, int offset, g
info
->
fields
[
i
].
mspec
,
&
align
,
TRUE
,
unicode
);
f
.
offset
=
offset
+
info
->
fields
[
i
].
offset
;
if
(
i
==
info
->
num_fields
-
1
&&
f
.
size
+
f
.
offset
<
info
->
native_size
)
{
if
(
(
i
==
info
->
num_fields
-
1
)
&&
((
f
.
size
+
f
.
offset
)
<
info
->
native_size
)
)
{
/* This can happen with .pack directives eg. 'fixed' arrays */
if
(
MONO_TYPE_IS_PRIMITIVE
(
f
.
type
))
{
/* Replicate the last field to fill out the remaining place, since the code in add_valuetype () needs type information */
...
...
src/tests/Interop/StructMarshalling/PInvoke/GameControllerButtonBind.cs
0 → 100644
浏览文件 @
414e1a74
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using
System
;
using
System.Runtime.InteropServices
;
using
System.Runtime.CompilerServices
;
using
System.Text
;
public
unsafe
partial
struct
GameControllerButtonBind
{
public
GameControllerButtonBind
(
GameControllerBindType
?
bindType
=
null
,
GameControllerButtonBindValue
?
value
=
null
)
:
this
()
{
if
(
bindType
is
not
null
)
{
BindType
=
bindType
.
Value
;
}
if
(
value
is
not
null
)
{
Value
=
value
.
Value
;
}
}
public
GameControllerBindType
BindType
;
public
GameControllerButtonBindValue
Value
;
}
public
enum
GameControllerBindType
:
int
{
ControllerBindtypeNone
=
0x0
,
ControllerBindtypeButton
=
0x1
,
ControllerBindtypeAxis
=
0x2
,
ControllerBindtypeHat
=
0x3
,
None
=
0x0
,
Button
=
0x1
,
Axis
=
0x2
,
Hat
=
0x3
,
}
[
StructLayout
(
LayoutKind
.
Explicit
)]
public
unsafe
partial
struct
GameControllerButtonBindValue
{
[
FieldOffset
(
0
)]
public
int
Button
;
[
FieldOffset
(
0
)]
public
int
Axis
;
[
FieldOffset
(
0
)]
public
GameControllerButtonBindValueHat
Hat
;
}
public
unsafe
partial
struct
GameControllerButtonBindValueHat
{
public
int
Hat
;
public
int
HatMask
;
}
src/tests/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.cpp
浏览文件 @
414e1a74
...
...
@@ -1297,3 +1297,8 @@ extern "C" DLL_EXPORT Int32CLongStruct STDMETHODCALLTYPE AddCLongs(Int32CLongStr
{
return
{
lhs
.
i
+
rhs
.
i
,
lhs
.
l
+
rhs
.
l
};
}
extern
"C"
DLL_EXPORT
SDL_GameControllerBindType
STDMETHODCALLTYPE
getBindType
(
SDL_GameControllerButtonBind
button
)
{
return
button
.
bindType
;
}
src/tests/Interop/StructMarshalling/PInvoke/MarshalStructAsParamDLL.h
浏览文件 @
414e1a74
...
...
@@ -974,3 +974,26 @@ struct Int32CLongStruct
int32_t
i
;
long
l
;
};
typedef
enum
{
SDL_CONTROLLER_BINDTYPE_NONE
=
0
,
SDL_CONTROLLER_BINDTYPE_BUTTON
,
SDL_CONTROLLER_BINDTYPE_AXIS
,
SDL_CONTROLLER_BINDTYPE_HAT
}
SDL_GameControllerBindType
;
typedef
struct
SDL_GameControllerButtonBind
{
SDL_GameControllerBindType
bindType
;
union
{
int
button
;
int
axis
;
struct
{
int
hat
;
int
hat_mask
;
}
hat
;
}
value
;
}
SDL_GameControllerButtonBind
;
src/tests/Interop/StructMarshalling/PInvoke/NestedStruct.cs
0 → 100644
浏览文件 @
414e1a74
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using
System
;
using
System.Runtime.InteropServices
;
using
Xunit
;
public
class
Managed
{
[
DllImport
(
"MarshalStructAsParam"
)]
static
extern
GameControllerBindType
getBindType
(
GameControllerButtonBind
button
);
public
static
int
Main
()
{
GameControllerButtonBind
button
=
new
GameControllerButtonBind
(
GameControllerBindType
.
ControllerBindtypeAxis
,
null
);
if
(
getBindType
(
button
)
==
GameControllerBindType
.
ControllerBindtypeAxis
)
{
Console
.
WriteLine
(
"\nTEST PASSED!"
);
return
100
;
}
else
{
Console
.
WriteLine
(
"\nTEST FAILED!"
);
return
1
;
}
}
}
src/tests/Interop/StructMarshalling/PInvoke/NestedStruct.csproj
0 → 100644
浏览文件 @
414e1a74
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="NestedStruct.cs" />
<Compile Include="GameControllerButtonBind.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
<CMakeProjectReference Include="CMakeLists.txt" />
</ItemGroup>
</Project>
src/tests/issues.targets
浏览文件 @
414e1a74
...
...
@@ -4062,6 +4062,9 @@
<ExcludeList
Include=
"$(XunitTestBinBase)/Interop/MonoAPI/**"
>
<Issue>
mobile and wasm don't support tests with native libraries. wasm also needs static linking
</Issue>
</ExcludeList>
<ExcludeList
Include=
"$(XunitTestBinBase)/Interop/StructMarshalling/PInvoke/NestedStruct/**"
>
<Issue>
https://github.com/dotnet/runtime/issues/64127
</Issue>
</ExcludeList>
</ItemGroup>
<Target
Name=
"GetFilteredExcludeList"
Returns=
"@(FilteredExcludeList)"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录