Skip to content

Commit

Permalink
Update tech
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoVIII committed May 21, 2023
1 parent e3d90eb commit 7edf309
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 110 deletions.
44 changes: 22 additions & 22 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"version": 1,
"isRoot": true,
"tools": {
"paket": {
"version": "7.0.0-alpha019",
"commands": [
"paket"
]
},
"fantomas-tool": {
"version": "4.6.5",
"commands": [
"fantomas"
]
},
"fsdocs-tool": {
"version": "14.0.1",
"commands": [
"fsdocs"
]
}
"version": 1,
"isRoot": true,
"tools": {
"paket": {
"version": "7.2.1",
"commands": [
"paket"
]
},
"fsdocs-tool": {
"version": "18.1.0",
"commands": [
"fsdocs"
]
},
"fantomas": {
"version": "6.0.3",
"commands": [
"fantomas"
]
}
}
}
}
5 changes: 0 additions & 5 deletions .devcontainer/Dockerfile

This file was deleted.

51 changes: 25 additions & 26 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,36 @@
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/dotnet-fsharp
{
"name": "F# (.NET)",
"build": {
"dockerfile": "Dockerfile",
"args": {}
},
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:0-6.0",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash"
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash"
},
"zsh": {
"path": "zsh"
}
},
"FSharp.dotnetRoot": "/usr/bin"
},
"zsh": {
"path": "zsh"
}
},
"FSharp.dotnetRoot": "/bin"
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"editorconfig.editorconfig",
"ybaumes.highlight-trailing-white-spaces",
"aaron-bond.better-comments",
"gruntfuggly.todo-tree",
"ms-dotnettools.csharp",
"Ionide.Ionide-fsharp"
]
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"editorconfig.editorconfig",
"ybaumes.highlight-trailing-white-spaces",
"aaron-bond.better-comments",
"gruntfuggly.todo-tree",
"ms-dotnettools.csharp",
"Ionide.Ionide-fsharp",
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
8080
],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "dotnet tool restore && dotnet restore",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
"postCreateCommand": "dotnet tool restore && dotnet run restore"
}
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
dotnet: [5.0.404]
dotnet: [6.0.408]
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
dotnet: [5.0.404]
dotnet: [6.0.408]
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
dotnet: [5.0.404]
dotnet: [6.0.408]
runs-on: ${{ matrix.os }}

steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ obj/
.ionide/
.fake/

# Paket
packages/

# Packed library
*.nupkg

Expand Down
4 changes: 1 addition & 3 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
version 5.251.0

source https://api.nuget.org/v3/index.json

storage: none
framework: auto-detect

nuget Expecto
nuget FsCheck
nuget FSharp.Core >= 5.0 lowest_matching: true, redirects: force
nuget FSharp.Core >= 6.0 lowest_matching: true, redirects: force
nuget Expecto.FsCheck
nuget NicoVIII.FSharp.Json prerelease

Expand Down
28 changes: 15 additions & 13 deletions paket.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
STORAGE: NONE
RESTRICTION: == net5.0
RESTRICTION: == net6.0
NUGET
remote: https://api.nuget.org/v3/index.json
Expecto (9.0.4)
Expand All @@ -8,10 +8,10 @@ NUGET
Expecto.FsCheck (9.0.4)
Expecto (>= 9.0.4)
FsCheck (>= 2.14.3)
FsCheck (2.16.4)
FsCheck (2.16.5)
FSharp.Core (>= 4.2.3)
FSharp.Core (5.0) - redirects: force
Mono.Cecil (0.11.3)
FSharp.Core (6.0) - redirects: force
Mono.Cecil (0.11.5)
NicoVIII.FSharp.Json (0.6)
FSharp.Core (>= 4.3.4)

