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

Added support for .NET 8 #1137

Merged
merged 5 commits into from
Feb 3, 2024
Merged
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
42 changes: 23 additions & 19 deletions .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: Testsuite

on:
[push, pull_request]
workflow_dispatch: # Allows manual triggering of workflow
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
test:
Expand All @@ -11,36 +15,37 @@ jobs:
matrix:
os: [windows-latest]
# os: [windows-latest, ubuntu-latest]
framework: [netcoreapp3.1, net6.0, net462]
framework: [net8.0, net6.0, netcoreapp3.1, net462]
steps:
- name: Checkout source
uses: actions/checkout@v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could configure the dependabot to take care of these, similar to this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For actions we only need to specify the major version change, so I think the dependabot might not be needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, but helpful... otherwise you have to manually follow these version changes (this was just an observation, not related to this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, the idea is good and it is a useful service.
Just evaluating how useful it will be in this case since all minor and patch/revision are automatically picked up.
Maybe a monthly or quarterly time span might be useful - will look into it when we add release workflow.

uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for GitVersioning to work
- name: Setup NuGet
uses: NuGet/setup-nuget@v1
- name: Cache NuGet packages
uses: actions/cache@v1
uses: actions/cache@v4
id: cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget }}
- name: Setup .NET 3.1 SDK
uses: actions/setup-dotnet@v3
- name: Setup .NET 3.1/8.0 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 3.1.x
include-prerelease: false
dotnet-version: |
3.1.x
8.0.x
- name: Restore NuGet Packages
if: steps.cache.outputs.cache-hit != 'true'
run: |
nuget restore Source/Svg.sln
nuget install NUnit.ConsoleRunner -Version 3.10.0 -OutputDirectory tools
nuget restore Tests/Svg.UnitTests.sln
nuget install NUnit.ConsoleRunner -Version 3.17.0 -OutputDirectory tools
- name: Run tests
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
run: |
dotnet test --framework ${{ matrix.framework }} Tests/Svg.UnitTests/Svg.UnitTests.csproj
dotnet test -c Release -f ${{ matrix.framework }} Tests/Svg.UnitTests/Svg.UnitTests.csproj

benchmark:
runs-on: ${{ matrix.os }}
Expand All @@ -49,29 +54,28 @@ jobs:
benchmark: [SvgDocument, SvgPathBuilder, SvgTransformConverter, CoordinateParser]
os: [windows-latest]
# os: [windows-latest, ubuntu-latest]
framework: [netcoreapp3.1]
framework: [net8.0]
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup NuGet
uses: NuGet/setup-nuget@v1
- name: Cache NuGet packages
uses: actions/cache@v1
uses: actions/cache@v4
id: cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-bench }}
- name: Setup .NET 3.1 SDK
uses: actions/setup-dotnet@v3
- name: Setup .NET 8.x SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 3.1.x
include-prerelease: false
dotnet-version: 8.0.x
- name: Restore NuGet Packages
if: steps.cache.outputs.cache-hit != 'true'
run: |
nuget restore Source/Svg.sln
nuget restore Tests/Svg.Benchmark.sln
- name: Run benchmarks
env:
DOTNET_NOLOGO: true
Expand Down
8 changes: 8 additions & 0 deletions Generators/Svg.Generators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it difficult to avoid it with implementation??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please can you elaborate? Cannot understand what you meant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to avoid CS0618 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to avoid CS0618 ?

Maybe stop marking codes as obsolete. Better still, state the version by which such will be removed,
and then remove the obsolete codes and tests accordingly.

On the library side (SVG-NET), we do not need the warnings.
The end-user needs the warning and should care.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, is this <NoWarn> unnecessary ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning was showing up in the workflow tests, so I turned it off in the projects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how many warnings will show, but should we hide them ?

I think this is information that developers should know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having moved the tests to Release configuration, we can release the warning in the Debug mode.
Knowing is not sufficient, there must be a plan and documentation of obsolete codes.

