Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1345116

Browse files
MichalStrehovskypull[bot]
authored andcommitted
Start running System.Runtime trimming tests (#101592)
1 parent8ddd276 commit1345116

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

‎src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/InvariantGlobalizationTrue.cs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
usingSystem;
55
usingSystem.Globalization;
66
usingSystem.Reflection;
7+
usingSystem.Runtime.CompilerServices;
78

89
/// <summary>
910
/// Ensures setting InvariantGlobalization = true still works in a trimmed app.
@@ -27,6 +28,18 @@ static int Main(string[] args)
2728
{
2829
return-3;
2930
}
31+
32+
// The rest of this code depends on a property of IL level trimming that keeps reflection
33+
// metadata for anything that is statically reachable. It's not applicable if we're not doing that
34+
// kind of trimming. Approximate what kind of trimming are we doing.
35+
if(GetMethodSecretly(typeof(Program),nameof(GetCoreLibType))==null)
36+
{
37+
// Sanity check: we only expect this for native AOT; IsDynamicCodeSupported approximates that.
38+
if(RuntimeFeature.IsDynamicCodeSupported)
39+
thrownewException();
40+
41+
return100;
42+
}
3043

3144
// Ensure the internal GlobalizationMode class is trimmed correctly.
3245
TypeglobalizationMode=GetCoreLibType("System.Globalization.GlobalizationMode");
@@ -65,4 +78,8 @@ static int Main(string[] args)
6578
// The intention of this method is to ensure the trimmer doesn't preserve the Type.
6679
privatestaticTypeGetCoreLibType(stringname)=>
6780
typeof(object).Assembly.GetType(name,throwOnError:false);
81+
82+
// The intention is to look for a method on a type in a way that trimming cannot detect.
83+
privatestaticMethodBaseGetMethodSecretly(Typetype,stringname)=>
84+
type.GetMethod(name,BindingFlags.Static|BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
6885
}

‎src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
and tested with this test. Issue https://github.com/dotnet/runtime/issues/48849 is
4444
tracking investigation on why this test is failing if not skipped.-->
4545
<SkipOnTestRuntimes>browser-wasm</SkipOnTestRuntimes>
46+
<!-- https://github.com/dotnet/runtime/issues/68714-->
47+
<NativeAotIncompatible>true</NativeAotIncompatible>
4648
</TestConsoleAppSourceFiles>
4749
<TestConsoleAppSourceFilesInclude="VerifyResourcesGetTrimmedTest.cs">
4850
<!-- Setting the Trimming feature switch to make sure that the Resources get trimmed by the trimmer
@@ -51,6 +53,8 @@
5153
</TestConsoleAppSourceFiles>
5254
<TestConsoleAppSourceFilesInclude="TypeBuilderComDisabled.cs">
5355
<DisabledProperties>BuiltInComInteropSupport</DisabledProperties>
56+
<!-- Reflection.Emit doesn't work with native AOT-->
57+
<NativeAotIncompatible>true</NativeAotIncompatible>
5458
</TestConsoleAppSourceFiles>
5559
<TestConsoleAppSourceFilesInclude="NullabilityInfoContextSupportFalse.cs">
5660
<DisabledProperties>NullabilityInfoContextSupport</DisabledProperties>
@@ -62,6 +66,8 @@
6266
<ItemGroupCondition="'$(TargetsWindows)' == 'true'">
6367
<TestConsoleAppSourceFilesInclude="UseWindowsThreadPoolFalse.cs">
6468
<DisabledFeatureSwitches>System.Threading.ThreadPool.UseWindowsThreadPool</DisabledFeatureSwitches>
69+
<!-- https://github.com/dotnet/runtime/issues/101591-->
70+
<NativeAotIncompatible>true</NativeAotIncompatible>
6571
</TestConsoleAppSourceFiles>
6672
<TestConsoleAppSourceFilesInclude="UseWindowsThreadPoolTrue.cs">
6773
<EnabledFeatureSwitches>System.Threading.ThreadPool.UseWindowsThreadPool</EnabledFeatureSwitches>

‎src/libraries/tests.proj‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,6 @@
650650
<!-- We need to go over these disablements: https://github.com/dotnet/runtime/issues/101228-->
651651
<ProjectExclusionsCondition="'$(RunNativeAotTestApps)' == 'true'"Include="$(MSBuildThisFileDirectory)\System.Private.Xml.Linq\tests\TrimmingTests\System.Xml.Linq.TrimmingTests.proj" />
652652
<ProjectExclusionsCondition="'$(RunNativeAotTestApps)' == 'true'"Include="$(MSBuildThisFileDirectory)\System.Private.Xml\tests\TrimmingTests\System.Private.Xml.TrimmingTests.proj" />
653-
<ProjectExclusionsCondition="'$(RunNativeAotTestApps)' == 'true'"Include="$(MSBuildThisFileDirectory)\System.Runtime\tests\System.Runtime.Tests\TrimmingTests\System.Runtime.TrimmingTests.proj" />
654653

655654
<TrimmingTestProjectsInclude="$(MSBuildThisFileDirectory)*\tests\**\*.TrimmingTests.proj"
656655
Exclude="@(ProjectExclusions)"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp