SlideShare uma empresa Scribd logo
1 de 67
.NET Core
daenet Lead Architect, Microsoft Regional Director, Azure MVP
@ddobric
Damir Dobric
https://about.me/damirdobric
AGENDA
 Intro
 Building, Linking Optimizing
 Performance improvements
 Benchmark .NET
 Ref Types, Span<T>
 Assembly forwarding
 Global Tools
 .NET Core IoT (Pi)
 What is coming in .NET 3?
.NET Core is
a general purpose development platform
with cross-platform support for
Windows, macOS and Linux,
various devices and
cloud
https://docs.microsoft.com/en-us/dotnet/core/
https://github.com/dotnet/core/blob/master/microsoft-support.md
Welcome .NET Core 2.1.x
 Plattform support
 Windows Client: 7, 8.1, 10 (1607+)
 Windows Server: 2008 R2 SP1+
 macOS: 10.12+
 RHEL: 6+
 Fedora: 26+
 Ubuntu: 14.04+
 Debian: 8+
 SLES: 12+
 openSUSE: 42.3+
 Alpine: 3.7+
https://github.com/dotnet/core/blob/master/release-notes/2.1/2.1-supported-os.md
 Chip support
 x64 on:
 Windows,
 macOS,
 Linux
 x86 on
 Windows
 ARM32 on Linux (Ubuntu 18.04+, Debian 9+)
 VS 15.7
Building, Linking, Optimizing
Framework Dependent (FDD) vs. Self-Contained (SC)
>dotnet publish -c release -r win-x64 -o out
>dotnet publish -c release
FDD
SC
TRUE is default
Self-Contained publish with small footprint
>dotnet new nuget
<ItemGroup>
<PackageReference Include="ILLink.Tasks" Version="0.1.4-preview-906439" />
</ItemGroup>
>dotnet publish -c release -r win-x64 -o out-with-linker
/p:LinkDuringPublish=true /p:ShowLinkerSizeComparison=true
Generates details
related to linking
process
Required to
activate IL Linker
Activates v3 feed
with IL-Linker
ShowLinkerSizeComparison
100%
means not used at all.
0%
No optimization.
Most likely your own
code
Typical case. This app
use Console.
Performance Improvements
Build Performance Improvements
Runtime JIT Performance Improvements
 Devirtualization => Micro-optimization
 JIT is able to statically determine the target of some virtual invocations
 Avoid virtual dispatch costs and enable potential inlining
https://www.infoq.com/news/2017/12/Devirtualization
Runtime Performance Improvements
 String improvements
 String.Equal
 String.IndexOfAny
 String.ToLower, String.ToUpper
 String.Concat
 Formatting and Parsing
 String.Format
 Type.Parse
 Networking
 Parsing of URIs and IPAdresses
 HttpClient, Socket and SslStream
 File System
Runtime Thread Performance Improvements
 Access to thread static [ThreadStatic]
 Improves scalable code with access to thread statics.
 Timer Global lock optimization
 Improves creation of many timer
 Create/Dispose cancelation tokens
 Async/Await overhead reduced
https://blogs.msdn.microsoft.com/dotnet/2018/04/18/performance-improvements-in-net-core-2-1/
v2.0: 20.36 ns
v2.1: 13.48 ns
https://blogs.msdn.microsoft.com/dotnet/2018/04/18/performance-improvements-in-net-core-2-1/
https://github.com/dotnet/BenchmarkDotNet
C# 7.2
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<LangVersion>7.2</LangVersion>
</PropertyGroup>
C# 7.x
“Ref” returns
 A reference return value allows a method to return a reference to a
variable
public ref T this[int index] { get { ... } }
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/ref-returns
ref var value = ref store.FindNumber(number);
public ref int FindNumber(int target)
{
for (int ctr = 0; ctr < numbers.Length; ctr++)
{
if (numbers[ctr] >= target)
return ref numbers[ctr];
}
return ref numbers[0];
}
DEMO
Read Only Ref ‘in’ in C# 7.2, 7.3
Returning references
Span<T>
 ref T field in C# and MSIL
 Span<T> uses a special internal type in the runtime that’s treated as a
just-in-time (JIT) intrinsic
https://msdn.microsoft.com/en-us/magazine/mt814808.aspx
DEMO
New era of memory management
Span<T>
Windows Compatibility Pack
 20000 APIs
 Windows only
 Cross-platform
https://github.com/dotnet/docs/blob/master/docs/core/porting/windows-compat-pack.md
<ItemGroup>
<PackageReference
Include="Microsoft.Windows.Compatibility"
Version="2.0.0" />
</ItemGroup>
.NET Global Tools
Run tool
Tool can do anything
https://github.com/natemcmaster/dotnet-tools
.NET Global Tools
 Creat32e tool
 Pack:
 Find tool on web or Nuget.Org
 Install the tool.
 Location:
 Command:
 Call the tool.
 Update the tool.
 Uninstall the tool.
<PackAsTool>true</PackAsTool>
dotnet tool install -g toolsample
%USERPROFILE%.dotnettools $HOME/.dotnet/tools
toolsample
dotnet pack -c release -o nupkg
dotnet tool update -g toolsample
dotnet tool uninstall -g toolsample
https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools
Roll Forward
 .NET Core 2.N forwarded to .NET Core 2.N+M
 Example: .NET Core 2.1 -> .NET Core 2.3
 Example: .NET Core 2.1 -> .NET Core 3.0 (NOT SUPPORTED!)
 Minor versions only
 Doesn't occur between preview versions and release versions.
.NET Core & IoT
.NET Core for IoT
 ARM 32 support
 GPIO (planning)
 .NET Core GPIO support is coming
https://github.com/ianhays/corefxlab/blob/gpio/src/System.Devices.Gpio/Planning.md
 You can start now with GPIO in .NET Core
https://jeremylindsayni.wordpress.com/2017/05/01/controlling-gpio-pins-using-a-net-core-2-
webapi-on-a-raspberry-pi-using-windows-10-or-ubuntu/
 .NET Core on Raspberry 2+
 Setup Ubuntu
-https://ubuntu-mate.org/blog/ubuntu-mate-xenial-final-release
https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md
.NET Core on Linux (ARM 32)
https://blogs.msdn.microsoft.com/benjaminperkins/2017/10/18/create-a-net-core-2-application-on-linux-with-visual-studio-code/
https://developers.de/2018/06/06/setup-net-core-2-1-on-arm
$ sudo apt-get -y update
$ sudo apt-get -y install libunwind8 gettext
$ wget https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.300/dotnet-sdk-linux-arm.tar.gz
$ wget https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/2.1.0/aspnetcore-runtime-2.1.0-linux-
arm.tar.gz $ sudo mkdir /opt/dotnet
$ sudo tar -xvf dotnet-sdk-2.1.300-linux-arm.tar.gz -C /opt/dotnet/
$ sudo tar -xvf aspnetcore-runtime-2.1.0-linux-arm.tar.gz -C /opt/dotnet/ $ sudo ln -s /opt/dotnet/dotnet /usr/local/bin
First look at .NET 3.0
Windows Forms and UWP in .NET Core
 Support for WinForms and WPF
 Apps can be self-contained and run in a single folder.
 XCOPY deployment
 No requirement to install anything
else (Self-Contained)
 C#, F#, VB
 Migration support from .NET 3.5
apps to .NET Core 3
 NO LINUX SUPPORT!
Recap
 V2.1 is RTM. Long Term Support
 Faster build
 Better Memory Management=>Performance Improvements
 Lot of micro-improvements (i.e.: devirtualization)
 IL Linker => Footprint optimization
 Span<TEverything>
 Global Tools are nuget packages. In .csproj <PackAsTool>true</PackAsTool>
 ARM 32 support. Runs on Raspberry PI 2+
 .NET 3.0:
 Self-contained assembly =>XCOPY
 WPF/WinForms
References
 Summary
 https://blogs.msdn.microsoft.com/dotnet/2018/05/30/announcing-net-core-2-1/
 Video .NET Core 2.1 and .NET Core 3
https://youtu.be/KAIJ3ezQb3c
 Setup .NET Core on ARM (PI)
 https://developers.de/2018/06/06/setup-net-core-2-1-on-arm
 IL Linker
 https://github.com/dotnet/core/blob/master/samples/linker-instructions.md
 GPIO Roadmap
 https://github.com/ianhays/corefxlab/blob/gpio/src/System.Devices.Gpio/Planning.md
 .NET Core on Linux with VS code
 https://blogs.msdn.microsoft.com/benjaminperkins/2017/10/18/create-a-net-core-2-
application-on-linux-with-visual-studio-code
Damir Dobric
https://about.me/damirdobric
Vielen Dank

Introduction to .NET Core
DEWX 2017
• Creating and deploying .NET core Applications
• .NET Standard
• Unit Testing .NET Core
• Migration
• Dependency Injection
• Logging
AGENDA
Creating and Running .NET Core applications
dotnet new console
dotnet restore
dotnet build
dotnet run
Deployment
Types of Deployment
 Framework Dependent
 Net Core Framework must be installed on the machine
 Small application footprint
 Framework Independent
 Net Core framework does not have to be installed
 Framework is installed (xcopy) with application binaries
 Bigger footprint
 Every application can use any kind of framework
Framework Dependent Application
 dotnet restore
 dotnet build
 dotnet publish -f netcoreapp2.0 -c Debug
Publish output
Framework Independent Application
dotnet publish -r win10-x64 --self-contained
<RuntimeIdentifiers>
win10-x64;osx.10.11-x64
</RuntimeIdentifiers>
Publish output
.NET Standard
What is .NET Standard?
The .NET Standard is an API spec that describes
the consistent set of .NET APIs that developers
can expect in each .NET implementation
https://github.com/dotnet/standard/blob/master/docs/versions.md
.NET Standard
 PCL is common lowest
