Skip to content

Commit 19a63f0

Browse files
committed
Add .NET 4.6.1 target that will be the minimal version for binary serialization.
1 parent 10b4cea commit 19a63f0

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/QuikGraph.Serialization/QuikGraph.Serialization.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFrameworks>net35;net40;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
4+
<TargetFrameworks>net35;net40;net461;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
55

66
<GeneratePackageOnBuild>$(Generate_QuikGraph_Serialization)</GeneratePackageOnBuild>
77

@@ -42,12 +42,16 @@ Updates:
4242
<!-- Targets defines -->
4343
<PropertyGroup Condition="'$(TargetFramework)'=='net35'">
4444
<AssemblyTitle>QuikGraph.Serialization .NET 3.5</AssemblyTitle>
45-
<DefineConstants>$(DefineConstants);NET35;SUPPORTS_SERIALIZATION;SUPPORTS_GRAPHS_SERIALIZATION;$(AdditionalConstants)</DefineConstants>
45+
<DefineConstants>$(DefineConstants);NET35;SUPPORTS_SERIALIZATION;SUPPORTS_GRAPHS_SERIALIZATION;DEPRECATE_BINARY_SERIALIZATION;$(AdditionalConstants)</DefineConstants>
4646
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4747
</PropertyGroup>
4848
<PropertyGroup Condition="'$(TargetFramework)'=='net40'">
4949
<AssemblyTitle>QuikGraph.Serialization .NET 4.0</AssemblyTitle>
50-
<DefineConstants>$(DefineConstants);NET40;SUPPORTS_SERIALIZATION;SUPPORTS_GRAPHS_SERIALIZATION;SUPPORTS_XML_DTD_PROCESSING;$(AdditionalConstants)</DefineConstants>
50+
<DefineConstants>$(DefineConstants);NET40;SUPPORTS_SERIALIZATION;SUPPORTS_GRAPHS_SERIALIZATION;DEPRECATE_BINARY_SERIALIZATION;SUPPORTS_XML_DTD_PROCESSING;$(AdditionalConstants)</DefineConstants>
51+
</PropertyGroup>
52+
<PropertyGroup Condition="'$(TargetFramework)'=='net461'">
53+
<AssemblyTitle>QuikGraph.Serialization .NET 4.6.1</AssemblyTitle>
54+
<DefineConstants>$(DefineConstants);NET461;SUPPORTS_SERIALIZATION;SUPPORTS_GRAPHS_SERIALIZATION;SUPPORTS_XML_DTD_PROCESSING;$(AdditionalConstants)</DefineConstants>
5155
</PropertyGroup>
5256
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard1.3'">
5357
<AssemblyTitle>QuikGraph.Serialization .NET Standard 1.3</AssemblyTitle>

src/QuikGraph.Serialization/SerializationExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public static class SerializationExtensions
2626
/// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
2727
/// <exception cref="T:System.ArgumentNullException"><paramref name="stream"/> is <see langword="null"/>.</exception>
2828
/// <exception cref="T:System.ArgumentException"><paramref name="stream"/> is not writable.</exception>
29+
#if DEPRECATE_BINARY_SERIALIZATION
30+
[Obsolete(
31+
"Binary serialization on old .NET targets is deprecated.\n" +
32+
"Consider using another kind of serialization or updating to at least .NET Framework 4.6.1+, .NET Standard 2.0+ or .NET 5.0+.")]
33+
#endif
2934
public static void SerializeToBinary<TVertex, TEdge>(
3035
[NotNull] this IGraph<TVertex, TEdge> graph,
3136
[NotNull] Stream stream)
@@ -61,6 +66,11 @@ public static void SerializeToBinary<TVertex, TEdge>(
6166
/// <exception cref="T:System.ArgumentNullException"><paramref name="stream"/> is <see langword="null"/>.</exception>
6267
/// <exception cref="T:System.ArgumentException"><paramref name="stream"/> is not readable.</exception>
6368
[Pure]
69+
#if DEPRECATE_BINARY_SERIALIZATION
70+
[Obsolete(
71+
"Binary deserialization on old .NET targets is deprecated.\n" +
72+
"Consider using another kind of serialization or updating to at least .NET Framework 4.6.1+, .NET Standard 2.0+ or .NET 5.0+.")]
73+
#endif
6474
public static TGraph DeserializeFromBinary<TVertex, TEdge, TGraph>(
6575
[NotNull] this Stream stream,
6676
[CanBeNull] SerializationBinder binder = null)

tests/QuikGraph.Serialization.Tests/BinarySerializationTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using NUnit.Framework;
55
using static QuikGraph.Serialization.Tests.SerializationTestCaseSources;
66

7+
#pragma warning disable 618 // Obsolete API usage
8+
79
namespace QuikGraph.Serialization.Tests
810
{
911
/// <summary>

0 commit comments

Comments
 (0)