Skip to content

Commit

Permalink
Merge pull request #1 from BigBang1112/dev
Browse files Browse the repository at this point in the history
Update to .NET 8
  • Loading branch information
BigBang1112 authored Aug 9, 2024
2 parents f49f4ed + 313d5cb commit eec853d
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 139 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*.cs]
csharp_style_prefer_range_operator = false
csharp_style_namespace_declarations = file_scoped
csharp_style_prefer_primary_constructors = false

dotnet_style_require_accessibility_modifiers = always
dotnet_diagnostic.IDE0040.severity = warning
dotnet_diagnostic.IDE0305.severity = none
35 changes: 26 additions & 9 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [ "main" ]
branches: [ main, dev ]
pull_request:
branches: [ "main" ]
branches: [ main ]

jobs:
build:
Expand All @@ -14,18 +14,35 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore
run: dotnet build -c Release --no-restore /p:ContinuousIntegrationBuild=true

- name: Test
run: dotnet test --no-build --verbosity normal
run: dotnet test -c Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage

- name: Code Coverage Report
uses: irongut/[email protected]
if: matrix.os == 'ubuntu-latest'
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: true
format: text
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
38 changes: 28 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,56 @@ permissions:
packages: write

jobs:
build:
name: Build
build-and-publish:
name: Build and Publish

runs-on: ubuntu-latest

env:
GH_TOKEN: ${{ github.token }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set release information
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 }}')"

- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7.0.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore
run: dotnet build -c Release --no-restore /p:ContinuousIntegrationBuild=true

- name: Test
run: dotnet test -c Release --no-build --verbosity normal
run: dotnet test -c Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage

- name: Code Coverage Report
uses: irongut/[email protected]
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: true
format: text
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'

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

- name: Publish the package to github.com
run: dotnet nuget push MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg -k ${{ env.GH_TOKEN }} -s https://nuget.pkg.github.com/bigbang1112/index.json

run: dotnet nuget push MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/bigbang1112/index.json
- name: Upload the package to this release
run: gh release upload ${{ github.ref_name }} MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg

- name: Set release information
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 }}).')"
12 changes: 2 additions & 10 deletions MinimalXmlReader.Benchmarks/MiniXmlReaderExample1Benchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using System.Text;
using System.Xml;

namespace MinimalXmlReader.Benchmarks;

[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.NativeAot70)]
[SimpleJob(RuntimeMoniker.Net80)]
[SimpleJob(RuntimeMoniker.NativeAot80)]
[MemoryDiagnoser]
public class MiniXmlReaderExample1Benchmarks
{
private readonly string xml;
private readonly MemoryStream ms;
private readonly XmlReader xmlReader;

public MiniXmlReaderExample1Benchmarks()
{
xml = File.ReadAllText("XmlRpcMethodCall.xml");

ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
xmlReader = System.Xml.XmlReader.Create(ms, new() { IgnoreWhitespace = true });
}

[Benchmark(Baseline = true)]
Expand Down
15 changes: 3 additions & 12 deletions MinimalXmlReader.Benchmarks/MiniXmlReaderExample2Benchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Xml;

namespace MinimalXmlReader.Benchmarks;

[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.NativeAot70)]
[SimpleJob(RuntimeMoniker.Net80)]
[SimpleJob(RuntimeMoniker.NativeAot80)]
[MemoryDiagnoser]
public class MiniXmlReaderExample2Benchmarks
{
private readonly string xml;
private readonly MemoryStream ms;
private readonly XmlReader xmlReader;

public MiniXmlReaderExample2Benchmarks()
{
xml = File.ReadAllText("Random.xml");

ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
xmlReader = System.Xml.XmlReader.Create(ms, new() { IgnoreWhitespace = true });
}

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

r.SkipProcessingInstruction();
r.SkipStartElement("root");
r.ReadStartElement("person", out var personAtts);
r.ReadStartElement("person", out var _);
r.SkipStartElement("random");
int.Parse(r.ReadContent());
r.SkipEndElement("random");
Expand Down
14 changes: 4 additions & 10 deletions MinimalXmlReader.Benchmarks/MiniXmlReaderExample3Benchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@

namespace MinimalXmlReader.Benchmarks;

[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.NativeAot70)]
[SimpleJob(RuntimeMoniker.Net80)]
[SimpleJob(RuntimeMoniker.NativeAot80)]
[MemoryDiagnoser]
public class MiniXmlReaderExample3Benchmarks
{
private readonly string xml;
private readonly MemoryStream ms;
private readonly XmlReader xmlReader;

public MiniXmlReaderExample3Benchmarks()
{
xml = File.ReadAllText("XmlRpcMethodResponseExtreme.xml");

ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
xmlReader = System.Xml.XmlReader.Create(ms, new() { IgnoreWhitespace = true });
}

[Benchmark(Baseline = true)]
Expand Down Expand Up @@ -51,7 +45,7 @@ public void MiniXmlReader()
{
r.SkipStartElement("string");

var str = r.ReadContent().ToString();
_ = r.ReadContent().ToString();

r.SkipEndElement("string");
r.SkipEndElement("value");
Expand Down Expand Up @@ -101,7 +95,7 @@ public void XmlReader()

r.ReadStartElement("string");

var str = r.ReadContentAsString();
_ = r.ReadContentAsString();

r.ReadEndElement();
r.ReadEndElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>11</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.6" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MinimalXmlReader.Tests/MiniXmlReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void IntegrationTest_XmlRpcMethodResponseExtreme()
{
r.SkipStartElement("string");

var str = r.ReadContent().ToString();
_ = r.ReadContent().ToString();

r.SkipEndElement("string");
r.SkipEndElement("value");
Expand Down
10 changes: 5 additions & 5 deletions MinimalXmlReader.Tests/MinimalXmlReader.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -11,13 +11,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
1 change: 1 addition & 0 deletions MinimalXmlReader.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{7F
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Položky řešení", "Položky řešení", "{BCCFF6F1-9AE2-4142-B49D-449ED93D590F}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
LICENSE.txt = LICENSE.txt
Expand Down
12 changes: 12 additions & 0 deletions MinimalXmlReader/EndType.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
namespace MinimalXmlReader;

/// <summary>
/// Represents the type of the end element.
/// </summary>
public enum EndType
{
/// <summary>
/// None
/// </summary>
None,
/// <summary>
/// Self-closed
/// </summary>
SelfClosed,
/// <summary>
/// Processing instruction
/// </summary>
ProcessingInstruction
}
Loading

0 comments on commit eec853d

Please sign in to comment.