This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
namespace LinqEqualityComparerExtensions | |
{ | |
public sealed class EqualityComparer<T> : IEqualityComparer<T> | |
{ | |
private readonly Func<T, int> getHashCode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requires the following references: | |
// Microsoft.Build.Engine | |
// Microsoft.Build.Framework | |
using System.Collections.Generic; | |
using Microsoft.Build.BuildEngine; | |
public static class MsBuildHelper | |
{ | |
public static bool RunMsBuild(string projectFile, string target, IDictionary<string, string> properties) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
using Moq; | |
using Moq.Language; | |
using Moq.Language.Flow; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[create_sandbox_for_schema] | |
@schema_name nvarchar(max), | |
@sandbox_name nvarchar(max) | |
AS | |
BEGIN | |
DECLARE sandbox_statements CURSOR FOR | |
WITH primary_key_columns AS | |
( | |
SELECT key_constraints.parent_object_id, | |
columns.name, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$startString = '@%x22%n' | |
$endString = '%n%x22@ | |
$dollar = '%x24' | |
$gitHash = "GitHash=$startString%n$endString" | |
$author = "Author=$startString%an$endString" | |
$branch = "Branch=$startString%d$endString -replace '^\s*\([^,]+,\s*[^,]+,\s*(?<BranchName>[^\)]+)\).*$dollar', '$dollar{BranchName}'" | |
$date = "Date=[datetime]::ParseExact($startString%ad$endString, %x22ddd MMM dd HH:mm:ss zzz", $($dollar)null)" | |
$logMessage = "LogMessage=$startString%s$endString" | |
$changes = "Changes=$startString" | |
$format = "`"$endString},@{$gitHash;$author;$branch;$date;$logMessage;$changes`"" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Management.Automation.Runspaces; | |
public static class Powershell | |
{ | |
public static T ExecuteScript<T>(string script, string returnVariableName) | |
{ | |
using (Pipeline pipeline = RunspaceFactory.CreateRunspace().CreatePipeline()) | |
{ | |
pipeline.Commands.AddScript(script); | |
pipeline.Runspace.Open(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find number of commits | |
& git rev-list --all --count | |
# Find log details for a single commit | |
& git log -1 $gitHash | |
# Find log details from a commit | |
& git log $gitHash..HEAD | |
# Find log details from a commit including the commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
& ildasm "$dll" /out:"$dll.il" | |
& ilasm "$dll.il" /dll /pdb /resource="$dll.res" /key="$key" /output="$dll" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void BuildProxyAssembly(string assemblyPath) | |
{ | |
string assemblyName = Path.GetFileNameWithoutExtension(assemblyPath) + ".Proxies"; | |
string modulePath = Path.Combine(Path.GetDirectoryName(assemblyPath), assemblyName + ".dll"); | |
DefaultProxyBuilder proxyBuilder = new DefaultProxyBuilder(new ModuleScope(true, true, assemblyName, modulePath, assemblyName, modulePath)); | |
Assembly assembly = Assembly.LoadFrom(assemblyPath); | |
var types = from classType in assembly.GetTypes() | |
where classType.IsClass && !classType.ContainsGenericParameters && !classType.IsAbstract && classType.IsPublic | |
from interfaceType in classType.GetInterfaces() | |
where interfaceType.IsPublic && classType.Assembly == interfaceType.Assembly && IsInterfaceOnlyOnClass(classType, interfaceType) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Concurrent; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
public static class MethodInfoToDelegateExtensions | |
{ | |
private static readonly ConcurrentDictionary<MethodInfo, object> cachedDelegates = new ConcurrentDictionary<MethodInfo, object>(); |