</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoWarn>$(NoWarn);CS1591;CS0618</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Samples/Entities/Entities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<NoWarn>$(NoWarn);CS0618;NETSDK1138</NoWarn>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoWarn>$(NoWarn);CS1591;CS0618;NETSDK1138</NoWarn>
Expand Down
3 changes: 3 additions & 0 deletions Samples/SVGBuilder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
#if NET5_0_OR_GREATER
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
5 changes: 3 additions & 2 deletions Samples/SVGBuilder/SVGBuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net6.0-windows;net462</TargetFrameworks>
<TargetFrameworks>net8.0-windows;net6.0-windows;net462</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<NoWarn>$(NoWarn);CS0618;NETSDK1138</NoWarn>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoWarn>$(NoWarn);CS1591;CS0618;NETSDK1138</NoWarn>
Expand Down
3 changes: 3 additions & 0 deletions Samples/SVGViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
#if NET5_0_OR_GREATER
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
5 changes: 3 additions & 2 deletions Samples/SVGViewer/SVGViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net6.0-windows;net462</TargetFrameworks>
<TargetFrameworks>net8.0-windows;net6.0-windows;net462</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<NoWarn>$(NoWarn);CS0618;NETSDK1138</NoWarn>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoWarn>$(NoWarn);CS1591;CS0618;NETSDK1138</NoWarn>
Expand Down
6 changes: 2 additions & 4 deletions Samples/SvgConsole/SvgConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
<PackAsTool>True</PackAsTool>
<ToolCommandName>SvgConsole</ToolCommandName>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

<PropertyGroup>
<Configurations>Debug;Release</Configurations>
<PublishTrimmed>False</PublishTrimmed>
<PublishReadyToRun>False</PublishReadyToRun>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<NoWarn>$(NoWarn);CS0618;NETSDK1138</NoWarn>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoWarn>$(NoWarn);CS1591;CS0618;NETSDK1138</NoWarn>
Expand Down
3 changes: 2 additions & 1 deletion Samples/SvgRuntimeUpdates/SvgRuntimeUpdates.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<NoWarn>$(NoWarn);CS0618;NETSDK1138</NoWarn>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoWarn>$(NoWarn);CS1591;CS0618;NETSDK1138</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion Source/DataTypes/SvgNumberCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static SvgNumberCollection Parse(ReadOnlySpan<char> numbers)
foreach (var part in parts)
{
var partValue = part.Value;
var result = StringParser.ToFloatAny(ref partValue);
var result = StringParser.ToFloatAny(partValue);
collection.Add(result);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/DataTypes/SvgPointCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c
var coords = s.AsSpan().Trim();
var state = new CoordinateParserState(ref coords);
var result = new SvgPointCollection();
while (CoordinateParser.TryGetFloat(out var pointValue, ref coords, ref state))
while (CoordinateParser.TryGetFloat(out var pointValue, coords, ref state))
{
result.Add(new SvgUnit(SvgUnitType.User, pointValue));
}
Expand Down
4 changes: 2 additions & 2 deletions Source/DataTypes/SvgUnitConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel;
using System.Globalization;
using Svg.Helpers;
Expand Down Expand Up @@ -81,7 +81,7 @@ public static SvgUnit Parse(ReadOnlySpan<char> unit)
}

var valSpan = identifierIndex > -1 ? unit.Slice(0, identifierIndex) : unit;
var val = StringParser.ToFloat(ref valSpan);
var val = StringParser.ToFloat(valSpan);
if (identifierIndex == -1)
{
return new SvgUnit(val);
Expand Down
10 changes: 10 additions & 0 deletions Source/Exceptions/SvgException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
#if !NET8_0_OR_GREATER
using System.Runtime.Serialization;
#endif

namespace Svg
{
Expand All @@ -10,8 +12,10 @@ public SvgException() { }
public SvgException(string message) : base(message) { }
public SvgException(string message, Exception inner) : base(message, inner) { }

#if !NET8_0_OR_GREATER
protected SvgException(SerializationInfo info, StreamingContext context)
: base (info, context) { }
#endif
}

[Serializable]
Expand All @@ -21,8 +25,10 @@ public SvgIDException() { }
public SvgIDException(string message) : base(message) { }
public SvgIDException(string message, Exception inner) : base(message, inner) { }

#if !NET8_0_OR_GREATER
protected SvgIDException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
#endif
}

[Serializable]
Expand All @@ -32,8 +38,10 @@ public SvgIDExistsException() { }
public SvgIDExistsException(string message) : base(message) { }
public SvgIDExistsException(string message, Exception inner) : base(message, inner) { }

#if !NET8_0_OR_GREATER
protected SvgIDExistsException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
#endif
}

[Serializable]
Expand All @@ -43,7 +51,9 @@ public SvgIDWrongFormatException() { }
public SvgIDWrongFormatException(string message) : base(message) { }
public SvgIDWrongFormatException(string message, Exception inner) : base(message, inner) { }

#if !NET8_0_OR_GREATER
protected SvgIDWrongFormatException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
#endif
}
}
4 changes: 4 additions & 0 deletions Source/Exceptions/SvgGdiPlusCannotBeLoadedException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
#if !NET8_0_OR_GREATER
using System.Runtime.Serialization;
#endif