denominator
 Standard is replacement for PCL
Which standard should I support?
1.0 2.0
NumberofAPIs
NumberofApplications
1.1 1.2 1.3 1.4 1.5 1.6
.NET Standard
NetStandard 2.0
API Browser
https://apisof.net
Cross Referencing
 netstandard 2.0 -> netstandard 1.1,..,1.6
 net461 -> netstandard 2.0
error CS0012: The type 'Object' is defined in an assembly that is not
referenced. You must add a reference to assembly 'netstandard,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
 Net452 -> netstandard 2.0
error : Project “NetCoreLib2.csproj' targets '.NETStandard,Version=v2.0’.
It cannot be referenced by a project that targets
'.NETFramework,Version=v4.5.2’.
 ss
Referencing .NET Desktop
Unit Testing
Unit testing with XUnit
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
Unit testing with MSTest
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.1.11" />
<PackageReference Include="MSTest.TestFramework" Version="1.1.11" />
</ItemGroup>
Test Execution
 dotnet test -h
 dotnet test --list-tests
 Execute specific tests
 dotnet test --filter "MessageOnly_LogsCorrectValues“
 dotnet test --filter Message -v d
 dotnet test --filter Message -v n
 dotnet test --filter Message -v d
 dotnet test --filter Message –filter ”Priority = 1”
Migration of .NET to .NET Core
API PORT ANALYZER
https://github.com/Microsoft/dotnet-apiport/
apiport analyze -f AddTokenGenDotNet.exe
Dependency Injection
• Inversion of Control IoC in 5 Min.
• Service Locator
• Dependency Injection
Arguments are injected in constructor
public class MySmsSender : ISmsProvider
{
private readonly SmsTradeSettings m_Settings;
private readonly ILogger m_Logger;
public SmsTradeSender(IOptions<SmsTradeSettings> options,
ILogger<SmsTradeSender> logger) :this(options.Value, logger)
{
}
public SmsTradeSender(SmsSettings settings, ILogger<MySmsSender> logger)
{
m_Settings = settings;
m_Logger = logger;
}
}
Required Packages
 Microsoft.Extensions.Configuration
 Microsoft.Extensions.Configuration.Binder
 Microsoft.Extensions.Configuration.Json
 Microsoft.Extensions.DependencyInjection
 Microsoft.Extensions.Options
Logging
Required Packages
 Microsoft.Extensions.Logging
 Microsoft.Extensions.Logging.Console
 Microsoft.Extensions.Logging.Debug
 Microsoft.Extensions.Logging.EventHub (*)
 …
How to build UI with .NET Core
 Graphic support overview
https://github.com/dotnet/corefx/issues/20325
 Open Source 2D Graphics Library
https://skia.org/
• Creating and deploying .NET core Applications
• .NET Standard
• Unit Testing .NET Core
• Migration
• Dependency Injection
• Logging
Recap
References
 .NET Core Guide:
 https://docs.microsoft.com/en-us/dotnet/core/
 Specification netstandard 2.0
 https://github.com/dotnet/standard/blob/master/docs/netstandard-20/README.md
 Building a C# Hello World Application with .NET Core in Visual Studio 2017 - Learn to to build,
debug, and publish a simple .NET Core console application using Visual Studio 2017.
 Building a class library with C# and .NET Core in Visual Studio 2017 - Learn how to build a class
library written in C# using Visual Studio 2017.
 Get started with Visual Studio Code using C# and .NET Core on Windows - This Channel9 video
shows you how to install and use Visual Studio Code, Microsoft's lightweight cross-platform code
editor, to create your first console application in .NET Core.
 Get Started with .NET Core and Visual Studio 2017 - This Channel9 video shows you how to install
and use Visual Studio 2017, Microsoft's fully-featured IDE, to create your first cross-platform console
application in .NET Core.
 Getting started with .NET Core using the command-line - Use any code editor with the .NET Core
cross-platform command-line interface (CLI).
Damir Dobric
https://about.me/damirdobric
Vielen Dank


Mais conteúdo relacionado

Mais procurados

Daneyon Hansen - Intro to OpenStack - Feb13 OpenStack Denver Meetup
Daneyon Hansen - Intro to OpenStack - Feb13 OpenStack Denver MeetupDaneyon Hansen - Intro to OpenStack - Feb13 OpenStack Denver Meetup
Daneyon Hansen - Intro to OpenStack - Feb13 OpenStack Denver Meetup
Shannon McFarland
 

Mais procurados (20)

How To Build Android for ARM Chip boards
How To Build Android for ARM Chip boardsHow To Build Android for ARM Chip boards
How To Build Android for ARM Chip boards
 
