Skip to content

Instantly share code, notes, and snippets.

Avatar

Jb Evain jbevain

View GitHub Profile
@jbevain
jbevain / TinySwitch.cs
Last active Aug 29, 2015
Switch opcode size analyser for CoreCLR #918
View TinySwitch.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
namespace TinySwitch
{
class Program
View a.The Code You Run.cs
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, CoreCLR!");
}
}
View test.rs
#![feature(lang_items)]
#![allow(unstable)]
#![allow(non_camel_case_types)]
extern crate libc;
extern crate unicode;
mod w32 {
use libc::types::os::arch::extra::{HANDLE, LPCWSTR};
@jbevain
jbevain / gist:6e1744b5de9038daa403
Created Dec 10, 2014
Copies of Mono.Cecil.dll in Unity
View gist:6e1744b5de9038daa403
C:\Program Files (x86)\Unity> find -name 'Mono.Cecil.dll'
./Editor/Data/Managed/Mono.Cecil.dll
./Editor/Data/Mono/lib/mono/2.0/Mono.Cecil.dll
./Editor/Data/Mono/lib/mono/unity/Mono.Cecil.dll
./Editor/Data/Mono/lib/mono/unity_web/Mono.Cecil.dll
./Editor/Data/MonoBleedingEdge/lib/mono/2.0/Mono.Cecil.dll
./Editor/Data/MonoBleedingEdge/lib/mono/3.5/Mono.Cecil.dll
./Editor/Data/MonoBleedingEdge/lib/mono/4.0/Mono.Cecil.dll
./Editor/Data/MonoBleedingEdge/lib/mono/gac/Mono.Cecil/0.9.4.0__0738eb9f132ed756/Mono.Cecil.dll
./Editor/Data/PlaybackEngines/flashsupport/BuildTools/cil2as/Mono.Cecil.dll
@jbevain
jbevain / NamespaceProjectHook.cs
Created Nov 26, 2014
Project Generation Hook to insert namespace in the project files
View NamespaceProjectHook.cs
using System;
using UnityEngine;
using UnityEditor;
using SyntaxTree.VisualStudio.Unity.Bridge;
[InitializeOnLoad]
public class NamespaceProjectHook
{
@jbevain
jbevain / ReferenceRemovalProjectHook.cs
Created Nov 26, 2014
Project Generation Hook to remove references to Boo.Lang and UnityScript assemblies
View ReferenceRemovalProjectHook.cs
using System;
using UnityEngine;
using UnityEditor;
using SyntaxTree.VisualStudio.Unity.Bridge;
[InitializeOnLoad]
public class ReferenceRemovalProjectHook
{
View TypedRef.cs
using System;
using System.Reflection;
using System.Reflection.Emit;
static class TypedRef
{
public static TClass RoundTrip<TClass>(TClass instance) where TClass : class
{
var method = new DynamicMethod("", typeof(TClass), new [] {typeof(TClass)}, true);
var il = method.GetILGenerator();
@jbevain
jbevain / gist:933a81871c55e716f208
Last active Aug 29, 2015
Allocating strings from unmanaged memory
View gist:933a81871c55e716f208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
namespace StringPool
{
@jbevain
jbevain / gist:c42dd13616117b9cd5a7
Last active Aug 29, 2015
VSTU sample of Expression Evaluation tests
View gist:c42dd13616117b9cd5a7
[Test]
public void StructInstanceMembers()
{
AssertExpressionsAtLine(21, "Types.cs", new Evaluations
{
{ "one",
Expect("one", Quoted("<X:1 Y:1 Z:1>"), "Victor",
Expect("X", "1f", "System.Single"),
Expect("Y", "1f", "System.Single"),
Expect("Z", "1f", "System.Single"))
View sizeof.cs
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);