Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
f8a1a6c1
R
runtime
项目概览
dotNET Platform
/
runtime
12 个月 前同步成功
通知
1
Star
1
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,发现更多精彩内容 >>
未验证
提交
f8a1a6c1
编写于
8月 09, 2023
作者:
A
Aaron Robinson
提交者:
GitHub
8月 09, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix up `InlineArray` tests (#90192)
* Convert invalid C# to IL project
上级
6f40dbb8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
133 addition
and
89 deletion
+133
-89
src/tests/Loader/classloader/InlineArray/InlineArrayInvalid.cs
...ests/Loader/classloader/InlineArray/InlineArrayInvalid.cs
+0
-34
src/tests/Loader/classloader/InlineArray/InlineArrayInvalid.csproj
.../Loader/classloader/InlineArray/InlineArrayInvalid.csproj
+1
-2
src/tests/Loader/classloader/InlineArray/InlineArrayValid.cs
src/tests/Loader/classloader/InlineArray/InlineArrayValid.cs
+13
-51
src/tests/Loader/classloader/InlineArray/InlineArrayValid.csproj
...ts/Loader/classloader/InlineArray/InlineArrayValid.csproj
+1
-2
src/tests/Loader/classloader/InlineArray/InvalidCSharp.il
src/tests/Loader/classloader/InlineArray/InvalidCSharp.il
+110
-0
src/tests/Loader/classloader/InlineArray/InvalidCSharp.ilproj
...tests/Loader/classloader/InlineArray/InvalidCSharp.ilproj
+8
-0
未找到文件。
src/tests/Loader/classloader/InlineArray/InlineArrayInvalid.cs
浏览文件 @
f8a1a6c1
...
...
@@ -10,14 +10,6 @@
unsafe
class
Validate
{
[
InlineArray
(
1
)]
[
StructLayout
(
LayoutKind
.
Explicit
)]
private
struct
Explicit
{
[
FieldOffset
(
0
)]
public
Guid
Guid
;
}
[
Fact
]
public
static
void
Explicit_Fails
()
{
...
...
@@ -30,12 +22,6 @@ public static void Explicit_Fails()
});
}
[
InlineArray
(
0
)]
private
struct
ZeroLength
{
public
int
field
;
}
[
Fact
]
public
static
void
ZeroLength_Fails
()
{
...
...
@@ -74,12 +60,6 @@ public static void TooLarge_Fails()
});
}
[
InlineArray
(-
1
)]
private
struct
NegativeLength
{
public
long
field
;
}
[
Fact
]
public
static
void
NegativeLength_Fails
()
{
...
...
@@ -96,13 +76,6 @@ public static void NegativeLength_Fails()
});
}
[
InlineArray
(
123
)]
private
struct
NoFields
{
public
static
int
x
;
}
[
Fact
]
public
static
void
NoFields_Fails
()
{
...
...
@@ -115,13 +88,6 @@ public static void NoFields_Fails()
});
}
[
InlineArray
(
1
)]
private
struct
TwoFields
{
int
a
;
int
b
;
}
[
Fact
]
public
static
void
TwoFields_Fails
()
{
...
...
src/tests/Loader/classloader/InlineArray/InlineArrayInvalid.csproj
浏览文件 @
f8a1a6c1
...
...
@@ -2,13 +2,12 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Exe</OutputType>
<!-- Issue: https://github.com/dotnet/runtime/issues/88861 -->
<DisableProjectBuild>true</DisableProjectBuild>
</PropertyGroup>
<ItemGroup>
<Compile Include="InlineArrayInvalid.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="InvalidCSharp.ilproj" />
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
</ItemGroup>
</Project>
src/tests/Loader/classloader/InlineArray/InlineArrayValid.cs
浏览文件 @
f8a1a6c1
...
...
@@ -22,18 +22,6 @@ struct MyArray<T> : IEnumerable<T>
public
int
Length
=>
LengthConst
;
[
UnscopedRef
]
public
ref
T
this
[
int
i
]
{
get
{
if
((
uint
)
i
>=
(
uint
)
Length
)
throw
new
IndexOutOfRangeException
(
nameof
(
i
));
return
ref
Unsafe
.
Add
(
ref
_element
,
i
);
}
}
[
UnscopedRef
]
public
Span
<
T
>
AsSpan
()
=>
MemoryMarshal
.
CreateSpan
<
T
>(
ref
_element
,
Length
);
...
...
@@ -107,9 +95,6 @@ struct Arr1
{
public
const
int
Length
=
42
;
public
E
e
;
[
UnscopedRef
]
public
ref
E
this
[
int
i
]
=>
ref
Unsafe
.
Add
(
ref
e
,
i
);
}
static
object
s
;
...
...
@@ -168,10 +153,7 @@ public static void UseOnStack()
struct
ObjShortArr
{
public
const
int
Length
=
100
;
public
(
object
,
short
)
element
;
[
UnscopedRef
]
public
ref
(
object
o
,
short
s
)
this
[
int
i
]
=>
ref
Unsafe
.
Add
(
ref
element
,
i
);
public
(
object
o
,
short
s
)
element
;
[
MethodImpl
(
MethodImplOptions
.
NoInlining
)]
public
static
ObjShortArr
CreateArray
(
int
recCount
)
{
...
...
@@ -219,7 +201,7 @@ public static void MixObjectsAndValuetypes()
public
(
object
,
short
)
element
;
[
UnscopedRef
]
public
ref
(
object
o
,
short
s
)
this
[
int
i
]
=>
ref
Unsafe
.
Add
(
ref
element
,
i
);
public
ref
(
object
o
,
short
s
)
At
(
int
i
)
=>
ref
Unsafe
.
Add
(
ref
element
,
i
);
}
[
MethodImpl
(
MethodImplOptions
.
NoInlining
)]
...
...
@@ -229,8 +211,8 @@ static void TestRefLikeOuterMethodArg(ObjShortArrRef arr)
for
(
short
i
=
0
;
i
<
ObjShortArrRef
.
Length
;
i
++)
{
Assert
.
Equal
(
i
*
2
,
arr
[
i
]
.
o
);
Assert
.
Equal
(
i
*
2
+
1
,
arr
[
i
]
.
s
);
Assert
.
Equal
(
i
*
2
,
arr
.
At
(
i
)
.
o
);
Assert
.
Equal
(
i
*
2
+
1
,
arr
.
At
(
i
)
.
s
);
}
}
...
...
@@ -242,48 +224,28 @@ public static void RefLikeOuter()
var
arr
=
new
ObjShortArrRef
();
for
(
short
i
=
0
;
i
<
ObjShortArrRef
.
Length
;
i
++)
{
arr
[
i
]
.
o
=
i
;
arr
[
i
]
.
s
=
(
short
)(
i
+
1
);
arr
.
At
(
i
)
.
o
=
i
;
arr
.
At
(
i
)
.
s
=
(
short
)(
i
+
1
);
}
GC
.
Collect
(
2
,
GCCollectionMode
.
Forced
,
true
,
true
);
for
(
short
i
=
0
;
i
<
ObjShortArrRef
.
Length
;
i
++)
{
Assert
.
Equal
(
i
,
arr
[
i
]
.
o
);
Assert
.
Equal
(
i
+
1
,
arr
[
i
]
.
s
);
Assert
.
Equal
(
i
,
arr
.
At
(
i
)
.
o
);
Assert
.
Equal
(
i
+
1
,
arr
.
At
(
i
)
.
s
);
}
for
(
short
i
=
0
;
i
<
ObjShortArrRef
.
Length
;
i
++)
{
arr
[
i
]
.
o
=
i
*
2
;
arr
[
i
]
.
s
=
(
short
)(
i
*
2
+
1
);
arr
.
At
(
i
)
.
o
=
i
*
2
;
arr
.
At
(
i
)
.
s
=
(
short
)(
i
*
2
+
1
);
}
TestRefLikeOuterMethodArg
(
arr
);
}
// ====================== RefLikeInner ========================================================
[
InlineArray
(
LengthConst
)]
ref
struct
SpanArr
{
private
const
int
LengthConst
=
100
;
public
Span
<
object
>
element
;
public
Span
<
object
>*
this
[
int
i
]
{
get
{
fixed
(
Span
<
object
>*
p
=
&
element
)
{
return
p
+
i
;
}
}
}
public
int
Length
=>
LengthConst
;
}
[
MethodImpl
(
MethodImplOptions
.
NoInlining
)]
static
void
TestRefLikeInnerMethodArg
(
SpanArr
arr
)
{
...
...
@@ -291,8 +253,8 @@ static void TestRefLikeInnerMethodArg(SpanArr arr)
for
(
int
i
=
1
;
i
<
arr
.
Length
;
i
++)
{
Assert
.
Equal
(
i
,
arr
[
i
]
->
Length
);
Assert
.
Equal
(
i
,
(*
arr
[
i
]
)[
0
]);
Assert
.
Equal
(
i
,
arr
.
At
(
i
)
->
Length
);
Assert
.
Equal
(
i
,
(*
arr
.
At
(
i
)
)[
0
]);
}
}
...
...
@@ -306,7 +268,7 @@ public static void RefLikeInner()
{
var
objArr
=
new
object
[
i
];
objArr
[
0
]
=
i
;
*
arr
[
i
]
=
objArr
;
*
arr
.
At
(
i
)
=
objArr
;
}
TestRefLikeInnerMethodArg
(
arr
);
...
...
src/tests/Loader/classloader/InlineArray/InlineArrayValid.csproj
浏览文件 @
f8a1a6c1
...
...
@@ -2,13 +2,12 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Exe</OutputType>
<!-- Issue: https://github.com/dotnet/runtime/issues/88861 -->
<DisableProjectBuild>true</DisableProjectBuild>
</PropertyGroup>
<ItemGroup>
<Compile Include="InlineArrayValid.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="InvalidCSharp.ilproj" />
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
</ItemGroup>
</Project>
src/tests/Loader/classloader/InlineArray/InvalidCSharp.il
0 → 100644
浏览文件 @
f8a1a6c1
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern System.Runtime { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) }
.assembly InvalidCSharp { }
.class public explicit ansi sealed beforefieldinit Explicit
extends [System.Runtime]System.ValueType
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.InlineArrayAttribute::.ctor(int32) = (
01 00 01 00 00 00 00 00
)
.field [0] public valuetype [System.Runtime]System.Guid Guid
}
.class public sequential ansi sealed beforefieldinit ZeroLength
extends [System.Runtime]System.ValueType
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.InlineArrayAttribute::.ctor(int32) = (
01 00 00 00 00 00 00 00
)
.field public int32 'field'
}
.class public sequential ansi sealed beforefieldinit TooLarge
extends [System.Runtime]System.ValueType
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.InlineArrayAttribute::.ctor(int32) = (
01 00 00 00 00 20 00 00
)
.field public int64 'field'
}
.class public sequential ansi sealed beforefieldinit NegativeLength
extends [System.Runtime]System.ValueType
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.InlineArrayAttribute::.ctor(int32) = (
01 00 ff ff ff ff 00 00
)
.field public int64 'field'
}
.class public sequential ansi sealed beforefieldinit NoFields
extends [System.Runtime]System.ValueType
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.InlineArrayAttribute::.ctor(int32) = (
01 00 7b 00 00 00 00 00
)
.pack 0
.size 1
.field public static int32 x
}
.class public sequential ansi sealed beforefieldinit TwoFields
extends [System.Runtime]System.ValueType
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.InlineArrayAttribute::.ctor(int32) = (
01 00 01 00 00 00 00 00
)
.field private int32 a
.field private int32 b
}
.class public sequential ansi sealed beforefieldinit SpanArr
extends [System.Runtime]System.ValueType
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.IsByRefLikeAttribute::.ctor() = (
01 00 00 00
)
.custom instance void [System.Runtime]System.Runtime.CompilerServices.InlineArrayAttribute::.ctor(int32) = (
01 00 64 00 00 00 00 00
)
.field private static literal int32 LengthConst = int32(100)
.field public valuetype [System.Runtime]System.Span`1<object> element
.method public hidebysig
instance valuetype [System.Runtime]System.Span`1<object>* At (
int32
) cil managed
{
.locals init (
[0] valuetype [System.Runtime]System.Span`1<object>& pinned
)
ldarg.0
ldflda valuetype [System.Runtime]System.Span`1<object> SpanArr::element
stloc.0
ldloc.0
conv.u
ldarg.1
conv.i
sizeof valuetype [System.Runtime]System.Span`1<object>
mul
add
ret
}
.method public hidebysig specialname
instance int32 get_Length () cil managed
{
ldc.i4.s 100
ret
}
.property instance int32 Length()
{
.get instance int32 SpanArr::get_Length()
}
}
src/tests/Loader/classloader/InlineArray/InvalidCSharp.ilproj
0 → 100644
浏览文件 @
f8a1a6c1
<Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<Compile Include="InvalidCSharp.il" />
</ItemGroup>
</Project>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录