From 9ddd98872e555415491609a3da0220ffd117958f Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Wed, 14 Aug 2019 20:39:55 +0200 Subject: [PATCH 1/7] Update zebra and giraffe to use dotnet core 3 --- frameworks/FSharp/giraffe/README.md | 2 +- .../FSharp/giraffe/giraffe-stripped.dockerfile | 4 ++-- .../FSharp/giraffe/giraffe-utf8direct.dockerfile | 4 ++-- .../FSharp/giraffe/giraffe-utf8json.dockerfile | 4 ++-- frameworks/FSharp/giraffe/giraffe.dockerfile | 4 ++-- frameworks/FSharp/giraffe/src/App/App.fsproj | 16 +++++++--------- frameworks/FSharp/zebra/README.md | 2 +- frameworks/FSharp/zebra/src/App/App.fsproj | 13 +++++-------- frameworks/FSharp/zebra/zebra-simple.dockerfile | 4 ++-- frameworks/FSharp/zebra/zebra.dockerfile | 4 ++-- 10 files changed, 26 insertions(+), 31 deletions(-) diff --git a/frameworks/FSharp/giraffe/README.md b/frameworks/FSharp/giraffe/README.md index dfb4a5fc5e6..209ef423bb8 100644 --- a/frameworks/FSharp/giraffe/README.md +++ b/frameworks/FSharp/giraffe/README.md @@ -5,7 +5,7 @@ This includes tests for plaintext and json serialization. **Language** -* F# 4.1 +* F# 4.7 **Platforms** diff --git a/frameworks/FSharp/giraffe/giraffe-stripped.dockerfile b/frameworks/FSharp/giraffe/giraffe-stripped.dockerfile index 09d0926bfd4..7eda4f9b34c 100644 --- a/frameworks/FSharp/giraffe/giraffe-stripped.dockerfile +++ b/frameworks/FSharp/giraffe/giraffe-stripped.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build WORKDIR /app COPY src/App . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime +FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 ENV COMPlus_ReadyToRun 0 WORKDIR /app diff --git a/frameworks/FSharp/giraffe/giraffe-utf8direct.dockerfile b/frameworks/FSharp/giraffe/giraffe-utf8direct.dockerfile index 09d0926bfd4..7eda4f9b34c 100644 --- a/frameworks/FSharp/giraffe/giraffe-utf8direct.dockerfile +++ b/frameworks/FSharp/giraffe/giraffe-utf8direct.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build WORKDIR /app COPY src/App . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime +FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 ENV COMPlus_ReadyToRun 0 WORKDIR /app diff --git a/frameworks/FSharp/giraffe/giraffe-utf8json.dockerfile b/frameworks/FSharp/giraffe/giraffe-utf8json.dockerfile index 09d0926bfd4..7eda4f9b34c 100644 --- a/frameworks/FSharp/giraffe/giraffe-utf8json.dockerfile +++ b/frameworks/FSharp/giraffe/giraffe-utf8json.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build WORKDIR /app COPY src/App . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime +FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 ENV COMPlus_ReadyToRun 0 WORKDIR /app diff --git a/frameworks/FSharp/giraffe/giraffe.dockerfile b/frameworks/FSharp/giraffe/giraffe.dockerfile index 322b23b984c..1c47ed7f5f5 100644 --- a/frameworks/FSharp/giraffe/giraffe.dockerfile +++ b/frameworks/FSharp/giraffe/giraffe.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build WORKDIR /app COPY src/App . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime +FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 ENV COMPlus_ReadyToRun 0 WORKDIR /app diff --git a/frameworks/FSharp/giraffe/src/App/App.fsproj b/frameworks/FSharp/giraffe/src/App/App.fsproj index e034ca4e748..326774d0859 100644 --- a/frameworks/FSharp/giraffe/src/App/App.fsproj +++ b/frameworks/FSharp/giraffe/src/App/App.fsproj @@ -1,7 +1,8 @@ - netcoreapp2.2 + netcoreapp3.0 + preview portable App Exe @@ -9,12 +10,9 @@ - - - - - - + + + @@ -28,7 +26,7 @@ - + - \ No newline at end of file + \ No newline at end of file diff --git a/frameworks/FSharp/zebra/README.md b/frameworks/FSharp/zebra/README.md index 7f3249e8fd0..040060a60fd 100644 --- a/frameworks/FSharp/zebra/README.md +++ b/frameworks/FSharp/zebra/README.md @@ -7,7 +7,7 @@ Zebra is a new F# functional Asp.net Framework Wrapper that utalises a shared st **Language** -* F# 4.1 +* F# 4.7 **Platforms** diff --git a/frameworks/FSharp/zebra/src/App/App.fsproj b/frameworks/FSharp/zebra/src/App/App.fsproj index 6f20f4f4487..69551986182 100644 --- a/frameworks/FSharp/zebra/src/App/App.fsproj +++ b/frameworks/FSharp/zebra/src/App/App.fsproj @@ -1,7 +1,8 @@  - netcoreapp2.1 + netcoreapp3.0 + preview portable App Exe @@ -9,12 +10,8 @@ - - - - - - + + @@ -33,7 +30,7 @@ - + \ No newline at end of file diff --git a/frameworks/FSharp/zebra/zebra-simple.dockerfile b/frameworks/FSharp/zebra/zebra-simple.dockerfile index 1786c0cd394..3cd053f0607 100644 --- a/frameworks/FSharp/zebra/zebra-simple.dockerfile +++ b/frameworks/FSharp/zebra/zebra-simple.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build WORKDIR /app COPY src/App . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime +FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 ENV COMPlus_ReadyToRun 0 WORKDIR /app diff --git a/frameworks/FSharp/zebra/zebra.dockerfile b/frameworks/FSharp/zebra/zebra.dockerfile index 09d0926bfd4..7eda4f9b34c 100644 --- a/frameworks/FSharp/zebra/zebra.dockerfile +++ b/frameworks/FSharp/zebra/zebra.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build WORKDIR /app COPY src/App . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime +FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 ENV COMPlus_ReadyToRun 0 WORKDIR /app From d0bd026d164833ca84b4bf389b5c6a1d3003482e Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 15 Aug 2019 07:59:00 +0200 Subject: [PATCH 2/7] Remove obsole env variable --- frameworks/FSharp/giraffe/giraffe-stripped.dockerfile | 1 - frameworks/FSharp/giraffe/giraffe-utf8direct.dockerfile | 1 - frameworks/FSharp/giraffe/giraffe-utf8json.dockerfile | 1 - frameworks/FSharp/giraffe/giraffe.dockerfile | 1 - frameworks/FSharp/zebra/zebra-simple.dockerfile | 1 - frameworks/FSharp/zebra/zebra.dockerfile | 1 - 6 files changed, 6 deletions(-) diff --git a/frameworks/FSharp/giraffe/giraffe-stripped.dockerfile b/frameworks/FSharp/giraffe/giraffe-stripped.dockerfile index 7eda4f9b34c..73acf6c5b0a 100644 --- a/frameworks/FSharp/giraffe/giraffe-stripped.dockerfile +++ b/frameworks/FSharp/giraffe/giraffe-stripped.dockerfile @@ -5,7 +5,6 @@ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 -ENV COMPlus_ReadyToRun 0 WORKDIR /app COPY --from=build /app/out ./ diff --git a/frameworks/FSharp/giraffe/giraffe-utf8direct.dockerfile b/frameworks/FSharp/giraffe/giraffe-utf8direct.dockerfile index 7eda4f9b34c..73acf6c5b0a 100644 --- a/frameworks/FSharp/giraffe/giraffe-utf8direct.dockerfile +++ b/frameworks/FSharp/giraffe/giraffe-utf8direct.dockerfile @@ -5,7 +5,6 @@ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 -ENV COMPlus_ReadyToRun 0 WORKDIR /app COPY --from=build /app/out ./ diff --git a/frameworks/FSharp/giraffe/giraffe-utf8json.dockerfile b/frameworks/FSharp/giraffe/giraffe-utf8json.dockerfile index 7eda4f9b34c..73acf6c5b0a 100644 --- a/frameworks/FSharp/giraffe/giraffe-utf8json.dockerfile +++ b/frameworks/FSharp/giraffe/giraffe-utf8json.dockerfile @@ -5,7 +5,6 @@ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 -ENV COMPlus_ReadyToRun 0 WORKDIR /app COPY --from=build /app/out ./ diff --git a/frameworks/FSharp/giraffe/giraffe.dockerfile b/frameworks/FSharp/giraffe/giraffe.dockerfile index 1c47ed7f5f5..17271bda28f 100644 --- a/frameworks/FSharp/giraffe/giraffe.dockerfile +++ b/frameworks/FSharp/giraffe/giraffe.dockerfile @@ -5,7 +5,6 @@ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 -ENV COMPlus_ReadyToRun 0 WORKDIR /app COPY --from=build /app/out ./ diff --git a/frameworks/FSharp/zebra/zebra-simple.dockerfile b/frameworks/FSharp/zebra/zebra-simple.dockerfile index 3cd053f0607..1a3ca04fa0b 100644 --- a/frameworks/FSharp/zebra/zebra-simple.dockerfile +++ b/frameworks/FSharp/zebra/zebra-simple.dockerfile @@ -5,7 +5,6 @@ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 -ENV COMPlus_ReadyToRun 0 WORKDIR /app COPY --from=build /app/out ./ diff --git a/frameworks/FSharp/zebra/zebra.dockerfile b/frameworks/FSharp/zebra/zebra.dockerfile index 7eda4f9b34c..73acf6c5b0a 100644 --- a/frameworks/FSharp/zebra/zebra.dockerfile +++ b/frameworks/FSharp/zebra/zebra.dockerfile @@ -5,7 +5,6 @@ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 -ENV COMPlus_ReadyToRun 0 WORKDIR /app COPY --from=build /app/out ./ From 788a84388d2c599c55302ef30fb07d768393e822 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 15 Aug 2019 07:59:31 +0200 Subject: [PATCH 3/7] Simplify fsproj --- frameworks/FSharp/giraffe/src/App/App.fsproj | 5 +---- frameworks/FSharp/zebra/src/App/App.fsproj | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/frameworks/FSharp/giraffe/src/App/App.fsproj b/frameworks/FSharp/giraffe/src/App/App.fsproj index 326774d0859..3dc4521443b 100644 --- a/frameworks/FSharp/giraffe/src/App/App.fsproj +++ b/frameworks/FSharp/giraffe/src/App/App.fsproj @@ -14,6 +14,7 @@ + @@ -25,8 +26,4 @@ - - - - \ No newline at end of file diff --git a/frameworks/FSharp/zebra/src/App/App.fsproj b/frameworks/FSharp/zebra/src/App/App.fsproj index 69551986182..894bc209f04 100644 --- a/frameworks/FSharp/zebra/src/App/App.fsproj +++ b/frameworks/FSharp/zebra/src/App/App.fsproj @@ -13,6 +13,7 @@ + @@ -29,8 +30,4 @@ - - - - \ No newline at end of file From 9b125b13addceae9eefbd40a18128e168bf93c75 Mon Sep 17 00:00:00 2001 From: Stuart Lang Date: Thu, 15 Aug 2019 10:51:27 +0100 Subject: [PATCH 4/7] Use anonymouse json message types --- frameworks/FSharp/giraffe/src/App/Custom.fs | 2 +- frameworks/FSharp/giraffe/src/App/Models.fs | 5 ----- frameworks/FSharp/giraffe/src/App/Stock.fs | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/frameworks/FSharp/giraffe/src/App/Custom.fs b/frameworks/FSharp/giraffe/src/App/Custom.fs index 1e6a4a0f9e3..2fa7301448a 100644 --- a/frameworks/FSharp/giraffe/src/App/Custom.fs +++ b/frameworks/FSharp/giraffe/src/App/Custom.fs @@ -108,7 +108,7 @@ let application : HttpHandler = routes' [ "/plaintext", text' "Hello, World!" - "/json", json' { JsonStructMessage.message = "Hello, World!" } + "/json", json' struct {| message = "Hello, World!" |} "/fortunes", fortunes' ] diff --git a/frameworks/FSharp/giraffe/src/App/Models.fs b/frameworks/FSharp/giraffe/src/App/Models.fs index 69b5e58640b..f67b6e77db6 100644 --- a/frameworks/FSharp/giraffe/src/App/Models.fs +++ b/frameworks/FSharp/giraffe/src/App/Models.fs @@ -3,11 +3,6 @@ open System.Collections.Generic open System -type JsonMessage = { message : string } - -[] -type JsonStructMessage = { message : string } - [] type Fortune = { id: int; message: string } diff --git a/frameworks/FSharp/giraffe/src/App/Stock.fs b/frameworks/FSharp/giraffe/src/App/Stock.fs index e8b7cf8e701..39876908f88 100644 --- a/frameworks/FSharp/giraffe/src/App/Stock.fs +++ b/frameworks/FSharp/giraffe/src/App/Stock.fs @@ -34,6 +34,6 @@ let application : HttpHandler = choose [ route "/plaintext" >=> text "Hello, World!" - route "/json" >=> json { JsonMessage.message = "Hello, World!" } + route "/json" >=> json {| message = "Hello, World!" |} route "/fortunes" >=> fortunes ] From 906151e399fc1b7861e9af5f8c71061f677fd1e9 Mon Sep 17 00:00:00 2001 From: Stuart Lang Date: Thu, 15 Aug 2019 12:44:17 +0100 Subject: [PATCH 5/7] Use System.Text.Json --- frameworks/FSharp/giraffe/src/App/App.fsproj | 1 - frameworks/FSharp/giraffe/src/App/Custom.fs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/FSharp/giraffe/src/App/App.fsproj b/frameworks/FSharp/giraffe/src/App/App.fsproj index 3dc4521443b..87d64e52820 100644 --- a/frameworks/FSharp/giraffe/src/App/App.fsproj +++ b/frameworks/FSharp/giraffe/src/App/App.fsproj @@ -13,7 +13,6 @@ - diff --git a/frameworks/FSharp/giraffe/src/App/Custom.fs b/frameworks/FSharp/giraffe/src/App/Custom.fs index 2fa7301448a..f871e4da24e 100644 --- a/frameworks/FSharp/giraffe/src/App/Custom.fs +++ b/frameworks/FSharp/giraffe/src/App/Custom.fs @@ -43,7 +43,7 @@ let application : HttpHandler = let inline contentLength x = new Nullable ( int64 x ) let json' data : HttpHandler = - let bytes = Utf8Json.JsonSerializer.Serialize(data) + let bytes = System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(data) fun _ ctx -> ctx.Response.ContentLength <- contentLength bytes.Length ctx.Response.ContentType <- "application/json" From 815f99f946df2cc8ce5f644a55ef394947625c63 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 15 Aug 2019 17:21:41 +0200 Subject: [PATCH 6/7] Set language version to F# 4.6 --- frameworks/FSharp/giraffe/README.md | 2 +- frameworks/FSharp/zebra/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/FSharp/giraffe/README.md b/frameworks/FSharp/giraffe/README.md index 209ef423bb8..aaced20e92c 100644 --- a/frameworks/FSharp/giraffe/README.md +++ b/frameworks/FSharp/giraffe/README.md @@ -5,7 +5,7 @@ This includes tests for plaintext and json serialization. **Language** -* F# 4.7 +* F# 4.6 **Platforms** diff --git a/frameworks/FSharp/zebra/README.md b/frameworks/FSharp/zebra/README.md index 040060a60fd..27b9a1ab6c7 100644 --- a/frameworks/FSharp/zebra/README.md +++ b/frameworks/FSharp/zebra/README.md @@ -7,7 +7,7 @@ Zebra is a new F# functional Asp.net Framework Wrapper that utalises a shared st **Language** -* F# 4.7 +* F# 4.6 **Platforms** From e6e633d6bdd936beace3cc60328faad84604e2d7 Mon Sep 17 00:00:00 2001 From: Stuart Lang Date: Thu, 15 Aug 2019 16:33:25 +0100 Subject: [PATCH 7/7] Use async serialization --- frameworks/FSharp/giraffe/src/App/Custom.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/FSharp/giraffe/src/App/Custom.fs b/frameworks/FSharp/giraffe/src/App/Custom.fs index f871e4da24e..0366dd94052 100644 --- a/frameworks/FSharp/giraffe/src/App/Custom.fs +++ b/frameworks/FSharp/giraffe/src/App/Custom.fs @@ -11,6 +11,7 @@ open System.IO let private DefaultCapacity = 1386 let private MaxBuilderSize = DefaultCapacity * 3 +let private BufferSize = 27 type MemoryStreamCache = @@ -43,13 +44,12 @@ let application : HttpHandler = let inline contentLength x = new Nullable ( int64 x ) let json' data : HttpHandler = - let bytes = System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(data) fun _ ctx -> - ctx.Response.ContentLength <- contentLength bytes.Length + ctx.Response.ContentLength <- contentLength BufferSize ctx.Response.ContentType <- "application/json" ctx.Response.StatusCode <- 200 task { - do! ctx.Response.Body.WriteAsync(bytes, 0, bytes.Length) + do! System.Text.Json.JsonSerializer.SerializeAsync(ctx.Response.Body, data) return Some ctx }