This commit is contained in:
Eugene Tolmachev 2023-11-29 11:08:05 -05:00 коммит произвёл Eugene Tolmachev
Родитель 6fbf7008f8
Коммит b93d1bc14f
11 изменённых файлов: 25 добавлений и 390 удалений

Просмотреть файл

@ -2,12 +2,6 @@
"version": 1,
"isRoot": true,
"tools": {
"fake-cli": {
"version": "5.20.4",
"commands": [
"fake"
]
},
"fsharp.formatting.commandtool": {
"version": "9.0.4",
"commands": [

Просмотреть файл

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<UserSecretsId>79a3edd0-2092-40a2-a04d-dcb46d5ca9ed</UserSecretsId>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DefineConstants>TASKS</DefineConstants>
</PropertyGroup>

Просмотреть файл

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -383,157 +383,6 @@ module String =
let substring index (s: string) =
s.Substring index
module Bytes =
open System.IO
open System.Linq
open System.Security.Cryptography
let hash (algo: unit -> #HashAlgorithm) (bs: byte[]) =
use ms = new MemoryStream()
ms.Write(bs, 0, bs.Length)
ms.Seek(0L, SeekOrigin.Begin) |> ignore
use sha = algo ()
sha.ComputeHash ms
let sha1 =
hash (fun () -> new SHA1Managed())
let sha256 =
hash (fun () -> new SHA256Managed())
let sha512 =
hash (fun () -> new SHA512Managed())
let toHex (bs: byte[]) =
BitConverter.ToString bs
|> String.replace "-" ""
|> String.toLowerInvariant
let ofHex (digestString: string) =
Enumerable.Range(0, digestString.Length)
.Where(fun x -> x % 2 = 0)
.Select(fun x -> Convert.ToByte(digestString.Substring(x, 2), 16))
.ToArray()
/// Compare two byte arrays in constant time, bounded by the length of the
/// longest byte array.
let equalsConstantTime (bits: byte []) (bobs: byte []) =
let mutable xx = uint32 bits.Length ^^^ uint32 bobs.Length
let mutable i = 0
while i < bits.Length && i < bobs.Length do
xx <- xx ||| uint32 (bits.[i] ^^^ bobs.[i])
i <- i + 1
xx = 0u
[<RequireQualifiedAccess>]
module Culture =
open System.Globalization
let invariant = CultureInfo.InvariantCulture
module UTF8 =
open System.Text
let private utf8 = Encoding.UTF8
/// Convert the full buffer `b` filled with UTF8-encoded strings into a CLR
/// string.
let toString (bs: byte []) =
utf8.GetString bs
/// Convert the byte array to a string, by indexing into the passed buffer `b`
/// and taking `count` bytes from it.
let toStringAtOffset (b: byte []) (index: int) (count: int) =
utf8.GetString(b, index, count)
/// Get the UTF8-encoding of the string.
let bytes (s: string) =
utf8.GetBytes s
/// Convert the passed string `s` to UTF8 and then encode the buffer with
/// base64.
let encodeBase64: string -> Base64String =
bytes >> Convert.ToBase64String
/// Convert the passed string `s`, assumed to be a valid Base64 encoding, to a
/// CLR string, going through UTF8.
let decodeBase64: Base64String -> string =
Convert.FromBase64String >> toString
let sha1 =
bytes >> Bytes.sha1
let sha1Hex =
bytes >> Bytes.sha1 >> Bytes.toHex
let sha256 =
bytes >> Bytes.sha256
let sha256Hex =
bytes >> Bytes.sha256 >> Bytes.toHex
let sha512 =
bytes >> Bytes.sha512
let sha512Hex =
bytes >> Bytes.sha512 >> Bytes.toHex
module Comparisons =
/// compare x to yobj mapped on selected value from function f
let compareOn f x (yobj: obj) =
match yobj with
| :? 'T as y -> compare (f x) (f y)
| _ -> invalidArg "yobj" "cannot compare values of different types"
/// check equality on x and y mapped on selected value from function f
let equalsOn f x (yobj:obj) =
match yobj with
| :? 'T as y -> (f x = f y)
| _ -> false
/// hash x on the selected value from f
let hashOn f x = hash (f x)
type Random with
/// generate a new random ulong64 value
member x.NextUInt64() =
let buffer = Array.zeroCreate<byte> sizeof<UInt64>
x.NextBytes buffer
BitConverter.ToUInt64(buffer, 0)
module Array =
/// Ordinally compare two arrays in constant time, bounded by the length of the
/// longest array. This function uses the F# language equality.
let equalsConstantTime (arr1: 'a []) (arr2: 'a []) =
if arr1.Length <> arr2.Length then false else
let mutable b = true
for i in 0 .. arr1.Length - 1 do
b <- b && (arr1.[i] = arr2.[i])
b
/// Returns a sequence that yields chunks of length n.
/// Each chunk is returned as an array.
/// Thanks to
/// https://nbevans.wordpress.com/2014/03/13/really-simple-way-to-split-a-f-sequence-into-chunks-partitions/
let chunk (n: uint32) (s: seq<'t>) = seq {
let n = int n
let pos = ref 0
let buffer = Array.zeroCreate<'t> n
for x in s do
buffer.[!pos] <- x
if !pos = n - 1 then
yield buffer |> Array.copy
pos := 0
else
incr pos
if !pos > 0 then
yield Array.sub buffer 0 !pos
}
module Regex =
open System.Text.RegularExpressions

Просмотреть файл

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<UserSecretsId>79a3edd0-2092-40a2-a04d-dcb46d5ca9ed</UserSecretsId>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -12,7 +12,7 @@ trigger:
steps:
- task: UseDotNet@2
inputs:
version: '5.0.100'
version: '6.0.100'
- task: DotNetCoreCLI@2
displayName: "Restore tools"
@ -27,9 +27,9 @@ steps:
NUGET_REPO_KEY: $(NUGET_REPO_KEY)
inputs:
command: custom
custom: fake
custom: fsi
${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags') }}:
arguments: 'build -t release'
arguments: 'build.fsx -t release'
${{ if not(startsWith(variables['Build.SourceBranch'], 'refs/tags')) }}:
arguments: build -t ci
arguments: build.fsx -t ci

26
build.fsx Normal file → Executable file
Просмотреть файл

@ -1,14 +1,11 @@
#r "paket:
nuget FSharp.Core ~> 4.7
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.Core.ReleaseNotes
nuget Fake.Core.Target
nuget Fake.Tools.Git //"
#load "./.fake/build.fsx/intellisense.fsx"
#if !FAKE
#r "Facades/netstandard"
#endif
#!/usr/bin/env -S dotnet fsi
#r "nuget: Fake.Core.Target"
#r "nuget: Fake.DotNet.Cli"
#r "nuget: Fake.IO.FileSystem"
#r "nuget: Fake.Core.ReleaseNotes"
#r "nuget: Fake.Core.Target"
#r "nuget: Fake.Tools.Git"
#r "nuget: MSBuild.StructuredLogger, 2.1.820"
open Fake.Core
open Fake.Core.TargetOperators
@ -32,6 +29,13 @@ let ver =
| Some n -> { release.SemVer with Patch = uint32 n; Original = None }
| _ -> SemVer.parse "0.0.0"
System.Environment.GetCommandLineArgs()
|> Array.skip 2 // fsi.exe; build.fsx
|> Array.toList
|> Context.FakeExecutionContext.Create false __SOURCE_FILE__
|> Context.RuntimeContext.Fake
|> Context.setExecutionContext
[<AutoOpen>]
module Shell =
let sh cmd args cwd parse =

Просмотреть файл

@ -1,212 +0,0 @@
STORAGE: NONE
RESTRICTION: == netstandard2.0
NUGET
remote: https://api.nuget.org/v3/index.json
BlackFox.VsWhere (1.1)
FSharp.Core (>= 4.2.3)
Microsoft.Win32.Registry (>= 4.7)
Fake.Core.CommandLineParsing (5.20.4)
FParsec (>= 1.1.1)
FSharp.Core (>= 4.7.2)
Fake.Core.Context (5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Environment (5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.FakeVar (5.20.4)
Fake.Core.Context (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Process (5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.FakeVar (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
Fake.IO.FileSystem (>= 5.20.4)
FSharp.Core (>= 4.7.2)
System.Collections.Immutable (>= 1.7.1)
Fake.Core.ReleaseNotes (5.20.4)
Fake.Core.SemVer (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.SemVer (5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.String (5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Target (5.20.4)
Fake.Core.CommandLineParsing (>= 5.20.4)
Fake.Core.Context (>= 5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.FakeVar (>= 5.20.4)
Fake.Core.Process (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
FSharp.Control.Reactive (>= 4.4.2)
FSharp.Core (>= 4.7.2)
Fake.Core.Tasks (5.20.4)
Fake.Core.Trace (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Trace (5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.FakeVar (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Xml (5.20.4)
Fake.Core.String (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.DotNet.Cli (5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.Process (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
Fake.DotNet.MSBuild (>= 5.20.4)
Fake.DotNet.NuGet (>= 5.20.4)
Fake.IO.FileSystem (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Mono.Posix.NETStandard (>= 1.0)
Newtonsoft.Json (>= 12.0.3)
Fake.DotNet.MSBuild (5.20.4)
BlackFox.VsWhere (>= 1.1)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.Process (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
Fake.IO.FileSystem (>= 5.20.4)
FSharp.Core (>= 4.7.2)
MSBuild.StructuredLogger (>= 2.1.176)
Fake.DotNet.NuGet (5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.Process (>= 5.20.4)
Fake.Core.SemVer (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Tasks (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
Fake.Core.Xml (>= 5.20.4)
Fake.IO.FileSystem (>= 5.20.4)
Fake.Net.Http (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Newtonsoft.Json (>= 12.0.3)
NuGet.Protocol (>= 5.6)
Fake.IO.FileSystem (5.20.4)
Fake.Core.String (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Net.Http (5.20.4)
Fake.Core.Trace (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Tools.Git (5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.Process (>= 5.20.4)
Fake.Core.SemVer (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
Fake.IO.FileSystem (>= 5.20.4)
FSharp.Core (>= 4.7.2)
FParsec (1.1.1)
FSharp.Core (>= 4.3.4)
FSharp.Control.Reactive (5.0.2)
FSharp.Core (>= 4.7.2)
System.Reactive (>= 5.0)
FSharp.Core (4.7.2)
Microsoft.Build (16.10)
Microsoft.Build.Framework (16.10)
System.Security.Permissions (>= 4.7)
Microsoft.Build.Tasks.Core (16.10)
Microsoft.Build.Framework (>= 16.10)
Microsoft.Build.Utilities.Core (>= 16.10)
Microsoft.NET.StringTools (>= 1.0)
Microsoft.Win32.Registry (>= 4.3)
System.CodeDom (>= 4.4)
System.Collections.Immutable (>= 5.0)
System.Reflection.Metadata (>= 1.6)
System.Resources.Extensions (>= 4.6)
System.Security.Cryptography.Pkcs (>= 4.7)
System.Security.Cryptography.Xml (>= 4.7)
System.Security.Permissions (>= 4.7)
System.Threading.Tasks.Dataflow (>= 4.9)
Microsoft.Build.Utilities.Core (16.10)
Microsoft.Build.Framework (>= 16.10)
Microsoft.NET.StringTools (>= 1.0)
Microsoft.Win32.Registry (>= 4.3)
System.Collections.Immutable (>= 5.0)
System.Configuration.ConfigurationManager (>= 4.7)
System.Security.Permissions (>= 4.7)
System.Text.Encoding.CodePages (>= 4.0.1)
Microsoft.NET.StringTools (1.0)
System.Memory (>= 4.5.4)
System.Runtime.CompilerServices.Unsafe (>= 5.0)
Microsoft.NETCore.Platforms (5.0.2)
Microsoft.NETCore.Targets (5.0)
Microsoft.Win32.Registry (5.0)
System.Buffers (>= 4.5.1)
System.Memory (>= 4.5.4)
System.Security.AccessControl (>= 5.0)
System.Security.Principal.Windows (>= 5.0)
Mono.Posix.NETStandard (1.0)
MSBuild.StructuredLogger (2.1.507)
Microsoft.Build (>= 16.4)
Microsoft.Build.Framework (>= 16.4)
Microsoft.Build.Tasks.Core (>= 16.4)
Microsoft.Build.Utilities.Core (>= 16.4)
Newtonsoft.Json (13.0.1)
NuGet.Common (5.10)
NuGet.Frameworks (>= 5.10)
NuGet.Configuration (5.10)
NuGet.Common (>= 5.10)
System.Security.Cryptography.ProtectedData (>= 4.4)
NuGet.Frameworks (5.10)
NuGet.Packaging (5.10)
Newtonsoft.Json (>= 9.0.1)
NuGet.Configuration (>= 5.10)
NuGet.Versioning (>= 5.10)
System.Security.Cryptography.Cng (>= 5.0)
System.Security.Cryptography.Pkcs (>= 5.0)
NuGet.Protocol (5.10)
NuGet.Packaging (>= 5.10)
NuGet.Versioning (5.10)
System.Buffers (4.5.1)
System.CodeDom (5.0)
System.Collections.Immutable (5.0)
System.Memory (>= 4.5.4)
System.Configuration.ConfigurationManager (5.0)
System.Security.Cryptography.ProtectedData (>= 5.0)
System.Security.Permissions (>= 5.0)
System.Formats.Asn1 (5.0)
System.Buffers (>= 4.5.1)
System.Memory (>= 4.5.4)
System.Memory (4.5.4)
System.Buffers (>= 4.5.1)
System.Numerics.Vectors (>= 4.4)
System.Runtime.CompilerServices.Unsafe (>= 4.5.3)
System.Numerics.Vectors (4.5)
System.Reactive (5.0)
System.Runtime.InteropServices.WindowsRuntime (>= 4.3)
System.Threading.Tasks.Extensions (>= 4.5.4)
System.Reflection.Metadata (5.0)
System.Collections.Immutable (>= 5.0)
System.Resources.Extensions (5.0)
System.Memory (>= 4.5.4)
System.Runtime (4.3.1)
Microsoft.NETCore.Platforms (>= 1.1.1)
Microsoft.NETCore.Targets (>= 1.1.3)
System.Runtime.CompilerServices.Unsafe (5.0)
System.Runtime.InteropServices.WindowsRuntime (4.3)
System.Runtime (>= 4.3)
System.Security.AccessControl (5.0)
System.Security.Principal.Windows (>= 5.0)
System.Security.Cryptography.Cng (5.0)
System.Security.Cryptography.Pkcs (5.0.1)
System.Buffers (>= 4.5.1)
System.Formats.Asn1 (>= 5.0)
System.Memory (>= 4.5.4)
System.Security.Cryptography.Cng (>= 5.0)
System.Security.Cryptography.ProtectedData (5.0)
System.Memory (>= 4.5.4)
System.Security.Cryptography.Xml (5.0)
System.Memory (>= 4.5.4)
System.Security.Cryptography.Pkcs (>= 5.0)
System.Security.Permissions (>= 5.0)
System.Security.Permissions (5.0)
System.Security.AccessControl (>= 5.0)
System.Security.Principal.Windows (5.0)
System.Text.Encoding.CodePages (5.0)
System.Runtime.CompilerServices.Unsafe (>= 5.0)
System.Threading.Tasks.Dataflow (5.0)
System.Threading.Tasks.Extensions (4.5.4)
System.Runtime.CompilerServices.Unsafe (>= 4.5.3)