59
What’s New & Hot in .NET 4.0? Jess Chadwick blog.jesschadwick.com twitter.com/jchadwick

Whats New and Hot in .NET 4.0

Embed Size (px)

DESCRIPTION

Walks through the new and awesome features in the .NET 4.0 Framework

Citation preview

Page 1: Whats New and Hot in .NET 4.0

What’s New & Hot in .NET 4.0?

Jess Chadwickblog.jesschadwick.comtwitter.com/jchadwick

Page 2: Whats New and Hot in .NET 4.0

About Me (Only one is true)

I invented the question mark.

I have several published magazine articles

I can swim the 100m breaststroke in under 1:30

Page 3: Whats New and Hot in .NET 4.0

The boring credentials…

Decade of development experience Recently turned independant consultant

Speaker & User Group Leader Microsoft MVP (ASP.NET) ASPInsider Writer

Blog: blog.jesschadwick.com Articles: in CoDe and DevConnections

magazines

Page 4: Whats New and Hot in .NET 4.0

What Is The .NET Framework?

Base Class Libraries

The CLRJIT & NGEN

Garbage Collector

Security Model

Exception Handling

Loader & Binder

WPFWin

FormsDLR

ASP.NET

WCF…and more!

LINQ-to-SQL

Page 5: Whats New and Hot in .NET 4.0

.NET 4.0 Overview: New & Updated

CLR & FRAMEWORK

The CLR The Base Class Library Performance, Concurrency

& Parallelization