Expand All @@ -29,22 +29,23 @@ NUGET
System.Reflection.Metadata (>= 1.6)
System.Reflection.TypeExtensions (>= 4.3)
System.Runtime.Loader (>= 4.0)
FSharp.Core (5.0)
FSharp.Core (7.0.300)
FSharp.Formatting (4.1)
FSharp.Compiler.Service (>= 35.0)
Microsoft.NETCore.Platforms (5.0)
Microsoft.NETCore.Platforms (7.0.2)
Microsoft.NETCore.Targets (5.0)
Newtonsoft.Json (12.0.3)
Newtonsoft.Json (13.0.3)
System.Buffers (4.5.1)
System.Collections.Immutable (5.0)
System.Memory (>= 4.5.4) - restriction: || (&& (== netcoreapp3.1) (>= net461)) (&& (== netcoreapp3.1) (< netcoreapp2.1)) (&& (== netcoreapp3.1) (< netstandard2.0)) (&& (== netcoreapp3.1) (>= uap10.1)) (== netstandard2.0) (== netstandard2.1)
System.Collections.Immutable (7.0)
System.Memory (>= 4.5.5)
System.Runtime.CompilerServices.Unsafe (>= 6.0)
System.IO (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.NETCore.Targets (>= 1.1)
System.Runtime (>= 4.3)
System.Text.Encoding (>= 4.3)
System.Threading.Tasks (>= 4.3)
System.Memory (4.5.4)
System.Memory (4.5.5)
System.Buffers (>= 4.5.1) - restriction: || (&& (== netcoreapp3.1) (>= monotouch)) (&& (== netcoreapp3.1) (>= net461)) (&& (== netcoreapp3.1) (< netcoreapp2.0)) (&& (== netcoreapp3.1) (< netstandard1.1)) (&& (== netcoreapp3.1) (< netstandard2.0)) (&& (== netcoreapp3.1) (>= xamarinios)) (&& (== netcoreapp3.1) (>= xamarinmac)) (&& (== netcoreapp3.1) (>= xamarintvos)) (&& (== netcoreapp3.1) (>= xamarinwatchos)) (== netstandard2.0) (== netstandard2.1)
System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== netcoreapp3.1) (< netcoreapp2.0)) (== netstandard2.0) (== netstandard2.1)
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== netcoreapp3.1) (>= monotouch)) (&& (== netcoreapp3.1) (>= net461)) (&& (== netcoreapp3.1) (< netcoreapp2.0)) (&& (== netcoreapp3.1) (< netcoreapp2.1)) (&& (== netcoreapp3.1) (< netstandard1.1)) (&& (== netcoreapp3.1) (< netstandard2.0)) (&& (== netcoreapp3.1) (>= uap10.1)) (&& (== netcoreapp3.1) (>= xamarinios)) (&& (== netcoreapp3.1) (>= xamarinmac)) (&& (== netcoreapp3.1) (>= xamarintvos)) (&& (== netcoreapp3.1) (>= xamarinwatchos)) (== netstandard2.0) (== netstandard2.1)
Expand All @@ -58,8 +59,9 @@ NUGET
System.Reflection.Emit (4.7)
System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== netcoreapp3.1) (< netcoreapp2.0) (< netstandard2.1)) (&& (== netcoreapp3.1) (< netstandard1.1)) (&& (== netcoreapp3.1) (< netstandard2.0)) (&& (== netcoreapp3.1) (>= uap10.1)) (== netstandard2.0) (&& (== netstandard2.1) (< netstandard1.1)) (&& (== netstandard2.1) (< netstandard2.0)) (&& (== netstandard2.1) (>= uap10.1))
System.Reflection.Emit.ILGeneration (4.7) - restriction: || (&& (== netcoreapp3.1) (< netcoreapp2.0) (< netstandard2.1)) (&& (== netcoreapp3.1) (< netstandard1.1)) (&& (== netcoreapp3.1) (< netstandard2.0)) (&& (== netcoreapp3.1) (>= uap10.1)) (== netstandard2.0) (&& (== netstandard2.1) (< netstandard1.1)) (&& (== netstandard2.1) (< netstandard2.0)) (&& (== netstandard2.1) (>= uap10.1))
System.Reflection.Metadata (5.0)
System.Collections.Immutable (>= 5.0)
System.Reflection.Metadata (7.0.1)
System.Collections.Immutable (>= 7.0)
System.Memory (>= 4.5.5)
System.Reflection.Primitives (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.NETCore.Targets (>= 1.1)
Expand All @@ -68,7 +70,7 @@ NUGET
System.Runtime (4.3.1)
Microsoft.NETCore.Platforms (>= 1.1.1)
Microsoft.NETCore.Targets (>= 1.1.3)
System.Runtime.CompilerServices.Unsafe (5.0) - restriction: || (&& (== netcoreapp3.1) (>= monotouch)) (&& (== netcoreapp3.1) (>= net461)) (&& (== netcoreapp3.1) (< netcoreapp2.0)) (&& (== netcoreapp3.1) (< netcoreapp2.1)) (&& (== netcoreapp3.1) (< netstandard1.1)) (&& (== netcoreapp3.1) (< netstandard2.0)) (&& (== netcoreapp3.1) (>= uap10.1)) (&& (== netcoreapp3.1) (>= xamarinios)) (&& (== netcoreapp3.1) (>= xamarinmac)) (&& (== netcoreapp3.1) (>= xamarintvos)) (&& (== netcoreapp3.1) (>= xamarinwatchos)) (== netstandard2.0) (== netstandard2.1)
System.Runtime.CompilerServices.Unsafe (6.0)
System.Runtime.Loader (4.3)
System.IO (>= 4.3)
System.Reflection (>= 4.3)
Expand Down
14 changes: 5 additions & 9 deletions run.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open Fake.IO

open RunHelpers
open RunHelpers.BasicShortcuts
open RunHelpers.Shortcuts
open RunHelpers.Templates

[<RequireQualifiedAccess>]
Expand Down Expand Up @@ -62,7 +62,6 @@ let main args =
|> List.ofArray
|> function
| [ "restore" ] -> Task.restore ()
| []
| [ "build" ] ->
job {
Task.restore ()
Expand All @@ -74,6 +73,7 @@ let main args =
Task.build Release
Task.pack version
}
| []
| [ "test" ] ->
job {
Task.restore ()
Expand All @@ -92,14 +92,10 @@ let main args =
Task.Docs.watch ()
}
// Missing args cases
| [ "pack" ] ->
let msg = [ "Usage: dotnet run pack <version>" ]
Error(1, msg)
| [ "pack" ] -> Job.error [ "Usage: dotnet run pack <version>" ]
// Default error case
| _ ->
let msg =
Job.error
[ "Usage: dotnet run [<command>]"
"Look up available commands in run.fs" ]

Error(1, msg)
|> ProcessResult.wrapUp
|> Job.execute
4 changes: 2 additions & 2 deletions run.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<WarnOn>3390;$(WarnOn)</WarnOn>
</PropertyGroup>

Expand All @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NicoVIII.RunHelpers" Version="0.5.0-alpha.3" />
<PackageReference Include="NicoVIII.RunHelpers" Version="0.5.0" />
</ItemGroup>

</Project>
20 changes: 7 additions & 13 deletions src/TypedPersistence/Core/Core.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ namespace TypedPersistence.Core

open System

// C# friendly single case union: http://fssnip.net/7Vd
/// Type for version of saves
// TODO: think about it. I'm not sure, if I want that. I like SCUs for Domain Modelling but here it feels like unnecessary boilerplate somehow?
[<Struct>]
type Version =
| Version of uint32
override this.ToString() = let (Version v) = this in string v
static member op_Equality(a, b: Version) = a = b
static member op_Inequality(a, b: Version) = a <> b
type Version = uint32

type IPersistenceProvider<'context> =
abstract getVersion: 'context -> Version option
Expand All @@ -21,8 +13,8 @@ type IPersistenceProvider<'context> =
type IPersistenceProviderCSharp<'context> =
abstract GetVersion: 'context -> Nullable<Version>

abstract Load<'T when 'T: struct and 'T: (new: unit -> 'T) and 'T :> System.ValueType> : 'context
-> Nullable<'T>
abstract Load<'T when 'T: struct and 'T: (new: unit -> 'T) and 'T :> System.ValueType> :
'context -> Nullable<'T>

