Skip to content

Instantly share code, notes, and snippets.

View jbevain's full-sized avatar

Jb Evain jbevain

View GitHub Profile
@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):
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
};
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.
@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>]
using System.Diagnostics;
using System.Globalization;
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
public static class VisualStudioFileOpening
{
open System
open System.Text
type StringIndex =
struct
val String: string
val Index: int
end
new(s: string) = { String = s; Index = 0 }
@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> |])
@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 / Demo.fs
Last active February 17, 2023 20:40
open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.CSharp
open Microsoft.CodeAnalysis.CSharp.Syntax
open FSharp.CodeAnalysis.CSharp.Patterns
// full form for the node, with SyntaxKind and tokens
let fullForm (n: CSharpSyntaxNode) =
match n with
| BinaryExpressionSyntax(_, LiteralExpressionSyntax(_), _, _) -> ()
@jbevain
jbevain / sizeof.cs
Created July 14, 2014 20:01
SizeOf
using System;
using System.Reflection.Emit;
static class SizeOf<TStruct> where TStruct : struct
{
public static readonly int Value;
static SizeOf()
{
var method = new DynamicMethod("", typeof(int), Type.EmptyTypes);