Skip to content

Instantly share code, notes, and snippets.

@alexandrnikitin
alexandrnikitin / gist:4540908
Created January 15, 2013 18:43
Returns resourceString then resourceString2 then exception.
var http = Substitute.For<IHttp>();
http.GetResponse(Arg.Any<string>()).Returns(resourceString, resourceString2);
http.GetResponse(Arg.Any<string>()).Returns(x => { throw new Exception(); });
public MemoryMapPager(string fileName, FlushMode flushMode = FlushMode.Full)
{
_flushMode = flushMode;
var fileInfo = new FileInfo(fileName);
var fileLength = fileInfo.Length;
var isFileEmpty = fileLength == 0 || fileInfo.Exists == false;
_fileStream = fileInfo.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
public class MeasuredInput
{
public string Identifier { get; set; }
public int MeasuredValue { get; set; }
public double Confidence { get; set; }
}
public class Measurement
{
public Measurement(string primaryId, string secondaryId, int value, double adjustedMeasurement)
@alexandrnikitin
alexandrnikitin / gist:8969922
Created February 13, 2014 04:53
Dynamic and extension method
public static class Program
{
public static void Main(string[] args)
{
dynamic a = 1;
MethodWithDynamic(a).Extension();
}
public static int MethodWithDynamic(dynamic a)
{
namespace Lib
{
public interface Counter { int Count(string s); }
public abstract class AbstractClass : AbstractParent
{
public abstract int Foo(int x);
public virtual int Foo(string s) { return Foo(Counter.Count(s)); }
}
using Autofac;
using Xunit;
namespace ClassLibrary1
{
public class Stackoverflow24762539
{
[Fact]
public void Repro()
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace PerformanceProblem
{
public class Program
{
public static void Main()
@alexandrnikitin
alexandrnikitin / PerformanceProblemWithNestedClass_With_T()
Last active August 29, 2015 14:10
PerformanceProblemWithNestedClass_With_T()
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace PerformanceProblem
{
public class Program
{
public static void Main()
@alexandrnikitin
alexandrnikitin / Delegate allocations
Last active August 29, 2015 14:11
Delegate allocations
Empty: 34 items
Identity: 25 items
Always true: 9 items
@alexandrnikitin
alexandrnikitin / Windbg
Last active May 24, 2016 20:27
Windbg commands
sxe ld:mscorlib
g
.loadby sos clr
// .loadby sos mscorwks
sxe ld:clrjit
// sxe ld:mscorjit
g
!threads
!dumpdomain
!dumpdomain 000000a930db1d10