net core blimey - smart devs ug

Post on 17-Aug-2015

45 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

.NET CoreBlimey.

@citizenmatt

This is Matt Ellis

He works for Microsoft, and is a developer on the .NET Core team.

This is not me.

This is Matt Ellis

He works for JetBrains, and is an interested amateur in .NET Core.

This is me.

What is .NET Core?

New .NET stack - CLR + BCL

Open SourceCross platform

(eventually)Standalone -

per-application installs

Factored for modularity - “cloud optimised”

Everything ships as NuGet packages,

including the runtime

Not finished…

.NET Core != .NET Framework

NOT a new version of the .NET Framework

• .NET Framework is going nowhere

• .NET Core is 5.0.NET Framework is 4.6

• .NET Core is a fork of the .NET Framework Code merged back to TFS

• .NET Core is (currently) a strict subset of the .NET Framework

• Missing pieces in .NET CoreWindows: WinForms, WPF, COM, etc.Platform: AppDomains, Remoting, Reflection.Emit, etc.

• Different constraints:Ship cycles, compatibility, system wide install

Why?

Multiple .NET stacks. Incompatibilities

Portable Class Librariesnot scalable

Cross platform

Independent release cyclesRuntime, BCL, apps

Nano Server

Tidy up15 years of evolution

Why?

Why?

Multiple .NET stacks. Incompatibilities

Portable Class Librariesnot scalable

Cross platform

Independent release cyclesRuntime, BCL, apps

Nano Server

Tidy up15 years of evolution

History

Started with .NET Framework 2.0

How do I get it?

NuGet

How do I get it?

DNX - Dot Net Execution Environment

DNX maintained by asp.net team

Stable builds on nuget.orgUnstable on myget.org

.NET Core, .NET Fx and ASP.NET teams maintain own .NET Core builds…

dnvm install latest -r coreclr -u

Build from source!

How do I get it?

Architecture

Boxes and bits.

.NET Native

Alternative runtime

• AOT compilation

• Compiles all dependencies Tree shaking

• Reflection? Via xml!

• Windows Store apps only

• Closed source

• LLILC - LLVM based JIT/AOT (OSS)

CoreCLR The new runtime.

dotnet/coreclr

JIT compiler (RyuJIT), Garbage Collector, Platform Abstraction Layer - C++

mscorlib (tightly coupled to runtime) - C#

PAL - OS and platform differences. E.g. exception handling, threads, etc.P/Invoke to OS, FEATURE #ifdefs

Book of the Runtime!

Mirror back to TFS

CoreFX The new BCL.

dotnet/corefx

Factored for modularity - each solution/assembly is a package

Some platform specific implementations, e.g. System.Console, Process.Interop.Unix.cs, etc.

Might throw PlatformNotSupportedException(e.g. Console.get_ForegroundColor )

Build is based on project.json, packages as references

Mirrored to TFS + .NET Framework

High compatibility bar for changes, transparent API review process

Console.get_ForegroundColorPlatformNotSupportedException

AppModels

Or: How do you run a .exe on Unix?

How the application is hosted and run

Environmental services

What is an AppModel?

Bootstrap the CLR Execute the application

.NET Framework AppModels

.NET .exe

Originally a native stub that loaded the CLR (x86 only!)

Special cased by OS loader since Windows XP

Loads mscoree.dll, which initialises CLR and executes

app

IIS/asp.net

Pre-IIS 7 - ISAPI filter

IIS 7 directly integrates CLR

Pipes requests/responses to managed code

Lifetime management

Windows Phone / Windows Store

Magic!

“Application host” loads CLR

Integrates with environment events. E.g. suspend and

resume applications

Pre-compiled / .NET Native

corerun

DNX - .NET Execution Environment (asp.net)

Windows 10 UWP Applications

.NET Core AppModels

coreconsole /osxcorebundlerun

DNX

Dot NET Execution Environment

asp.net 5Targets .NET Core /.NET Framework /

Mono

In memory compilation via Roslyn

Changes project systemReference packages, not assemblies

More…

• Packages for runtime and BCL

• BCL factored into many packages

• NuGet at heart of project system (DNX)

• NuGet is the new Portable Class Library

• Sketchy documentation…

NuGet v3

Bleeding edge.

