Skip to content

Commit b5d393a

Browse files
committed
integrate visualfsharp OOB
2 parents 4331dca + f094532 commit b5d393a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3364
-471
lines changed

packages.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="NUnit" version="2.6.4" targetFramework="net40" />
44
<package id="NUnit.Runners" version="2.6.4" />
5+
<package id="FsCheck" version="2.0.3" />
56
</packages>

src/FSharpSource.targets

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Some other NuGET monikers to support in the future, see http://docs.nuget.org/do
6363
<StrongNames>true</StrongNames>
6464
</PropertyGroup>
6565

66-
<PropertyGroup Condition="('$(Configuration)'=='Debug' OR '$(Configuration)'=='Release') AND ('$(AssemblyName)'!='FSharp.Core')">
66+
<PropertyGroup Condition="('$(Configuration)'=='Debug' OR '$(Configuration)'=='Release') AND ('$(AssemblyName)'!='FSharp.Core') AND ('$(AssemblyName)'!='FSharp.Core.Unittests')">
6767
<DefineConstants>STRONG_NAME_FSHARP_COMPILER_WITH_TEST_KEY;$(DefineConstants)</DefineConstants>
6868
<OtherFlags>$(OtherFlags) --keyfile:"$(FSharpSourcesRoot)\fsharp\test.snk"</OtherFlags>
6969
<StrongNames>true</StrongNames>
@@ -112,7 +112,10 @@ Some other NuGET monikers to support in the future, see http://docs.nuget.org/do
112112
<NUnitVersion>2.6.4</NUnitVersion>
113113
<NUnitFullVersion>2.6.4.14350</NUnitFullVersion>
114114
<NUnitLibDir>$(FSharpSourcesRoot)\..\packages\NUnit.$(NUnitVersion)\lib\</NUnitLibDir>
115-
<NunitToolsLibDir>$(FSharpSourcesRoot)\..\packages\NUnit.Runners.$(NUnitVersion)\tools\lib\</NunitToolsLibDir>
115+
<NUnitToolsLibDir>$(FSharpSourcesRoot)\..\packages\NUnit.Runners.$(NUnitVersion)\tools\lib\</NUnitToolsLibDir>
116+
<FsCheckVersion>2.0.3</FsCheckVersion>
117+
<FsCheckFullVersion>2.0.3.0</FsCheckFullVersion>
118+
<FsCheckLibDir>$(FSharpSourcesRoot)\..\packages\FsCheck.$(FsCheckVersion)\lib\</FsCheckLibDir>
116119
</PropertyGroup>
117120

118121
<!-- v2.0-specific flags -->
@@ -960,7 +963,7 @@ Some other NuGET monikers to support in the future, see http://docs.nuget.org/do
960963
Outputs="@(CustomCopyLocal->'$(OutDir)%(TargetFilename)')"
961964
Condition="'$(targetCLIDir)'!='Silverlight/4.0/'"
962965
>
963-
<Exec Command="$(FSharpSourcesRoot)\fsharp\FSharp.Build\subst.exe &quot;%(CustomCopyLocal.FullPath)&quot; {VisualStudioVersion} $(VisualStudioVersion) {FinalDir} &quot;$([System.IO.Path]::GetFullPath('$(OutputPath)'))\&quot; {LkgVersion} $(LkgVersion) {BuildSuffix} &quot;$(FsBuildSuffix)&quot; {FSharpTargetsDir} &quot;%24(MSBuildThisFileDirectory)&quot; &gt; $(OutDir)%(CustomCopyLocal.TargetFilename) "/>
966+
<Exec Command="$(FSharpSourcesRoot)\fsharp\FSharp.Build\subst.exe &quot;%(CustomCopyLocal.FullPath)&quot; {VisualStudioVersion} $(VisualStudioVersion) {FinalDir} &quot;$([System.IO.Path]::GetFullPath('$(OutputPath)'))\&quot; {LkgVersion} $(LkgVersion) {BuildSuffix} &quot;$(FsBuildSuffix)&quot; {FSharpTargetsDir} &quot;%24(MSBuildThisFileDirectory)&quot; {FSCoreVersion} &quot;$(FSCoreVersion)&quot; &gt; $(OutDir)%(CustomCopyLocal.TargetFilename) "/>
964967
<!-- Make sure it will get cleaned -->
965968
<CreateItem Include="$(OutDir)%(CustomCopyLocal.TargetFilename)">
966969
<Output TaskParameter="Include" ItemName="FileWrites"/>

