Skip to content

Instantly share code, notes, and snippets.

View huseyint's full-sized avatar

Hüseyin Tüfekçilerli huseyint

View GitHub Profile

Keybase proof

I hereby claim:

  • I am huseyint on github.
  • I am huseyint (https://keybase.io/huseyint) on keybase.
  • I have a public key whose fingerprint is 38A9 7B2C AE48 E3B1 956C 50C4 DCDF E671 FDE8 6DC5

To claim this, I am signing this object:

@huseyint
huseyint / ReadonlyFieldDeserialization.cs
Created August 1, 2017 09:09
C# BinaryFormatter works fine with readonly fields
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
class Program
{
static void Main()
{
var formatter = new BinaryFormatter();
@huseyint
huseyint / keybase.md
Created April 3, 2014 15:36
keybase.md

Keybase proof

I hereby claim:

  • I am huseyint on github.
  • I am huseyint (https://keybase.io/huseyint) on keybase.
  • I have a public key whose fingerprint is 38A9 7B2C AE48 E3B1 956C 50C4 DCDF E671 FDE8 6DC5

To claim this, I am signing this object:

@huseyint
huseyint / gist:6087575
Created July 26, 2013 09:33
Dictionary with single item assertion
// headers is a Dictionary<string, string>
Assert.AreEqual(1, headers.Count);
Assert.AreEqual("bar", headers["foo"]);
// Do I need both of these? Only first? Only second?
// Only 1st: What if the item is different than what I expected?
// Only 2nd: If dictionary is empty, this line will throw an exception before assertion is evaluated, is this OK?
// Both: Isn't this against "one assert per unit test" rule?
@huseyint
huseyint / gist:5498304
Created May 1, 2013 20:54
IEqualityComparer<T> delegating work to underlying Func<T, TKey>
public class FuncComparer<T, TKey> : IEqualityComparer<T>
{
private readonly Func<T, TKey> _func;
public FuncComparer(Func<T, TKey> func)
{
_func = func;
}
public bool Equals(T x, T y)
@huseyint
huseyint / comaprison.cs
Created June 15, 2011 06:41 — forked from jakcharlton/comaprison.cs
Property equality comparison on two objects
// Shamelessly stolen and adapted from http://stackoverflow.com/questions/506096/comparing-object-properties-in-c
public static class Comparisons
{
public static bool PublicInstancePropertiesEqual<T>(this T self, T to, params string[] ignore) where T : class
{
if (self != null && to != null)
{
var type = typeof(T);
foreach (var propertyName in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).Select(pi => pi.Name).Except(ignore))
{