How does this affect us?

Let NuGet be NuGet

Don’t target a framework

Add NuGet dependencies for all BCL assemblies

Specify required versions of BCL assemblies

Let NuGet sort it out

Effectively, there is no longer a fixed framework

version to target

New Target Framework Monikers

Brand new

• dotnet - - .NET Core contracts. “Replaces” portable- . Use this! Supports .Net Framework 4.5 and later (inc. Xamarin)

• dnx451 , dnx46 - DNX targeting .NET Framework 4.5.1, 4.6

• dnxcore50 - DNX targeting .NET Core

• uap10.0 - .NET Core 5.0 on Windows. AKA (UWP apps. Follows netcore45 / win8 , netcore451 / win81)

dotnet

dnx451 dnx46

dnxcore50

netcore50netcore45 win8 netcore451 win81

uap10.0

portable-*

Resolution depends on project type

Project understands dotnet TFM: (UWP, .NET 4.6, ASP.NET 5)

“Modern PCL” with project.json: (What is a “Modern PCL”?)

More details on docs.nuget.org

dotnet

What About Compatibility?

All .NET Core packages are PCLs. Kinda.

PCL Refresher

1. A PCL is a class library that needs to run on multiple platforms and versions(e.g. .NET Framework, Windows Phone, Xamarin)

2. It defines a common subset of APIs that are available on ALL of the required versions of these platforms - a “Profile”

3. When targeting a Profile, the compiler references a set of Reference AssembliesThese describe the API with empty types, and forward types to correct assemblies

4. At runtime, the real assemblies on the target platform implement the APIs Can also forward types to other assemblies

Portable Class Libraries

• PCL hides platform specific implementation details behind a common API contract

• Profiles do not scale. The more versions and platforms, the more Profiles…

Why is this important?

Isn’t .NET Core a common, compatible, cross platform implementation?

• The BCL is the Base Class Library. It’s low level, and has to worry about underlying platform differences, e.g. file IO

• The BCL needs to be abstracted away from the platform, to allow for platform specific implementations. And refactoring!

Reference Assemblies

BCL packages include a Reference Assembly in \ref

• This is referenced at compile time and provides the contract for the API, just like PCL Reference Assemblies

• The runtime implementation(e.g. \lib\netcore50 ) handles platform/host specifics

\ref

\lib\dnxcore50

Why is this important?

This is how compatibility works

• Reference Assemblies allow consuming .NET Core packages from .NET Framework and other PCL platforms

• Reference Assembly provides the contract, forwards any types

• Implementation assemblies provide potential platform specific implementations

Compatibility (not a guarantee)

• .NET Framework 4.5 can consume .NET Core packages

• .NET Core 5.0 is a subset of .NET Framework 4.6Should be able to consume .NET Framework 4.6 packages

• .NET Core can consume PCL libs that are compatible with System.Runtime.dll (facade that forwards to e.g. mscorlib.dll)

• A new PCL Profile will include .NET Core (e.g. )(Not announced as part of NuGet v3 - dotnet is checked before portable-* ?)

portable-dotnet+…+…

Known Unknowns

• How are OS specific implementations going to be shipped? ( \runtimes ?)

• Do we need a Reference Assembly for each package?

• Why do we need platform/host TFMs (e.g. dnxcore50 ) when we can specify dependencies?

dnxcore50

\runtimes

http://docs.nuget.org/Create/uwp-create

What does this mean for Mono?

Lots. Or not much.

Mono == .NET FrameworkMono already cross platform

Mono’s focus is non-Windows

mobile (Xamarin)

.NET Core’s focus is server and

Windows UWP

Mono can include CoreCLR + CoreFX

code

Where does Roslyn fit in?

Orthogonal.

Runs on .NET Framework + Mono

Planned for.NET Core

CompilingCoreCLR + CoreFX

currently requires Windows

C# compilerwritten in C#

.NET Core

Cross platform

Open Source

NuGet everywhere

Bleeding edge

Icons: http://icons8.com/

The future of .NET

Links

CoreCLR - https://www.github.com/dotnet/coreclr

CoreFX - https://www.github.com/dotnet/corefx

DNX - https://github.com/aspnet/Home

NuGet - http://docs.nuget.org

@citizenmatt

top related