Run Qt on Linux embedded systems using Yocto
Run Qt on Linux embedded systems using YoctoRun Qt on Linux embedded systems using Yocto
Run Qt on Linux embedded systems using Yocto
 
Learning notes on Open Source License
Learning notes on Open Source License Learning notes on Open Source License
Learning notes on Open Source License
 
Software update for embedded systems
Software update for embedded systemsSoftware update for embedded systems
Software update for embedded systems
 
Userspace drivers-2016
Userspace drivers-2016Userspace drivers-2016
Userspace drivers-2016
 
Using open source software to build an industrial grade embedded linux platfo...
Using open source software to build an industrial grade embedded linux platfo...Using open source software to build an industrial grade embedded linux platfo...
Using open source software to build an industrial grade embedded linux platfo...
 
Daneyon Hansen - Intro to OpenStack - Feb13 OpenStack Denver Meetup
Daneyon Hansen - Intro to OpenStack - Feb13 OpenStack Denver MeetupDaneyon Hansen - Intro to OpenStack - Feb13 OpenStack Denver Meetup
Daneyon Hansen - Intro to OpenStack - Feb13 OpenStack Denver Meetup
 
UplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processor
UplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processorUplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processor
UplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processor
 
Embedded Recipes 2019 - Testing firmware the devops way
Embedded Recipes 2019 - Testing firmware the devops wayEmbedded Recipes 2019 - Testing firmware the devops way
Embedded Recipes 2019 - Testing firmware the devops way
 
Memory Management in TIZEN - Samsung SW Platform Team
Memory Management in TIZEN - Samsung SW Platform TeamMemory Management in TIZEN - Samsung SW Platform Team
Memory Management in TIZEN - Samsung SW Platform Team
 
Coscup2018 itri android-in-cloud
Coscup2018 itri android-in-cloudCoscup2018 itri android-in-cloud
Coscup2018 itri android-in-cloud
 
Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)
Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)
Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)
 
Open source Android 10 on Orange Pi: Meth or Reality?
Open source Android 10 on Orange Pi: Meth or Reality?Open source Android 10 on Orange Pi: Meth or Reality?
Open source Android 10 on Orange Pi: Meth or Reality?
 
windows CE
windows CEwindows CE
windows CE
 
Embedded Recipes 2019 - RT is about to make it to mainline. Now what?
Embedded Recipes 2019 - RT is about to make it to mainline. Now what?Embedded Recipes 2019 - RT is about to make it to mainline. Now what?
Embedded Recipes 2019 - RT is about to make it to mainline. Now what?
 
Introduction to Civil Infrastructure Platform
Introduction to Civil Infrastructure PlatformIntroduction to Civil Infrastructure Platform
Introduction to Civil Infrastructure Platform
 
Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)
Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)
Software, Over the Air (SOTA) for Automotive Grade Linux (AGL)
 
Upgrade Ubuntu 18.04 Security with Secureboot
Upgrade Ubuntu 18.04 Security with SecurebootUpgrade Ubuntu 18.04 Security with Secureboot
Upgrade Ubuntu 18.04 Security with Secureboot
 
P2P Container Image Distribution on IPFS With containerd and nerdctl
P2P Container Image Distribution on IPFS With containerd and nerdctlP2P Container Image Distribution on IPFS With containerd and nerdctl
P2P Container Image Distribution on IPFS With containerd and nerdctl
 
Debugging embedded devices using GDB
Debugging embedded devices using GDBDebugging embedded devices using GDB
Debugging embedded devices using GDB
 

Semelhante a What should you know about Net Core?

NET app modernization and Microsoft Azure.pptx
NET app modernization and Microsoft Azure.pptxNET app modernization and Microsoft Azure.pptx
NET app modernization and Microsoft Azure.pptx
NishitPatel409228
 
Red hat enterprise_linux-5.5-release_notes-en-us
Red hat enterprise_linux-5.5-release_notes-en-usRed hat enterprise_linux-5.5-release_notes-en-us
Red hat enterprise_linux-5.5-release_notes-en-us
Duong Hieu
 

Semelhante a What should you know about Net Core? (20)

.Net: Introduction, trends and future
.Net: Introduction, trends and future.Net: Introduction, trends and future
.Net: Introduction, trends and future
 
NET app modernization and Microsoft Azure.pptx
NET app modernization and Microsoft Azure.pptxNET app modernization and Microsoft Azure.pptx
NET app modernization and Microsoft Azure.pptx
 
Microsoft Connect 2018 .NET User Group Paderborn
Microsoft Connect 2018 .NET User Group PaderbornMicrosoft Connect 2018 .NET User Group Paderborn
Microsoft Connect 2018 .NET User Group Paderborn
 
Install .Net Core, SQL Server V-Next on Linux and deploy .Net core applicatio...
Install .Net Core, SQL Server V-Next on Linux and deploy .Net core applicatio...Install .Net Core, SQL Server V-Next on Linux and deploy .Net core applicatio...
Install .Net Core, SQL Server V-Next on Linux and deploy .Net core applicatio...
 
