54
.NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Embed Size (px)

Citation preview

Page 1: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

.NET 4.5, Just the good StuffWilliam TullochSenior ConsultantReadify

Mahesh Krishnan Principal ConsultantReadify

DEV215

Page 2: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

A shameless plug

Page 3: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

AgendaWhat are we going to cover?

The big pictureCore FrameworkWeb stuffThe three pillars of .NET 3.0 (WCF, WPF & WF)Other cool stuff

Page 4: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

10 Years ago

Page 5: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

A brief history of the .NET frameworkFe

brua

ry

2002

.NE

T 1.

0 Ap

ril

2003

.NE

T 1.

1

Janu

ary

2006

.NE

T 2.

0

Nov

embe

r 20

06 .N

ET

3.0

Nov

embe

r 20

07 .N

ET

3.5

April

20

10 .N

ET

4.0

Augu

st

2012

Page 6: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

.NET 4.5

Page 7: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

What has influenced this release?

Improving asynchronous operationsWindows 8 & WinRTNuGetPerformanceUsers’ Voice

Page 8: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Core Framework

Page 9: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

async/await

Page 10: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Demo

A simple example

async/await

Page 11: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

That was easy but …

Page 12: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

All things asynchronous

Stream, TextWriter and TextReader have new async methods for expensive operations

Classes in System.Data.Common & System.Data.SqlClient now provide async methods

In WCF generating a proxy will create both synchronous and asynchronous operations by default

Page 13: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Identity

Page 14: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Since .NET 1.0 …

IIdentity

WindowsIdentity GenericIdentity FormsIdentity

Page 15: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

The IIdentity interface public interface IIdentity{

string AuthenticationType{ get; }

bool IsAuthenticated{ get; }

string Name{ get; }}

Page 16: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Since .NET 1.0 …

IPrincipal

WindowsPrincipal GenericPrincipal FormsPrincipal

Page 17: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

The IPrincipal interface public interface IPrincipal{

IIdentity Identity{ get; }

bool IsInRole(string role);}

Page 18: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Now in .NET 4.5

ClaimsIdentity

WindowsIdentity GenericIdentity FormsIdentity

IIdentity

Page 19: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

The ClaimsIdentity classpublic class ClaimsIdentity : IIdentity{ //constructors removed to simply view // Properties public virtual string Name { get; } public virtual string AuthenticationType { get; } public virtual bool IsAuthenticated { get; }

public virtual IEnumerable<Claim> Claims { get; } public ClaimsIdentity Actor { get; set; } public object BootstrapContext { get; set; } public string Label { get; set; } public string NameClaimType { get; } public string RoleClaimType { get; }

//Helper methods for working with claims removed}

Page 20: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Now in .NET 4.5

ClaimsPrincipal

WindowsPrincipal GenericPrincipal FormsPrincipal

IPrincipal

Page 21: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

The ClaimsPrincipal classpublic class ClaimsPrincipal : IPrincipal{ // Properties public virtual IIdentity Identity { get; } public virtual IEnumerable<Claim> Claims { get; } public static ClaimsPrincipal Current { get; } public virtual IEnumerable<ClaimsIdentity> Identities { get; }

public virtual bool IsInRole(string role); //Helper methods for claims removed}

Page 22: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

A quick look at claims

Page 23: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Moving on from Role-based identity

AD in Windows Server 2012 can now export claims

Existing identity management doesn’t have to change for existing apps when upgrading to .NET 4.5

Windows Identity Foundation is now built into .NET 4.5

Page 24: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Portable Class Libraries

Page 25: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Portable Class Libraries

Page 26: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Some other things worth mentioning

Profile Optimisation and multicore JIT

Timeout support for regular expressions

New System.IO.Compression namespace

WeakReference<T>

Culture definition for the application domain

Page 27: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

All things web

Page 28: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Web API

Http programming model – helps in writing RESTful appsFull support for routes

Content negotiation

Query composition

Can be self-hosted

Page 29: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Creating a simple REST service

Page 30: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Working with the HttpClient

Page 31: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Web Sockets

Page 32: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Web Sockets

Full duplex, bi-directional communication

Built on HTTP, thus can traverse firewalls and proxies

Supports binary and UTF-8 payloads

Supported in WinRT, IE10, IIS 8, ASP.NET 4.5 and WCF 4.5on Windows 8 and Windows Server 2012

Page 33: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

ASP.NET

Page 34: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Web forms

Strongly typed data controls and model binding

Improved async support

Built-in minification and bundling of Javascript & CSS

Server controls updated for HTML 5

Page 35: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

MVC 4

Razor enhancementsChanges to the template Async controller actionsImproved support for mobile development …

Page 36: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

ASP.NET

Page 37: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

The pillars of .NET 3.0

Page 38: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

WCF

Page 39: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

What’s new in WCF

Easier to ConfigureProxies define async methods by defaultCan create explicit task-based async operations WebSockets and UDP protocols supportedWCF support for Windows 8 apps

Page 40: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Using WCF in a Windows 8 app

Page 41: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

WPF

Page 42: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

What’s new in WPF

The Ribbon ControlValidating data asynchronouslyData Binding Changes

Delay property bindingBinding to static properties

Markup extensions for events…

Page 43: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Workflow Foundation

Page 44: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

What’s in new in WF

C# expressions

Contract-first workflow services

Workflow versioning - WorkflowIdentity

Authoring & designer improvements

Page 45: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

Other cool stuff

Page 46: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

MEF 2.0

Page 47: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

MEF 2.0

Support for open generic parts

Convention-based registration

Composition scoping enhancements

Diagnostic improvements

MEF for Metro & web apps

Page 48: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

MEF in Windows 8

Page 49: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

The TPL

Page 50: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

What’s new in the TPL

Performance

New methods

Run()

Delay()

WhenAny()

WhenAll()

FromResult()

The Progress<T> class

Page 51: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

TPL Dataflow

Page 52: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

What is TPL Dataflow (TDF)?

“TPL Dataflow (TDF) is a new .NET library for building concurrent applications. It promotes actor/agent-oriented designs through primitives for in-process message passing, dataflow, and pipelining. TDF builds upon the APIs and scheduling infrastructure provided by the Task Parallel Library (TPL), and integrates with the language support for asynchrony provided by C#, Visual Basic, and F#.”

Page 53: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

TDF is …

A set primitives referred to as blocks

A block essentially consists of a queue/buffer and a Task

Some examples of blocks are:

ActionBlock

TransformBlock

BufferBlock

Page 54: NET 4.5, Just the good Stuff William Tulloch Senior Consultant Readify Mahesh Krishnan Principal Consultant Readify DEV215

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the

part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.