Advanced Reflec+on & Metaprogrammming Jb Evain - - PowerPoint PPT Presentation

advanced reflec on metaprogrammming
SMART_READER_LITE
LIVE PREVIEW

Advanced Reflec+on & Metaprogrammming Jb Evain - - PowerPoint PPT Presentation

Advanced Reflec+on & Metaprogrammming Jb Evain <jbevain@novell.com> Mono Team, Novell, Inc. Metaprogrammming Metaprogramming is the wri+ng of


slide-1
SLIDE 1

Advanced ¡Reflec+on ¡ & ¡ Metaprogrammming ¡

Jb ¡Evain ¡ ¡<jbevain@novell.com> ¡ Mono ¡Team, ¡Novell, ¡Inc. ¡

slide-2
SLIDE 2

Metaprogrammming ¡

slide-3
SLIDE 3

“Metaprogramming ¡is ¡the ¡wri+ng ¡of ¡ computer ¡programs ¡that ¡write ¡or ¡ manipulate ¡other ¡programs ¡(or ¡ themselves) ¡as ¡their ¡data, ¡or ¡that ¡do ¡ part ¡of ¡the ¡work ¡at ¡compile ¡+me ¡ that ¡would ¡otherwise ¡be ¡done ¡at ¡ run+me.” ¡

hLp://en.wikipedia.com/wiki/ Metaprogramming ¡

slide-4
SLIDE 4

Languages ¡/ ¡Compile ¡+me ¡ metaprogramming ¡

what ¡this ¡talk ¡is ¡not ¡about ¡

slide-5
SLIDE 5

programs ¡as ¡data ¡

slide-6
SLIDE 6
slide-7
SLIDE 7

metadata ¡

slide-8
SLIDE 8

headers ¡

slide-9
SLIDE 9

tables ¡

slide-10
SLIDE 10

CIL ¡

slide-11
SLIDE 11
slide-12
SLIDE 12
slide-13
SLIDE 13

System.Reflec+on ¡

buil+n ¡

slide-14
SLIDE 14

System.Reflec+on ¡

  • Object.GetType ¡() ¡
  • Type.GetTypeFromHandle ¡(…) ¡
  • MethodBody.GetILAsByteArray ¡() ¡
slide-15
SLIDE 15

Mono.Reflec+on ¡

lightweight ¡reflec+on ¡helper ¡

slide-16
SLIDE 16

Mono.Reflec+on ¡

  • Run+me ¡IL ¡disassembler ¡
  • IL ¡paLern ¡matching ¡
  • Property ¡backing ¡field ¡
slide-17
SLIDE 17

Mono.Cecil ¡

Swiss ¡Army ¡Knife ¡for ¡assemblies ¡

slide-18
SLIDE 18

Cross ¡Pla\orm ¡

  • Mono ¡
  • .net ¡>= ¡2.0 ¡
  • CompactFramework ¡>= ¡2 ¡
  • Silverlight ¡>= ¡2 ¡
  • WP7 ¡
slide-19
SLIDE 19

Why ¡

  • Complete ¡metadata ¡access ¡
  • No ¡AppDomain ¡bloa+ng ¡
  • Collec+ble ¡data ¡
  • No ¡+e ¡to ¡a ¡specific ¡mscorlib.dll ¡
  • Ability ¡to ¡modify ¡exis+ng ¡assemblies ¡
slide-20
SLIDE 20

Why ¡not ¡

  • System.Reflec+on.Emit’s ¡

– AssemblyBuilderAccess.Run ¡ – AssemblyBuilderAccess.RunAndCollect ¡

slide-21
SLIDE 21

The ¡strong ¡name ¡problem ¡

slide-22
SLIDE 22

Similar ¡projects ¡

  • Microsoe’s ¡CCI ¡
  • IKVM.Reflec+on[.Emit] ¡
slide-23
SLIDE 23

usage ¡

slide-24
SLIDE 24

achievement ¡

slide-25
SLIDE 25

a ¡glimpse ¡at ¡the ¡future ¡

slide-26
SLIDE 26

Milo ¡

A ¡level ¡higher ¡

slide-27
SLIDE 27

links ¡

  • hLp://twiLer.com/jbevain ¡
  • hLp://evain.net/blog ¡
  • hLp://github.com/jbevain/cecil ¡
  • hLp://groups.google.com/group/mono-­‑cecil ¡
  • hLp://github.com/jbevain/mono.reflec+on ¡
slide-28
SLIDE 28

ques+ons ¡? ¡