Skip to content

Instantly share code, notes, and snippets.

View dgrunwald's full-sized avatar

Daniel Grunwald dgrunwald

View GitHub Profile
// Copyright (c) 2013 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
@dgrunwald
dgrunwald / async.cs
Created March 2, 2012 20:33
Async/Await support for .NET 4.0
// Copyright (c) 2012 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
@dgrunwald
dgrunwald / ProcessRunner.cs
Created April 7, 2013 15:51
Replacement for System.Diagnostics.Process
// Copyright (c) 2013 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
@dgrunwald
dgrunwald / DecompileQueries.cs
Created August 21, 2012 10:58
Query Expression Decompiler
// Uses ICSharpCode.NRefactory 5.2
using System;
using System.Linq;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.PatternMatching;
namespace DecompileQueries
{
class Program
@dgrunwald
dgrunwald / dup-stloc-jit-bug.il
Created November 1, 2017 00:25
Implicitly truncating stloc after dup seems to be miscompiled in RyuJIT
.assembly extern mscorlib
{
.publickeytoken = ( b7 7a 5c 56 19 34 e0 89 )
.ver 4:0:0:0
}
.assembly 'StackTypes'
{
.ver 0:0:0:0
}
.assembly extern System.Runtime
{
.publickeytoken = (
b0 3f 5f 7f 11 d5 0a 3a
)
.ver 4:2:0:0
}
.assembly extern System.Console
{
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 4:0:0:0
}
.assembly StackTests
{
.hash algorithm 0x00008004
.ver 1:0:4059:39717
}
@dgrunwald
dgrunwald / awaitableWPF.cs
Created March 2, 2012 20:30
Awaitable WPF Dispatcher
public static class WpfExtensions
{
public static DispatcherAwaiter GetAwaiter(this Dispatcher dispatcher)
{
return new DispatcherAwaiter(dispatcher, DispatcherPriority.Normal);
}
public static Tuple<Dispatcher, DispatcherPriority> WithPriority(this Dispatcher dispatcher, DispatcherPriority priority)
{
return Tuple.Create(dispatcher, priority);
@dgrunwald
dgrunwald / gist:8474772
Created January 17, 2014 14:59
Invalid code that messes up locations in NRefactory parser
using System;
using System.Linq;
class Test
{
public static Task<int> RunGitAsync(string workingDir, params string[] arguments)
{
string git = FindGit();
if (git == null)
return Task.FromResult(9009);
ProcessRunner p = new ProcessRunner();
################################ UNIT TESTS ################################
Running tests in 'C:\work\NRefactory\bin\Debug\ICSharpCode.NRefactory.Tests.dll'...
======================================================================
Starting new resolver for precedent => {
Console.WriteLine (precedent.IsFaulted);
}
Resolved 'int' to [TypeResolveResult System.Int32]
Resolved 'Task<int>' to [TypeResolveResult System.Threading.Tasks.Task`1[[System.Int32]]]
Resolved 'Task<int> foo = null;
' to [ResolveResult System.Void]