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

Open Source .NET technology explained [COSCUP2015]

Open Source .NET technology explained [COSCUP2015]

Atsushi Eno

August 15, 2015
Tweet

More Decks by Atsushi Eno

Other Decks in Programming

Transcript

  1. /me • Mono project developer, .NET Core contributor • Software

    engineer at Xamarin • lurking around H4 and TOSSUG (when in Taipei)
  2. my COSCUP sessions on OSS & .NET • 2013: MonoDevelop

    IDE ◦ how the IDE works. • 2014: Mono and Open Source .NET ◦ how Mono is made up with OSS-ed .NET parts • 2015: .NET Core ◦ what .NET Core is, how it works. (meh, the topics are getting bloat...)
  3. Agenda • The situation how .NET Core was born •

    See how .NET Core works • Current .NET Core status and visions
  4. Quick intro to .NET Framework • A complete development platform

    (like Java) ◦ ECMA 335 (CLI) high-level VM, statically-typed system (similar to jvm) foundation class libraries (similar to rt.jar) beyond standards: DB, Web, GUI... well-thought assembly (library) versioning support ◦ ECMA 334 (C#) statically-typed compilers (similar to java)
  5. what is .NET dev. experience like? • mostly awesome ◦

    solid and mature framework libraries ◦ C# is stable yet evolving ◦ the IDE (Visual Studio) experience is supreme
  6. is .NET perfect then? • NO! NO! NO! ◦ it's

    not quite handy, need to install .NET Fx ◦ apps easily become Windows-only ◦ too much of Windows-isms ◦ too many framwork variants, hard to support all ◦ .NET Fx development is getting slow ◦ updatable only in sync with Windows or VS releases. ◦ several issues due to closed source
  7. There is Mono, it is truly x-plat Mono complements .NET

    defects • cross platform • open source • non-Windows native API Also, Microsoft friendly Problems • not (meant to be) fully compatible w/ .NET Fx • not actively developing server stack anymore • Xamarin went mobiles, leaving Linux desktop
  8. x-plat ain't easy • SL, WP, StoreApp, Xamarin ... different

    Fx and versions ◦ because everything cannot be implemented everywhere ◦ You cannot reference Desktop assemblies in those frameworks ◦ Normally libraries need to be built for those platforms • PCL (Portable Class Library) makes it easy ◦ you build your library as a PCL project ◦ PCLs can be referenced by any (of the profile targets) ◦ For PCLs, you specify Profile, not dll references ◦ packages via NuGet.org (zip archive of dlls, resources and tools)
  9. How is PCL support implemented? (briefly) • modularized core libraries

    ◦ so each Profile is represented as a set of feature assemblies • Type forwarding ◦ PCL "Facade" assemblies don't have implementation ◦ instead, they have [TypeForwardedTo] attributes.
  10. ASP.NET evolution • Web Forms o very easy (even for

    VB coders) x integration with external JavaScript was horrible ASP.NET Ajax • MVC o that's what normal Web dev. wanted. o started as an OSS project, and extended OSS-ism. x depends on System.Web
  11. What's wrong with System.Web? • part of .NET Fx -

    hard to upgrade • Web dev. trends need low-level support ◦ non-blocking I/O (libuv) ◦ HTTP/2 • needs updatable lightweight deployment framework
  12. • "Introducing .NET Core" (.NET team blog) • portable subset

    of .NET Fx • sort out all of those known issues ◦ MIT license w/ patent covenant ◦ standalone redist-able, per app ◦ x-plat • release stages: src(git)/pkg/Fx the rise of .NET Core
  13. .NET Core components (briefly) • coreclr - runtime (VM) •

    roslyn - C# compiler • corefx - foundation class libraries • aspnet - web app framework
  14. Running .NET Core • Use "DNX SDK" (dnvm) ◦ installer

    https://github.com/dotnet/coreclr#get-net-core or Docker ◦ ... or manually set up everything (complicated) • app files: (C#) sources, package.json (project config) • Run ◦ set up dnvm (dnvm: runtime configurator; see coreclr docs) like update-alternatives ◦ dnu restore (dnu: package resolver) ◦ dnx (-p) . run (dnx: runtime, -p is very new option) ◦ dnvm install 1.0.0-beta7-12275 -r coreclr -u; dnvm install 1.0.0-beta7-12275 -u; dnu restore; dnvm use 1.0.0-beta7-12275 -r coreclr; dnx . run
  15. Running .NET Core • How things work ◦ dnvm (framework/selector)

    ▪ the Fx runtime backend can be: clr, mono, coreclr ◦ dnu (package resolver) ▪ based on nuget ◦ dnx (runtime) ▪ uses roslyn (compiler) to compile app at run time
  16. Building .NET Core (Well, you can build them, but managing

    everything to run app is messy.) • coreclr runtime ◦ you need Windows to build mscorlib.dll ◦ or, some people offer precompiled ones ◦ or, use my patched build that partially works (PR1275) • corefx classlibs ◦ builds on Linux/Mac/Win (often fails outside Windows) ◦ still lacks PCL Facades - need to download binaries (dnu restore) • roslyn compiler ◦ Windows for full build, or partial x-plat build
  17. coreclr • .NET Core runtime (VM) ◦ Rotor (SSCLI) ->

    Silverlight (on Mac) -> this ◦ EE (execution engine) , GC, native interop, JIT, debugging ◦ mscorlib.dll (as it is tightly-coupled with the VM) ◦ architecture docs for hackers: Book of the Runtime (BotR), CoreCLR Coding Guide (in the github repo) but you would be just happy with existing .NET readings, they are so advanced...
  18. corefx • managed class libraries • subset of .NET FCL

    ◦ StoreApp/Silverlight/Phone, excluding UI, Plat-specific ◦ Not fully done, see corefx-progress repo
  19. roslyn • compiler infrastructure: compilers + "services" ◦ => my

    COSCUP2013 slides ◦ Used by VS2015, MonoDevelop6 and "omnisharp" • managed C#/VB compiler implementation ◦ easy to extend by .NET devs • debug symbols are getting portable (PPDB - very new)
  20. aspnet • The revamped ASP.NET. ◦ decomposed System.Web into many

    packages ◦ cross platform from scratch. ▪ app runtime: dnx (so, clr/mono/coreclr) ▪ server: IIS (Helios), libuv (Kestrel), self-host (WebListener) ◦ own packaging / dependency system: dnu ▪ Hosting, Mvc, SignalR, Identity, EntityFramework, ... ◦ dynamic compilation using Roslyn (as dnx does)
  21. related: referencesource • incomplete sources for .NET Framework (not .NET

    Core) • It is mostly for Mono project ◦ so that Mono can import it, for improved compatiblity. ◦ Mono is importing them, but cannot simply replace. ▪ remove Windows-isms, mobile restrictions etc.
  22. related: msbuild • MSBuild is needed to build .NET Core

    themselves. • Needed for cross platform build. ◦ Mono implementation (xbuild) is old and incomplete. • getting x-plat ready now.
  23. related: llilc • Another JIT implementation for coreclr ◦ JIT

    = native executable code generator ◦ coreclr JIT is pluggable (can be replaced) • JIT implementation trend: use LLVM native codegen ◦ to support as many platforms as LLVM supports. • llilc: coreclr JIT implementation using LLVM • under development yet
  24. related: Visual Studio Code • NOT open source (yet?) •

    Cross platform IDE for .NET Core • Very simple IDE. Just an enhanced code editor + debugger ◦ But what is an "IDE" ? >> my COSCUP2013 slides • built upon Electron (Atom Shell) • supports C# and TypeScript (TS has language service)
  25. the state of .NET Core • .NET Core: the future

    .NET platform (i.e. not now) ◦ .NET Framework etc. will be based on it. • code status ◦ coreclr - Windows dependencies in the build system ◦ corefx - more porting work needed ◦ no integrated build/installs. ◦ builds are not stable yet. Builds on CI servers are almost fake. • ASP.NET - on its own roadmap
  26. the state of Mono • is Mono still needed? ◦

    cross platform is still big TODO at .NET Core. ◦ There is mono ecosystem (Gtk# and apps) ◦ so as Xamarin platforms • Mono visions ◦ import more referencesource for .NET compatibility ◦ reuse good coreclr parts (e.g. GC)
  27. How can you benefit from .NET Core? • For now

    if you just write apps, use .NET Framework etc. ! • You can understand the underlying Fx you use better. • You can build and ship app with your own .NET Core build. ◦ ship with fixed version of .NET Core ◦ modify the Fx behavior to fit your app's need. • You can research how the modern dev. framework works.
  28. .NET Core: Possible use cases • Learn from what Mono

    has done in the past • Hosting CoreCLR ◦ Office.NET, CLI-UNO (LibreOffice) ◦ SQLCLR ◦ Unity3D etc. • Develop another .NET based framework? ◦ Browser plugin? (Silverlight/Moonlight => WebAssembly) ◦ IoT? (.NET Micro Framework) ◦ new mobile platforms? (Xamarin)
  29. developing (contributing to) .NET Core • .NET Core hosted at

    github. They accept PRs. ◦ Cup<T> • still not easy to try integration tests with private hacks...