From d18e13fca01b9b8b0bf01446e758d54e83d6742f Mon Sep 17 00:00:00 2001 From: "ben.hughes" Date: Thu, 26 Jan 2017 11:57:55 +0000 Subject: [PATCH 1/4] added binary serialisation --- src/Option/Option.cs | 1 + tests/Option.Tests/OptionTests.cs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Option/Option.cs b/src/Option/Option.cs index d31f5c3..d11bb8c 100755 --- a/src/Option/Option.cs +++ b/src/Option/Option.cs @@ -13,6 +13,7 @@ namespace Functional.Option /// /// The type to create an option for. [DebuggerDisplay("HasValue = {_hasValue}, Value = {_value}")] + [Serializable] public struct Option : IEquatable>, IEnumerable { /// diff --git a/tests/Option.Tests/OptionTests.cs b/tests/Option.Tests/OptionTests.cs index bc74e33..99af8e2 100755 --- a/tests/Option.Tests/OptionTests.cs +++ b/tests/Option.Tests/OptionTests.cs @@ -2,8 +2,12 @@ using NUnit.Framework; using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; using System.Text; +using System.Xml; +using System.Xml.Serialization; namespace Tests { @@ -350,6 +354,25 @@ public void TestIEnumerable() Assert.AreEqual(TimeSpan.FromHours(1), aggr); } + [Test] + public void TestBinarySerialization() + { + const int value = 123; + + var o1 = Option.Some(value); + + var memoryStream = new MemoryStream(); + var formatter = new BinaryFormatter(); + formatter.Serialize(memoryStream, o1); + + memoryStream.Flush(); + memoryStream.Position = 0; + + var o2 = (Option)formatter.Deserialize(memoryStream); + + Assert.AreEqual(value, o2.Value); + } + private static void TestIEnumerableHelper(Option o) { var select = o.Select(x => x); From 4e2dc51ec944109f18c5f6fca4e642bb695b8204 Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Tue, 9 Jan 2018 09:08:41 +0000 Subject: [PATCH 2/4] Updated Option to target netstandard 2.0 and net45 --- .gitignore | 1 + src/Option/Option.csproj | 63 ++------------------------ src/Option/Option.sln | 19 ++++---- src/Option/Properties/AssemblyInfo.cs | 36 --------------- tests/Option.Tests/Option.Tests.csproj | 8 ++-- 5 files changed, 21 insertions(+), 106 deletions(-) delete mode 100755 src/Option/Properties/AssemblyInfo.cs diff --git a/.gitignore b/.gitignore index b5dca60..d3f1567 100644 --- a/.gitignore +++ b/.gitignore @@ -105,3 +105,4 @@ Generated_Code #added for RIA/Silverlight projects _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML +.vs diff --git a/src/Option/Option.csproj b/src/Option/Option.csproj index ea3fdc2..61bbf29 100755 --- a/src/Option/Option.csproj +++ b/src/Option/Option.csproj @@ -1,60 +1,7 @@ - - - + + - Debug - AnyCPU - {CF04262A-A434-4F8F-B164-4F1D47D2542C} - Library - Properties - Option - Option - v3.5 - 512 - + netstandard2.0;net45; - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - bin\Debug\Option.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Option.XML - false - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/src/Option/Option.sln b/src/Option/Option.sln index 1b22d39..ea58c84 100755 --- a/src/Option/Option.sln +++ b/src/Option/Option.sln @@ -1,28 +1,31 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30110.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.27004.2002 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Option", "Option.csproj", "{CF04262A-A434-4F8F-B164-4F1D47D2542C}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Option.Tests", "..\..\tests\Option.Tests\Option.Tests.csproj", "{701FF69B-E4B9-431D-96D2-599B28CE6599}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Option", "Option.csproj", "{C4D8570F-74F2-49D6-AD9B-26519C1585CA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CF04262A-A434-4F8F-B164-4F1D47D2542C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CF04262A-A434-4F8F-B164-4F1D47D2542C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CF04262A-A434-4F8F-B164-4F1D47D2542C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CF04262A-A434-4F8F-B164-4F1D47D2542C}.Release|Any CPU.Build.0 = Release|Any CPU {701FF69B-E4B9-431D-96D2-599B28CE6599}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {701FF69B-E4B9-431D-96D2-599B28CE6599}.Debug|Any CPU.Build.0 = Debug|Any CPU {701FF69B-E4B9-431D-96D2-599B28CE6599}.Release|Any CPU.ActiveCfg = Release|Any CPU {701FF69B-E4B9-431D-96D2-599B28CE6599}.Release|Any CPU.Build.0 = Release|Any CPU + {C4D8570F-74F2-49D6-AD9B-26519C1585CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C4D8570F-74F2-49D6-AD9B-26519C1585CA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C4D8570F-74F2-49D6-AD9B-26519C1585CA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C4D8570F-74F2-49D6-AD9B-26519C1585CA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {78DFE719-4A64-46FF-B615-95F0CF185FEC} + EndGlobalSection EndGlobal diff --git a/src/Option/Properties/AssemblyInfo.cs b/src/Option/Properties/AssemblyInfo.cs deleted file mode 100755 index 53aea1c..0000000 --- a/src/Option/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Option")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Option")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("65309ded-7fa0-4411-9db3-3aaf7fd961b3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tests/Option.Tests/Option.Tests.csproj b/tests/Option.Tests/Option.Tests.csproj index 3b38110..2a04a01 100755 --- a/tests/Option.Tests/Option.Tests.csproj +++ b/tests/Option.Tests/Option.Tests.csproj @@ -53,15 +53,15 @@ + + + - {cf04262a-a434-4f8f-b164-4f1d47d2542c} + {c4d8570f-74f2-49d6-ad9b-26519c1585ca} Option - - -