Demystify truncating internals of F# async/task expressions
This commit is contained in:
20
sample/FSharpStackTrace/FSharpStackTrace.fsproj
Normal file
20
sample/FSharpStackTrace/FSharpStackTrace.fsproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Ben.Demystifier\Ben.Demystifier.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Ply" Version="0.1.7" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
35
sample/FSharpStackTrace/Program.fs
Normal file
35
sample/FSharpStackTrace/Program.fs
Normal file
@@ -0,0 +1,35 @@
|
||||
// Learn more about F# at http://fsharp.org
|
||||
|
||||
open System
|
||||
open System.Diagnostics
|
||||
open System.Threading.Tasks
|
||||
open FSharp.Control.Tasks.Builders
|
||||
|
||||
let call i = async {
|
||||
do! Async.Sleep 1
|
||||
if i = 10 then
|
||||
failwith "BOOM!"
|
||||
return i
|
||||
}
|
||||
|
||||
let run count = async {
|
||||
let calls = Array.init count call
|
||||
for call in calls do
|
||||
let! _ = call
|
||||
()
|
||||
return 0
|
||||
}
|
||||
|
||||
let makeTheCall () = task {
|
||||
let! x = run 20
|
||||
return x
|
||||
}
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
try
|
||||
let results = makeTheCall().GetAwaiter().GetResult()
|
||||
printfn "%A" results
|
||||
with e ->
|
||||
printfn "%s" <| string (e.Demystify())
|
||||
0 // return an integer exit code
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
class Program
|
||||
|
||||
Reference in New Issue
Block a user