Skip to content

Commit eec853d

Browse files
authored
Merge pull request #1 from BigBang1112/dev
Update to .NET 8
2 parents f49f4ed + 313d5cb commit eec853d

14 files changed

+226
-139
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[*.cs]
2+
csharp_style_prefer_range_operator = false
3+
csharp_style_namespace_declarations = file_scoped
4+
csharp_style_prefer_primary_constructors = false
5+
6+
dotnet_style_require_accessibility_modifiers = always
7+
dotnet_diagnostic.IDE0040.severity = warning
8+
dotnet_diagnostic.IDE0305.severity = none

.github/workflows/dotnet.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ main, dev ]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: [ main ]
88

99
jobs:
1010
build:
@@ -14,18 +14,35 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, windows-latest]
17-
17+
1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
20+
2021
- name: Setup .NET
21-
uses: actions/setup-dotnet@v3
22+
uses: actions/setup-dotnet@v4
2223
with:
2324
dotnet-version: |
24-
6.0.x
25-
7.0.x
25+
8.0.x
26+
2627
- name: Restore dependencies
2728
run: dotnet restore
29+
2830
- name: Build
29-
run: dotnet build --no-restore
31+
run: dotnet build -c Release --no-restore /p:ContinuousIntegrationBuild=true
32+
3033
- name: Test
31-
run: dotnet test --no-build --verbosity normal
34+
run: dotnet test -c Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
35+
36+
- name: Code Coverage Report
37+
uses: irongut/[email protected]
38+
if: matrix.os == 'ubuntu-latest'
39+
with:
40+
filename: coverage/**/coverage.cobertura.xml
41+
badge: true
42+
fail_below_min: true
43+
format: text
44+
hide_branch_rate: false
45+
hide_complexity: true
46+
indicators: true
47+
output: both
48+
thresholds: '60 80'

.github/workflows/publish.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,56 @@ permissions:
99
packages: write
1010

1111
jobs:
12-
build:
13-
name: Build
12+
build-and-publish:
13+
name: Build and Publish
1414

1515
runs-on: ubuntu-latest
1616

1717
env:
1818
GH_TOKEN: ${{ github.token }}
1919

2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
22+
23+
- name: Set release information
24+
run: gh release edit ${{ github.ref_name }} -n "$(echo -e '***[Pre-release is being automatically created, please wait...](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})***\n\n${{ github.event.release.body }}')"
2225

2326
- name: Setup .NET
24-
uses: actions/setup-dotnet@v1
27+
uses: actions/setup-dotnet@v4
2528
with:
2629
dotnet-version: |
27-
7.0.x
28-
6.0.x
30+
8.0.x
2931
3032
- name: Restore dependencies
3133
run: dotnet restore
3234

3335
- name: Build
34-
run: dotnet build -c Release --no-restore
36+
run: dotnet build -c Release --no-restore /p:ContinuousIntegrationBuild=true
3537

3638
- name: Test
37-
run: dotnet test -c Release --no-build --verbosity normal
39+
run: dotnet test -c Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
40+
41+
- name: Code Coverage Report
42+
uses: irongut/[email protected]
43+
with:
44+
filename: coverage/**/coverage.cobertura.xml
45+
badge: true
46+
fail_below_min: true
47+
format: text
48+
hide_branch_rate: false
49+
hide_complexity: true
50+
indicators: true
51+
output: both
52+
thresholds: '60 80'
3853

3954
- name: Publish the package to nuget.org
4055
run: dotnet nuget push MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
4156

4257
- name: Publish the package to github.com
43-
run: dotnet nuget push MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg -k ${{ env.GH_TOKEN }} -s https://nuget.pkg.github.com/bigbang1112/index.json
44-
58+
run: dotnet nuget push MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/bigbang1112/index.json
59+
4560
- name: Upload the package to this release
4661
run: gh release upload ${{ github.ref_name }} MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg
62+
63+
- name: Set release information
64+
run: gh release edit ${{ github.ref_name }} -n "$(echo -e '${{ github.event.release.body }}\n\nAssets were automatically generated using the [publish workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).')"

MinimalXmlReader.Benchmarks/MiniXmlReaderExample1Benchmarks.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
using BenchmarkDotNet.Attributes;
22
using BenchmarkDotNet.Jobs;
3-
using System.Text;
4-
using System.Xml;
53

64
namespace MinimalXmlReader.Benchmarks;
75

