Whats New and Hot in .NET 4.0
-
Upload
jess-chadwick -
Category
Technology
-
view
1.513 -
download
0
description
Transcript of Whats New and Hot in .NET 4.0
What’s New & Hot in .NET 4.0?
Jess Chadwickblog.jesschadwick.comtwitter.com/jchadwick
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
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
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
.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
.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 )
.NET Framework Improvements
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
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
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;}
Code Contracts
Design By Contract
Code Contracts provide a
language-agnostic and
declarative way to express coding
assumptions in .NET programs.
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;}
A Code Contract contains…
Invariants - must always be true[ContractInvariantMethod]protected void ObjectInvariant(){Contract.Invariant(denominator > 0);}
Code Contracts
Why are Contracts Useful?
• Debugging
• Tooling!• Pex
(research.microsoft.com/projects/pex/)
Language EnhancementsC#, Visual Basic, plus new Functional & Dynamic Languages
New C# 4.0 Features
1. Improved COM Inter-op
2. Named and Optional Parameters
3. Covariance and Contravariance
New VB10 Features
1. Auto-Implemented Properties
2. Collection Initializers
3. Statement Lambdas
4. Implicit Line Continuation
5. Covariance and Contravariance
New VB10 Features
1. Automatic Properties
2. Collection Initializers
3. Statement Lambdas
4. Implicit Line Continuation
5. Covariance and Contravariance
Covariance & Contravariance
“Fix” generics
Covariance
Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is preserved
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;
Contravariance
Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is reversed.
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());
New Language Features
Emerging Language Trends
Declarative
ConcurrentDynamic
Emerging Language Trends
Declarative
ConcurrentDynamic
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
Emerging Language Trends
Declarative
ConcurrentDynamic
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!)
Dynamic Language Runtime
Why a “Dynamic Language Runtime”?
Common Language Runtime
Statically-Typed
C#VB
RubyPython
Dynamically-Typed
Dynamic Language Runtime
PythonBinder
RubyBinder
COMBinder
JScriptBinder
ObjectBinder
.NET Dynamic Programming
Dynamic Language Runtime
Expression TreesDynamic Dispatch
Call Site Caching
IronPython
IronRuby C# VB.NET…
whatever!
Dynamic Language Runtime
Emerging Language Trends
Declarative
ConcurrentDynamic
Declarative Development
ASP.NET Web Forms (ASPX)
XAML (WPF & Silverlight)
Code Contracts
MEF!
Managed Extensibility Framework (MEF)
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
What is MEF? (Simple Answer)
Imports and Exports
What is MEF? (Simple Answer)
Imports and Exportsof components (“parts”)
What is MEF? (Complex Answer)
Imports and Exports of components (“parts”)
wired together via containers
Implementing MEF…and, heck – everything
else!
What’s New in the Platforms?WPF, ASP.NET, Workflow, etc!
Windows Presentation Framework (WPF)
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!
Entity FrameworkIt’s not just for databases anymore!
EF4 Enhancements
Model-First Development
Persistence Ignorance (POCO support!)
Application Patterns (Repository, Unit of Work, etc.)
Customization of Queries & Generated Code
Windows Workflow
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
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"
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
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
Improving the WebASP.NET MVC, Web Forms, and ASP.NET AJAX
ASP.NET MVC
v.2 “Officially” part of the framework New Features for v2:
Areas Data Annotations support Templated Helpers Client-Side Validation
Web Forms
• Client ID manipulation
• Fine-Grained ViewState control
ASP.NET AJAX
• Client-Side Templates
• Client-Side Data Controls (DataView &
DataContext)
• Declarative Instantiation
• Command Bubbling
• Live Bindings
Questions?Please complete the online evaluation form
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