What's new in .NET
@rorypreddy
• Years of backwards compatibility for .NET is limiting
the teams with future development.
• .NET Framework is slowing down
• They will continue to update
• No changes to support policy
• Recommend new development on .NET Core
The Future of .NET Framework
Don’t Panic!
• You don’t have
to move!
New
development
• .NET Core is a
good choice
Existing code
• Costs and
benefits to
migrating
TheBottom Line
CORE 3.0
• Side-by-side and App-local Deployment
• Easily convert existing Desktop
applications to .Net Core 3
• Improvement to Project Files
• Continue to support Controls, NuGet
Packages, and Existing Assembly
References
Modernize Desktop Apps with .NET Core 3
Highly-compatible,
targeted improvements,
like last few releases
UWP
Windows-only
WEB
ASP.NET
Core
EF 6
EF Core
AI/ML
ML.NET
WPF
.NET Core 3.NET Framework 4.8
Existing
App
Highly
compatible
updates
Install .NET
Core updates
per your
needs
Windows-only Cross-platform
DATA
Windows
Forms
.NET STANDARD
Update .NET Framework Apps
Strategy: Divide and Conquor
What Goes Where
• Desktop Apps -> .NETCore 3
• Business Logic -> .NET Standard
• BackEndAPls -> .NETCore 3
• Front EndWeb Apps -> Well, this istougher...
Migrating a Typical .NET App Partially to the Cloud
On-Premises
WPF App
Windows .NET Framework
Web API Back End
Windows .NET Framework
SQL
Database
1
On-Premises
WPF App
Windows .NET Framework
Web API Back End
Windows .NET Core
SQL
Database
2
Cloud
On-Premises
WPF App
Windows .NET Framework
Web API Back End
Windows .NET Core
SQL
Database
3
Handling Shared Code When Targeting Multiple .NET Implementations
WPF App
.NET Framework
Web API Back End
.NET Framework
1
Business Logic
.NET Framework
WPF App
.NET Framework
Web API Back End
.NET Core
2
Business Logic
.NET Standard
Desktop
What to expect in porting desktop apps to
Core
• Update project files to target .NET Core 3
and recompile.
• Dependencies will not need to retarget and
recompile. There will be additional benefits if you
update dependencies.
Business Logic &
.NET Standard
What is .NET Standard?
.NET Standard is a specification
A set of APIs that all .NET platforms must
implement
$ dotnet new classlib -o My.Class.Library
.NET Standard is represented by
The NuGet package NetStandard.Library which contains
The reference assembly netstandard.dll
At build time
.NET Standard bridges references to existing .NET Framework and PCL
assemblies via type forwarding
At runtime
Each platform provides an implementation for netstandard.dll that type
forwards to its implementation
• .NET Core is an implementation of the .NET Standard
• .NET Standard updates are coordinated across all .NET implementers
• .NET Core can be updated independently
How does .NET Standard work?
Using platform-specific APIs
from .NET Standard
Windows Compatibility Pack
• Microsoft.Windows.Compatibility (NuGet package)
• Can be referenced from .NETCore as well as from .NETStandard
• Has ~21 k Api’s (Windows-only as well as cross-platform)
• Contents
ACLs
Code Pages
Code Dom
Configuration
Crypto
DirectoryServices
Drawing
EventLog
MEF v1
Odbc
Perf Counters
Permissions
Ports
Registry
Runtime Caching
WCF
Windows Services
Detecting usage of unsupported APIs
• Use API Analyzer!
• https://aka.ms/apianalyzer
• Warns about potential compatibility issues and calls to deprecated APIs.
Analyzer report
Analyzer report
C# 8.0
8.0 High probability
• New types
• Asynchronous Streams & Iterators &
dispose
• Default interface implementations
• Extension everything
• Records
• Discriminated unions
• Params Span
Types
• Part of .NET Standard 2.1 and C# 8
• The new Index type
• The Range type
• Nullable reference types
• .Net Core 3.0, Xamarin, Unity, and Mono will implement the
2.1 version
• .Net Framework 4.8 will not!
• Types required to use these features will not be available
when C# 8. 0 is targeted to .Net Framework 4.8
Index and Range TYPES
Index Expressions
var lastCharacter = myString[myString.Length-1];
var lastCharacter = myString[^1];
Index nextIndex = ^(x + 1); var nextChar = myString[nextIndex]
Range Expressions
var s = myString.Substring[0..2];
var s = myString.Substring(1..^1);
NULLABLE REFERENCE TYPES
public string Run(string? p1, string p2)
{
return p1 + p2;
}
foreach await(var s in objects) {
}
using await…
ASYNCHRONOUS STREAMS & ITERATORS &
DISPOSE
DEFAULT INTERFACE IMPLEMENTATIONS
public interface IDefaultInterfaceMethod=
{
public void DefaultMethod() => Console.WriteLine("Merhaba")
}
public class AnyClass : IDefaultInterfaceMethod
{
}
EXTENSION EVERYTHING
extension ObjectExtension extends Object
{
}
RECORDS
That’s it. With just one line of code, we’d get, for free
• A constructor.
• A pair of properties.
• “Equals” and “GetHashCode” overrides.
• An implementation of IEquatable<Move>.
• A “Deconstruct” method
var move = new Move("Alice Doe", MoveStrategy.Rock);
var move2 = new Move("Alice Doe", MoveStrategy.Rock);
Assert.AreEqual(move, move2);
class Shape { }
class Triangle : Shape { }
class Pentagon : Shape { }
public int A(Shape shape)
{
return shape switch {
Triangle u => 3, Pentagon b => 5
}
}
DISCRIMINATED UNIONS
PARAMS SPAN
public string Run(params Span<string> a)
{
return string.Join('-', a);
}
8.0 Low probability
• Struct readonly members
• Dictionary Literals
• UTF8 Literals
• Static local functions
• Implicitly scoped using statement
• &&= and ||= assignment operators
STRUCT READONLY MEMBERS
struct Square
{
public int X;
readonly int Size()
{
X = 2;
return X * X;
}
}
DICTIONARY LITERALS
var x = new Dictionary<string, int>() { { "foo", 4 }, { "bar", 5 } };
var y = new Dictionary<string, int>() { ["foo"] = 4, ["bar"] = 5 };
var z = ["foo":4, "bar": 5];
Thanks
@rorypreddy
.NET core 3.0 daily builds
• https://github.com/dotnet/core/blob/master/daily-builds.md
.NET Core 3.0 PortabilityAnalyzer
• https://github.com/Microsoft/dotnet-apiport-ui