src/absil/ilread.fs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ type ILReaderContext =
10491049
userStringsStreamPhysicalLoc: int32;
10501050
stringsStreamPhysicalLoc: int32;
10511051
blobsStreamPhysicalLoc: int32;
1052+
blobsStreamSize: int32;
10521053
readUserStringHeap: (int32 -> string);
10531054
memoizeString: string -> string;
10541055
readStringHeap: (int32 -> string);
@@ -1534,9 +1535,13 @@ let readStringHeapUncached ctxtH idx =
15341535
let readStringHeap ctxt idx = ctxt.readStringHeap idx
15351536
let readStringHeapOption ctxt idx = if idx = 0 then None else Some (readStringHeap ctxt idx)
15361537

1538+
let emptyByteArray: byte[] = [||]
15371539
let readBlobHeapUncached ctxtH idx =
15381540
let ctxt = getHole ctxtH
1539-
seekReadBlob ctxt.is (ctxt.blobsStreamPhysicalLoc + idx)
1541+
// valid index lies in range [1..streamSize)
1542+
// NOTE: idx cannot be 0 - Blob\String heap has first empty element that is one byte 0
1543+
if idx <= 0 || idx >= ctxt.blobsStreamSize then emptyByteArray
1544+
else seekReadBlob ctxt.is (ctxt.blobsStreamPhysicalLoc + idx)
15401545
let readBlobHeap ctxt idx = ctxt.readBlobHeap idx
15411546
let readBlobHeapOption ctxt idx = if idx = 0 then None else Some (readBlobHeap ctxt idx)
15421547

@@ -3973,6 +3978,7 @@ let rec genOpenBinaryReader infile is opts =
39733978
userStringsStreamPhysicalLoc = userStringsStreamPhysicalLoc;
39743979
stringsStreamPhysicalLoc = stringsStreamPhysicalLoc;
39753980
blobsStreamPhysicalLoc = blobsStreamPhysicalLoc;
3981+
blobsStreamSize = blobsStreamSize;
39763982
memoizeString = Tables.memoize id;
39773983
readUserStringHeap = cacheUserStringHeap (readUserStringHeapUncached ctxtH);
39783984
readStringHeap = cacheStringHeap (readStringHeapUncached ctxtH);

src/fsharp/FSComp.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -928,9 +928,9 @@ optsEmitDebugInfoInQuotations,"Emit debug information in quotations"
928928
# service.fs strings
929929
# -----------------------------------------------------------------------------
930930
typeInfoFullName,"Full name"
931-
typeInfoType,"type"
932-
typeInfoInherits,"inherits"
933-
typeInfoImplements,"implements"
931+
# typeInfoType,"type"
932+
# typeInfoInherits,"inherits"
933+
# typeInfoImplements,"implements"
934934
typeInfoOtherOverloads,"and %d other overloads"
935935
typeInfoUnionCase,"union case"
936936
typeInfoActivePatternResult,"active pattern result"
@@ -1089,8 +1089,8 @@ lexHashBangMustBeFirstInFile,"#! may only appear as the first line at the start
10891089
1189,parsNonAdjacentTypars,"Type parameters must be placed directly adjacent to the type name, e.g. \"type C<'T>\", not type \"C <'T>\""
10901090
1190,parsNonAdjacentTyargs,"Type arguments must be placed directly adjacent to the type name, e.g. \"C<'T>\", not \"C <'T>\""
10911091
parsNonAtomicType,"The use of the type syntax 'int C' and 'C <int>' is not permitted here. Consider adjusting this type to be written in the form 'C<int>'"
1092-
1191,tastUndefinedTyconItemField,"The type %s did not contain the field '%s'"
1093-
1192,tastUndefinedTyconItemUnionCase,"The type %s did not contain the union case '%s'"
1092+
# 1191,tastUndefinedTyconItemField,"The type %s did not contain the field '%s'"
1093+
# 1192,tastUndefinedTyconItemUnionCase,"The type %s did not contain the union case '%s'"
10941094
1193,tastUndefinedItemRefModuleNamespace,"The module/namespace '%s' from compilation unit '%s' did not contain the module/namespace '%s'"
10951095
1194,tastUndefinedItemRefVal,"The module/namespace '%s' from compilation unit '%s' did not contain the val '%s'"
10961096
1195,tastUndefinedItemRefModuleNamespaceType,"The module/namespace '%s' from compilation unit '%s' did not contain the namespace, module or type '%s'"
@@ -1342,3 +1342,5 @@ estApplyStaticArgumentsForMethodNotImplemented,"A type provider implemented GetS
13421342
3184,ppparsIncompleteExpression,"Incomplete preprocessor expression"
13431343
3185,ppparsMissingToken,"Missing token '%s' in preprocessor expression"
13441344
3186,pickleMissingDefinition,"An error occurred while reading the F# metadata node at position %d in table '%s' of assembly '%s'. The node had no matching declaration. Please report this warning. You may need to recompile the F# assembly you are using."
1345+
3187,checkNotSufficientlyGenericBecauseOfScope,"Type inference caused the type variable %s to escape its scope. Consider adding an explicit type parameter declaration or adjusting your code to be less generic."
1346+
3188,checkNotSufficientlyGenericBecauseOfScopeAnon,"Type inference caused an inference type variable to escape its scope. Consider adding type annotations to make your code less generic."

