Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hacking Mono and .NET (COSCUP 2014)

Hacking Mono and .NET (COSCUP 2014)

Atsushi Eno

July 19, 2014
Tweet

More Decks by Atsushi Eno

Other Decks in Programming

Transcript

  1. 開源版.NET Framework 実装 Open Source .NET Framework implementation 可以用在 runs

    on: Linux, Mac, Windows, iOS, Android ... 有自己的軟體生態系統 has own ecosystem Mono http://goo.gl/OqqpfK
  2. 目的 Aims • .NET跟Mono開源程度? find how open source .NET and

    Mono are. • Mono未來開發走向會到哪裡? find where Mono development goes. • 你們可以在.NET/Mono上研究跟hack什麼? find what you can research and hack into. http://goo.gl/OqqpfK
  3. .NET/Mono 軟體堆疊 software stack • Runtime [CLR, mono runtime] ◦

    CIL metadata execution engine (JIT) ◦ 垃圾收集器 garbage collector ◦ 其他核心處理 other core operations • C# 編譯器 Compilers (etc.) [csc, mcs] 命令行編譯器 command line compiler 編譯器即服務 compiler as a service • 函式庫 Class Libraries
  4. 開源程度.NET? / How is .NET open? 所以呢、它跟Mono有關係嗎? so what, does

    it matter for Mono? →我們(可以)再利用他們的程式源碼、不要重新發明輪子  We (can) reuse their code, no need to reinvent the wheel →我們可以修改、使其運行在Mono / *nix環境  We can make changes to make it work on Mono / *nix
  5. Project Hosting • https://github.com/aspnet ◦ 包含 SignalR, EntityFramework etc. •

    https://github.com/reactive-extensions • https://github.com/fsharp • http://roslyn.codeplex.com/ • http://dlr.codeplex.com/ 你可以提交PR / You can submit pull requests!
  6. mono runtime, 虛擬機 VM - C CIL metadata loader (assembly

    loader) "mini" virtual execution system: JIT, AOT "sgen" garbage collector core operations string and numbers, I/O, threading, marshal, g10n etc. miscellaneous - profiler, debugger, security ./mono ./mono ./mcs ./mcs ./class
  7. mcs: C# 編譯器 compiler - C# Full C# 5 support

    + some C#6 feature C# REPL (csharp, gsharp) NRefactory - compiler as a service code formatting code completion code analysys ... needs to work with Roslyn ./mono ./mono ./mcs ./mcs ./class
  8. mcs 函式庫 Class Libraries per assembly: mcs/class/corlib, ../System, ... ADO.NET,

    ASP.NET, WinForms, WCF... not "complete" submodule Microsoft libraries. PCL profile assemblies too. ./mono ./mono ./mcs ./mcs ./class
  9. Mono GUI Frameworks • Gtk# - Gtk+ .NET binding ◦

    Banshee, F-Spot, Pinta ... • MonoMac - Cocoa binding • Xwt - cross platform UI toolkit ◦ WPF/MonoMac/Gtk# ◦ supports XAML ◦ Xamarin product uses it
  10. Mono的情況 / Mono state of union Mono 1.0: .NET 1.1,

    core & server (ASP.NET) ".NET on Linux" Mono 1.2: .NET 2.0, WinForms & Gtk# apps "Linux desktop apps on .NET" Mono 2.x: .NET 3,5/4.0, Linq, dynamic, Silverlight Mono 3.x: .NET 4.5, mobile Mono team has been doing a lot (and some are dead)
  11. 發展方向 Development Direction Mono core team - Xamarin driven •

    手機最適合的Runtime mobile-optimal Runtime ◦ minimal footprint, AOT, GC • C# compiler: 保持最新 keep up to date • 非同步函式庫 async class libraries
  12. 發展方向 Development Direction MonoDevelop team • overall Windows / Mac

    improvements • core: project model, text editor ... ◦ NRefactory (C# CaaS) - with SharpDevelop • OSS addins: NuGet, PCL ... (Xamarin: product support addins)
  13. 發展方向 Development Direction Community • Driven mostly by personal interests

    ◦ sometimes big project e.g. MonoGame • Xamarin based (mobile) community projects • Google Summer of Code (GSoC) - 2-3mo. projects
  14. ASP.NET vNext • No IIS or System.Web.dll dependency • Can

    be distributed as one single app • highly modularized framework ◦ from servers to Mvc, SignalR, Identity...
  15. ASP.NET vNext Running ASP.NET vNext on OSX and Linux setup

    "kvm" curl https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh source ~/.kre/kvm/kvm.sh kvm upgrade (use HelloWorldVNext c5c59b so far; master is broken) mono-aspnetvnext Docker image vNext is not quite ready to run complex apps right now...
  16. Reactive Extensions (Rx) "Linq to Events" operate on events in

    Linq way filter, combine, transform events functionally another asynchronous programming approach Sample(), Window(), Merge(), ... hundreds Available on desktop and mobile (iOS/Android/WP)
  17. F# Functional programming (non-pure) brings more type safety pattern matching,

    async, type providers still supports some imperative syntax MonoDevelop F# addin
  18. Xwt + Rx public MyWindow () { this.Closed += delegate

    { Application.Exit (); }; var label = new Label (); var f = new Xwt.Frame () { WidthRequest = 200, HeightRequest = 200 }; var eo = Observable.FromEventPattern<MouseMovedEventArgs> (f, "MouseMoved") .Sample (TimeSpan.FromSeconds (1)); eo.Subscribe (v => label.Text = v.EventArgs.Position.ToString ()); var vb = new VBox (); vb.PackStart (f); vb.PackStart (label); Content = vb; } https://gist.github.com/atsushieno/b5c8beb54312f6452262
  19. Xwt + Rx + F# type MyWindow () as this

    = inherit Window () do this.Closed.Add (fun ea -> Application.Exit ()) let label = new Label () let f = new Frame (WidthRequest = 200.0, HeightRequest = 200.0) let eo = Observable.FromEventPattern<MouseMovedEventArgs> (f, "MouseMoved") let sample = eo.Sample (TimeSpan.FromSeconds 1.0) sample.Subscribe (fun v -> label.Text <- v.EventArgs.Position.ToString ()) let vb = new VBox () vb.PackStart (f) vb.PackStart (label) this.Content <- vb https://gist.github.com/atsushieno/8f93bb13177677c78c9a