From 7a2f2bd92df8358c1e34d6f75b182896542c96d5 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Fri, 17 Sep 2021 17:35:07 -0400 Subject: [PATCH] WIP on .NET 6 conversion (#31) --- src/Directory.Build.props | 6 +++--- src/PrayerTracker.Data/DataAccess.fs | 1 - src/PrayerTracker.Data/Entities.fs | 2 ++ .../Migrations/20161217153124_InitialDatabase.fs | 1 + src/PrayerTracker.Data/PrayerTracker.Data.fsproj | 9 ++++----- src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj | 6 +++--- src/PrayerTracker.Tests/UI/CommonFunctionsTests.fs | 2 +- src/PrayerTracker.UI/Church.fs | 2 +- src/PrayerTracker.UI/CommonFunctions.fs | 10 +++++++++- src/PrayerTracker.UI/Home.fs | 4 ++-- src/PrayerTracker.UI/Layout.fs | 2 +- src/PrayerTracker.UI/PrayerRequest.fs | 2 +- src/PrayerTracker.UI/PrayerTracker.UI.fsproj | 9 +++++---- src/PrayerTracker.UI/SmallGroup.fs | 2 +- src/PrayerTracker.UI/User.fs | 2 +- src/PrayerTracker.UI/ViewModels.fs | 4 ++-- src/PrayerTracker/Church.fs | 1 - src/PrayerTracker/CommonFunctions.fs | 3 +-- src/PrayerTracker/Cookies.fs | 5 +++-- src/PrayerTracker/Email.fs | 3 +-- src/PrayerTracker/Extensions.fs | 1 + src/PrayerTracker/PrayerRequest.fs | 1 - src/PrayerTracker/PrayerTracker.fsproj | 6 +++--- src/PrayerTracker/SmallGroup.fs | 3 +-- src/PrayerTracker/User.fs | 1 - 25 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 47fecfd..9e16426 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,9 +1,9 @@ - 7.5.0.0 - 7.5.0.0 + 7.6.0.0 + 7.6.0.0 danieljsummers Bit Badger Solutions - 7.5.0 + 7.6.0 diff --git a/src/PrayerTracker.Data/DataAccess.fs b/src/PrayerTracker.Data/DataAccess.fs index 2dc2215..6dfebcd 100644 --- a/src/PrayerTracker.Data/DataAccess.fs +++ b/src/PrayerTracker.Data/DataAccess.fs @@ -1,7 +1,6 @@ [] module PrayerTracker.DataAccess -open FSharp.Control.Tasks.ContextInsensitive open Microsoft.EntityFrameworkCore open PrayerTracker.Entities open System.Collections.Generic diff --git a/src/PrayerTracker.Data/Entities.fs b/src/PrayerTracker.Data/Entities.fs index 6718779..1780d11 100644 --- a/src/PrayerTracker.Data/Entities.fs +++ b/src/PrayerTracker.Data/Entities.fs @@ -6,6 +6,8 @@ open NodaTime open System open System.Collections.Generic +// fsharplint:disable RecordFieldNames MemberNames + (*-- SUPPORT TYPES --*) /// How as-of dates should (or should not) be displayed with requests diff --git a/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs b/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs index 7f5b230..c228771 100644 --- a/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs +++ b/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs @@ -10,6 +10,7 @@ open PrayerTracker open PrayerTracker.Entities open System +// fsharplint:disable RecordFieldNames type ChurchTable = { churchId : OperationBuilder diff --git a/src/PrayerTracker.Data/PrayerTracker.Data.fsproj b/src/PrayerTracker.Data/PrayerTracker.Data.fsproj index b00699a..b7eeb49 100644 --- a/src/PrayerTracker.Data/PrayerTracker.Data.fsproj +++ b/src/PrayerTracker.Data/PrayerTracker.Data.fsproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 @@ -14,10 +14,9 @@ - - - - + + + diff --git a/src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj b/src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj index ebe2fbf..14f1306 100644 --- a/src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj +++ b/src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj @@ -2,7 +2,7 @@ Exe - net5.0 + net6.0 @@ -15,9 +15,9 @@ - + - + diff --git a/src/PrayerTracker.Tests/UI/CommonFunctionsTests.fs b/src/PrayerTracker.Tests/UI/CommonFunctionsTests.fs index 156345f..437feed 100644 --- a/src/PrayerTracker.Tests/UI/CommonFunctionsTests.fs +++ b/src/PrayerTracker.Tests/UI/CommonFunctionsTests.fs @@ -1,7 +1,7 @@ module PrayerTracker.UI.CommonFunctionsTests open Expecto -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine open Microsoft.AspNetCore.Mvc.Localization open Microsoft.Extensions.Localization open PrayerTracker.Tests.TestLocalization diff --git a/src/PrayerTracker.UI/Church.fs b/src/PrayerTracker.UI/Church.fs index 167390c..cdeed04 100644 --- a/src/PrayerTracker.UI/Church.fs +++ b/src/PrayerTracker.UI/Church.fs @@ -1,6 +1,6 @@ module PrayerTracker.Views.Church -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine open PrayerTracker.Entities open PrayerTracker.ViewModels diff --git a/src/PrayerTracker.UI/CommonFunctions.fs b/src/PrayerTracker.UI/CommonFunctions.fs index 9fa8aea..8d55bc8 100644 --- a/src/PrayerTracker.UI/CommonFunctions.fs +++ b/src/PrayerTracker.UI/CommonFunctions.fs @@ -2,8 +2,9 @@ module PrayerTracker.Views.CommonFunctions open Giraffe -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine open Microsoft.AspNetCore.Antiforgery +open Microsoft.AspNetCore.Html open Microsoft.AspNetCore.Http open Microsoft.AspNetCore.Mvc.Localization open Microsoft.Extensions.Localization @@ -125,6 +126,13 @@ let _onsubmit = attr "onsubmit" let _scoped = flag "scoped" +/// The name this function used to have when the view engine was part of Giraffe +let renderHtmlNode = RenderView.AsString.htmlNode + +/// Render an HTML node, then return the value as an HTML string +let renderHtmlString = renderHtmlNode >> HtmlString + + /// Utility methods to help with time zones (and localization of their names) module TimeZones = diff --git a/src/PrayerTracker.UI/Home.fs b/src/PrayerTracker.UI/Home.fs index 2ad9fda..b987660 100644 --- a/src/PrayerTracker.UI/Home.fs +++ b/src/PrayerTracker.UI/Home.fs @@ -1,7 +1,7 @@ /// Views associated with the home page, or those that don't fit anywhere else module PrayerTracker.Views.Home -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine open Microsoft.AspNetCore.Html open PrayerTracker.ViewModels open System.IO @@ -204,7 +204,7 @@ let termsOfService vi = let raw = rawLocText sw let ppLink = a [ _href "/web/legal/privacy-policy" ] [ str (s.["Privacy Policy"].Value.ToLower ()) ] - |> (renderHtmlNode >> HtmlString) + |> renderHtmlString [ p [ _class "pt-right-text" ] [ small [] [ em [] [ raw l.["(as of May 24, 2018)"] ] ] ] h3 [] [ str "1. "; raw l.["Acceptance of Terms"] ] diff --git a/src/PrayerTracker.UI/Layout.fs b/src/PrayerTracker.UI/Layout.fs index 1b9c558..4d299ab 100644 --- a/src/PrayerTracker.UI/Layout.fs +++ b/src/PrayerTracker.UI/Layout.fs @@ -1,7 +1,7 @@ /// Layout items for PrayerTracker module PrayerTracker.Views.Layout -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine open PrayerTracker open PrayerTracker.ViewModels open System diff --git a/src/PrayerTracker.UI/PrayerRequest.fs b/src/PrayerTracker.UI/PrayerRequest.fs index 60550d5..c8771e5 100644 --- a/src/PrayerTracker.UI/PrayerRequest.fs +++ b/src/PrayerTracker.UI/PrayerRequest.fs @@ -1,7 +1,7 @@ module PrayerTracker.Views.PrayerRequest open Giraffe -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine open Microsoft.AspNetCore.Http open NodaTime open PrayerTracker diff --git a/src/PrayerTracker.UI/PrayerTracker.UI.fsproj b/src/PrayerTracker.UI/PrayerTracker.UI.fsproj index fb49b75..4253ebc 100644 --- a/src/PrayerTracker.UI/PrayerTracker.UI.fsproj +++ b/src/PrayerTracker.UI/PrayerTracker.UI.fsproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 @@ -18,13 +18,14 @@ - - + + + - + diff --git a/src/PrayerTracker.UI/SmallGroup.fs b/src/PrayerTracker.UI/SmallGroup.fs index 068dd6d..0fdce40 100644 --- a/src/PrayerTracker.UI/SmallGroup.fs +++ b/src/PrayerTracker.UI/SmallGroup.fs @@ -1,6 +1,6 @@ module PrayerTracker.Views.SmallGroup -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine open Microsoft.Extensions.Localization open PrayerTracker open PrayerTracker.Entities diff --git a/src/PrayerTracker.UI/User.fs b/src/PrayerTracker.UI/User.fs index 965d0f8..86504b0 100644 --- a/src/PrayerTracker.UI/User.fs +++ b/src/PrayerTracker.UI/User.fs @@ -1,6 +1,6 @@ module PrayerTracker.Views.User -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine open PrayerTracker.Entities open PrayerTracker.ViewModels diff --git a/src/PrayerTracker.UI/ViewModels.fs b/src/PrayerTracker.UI/ViewModels.fs index 52c8b24..478171e 100644 --- a/src/PrayerTracker.UI/ViewModels.fs +++ b/src/PrayerTracker.UI/ViewModels.fs @@ -557,7 +557,7 @@ module UserLogOn = } -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine /// This represents a list of requests type RequestList = @@ -651,7 +651,7 @@ with |> ul [] br [] ] - |> renderHtmlNodes + |> RenderView.AsString.htmlNodes /// Generate this list as plain text member this.asText (s : IStringLocalizer) = diff --git a/src/PrayerTracker/Church.fs b/src/PrayerTracker/Church.fs index 2832fef..db062cb 100644 --- a/src/PrayerTracker/Church.fs +++ b/src/PrayerTracker/Church.fs @@ -1,6 +1,5 @@ module PrayerTracker.Handlers.Church -open FSharp.Control.Tasks.V2.ContextInsensitive open Giraffe open PrayerTracker open PrayerTracker.Entities diff --git a/src/PrayerTracker/CommonFunctions.fs b/src/PrayerTracker/CommonFunctions.fs index 00f5a46..2be1c82 100644 --- a/src/PrayerTracker/CommonFunctions.fs +++ b/src/PrayerTracker/CommonFunctions.fs @@ -2,7 +2,6 @@ [] module PrayerTracker.Handlers.CommonFunctions -open FSharp.Control.Tasks.V2.ContextInsensitive open Giraffe open Microsoft.AspNetCore.Antiforgery open Microsoft.AspNetCore.Html @@ -234,7 +233,7 @@ let requireAccess level : HttpHandler = } fun next ctx -> - task { + FSharp.Control.Tasks.Affine.task { // Auto-logon user or class, if required match isUserLoggedOn ctx with | true -> () diff --git a/src/PrayerTracker/Cookies.fs b/src/PrayerTracker/Cookies.fs index 6eca03f..13fc471 100644 --- a/src/PrayerTracker/Cookies.fs +++ b/src/PrayerTracker/Cookies.fs @@ -6,6 +6,7 @@ open System open System.Security.Cryptography open System.IO +// fsharplint:disable MemberNames /// Cryptography settings to use for encrypting cookies type CookieCrypto (key : string, iv : string) = @@ -24,7 +25,7 @@ module private Crypto = /// Encrypt a cookie payload let encrypt (payload : string) = - use aes = new AesManaged () + use aes = Aes.Create () use enc = aes.CreateEncryptor (crypto.Key, crypto.IV) use ms = new MemoryStream () use cs = new CryptoStream (ms, enc, CryptoStreamMode.Write) @@ -35,7 +36,7 @@ module private Crypto = /// Decrypt a cookie payload let decrypt payload = - use aes = new AesManaged () + use aes = Aes.Create () use dec = aes.CreateDecryptor (crypto.Key, crypto.IV) use ms = new MemoryStream (Convert.FromBase64String payload) use cs = new CryptoStream (ms, dec, CryptoStreamMode.Read) diff --git a/src/PrayerTracker/Email.fs b/src/PrayerTracker/Email.fs index 87dc18c..3dde503 100644 --- a/src/PrayerTracker/Email.fs +++ b/src/PrayerTracker/Email.fs @@ -1,7 +1,6 @@ /// Methods for sending e-mails module PrayerTracker.Email -open FSharp.Control.Tasks.ContextInsensitive open MailKit.Net.Smtp open MailKit.Security open Microsoft.Extensions.Localization @@ -62,7 +61,7 @@ let createTextMessage grp subj body (s : IStringLocalizer) = /// Send e-mails to a class let sendEmails (client : SmtpClient) (recipients : Member list) grp subj html text s = task { - let htmlMsg = createHtmlMessage grp subj html s + let htmlMsg = createHtmlMessage grp subj html s let plainTextMsg = createTextMessage grp subj text s for mbr in recipients do diff --git a/src/PrayerTracker/Extensions.fs b/src/PrayerTracker/Extensions.fs index f8c93c7..1b64d9f 100644 --- a/src/PrayerTracker/Extensions.fs +++ b/src/PrayerTracker/Extensions.fs @@ -7,6 +7,7 @@ open Newtonsoft.Json open PrayerTracker.Entities open PrayerTracker.ViewModels +// fsharplint:disable MemberNames type ISession with /// Set an object in the session diff --git a/src/PrayerTracker/PrayerRequest.fs b/src/PrayerTracker/PrayerRequest.fs index f272c6a..ca7ff05 100644 --- a/src/PrayerTracker/PrayerRequest.fs +++ b/src/PrayerTracker/PrayerRequest.fs @@ -1,6 +1,5 @@ module PrayerTracker.Handlers.PrayerRequest -open FSharp.Control.Tasks.V2.ContextInsensitive open Giraffe open Microsoft.AspNetCore.Http open NodaTime diff --git a/src/PrayerTracker/PrayerTracker.fsproj b/src/PrayerTracker/PrayerTracker.fsproj index 1cdc542..7eec552 100644 --- a/src/PrayerTracker/PrayerTracker.fsproj +++ b/src/PrayerTracker/PrayerTracker.fsproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 @@ -23,10 +23,10 @@ - + - + diff --git a/src/PrayerTracker/SmallGroup.fs b/src/PrayerTracker/SmallGroup.fs index 77685ac..79a467a 100644 --- a/src/PrayerTracker/SmallGroup.fs +++ b/src/PrayerTracker/SmallGroup.fs @@ -1,8 +1,7 @@ module PrayerTracker.Handlers.SmallGroup -open FSharp.Control.Tasks.V2.ContextInsensitive open Giraffe -open Giraffe.GiraffeViewEngine +open Giraffe.ViewEngine open Microsoft.AspNetCore.Http open NodaTime open PrayerTracker diff --git a/src/PrayerTracker/User.fs b/src/PrayerTracker/User.fs index 066d7f0..6d9467b 100644 --- a/src/PrayerTracker/User.fs +++ b/src/PrayerTracker/User.fs @@ -1,6 +1,5 @@ module PrayerTracker.Handlers.User -open FSharp.Control.Tasks.V2.ContextInsensitive open Giraffe open Microsoft.AspNetCore.Html open Microsoft.AspNetCore.Http