src/fsharp/FSharp.Compiler-proto/FSharp.Compiler-proto.fsproj

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
137137
<Compile Include="..\..\absil\ildiag.fs">
138138
<Link>ildiag.fs</Link>
139139
</Compile>
140+
<Compile Include="..\ReferenceResolution.fsi">
141+
<Link>ReferenceResolution.fsi</Link>
142+
</Compile>
140143
<Compile Include="..\ReferenceResolution.fs">
141144
<Link>ReferenceResolution.fs</Link>
142145
</Compile>
@@ -232,12 +235,15 @@
232235
<Compile Include="..\..\ilx\ilxsettings.fs">
233236
<Link>ilxsettings.fs</Link>
234237
</Compile>
235-
<Compile Include="..\..\ilx\EraseClosures.fsi">
236-
<Link>EraseClosures.fsi</Link>
237-
</Compile>
238-
<Compile Include="..\..\ilx\EraseClosures.fs">
238+
<Compile Include="..\..\ilx\EraseClosures.fsi">
239+
<Link>EraseClosures.fsi</Link>
240+
</Compile>
241+
<Compile Include="..\..\ilx\EraseClosures.fs">
239242
<Link>EraseClosures.fs</Link>
240243
</Compile>
244+
<Compile Include="..\..\ilx\EraseUnions.fsi">
245+
<Link>EraseUnions.fsi</Link>
246+
</Compile>
241247
<Compile Include="..\..\ilx\EraseUnions.fs">
242248
<Link>EraseUnions.fs</Link>
243249
</Compile>
@@ -272,14 +278,11 @@
272278
</Compile>
273279
<Compile Include="pplex.fs" />
274280
<Compile Include="lex.fs" />
275-
<Compile Include="..\ast.fs">
276-
<Link>ast.fs</Link>
277-
</Compile>
278281
<Compile Include="..\QuotationPickler.fsi">
279282
<Link>QuotationPickler.fsi</Link>
280283
</Compile>
281284
<Compile Include="..\QuotationPickler.fs">
282-
<Link>QuotationPickler.fs</Link>
285+
<Link>QuotationPickler.fs</Link>
283286
</Compile>
284287
<Compile Include="..\QueueList.fs">
285288
<Link>QueueList.fs</Link>
@@ -288,14 +291,14 @@
288291
<Link>tast.fs</Link>
289292
</Compile>
290293
<Compile Include="..\TcGlobals.fs">
291-
<Link>TcGlobals.fs</Link>
292-
</Compile>
293-
<Compile Include="..\TastOps.fsi">
294-
<Link>TastOps.fsi</Link>
295-
</Compile>
296-
<Compile Include="..\TastOps.fs">
297-
<Link>TastOps.fs</Link>
298-
</Compile>
294+
<Link>TcGlobals.fs</Link>
295+
</Compile>
296+
<Compile Include="..\TastOps.fsi">
297+
<Link>TastOps.fsi</Link>
298+
</Compile>
299+
<Compile Include="..\TastOps.fs">
300+
<Link>TastOps.fs</Link>
301+
</Compile>
299302
<Compile Include="..\TastPickle.fsi">
300303
<Link>TastPickle.fsi</Link>
301304
</Compile>
@@ -338,10 +341,10 @@
338341
<Compile Include="..\PatternMatchCompilation.fs">
339342
<Link>PatternMatchCompilation.fs</Link>
340343
</Compile>
341-
<Compile Include="..\ConstraintSolver.fsi">
342-
<Link>ConstraintSolver.fsi</Link>
343-
</Compile>
344-
<Compile Include="..\ConstraintSolver.fs">
344+
<Compile Include="..\ConstraintSolver.fsi">
345+
<Link>ConstraintSolver.fsi</Link>
346+
</Compile>
347+
<Compile Include="..\ConstraintSolver.fs">
345348
<Link>ConstraintSolver.fs</Link>
346349
</Compile>
347350
<Compile Include="..\CheckFormatStrings.fsi">
@@ -374,16 +377,16 @@
374377
<Compile Include="..\Optimizer.fsi">
375378
<Link>Optimizer.fsi</Link>
376379
</Compile>
380+
<Compile Include="..\Optimizer.fs">
381+
<Link>Optimizer.fs</Link>
382+
</Compile>
377383
<Compile Include="..\autobox.fs">
378384
<Link>autobox.fs</Link>
379385
</Compile>
380-
<Compile Include="..\Optimizer.fs">
381-
<Link>Optimizer.fs</Link>
386+
<Compile Include="..\DetupleArgs.fsi">
387+
<Link>DetupleArgs.fsi</Link>
382388
</Compile>
383-
<Compile Include="..\DetupleArgs.fsi">
384-
<Link>DetupleArgs.fsi</Link>
385-
</Compile>
386-
<Compile Include="..\DetupleArgs.fs">
389+
<Compile Include="..\DetupleArgs.fs">
387390
<Link>DetupleArgs.fs</Link>
388391
</Compile>
389392
<Compile Include="..\InnerLambdasToTopLevelFuncs.fsi">
@@ -427,6 +430,9 @@
427430
<Link>IncrementalBuild.fs</Link>
428431
</Compile>
429432
-->
433+
<Compile Include="..\fsc.fsi">
434+
<Link>fsc.fsi</Link>
435+
</Compile>
430436
<Compile Include="..\fsc.fs">
431437
<Link>fsc.fs</Link>
432438
</Compile>

