This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is used to quickly diagnose why a rebuild happened in a large solution | |
// It reads a binlog file and finds all the CoreCompile targets that were triggered by a file being newer than the output file | |
// It then prints out the project and the messages that caused the rebuild | |
// to create a binlog you can refer to https://learn.microsoft.com/en-us/visualstudio/ide/msbuild-logs?view=vs-2022#provide-msbuild-binary-logs-for-investigation | |
// CLI: dotnet build -bl:mybinlog.binlog | |
// or in `.build/build.fs` add `BuildParameter.enableBinLog "mybinlog.binlog"` to the `build'` target. | |
// Use https://msbuildlog.com/ to diagnose further | |
#r "nuget: MSBuild.StructuredLogger" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Runtime.CompilerServices | |
type Log() = | |
static member inline GatherLogMeta | |
( | |
?name_space: string, | |
[<CallerMemberName>] ?cmb: string, | |
[<CallerLineNumber>] ?cln: int, | |
[<CallerFilePath>] ?cfp: string | |
) = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: FSharp.Compiler.Service, 43.8.300" | |
open FSharp.Compiler.Syntax | |
open FSharp.Compiler.SyntaxTrivia | |
open FSharp.Compiler.Xml | |
open FSharp.Compiler.CodeAnalysis | |
open System.IO | |
type Node = | |
{ Data : Data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ResultBuilder () = | |
member inline _.Return (x) = Ok x | |
member inline _.Bind(x,f) = | |
match x with | |
| Ok x -> f x | |
| Error e -> Error <| e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
open System.Collections.Generic | |
let root = __SOURCE_DIRECTORY__ | |
let srcDir = Path.Combine(root, "src") | |
// Add <OtherFlags>$(OtherFlags) --test:GraphBasedChecking --test:DumpCheckingGraph --times:timings.csv</OtherFlags> to the .fsproj or Directory.Build.props |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Threading.Tasks | |
type FooBuilder() = | |
member _.Return(x) = Task.FromResult(Ok x) | |
member _.Bind(x, f) : Task<Result<'TResult, 'Error list>> = | |
task { | |
let! x = x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace FsToolkit.ErrorHandling.Ducks | |
open System | |
open System.Collections.Generic | |
open System.Threading.Tasks | |
open System.Runtime.CompilerServices | |
open Microsoft.FSharp.Core.CompilerServices | |
type Disposable<'Disposable when 'Disposable: (member Dispose: unit -> unit)> = 'Disposable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Threading | |
open System.Threading.Tasks | |
// Based on https://gist.github.com/StephenCleary/7dd1c0fc2a6594ba0ed7fb7ad6b590d6 | |
// and https://gist.github.com/brendankowitz/5949970076952746a083054559377e56 | |
/// <summary> | |
/// An awaitable wrapper around a task whose result is disposable. The wrapper is not disposable, so this prevents usage errors like "use _lock = myAsync()" when the appropriate usage should be "use! _lock = myAsync())". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: Serilog, 2.9.0" | |
open System.Threading.Tasks | |
[<Interface>] | |
type ILogger = | |
abstract Debug: string -> unit | |
abstract Error: string -> unit | |
[<Interface>] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type BlockingObjectPool<'T when 'T : (new : unit -> 'T)>(maxCount : int) = | |
let pool = Stack<'T>(maxCount) | |
let semaphoreSlim = new SemaphoreSlim(maxCount, maxCount) | |
do for i=0 to maxCount do | |
let foo = new 'T() | |
pool.Push(foo) | |
member _.Get() = | |
printf $"Getting from pool : {semaphoreSlim.CurrentCount}" | |
semaphoreSlim.Wait() |
NewerOlder