Skip to content

Instantly share code, notes, and snippets.

View kiwidev's full-sized avatar

Mark Young kiwidev

  • Microsoft
  • New Zealand
View GitHub Profile
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
using System;
namespace Immutable
{
enum Qux { Qux1, Qux2 }
class Baz
{
public Baz(Qux qux)
{
using System;
namespace Immutable
{
enum Qux { Qux1, Qux2 }
static class Option
{
public static Option<T> Value<T>(T value)
{
@kiwidev
kiwidev / gist:6326238
Last active December 21, 2015 15:19
Defining a preprocessor constant depending on version of Visual Studio... Put this after the standard DefineConstants definition inside project file (unload project, edit, reload project).
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'">
<DefineConstants>$(DefineConstants);VS_10;</DefineConstants>
</PropertyGroup>
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;
public class Fixture
{
[Fact]
public void Should_FactMethodName()
@kiwidev
kiwidev / ExceptionWrappingSynchronizationContext.cs
Created October 26, 2012 10:53
SynchronizationContext that allows for catching and dealing with unhandled exceptions. Very useful in WinRT.
using System;
using System.Threading;
namespace TestExceptions
{
/// <summary>
/// Wrapper around a standard synchronization context, that catches any unhandled exceptions.
/// Acts as a facade passing calls to the original SynchronizationContext
/// </summary>
/// <example>
@kiwidev
kiwidev / gist:2630345
Created May 7, 2012 20:52
One line game of life
[TestMethod]
public void OneLiner()
{
Func<bool[], int, bool[]> gameOfLife =
(cells, width) =>
cells.Select((cell, index) =>
// Neighbours
new
{