Skip to content

Instantly share code, notes, and snippets.

View SteveDunn's full-sized avatar

Steve Dunn SteveDunn

View GitHub Profile
@dotMorten
dotMorten / MSBuildCheatSheet.xml
Created January 14, 2019 23:19
MSBuild Cheat Sheet
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
How to define a variable.
Just stick a new node in a property group.
-->
<PropertyGroup>
<!-- This node in a property group will define a variable -->
<TestVariable>Test Variable Value</TestVariable>
@davidfowl
davidfowl / dotnetlayout.md
Last active April 26, 2024 13:37
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@davidfowl
davidfowl / gist:3173128
Created July 24, 2012 22:36 — forked from jmangelo/gist:3173109
MethodInfo.Invoke is slow... open instance delegate to the rescue
using System;
using System.Linq;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Collections.Generic;
namespace ConsoleApplication3
{
class Program
@adjames
adjames / GenericConstructorHelper.cs
Created February 4, 2012 07:29
Workaround for inability to create C# generic constraints for the presence of a constructor that takes parameters... i.e. Foo<T>(string name) where T: new(string)
public Func<T1, TResult> CompileConstructor<T1, TResult>()
{
var type1 = typeof(T1);
var parameter1 = Expression.Parameter(type1);
var constructor = typeof(TResult).GetConstructor(new Type[] { type1 });
var body = Expression.New(constructor, parameter1);
var lambda = Expression.Lambda<Func<T1, TResult>>(body, parameter1);
var method = lambda.Compile();
return method;
}