Academy PRO: .NET Core intro
Academy PRO: .NET Core introAcademy PRO: .NET Core intro
Academy PRO: .NET Core intro
 
ASP.NET Core: The best of the new bits
ASP.NET Core: The best of the new bitsASP.NET Core: The best of the new bits
ASP.NET Core: The best of the new bits
 
Net core
Net coreNet core
Net core
 
.NET framework vs .net core 3.1 commons &amp; differences
 .NET framework vs .net core 3.1  commons &amp; differences .NET framework vs .net core 3.1  commons &amp; differences
.NET framework vs .net core 3.1 commons &amp; differences
 
ASP.NET Core deployment options
ASP.NET Core deployment optionsASP.NET Core deployment options
ASP.NET Core deployment options
 
Flutter Vikings 2022 - Full Stack Dart
Flutter Vikings 2022  - Full Stack DartFlutter Vikings 2022  - Full Stack Dart
Flutter Vikings 2022 - Full Stack Dart
 
.NET Applications & Cloud Meetup at 7 Peaks
.NET Applications & Cloud Meetup at 7 Peaks.NET Applications & Cloud Meetup at 7 Peaks
.NET Applications & Cloud Meetup at 7 Peaks
 
Christchurch Embedded .NET User Group - Introduction to Microsoft Embedded pl...
Christchurch Embedded .NET User Group - Introduction to Microsoft Embedded pl...Christchurch Embedded .NET User Group - Introduction to Microsoft Embedded pl...
Christchurch Embedded .NET User Group - Introduction to Microsoft Embedded pl...
 
Revolutionizing WSO2 PaaS with Kubernetes & App Factory
Revolutionizing WSO2 PaaS with Kubernetes & App FactoryRevolutionizing WSO2 PaaS with Kubernetes & App Factory
Revolutionizing WSO2 PaaS with Kubernetes & App Factory
 
Nano Server - the future of Windows Server - Thomas Maurer
Nano Server - the future of Windows Server - Thomas MaurerNano Server - the future of Windows Server - Thomas Maurer
Nano Server - the future of Windows Server - Thomas Maurer
 
Enabling NFV features in kubernetes
Enabling NFV features in kubernetesEnabling NFV features in kubernetes
Enabling NFV features in kubernetes
 
Red hat enterprise_linux-5.5-release_notes-en-us
Red hat enterprise_linux-5.5-release_notes-en-usRed hat enterprise_linux-5.5-release_notes-en-us
Red hat enterprise_linux-5.5-release_notes-en-us
 
Deep Learning Edge
Deep Learning Edge Deep Learning Edge
Deep Learning Edge
 
Pottnet Meetup Essen - ASP.Net Core
Pottnet Meetup Essen - ASP.Net CorePottnet Meetup Essen - ASP.Net Core
Pottnet Meetup Essen - ASP.Net Core
 
Pottnet MeetUp Essen - ASP.Net Core
Pottnet MeetUp Essen - ASP.Net CorePottnet MeetUp Essen - ASP.Net Core
Pottnet MeetUp Essen - ASP.Net Core
 
MSMDC_CLI363
MSMDC_CLI363MSMDC_CLI363
MSMDC_CLI363
 

Mais de Damir Dobric

Mais de Damir Dobric (20)

Tools fuer ki and ml
Tools fuer ki and mlTools fuer ki and ml
Tools fuer ki and ml
 
Ai zum anfassen
Ai zum anfassenAi zum anfassen
Ai zum anfassen
 
Introduction to Cosmos db
Introduction to Cosmos dbIntroduction to Cosmos db
Introduction to Cosmos db
 
Ai zum anfassen
Ai zum anfassenAi zum anfassen
Ai zum anfassen
 
AI for developers
AI for developersAI for developers
AI for developers
 
Microservices and modern backends - Azure Meetup Frankfurt
Microservices and modern backends  - Azure Meetup FrankfurtMicroservices and modern backends  - Azure Meetup Frankfurt
Microservices and modern backends - Azure Meetup Frankfurt
 
Building Applications for HoloLens
Building Applications for HoloLensBuilding Applications for HoloLens
Building Applications for HoloLens
 
Key Steps in Developing .NET Core Applications
Key Steps in Developing .NET Core ApplicationsKey Steps in Developing .NET Core Applications
Key Steps in Developing .NET Core Applications
 
IoT Ultimate Session
IoT Ultimate SessionIoT Ultimate Session
IoT Ultimate Session
 
Moderne backends mit dem aktor programmiermodell
Moderne backends mit dem aktor programmiermodellModerne backends mit dem aktor programmiermodell
Moderne backends mit dem aktor programmiermodell
 
IoT with UWP, .NETCore and Azure
IoT with UWP, .NETCore and AzureIoT with UWP, .NETCore and Azure
IoT with UWP, .NETCore and Azure
 