8-
[SimpleJob(RuntimeMoniker.Net60)]
9-
[SimpleJob(RuntimeMoniker.Net70)]
10-
[SimpleJob(RuntimeMoniker.NativeAot70)]
6+
[SimpleJob(RuntimeMoniker.Net80)]
7+
[SimpleJob(RuntimeMoniker.NativeAot80)]
118
[MemoryDiagnoser]
129
public class MiniXmlReaderExample1Benchmarks
1310
{
1411
private readonly string xml;
15-
private readonly MemoryStream ms;
16-
private readonly XmlReader xmlReader;
1712

1813
public MiniXmlReaderExample1Benchmarks()
1914
{
2015
xml = File.ReadAllText("XmlRpcMethodCall.xml");
21-
22-
ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
23-
xmlReader = System.Xml.XmlReader.Create(ms, new() { IgnoreWhitespace = true });
2416
}
2517

2618
[Benchmark(Baseline = true)]

MinimalXmlReader.Benchmarks/MiniXmlReaderExample2Benchmarks.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
using BenchmarkDotNet.Attributes;
22
using BenchmarkDotNet.Jobs;
33
using System.Globalization;
4-
using System.Reflection;
5-
using System.Text;
6-
using System.Xml;
74

85
namespace MinimalXmlReader.Benchmarks;
96

10-
[SimpleJob(RuntimeMoniker.Net60)]
11-
[SimpleJob(RuntimeMoniker.Net70)]
12-
[SimpleJob(RuntimeMoniker.NativeAot70)]
7+
[SimpleJob(RuntimeMoniker.Net80)]
8+
[SimpleJob(RuntimeMoniker.NativeAot80)]
139
[MemoryDiagnoser]
1410
public class MiniXmlReaderExample2Benchmarks
1511
{
1612
private readonly string xml;
17-
private readonly MemoryStream ms;
18-
private readonly XmlReader xmlReader;
1913

2014
public MiniXmlReaderExample2Benchmarks()
2115
{
2216
xml = File.ReadAllText("Random.xml");
23-
24-
ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
25-
xmlReader = System.Xml.XmlReader.Create(ms, new() { IgnoreWhitespace = true });
2617
}
2718

2819
[Benchmark(Baseline = true)]
@@ -32,7 +23,7 @@ public void MiniXmlReader()
3223

3324
r.SkipProcessingInstruction();
3425
r.SkipStartElement("root");
35-
r.ReadStartElement("person", out var personAtts);
26+
r.ReadStartElement("person", out var _);
3627
r.SkipStartElement("random");
3728
int.Parse(r.ReadContent());
3829
r.SkipEndElement("random");

MinimalXmlReader.Benchmarks/MiniXmlReaderExample3Benchmarks.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@
55

66
namespace MinimalXmlReader.Benchmarks;
77

8-
[SimpleJob(RuntimeMoniker.Net60)]
9-
[SimpleJob(RuntimeMoniker.Net70)]
10-
[SimpleJob(RuntimeMoniker.NativeAot70)]
8+
[SimpleJob(RuntimeMoniker.Net80)]
9+
[SimpleJob(RuntimeMoniker.NativeAot80)]
1110
[MemoryDiagnoser]
1211
public class MiniXmlReaderExample3Benchmarks
1312
{
1413
private readonly string xml;
15-
private readonly MemoryStream ms;
16-
private readonly XmlReader xmlReader;
1714

1815
public MiniXmlReaderExample3Benchmarks()
1916
{
2017
xml = File.ReadAllText("XmlRpcMethodResponseExtreme.xml");
21-
22-
ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
23-
xmlReader = System.Xml.XmlReader.Create(ms, new() { IgnoreWhitespace = true });
2418
}
2519

2620
[Benchmark(Baseline = true)]
@@ -51,7 +45,7 @@ public void MiniXmlReader()
5145
{
5246
r.SkipStartElement("string");
5347

54-
var str = r.ReadContent().ToString();
48+
_ = r.ReadContent().ToString();
5549

5650
r.SkipEndElement("string");
5751
r.SkipEndElement("value");
@@ -101,7 +95,7 @@ public void XmlReader()
10195

10296
r.ReadStartElement("string");
10397

104-
var str = r.ReadContentAsString();
98+
_ = r.ReadContentAsString();
10599

106100
r.ReadEndElement();
107101
r.ReadEndElement();

MinimalXmlReader.Benchmarks/MinimalXmlReader.Benchmarks.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
5+
<TargetFrameworks>net8.0</TargetFrameworks>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<LangVersion>11</LangVersion>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="BenchmarkDotNet" Version="0.13.6" />
12+
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

MinimalXmlReader.Tests/MiniXmlReaderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void IntegrationTest_XmlRpcMethodResponseExtreme()
146146
{
147147
r.SkipStartElement("string");
148148

149-
var str = r.ReadContent().ToString();
149+
_ = r.ReadContent().ToString();
150150

151151
r.SkipEndElement("string");
152152
r.SkipEndElement("value");

MinimalXmlReader.Tests/MinimalXmlReader.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

@@ -11,13 +11,13 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
15-
<PackageReference Include="xunit" Version="2.4.2" />
16-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
15+
<PackageReference Include="xunit" Version="2.9.0" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
<PrivateAssets>all</PrivateAssets>
1919
</PackageReference>
20-
<PackageReference Include="coverlet.collector" Version="3.2.0">
20+
<PackageReference Include="coverlet.collector" Version="6.0.2">
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
<PrivateAssets>all</PrivateAssets>
2323
</PackageReference>

MinimalXmlReader.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{7F
1818
EndProject
1919
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Položky řešení", "Položky řešení", "{BCCFF6F1-9AE2-4142-B49D-449ED93D590F}"
2020
ProjectSection(SolutionItems) = preProject
21+
.editorconfig = .editorconfig
2122
.gitattributes = .gitattributes
2223
.gitignore = .gitignore
2324
LICENSE.txt = LICENSE.txt

0 commit comments

Comments
 (0)