Skip to content

Instantly share code, notes, and snippets.

View jbevain's full-sized avatar

Jb Evain jbevain

View GitHub Profile
@jbevain
jbevain / roslyn-enumerable-of-t.diff
Last active August 29, 2015 13:58
Roslyn patch to add syntactic sugar to C# replacing IEnumerable<T> with T~
diff --git a/Src/Compilers/CSharp/Source/Binder/Binder_Symbols.cs b/Src/Compilers/CSharp/Source/Binder/Binder_Symbols.cs
index ce0a903..b34b498 100644
--- a/Src/Compilers/CSharp/Source/Binder/Binder_Symbols.cs
+++ b/Src/Compilers/CSharp/Source/Binder/Binder_Symbols.cs
@@ -379,6 +379,20 @@ namespace Microsoft.CodeAnalysis.CSharp
return new PointerTypeSymbol(elementType);
}
+ case SyntaxKind.EnumerableType:
+ {
@jbevain
jbevain / reflection.fs
Created December 20, 2013 16:00
Consuming a reflection type provider.
open System
open System.Reflection
open System.Reflection.Emit
open SyntaxTree.Reflection
let corlib = Assemblies.mscorlib
let console = corlib.``System.Console``
let writeLine = console.``WriteLine(string)``
let write = DynamicMethod("write", null, [| typeof<string> |])
open System
open System.Text
type StringIndex =
struct
val String: string
val Index: int
end
new(s: string) = { String = s; Index = 0 }
using System.Diagnostics;
using System.Globalization;
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
public static class VisualStudioFileOpening
{
@jbevain
jbevain / codeof.fs
Last active December 18, 2015 20:38
open System
open System.Reflection
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
[<ReflectedDefinition>]
let id x = x
[<ReflectedDefinition>]
If there’s one thing I’ve come to learn about life, it’s that most things are neither completely black nor completely white. There’s an infinity of shade of grays in between.
And if the announce of the Visual Studio (VS from now on) 11 beta taught me something, it is that VS 11 is exactly that. Neither completely black, nor completely white. But very gray. Oh so gray.
I won’t comment about the new look here, as the object of my ire with VS and its apparent roadmap lies at a completely different level. And boy am I annoyed to see where the VS team puts its focus.
Visual Studio 11 will be the sixth iteration of Visual Studio with .net support. And it’s still a terrible platform for the .net programmer.
Do you remember Steve Yegge’s rant about the need of a programmable platform at Google? It’s a tad long (euphemism of the day), but it’s well worth the read. And with Visual Studio, Microsoft is exactly failing at that.
using System;
using System.Collections.Generic;
using Mono.Cecil;
class CompactFrameworkPatcher {
static readonly byte [] fwPkToken1 = new byte [] {
0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89
};
@jbevain
jbevain / il.boo
Created March 23, 2011 09:18
boo il macro
import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.PatternMatching
import System
import System.Collections.Generic
import System.Reflection
import System.Reflection.Emit
macro il(obj as ReferenceExpression):
@jbevain
jbevain / gist:647076
Created October 26, 2010 15:14
Node dumper using y combinator
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Node {
public string Text { get; private set; }
public IList<Node> Children { get; private set; }
diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay
index b718931..70051f1 100644
--- a/mcs/mcs/cs-parser.jay
+++ b/mcs/mcs/cs-parser.jay
@@ -2705,6 +2705,22 @@ delegate_declaration
}
;
+opt_enumerable_or_nullable
+ : opt_enumerable