FODY

IL weaving for everyone

Paweł Łukasik

 18.09.2014

AGENDA


  • What's Fody?
  • What can be done?
  • Show me the code!
  • Our own example!

About.me


FODY?



Extensible tool for weaving .net assemblies.

Weaving??

Manipulating:

  • source code - compile-time
    • T4, WebForms designer
  • IL instructions - compile-time
    • Fody, PostSharp
  • JIT code - run time

source: http://www.infoq.com/articles/Simon-Cropp

source: http://www.infoq.com/articles/Simon-Cropp

IL Manipulation Pros

  • reduces source code clutter



IL Manipulation Cons

  • harder to maintain/grasp


FODY

  • solutions for 'pluming-code' tasks
    • INPC, Logging, Auditing etc.
  • remedy for IL manipulation cons
    • easier to maintain/grasp
  • available as nuget
    • *.Fody
  • source code on github (https://github.com/Fody/Fody)
  • MIT license

The plumbing tasks Fody handles

  • Injection of the MSBuild task into the build pipeline
  • Resolving the location of the assembly and pdb
  • Abstracts the complexities of logging to MSBuild
  • Reads the assembly and pdb into the Mono.Cecil object model
  • Re-applying the strong name if necessary
  • Saving the assembly and pdb



Extensible Fody

Add-INS




Anotar

logging




AssertMessage

assertions




AsyncErrorHandler

error handling to async and TPL code



Caseless

case-insensitive string comaprison



Catel

proprietary



Commander

ICommand properties from MVVM



Costura

references as resources



DependencyInjection

AutoFac, Ninject & Spring



EmptyConstructor

Adds empty ctor



EmptyStringGuard

checks from empty strings



EnableFaking

allows testing w/o writing interfaces



Equals

generates GetHashCode & Equals




ExtraConstraints

contraints on Enums and Delegates



Fielder

converts fields to public properties



InfoOf

simillar to typeof for methods, properties and fields



Ionad

replaces static methods calls



Janitor

simplifies IDisposable



JetBrainsAnnotations

proprietary



MethodCache

Caches return value of methods



MethodDecorator

Add code to be executed before and after invocation 





MethodTimer

method timing code




Mixins



ModuleInit

Module initializer of an assembly



Mutable

F# adding for union type setters



NullGuard

checks for null arguments



Obsolete

Helps keeps ObsoleteAttribute consistent



PropertyChanged

INotifyPropertyChanged



PropertyChanging

INotifyPropertyChanging



Publicize

Non-public to public



RemoveReference

self-explanatory



Resourcer

simple reading of resources



Scalpel

removes tests




Spring



Stamp

Adds git info to assembly




StampSvn

Same but with SVN



Stiletto

proprietary



ToString

ToString from public properties



Usable

enclose all IDisposable variables with using



Validar

IDataErrorInfo & INotifyDataErrorInfo



Visualize

DebuggerVisualizer




Virtuosity

change all members to virtual



YALF

Yet Anoyher Logging Framework

FodyWeavers.xml

  • configure weavers and their options
  • multiple entries - order counts!


DEMO

Fody in Action



DEMO: CREATE YOUR OWN ADDIN


FODY

+

Obfuscate

.Sum()

    We've showed:

    • how to use Fody
    • its Addins
    • how to create our own AddIn

    Knowledge - WHERE?





    Fody (ptak) -> wikłacze -> weaver -> IL weaver -> Fody (tool)


    Questions?

    Feedback:

    twitter: @pawel_lukasik

    mail: pawel@octal.pl

    blog: http://blog.octal.pl



    THANK YOU!

    http://slides.com/pawellukasik/fody-rzeszow

    http://blog.octal.pl

    Made with Slides.com