Skip to content
/ FluentIL Public
forked from PCOL/FluentIL

A .NET library for using reflection emit in a fluent way.

License

Notifications You must be signed in to change notification settings

arlm/FluentIL

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FluentIL

A .NET library for using reflection emit in a fluent way.

Examples

Create Type

Creates a simple type with no constructors, methods, or properties.

var type = TypeFactory
    .Default
    .NewType("TestType")
    .CreateType();

Create Type With Method

Creates a simple type with a test method that takes a single string parameter and returns it.

var typeBuilder = TypeFactory
    .Default
    .NewType("TestType");

typeBuilder
    .NewMethod<string>("TestMethod")
    .Public()
    .Param<string>("value");
    .Body()
    .Declare<string>(out ILocal local)
    .LdArg1()
    .StLoc(local)
    .Nop()
    .LdLoc()
    .Ret();

var type = typeBuilder.CreateType();

Create Type with Property

Creates a simple type with a string property called Value with public get and set methods.

var typeBuilder = TypeFactory
    .Default
    .NewType("TestType");

var fieldValue = typeBuilder
    .NewField<string>("value")
    .Private();

typeBuilder
    .NewProperty<string>("Value");
    .Getter(m => m
        .Public()
        .Body()
        .LdArg0()
        .LdFld(fieldValue)
        .Ret())
    .Setter(m => m
        .Public()
        .Body()
        .LdArg0()
        .LdArg1()
        .StFld(fieldValue()
        .Ret())

About

A .NET library for using reflection emit in a fluent way.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%