Overview of .NET Framework 4.0 - download.microsoft.com

Overview of .NET Framework 4.0 - download.microsoft.com

Overview of .NET Framework Sanjay Vyas Whats New In Base Class Library Managed Extensibility Framework New Data Types I/O Improvements Declaration & consumption of extensibility points

Monitoring for new runtime extension BigInteger ComplexNumber Tuple SortedSet Memory Mapped Files Unified Cancelling Model Managed Extensibility Framework Create reusable components Dont we already have reusable components?

No need to create infrastructure from scratch MEF is dynamically composed Whats so dynamic about it Current plugin model tied to specific apps Same component cannot be used across apps Discoverable at runtime Tagging for rich queries and filtering MEF Architecture MEF Catalog Discovers and maintain extensions

CompositionContainer Coordinate creations and satisfy dependencies ComposablePart Offer one or more exports May depend on imports for extension it uses Demo Managed Extensibiity Framework New Language Features C# 4.0

Named Parameters Optional Parameters Dynamic Scoping Generic Variance Extension Property VB.NET 10 Statement Lambdas Multiline Lambdas Auto implemented Properties Collection Initializer Generic Variance

Extension Property Optional and Named Parameter Some methods have excessive parameters Too many overloads of methods Most arent used in everyday scenario Developers still have to supply default values Heavy use of Type.Missing Comma counting is a pain

Difficult to remember parameter by position Overload Of Overloads class Book { // Multiple constructors Book() : this(, , , ) { } Book(string isbn) : this(isbn, , , 0) { } Book(string isbn, string title) : this(isbn, title, , 0) {

} Book(string isbn, string title, string author) : this(isbn, title, author, 0) { } } // Master Constructor which gets called by others Book(string isbn, string title, string author, int pages) { // Do the actual work here } Optional Parameters class Book

{ } : : : Book Book Book Book // Use optional parameters Book(string isbn=, string title=, string author=, int pages=0) { // Do the actual work here

} book book book book = = = = new new new

new Book(1-43254-333-1); Book(1-43254-333-1, How not to code); Book(1-43254-333-1, How not to code, Copy Paster); Book(1-43254-333-1, 240); // Cannot skip parameters Named Parameter class Book { } // Use optional parameters Book(string isbn=, string title=, string author=, int pages=0)