Whats new in .NET for 2019

  • 1.
    What's new in.NET @rorypreddy
  • 3.
    • Years ofbackwards compatibility for .NET is limiting the teams with future development. • .NET Framework is slowing down • They will continue to update • No changes to support policy • Recommend new development on .NET Core The Future of .NET Framework
  • 4.
    Don’t Panic! • Youdon’t have to move! New development • .NET Core is a good choice Existing code • Costs and benefits to migrating TheBottom Line
  • 5.
    CORE 3.0 • Side-by-sideand App-local Deployment • Easily convert existing Desktop applications to .Net Core 3 • Improvement to Project Files • Continue to support Controls, NuGet Packages, and Existing Assembly References
  • 6.
    Modernize Desktop Appswith .NET Core 3 Highly-compatible, targeted improvements, like last few releases UWP Windows-only WEB ASP.NET Core EF 6 EF Core AI/ML ML.NET WPF .NET Core 3.NET Framework 4.8 Existing App Highly compatible updates Install .NET Core updates per your needs Windows-only Cross-platform DATA Windows Forms .NET STANDARD Update .NET Framework Apps
  • 7.
  • 8.
    What Goes Where •Desktop Apps -> .NETCore 3 • Business Logic -> .NET Standard • BackEndAPls -> .NETCore 3 • Front EndWeb Apps -> Well, this istougher...
  • 9.
    Migrating a Typical.NET App Partially to the Cloud On-Premises WPF App Windows .NET Framework Web API Back End Windows .NET Framework SQL Database 1 On-Premises WPF App Windows .NET Framework Web API Back End Windows .NET Core SQL Database 2 Cloud On-Premises WPF App Windows .NET Framework Web API Back End Windows .NET Core SQL Database 3
  • 10.
    Handling Shared CodeWhen Targeting Multiple .NET Implementations WPF App .NET Framework Web API Back End .NET Framework 1 Business Logic .NET Framework WPF App .NET Framework Web API Back End .NET Core 2 Business Logic .NET Standard
  • 11.
  • 12.
    What to expectin porting desktop apps to Core • Update project files to target .NET Core 3 and recompile. • Dependencies will not need to retarget and recompile. There will be additional benefits if you update dependencies.
  • 13.
  • 14.
    What is .NETStandard? .NET Standard is a specification A set of APIs that all .NET platforms must implement $ dotnet new classlib -o My.Class.Library
  • 15.
    .NET Standard isrepresented by The NuGet package NetStandard.Library which contains The reference assembly netstandard.dll At build time .NET Standard bridges references to existing .NET Framework and PCL assemblies via type forwarding At runtime Each platform provides an implementation for netstandard.dll that type forwards to its implementation • .NET Core is an implementation of the .NET Standard • .NET Standard updates are coordinated across all .NET implementers • .NET Core can be updated independently How does .NET Standard work?
  • 16.
  • 17.
    Windows Compatibility Pack •Microsoft.Windows.Compatibility (NuGet package) • Can be referenced from .NETCore as well as from .NETStandard • Has ~21 k Api’s (Windows-only as well as cross-platform) • Contents ACLs Code Pages Code Dom Configuration Crypto DirectoryServices Drawing EventLog MEF v1 Odbc Perf Counters Permissions Ports Registry Runtime Caching WCF Windows Services
  • 18.
    Detecting usage ofunsupported APIs • Use API Analyzer! • https://aka.ms/apianalyzer • Warns about potential compatibility issues and calls to deprecated APIs.
  • 19.
  • 20.
  • 21.
  • 22.
    8.0 High probability •New types • Asynchronous Streams & Iterators & dispose • Default interface implementations • Extension everything • Records • Discriminated unions • Params Span
  • 23.
    Types • Part of.NET Standard 2.1 and C# 8 • The new Index type • The Range type • Nullable reference types • .Net Core 3.0, Xamarin, Unity, and Mono will implement the 2.1 version • .Net Framework 4.8 will not! • Types required to use these features will not be available when C# 8. 0 is targeted to .Net Framework 4.8
  • 24.
    Index and RangeTYPES Index Expressions var lastCharacter = myString[myString.Length-1]; var lastCharacter = myString[^1]; Index nextIndex = ^(x + 1); var nextChar = myString[nextIndex] Range Expressions var s = myString.Substring[0..2]; var s = myString.Substring(1..^1);
  • 25.
    NULLABLE REFERENCE TYPES publicstring Run(string? p1, string p2) { return p1 + p2; }
  • 26.
    foreach await(var sin objects) { } using await… ASYNCHRONOUS STREAMS & ITERATORS & DISPOSE
  • 27.
    DEFAULT INTERFACE IMPLEMENTATIONS publicinterface IDefaultInterfaceMethod= { public void DefaultMethod() => Console.WriteLine("Merhaba") } public class AnyClass : IDefaultInterfaceMethod { }
  • 28.
  • 29.
    RECORDS That’s it. Withjust one line of code, we’d get, for free • A constructor. • A pair of properties. • “Equals” and “GetHashCode” overrides. • An implementation of IEquatable<Move>. • A “Deconstruct” method var move = new Move("Alice Doe", MoveStrategy.Rock); var move2 = new Move("Alice Doe", MoveStrategy.Rock); Assert.AreEqual(move, move2);
  • 30.
    class Shape {} class Triangle : Shape { } class Pentagon : Shape { } public int A(Shape shape) { return shape switch { Triangle u => 3, Pentagon b => 5 } } DISCRIMINATED UNIONS
  • 31.
    PARAMS SPAN public stringRun(params Span<string> a) { return string.Join('-', a); }
  • 32.
    8.0 Low probability •Struct readonly members • Dictionary Literals • UTF8 Literals • Static local functions • Implicitly scoped using statement • &&= and ||= assignment operators
  • 33.
    STRUCT READONLY MEMBERS structSquare { public int X; readonly int Size() { X = 2; return X * X; } }
  • 34.
    DICTIONARY LITERALS var x= new Dictionary<string, int>() { { "foo", 4 }, { "bar", 5 } }; var y = new Dictionary<string, int>() { ["foo"] = 4, ["bar"] = 5 }; var z = ["foo":4, "bar": 5];
  • 35.
    Thanks @rorypreddy .NET core 3.0daily builds • https://github.com/dotnet/core/blob/master/daily-builds.md .NET Core 3.0 PortabilityAnalyzer • https://github.com/Microsoft/dotnet-apiport-ui