Skip to content

Instantly share code, notes, and snippets.

@hmemcpy
hmemcpy / keybindings.json
Created May 5, 2015 07:57
ReSharper IntelliJ keybindings for Visual Studio Code
// ReSharper IntelliJ keybindings for Visual Studio Code
// This is a work in progress...
[
{ "key": "ctrl+b", "command": "editor.action.goToDeclaration",
"when": "editorTextFocus" },
{ "key": "alt+f7", "command": "editor.action.referenceSearch.trigger",
"when": "editorTextFocus" }
]
@hmemcpy
hmemcpy / .gitignore
Created February 12, 2016 11:47
VS default .gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
@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???
class MyBusinessObject
{
public int? MyNullable;
public bool HasSomeBusinessProperty
{
get { return myNullable.HasValue; }
}
}
@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();
}
@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" />
I'm tryng to refactor a monstrous WCF service into something more manageable.
At the time of writing, the service takes about 9 dependencies via constructor, which makes unit testing it very difficult.
The service is handling local state via state machine, does validation on the parameters, throws fault exceptions, performs the actual operation and fires publication events via a pub/sub channel. This code is very similar accross all other service calls.
I realize that I can do several of those things (argument validation, pub/sub notifications) differently, perhaps via WCF behaviors, but my gut tells me that the general approach is wrong -- this feels too "procedural".
I wonder if acronyms like DDD or CQRS or other techniques can help out here?
Thanks!
@hmemcpy
hmemcpy / readme.md
Created February 5, 2013 21:08
Your feedback on the System.Diagnostics.Abstractions API is requested...

I'm working on a small project, inspired by the awesome System.IO.Abstractions, aiming to provide a wrapper over System.Diagnostics.Process, to assist testability of anything process-related.

Where System.IO.Abstractions provides a wrapper over the Path, File, Directory types, as well as a wrapper objects over FileInfo and DirectoryInfo, all conveniently accessible from an IFileSystem, mirroring the way those types exist today in the .NET framework, the System.Diagnostics.Process type presents its own challenges when trying to create a convenient wrapper.

Your feedback on the API is, therefore, very much appreciated.

The Process class has several static methods for launching a new process, as well as other stuff:

void EnterDebugMode();

Process GetCurrentProcess();

@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: ''
...