├── Strilanc.Value.May.1.0.0.nupkg
├── Strilanc.Value.May.1.0.1.nupkg
├── Strilanc.Value.May.1.0.2.nupkg
├── .gitignore
├── MayExample
├── App.config
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── App.xaml
├── App.xaml.cs
├── MainWindow.xaml
├── ExampleMayUtilityMethods.cs
├── MainWindow.xaml.cs
└── MayExample.csproj
├── ReadMe.txt
├── License.txt
├── May
├── IMayHaveValue.cs
├── Properties
│ └── AssemblyInfo.cs
├── MayNoValue.cs
├── May.csproj
├── May.cs
├── MayUtilities.cs
└── MayExtensions.cs
├── MayTest
├── TestUtil.cs
├── Properties
│ └── AssemblyInfo.cs
├── MayUtilitiesTest.cs
├── MayTest.csproj
└── MayTest.cs
└── May.sln
/Strilanc.Value.May.1.0.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Strilanc/May/HEAD/Strilanc.Value.May.1.0.0.nupkg
--------------------------------------------------------------------------------
/Strilanc.Value.May.1.0.1.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Strilanc/May/HEAD/Strilanc.Value.May.1.0.1.nupkg
--------------------------------------------------------------------------------
/Strilanc.Value.May.1.0.2.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Strilanc/May/HEAD/Strilanc.Value.May.1.0.2.nupkg
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | TestResults/*
2 | */bin/*
3 | */obj/*
4 | *.pfx
5 | *.snk
6 | *.testsettings
7 | *.suo
8 | *.crunchsolution.cache
9 | *.ncrunchsolution
10 | *.suo
11 | *.user
12 | _ReSharper.*
13 |
--------------------------------------------------------------------------------
/MayExample/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/MayExample/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/MayExample/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/MayExample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace MayExample {
10 | ///
11 | /// Interaction logic for App.xaml
12 | ///
13 | public partial class App : Application {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ReadMe.txt:
--------------------------------------------------------------------------------
1 | Implements an option type (Strilanc.Value.May) that encourages usage based on pattern matching rather than ForceGetValue. Also includes utility methods for producing, consuming and transforming May.
2 |
3 | Note on null: May treats null like any other value. May.NoValue is distinct from null, and both are distinct from ((object)null).Maybe().
4 |
5 | Blog post with usage examples: http://twistedoakstudios.com/blog/Post1130_when-null-is-not-enough-an-option-type-for-c
6 |
7 | NuGet package: https://nuget.org/packages/Strilanc.Value.May
--------------------------------------------------------------------------------
/MayExample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | Public Domain
2 |
3 | I place no restrictions on the use of code in this repostory, including:
4 | - The 'May' option type and related utility methods in the 'May' project
5 | - The examples and related code in the example project
6 | - The tests and related code in the testing project
7 |
8 | That means:
9 | - Attribution not required.
10 | - Commercial use allowed.
11 | - Derivative use allowed.
12 |
13 | But note:
14 | - No guarantees (I did my best to ensure correctness, but I am not infallible.).
15 |
16 | Not that I wouldn't mind hearing about it if you used my code.
17 | If you need a 'real' license for obtuse legal reasons, I would be happy to grant it.
18 |
19 | Craig Gidney, 2012
20 |
--------------------------------------------------------------------------------
/May/IMayHaveValue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Diagnostics.Contracts;
4 |
5 | namespace Strilanc.Value {
6 | ///
7 | ///A potential value that may or may not contain an unknown value of unknown type.
8 | ///All implementations should compare equal and have a hash code of 0 when HasValue is false.
9 | ///
10 | ///
11 | ///Used to allow comparisons of the raw May.NoValue to generic ones like May<int>.NoValue.
12 | ///Also used as the result type of the 'do action if value present' method, but only because there is no standard void or unit type.
13 | ///
14 | [EditorBrowsable(EditorBrowsableState.Never)]
15 | public interface IMayHaveValue : IEquatable {
16 | ///Determines if this potential value contains a value or not.
17 | [Pure]
18 | bool HasValue { get; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/MayExample/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18010
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MayExample.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/May/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("May")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("May")]
14 | [assembly: AssemblyCopyright("Copyright © 2012")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: NeutralResourcesLanguage("en")]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | //
26 | // You can specify all the values or you can default the Build and Revision Numbers
27 | // by using the '*' as shown below:
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("1.0.0.0")]
30 | [assembly: AssemblyFileVersion("1.0.0.0")]
31 |
--------------------------------------------------------------------------------
/MayTest/TestUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | internal static class TestUtil {
7 | public static IEnumerable Range(this int count) {
8 | return Enumerable.Range(0, count);
9 | }
10 | public static void AssertThrows(Func