namespace Svg
{
Expand All @@ -13,7 +15,9 @@ public SvgGdiPlusCannotBeLoadedException(string message) : base(message) { }
public SvgGdiPlusCannotBeLoadedException(Exception inner) : base(gdiErrorMsg, inner) {}
public SvgGdiPlusCannotBeLoadedException(string message, Exception inner) : base(message, inner) { }

#if !NET8_0_OR_GREATER
protected SvgGdiPlusCannotBeLoadedException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
#endif
}
}
4 changes: 4 additions & 0 deletions Source/Exceptions/SvgMemoryException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
#if !NET8_0_OR_GREATER
using System.Runtime.Serialization;
#endif

namespace Svg.Exceptions
{
Expand All @@ -10,7 +12,9 @@ public SvgMemoryException() { }
public SvgMemoryException(string message) : base(message) { }
public SvgMemoryException(string message, Exception inner) : base(message, inner) { }

#if !NET8_0_OR_GREATER
protected SvgMemoryException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
#endif
}
}
8 changes: 4 additions & 4 deletions Source/Helpers/StringParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal static class StringParser
{
private static readonly CultureInfo Format = CultureInfo.InvariantCulture;

public static float ToFloat(ref ReadOnlySpan<char> value)
public static float ToFloat(ReadOnlySpan<char> value)
{
#if NETSTANDARD2_1 || NETCOREAPP2_1_OR_GREATER
return float.Parse(value, NumberStyles.Float, Format);
Expand All @@ -16,7 +16,7 @@ public static float ToFloat(ref ReadOnlySpan<char> value)
#endif
}

public static float ToFloatAny(ref ReadOnlySpan<char> value)
public static float ToFloatAny(ReadOnlySpan<char> value)
{
#if NETSTANDARD2_1 || NETCOREAPP2_1_OR_GREATER
return float.Parse(value, NumberStyles.Any, Format);
Expand All @@ -25,7 +25,7 @@ public static float ToFloatAny(ref ReadOnlySpan<char> value)
#endif
}

public static double ToDouble(ref ReadOnlySpan<char> value)
public static double ToDouble(ReadOnlySpan<char> value)
{
#if NETSTANDARD2_1 || NETCOREAPP2_1_OR_GREATER
return double.Parse(value, NumberStyles.Any, Format);
Expand All @@ -34,7 +34,7 @@ public static double ToDouble(ref ReadOnlySpan<char> value)
#endif
}

public static int ToInt(ref ReadOnlySpan<char> value)
public static int ToInt(ReadOnlySpan<char> value)
{
#if NETSTANDARD2_1 || NETCOREAPP2_1_OR_GREATER
return int.Parse(value, NumberStyles.Integer, Format);
Expand Down
8 changes: 4 additions & 4 deletions Source/Paths/CoordinateParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static bool MarkState(bool hasMode, ref CoordinateParserState state)
return hasMode;
}

public static bool TryGetBool(out bool result, ref ReadOnlySpan<char> chars, ref CoordinateParserState state)
public static bool TryGetBool(out bool result, ReadOnlySpan<char> chars, ref CoordinateParserState state)
{
var charsLength = chars.Length;

Expand Down Expand Up @@ -88,7 +88,7 @@ public static bool TryGetBool(out bool result, ref ReadOnlySpan<char> chars, ref
return MarkState(false, ref state);
}

public static bool TryGetFloat(out float result, ref ReadOnlySpan<char> chars, ref CoordinateParserState state)
public static bool TryGetFloat(out float result, ReadOnlySpan<char> chars, ref CoordinateParserState state)
{
var charsLength = chars.Length;

Expand Down Expand Up @@ -289,7 +289,7 @@ public static bool TryGetFloat(out float result, ref ReadOnlySpan<char> chars, r
if (state.CurrNumState != NumState.Separator && state.NewNumState < state.CurrNumState)
{
var value = chars.Slice(state.Position, state.CharsPosition - state.Position);
result = StringParser.ToFloat(ref value);
result = StringParser.ToFloat(value);
state.Position = state.CharsPosition;
state.CurrNumState = state.NewNumState;
return MarkState(true, ref state);
Expand All @@ -316,7 +316,7 @@ public static bool TryGetFloat(out float result, ref ReadOnlySpan<char> chars, r
else
{
var value = chars.Slice(state.Position, charsLength - state.Position);
result = StringParser.ToFloat(ref value);
result = StringParser.ToFloat(value);
state.Position = charsLength;
return MarkState(true, ref state);
}
Expand Down
Loading
Loading