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

Commit12b2d16

Browse files
committed
Merge branch 'master' into vs2017-rtm
2 parentsf38fec3 +507ea9e commit12b2d16

File tree

43 files changed

+2040
-435
lines changed

Some content is hidden

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

43 files changed

+2040
-435
lines changed

‎VisualFSharp.sln‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion =15.0.26014.0
4+
VisualStudioVersion =15.0.26020.0
55
MinimumVisualStudioVersion =10.0.40219.1
66
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") ="FSharp.Compiler","src\fsharp\FSharp.Compiler\FSharp.Compiler.fsproj","{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}"
77
EndProject
@@ -137,6 +137,10 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "HostedCompilerServer", "tes
137137
EndProject
138138
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") ="ILComparer","tests\fsharpqa\testenv\src\ILComparer\ILComparer.fsproj","{2E60864A-E3FF-4BCC-810F-DC7C34E6B236}"
139139
EndProject
140+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") ="Utils","Utils","{D086C8C6-D00D-4C3B-9AB2-A4286C9F5922}"
141+
EndProject
142+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") ="LanguageServiceProfiling","vsintegration\Utils\LanguageServiceProfiling\LanguageServiceProfiling.fsproj","{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}"
143+
EndProject
140144
Global
141145
GlobalSection(SolutionConfigurationPlatforms) =preSolution
142146
Debug|Any CPU=Debug|Any CPU
@@ -738,6 +742,18 @@ Global
738742
{2E60864A-E3FF-4BCC-810F-DC7C34E6B236}.Release|Any CPU.Build.0=Release|Any CPU
739743
{2E60864A-E3FF-4BCC-810F-DC7C34E6B236}.Release|x86.ActiveCfg=Release|Any CPU
740744
{2E60864A-E3FF-4BCC-810F-DC7C34E6B236}.Release|x86.Build.0=Release|Any CPU
745+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Debug|Any CPU.ActiveCfg=Debug|Any CPU
746+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Debug|Any CPU.Build.0=Debug|Any CPU
747+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Debug|x86.ActiveCfg=Debug|Any CPU
748+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Debug|x86.Build.0=Debug|Any CPU
749+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Proto|Any CPU.ActiveCfg=Release|Any CPU
750+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Proto|Any CPU.Build.0=Release|Any CPU
751+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Proto|x86.ActiveCfg=Release|Any CPU
752+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Proto|x86.Build.0=Release|Any CPU
753+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Release|Any CPU.ActiveCfg=Release|Any CPU
754+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Release|Any CPU.Build.0=Release|Any CPU
755+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Release|x86.ActiveCfg=Release|Any CPU
756+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903}.Release|x86.Build.0=Release|Any CPU
741757
EndGlobalSection
742758
GlobalSection(SolutionProperties) =preSolution
743759
HideSolutionNode =FALSE
@@ -798,5 +814,7 @@ Global
798814
{E6A45CDF-B408-420F-B475-74611BEFC52B} ={141F6C23-E1B1-4D89-9F10-F0B8AD58E71F}
799815
{4239EFEA-E746-446A-BF7A-51FCBAB13946} ={CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
800816
{2E60864A-E3FF-4BCC-810F-DC7C34E6B236} ={CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
817+
{D086C8C6-D00D-4C3B-9AB2-A4286C9F5922} ={4C7B48D7-19AF-4AE7-9D1D-3BB289D5480D}
818+
{E7FA3A71-51AF-4FCA-9C2F-7C853E515903} ={D086C8C6-D00D-4C3B-9AB2-A4286C9F5922}
801819
EndGlobalSection
802820
EndGlobal

‎build.cmd‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ echo ^<debug^|release^>
2424
echo^<diag^|publicsign^>
2525
echo^<test^|test-net40-coreunit^|test-coreclr-coreunit^|test-compiler-unit^|test-pcl-coreunit^|test-net40-fsharp^|test-coreclr-fsharp^|test-net40-fsharpqa^>
2626
echo^<include tag^>
27+
echo^<init^>
2728
echo.
2829
echo No arguments default to 'default', meaning this (no testing)
2930
echo.
@@ -177,7 +178,7 @@ if /i '%ARG%' == 'microbuild' (
177178
setBUILD_PORTABLE=1
178179
setBUILD_VS=1
179180
setBUILD_SETUP=%FSC_BUILD_SETUP%
180-
181+
181182
setTEST_NET40_COMPILERUNIT_SUITE=1
182183
setTEST_NET40_COREUNIT_SUITE=1
183184
setTEST_NET40_FSHARP_SUITE=1
@@ -189,7 +190,6 @@ if /i '%ARG%' == 'microbuild' (
189190
setCI=1
190191
)
191192

192-
193193
REM These divide 'ci' into two chunks which can be done in parallel
194194
if /i '%ARG%'== 'ci_part1' (
195195
set_autoselect=0
@@ -204,7 +204,6 @@ if /i '%ARG%' == 'ci_part1' (
204204
setTEST_NET40_FSHARPQA_SUITE=1
205205
setTEST_VS_IDEUNIT_SUITE=1
206206
setCI=1
207-
208207
)
209208

210209
if /i '%ARG%'== 'ci_part2' (
@@ -328,6 +327,10 @@ if /i '%ARG%' == 'publicsign' (
328327
setBUILD_PUBLICSIGN=1
329328
)
330329

330+
if /i '%ARG%'== 'init' (
331+
setBUILD_PROTO_WITH_CORECLR_LKG=1
332+
)
333+
331334
goto :EOF
332335
:: Note: "goto :EOF" returns from an in-batchfile "call" command
333336
:: in preference to returning from the entire batch file.
@@ -477,6 +480,7 @@ if '%BUILD_PROTO_WITH_CORECLR_LKG%' == '1' (
477480
)
478481

479482
set_dotnetexe=%~dp0Tools\dotnetcli\dotnet.exe
483+
setNUGET_PACKAGES=%~dp0Packages
480484

481485
set_fsiexe="packages\FSharp.Compiler.Tools.4.0.1.19\tools\fsi.exe"
482486
ifnotexist%_fsiexe%echo Error: Could not find%_fsiexe%&&goto :failure
@@ -495,7 +499,6 @@ if NOT EXIST Proto\net40\bin\fsc-proto.exe (
495499
set_dotnetexe=%~dp0Tools\dotnetcli\dotnet.exe
496500
set_architecture=win7-x64
497501

498-
499502
rem Build Proto
500503
if '%BUILD_PROTO%'== '1' (
501504
rmdir /s /q Proto

‎src/FSharpSource.Settings.targets‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<ConfigurationGroupCondition="'$(ConfigurationGroup)'==''">Debug</ConfigurationGroup>
1919
</PropertyGroup>
2020

21-
<!-- Nuget Package properties-->
2221
<PropertyGroup>
2322
<!-- Settings used all the time-->
2423
<Tailcalls>true</Tailcalls>
@@ -106,12 +105,15 @@
106105
<DefineConstantsCondition="'$(VisualStudioVersion)'=='' AND '$(ProjectLanguage)' != 'VisualBasic'">$(DefineConstants);VS_VERSION_DEV14</DefineConstants>
107106
</PropertyGroup>
108107

109-
<PropertyGroup>
108+
<!-- Nuget Package properties-->
109+
<PropertyGroup>
110110
<BuildRevision>$([System.DateTime]::Now.ToString(`yyMMdd`))</BuildRevision>
111-
<NuGetReleaseVersion>1.0.0</NuGetReleaseVersion>
111+
<NuGetReleaseVersion>1.0.0</NuGetReleaseVersion>
112112
<NuGetPreReleaseVersion>$(NuGetReleaseVersion)-rc</NuGetPreReleaseVersion>
113-
<NuGetPerBuildPreReleaseVersionCondition="'$(BuildRevision)' != ''">$(NuGetPreReleaseVersion)-$(BuildRevision.Trim())</NuGetPerBuildPreReleaseVersion>
114-
</PropertyGroup>
113+
<NuGetPerBuildPreReleaseVersionCondition="'$(BuildRevision)' != ''">$(NuGetPreReleaseVersion)-$(BuildRevision.Trim())</NuGetPerBuildPreReleaseVersion>
114+
<NUGET_PACKAGESCondition=" '$(NUGET_PACKAGES)' == ''">$(MSBuildThisFileDirectory)..\packages</NUGET_PACKAGES>
115+
<RestorePackagesPath>$(NUGET_PACKAGES)</RestorePackagesPath>
116+
</PropertyGroup>
115117

116118
<PropertyGroup>
117119
<!-- Compiler tool locations.-->
@@ -129,6 +131,8 @@
129131
<!-- The LKG FSI.EXE requires MSBuild 15 to be installed, which is painful-->
130132
<FsiToolPath>$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.0.1.19\tools</FsiToolPath>
131133
</PropertyGroup>
134+
132135
<ImportProject="../Tools/Build.Common.props"Condition="'$(TargetFramework)'=='coreclr'"/>
136+
<ImportProject="$(BuildVersionFilePath)"Condition="Exists('$(BuildVersionFilePath)')" />
133137

134138
</Project>

‎src/FSharpSource.targets‎

Lines changed: 86 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -412,18 +412,16 @@
412412

413413
<!-- Hook up .NET Core to enable solution refresh of packages-->
414414
<PropertyGroupCondition="'$(TargetFramework)'=='coreclr'">
415-
416-
<NuGetPackagesPathCondition="'$(NuGetPackagesPath)' == ''">$(FSharpSourcesRoot)\..\packages</NuGetPackagesPath>
417415

418416
<!-- Implicitly needed by packageresolve.targets. Should file a bug for a better error message here-->
419-
<PackagesDir>$(NuGetPackagesPath)\</PackagesDir>
417+
<PackagesDir>$(NUGET_PACKAGES)</PackagesDir>
420418

421419
<NuGetToolPathCondition="'$(NuGetToolPath)' == ''">$(FSharpSourcesRoot)\..\.nuget\</NuGetToolPath>
422420
<NuGetConfigCommandLine>-ConfigFile "$(NuGetConfigFile)"</NuGetConfigCommandLine>
423421

424-
<NugetRestoreCommand>"$(NuGetToolPath)NuGet.exe install -OutputDirectory "$(NuGetPackagesPath)" -Config "$(NuGetToolPath)NuGet.Config"</NugetRestoreCommand>
422+
<NugetRestoreCommand>"$(NuGetToolPath)NuGet.exe install -OutputDirectory "$(PackagesDir)" -Config "$(NuGetToolPath)NuGet.Config"</NugetRestoreCommand>
425423

426-
<DnuRestoreCommand>"$(NuGetToolPath)NuGet.exe" restore -OutputDirectory "$(NuGetPackagesPath)" -Config "$(NuGetToolPath)NuGet.Config"</DnuRestoreCommand>
424+
<DnuRestoreCommand>"$(NuGetToolPath)NuGet.exe" restore -OutputDirectory "$(PackagesDir)" -Config "$(NuGetToolPath)NuGet.Config"</DnuRestoreCommand>
427425

428426
<!-- Current version of .NET Core does not support all semantics used in our packages,
429427
so we ignore the pre-calculation in the lock file and calculate asset applicability in the build task-->
@@ -473,32 +471,27 @@
473471
</Target>
474472

475473
<TargetName="dotnetrestore"BeforeTargets="Build"Condition=" '$(TargetFramework)' == 'coreclr'">
476-
<ExecCommand="$(MSBuildThisFileDirectory)..\.nuget\nuget.exe restore -PackagesDirectory $(MSBuildThisFileDirectory)..\packages -Config $(MSBuildThisFileDirectory)..\.nuget\NuGet.Config project.json" />
477-
</Target>
478-
479-
<TargetName="nugetpack"AfterTargets="Build"Condition="'$(TargetFramework)' == 'coreclr'"
480-
Inputs="@(PackageNuspec)"Outputs='$(OutputPath.TrimEnd("\"))\nuget\"%(PackageNuspec.Filename)).nupkg'>
481-
<PropertyGroup>
482-
<PackageProperties>-prop "licenseUrl=$(PackageLicenceUrl)" -prop "version=$(PackageVersion)" -prop "authors=$(PackageAuthors)" -prop "projectUrl=$(PackageProjectUrl)" -prop "tags=$(PackageTags)"</PackageProperties>
483-
</PropertyGroup>
484-
485-
<ExecCommand='$(MSBuildThisFileDirectory)..\.nuget\nuget.exe pack %(PackageNuspec.Filename)%(PackageNuspec.Extension) -BasePath "$(OutputPath.TrimEnd("\"))" -ExcludeEmptyDirectories $(PackageProperties) -OutputDirectory "$(MSBuildThisFileDirectory)..\artifacts' />
474+
<ExecCommand="$(MSBuildThisFileDirectory)..\.nuget\nuget.exe restore -PackagesDirectory $(PackagesDir) -Config $(MSBuildThisFileDirectory)..\.nuget\NuGet.Config project.json" />
486475
</Target>
487476

488477
<TargetName="dotnetrestore"BeforeTargets="Build"Condition=" '$(DOTNET_PUBLISH)' == 'true'">
478+
<SetEnvVarName="NUGET_PACKAGES"Value="$(NUGET_PACKAGES)" />
489479
<ExecCommand="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe restore --configfile $(MSBuildThisFileDirectory)..\.nuget\NuGet.Config project.json"/>
490480
</Target>
491481

492482
<TargetName="dotnetpublish"AfterTargets="Build"Condition=" '$(DOTNET_PUBLISH)' == 'true'">
483+
<SetEnvVarName="NUGET_PACKAGES"Value="$(NUGET_PACKAGES)" />
493484
<ExecCommand="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe --verbose publish --no-build project.json -r $(DOTNET_PUBLISH_PLATFORM) -c $(Configuration) -o $(DOTNET_PUBLISH_PATH)"/>
494485
</Target>
495486

496487
<TargetName="dotnetpublishfsccompiler"AfterTargets="CopyFilesToOutputDirectory"Condition=" '$(DOTNET_PUBLISH_FSC)' == 'true'">
488+
<SetEnvVarName="NUGET_PACKAGES"Value="$(NUGET_PACKAGES)" />
497489
<ExecCommand="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe restore DeployCompiler\fsc\project.json"/>
498490
<ExecCommand="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe --verbose publish --no-build DeployCompiler\fsc\project.json -r $(DOTNET_PUBLISH_PLATFORM) -c $(Configuration) -o $(DOTNET_PUBLISH_FSC_PATH)"/>
499491
</Target>
500492

501493
<TargetName="dotnetpublishfsicompiler"AfterTargets="CopyFilesToOutputDirectory"Condition=" '$(DOTNET_PUBLISH_FSI)' == 'true'">
494+
<SetEnvVarName="NUGET_PACKAGES"Value="$(NUGET_PACKAGES)" />
502495
<ExecCommand="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe restore DeployCompiler\fsi\project.json"/>
503496
<ExecCommand="$(MSBuildThisFileDirectory)..\Tools\dotnetcli\dotnet.exe --verbose publish --no-build DeployCompiler\fsi\project.json -r $(DOTNET_PUBLISH_PLATFORM) -c $(Configuration) -o $(DOTNET_PUBLISH_FSI_PATH)"/>
504497
</Target>
@@ -518,6 +511,68 @@
518511
<WriteLinesToFileFile="$(IntermediateOutputPath)source_link.json"Overwrite="true"Lines='{"documents": { "$(SrcRootDirectory)/*" : "$(RemoteUri.Replace(".git", "").Replace("github.com", "raw.githubusercontent.com"))/$(LatestCommit)/*" }}' />
519512
</Target>
520513

514+
<!-- If BuildVersionFilePath not specified then do nothing-->
515+
<TargetName="CleanVersionFile" Condition ="'$(BuildVersionFilePath)' != ''">
516+
<PropertyGroup>
517+
<BuildVersionFileDir>$([System.IO.Path]::GetDirectoryName($(BuildVersionFilePath)))</BuildVersionFileDir>
518+
</PropertyGroup>
519+
<RemoveDirCondition="Exists('$(BuildVersionFileDir)')"Directories="$(BuildVersionFileDir)" />
520+
</Target>
521+
522+
<!-- If BuildVersionFilePath not specified then do nothing-->
523+
<TargetName="CreateOrUpdateBuildVersionFile" Condition ="'$(BuildVersionFilePath)' != ''">
524+
<PropertyGroup>
525+
<BuildVersionFileDir>$([System.IO.Path]::GetDirectoryName($(BuildVersionFilePath)))</BuildVersionFileDir>
526+
<PackageVersionMajorCondition="'$(PackageVersionMajor)' == ''" >$(NuGetPerBuildPreReleaseVersion)</PackageVersionMajor>
527+
<PackageVersionMinorCondition="'$(PackageVersionMinor)' != ''" >$([MSBuild]::Add($(PackageVersionMinor), 1))</PackageVersionMinor>
528+
<PackageVersionMinorCondition="'$(PackageVersionMinor)' == ''" >1</PackageVersionMinor>
529+
</PropertyGroup>
530+
531+
<ItemGroup>
532+
<CurrentVersionLinesInclude="%3C%3Fxml version=%221.0%22 encoding=%22utf-8%22%3F%3E" />
533+
<CurrentVersionLinesInclude="%3C!-- This is a generated file. $(VersionSeedSourceComment) Seed Date is $(VersionSeedDate). --%3E" />
534+
<CurrentVersionLinesInclude="%3CProject xmlns=%22http://schemas.microsoft.com/developer/msbuild/2003%22%3E" />
535+
<CurrentVersionLinesInclude="%3CPropertyGroup%3E" />
536+
<CurrentVersionLinesInclude="%3CPackageVersionMajor Condition=%22%27%24(PackageVersionMajor)%27==%27%27%22%3E$(NuGetPerBuildPreReleaseVersion)%3C/PackageVersionMajor%3E" />
537+
<CurrentVersionLinesInclude="%3CPackageVersionMinor Condition=%22%27%24(PackageVersionMinor)%27==%27%27%22%3E$(PackageVersionMinor)%3C/PackageVersionMinor%3E" />
538+
<CurrentVersionLinesInclude="%3C/PropertyGroup%3E" />
539+
<CurrentVersionLinesInclude="%3C/Project%3E" />
540+
</ItemGroup>
541+
542+
<!-- Since by default the file will get dropped at the obj dir, make sure that the dir is created already or else WriteLinesToFile will error.-->
543+
<MakeDirCondition="!Exists('$(BuildVersionFileDir)')"Directories="$(BuildVersionFileDir)" />
544+
545+
<WriteLinesToFile
546+
ContinueOnError="WarnAndContinue"
547+
File="$(BuildVersionFilePath)"
548+
Lines="@(CurrentVersionLines)"
549+
Overwrite="true" />
550+
551+
<!-- Delete old BuildVersion.props files-->
552+
<ItemGroup>
553+
<OldBuildVersionFilesInclude="$(BuildVersionFilePath)BuildVersions-*.props"Exclude="$(BuildVersionFilePath)%(BuildVersionFileItem.Filename).props" />
554+
</ItemGroup>
555+
<DeleteFiles="@(OldBuildVersionFiles)"TreatErrorsAsWarnings="true"/>
556+
</Target>
557+
558+
<TargetName="nugetpack"
559+
DependsOnTargets="CreateOrUpdateBuildVersionFile"
560+
AfterTargets="Build"
561+
Condition="'$(TargetFramework)' == 'coreclr'"
562+
Inputs="@(PackageNuspec)"
563+
Outputs='$(FSharpSourcesRoot.TrimEnd("\"))\..\$(Configuration)\artifacts\"%(PackageNuspec.Filename)).nupkg'>
564+
565+
<PropertyGroup>
566+
<PackageProperties>-prop "licenseUrl=$(PackageLicenceUrl)" -prop "version=$(PackageVersion)" -prop "authors=$(PackageAuthors)" -prop "projectUrl=$(PackageProjectUrl)" -prop "tags=$(PackageTags)"</PackageProperties>
567+
</PropertyGroup>
568+
569+
<MakeDirDirectories="$(FSharpSourcesRoot.TrimEnd('\'))\..\$(Configuration)\artifacts" />
570+
<MakeDirDirectories="$(FSharpSourcesRoot.TrimEnd('\'))\..\artifacts" />
571+
<SetEnvVarName="NUGET_PACKAGES"Value="$(NUGET_PACKAGES)" />
572+
<ExecCommand='$(MSBuildThisFileDirectory)..\.nuget\nuget.exe pack @(PackageNuspec) -BasePath $(OutputPath.TrimEnd("\")) -ExcludeEmptyDirectories $(PackageProperties) -OutputDirectory $(FSharpSourcesRoot.TrimEnd("\"))\..\$(Configuration)\artifacts' />
573+
<ExecCommand='$(MSBuildThisFileDirectory)..\.nuget\nuget.exe pack @(PackageNuspec) -BasePath $(OutputPath.TrimEnd("\")) -ExcludeEmptyDirectories $(PackageProperties) -OutputDirectory $(FSharpSourcesRoot.TrimEnd("\"))\..\artifacts' />
574+
</Target>
575+
521576
<UsingTaskTaskName="ReplaceFileText"TaskFactory="CodeTaskFactory"AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
522577
<ParameterGroup>
523578
<InputFilenameParameterType="System.String"Required="true" />
@@ -541,4 +596,19 @@
541596
</Task>
542597
</UsingTask>
543598

544-
</Project>
599+
<UsingTaskTaskName="SetEnvVar"TaskFactory="CodeTaskFactory"AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
600+
<ParameterGroup>
601+
<NameParameterType="System.String"Required="true" />
602+
<ValueParameterType="System.String"Required="true" />
603+
</ParameterGroup>
604+
<Task>
605+
<UsingNamespace="System" />
606+
<CodeType="Fragment"Language="cs">
607+
<![CDATA[
608+
Environment.SetEnvironmentVariable(Name, Value);
609+
]]>
610+
</Code>
611+
</Task>
612+
</UsingTask>
613+
614+
</Project>

‎src/absil/illib.fs‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,15 @@ module ResultOrException =
494494
/// captured by the NotYetDone closure. Computations do not need to be restartable.
495495
///
496496
/// - The key thing is that you can take an Eventually value and run it with
497-
/// Eventually.repeatedlyProgressUntilDoneOrTimeShareOver
497+
/// Eventually.repeatedlyProgressUntilDoneOrTimeShareOverOrCanceled
498498
typeEventually<'T>=
499499
| Doneof'T
500500
| NotYetDoneof(unit->Eventually<'T>)
501501

502502
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
503503
moduleEventually=
504+
openSystem.Threading
505+
504506
let recbox e=
505507
match ewith
506508
| Done x-> Done(Operators.box x)
@@ -515,10 +517,11 @@ module Eventually =
515517
else forceWhile check(work())
516518

517519
letforce e= Option.get(forceWhile(fun()->true) e)
520+
518521

519522
/// Keep running the computation bit by bit until a time limit is reached.
520523
/// The runner gets called each time the computation is restarted
521-
letrepeatedlyProgressUntilDoneOrTimeShareOver timeShareInMilliseconds runner e=
524+
letrepeatedlyProgressUntilDoneOrTimeShareOverOrCanceled timeShareInMilliseconds(ct:CancellationToken)runner e=
522525
letsw=new System.Diagnostics.Stopwatch()
523526
let recrunTimeShare e=
524527
runner(fun()->
@@ -527,14 +530,27 @@ module Eventually =
527530
let recloop(e)=
528531
match ewith
529532
| Done_-> e
530-
| NotYetDone work->
531-
if sw.ElapsedMilliseconds> timeShareInMillisecondsthen
533+
| NotYetDone work->
534+
ifct.IsCancellationRequested||sw.ElapsedMilliseconds> timeShareInMillisecondsthen
532535
sw.Stop();
533536
NotYetDone(fun()-> runTimeShare e)
534537
else
535538
loop(work())
536539
loop(e))
537540
runTimeShare e
541+
542+
/// Keep running the asynchronous computation bit by bit. The runner gets called each time the computation is restarted.
543+
/// Can be cancelled in the normal way.
544+
letforceAsync(runner:(unit-> Eventually<'T>)->Async<Eventually<'T>>)(e:Eventually<'T>):Async<'Toption>=
545+
let recloop(e:Eventually<'T>)=
546+
async{
547+
match ewith
548+
| Done x->return Some x
549+
| NotYetDone work->
550+
let!r= runner work
551+
return! loop r
552+
}
553+
loop e
538554

539555
let recbind k e=
540556
match ewith

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp