Skip to content

Commit 467524c

Browse files
committed
Merge branch 'develop'
2 parents 313d7f1 + c6325de commit 467524c

File tree

8 files changed

+66
-15
lines changed

8 files changed

+66
-15
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Setup .NET Core
3232
uses: actions/setup-dotnet@v1
3333
with:
34-
dotnet-version: 5.0.100
34+
dotnet-version: 6.0.100
3535
- name: Restore
3636
run: dotnet restore
3737
- name: Build
@@ -71,7 +71,7 @@ jobs:
7171
- name: Setup .NET Core
7272
uses: actions/setup-dotnet@v1
7373
with:
74-
dotnet-version: 5.0.100
74+
dotnet-version: 6.0.100
7575
- name: Create Release NuGet package
7676
run: |
7777
arrTag=(${GITHUB_REF//\// })

RELEASE_NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Release Notes
22
=============
33

4+
## 2.0.0-alpha-1
5+
6+
- Updated to .NET 6 and Giraffe 6.0.0-alpha-*
7+
- Improved performance by removing redundant `ToArray` functions and making `XmlElement` a struct
8+
49
## 1.4.0
510

611
- Added `slot` and `template` elements

samples/Giraffe.ViewEngine.Sample/Giraffe.ViewEngine.Sample.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<RootNamespace>GithubExample</RootNamespace>
77
</PropertyGroup>
88

src/Giraffe.ViewEngine/Engine.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module HtmlElements =
3535
| KeyValue of string * string
3636
| Boolean of string
3737

38-
type XmlElement = string * XmlAttribute[] // Name * XML attributes
38+
type XmlElement = (struct(string * XmlAttribute list)) // Name * XML attributes
3939

4040
type XmlNode =
4141
| ParentNode of XmlElement * XmlNode list // An XML element which contains nested XML elements
@@ -58,11 +58,11 @@ module HtmlElements =
5858
let tag (tagName : string)
5959
(attributes : XmlAttribute list)
6060
(contents : XmlNode list) =
61-
ParentNode ((tagName, Array.ofList attributes), contents)
61+
ParentNode ((tagName, attributes), contents)
6262

6363
let voidTag (tagName : string)
6464
(attributes : XmlAttribute list) =
65-
VoidElement (tagName, Array.ofList attributes)
65+
VoidElement (tagName, attributes)
6666

6767
/// <summary>
6868
///
@@ -554,21 +554,21 @@ module internal ViewBuilder =
554554

555555
let rec internal buildNode (isHtml : bool) (sb : StringBuilder) (node : XmlNode) : unit =
556556

557-
let buildElement closingBracket (elemName, attributes : XmlAttribute array) =
557+
let buildElement closingBracket struct(elemName, attributes : XmlAttribute list) =
558558
match attributes with
559-
| [||] -> do sb += "<" += elemName +! closingBracket
559+
| [] -> do sb += "<" += elemName +! closingBracket
560560
| _ ->
561561
do sb += "<" +! elemName
562562

563563
attributes
564-
|> Array.iter (fun attr ->
564+
|> List.iter (fun attr ->
565565
match attr with
566566
| KeyValue (k, v) -> do sb += " " += k += "=\"" += v +! "\""
567567
| Boolean k -> do sb += " " +! k)
568568

569569
do sb +! closingBracket
570570

571-
let inline buildParentNode (elemName, attributes : XmlAttribute array) (nodes : XmlNode list) =
571+
let inline buildParentNode struct(elemName, attributes : XmlAttribute list) (nodes : XmlNode list) =
572572
do buildElement ">" (elemName, attributes)
573573
for node in nodes do buildNode isHtml sb node
574574
do sb += "</" += elemName +! ">"

src/Giraffe.ViewEngine/Giraffe.ViewEngine.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<NeutralLanguage>en-GB</NeutralLanguage>
99

1010
<!-- Build settings -->
11-
<TargetFrameworks>net5.0;netstandard2.0</TargetFrameworks>
11+
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
1212
<DebugType>portable</DebugType>
1313
<OutputType>Library</OutputType>
1414
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -46,5 +46,5 @@
4646
<Compile Include="StringBuilderPool.fs" />
4747
<Compile Include="Engine.fs" />
4848
</ItemGroup>
49-
49+
5050
</Project>

tests/Giraffe.ViewEngine.Benchmarks/Giraffe.ViewEngine.Benchmarks.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net5.0</TargetFramework>
3+
<TargetFramework>net6.0</TargetFramework>
4+
<OutputType>Exe</OutputType>
45
</PropertyGroup>
56

67
<ItemGroup>

tests/Giraffe.ViewEngine.Benchmarks/Program.fs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,51 @@ type HtmlUtf8Benchmark() =
6868
ArrayPool<char>.Shared.Return(chars)
6969
stringBuilder.Clear()
7070

71+
[<MemoryDiagnoser>]
72+
type HtmlBuildBenchmark() =
73+
74+
let doc() =
75+
div [] [
76+
div [ _class "top-bar" ]
77+
[ div [ _class "top-bar-left" ]
78+
[ ul [ _class "dropdown menu"
79+
_data "dropdown-menu" "" ]
80+
[ li [ _class "menu-text" ]
81+
[ rawText "Site Title" ]
82+
li [ ]
83+
[ a [ _href "#" ]
84+
[ str """One <script>alert("hello world")</script>""" ]
85+
ul [ _class "menu vertical" ]
86+
[ li [ ]
87+
[ a [ _href "#" ]
88+
[ rawText "One" ] ]
89+
li [ ]
90+
[ a [ _href "#" ]
91+
[ str "Two" ] ]
92+
li [ ]
93+
[ a [ _href "#" ]
94+
[ rawText "Three" ] ] ] ]
95+
li [ ]
96+
[ a [ _href "#" ]
97+
[ str "Two" ] ]
98+
li [ ]
99+
[ a [ _href "#" ]
100+
[ str "Three" ] ] ] ]
101+
div [ _class "top-bar-right" ]
102+
[ ul [ _class "menu" ]
103+
[ li [ ]
104+
[ input [ _type "search"
105+
_placeholder "Search" ] ]
106+
li [ ]
107+
[ button [ _type "button"
108+
_class "button" ]
109+
[ rawText "Search" ] ] ] ] ]
110+
]
111+
112+
[<Benchmark( Baseline = true )>]
113+
member this.Default() =
114+
doc()
115+
71116
[<EntryPoint>]
72117
let main args =
73118
let asm = typeof<HtmlUtf8Benchmark>.Assembly

tests/Giraffe.ViewEngine.Tests/Giraffe.ViewEngine.Tests.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net5.0</TargetFramework>
3+
<TargetFramework>net6.0</TargetFramework>
44
</PropertyGroup>
55

66
<ItemGroup>
@@ -19,7 +19,7 @@
1919
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.*" />
2020
<PackageReference Include="NSubstitute" Version="4.2.*" />
2121
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.*" PrivateAssets="All" />
22-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.*" />
22+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.*" />
2323
</ItemGroup>
2424

2525
<ItemGroup>

0 commit comments

Comments
 (0)