{{
FodyFody
code weaving made funcode weaving made fun
About meAbout me
 Tomasz PluskiewiczTomasz Pluskiewicz
 WrocławWrocław
 MakoLab S.A.MakoLab S.A.
 @tpluscode@tpluscode
 About code weavingAbout code weaving
 About FodyAbout Fody
 ExamplesExamples
 QuestionsQuestions
AgendaAgenda
„„Generate” additional code to:Generate” additional code to:
 Add boilerplate code automaticallyAdd boilerplate code auto...
 Source code weavingSource code weaving
 Compile-time weavingCompile-time weaving
 Runtime weavingRuntime weaving
How c...
 Emitting MSILEmitting MSIL
 Refelction.EmitRefelction.Emit
 Mono.CecilMono.Cecil
 Dynamic proxiesDynamic proxies
 Ca...
 Simple but less flexibileSimple but less flexibile
 Requires runtime reference to PostSharpRequires runtime reference t...
IL weaving (with Cecil)IL weaving (with Cecil)
 ILIL isis difficultdifficult
 Need to update PDBsNeed to update PDBs
 M...
Fodies are small passerine
birds belonging to the genus
Foudia in the weaver family
Ploceidae
- wikipedia/Fody
WeaverWeaver
CodeCode
 Many pre-built weaversMany pre-built weavers
 Uses Mono.CecilUses Mono.Cecil
 Integrates into build processIntegrates ...
 Almost 70 packages on NuGetAlmost 70 packages on NuGet
 NullGuardNullGuard
 PropertyChangedPropertyChanged
 CosturaCo...
DemoDemo
 Emitting IL is still required (duh!)Emitting IL is still required (duh!)
 However FodyHowever Fody
 Injects weavers to...
 Assembly with .Fody suffixAssembly with .Fody suffix
 ILMerge referencesILMerge references
 Pulic ModuleWeaver classPu...
DemoDemo
 Don’t use Visual Studio pluginDon’t use Visual Studio plugin
 Weaver order sometimes does matterWeaver order sometimes ...
 https://github.com/Fody/https://github.com/Fody/
 https://github.com/Fody/Fody/wiki/HowToWriteAnAddinhttps://github.com...
Questions?Questions?
The end – wake up nowThe end – wake up now 
Fody - code weaving made fun
Upcoming SlideShare
Loading in …5
×

Fody - code weaving made fun

3,860
-1

Published on

Slides from a presentation held on Wrocław .NET Users Group 60. meeting.

Published in: Technology, Lifestyle
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,860
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Fody - code weaving made fun

  1. 1. {{ FodyFody code weaving made funcode weaving made fun
  2. 2. About meAbout me  Tomasz PluskiewiczTomasz Pluskiewicz  WrocławWrocław  MakoLab S.A.MakoLab S.A.  @tpluscode@tpluscode
  3. 3.  About code weavingAbout code weaving  About FodyAbout Fody  ExamplesExamples  QuestionsQuestions AgendaAgenda
  4. 4. „„Generate” additional code to:Generate” additional code to:  Add boilerplate code automaticallyAdd boilerplate code automatically  Implement Aspect-Oriented ProgrammingImplement Aspect-Oriented Programming  ObfuscationObfuscation  Build killer APIsBuild killer APIs What is code weaving?What is code weaving?
  5. 5.  Source code weavingSource code weaving  Compile-time weavingCompile-time weaving  Runtime weavingRuntime weaving How can I weave?How can I weave?
  6. 6.  Emitting MSILEmitting MSIL  Refelction.EmitRefelction.Emit  Mono.CecilMono.Cecil  Dynamic proxiesDynamic proxies  Castle, LinFu, Unity, Impromptu InterfaceCastle, LinFu, Unity, Impromptu Interface  AOPAOP  PostSharp, AfterthoughtPostSharp, Afterthought  RoslynRoslyn The toolsThe tools
  7. 7.  Simple but less flexibileSimple but less flexibile  Requires runtime reference to PostSharpRequires runtime reference to PostSharp  Requires Visual Studio extensionRequires Visual Studio extension  Aspects in embedded resourcesAspects in embedded resources  Full functionality is not freeFull functionality is not free PostSharpPostSharp
  8. 8. IL weaving (with Cecil)IL weaving (with Cecil)  ILIL isis difficultdifficult  Need to update PDBsNeed to update PDBs  MSBuild integrationMSBuild integration
  9. 9. Fodies are small passerine birds belonging to the genus Foudia in the weaver family Ploceidae - wikipedia/Fody
  10. 10. WeaverWeaver CodeCode
  11. 11.  Many pre-built weaversMany pre-built weavers  Uses Mono.CecilUses Mono.Cecil  Integrates into build processIntegrates into build process  Works on build serversWorks on build servers  Leaves no referencesLeaves no references  Well… depending on the pluginWell… depending on the plugin  Versatile:Versatile:  .NET 3.5-4.5.NET 3.5-4.5  Silverlight 4 & 5Silverlight 4 & 5  Mono, MonoTouch, MonoDroidMono, MonoTouch, MonoDroid  Windows Phone 7 & 8 (also Metro)Windows Phone 7 & 8 (also Metro)  Portable Class LibraryPortable Class Library FodyFody
  12. 12.  Almost 70 packages on NuGetAlmost 70 packages on NuGet  NullGuardNullGuard  PropertyChangedPropertyChanged  CosturaCostura  AnotarAnotar  ModuleInitModuleInit  FreezableFreezable  MethodDecoratorMethodDecorator  InfoOfInfoOf  ToStringToString Community weaversCommunity weavers
  13. 13. DemoDemo
  14. 14.  Emitting IL is still required (duh!)Emitting IL is still required (duh!)  However FodyHowever Fody  Injects weavers to build pipelineInjects weavers to build pipeline  Loads assembliesLoads assemblies  Rewrites PDBsRewrites PDBs  Reapplies strong nameReapplies strong name  Writes to MSBuild build logWrites to MSBuild build log Custom weavingCustom weaving
  15. 15.  Assembly with .Fody suffixAssembly with .Fody suffix  ILMerge referencesILMerge references  Pulic ModuleWeaver classPulic ModuleWeaver class  Mutltiple deployment optionsMutltiple deployment options  In-solutionIn-solution  $(SolutionDir)/Tools  NuGet packageNuGet package  Learn fromLearn from  existing weavers (example follows)existing weavers (example follows)  Fody wikiFody wiki Writing a weaverWriting a weaver
  16. 16. DemoDemo
  17. 17.  Don’t use Visual Studio pluginDon’t use Visual Studio plugin  Weaver order sometimes does matterWeaver order sometimes does matter  Debugging unavailable codeDebugging unavailable code   LogInfo requires detailed MSBuild outputLogInfo requires detailed MSBuild output  Tools -> Projects and Solutions -> Build andTools -> Projects and Solutions -> Build and RunRun  Remember to update Fody packageRemember to update Fody package GotchasGotchas
  18. 18.  https://github.com/Fody/https://github.com/Fody/  https://github.com/Fody/Fody/wiki/HowToWriteAnAddinhttps://github.com/Fody/Fody/wiki/HowToWriteAnAddin  https://github.com/Fody/Fody/wiki/ModuleWeaverhttps://github.com/Fody/Fody/wiki/ModuleWeaver  https://github.com/Fody/Fody/wiki/DeployingAddinsAsNugetshttps://github.com/Fody/Fody/wiki/DeployingAddinsAsNugets  http://www.planetgeek.ch/2013/08/31/dont-wear-woven-sweatshirts-instead-weave-your-http://www.planetgeek.ch/2013/08/31/dont-wear-woven-sweatshirts-instead-weave-your- assemblies/assemblies/  http://haacked.com/archive/2013/01/04/mitigate-the-billion-dollar-mistake-with-aspects.aspx/http://haacked.com/archive/2013/01/04/mitigate-the-billion-dollar-mistake-with-aspects.aspx/ LinksLinks
  19. 19. Questions?Questions?
  20. 20. The end – wake up nowThe end – wake up now 
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×