21
.NET Core How to migrate and write new code for .NET Core

Net Core

Embed Size (px)

Citation preview

Page 1: Net Core

.NET CoreHow to migrate and write new code for .NET Core

Page 2: Net Core

Bertrand Le Roy

▪ Senior Program Manager on .NET Core

▪ One of the founders of Orchard

▪ http://weblogs.asp.net/bleroy

▪ https://blogs.msdn.microsoft.com/dotnet/tag/week-in-net/

▪ https://www.youtube.com/channel/UCvtT19MZW8dq5Wwfu6B0oxw

Page 3: Net Core

Objectives

▪ What’s .NET Core and when to use it (or not)

▪ How to create a new library, ASP.NET, or console application

▪ How to port existing code

Page 4: Net Core

Innovation

Any platformOpenness

.NET CoreASP.NET 5

Page 5: Net Core

.NET Core ≠ .NET Framework

Page 6: Net Core

.NET Framework 4.6

▪ .NET implementation for any scenario on Windows with comprehensive library support

Page 7: Net Core

.NET Core

▪ Modular and smaller implementation of .NET

▪ Cross-platform▪ App-level isolation▪ Built in the open▪ Optimized for specific workloads▪ Built for the next ten years of software development

Page 8: Net Core

WPF Windows Forms

Universal Windows Apps

ASP.NET (4.X) ASP.NET Core

Next gen JIT (RyuJIT)SIMD

Runtime Components Compilers

Languages innovation.NET Compiler Platform

.NET Core 5 Libraries

.NET Framework 4.6 Libraries

NuGet packagesCommon

.NET Framework 4.6 .NET Core

What’s common, and what’s not?

Page 9: Net Core

What’s not supported?

▪ WPF

▪ Winforms

▪ WebForms

▪ Binary serialization…

▪ Anything Windows-specific: registry, ACLs, perf counters, etc.

Page 10: Net Core

Significant change: Reflection

foo.GetType() → foo.GetType().GetTypeInfo()

If you can’t find it on Type, try TypeInfo

Extension method from System.Reflection

Page 11: Net Core

API Portability resources

▪ Portability analyzer VS extension▪ https://github.com/Microsoft/dotnet-apiport/releases▪ http://dotnetstatus.azurewebsites.net/ ▪ https://packagesearch.azurewebsites.net/ ▪ http://forums.dotnetfoundation.org/ ▪ https://gitter.im/dotnet/corefx ▪ https://dotnet.github.io/porting *

* soon

Page 12: Net Core

Managing expectations

▪ This is very much a new platform with a known flavor

▪ There is a cost to migration

▪ There are things to learn

▪ Not all projects can or should migrate

Page 13: Net Core

Should I migrate my project?

Cannot:

▪ WPF, WinForms, unless UWP

▪ ASP.NET WebForms

Should (absolutely):

▪ General purpose libraries

Should (maybe):

▪ ASP.NET MVC

▪ Micro-services

▪ Console apps

▪ Rewrite

▪ Talent expertise on Linux

Page 14: Net Core

DEMOPorting FluentPath

Page 15: Net Core

Dependencies

▪ Most fundamental libraries first: test frameworks, tooling, data access, JSON, logging, IoC, etc.

▪ Go to the source, ask the author

▪ Offer to help, or fork

▪ Switch to another Core-compatible library

▪ DIY

Page 16: Net Core

Testing

▪ xUnit was first, now NUnit, MsTest

▪ Secondary test libraries (mocking, functional testing, etc.) in progress

Page 17: Net Core

Debugging

▪ On Windows: Visual Studio

▪ Everywhere: VS Code

Page 18: Net Core

Tooling

Your choice of tool, on your choice platform

▪ Visual Studio on Windows

▪ Visual Studio Code on Mac, Linux, or Windows

▪ vi or emacs with OmniSharp

▪ etc.

Page 19: Net Core

.NET CLI replaces DNX, DNVM, DNU

▪ dotnet new

▪ dotnet restore

▪ dotnet run

▪ dotnet build

▪ dotnet build –native

▪ dotnet dosomethingcool

Scaffolds a minimal app

Restores packages for the project

Compiles and runs the app

Compiles to IL

Compiles to a single executable

You can build your own commands

Page 20: Net Core

DEMOCreating a new application

Page 21: Net Core

Q&A