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

Commitc1531ec

Browse files
author
Keegan Caruso
committed
Use remote executor for tests using appcontext
1 parentd96f35a commitc1531ec

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

‎src/libraries/System.Linq/src/System/Linq/Select.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private static IEnumerable<TResult> SelectImplementation<TSource, TResult>(Func<
6060
// for value types. We don't do the same for reference types because reference type
6161
// expansion can happen lazily at runtime and the AOT compiler does postpone it (we
6262
// don't need more code, just more data structures describing the new types).
63-
if(/*ValueTypeTrimFriendlySelect &&*/typeof(TResult).IsValueType)
63+
if(ValueTypeTrimFriendlySelect&&typeof(TResult).IsValueType)
6464
{
6565
#ifOPTIMIZE_FOR_SIZE
6666
returnnewIEnumerableSelectIterator<TSource,TResult>(iterator,selector);

‎src/libraries/System.Linq/tests/SkipWhileTests.cs‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
usingSystem.Collections.Generic;
5+
usingMicrosoft.DotNet.RemoteExecutor;
56
usingXunit;
67

78
namespaceSystem.Linq.Tests
@@ -62,14 +63,33 @@ public void RunOnce()
6263
Assert.Equal(Enumerable.Range(10,10),Enumerable.Range(0,20).RunOnce().SkipWhile((i,idx)=>idx<10));
6364
}
6465

66+
[ConditionalFact(typeof(RemoteExecutor),nameof(RemoteExecutor.IsSupported))]
67+
publicstaticvoidSkipErrorWhenSourceErrors_TrimFriendlySelectTrue()
68+
{
69+
RemoteExecutor.Invoke(()=>
70+
{
71+
AppContext.SetSwitch("System.Linq.Enumerable.ValueTypeTrimFriendlySelect",true);
72+
73+
varsource=NumberRangeGuaranteedNotCollectionType(-2,5).Select(i=>(decimal)i).Select(m=>1/m).Skip(4);
74+
varvaluesFromEnumerable=source.ToList();
75+
List<decimal>expectedValues=[(decimal)1/2];
76+
Assert.Equal(expectedValues,valuesFromEnumerable);
77+
}).Dispose();
78+
}
79+
6580
[Fact]
66-
publicvoidSkipErrorWhenSourceErrors()
81+
publicvoidSkipErrorWhenSourceErrors_TrimFriendlySelectFalse()
6782
{
68-
varsource=NumberRangeGuaranteedNotCollectionType(-2,5).Select(i=>(decimal)i).Select(m=>1/m).Skip(4);
69-
using(varen=source.GetEnumerator())
83+
RemoteExecutor.Invoke(()=>
7084
{
71-
Assert.Throws<DivideByZeroException>(()=>en.MoveNext());
72-
}
85+
AppContext.SetSwitch("System.Linq.Enumerable.ValueTypeTrimFriendlySelect",false);
86+
87+
varsource=NumberRangeGuaranteedNotCollectionType(-2,5).Select(i=>(decimal)i).Select(m=>1/m).Skip(4);
88+
using(varen=source.GetEnumerator())
89+
{
90+
Assert.Throws<DivideByZeroException>(()=>en.MoveNext());
91+
}
92+
}).Dispose();
7393
}
7494

7595
[Fact]

‎src/libraries/System.Linq/tests/System.Linq.Tests.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<ProjectSdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3+
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
34
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
45
<DebuggerSupportCondition="'$(DebuggerSupport)' == '' and '$(TargetOS)' == 'browser'">true</DebuggerSupport>
56
</PropertyGroup>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp