Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
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/
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
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
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];
}
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
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
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
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
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
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”
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).