Microsoft Io TechCamp Frankfurt am Main 2015
Microsoft Io TechCamp Frankfurt am Main 2015Microsoft Io TechCamp Frankfurt am Main 2015
Microsoft Io TechCamp Frankfurt am Main 2015
 
Microservices and Azure App Services
Microservices and Azure App ServicesMicroservices and Azure App Services
Microservices and Azure App Services
 
Azure Machine Learning Intro
Azure Machine Learning IntroAzure Machine Learning Intro
Azure Machine Learning Intro
 
Internet of Things, Cloud & Co.
Internet of Things, Cloud & Co.Internet of Things, Cloud & Co.
Internet of Things, Cloud & Co.
 
Internet of Things & Co.
Internet of Things & Co.Internet of Things & Co.
Internet of Things & Co.
 
IoT, connecting apps, devices and services
IoT, connecting apps, devices and servicesIoT, connecting apps, devices and services
IoT, connecting apps, devices and services
 
Connecting Apps, Devices and Services
Connecting Apps, Devices and ServicesConnecting Apps, Devices and Services
Connecting Apps, Devices and Services
 
Distributed systems witth Service Bus and Workflow Manager
Distributed systems witth Service Bus and Workflow ManagerDistributed systems witth Service Bus and Workflow Manager
Distributed systems witth Service Bus and Workflow Manager
 
WinDays 2013 KeyNote Slides
WinDays 2013 KeyNote SlidesWinDays 2013 KeyNote Slides
WinDays 2013 KeyNote Slides
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

