Skip to content

Instantly share code, notes, and snippets.

View bradwilson's full-sized avatar
🤘
All metal, all the time!

Brad Wilson bradwilson

🤘
All metal, all the time!
View GitHub Profile
public struct Maybe<T>
{
public static readonly Maybe<T> NoValue;
public Maybe(T value, bool hasValue = true) : this()
{
HasValue = hasValue;
Value = value;
}
@bradwilson
bradwilson / gist:9276064
Created February 28, 2014 17:53
Using Expression<T> with data theories for better output display in xUnit.net
public static IEnumerable<object[]> ExpirationMethods
{
get
{
return new TheoryDataSet<Expression<Action<Cache>>>
{
cache => cache.Clock.UtcNow.Returns(BaseTime + cache.Duration),
cache => cache.Expire()
};
}
@bradwilson
bradwilson / gist:9457177
Last active August 29, 2015 13:57
Release notes for xUnit.net v2 Build 2595

There have been significant changes in the latest alpha build of xUnit.net. Some of these changes will cause compilation errors for developers upgrading from previous alpha builds (as well as v1).

New Features for Test Authors

Support for tests in Windows 8, Windows Phone 8, and PCLs

This release has added support for writing unit tests in several new class library formats: Windows 8 class libraries, Windows Phone 8 class libraries, and Portable Class Libraries that target either of those (plus Desktop .NET 4.5). The runners that we supply can run those tests, although they are currently run in the desktop CLR. Three assemblies have been converted to PCLs as a result: xunit.abstractions.dll, xunit.assert.dll, and xunit.core.dll. The rest of the DLLs remain in their current configuration of supporting either Desktop .NET 3.5 or 4.5.

Adding support for MaxParallelThreads

@bradwilson
bradwilson / gist:11388191
Last active August 29, 2015 14:00
Release notes for xUnit.net v2 Beta 2
@bradwilson
bradwilson / issues.md
Created August 4, 2015 01:27
Dependency selection logic issues in NuGet v3

Look at these lines in this NUSPEC file:

https://github.com/xunit/xunit/blob/b1cbc40158cc53be5b9150bcdeb2e1cae40db5c9/src/xunit.extensibility.execution.nuspec#L24-L44

They were added because we observed some very unusal behavior. Specifically, note that the libraries are all platform specific (other than portable-win81+wpa81). Without the highlighted lines, this is the observable behavior when referencing this NuGet package:

  • It would link against the platform-specific library (e.g., lib\net45\xunit.execution.desktop.dll)
  • It would pull the dependency list from "dotnet", some of which are clearly not net45 compatible (e.g., System.Runtime 4.0.20)

We originally had a TF-less group, which we assumed would be used by anybody who wasn't "dotnet" or "dnx46":

@bradwilson
bradwilson / Console.xml
Created May 1, 2012 23:15
console.xml for Console2
<?xml version="1.0"?>
<settings>
<console change_refresh="10" refresh="100" rows="35" columns="160" buffer_rows="9999" buffer_columns="0" shell="" init_dir="" start_hidden="1" save_size="0">
<colors>
<color id="0" r="48" g="48" b="48"/>
<color id="1" r="0" g="0" b="128"/>
<color id="2" r="0" g="150" b="0"/>
<color id="3" r="0" g="150" b="150"/>
<color id="4" r="174" g="87" b="0"/>
<color id="5" r="128" g="0" b="128"/>
[alias]
co = checkout
st = status
br = branch
re = rebase
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
cat = cat-file -t
type = cat-file -t
dump = cat-file -p
[color "branch"]
@bradwilson
bradwilson / net40.cs
Created August 21, 2012 03:15
Alternate implementation of WriteToStreamAsync
public override Task WriteToStreamAsync(Type type, object value,
Stream stream,
HttpContent content,
TransportContext transportContext)
{
if (string.IsNullOrEmpty(JsonpCallbackFunction))
return base.WriteToStreamAsync(type, value, stream, content, transportContext);
StreamWriter writer = null;
param(
[string]$server = "origin",
[string]$branch = "master"
)
$gitStatus = (Get-GitStatus)
if ($gitStatus -eq $null) {
write-error "Not in a Git repository."
} elseif ($gitStatus.HasUntracked -or $gitStatus.HasWorking -or $gitStatus.HasIndex) {