Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ Generated_Code #added for RIA/Silverlight projects
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
.vs
1 change: 1 addition & 0 deletions src/Option/Option.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Functional.Option
/// </summary>
/// <typeparam name="T">The type to create an option for.</typeparam>
[DebuggerDisplay("HasValue = {_hasValue}, Value = {_value}")]
[Serializable]
public struct Option<T> : IEquatable<Option<T>>, IEnumerable<T>
{
/// <summary>
Expand Down
68 changes: 8 additions & 60 deletions src/Option/Option.csproj
Original file line number Diff line number Diff line change
@@ -1,60 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CF04262A-A434-4F8F-B164-4F1D47D2542C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Option</RootNamespace>
<AssemblyName>Option</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>bin\Debug\Option.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Option.XML</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EmptyArray.cs" />
<Compile Include="ExtensionMethods.cs" />
<Compile Include="Option.cs" />
<Compile Include="OptionPatternMatcher.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net461;</TargetFrameworks>
<IsPackable>true</IsPackable>
</PropertyGroup>

</Project>
19 changes: 11 additions & 8 deletions src/Option/Option.sln
Original file line number Diff line number Diff line change
@@ -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
36 changes: 0 additions & 36 deletions src/Option/Properties/AssemblyInfo.cs

This file was deleted.

8 changes: 4 additions & 4 deletions tests/Option.Tests/Option.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Option\Option.csproj">
<Project>{cf04262a-a434-4f8f-b164-4f1d47d2542c}</Project>
<Project>{c4d8570f-74f2-49d6-ad9b-26519c1585ca}</Project>
<Name>Option</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
23 changes: 23 additions & 0 deletions tests/Option.Tests/OptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -350,6 +354,25 @@ public void TestIEnumerable()
Assert.AreEqual(TimeSpan.FromHours(1), aggr);
}

[Test]
public void TestBinarySerialization()
{
const int value = 123;

var o1 = Option<int>.Some(value);

var memoryStream = new MemoryStream();
var formatter = new BinaryFormatter();
formatter.Serialize(memoryStream, o1);

memoryStream.Flush();
memoryStream.Position = 0;

var o2 = (Option<int>)formatter.Deserialize(memoryStream);

Assert.AreEqual(value, o2.Value);
}

private static void TestIEnumerableHelper(Option<int> o)
{
var select = o.Select(x => x);
Expand Down