New Languages (F#, IronPython)

Language Enhancements Dynamic Language

Runtime Code Contracts Managed Extensibility

Framework (MEF)

PLATFORMS

Entity Framework WPF Windows Workflow ASP.NET

ASP.NET MVC Web Forms ASP.NET AJAX

Page 6: Whats New and Hot in .NET 4.0

.NET 4.0 Overview: New & Updated

CLR & FRAMEWORK

The CLR The Base Class Library Performance, Concurrency

&Parallelization

New Languages Language Enhancements Dynamic Language

Runtime Code Contracts Managed Extensibility

Framework (MEF)

PLATFORMS

Entity Framework WPF Windows Workflow ASP.NET

ASP.NET MVC Web Forms ASP.NET AJAX

( Platform demos if we have time )

Page 7: Whats New and Hot in .NET 4.0

.NET Framework Improvements

Page 8: Whats New and Hot in .NET 4.0

The Goals of CLR 4

Working Better Together…

Faster…

With Fewer Bugs…

In-Proc SxS

Native/Managed InteropDLR Integration

Managed Extensibility Framework

Threading Parallel Extensions

Garbage Collection Profiling

Code Contracts DebuggingCorrupted State Exceptions

Page 9: Whats New and Hot in .NET 4.0

Base Class Library Additions

Numerics BigInteger

Data Structures Tuple (new

Tuple<int,int,string>(1,2,”Test”)) ISet<T> (SortedSet<T> & HashSet<T>)

I/O Memory-Mapped File

Page 10: Whats New and Hot in .NET 4.0

Performance, Concurrency, and Parallel Extensions

Thread-safe collections (BlockingCollection<T>, ConcurrentDictionary<T>, etc.)

Task Parallel Library (TPL)

PLINQ

Lazy Initializationeg: Lazy<IEnumerable<Order>> Orders { get; set;}

Page 11: Whats New and Hot in .NET 4.0

Code Contracts

Page 12: Whats New and Hot in .NET 4.0

Design By Contract

Code Contracts provide a

language-agnostic and

declarative way to express coding

assumptions in .NET programs.

Page 13: Whats New and Hot in .NET 4.0

A Code Contract contains…Pre-conditions: must be true

beforepublic Rational(int numerator, int denominator){Contract.Requires(denominator > 0); …}

Post-conditions: must be true afterpublic string GetPassword(){Contract.Ensures(Contract.Result<string>() != null); … return password;}

Page 14: Whats New and Hot in .NET 4.0

A Code Contract contains…

Invariants - must always be true[ContractInvariantMethod]protected void ObjectInvariant(){Contract.Invariant(denominator > 0);}

Page 15: Whats New and Hot in .NET 4.0

Code Contracts

Page 16: Whats New and Hot in .NET 4.0

Why are Contracts Useful?

• Debugging

• Tooling!• Pex

(research.microsoft.com/projects/pex/)

Page 17: Whats New and Hot in .NET 4.0

Language EnhancementsC#, Visual Basic, plus new Functional & Dynamic Languages

Page 18: Whats New and Hot in .NET 4.0

New C# 4.0 Features

1. Improved COM Inter-op

2. Named and Optional Parameters

3. Covariance and Contravariance

Page 19: Whats New and Hot in .NET 4.0

New VB10 Features

1. Auto-Implemented Properties

2. Collection Initializers

3. Statement Lambdas

4. Implicit Line Continuation

5. Covariance and Contravariance

Page 20: Whats New and Hot in .NET 4.0

New VB10 Features

1. Automatic Properties

2. Collection Initializers

3. Statement Lambdas

4. Implicit Line Continuation

5. Covariance and Contravariance

Page 21: Whats New and Hot in .NET 4.0

Covariance & Contravariance

“Fix” generics

Page 22: Whats New and Hot in .NET 4.0

Covariance

Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is preserved

Page 23: Whats New and Hot in .NET 4.0

Covariance

Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is preserved

class Derived : Base { }

IEnumerable<Derived> d = new List<Derived>();

IEnumerable<Base> b = d;

Page 24: Whats New and Hot in .NET 4.0

Contravariance

Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is reversed.

Page 25: Whats New and Hot in .NET 4.0

Contravariance

Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is reversed.

class Derived : Base { }

public void DoSomething(Action<Derived> func);

DoSomething((Base x) => x.Foo());

Page 26: Whats New and Hot in .NET 4.0

New Language Features

Page 27: Whats New and Hot in .NET 4.0

Emerging Language Trends

Declarative

ConcurrentDynamic

Page 28: Whats New and Hot in .NET 4.0

Emerging Language Trends

Declarative

ConcurrentDynamic

Page 29: Whats New and Hot in .NET 4.0

Introducing… F#!

F# Is… A functional programming language

derived from OCaml and the ML family of languages

Very good for computation-intensive problems, highly-parallel problems, and language-oriented programming

A first-class .NET 4.0 language, with full Visual Studio 2010 support

Page 30: Whats New and Hot in .NET 4.0

Emerging Language Trends

Declarative

ConcurrentDynamic

Page 31: Whats New and Hot in .NET 4.0

New C# 4.0 Features

1. Improved COM Inter-op

2. Named and Optional Parameters

3. Covariance and Contravariance

4. Late-binding support (via dynamic keyword)

(Will show up in our demos coming up next!)

Page 32: Whats New and Hot in .NET 4.0

Dynamic Language Runtime

Page 33: Whats New and Hot in .NET 4.0

Why a “Dynamic Language Runtime”?

Common Language Runtime

Statically-Typed

C#VB

RubyPython

Dynamically-Typed

Dynamic Language Runtime

Page 34: Whats New and Hot in .NET 4.0

PythonBinder

RubyBinder

COMBinder

JScriptBinder

ObjectBinder

.NET Dynamic Programming

Dynamic Language Runtime

Expression TreesDynamic Dispatch

Call Site Caching

IronPython

IronRuby C# VB.NET…

whatever!

Page 35: Whats New and Hot in .NET 4.0

Dynamic Language Runtime

Page 36: Whats New and Hot in .NET 4.0

Emerging Language Trends

Declarative

ConcurrentDynamic

Page 37: Whats New and Hot in .NET 4.0

Declarative Development

ASP.NET Web Forms (ASPX)

XAML (WPF & Silverlight)

Code Contracts

MEF!

Page 38: Whats New and Hot in .NET 4.0

Managed Extensibility Framework (MEF)

Page 39: Whats New and Hot in .NET 4.0

What is MEF?

MEF is… A way to manage dependencies

A way to provide extensibility in your apps

A framework to encourage loose coupling and reusability

A new addition to the Base Class Library System.ComponentModel.Composition

Page 40: Whats New and Hot in .NET 4.0

What is MEF? (Simple Answer)

Imports and Exports

Page 41: Whats New and Hot in .NET 4.0

What is MEF? (Simple Answer)

Imports and Exportsof components (“parts”)

Page 42: Whats New and Hot in .NET 4.0

What is MEF? (Complex Answer)

Imports and Exports of components (“parts”)

wired together via containers

Page 43: Whats New and Hot in .NET 4.0

Implementing MEF…and, heck – everything

else!

Page 44: Whats New and Hot in .NET 4.0

What’s New in the Platforms?WPF, ASP.NET, Workflow, etc!

Page 45: Whats New and Hot in .NET 4.0

Windows Presentation Framework (WPF)

Page 46: Whats New and Hot in .NET 4.0

Lots of Good Stuff for WPF Multitouch

Windows 7 taskbar

Windows 7 ribbon

Full Trust XBaps

Cached compositions

Textclarity

Layout rounding

ClickOnce improvements

Focus mgt improvements

Support for UIAccessible2

VSM integration

Media element improvements

Client profile

Data controls

Accessibility improvements

Control themes

Chart controls

… hundreds of good bug

fixes too!

Page 47: Whats New and Hot in .NET 4.0

Entity FrameworkIt’s not just for databases anymore!

Page 48: Whats New and Hot in .NET 4.0

EF4 Enhancements

Model-First Development

Persistence Ignorance (POCO support!)

Application Patterns (Repository, Unit of Work, etc.)

Customization of Queries & Generated Code

Page 49: Whats New and Hot in .NET 4.0

Windows Workflow

Page 50: Whats New and Hot in .NET 4.0

WF challenges today

Limited support for XAML-only workflows Versioning is problematic Composition difficult or impossible Writing custom activities and managing

data flow is not easy enough today Limited WCF integration and activity

support No generic server host environment Bottom line: A high bar to get to enough

value to make it worth the tax

Page 51: Whats New and Hot in .NET 4.0

Moving towards .NET 4.0

XAML-only workflows are the new default Unified model between WF, WCF, and WPF

Extended base activity library Simplified WF programming model Support for arguments, variables,

expressions Major improvements to WCF integration Runtime and designer improvements Hosting & management via "Dublin"

Page 52: Whats New and Hot in .NET 4.0

Extended base activity library .NET 4.0 comes with several new activities

Flow control• Flowchart• ForEach• DoWhile• Break

WCF• Send• Receive• SendReply• SendParameters• ReceiveParameter

s• CorrelationScope• InitializeCorrelatio

n• …

Others• Assign• MethodInvoke• Persist• Interop• PowerShellComm

and• ...

Microsoft is planning to ship more activities via CodePlex

Page 53: Whats New and Hot in .NET 4.0

New flow chart model

Flowcharts offer a middle ground between the sequential and state machine models

Simple step-by-step model, with decisions and switches

Allows you to return to previousactivities in the workflow

Page 54: Whats New and Hot in .NET 4.0

Improving the WebASP.NET MVC, Web Forms, and ASP.NET AJAX

Page 55: Whats New and Hot in .NET 4.0

ASP.NET MVC

v.2 “Officially” part of the framework New Features for v2:

Areas Data Annotations support Templated Helpers Client-Side Validation

Page 56: Whats New and Hot in .NET 4.0

Web Forms

• Client ID manipulation

• Fine-Grained ViewState control

Page 57: Whats New and Hot in .NET 4.0

ASP.NET AJAX

• Client-Side Templates

• Client-Side Data Controls (DataView &

DataContext)

• Declarative Instantiation

• Command Bubbling

• Live Bindings

Page 58: Whats New and Hot in .NET 4.0

Questions?Please complete the online evaluation form

Page 59: Whats New and Hot in .NET 4.0

Thank you!

Contact InfoEmail: [email protected]: blog.jesschadwick.comTwitter: twitter.com/jchadwick

Resources• Visual Studio 2010: msdn.microsoft.com/en-us/vstudio• MEF Homepage: mef.codeplex.com• DLR Homepage: dlr.codeplex.com• IronPython Homepage: ironpython.codeplex.com