abstract Save<'T> : 'context * 'T -> unit
abstract SaveVersion<'T> : 'context * Version * 'T -> unit
Expand All @@ -34,8 +26,10 @@ module Provider =
member _.GetVersion context =
provider.getVersion context |> Option.toNullable

member _.Load<'T when 'T: struct and 'T: (new: unit -> 'T) and 'T :> System.ValueType> context
=
member _.Load<'T
when 'T: struct and 'T: (new: unit -> 'T) and 'T :> System.ValueType>
context
=
provider.load<'T> context |> Option.toNullable

member _.Save<'T>(context, object) = provider.save<'T> context object
Expand Down
2 changes: 1 addition & 1 deletion src/TypedPersistence/Core/TypedPersistence.Core.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/TypedPersistence/Json/Helper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ module Helper =
let deserializeJson<'a> content =
try
Json.deserialize<'a> content |> Some
with :? JsonDeserializationError -> None
with :? JsonDeserializationError ->
None
7 changes: 5 additions & 2 deletions src/TypedPersistence/Json/Loading.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ open TypedPersistence.Json.Types
[<AutoOpen>]
module Loading =
let private getFileContent filepath =
if File.Exists filepath then File.ReadAllText filepath |> Some else None
if File.Exists filepath then
File.ReadAllText filepath |> Some
else
None

let getVersion (filepath: string) =
opt {
let! content = getFileContent filepath
let! parsed = deserializeJson<OnlyVersion> content
return parsed.version |> Version
return parsed.version
}

let load<'a> (filepath: string) =
Expand Down

0 comments on commit 7edf309

Please sign in to comment.