Skip to content

Instantly share code, notes, and snippets.

View jbevain's full-sized avatar

Jb Evain jbevain

View GitHub Profile
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, CoreCLR!");
}
}
@jbevain
jbevain / test.rs
Last active August 29, 2015 14:13
#![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 December 10, 2014 14:24
Copies of Mono.Cecil.dll in Unity
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 November 26, 2014 13:16
Project Generation Hook to insert namespace in the project files
using System;
using UnityEngine;
using UnityEditor;
using SyntaxTree.VisualStudio.Unity.Bridge;
[InitializeOnLoad]
public class NamespaceProjectHook
{
@jbevain
jbevain / ReferenceRemovalProjectHook.cs
Created November 26, 2014 13:15
Project Generation Hook to remove references to Boo.Lang and UnityScript assemblies
using System;
using UnityEngine;
using UnityEditor;
using SyntaxTree.VisualStudio.Unity.Bridge;
[InitializeOnLoad]
public class ReferenceRemovalProjectHook
{
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 July 16, 2023 06:42
Allocating strings from unmanaged memory
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 August 29, 2015 14:07
VSTU sample of Expression Evaluation tests
[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"))
@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);
@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(_), _, _) -> ()