src/fsharp/FSharp.Compiler/FSharp.Compiler.fsproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@
152152
<Compile Include="..\ErrorLogger.fs">
153153
<Link>ErrorLogging\ErrorLogger.fs</Link>
154154
</Compile>
155+
<Compile Include="..\ReferenceResolution.fsi">
156+
<Link>ReferenceResolution\ReferenceResolution.fsi</Link>
157+
</Compile>
155158
<Compile Include="..\ReferenceResolution.fs">
156159
<Link>ReferenceResolution\ReferenceResolution.fs</Link>
157160
</Compile>
@@ -455,6 +458,9 @@
455458
<Compile Include="..\vs\IncrementalBuild.fs">
456459
<Link>Driver\IncrementalBuild.fs</Link>
457460
</Compile>
461+
<Compile Include="..\fsc.fsi">
462+
<Link>Driver\fsc.fsi</Link>
463+
</Compile>
458464
<Compile Include="..\fsc.fs">
459465
<Link>Driver\fsc.fs</Link>
460466
</Compile>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
3+
<configuration>
4+
<runtime>
5+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
6+
<dependentAssembly>
7+
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
8+
<bindingRedirect oldVersion="2.0.0.0-4.4.0.0" newVersion="{FSCoreVersion}"/>
9+
</dependentAssembly>
10+
</assemblyBinding>
11+
</runtime>
12+
</configuration>

