Skip to content

Instantly share code, notes, and snippets.

@vladima
Created May 16, 2015 04:41
Show Gist options
  • Save vladima/4f1b6c248ec21ff45fa1 to your computer and use it in GitHub Desktop.
Save vladima/4f1b6c248ec21ff45fa1 to your computer and use it in GitHub Desktop.
// compile as: fsc -r:Mirror.dll client.fs
module Client
type T = Top.Repro.C
T.Run()
// compile as: fsc --target:library ProvidedTypes.fsi ProvidedTypes.fs Mirror.fs
namespace Repro
open System.IO
open System.Reflection
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
[<assembly : TypeProviderAssembly>]
do()
[<TypeProvider>]
type Mirror() as this =
inherit TypeProviderForNamespaces()
let thisAssembly = typeof<Mirror>.Assembly
let topType = ProvidedTypeDefinition(thisAssembly, "Top", "Repro", Some typeof<obj>, IsErased = true)
let csAssembly =
let location = Path.GetDirectoryName(thisAssembly.Location)
System.Reflection.Assembly.LoadFrom(Path.Combine(location, "program.dll"))
do topType.AddAssemblyTypesAsNestedTypesDelayed(fun() -> csAssembly)
do this.AddNamespace("Top", [topType])
// compile as: csc /t:library program.cs
using System;
using System.Net.Security;
using System.ServiceModel;
class C {
[FaultContract(typeof(Exception), ProtectionLevel = ProtectionLevel.Sign)]
public static void Run() {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment