Skip to content

Instantly share code, notes, and snippets.

View dgrunwald's full-sized avatar

Daniel Grunwald dgrunwald

View GitHub Profile
"C:\Program Files (x86)\SharpDevelop\5.0\bin\..\bin\Tools\NUnit\nunit-console-x86.exe" "C:\work\SD5\bin\UnitTests\Debugger.Tests.dll" /noxml /pipe="97d81b0f-c2ca-45a8-a1cd-dd556f6a5c39" /run="Debugger.Tests.DebuggerTests.ControlFlow_Stepping"
NUnit-Console version 2.6.3.0
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
Copyright (C) 2006 Daniel Grunwald.
Copyright (C) 2006-2008 Matt Ward.
All Rights Reserved.
Runtime Environment -
using System;
using System.Collections.Generic;
class Program
{
public static void Main()
{
var la = new B2();
int ha;
@dgrunwald
dgrunwald / gist:835364
Created February 19, 2011 21:06
Pattern Matching Idea
var usingVarDecl = new VariableDeclarationStatement {
Type = Pattern.Any("type"),
Variables = {
Pattern.NamedGroup(
"variable",
new VariableInitializer {
Initializer = Pattern.Any()
}
)
}
@dgrunwald
dgrunwald / gist:1022708
Created June 13, 2011 12:44
NR memory usage test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace TestNRMemoryUsage
{
public IType Resolve(ITypeResolveContext context)
{
string[] parts = typeName.Split('.');
var assemblies = new [] { context.CurrentAssembly, context.Compilation.MainAssembly }.Concat(context.Compilation.ReferencedAssemblies);
for (int i = parts.Length - 1; i >= 0; i++) {
string ns = string.Join(".", parts, 0, i);
string name = parts[i];
int topLevelTPC = (i == parts.Length - 1 ? typeParameterCount : 0);
foreach (var asm in assemblies) {
if (asm == null)
@dgrunwald
dgrunwald / gist:2158660
Created March 22, 2012 14:31
Adorner in ScrollViewer
void AddLayer(ScrollViewer scrollViewer)
{
scrollViewer.ApplyTemplate();
ScrollBar scrollBar = (ScrollBar)scrollViewer.Template.FindName("PART_VerticalScrollBar", scrollViewer);
scrollBar.ApplyTemplate();
Track track = (Track)scrollBar.Template.FindName("PART_Track", scrollBar);
var grid = VisualTreeHelper.GetParent(track) as Grid;
if (grid != null) {
var myElement = new Border();
Grid.SetColumn(myElement, Grid.GetColumn(track));
@dgrunwald
dgrunwald / gist:2391396
Created April 15, 2012 09:12
async decompiler
// Original:
public async Task<bool> SimpleBoolTaskMethod()
{
Console.WriteLine("Before");
await Task.Delay(TimeSpan.FromSeconds(1.0));
Console.WriteLine("After");
return true;
}
// MoveNext
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
[CompilerGenerated]
[StructLayout(LayoutKind.Auto)]
private struct <CopyToAsyncInternal>d__2 : IAsyncStateMachine
{
class Program
{
public static void Main(string[] args)
{
bool b = false;
short s = 0;
var res = b ? 1L : s;
Console.WriteLine(res.GetType()); // prints Int64
}
}
class Program
{
public static void Main(string[] args)
{
bool b = false;
StringComparison s = 0;
var res = b ? 0.0f : s;
Console.WriteLine(res.GetType()); // prints System.StringComparison
}
}