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
| let ifDefRuntime = | |
| #if NET8_0 | |
| "This is .NET 8.0" | |
| #endif | |
| #if NET9_0 | |
| "This is .NET 9.0" | |
| #endif | |
| #if NET10_0 | |
| "This is .NET 10.0" |
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
| module Seq = | |
| open System.Linq | |
| /// Attempts to determine the number of elements in a sequence without forcing an enumeration. | |
| let inline tryLength (xs : seq<_>) = | |
| match Enumerable.TryGetNonEnumeratedCount xs with | |
| | true, count -> ValueSome count | |
| | _ -> | |
| match xs with | |
| // F# list implements IReadOnlyCollection/IReadOnlyList |
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.Build | |
| module DotEnv = | |
| open System | |
| open System.IO | |
| let private parseLine (line: string) = | |
| match line.Split('=', StringSplitOptions.RemoveEmptyEntries) with | |
| | args when args.Length = 2 -> Environment.SetEnvironmentVariable(args.[0], args.[1]) | |
| | _ -> () |
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
| [<AutoOpen>] | |
| module Ignore = | |
| [<RequiresExplicitTypeArguments>] | |
| let inline ignore<'a> (x: 'a) : unit = ignore<'a> x | |
| type Async = | |
| [<RequiresExplicitTypeArguments>] | |
| static member inline Ignore<'a>(x: Async<'a>) : Async<unit> = FSharp.Control.Async.Ignore<'a> 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
| // 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 GatherLogMetaStackFrame | |
| (?name_space: string, [<CallerMemberName>] ?cmb: string, [<CallerLineNumber>] ?cln: int, [<CallerFilePath>] ?cfp: string) | |
| = | |
| let name_space = | |
| match name_space with | |
| | Some ns -> ns | |
| | _ -> |
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 |
NewerOlder