File tree Expand file tree Collapse file tree 9 files changed +53
-14
lines changed
System.Reflection.Metadata/tests/Metadata/Decoding
System.Reflection.MetadataLoadContext/tests/src/Tests
System.Diagnostics.Debug.Tests
System.Runtime.Tests/System Expand file tree Collapse file tree 9 files changed +53
-14
lines changed Original file line number Diff line number Diff line change 125
125
<_ApplePropertyNames Include =" UseConsoleUITemplate" />
126
126
<_ApplePropertyNames Include =" UseRuntimeComponents" />
127
127
<_ApplePropertyNames Include =" IncludesTestRunner" />
128
+ <_ApplePropertyNames Include =" ShouldILStrip" />
128
129
129
130
<_ApplePropertiesToPass
130
131
Include =" $(%(_ApplePropertyNames.Identity))"
Original file line number Diff line number Diff line change @@ -258,14 +258,17 @@ public void PinnedAndUnpinnedLocals()
258
258
Assert . Equal ( "DoSomething" , reader . GetString ( methodDef . Name ) ) ;
259
259
260
260
MethodBodyBlock body = peReader . GetMethodBody ( methodDef . RelativeVirtualAddress ) ;
261
- StandaloneSignature localSignature = reader . GetStandaloneSignature ( body . LocalSignature ) ;
262
-
263
- ImmutableArray < string > localTypes = localSignature . DecodeLocalSignature ( provider , genericContext : null ) ;
264
-
265
- // Compiler can generate temporaries or re-order so just check the ones we expect are there.
266
- // (They could get optimized away too. If that happens in practice, change this test to use hard-coded signatures.)
267
- Assert . Contains ( "uint8[] pinned" , localTypes ) ;
268
- Assert . Contains ( "uint8[]" , localTypes ) ;
261
+ var il = body . GetILBytes ( ) ;
262
+ // ILStrip replaces method body with the 'ret' IL opcode i.e. 0x2a
263
+ if ( ! ( il ? . Length == 1 && il [ 0 ] == 0x2a ) ) {
264
+ StandaloneSignature localSignature = reader . GetStandaloneSignature ( body . LocalSignature ) ;
265
+ ImmutableArray < string > localTypes = localSignature . DecodeLocalSignature ( provider , genericContext : null ) ;
266
+
267
+ // Compiler can generate temporaries or re-order so just check the ones we expect are there.
268
+ // (They could get optimized away too. If that happens in practice, change this test to use hard-coded signatures.)
269
+ Assert . Contains ( "uint8[] pinned" , localTypes ) ;
270
+ Assert . Contains ( "uint8[]" , localTypes ) ;
271
+ }
269
272
}
270
273
}
271
274
Original file line number Diff line number Diff line change @@ -31,7 +31,15 @@ private static void TestConstructors1Worker(Type t)
31
31
Assert . False ( c . IsConstructedGenericMethod ( ) ) ;
32
32
Assert . False ( c . IsGenericMethod ) ;
33
33
Assert . Equal ( MethodAttributes . Public | MethodAttributes . HideBySig | MethodAttributes . SpecialName | MethodAttributes . RTSpecialName , c . Attributes ) ;
34
- Assert . Equal ( MethodImplAttributes . IL , c . MethodImplementationFlags ) ;
34
+ if ( c . MethodImplementationFlags . HasFlag ( MethodImplAttributes . NoInlining ) )
35
+ {
36
+ // when the assembly was processed with ILStrip, the NoInlining flag is set
37
+ Assert . Equal ( MethodImplAttributes . IL | MethodImplAttributes . NoInlining , c . MethodImplementationFlags ) ;
38
+ }
39
+ else
40
+ {
41
+ Assert . Equal ( MethodImplAttributes . IL , c . MethodImplementationFlags ) ;
42
+ }
35
43
Assert . Equal ( CallingConventions . Standard | CallingConventions . HasThis , c . CallingConvention ) ;
36
44
37
45
ParameterInfo [ ] ps = c . GetParameters ( ) ;
Original file line number Diff line number Diff line change @@ -30,7 +30,15 @@ private static void TestMethods1Worker(Type t)
30
30
Assert . False ( m . IsConstructedGenericMethod ( ) ) ;
31
31
Assert . False ( m . IsGenericMethod ) ;
32
32
Assert . Equal ( MethodAttributes . Public | MethodAttributes . HideBySig , m . Attributes ) ;
33
- Assert . Equal ( MethodImplAttributes . IL , m . MethodImplementationFlags ) ;
33
+ if ( m . MethodImplementationFlags . HasFlag ( MethodImplAttributes . NoInlining ) )
34
+ {
35
+ // when the assembly was processed with ILStrip, the NoInlining flag is set
36
+ Assert . Equal ( MethodImplAttributes . IL | MethodImplAttributes . NoInlining , m . MethodImplementationFlags ) ;
37
+ }
38
+ else
39
+ {
40
+ Assert . Equal ( MethodImplAttributes . IL , m . MethodImplementationFlags ) ;
41
+ }
34
42
Assert . Equal ( CallingConventions . Standard | CallingConventions . HasThis , m . CallingConvention ) ;
35
43
36
44
Type theT = t . GetGenericArguments ( ) [ 0 ] ;
Original file line number Diff line number Diff line change 5
5
<TestRuntime >true</TestRuntime >
6
6
<!-- Some tests need types like System.Diagnostics.DebugProvider which are only exposed from System.Private.CoreLib -->
7
7
<CompileUsingReferenceAssemblies >false</CompileUsingReferenceAssemblies >
8
+ <!-- Active issue: https://github.com/dotnet/runtime/issues/87740 -->
9
+ <ShouldILStrip >false</ShouldILStrip >
8
10
</PropertyGroup >
9
11
<ItemGroup >
10
12
<DefaultReferenceExclusion Include =" System.Collections" />
Original file line number Diff line number Diff line change 3
3
4
4
using System ;
5
5
using System . Reflection ;
6
+ using Microsoft . DotNet . XUnitExtensions ;
6
7
using Xunit ;
7
8
8
9
#pragma warning disable 0219 // field is never used
@@ -55,6 +56,9 @@ public static void TestMethodBody()
55
56
{
56
57
MethodBase mbase = typeof ( MethodBaseTests ) . GetMethod ( "MyOtherMethod" , BindingFlags . Static | BindingFlags . Public ) ;
57
58
MethodBody mb = mbase . GetMethodBody ( ) ;
59
+ var il = mb . GetILAsByteArray ( ) ;
60
+ if ( il ? . Length == 1 && il [ 0 ] == 0x2a ) // ILStrip replaces method bodies with the 'ret' IL opcode i.e. 0x2a
61
+ throw new SkipTestException ( "The method body was processed using ILStrip." ) ;
58
62
var codeSize = mb . GetILAsByteArray ( ) . Length ;
59
63
Assert . True ( mb . InitLocals ) ; // local variables are initialized
60
64
Original file line number Diff line number Diff line change 3
3
4
4
using System ;
5
5
using System . Reflection ;
6
+ using Microsoft . DotNet . XUnitExtensions ;
6
7
using Xunit ;
7
8
8
9
#pragma warning disable 0219 // field is never used
@@ -17,6 +18,10 @@ public static void Test_MethodBody_ExceptionHandlingClause()
17
18
MethodInfo mi = typeof ( MethodBodyTests ) . GetMethod ( "MethodBodyExample" , BindingFlags . NonPublic | BindingFlags . Static ) ;
18
19
MethodBody mb = mi . GetMethodBody ( ) ;
19
20
21
+ var il = mb . GetILAsByteArray ( ) ;
22
+ if ( il ? . Length == 1 && il [ 0 ] == 0x2a ) // ILStrip replaces method bodies with the 'ret' IL opcode i.e. 0x2a
23
+ throw new SkipTestException ( "The method body was processed using ILStrip." ) ;
24
+
20
25
Assert . True ( mb . InitLocals ) ; // local variables are initialized
21
26
#if DEBUG
22
27
Assert . Equal ( 2 , mb . MaxStackSize ) ;
Original file line number Diff line number Diff line change @@ -13,8 +13,17 @@ public static class MethodImplAttributeTests
13
13
public static void AggressiveOptimizationTest ( )
14
14
{
15
15
MethodImplAttributes implAttributes = MethodBase . GetCurrentMethod ( ) . MethodImplementationFlags ;
16
- Assert . Equal ( MethodImplAttributes . AggressiveOptimization , implAttributes ) ;
17
- Assert . Equal ( MethodImplOptions . AggressiveOptimization , ( MethodImplOptions ) implAttributes ) ;
16
+ if ( implAttributes . HasFlag ( MethodImplAttributes . NoInlining ) )
17
+ {
18
+ // when the assembly was processed with ILStrip, the NoInlining flag is set
19
+ Assert . Equal ( MethodImplAttributes . AggressiveOptimization | MethodImplAttributes . NoInlining , implAttributes ) ;
20
+ Assert . Equal ( MethodImplOptions . AggressiveOptimization | MethodImplOptions . NoInlining , ( MethodImplOptions ) implAttributes ) ;
21
+ }
22
+ else
23
+ {
24
+ Assert . Equal ( MethodImplAttributes . AggressiveOptimization , implAttributes ) ;
25
+ Assert . Equal ( MethodImplOptions . AggressiveOptimization , ( MethodImplOptions ) implAttributes ) ;
26
+ }
18
27
}
19
28
}
20
29
}
Original file line number Diff line number Diff line change 16
16
<UseMonoJustInterp Condition =" '$(RunAOTCompilation)' == 'true' and '$(MonoForceInterpreter)' == 'true'" >true</UseMonoJustInterp >
17
17
18
18
<StripDebugSymbols Condition =" '$(StripDebugSymbols)' == ''" >false</StripDebugSymbols >
19
- <!-- Tracking issue: https://github.com/dotnet/runtime/issues/87740 -->
20
- <!-- <ShouldILStrip Condition="'$(RunAOTCompilation)' == 'true' and '$(MonoForceInterpreter)' != 'true'">true</ShouldILStrip> -->
21
19
22
20
<!-- TODO: We currently do not support bundling a static iOS-library with NativeAOT -->
23
21
<_IsLibraryMode Condition =" ('$(UseNativeAOTRuntime)' != 'true' and '$(NativeLib)' != '') or ('$(UseNativeAOTRuntime)' == 'true' and '$(NativeLib)' == 'Shared')" >true</_IsLibraryMode >
22
+ <ShouldILStrip Condition =" '$(ShouldILStrip)' == '' and '$(RunAOTCompilation)' == 'true' and '$(MonoForceInterpreter)' != 'true' and '$(_IsLibraryMode)' != 'true'" >true</ShouldILStrip >
24
23
25
24
<_AotCompileTargetName Condition =" '$(UseNativeAOTRuntime)' == 'true'" >_AppleNativeAotCompile</_AotCompileTargetName >
26
25
<_AotCompileTargetName Condition =" '$(UseNativeAOTRuntime)' != 'true'" >_AppleAotCompile</_AotCompileTargetName >
You can’t perform that action at this time.
0 commit comments