{ // Do the actual work here } : : : Book book = new Book(isbn:1-43254-333-1); Book book = new Book(isbn:1-43254-333-1, title:How not to code); Book book = new Book(isbn:1-43254-333-1, title:How not to code, author:Copy Paster); Book book = new Book(isbn:1-43254-333-1, pages:240); Dynamic scoping C# is static type languages

Types are explicitly defined Methods are bound at runtime Dynamic dispatch exists Reflection API Method.Invoke() is tedious COM Automation is based on IDispatch May not have .TLB Lookup can be purely runtime Certain Application Types require Dynamism E.g. SOAP/REST proxies Dynamic in .NET 4.0

CLR is mostly static type Compile time type checking (e.g. IUnknown) DLR added dynamism to .NET Run time type checking (e.g. IDispatch) DLR is now part of .NET 4.0 API Full support of IronRuby, IronPython Dynamic dispatch now built into .NET/C# Dynamic Dispatch Introduction of type dynamic Compiler merely packages information

Compiler defers binding to runtime Built-in support for COM Calls Uses IDispatch interface PIA not required Runtime binding for framework objects Build your own IDynamicObject IronPython, IronRuby use this E.g. RestProxy Dynamic Data Type Isnt Object type dynamic already? .NET already has var, why add dynamic?

Object Static type, base class var is ALSO static type, compiler inferred dynamic Evaluation deferred Dynamic implementation dynamic d = GetFlyingObject(Superman); d.Fly(); // Up, up and away dynamic d = GetFlyingObject(AirPlane); d.Fly(); // Take off dynamic d = GetFlyingObject(Cat); d.Fly(); // OOPS but at runtime

Demo Dynamic Dispatch Variance Covariance Similar to base reference to derived class Covariance is applied to arrays, delegates.. Contravariance Similar to derived instance passed to base

Changes to Variance Variance can now be applied to Interfaces Variant types supports interfaces and delegates Variance applies to reference conversion only Value types are not supported Covariance Requires the use of out keyword Contravariant Requires the use of in keyword It could be automatically inferred but that could lead to code-breaking when interface definition changes

Demo Variance Code Contracts Foundation Design by contract Based on MSRs SPEC# What does it bring? Improved testability Static verification API Documentation How does it help?

Guarantee obligations on entry (parameter validations) Guarantee property at exit (return value range) Maintain property during execution (object invariance) Code Contracts New namespace in .NET System.Diagnostics.Contracts Parameter validation Contract.Requires() Return value guarantee Contract.Ensures() Object state guarantee

Contract.Invariant() Code Contracts Compile generates the IL code Contracts are conditionally compiled Define CONTRACTS_FULL to enable Demo Code Contracts Parallelism in .NET 4.0 Dont we have multithreading and ThreadPool? Requires too much work

Requires understanding of nitty-gritties Bifurcated thinking for single CPU vs. multi What does parallelism bring in? Make multicore programming simple Automatcially handle single vs. multicore Focus on what rather than how Visual Studio 2010 Tools / Programming Models / Runtimes Programming Models Programming Models PLINQ

Parallel Debugger Toolwindows Data Data Structures Structures Task Parallel Library Concurrency Runtime ThreadPool Profiler

Concurrency Analysis Task Scheduler Parallel Pattern Library Data Data Structures Structures Integrated Tooling Concurrency Runtime

Task Scheduler Resource Manager Resource Manager Operating System Threads Key: Managed Library Agents

Library Native Library Tools Parallels in .NET Task Parallel Library (TPL) Task and Data Parallelism LINQ to Parallel (PLINQ) Use LINQ to implement parallelism on queries Coordinated Data Structures High performance collection classes which are

lock free and thread safe Parallel Diagnostic Tools Parallels Debugger and VSTS Profiler concurrency view User Mode Scheduler CLR Thread Pool Global Queue Worker Thread 1 Program

Thread Worker Thread p User Mode Scheduler For Tasks CLR Thread Pool: Work-Stealing Global Queue Local Queue

Worker Thread 1 Local Queue Worker Thread p Task 6

Task 1 Task 2Program Thread Task Task 4 3 Task 5 Task Parallel Library Write code which automatically uses multicore

Expose potential parallelism in sequential code No language extension (aka Syntactic sugar) yet Parallelism types The Task Class Task Parallelism The Parallel Class Data Parallelism Task Management TaskManager class Use default or create your own Demo Task Parallel Library Resources

Software Application Developers Infrastructure Professionals http://msdn.microsoft.com/ http://technet.microsoft.com/ msdnindia @msdnindia technetindia

@technetindia 2011 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.

Recently Viewed Presentations

  • Mae hen wlad fy nhadau yn annwyl i

    Mae hen wlad fy nhadau yn annwyl i

    Dros ryddid collasant eu gwaed. Gwlad, Gwlad, pleidiol wyf i'm gwlad, Tra môr yn fur i'r bur hoff bau, O bydded i'r heniaith barhau. Mae Hen Wlad Fy Nhadau Written by Evan James Presentation by www.communication4all.co.uk Animations available from www.animationfactory.com...
  • Senior Parent Night

    Senior Parent Night

    Unweighted is on a 4.0 scale Weighted is on a 6.0 scale Top 15% weighted rank = NJ Star Transcript reflects weighted & unweighted GPA & Rank The University expects all applicants to have completed strong college preparatory course work...
  • CHAPTER ONE Supplement Chapter 1  SECTION 1.1  INFORMATION

    CHAPTER ONE Supplement Chapter 1 SECTION 1.1 INFORMATION

    - raw facts that describe the characteristic of an event. Information - data converted into a meaningful and useful context. Business intelligence - applications and technologies that are used to gather, provide access to, and analyze data and information to...
  • Assessment of General Education - Oklahoma City University

    Assessment of General Education - Oklahoma City University

    Coordinator: Dr. Jo Lynn Autry Digranes Assessment of Student Learning The systematic collection of information about student learning, using the time, knowledge, expertise, and resources available, in order to inform decisions about how to improve learning.
  • Theme A theme can be divided into two

    Theme A theme can be divided into two

    Thematic Concept. Thematic Statement. Fear. The only thing we have to fear is fear itself, in the novel I am the messenger by Markus Zusak , the character Ed is afraid of getting out there and doing anything, of taking...
  • Chapter 23-2 Industrialization and Its Discontents

    Chapter 23-2 Industrialization and Its Discontents

    Robert Owen (1771-1858) created Grand National Consolidated Trades Union and tried to organize a national strike. ... Thomas Hardy's novels reflect the futility of fighting modernity. George Bernard Shaw mocked the shallowness of . fin-de-siècle . society. Decadence and Symbolism...
  • ACARA and what it will mean for Languages

    ACARA and what it will mean for Languages

    ACARA and what it will mean for Languages educators Sherryl Saunders Secretary, AFMLTA Professional Learning Officer, MLTAQ as at 20 August 2014
  • Meeting the Demands of No Child Left Behind

    Meeting the Demands of No Child Left Behind

    Scheurich and Skrla No Child Left Behind: A Challenge for Special Education Meeting the Challenge Through Collaborative Leadership and Systemic Change Judith Moening North East I.S.D., San Antonio, Texas NCLB: A Challenge to the Traditional Model of Special Education Traditional...