Skip to content

Instantly share code, notes, and snippets.

@hmemcpy
hmemcpy / FakeItEasy.ExternalAnnotations.xml
Last active December 14, 2015 01:09
An external annotations file for FakeItEasy, so ReSharper won't complain about implicit captures on CallTo() lambdas. Place this file alongside FakeItEasy.dll and reload your solution.
<?xml version="1.0" encoding="utf-8"?>
<assembly name="FakeItEasy">
<member name="M:FakeItEasy.A.CallTo(System.Linq.Expressions.Expression{System.Action})">
<parameter name="callSpecification">
<attribute ctor="M:JetBrains.Annotations.InstantHandleAttribute.#ctor" />
</parameter>
</member>
<member name="M:FakeItEasy.A.CallTo``1(System.Linq.Expressions.Expression{System.Func{``0}})">
<parameter name="callSpecification">
<attribute ctor="M:JetBrains.Annotations.InstantHandleAttribute.#ctor" />
@hmemcpy
hmemcpy / gist:5023336
Last active December 14, 2015 03:48
Who knew static initializers depend on the order?
public static readonly string[] MyPaths = GetAllPaths("path1", "path2");
static readonly string[] AllExtensions = new[] { ".htm", ".html", ".sshtml" };
private static string[] GetAllPaths(params string[] viewLocations)
{
// this will throw a NRE since AllExtensions is null!
return viewLocations.SelectMany(view => AllExtensions.Select(extension => view + extension)).ToArray();
}
class MyBusinessObject
{
public int? MyNullable;
public bool HasSomeBusinessProperty
{
get { return myNullable.HasValue; }
}
}
@hmemcpy
hmemcpy / fakee
Last active January 1, 2016 23:48
AcountProvider provider = AccountProvider.CreateProvider();
AcountProvider outProvider;
A.CallTo(() => mockAppointment.GetAccountCollection().GetProviderImpl(out outProvider)) // GetProviderImpl is a generic method
.Returns(true)
.AssignsOutAndRefParameters(provider);
bool result = mockAppointment.GetAccountCollection().GetProviderImp(out outProvider); // this returns false and provider is null???
@hmemcpy
hmemcpy / gist:9447256
Last active August 29, 2015 13:57
Why do u crash?????
<entry>
<record>10589</record>
<time>2014/03/09 11:56:50.360</time>
<type>Error</type>
<source>Editor or Editor Extension</source>
<description>System.InvalidOperationException: Attempting to get the view from an adapter in state Closed
at Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.get_WpfTextViewHost()
at Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.ClearCommandContext()
at Microsoft.VisualStudio.Editor.Implementation.VsMouseProcessor.PostprocessMouseLeftButtonUp(MouseButtonEventArgs e)
at Microsoft.VisualStudio.Text.Utilities.WpfMouseProcessor.&lt;&gt;c__DisplayClass30.&lt;UIElement_MouseLeftButtonUp&gt;b__29()
This file has been truncated, but you can view the full file.
TearDown : JetBrains.Util.Tests.TestLoggerListener+TestWrapperException : 124 exceptions were thrown.
#001: Component CatalogType: JetBrains.ProjectModel.SolutionActivityTrackingComponent [Singleton, Corrupted] construction has failed. Exception has been thrown by the target of an invocation. Sequence contains more than one element
--- EXCEPTION #1/4 [InvalidOperationException]
Message = “Sequence contains more than one element”
ExceptionPath = Root.InnerException.InnerException.InnerException
ClassName = System.InvalidOperationException
Data.DescriptorType = “JetBrains.Application.Extensibility.PartComponentDescriptor, JetBrains.Platform.ReSharper.ComponentModel, Version=8.2.0.2151, Culture=neutral, PublicKeyToken=1010a0d8d6380325”
Data.State = Null
HResult = COR_E_INVALIDOPERATION=80131509
@hmemcpy
hmemcpy / gist:9f47ae12d88b4ab38439
Last active August 29, 2015 14:06
ATDD style tests with BDDfy!
private const string program = @"
/* 1 */ class Person
/* 2 */ {
/* 3 */ public int _age = 22;
/* 4 */ public int Age { get { return _age; } set { _age = value; } }
public override string ToString() { return ""hi""; }
/* 5 */ }
/* 6 */
/* 7 */ class Program
/* 8 */ {
@hmemcpy
hmemcpy / my-boxstarter.ps1
Last active August 29, 2015 14:08
Boxstarter script for my development machine
#development
cinst notepad2
cinst git.install
cinst poshgit
cinst jump-location
cinst beyondcompare
cinst devbox-rapidee
cinst envycoder
cinst nuget.commandline
cinst scriptcs
@hmemcpy
hmemcpy / Export-SvnDiff.ps1
Created December 16, 2014 11:29
Export-SvnDiff
function Export-SvnDiff($repo, $fromRevision, $toRevision, $outputDirectory)
{
$xpath = "/diff/paths/path[@kind='file' and (@item='added' or @item='modified')]"
[xml]$output = & svn diff -r $("{0}:{1}" -f $fromRevision, $toRevision) $repo --summarize --xml
$output | Select-Xml -XPath $xpath | % { $_.node."#text" } | % {
$targetFile = Resolve-FullPath (Join-Path $outputDirectory ($_ -replace $repo))
$targetDir = $targetFile | Split-Path
New-Item -Force -ItemType directory -Path $targetDir | Out-Null
& svn export -r $toRevision -q --force $_ $targetFile
@hmemcpy
hmemcpy / config.cson
Last active November 30, 2015 14:34
Turn off displaying CR/LF "invisibles" in Atom
# File -> Open your Config
# add the following inside 'invisibles':
"*":
editor:
invisibles:
eol: ''
cr: ''
...