What should you know about Net Core?

  • 1. .NET Core daenet Lead Architect, Microsoft Regional Director, Azure MVP @ddobric Damir Dobric https://about.me/damirdobric
  • 2. AGENDA  Intro  Building, Linking Optimizing  Performance improvements  Benchmark .NET  Ref Types, Span<T>  Assembly forwarding  Global Tools  .NET Core IoT (Pi)  What is coming in .NET 3?
  • 3. .NET Core is a general purpose development platform with cross-platform support for Windows, macOS and Linux, various devices and cloud https://docs.microsoft.com/en-us/dotnet/core/
  • 5. Welcome .NET Core 2.1.x  Plattform support  Windows Client: 7, 8.1, 10 (1607+)  Windows Server: 2008 R2 SP1+  macOS: 10.12+  RHEL: 6+  Fedora: 26+  Ubuntu: 14.04+  Debian: 8+  SLES: 12+  openSUSE: 42.3+  Alpine: 3.7+ https://github.com/dotnet/core/blob/master/release-notes/2.1/2.1-supported-os.md  Chip support  x64 on:  Windows,  macOS,  Linux  x86 on  Windows  ARM32 on Linux (Ubuntu 18.04+, Debian 9+)  VS 15.7
  • 7. Framework Dependent (FDD) vs. Self-Contained (SC) >dotnet publish -c release -r win-x64 -o out >dotnet publish -c release FDD SC
  • 8. TRUE is default Self-Contained publish with small footprint >dotnet new nuget <ItemGroup> <PackageReference Include="ILLink.Tasks" Version="0.1.4-preview-906439" /> </ItemGroup> >dotnet publish -c release -r win-x64 -o out-with-linker /p:LinkDuringPublish=true /p:ShowLinkerSizeComparison=true Generates details related to linking process Required to activate IL Linker Activates v3 feed with IL-Linker
  • 9. ShowLinkerSizeComparison 100% means not used at all. 0% No optimization. Most likely your own code Typical case. This app use Console.
  • 12. Runtime JIT Performance Improvements  Devirtualization => Micro-optimization  JIT is able to statically determine the target of some virtual invocations  Avoid virtual dispatch costs and enable potential inlining https://www.infoq.com/news/2017/12/Devirtualization
  • 13. Runtime Performance Improvements  String improvements  String.Equal  String.IndexOfAny  String.ToLower, String.ToUpper  String.Concat  Formatting and Parsing  String.Format  Type.Parse  Networking  Parsing of URIs and IPAdresses  HttpClient, Socket and SslStream  File System
  • 14. Runtime Thread Performance Improvements  Access to thread static [ThreadStatic]  Improves scalable code with access to thread statics.  Timer Global lock optimization  Improves creation of many timer  Create/Dispose cancelation tokens  Async/Await overhead reduced https://blogs.msdn.microsoft.com/dotnet/2018/04/18/performance-improvements-in-net-core-2-1/ v2.0: 20.36 ns v2.1: 13.48 ns
  • 16. C# 7.2 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <LangVersion>7.2</LangVersion> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <LangVersion>7.2</LangVersion> </PropertyGroup>
  • 18. “Ref” returns  A reference return value allows a method to return a reference to a variable public ref T this[int index] { get { ... } } https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/ref-returns ref var value = ref store.FindNumber(number); public ref int FindNumber(int target) { for (int ctr = 0; ctr < numbers.Length; ctr++) { if (numbers[ctr] >= target) return ref numbers[ctr]; } return ref numbers[0]; }
  • 19. DEMO Read Only Ref ‘in’ in C# 7.2, 7.3 Returning references
  • 20. Span<T>  ref T field in C# and MSIL  Span<T> uses a special internal type in the runtime that’s treated as a just-in-time (JIT) intrinsic https://msdn.microsoft.com/en-us/magazine/mt814808.aspx
  • 21. DEMO New era of memory management Span<T>
  • 22. Windows Compatibility Pack  20000 APIs  Windows only  Cross-platform https://github.com/dotnet/docs/blob/master/docs/core/porting/windows-compat-pack.md <ItemGroup> <PackageReference Include="Microsoft.Windows.Compatibility" Version="2.0.0" /> </ItemGroup>
  • 23. .NET Global Tools Run tool Tool can do anything https://github.com/natemcmaster/dotnet-tools
  • 24. .NET Global Tools  Creat32e tool  Pack:  Find tool on web or Nuget.Org  Install the tool.  Location:  Command:  Call the tool.  Update the tool.  Uninstall the tool. <PackAsTool>true</PackAsTool> dotnet tool install -g toolsample %USERPROFILE%.dotnettools $HOME/.dotnet/tools toolsample dotnet pack -c release -o nupkg dotnet tool update -g toolsample dotnet tool uninstall -g toolsample https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools
  • 25. Roll Forward  .NET Core 2.N forwarded to .NET Core 2.N+M  Example: .NET Core 2.1 -> .NET Core 2.3  Example: .NET Core 2.1 -> .NET Core 3.0 (NOT SUPPORTED!)  Minor versions only  Doesn't occur between preview versions and release versions.
  • 26. .NET Core & IoT
  • 27. .NET Core for IoT  ARM 32 support  GPIO (planning)  .NET Core GPIO support is coming https://github.com/ianhays/corefxlab/blob/gpio/src/System.Devices.Gpio/Planning.md  You can start now with GPIO in .NET Core https://jeremylindsayni.wordpress.com/2017/05/01/controlling-gpio-pins-using-a-net-core-2- webapi-on-a-raspberry-pi-using-windows-10-or-ubuntu/  .NET Core on Raspberry 2+  Setup Ubuntu -https://ubuntu-mate.org/blog/ubuntu-mate-xenial-final-release https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md
  • 28. .NET Core on Linux (ARM 32) https://blogs.msdn.microsoft.com/benjaminperkins/2017/10/18/create-a-net-core-2-application-on-linux-with-visual-studio-code/ https://developers.de/2018/06/06/setup-net-core-2-1-on-arm $ sudo apt-get -y update $ sudo apt-get -y install libunwind8 gettext $ wget https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.300/dotnet-sdk-linux-arm.tar.gz $ wget https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/2.1.0/aspnetcore-runtime-2.1.0-linux- arm.tar.gz $ sudo mkdir /opt/dotnet $ sudo tar -xvf dotnet-sdk-2.1.300-linux-arm.tar.gz -C /opt/dotnet/ $ sudo tar -xvf aspnetcore-runtime-2.1.0-linux-arm.tar.gz -C /opt/dotnet/ $ sudo ln -s /opt/dotnet/dotnet /usr/local/bin
  • 29. First look at .NET 3.0
  • 30. Windows Forms and UWP in .NET Core  Support for WinForms and WPF  Apps can be self-contained and run in a single folder.  XCOPY deployment  No requirement to install anything else (Self-Contained)  C#, F#, VB  Migration support from .NET 3.5 apps to .NET Core 3  NO LINUX SUPPORT!
  • 31. Recap  V2.1 is RTM. Long Term Support  Faster build  Better Memory Management=>Performance Improvements  Lot of micro-improvements (i.e.: devirtualization)  IL Linker => Footprint optimization  Span<TEverything>  Global Tools are nuget packages. In .csproj <PackAsTool>true</PackAsTool>  ARM 32 support. Runs on Raspberry PI 2+  .NET 3.0:  Self-contained assembly =>XCOPY  WPF/WinForms
  • 32. References  Summary  https://blogs.msdn.microsoft.com/dotnet/2018/05/30/announcing-net-core-2-1/  Video .NET Core 2.1 and .NET Core 3 https://youtu.be/KAIJ3ezQb3c  Setup .NET Core on ARM (PI)  https://developers.de/2018/06/06/setup-net-core-2-1-on-arm  IL Linker  https://github.com/dotnet/core/blob/master/samples/linker-instructions.md  GPIO Roadmap  https://github.com/ianhays/corefxlab/blob/gpio/src/System.Devices.Gpio/Planning.md  .NET Core on Linux with VS code  https://blogs.msdn.microsoft.com/benjaminperkins/2017/10/18/create-a-net-core-2- application-on-linux-with-visual-studio-code
  • 34. Introduction to .NET Core DEWX 2017
  • 35. • Creating and deploying .NET core Applications • .NET Standard • Unit Testing .NET Core • Migration • Dependency Injection • Logging AGENDA
  • 36. Creating and Running .NET Core applications dotnet new console dotnet restore dotnet build dotnet run
  • 38. Types of Deployment  Framework Dependent  Net Core Framework must be installed on the machine  Small application footprint  Framework Independent  Net Core framework does not have to be installed  Framework is installed (xcopy) with application binaries  Bigger footprint  Every application can use any kind of framework
  • 39. Framework Dependent Application  dotnet restore  dotnet build  dotnet publish -f netcoreapp2.0 -c Debug
  • 41. Framework Independent Application dotnet publish -r win10-x64 --self-contained <RuntimeIdentifiers> win10-x64;osx.10.11-x64 </RuntimeIdentifiers>
  • 44. What is .NET Standard? The .NET Standard is an API spec that describes the consistent set of .NET APIs that developers can expect in each .NET implementation https://github.com/dotnet/standard/blob/master/docs/versions.md
  • 45. .NET Standard  PCL is common lowest denominator  Standard is replacement for PCL
  • 46. Which standard should I support? 1.0 2.0 NumberofAPIs NumberofApplications 1.1 1.2 1.3 1.4 1.5 1.6
  • 47.
  • 51. Cross Referencing  netstandard 2.0 -> netstandard 1.1,..,1.6  net461 -> netstandard 2.0 error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.  Net452 -> netstandard 2.0 error : Project “NetCoreLib2.csproj' targets '.NETStandard,Version=v2.0’. It cannot be referenced by a project that targets '.NETFramework,Version=v4.5.2’.  ss
  • 54. Unit testing with XUnit <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> <PackageReference Include="xunit" Version="2.2.0" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> </ItemGroup>
  • 55. Unit testing with MSTest <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> <PackageReference Include="MSTest.TestAdapter" Version="1.1.11" /> <PackageReference Include="MSTest.TestFramework" Version="1.1.11" /> </ItemGroup>
  • 56. Test Execution  dotnet test -h  dotnet test --list-tests  Execute specific tests  dotnet test --filter "MessageOnly_LogsCorrectValues“  dotnet test --filter Message -v d  dotnet test --filter Message -v n  dotnet test --filter Message -v d  dotnet test --filter Message –filter ”Priority = 1”
  • 57. Migration of .NET to .NET Core
  • 59. Dependency Injection • Inversion of Control IoC in 5 Min. • Service Locator • Dependency Injection
  • 60. Arguments are injected in constructor public class MySmsSender : ISmsProvider { private readonly SmsTradeSettings m_Settings; private readonly ILogger m_Logger; public SmsTradeSender(IOptions<SmsTradeSettings> options, ILogger<SmsTradeSender> logger) :this(options.Value, logger) { } public SmsTradeSender(SmsSettings settings, ILogger<MySmsSender> logger) { m_Settings = settings; m_Logger = logger; } }
  • 61. Required Packages  Microsoft.Extensions.Configuration  Microsoft.Extensions.Configuration.Binder  Microsoft.Extensions.Configuration.Json  Microsoft.Extensions.DependencyInjection  Microsoft.Extensions.Options
  • 63. Required Packages  Microsoft.Extensions.Logging  Microsoft.Extensions.Logging.Console  Microsoft.Extensions.Logging.Debug  Microsoft.Extensions.Logging.EventHub (*)  …
  • 64. How to build UI with .NET Core  Graphic support overview https://github.com/dotnet/corefx/issues/20325  Open Source 2D Graphics Library https://skia.org/
  • 65. • Creating and deploying .NET core Applications • .NET Standard • Unit Testing .NET Core • Migration • Dependency Injection • Logging Recap
  • 66. References  .NET Core Guide:  https://docs.microsoft.com/en-us/dotnet/core/  Specification netstandard 2.0  https://github.com/dotnet/standard/blob/master/docs/netstandard-20/README.md  Building a C# Hello World Application with .NET Core in Visual Studio 2017 - Learn to to build, debug, and publish a simple .NET Core console application using Visual Studio 2017.  Building a class library with C# and .NET Core in Visual Studio 2017 - Learn how to build a class library written in C# using Visual Studio 2017.  Get started with Visual Studio Code using C# and .NET Core on Windows - This Channel9 video shows you how to install and use Visual Studio Code, Microsoft's lightweight cross-platform code editor, to create your first console application in .NET Core.  Get Started with .NET Core and Visual Studio 2017 - This Channel9 video shows you how to install and use Visual Studio 2017, Microsoft's fully-featured IDE, to create your first cross-platform console application in .NET Core.  Getting started with .NET Core using the command-line - Use any code editor with the .NET Core cross-platform command-line interface (CLI).

Notas do Editor

  1. dd