src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<!-- Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
33
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
44
<PropertyGroup>
@@ -50,10 +50,18 @@
5050
</PropertyGroup>
5151
<ItemGroup>
5252
<!-- need full name and SpecificVersion = true in order to convince msbuild to allow this reference when targeting portable47 -->
53-
<Reference Include="nunit.framework, Version=$(NUnitFullVersion), Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl3-wp'" >
54-
<SpecificVersion>true</SpecificVersion>
55-
<Private>True</Private>
56-
<HintPath>$(NUnitLibDir)\nunit.framework.dll</HintPath>
53+
<Reference Include="nunit.framework, Version=$(NUnitFullVersion), Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" Condition="'$(TargetFramework)' != 'sl5' AND '$(TargetFramework)' != 'sl3-wp'">
54+
<SpecificVersion>true</SpecificVersion>
55+
<Private>True</Private>
56+
<HintPath>$(NUnitLibDir)\nunit.framework.dll</HintPath>
57+
</Reference>
58+
<Reference Include="FsCheck, Version=$(FsCheckFullVersion)" Condition="'$(TargetFramework)' != 'portable47' AND '$(TargetFramework)' != 'net20'">
59+
<SpecificVersion>true</SpecificVersion>
60+
<Private>True</Private>
61+
<HintPath Condition="'$(TargetFramework)' == 'net40'">$(FsCheckLibDir)\net45\FsCheck.dll</HintPath>
62+
<HintPath Condition="'$(TargetFramework)' == 'portable7'">$(FsCheckLibDir)\portable-net45+netcore45\FsCheck.dll</HintPath>
63+
<HintPath Condition="'$(TargetFramework)' == 'portable78'">$(FsCheckLibDir)\portable-net45+netcore45+wp8\FsCheck.dll</HintPath>
64+
<HintPath Condition="'$(TargetFramework)' == 'portable259'">$(FsCheckLibDir)\portable-net45+netcore45+wpa81+wp8\FsCheck.dll</HintPath>
5765
</Reference>
5866
<Reference Include="NUnitFramework" Condition="'$(TargetFramework)' == 'sl5' OR '$(TargetFramework)' == 'sl3-wp'" />
5967
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj">
@@ -82,24 +90,29 @@
8290
<ItemGroup>
8391
<Compile Include="NUnitFrameworkShims.fs" Condition="'$(TargetFramework)' == 'sl3-wp'" />
8492
<Compile Include="LibraryTestFx.fs" />
93+
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\Utils.fs" Condition="'$(TargetFramework)' != 'portable47' AND '$(TargetFramework)' != 'net20'" />
8594
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ArrayModule.fs" />
8695
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ArrayModule2.fs" />
8796
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\Array2Module.fs" />
8897
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\Array3Module.fs" />
8998
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\Array4Module.fs" />
99+
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ArrayProperties.fs" Condition="'$(TargetFramework)' != 'portable47' AND '$(TargetFramework)' != 'net20'" />
90100
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ComparisonIdentityModule.fs" />
91101
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\HashIdentityModule.fs" />
92102
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ListModule.fs" />
93103
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ListModule2.fs" />
94104
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ObsoleteListFunctions.fs" />
95105
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ListType.fs" />
106+
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ListProperties.fs" Condition="'$(TargetFramework)' != 'portable47' AND '$(TargetFramework)' != 'net20'" />
96107
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\MapModule.fs" />
97108
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\MapType.fs" />
98109
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\SetModule.fs" />
99110
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\SetType.fs" />
100111
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\SeqModule.fs" />
101112
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\SeqModule2.fs" />
102113
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\ObsoleteSeqFunctions.fs" />
114+
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\SeqProperties.fs" Condition="'$(TargetFramework)' != 'portable47' AND '$(TargetFramework)' != 'net20'" />
115+
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\CollectionModulesConsistency.fs" Condition="'$(TargetFramework)' != 'portable47' AND '$(TargetFramework)' != 'net20'" />
103116
<Compile Include="FSharp.Core\Microsoft.FSharp.Collections\StringModule.fs" />
104117
<Compile Include="FSharp.Core\PrimTypes.fs" />
105118
<Compile Include="FSharp.Core\DiscrimantedUnionType.fs" />
@@ -120,6 +133,9 @@
120133
<Compile Include="NUnitFrameworkShims.fs" Condition="'$(TargetFramework)' == 'sl3-wp'" />
121134
<!-- <Compile Include="SurfaceArea.4.0.fs" Condition="'$(TargetFramework)' == 'net40'"/> -->
122135
<Compile Include="SurfaceArea.$(TargetFramework).fs" />
123-
</ItemGroup>
136+
<CustomCopyLocal Include="FSharp.Core.Unittests.dll.config">
137+
<TargetFilename>FSharp.Core.Unittests.dll.config</TargetFilename>
138+
</CustomCopyLocal>
139+
</ItemGroup>
124140
<Import Project="$(FSharpSourcesRoot)\FSharpSource.targets" />
125141
</Project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
3+
module FSharp.Core.Unittests.FSharp_Core.Microsoft_FSharp_Collections.ArrayProperties
4+
5+
open System
6+
open System.Collections.Generic
7+
open NUnit.Framework
8+
open FsCheck
9+
10+
let isStable sorted = sorted |> Seq.pairwise |> Seq.forall (fun ((ia, a),(ib, b)) -> if a = b then ia < ib else true)
11+
12+
let distinctByStable<'a when 'a : comparison> (xs : 'a []) =
13+
let indexed = xs |> Seq.indexed |> Seq.toArray
14+
let sorted = indexed |> Array.distinctBy snd
15+
isStable sorted
16+
17+
[<Test>]
18+
let ``Seq.distinctBy is stable`` () =
19+
Check.QuickThrowOnFailure distinctByStable<int>
20+
Check.QuickThrowOnFailure distinctByStable<string>

0 commit comments

Comments
 (0)