Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to .net 7 #27

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
###############################
# Core EditorConfig Options #
###############################
root = true
# All files
[*]
indent_style = space

# XML project files
[*.{csproj,fsproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2

# Code files
[*.{cs,csx,fs,fsx}]
indent_size = 4
insert_final_newline = true
charset = utf-8
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
dotnet-version: 7.x
- name: Restore
run: dotnet restore
- name: Build
Expand All @@ -40,7 +40,11 @@ jobs:
run: dotnet test -c Release
- name: Pack
if: matrix.os == 'ubuntu-latest'
run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:PackageVersion=$GITHUB_RUN_ID src/$PROJECT_NAME/$PROJECT_NAME.*proj
run: |
latestTag=$(git describe --tags --abbrev=0 2>/dev/null || echo 0.0.1)
runId=$GITHUB_RUN_ID
packageVersion="${latestTag//v}-build.${runId}"
dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:PackageVersion=$packageVersion src/$PROJECT_NAME/$PROJECT_NAME.*proj
- name: Upload Artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -71,7 +75,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
dotnet-version: 7.x
- name: Create Release NuGet package
run: |
arrTag=(${GITHUB_REF//\// })
Expand Down
76 changes: 55 additions & 21 deletions Giraffe.Razor.sln
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{03CCBA43-B6F5-4FA7-8C18-432BB07225FC}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Giraffe.Razor", "src\Giraffe.Razor\Giraffe.Razor.fsproj", "{9B52367B-CC80-452E-9062-7583995BFAC0}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Giraffe.Razor", "src\Giraffe.Razor\Giraffe.Razor.fsproj", "{9B52367B-CC80-452E-9062-7583995BFAC0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{E067A6B8-538E-4362-83C2-9ECBC486AC31}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GiraffeRazorSample", "samples\GiraffeRazorSample\GiraffeRazorSample.fsproj", "{14818084-9969-4F42-8A66-394FC6670B50}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "GiraffeRazorSample", "samples\GiraffeRazorSample\GiraffeRazorSample.fsproj", "{14818084-9969-4F42-8A66-394FC6670B50}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_root", "_root", "{73E09F74-F64D-4C42-92FC-19731C0C5553}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.gitattributes = .gitattributes
LICENSE = LICENSE
NuGet.config = NuGet.config
README.md = README.md
RELEASE_NOTES.md = RELEASE_NOTES.md
giraffe-64x64.png = giraffe-64x64.png
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
EndProjectSection
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
giraffe-64x64.png = giraffe-64x64.png
LICENSE = LICENSE
NuGet.config = NuGet.config
README.md = README.md
RELEASE_NOTES.md = RELEASE_NOTES.md
EndProjectSection
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Models", "samples\Models\Models.fsproj", "{7FF78E51-A357-4D4B-90FF-B03E148AE18C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorClassLibrary", "samples\RazorClassLibrary\RazorClassLibrary.csproj", "{0A429935-F750-4334-98BE-9FC26764A174}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -32,13 +37,6 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9B52367B-CC80-452E-9062-7583995BFAC0} = {03CCBA43-B6F5-4FA7-8C18-432BB07225FC}
{14818084-9969-4F42-8A66-394FC6670B50} = {E067A6B8-538E-4362-83C2-9ECBC486AC31}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9B52367B-CC80-452E-9062-7583995BFAC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B52367B-CC80-452E-9062-7583995BFAC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -64,5 +62,41 @@ Global
{14818084-9969-4F42-8A66-394FC6670B50}.Release|x64.Build.0 = Release|Any CPU
{14818084-9969-4F42-8A66-394FC6670B50}.Release|x86.ActiveCfg = Release|Any CPU
{14818084-9969-4F42-8A66-394FC6670B50}.Release|x86.Build.0 = Release|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Debug|x64.ActiveCfg = Debug|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Debug|x64.Build.0 = Debug|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Debug|x86.ActiveCfg = Debug|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Debug|x86.Build.0 = Debug|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Release|Any CPU.Build.0 = Release|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Release|x64.ActiveCfg = Release|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Release|x64.Build.0 = Release|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Release|x86.ActiveCfg = Release|Any CPU
{7FF78E51-A357-4D4B-90FF-B03E148AE18C}.Release|x86.Build.0 = Release|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Debug|x64.ActiveCfg = Debug|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Debug|x64.Build.0 = Debug|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Debug|x86.ActiveCfg = Debug|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Debug|x86.Build.0 = Debug|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Release|Any CPU.Build.0 = Release|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Release|x64.ActiveCfg = Release|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Release|x64.Build.0 = Release|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Release|x86.ActiveCfg = Release|Any CPU
{0A429935-F750-4334-98BE-9FC26764A174}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9B52367B-CC80-452E-9062-7583995BFAC0} = {03CCBA43-B6F5-4FA7-8C18-432BB07225FC}
{14818084-9969-4F42-8A66-394FC6670B50} = {E067A6B8-538E-4362-83C2-9ECBC486AC31}
{0A429935-F750-4334-98BE-9FC26764A174} = {E067A6B8-538E-4362-83C2-9ECBC486AC31}
{7FF78E51-A357-4D4B-90FF-B03E148AE18C} = {E067A6B8-538E-4362-83C2-9ECBC486AC31}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D44B626-1BB8-4B87-8E9F-045072A0598C}
EndGlobalSection
EndGlobal
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Release Notes
=============

## 5.2.0

- Upgraded to .NET 7
- Updated `Giraffe` dependency to `6.0.0`
- Updated Sample project
- Changed `Ply` to native `task` CE

## 5.1.0-rc-2

- Updated `Giraffe` dependency to `5.0.0-rc-6` and changed from `TaskBuilder.fs` to `Ply` for `task` CEs.
Expand Down
19 changes: 6 additions & 13 deletions samples/GiraffeRazorSample/GiraffeRazorSample.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AssemblyName>GiraffeRazorSample</AssemblyName>
<PackageId>GiraffeRazorSample</PackageId>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
Expand All @@ -10,24 +10,17 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Giraffe.Razor\Giraffe.Razor.fsproj" />
<ProjectReference Include="..\Models\Models.fsproj" />
<ProjectReference Include="..\RazorClassLibrary\RazorClassLibrary.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ply" Version="0.3.*" />
</ItemGroup>

<ItemGroup>
<Watch Include="**\*.cshtml" Exclude="bin\**\*" />
<None Include="Properties\launchSettings.json" />
<Content Include="wwwroot\main.css" />
</ItemGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<Content Include="Views\*.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
52 changes: 25 additions & 27 deletions samples/GiraffeRazorSample/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,12 @@ open Microsoft.AspNetCore
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Http
open Microsoft.AspNetCore.Http.Features
open Microsoft.AspNetCore.Mvc.ModelBinding
open Microsoft.Extensions.Logging
open Microsoft.Extensions.DependencyInjection
open FSharp.Control.Tasks
open Giraffe
open Giraffe.Razor

// ---------------------------------
// Models
// ---------------------------------

[<CLIMutable>]
type Person =
{
Name : string
}

[<CLIMutable>]
type CreatePerson =
{
Name : string
CheckMe : bool
}
open Models

// ---------------------------------
// Web app
Expand Down Expand Up @@ -62,8 +44,7 @@ let smallFileUploadHandler =
let largeFileUploadHandler =
fun (next : HttpFunc) (ctx : HttpContext) ->
task {
let formFeature = ctx.Features.Get<IFormFeature>()
let! form = formFeature.ReadFormAsync CancellationToken.None
let! form = ctx.Request.ReadFormAsync CancellationToken.None
return! (form.Files |> displayFileInfos) next ctx
}

Expand All @@ -81,7 +62,7 @@ let renderPerson =

let renderCreatePerson =
let model = { Name = ""; CheckMe = true }
let viewData = dict [("Title", box "Create peson")]
let viewData = dict [("Title", box "Create person")]
razorHtmlView "CreatePerson" (Some model) (Some viewData) None

let createPerson =
Expand All @@ -97,7 +78,7 @@ let createPerson =
let url = sprintf "/person?name=%s" model.Name
return! redirectTo false url next ctx
else
let viewData = dict [("Title", box "Create peson")]
let viewData = dict [("Title", box "Create person")]
return! razorHtmlView "CreatePerson" (Some model) (Some viewData) (Some modelState) next ctx
}

Expand All @@ -108,11 +89,23 @@ let viewData =
"Bar", true :> obj
]

let renderIndex =
"""
<p>non razor index</p>
<ul>
<li><a href=/razor>razor</a></li></li>
<li><a href=/person>person</a></li></li>
<li><a href=/person/create>person/create</li></a></li>
<li><a href=/upload>upload</a></li>
</ul>
"""
|> htmlString

let webApp =
choose [
GET >=>
choose [
route "/" >=> text "index"
route "/" >=> renderIndex
route "/razor" >=> razorView "text/html" "Hello" None (Some viewData) None
route "/person/create" >=> renderCreatePerson
route "/person" >=> renderPerson
Expand All @@ -132,7 +125,7 @@ let webApp =

let errorHandler (ex : Exception) (logger : ILogger) =
logger.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.")
clearResponse >=> ServerErrors.INTERNAL_ERROR (text ex.Message)
clearResponse >=> ServerErrors.INTERNAL_ERROR ex.Message

// ---------------------------------
// Main
Expand All @@ -148,9 +141,14 @@ let configureServices (services : IServiceCollection) =
let sp = services.BuildServiceProvider()
let env = sp.GetService<IWebHostEnvironment>()
services.AddGiraffe() |> ignore
Path.Combine(env.ContentRootPath, "Views")
services.AddMvc() |> ignore // Required for Razor views to work, regardless of runtime compilation or not.
// Only use Razor runtime compilation in DEBUG (For hot reload to work)
// The statically compiled views are used in Release mode.
#if DEBUG
Path.GetFullPath(Path.Combine(env.ContentRootPath, "..", "RazorClassLibrary"))
|> services.AddRazorEngine
|> ignore
#endif

let configureLogging (loggerBuilder : ILoggingBuilder) =
loggerBuilder.AddFilter(fun lvl -> lvl.Equals LogLevel.Error)
Expand All @@ -168,4 +166,4 @@ let main _ =
.ConfigureLogging(configureLogging)
.Build()
.Run()
0
0
2 changes: 0 additions & 2 deletions samples/GiraffeRazorSample/Views/Partial.cshtml

This file was deleted.

18 changes: 18 additions & 0 deletions samples/Models/Models.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Models

// ---------------------------------
// Models
// ---------------------------------

[<CLIMutable>]
type Person =
{
Name : string
}

[<CLIMutable>]
type CreatePerson =
{
Name : string
CheckMe : bool
}
12 changes: 12 additions & 0 deletions samples/Models/Models.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="Models.fs" />
</ItemGroup>

</Project>
28 changes: 28 additions & 0 deletions samples/RazorClassLibrary/RazorClassLibrary.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>

<!--Necessary to support views in the razor library-->
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.10" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Models\Models.fsproj" />
</ItemGroup>

<ItemGroup>
<None Include="**\*.cshtml" />
</ItemGroup>

</Project>
Loading