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

Commit13b0ba0

Browse files
libozKevinRansom
authored andcommitted
F# RFC FS-1029 - Implement IReadOnlyCollection<'T> in list<'T> (dotnet#2093)
* F# RFC FS-1029* added tests* dealing with the old portable library* simpler conditional
1 parent24d088f commit13b0ba0

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

‎src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ListType.fs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,25 @@ type ListType() =
8282
CheckThrowsInvalidOperationExn(fun()->enum.Current|> ignore)
8383
Assert.AreEqual(false,enum.MoveNext())
8484
CheckThrowsInvalidOperationExn(fun()->enum.Current|> ignore)
85+
86+
#if!FSCORE_PORTABLE_OLD
87+
[<Test>]
88+
memberthis.IReadOnlyCollection_T()=
89+
90+
// Legit IReadOnlyCollection_T
91+
letc=['a';'b';'c']:> IReadOnlyCollection<char>
92+
93+
Assert.AreEqual(c.Count, Seq.length c)
94+
95+
letc=[1..10]:> IReadOnlyCollection<int>
96+
97+
Assert.AreEqual(c.Count,10)
98+
99+
// Empty IReadOnlyCollection_T
100+
letc=[]:> IReadOnlyCollection<int>
101+
102+
Assert.AreEqual(c.Count,0)
103+
#endif
85104

86105
// Base class methods
87106
[<Test>]

‎src/fsharp/FSharp.Core/prim-types.fs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,6 +3497,10 @@ namespace Microsoft.FSharp.Collections
34973497
|(::): Head: 'T* Tail: 'T list-> 'T list
34983498
interface System.Collections.Generic.IEnumerable<'T>
34993499
interface System.Collections.IEnumerable
3500+
3501+
#if!FSCORE_PORTABLE_OLD
3502+
interface System.Collections.Generic.IReadOnlyCollection<'T>
3503+
#endif
35003504

35013505
and 'T list= List<'T>
35023506

@@ -3690,6 +3694,11 @@ namespace Microsoft.FSharp.Collections
36903694
interface System.Collections.IEnumerablewith
36913695
memberl.GetEnumerator()=(PrivateListHelpers.mkListEnumerator l:> System.Collections.IEnumerator)
36923696

3697+
#if!FSCORE_PORTABLE_OLD
3698+
interface IReadOnlyCollection<'T>with
3699+
memberl.Count= l.Length
3700+
#endif
3701+
36933702
typeseq<'T>= IEnumerable<'T>
36943703

36953704

‎src/fsharp/FSharp.Core/prim-types.fsi‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,10 @@ namespace Microsoft.FSharp.Collections
18281828

18291829
interface System.Collections.Generic.IEnumerable<'T>
18301830
interface System.Collections.IEnumerable
1831+
1832+
#if!FSCORE_PORTABLE_OLD
1833+
interface System.Collections.Generic.IReadOnlyCollection<'T>
1834+
#endif
18311835

18321836
///<summary>An abbreviation for the type of immutable singly-linked lists. </summary>
18331837
///

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp