SlideShare a Scribd company logo
1 of 23
Core .NET Framework 4 Enhancements
Your presenter for today? Robert MacLean sadev.co.za @rmaclean
What to expect
What are we covering? LINQ ASP.NET WCF WPF ADO.NET … C# VB.NET C++ DLR Base Class Libraries Common Language Runtime JITNGEN Garbage Collector Type System Exception handling Hosting APIs Loader and binder Debugging, …
PREP  VS – with base project Open program.cs VS – With  SxS Demo VS – With Movies (MEF) demo, do a build and remove some of the adapters from the output (put somewhere you can get them easily). Keep folder open VS – With location demo. Clean reflector
BIG INT Tour base [Ctrl+1] – talk about the big number and what happens when you try to go over it (overflow and exceptions). Point out decimal is a type value. decimal bigNumber = decimal.MaxValue; Console.WriteLine(bigNumber); bigNumber++; Console.WriteLine(bigNumber); Add reference to system.numerics (nice to point out performance of add reference dialog) [Ctrl+2] – change to big int. point out it is a class. Talk about static methods needed. Talk about no logical upperlimit BigIntegerbigInteger1 = new BigInteger(decimal.MaxValue); Console.WriteLine(bigInteger1); BigInteger bigInteger2 = new BigInteger(decimal.MaxValue); Console.WriteLine(bigInteger1 * bigInteger2); Console.WriteLine(BigInteger.Multiply(bigInteger1, bigInteger2)); LAZY<T> [Ctrl+3] Add the slow class [Ctrl+4] Add code to the main method to show the constructor is slow Console.WriteLine("Before slow create"); Slow slow = new Slow(); Console.WriteLine("After slow create"); slow.Message(); [Ctrl+5] Now change to implement Lazy<T> and show how it is not created until we actually use it. Console.WriteLine("Before slow create"); Lazy<Slow> slow = new Lazy<Slow>(); Console.WriteLine("After slow create"); Console.WriteLine(slow.IsValueCreated);             slow.Value.Message(); Console.WriteLine(slow.IsValueCreated);             Remove the main method and type sorted – nice to show intellisense filtering. Should have sortedlist, sorteddictionary and sortedset Talk about difference between sorting in a list which needs to check during actions and unbalanced binary tree which takes no perf hit on insert etc… and still gives great sorting perf. Also point out difference in requirements of keys for list/dictionary and objects in set.
IObserable SLIDE (1) – explain the pattern [Ctrl+6] Add data class  [Ctrl+7] Add the provider class [Ctrl+8] Add the subscriber class [Ctrl+9] Add the code to the main method GPSSensor sensor = new GPSSensor(); Map map = new Map(); sensor.Subscribe(map, ConsoleColor.Red); //Map map2 = new Map(); //sensor.Subscribe(map2, ConsoleColor.Yellow); do { sensor.GetPosition(); Thread.Sleep(1000); } while (map.StillTracking); Uncomment to show second subscriber SxS Slide (1) – Explain the issue Switch to VS with loader demo. Tour the code start with the two assemblies, point out versions they are compiled to and what they do. Now show the Loader app and show the version (3.5). Show the code and point out that with reflection we are loading it – remind the audience to remember this stuff for later Run the app and note it points out v2 NOT 3.5 – cause the CLR hasn’t changed since 2. Click the run 3.5 assembly – works. Click run 4 assembly and note the exception. Now change the assembly version of loader to 4. and do stesp 4 and 5 again and it works! PIA Slide(1) – Explain what PIA is. Problems – rediretibution and size of distributable Go to VS [ALT +1 ] Add the count down method private static void CountDown()         { Console.WriteLine("3..."); Thread.Sleep(1000); Console.WriteLine("2..."); Thread.Sleep(1000); Console.WriteLine("1..."); Thread.Sleep(1000); }
Add reference to Microsoft.Office.Interop.Excel – add version 14.  Properties of the assembly and make sure embed is off. [ALT + 3] Add code to main method and talk through. Since it is automation explain the count down. Run and move back. Go to binary and drag into reflector – point out that it is listed under references which means shipping it. Go back to VS and change the assembly to embed. Build and demo to show it still works. Refresh reflector and show it has moved from references to actually embedding it into the project. Code Contracts [ALT + 4] Show the code and explain how the zune works out dates.  [ALT + 5] Add code to call it in the main intdayInYear; intyear = ZuneDate.YearSince1980(300, out dayInYear); Console.WriteLine("It's the {0} day of {1}", dayInYear, year); Now change day to: 10593 and explain the bugon Dec 31 2008 [ALT + 6] – fully updated loop Add to start of loop: intdaysAtStart = daysLeft; Add to end of loop: Contract.Assert(daysLeft < daysAtStart); Now project and enable static code contract checking and build Point out the unproven issue – saying it thinks that there is a scenario that could fail [ALT + 7] Add the else to verify and build else { Contract.Assert(false); } It is the problem – so lets deal with it [ALT +8]  Change the else contents to then build and show no errors. Now show  dayInYear= 366;     return year; Change day to -1 and show it doesn’t make sense. [ALT+9] Add to start of check: Contract.Requires(daysSince1980 > 0); Build and show how it identifies it – that is preconditions. Leave for now. [Ctrl+Alt+1] Add post conditions: Contract.Ensures(Contract.ValueAtReturn<int>(out dayInYear) > 0); Contract.Ensures(Contract.ValueAtReturn<int>(out dayInYear) < 367); Run and show that the code doesn’t fail even though our condition is not enforces the check. Pop into reflector and show that those conditions aren’t there. Turn on runtime checking and build and run – not the failure. Pop into reflector and show the code now and show the new code which has been added to the start and end!  Mention sandcastle documentation tool support too
MEF Show folder with Movies project in it and run it.  Add in the files we removed during the setup and run again. Remind people of reflection we saw before. Switch to VS with Movies Project and tour the code/ Explain we have an interface  Show a provider implements it and is attributed with export. Show code of form and show the ImportMany attribute and talk about the initialisation (Catalog, container, and then we can loop over it). Parallel Open Task Manager Slides (1) – explain enhancements in parallel and why it is important Show hunt button code and explain that change it [Ctrl+Alt+2] Parallel.ForEach(movieProviders, movieProvider =>             { HighlightProvider(movieProvider, HighlightState.Searching); IEnumerable<MovieInfo> movies = movieProvider.Search(MovieNameTextBox.Text); HighlightProvider(movieProvider, HighlightState.Loading); AddRange(results, movies); HighlightProvider(movieProvider, HighlightState.None); }); Run and show in parallel Go to IMDB provider and show the LINQ query and explain that could also be parallele. [CTRL+ALT+3]: varmatchedLines = from l in File.ReadLines("movies.list").AsParallel() Build and show improvement (if any) Location Switch to location demo and tour that code and demo. PRAY
All the small things <demo/>
IObservable Update Publisher Data Data Data Subscriber Subscriber Subscriber
IObservable <demo/>
In-process side-by-side (SxS) 2.0 addin 3.0 addin 3.5 addin 4.0 addin .NET 4.0 .NET 3.5 .NET 3.0 .NET 2.0 Host Process (eg: Outlook)
In Process SxS <demo/>
Primary Interop Assemblies (PIA) .NET Meta Data (Headers) PIA COM Helper classes
PIA <demo/>
Tour of .NET 4 Part 2 <demo/>
Parallel PLINQ Task Parallel Library .NET Framework ThreadPool Thread OS
Parallel Enhancements <demo/>
System.Device.Location <demo/>
Location Windows 7 only Status will be Disabled for other platforms Geosense for Windows http://geosenseforwindows.com/
Is this everything? Support for Teredo All the new security enhancements in networking Garbage Collection Improved New ways to detect 64bit OS’s and processes Improvements to System.Enviroment Ngen Improved Memory Mapped Files New File and Directory Enumeration options based on generics Tuples F# New options for performance monitoring which are not invasive Improved parsing for GUID New helper method for Thread Improvements for Registries New helper method for Monitors Better stream compression options New helper methods for UIntPtr and IntPtr New helper method for System.IO.Path New helper method for Streams New helper method and parsing options for Enum New helper method for StopWatch New helper method for StringBuilder System.Numerics.Complex TimeSpanParsing Improvements String Improvements
Future? http://bcl.codeplex.com BigRational LongPath PerfMonitor TraceEvent

More Related Content

What's hot

Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Robert Pickering
 
C++ functions presentation by DHEERAJ KATARIA
C++ functions presentation by DHEERAJ KATARIAC++ functions presentation by DHEERAJ KATARIA
C++ functions presentation by DHEERAJ KATARIADheeraj Kataria
 
Opengl lec 3
Opengl lec 3Opengl lec 3
Opengl lec 3elnaqah
 
Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
Chapter Seven(1)
Chapter Seven(1)Chapter Seven(1)
Chapter Seven(1)bolovv
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)bolovv
 
Advance python programming
Advance python programming Advance python programming
Advance python programming Jagdish Chavan
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4Abdul Haseeb
 
R package development, create package documentation isabella gollini
R package development, create package documentation   isabella golliniR package development, create package documentation   isabella gollini
R package development, create package documentation isabella golliniDataFest Tbilisi
 
Lecture01
Lecture01Lecture01
Lecture01Xafran
 
Docase notation for Haskell
Docase notation for HaskellDocase notation for Haskell
Docase notation for HaskellTomas Petricek
 

What's hot (20)

Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
 
Alp 05
Alp 05Alp 05
Alp 05
 
F# 101
F# 101F# 101
F# 101
 
Python 3000
Python 3000Python 3000
Python 3000
 
C++ functions presentation by DHEERAJ KATARIA
C++ functions presentation by DHEERAJ KATARIAC++ functions presentation by DHEERAJ KATARIA
C++ functions presentation by DHEERAJ KATARIA
 
Opengl lec 3
Opengl lec 3Opengl lec 3
Opengl lec 3
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Chapter Seven(1)
Chapter Seven(1)Chapter Seven(1)
Chapter Seven(1)
 
C++ Functions
C++ FunctionsC++ Functions
C++ Functions
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)
 
Advance python programming
Advance python programming Advance python programming
Advance python programming
 
C++ functions
C++ functionsC++ functions
C++ functions
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4
 
R package development, create package documentation isabella gollini
R package development, create package documentation   isabella golliniR package development, create package documentation   isabella gollini
R package development, create package documentation isabella gollini
 
Python
PythonPython
Python
 
Lecture01
Lecture01Lecture01
Lecture01
 
C++ theory
C++ theoryC++ theory
C++ theory
 
Reactive fsharp
Reactive fsharpReactive fsharp
Reactive fsharp
 
Oct.22nd.Presentation.Final
Oct.22nd.Presentation.FinalOct.22nd.Presentation.Final
Oct.22nd.Presentation.Final
 
Docase notation for Haskell
Docase notation for HaskellDocase notation for Haskell
Docase notation for Haskell
 

Viewers also liked

A Web Developer's Journey across different versions of ASP.NET
A Web Developer's Journey across different versions of ASP.NETA Web Developer's Journey across different versions of ASP.NET
A Web Developer's Journey across different versions of ASP.NETHarish Ranganathan
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantNitin Sawant
 
ASP.NET MVC Fundamental
ASP.NET MVC FundamentalASP.NET MVC Fundamental
ASP.NET MVC Fundamentalldcphuc
 
Feature and Future of ASP.NET
Feature and Future of ASP.NETFeature and Future of ASP.NET
Feature and Future of ASP.NETMd. Mahedee Hasan
 
ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1Kumar S
 
Net framework
Net frameworkNet framework
Net frameworkTuan Ngo
 
Introduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enIntroduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enTuan Ngo
 

Viewers also liked (9)

A Web Developer's Journey across different versions of ASP.NET
A Web Developer's Journey across different versions of ASP.NETA Web Developer's Journey across different versions of ASP.NET
A Web Developer's Journey across different versions of ASP.NET
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
 
ASP.NET MVC Fundamental
ASP.NET MVC FundamentalASP.NET MVC Fundamental
ASP.NET MVC Fundamental
 
Feature and Future of ASP.NET
Feature and Future of ASP.NETFeature and Future of ASP.NET
Feature and Future of ASP.NET
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1
 
Net framework
Net frameworkNet framework
Net framework
 
Introduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enIntroduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 en
 

Similar to Core .NET Framework 4.0 Enhancements

MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersDave Bost
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep JoshiSpiffy
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1benDesigning
 
[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-view[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-viewNAVER D2
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
Whidbey old
Whidbey old Whidbey old
Whidbey old grenaud
 
Open frameworks 101_fitc
Open frameworks 101_fitcOpen frameworks 101_fitc
Open frameworks 101_fitcbenDesigning
 
BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up Craig Schumann
 
Windows Presentation Foundation
Windows Presentation FoundationWindows Presentation Foundation
Windows Presentation FoundationTran Ngoc Son
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The EnterpriseDaniel Egan
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202Mahmoud Samir Fayed
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Maarten Balliauw
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010Skills Matter
 
A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010Abram John Limpin
 
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0Antonio Chagoury
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answersdebarghyamukherjee60
 

Similar to Core .NET Framework 4.0 Enhancements (20)

MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1
 
F# And Silverlight
F# And SilverlightF# And Silverlight
F# And Silverlight
 
[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-view[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-view
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Whidbey old
Whidbey old Whidbey old
Whidbey old
 
Open frameworks 101_fitc
Open frameworks 101_fitcOpen frameworks 101_fitc
Open frameworks 101_fitc
 
BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up
 
Windows Presentation Foundation
Windows Presentation FoundationWindows Presentation Foundation
Windows Presentation Foundation
 
ArduinoWorkshop2.pdf
ArduinoWorkshop2.pdfArduinoWorkshop2.pdf
ArduinoWorkshop2.pdf
 
Introduction to F#
Introduction to F#Introduction to F#
Introduction to F#
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010
 
A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010
 
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
A Sneak Peek At Visual Studio 2010 And .Net Framework 4.0
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 

More from Robert MacLean

14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)Robert MacLean
 
Building a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPBuilding a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPRobert MacLean
 
Features of Kotlin I find exciting
Features of Kotlin I find excitingFeatures of Kotlin I find exciting
Features of Kotlin I find excitingRobert MacLean
 
DevConf Survival Guide
DevConf Survival GuideDevConf Survival Guide
DevConf Survival GuideRobert MacLean
 
The state of testing @ Microsoft
The state of testing @ MicrosoftThe state of testing @ Microsoft
The state of testing @ MicrosoftRobert MacLean
 
Visual Studio ❤ JavaScript
Visual Studio ❤ JavaScriptVisual Studio ❤ JavaScript
Visual Studio ❤ JavaScriptRobert MacLean
 
Putting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/TestPutting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/TestRobert MacLean
 
A Developer Day 2014 - Durban
A Developer Day 2014 - Durban A Developer Day 2014 - Durban
A Developer Day 2014 - Durban Robert MacLean
 
Agile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM RangersAgile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM RangersRobert MacLean
 
Hour of code - Train the trainer
Hour of code - Train the trainerHour of code - Train the trainer
Hour of code - Train the trainerRobert MacLean
 
Building services for apps on a shoestring budget
Building services for apps on a shoestring budgetBuilding services for apps on a shoestring budget
Building services for apps on a shoestring budgetRobert MacLean
 
3 things your app API is doing WRONG
3 things your app API is doing WRONG3 things your app API is doing WRONG
3 things your app API is doing WRONGRobert MacLean
 

More from Robert MacLean (20)

14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)
 
Git
GitGit
Git
 
OWASP TOP 10
OWASP TOP 10OWASP TOP 10
OWASP TOP 10
 
Building a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPBuilding a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCP
 
Looking at the Vue
Looking at the VueLooking at the Vue
Looking at the Vue
 
Kotlin 101
Kotlin 101Kotlin 101
Kotlin 101
 
Features of Kotlin I find exciting
Features of Kotlin I find excitingFeatures of Kotlin I find exciting
Features of Kotlin I find exciting
 
JavaScript Gotchas
JavaScript GotchasJavaScript Gotchas
JavaScript Gotchas
 
DevConf Survival Guide
DevConf Survival GuideDevConf Survival Guide
DevConf Survival Guide
 
The state of testing @ Microsoft
The state of testing @ MicrosoftThe state of testing @ Microsoft
The state of testing @ Microsoft
 
Visual Studio ❤ JavaScript
Visual Studio ❤ JavaScriptVisual Studio ❤ JavaScript
Visual Studio ❤ JavaScript
 
What is new in C# 6?
What is new in C# 6?What is new in C# 6?
What is new in C# 6?
 
Putting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/TestPutting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/Test
 
A Developer Day 2014 - Durban
A Developer Day 2014 - Durban A Developer Day 2014 - Durban
A Developer Day 2014 - Durban
 
Agile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM RangersAgile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM Rangers
 
Hour of code - Train the trainer
Hour of code - Train the trainerHour of code - Train the trainer
Hour of code - Train the trainer
 
Building services for apps on a shoestring budget
Building services for apps on a shoestring budgetBuilding services for apps on a shoestring budget
Building services for apps on a shoestring budget
 
3 things your app API is doing WRONG
3 things your app API is doing WRONG3 things your app API is doing WRONG
3 things your app API is doing WRONG
 
ASP.NET
ASP.NETASP.NET
ASP.NET
 
LightSwitch
LightSwitchLightSwitch
LightSwitch
 

Core .NET Framework 4.0 Enhancements

  • 1. Core .NET Framework 4 Enhancements
  • 2. Your presenter for today? Robert MacLean sadev.co.za @rmaclean
  • 4. What are we covering? LINQ ASP.NET WCF WPF ADO.NET … C# VB.NET C++ DLR Base Class Libraries Common Language Runtime JITNGEN Garbage Collector Type System Exception handling Hosting APIs Loader and binder Debugging, …
  • 5. PREP VS – with base project Open program.cs VS – With SxS Demo VS – With Movies (MEF) demo, do a build and remove some of the adapters from the output (put somewhere you can get them easily). Keep folder open VS – With location demo. Clean reflector
  • 6. BIG INT Tour base [Ctrl+1] – talk about the big number and what happens when you try to go over it (overflow and exceptions). Point out decimal is a type value. decimal bigNumber = decimal.MaxValue; Console.WriteLine(bigNumber); bigNumber++; Console.WriteLine(bigNumber); Add reference to system.numerics (nice to point out performance of add reference dialog) [Ctrl+2] – change to big int. point out it is a class. Talk about static methods needed. Talk about no logical upperlimit BigIntegerbigInteger1 = new BigInteger(decimal.MaxValue); Console.WriteLine(bigInteger1); BigInteger bigInteger2 = new BigInteger(decimal.MaxValue); Console.WriteLine(bigInteger1 * bigInteger2); Console.WriteLine(BigInteger.Multiply(bigInteger1, bigInteger2)); LAZY<T> [Ctrl+3] Add the slow class [Ctrl+4] Add code to the main method to show the constructor is slow Console.WriteLine("Before slow create"); Slow slow = new Slow(); Console.WriteLine("After slow create"); slow.Message(); [Ctrl+5] Now change to implement Lazy<T> and show how it is not created until we actually use it. Console.WriteLine("Before slow create"); Lazy<Slow> slow = new Lazy<Slow>(); Console.WriteLine("After slow create"); Console.WriteLine(slow.IsValueCreated); slow.Value.Message(); Console.WriteLine(slow.IsValueCreated); Remove the main method and type sorted – nice to show intellisense filtering. Should have sortedlist, sorteddictionary and sortedset Talk about difference between sorting in a list which needs to check during actions and unbalanced binary tree which takes no perf hit on insert etc… and still gives great sorting perf. Also point out difference in requirements of keys for list/dictionary and objects in set.
  • 7. IObserable SLIDE (1) – explain the pattern [Ctrl+6] Add data class [Ctrl+7] Add the provider class [Ctrl+8] Add the subscriber class [Ctrl+9] Add the code to the main method GPSSensor sensor = new GPSSensor(); Map map = new Map(); sensor.Subscribe(map, ConsoleColor.Red); //Map map2 = new Map(); //sensor.Subscribe(map2, ConsoleColor.Yellow); do { sensor.GetPosition(); Thread.Sleep(1000); } while (map.StillTracking); Uncomment to show second subscriber SxS Slide (1) – Explain the issue Switch to VS with loader demo. Tour the code start with the two assemblies, point out versions they are compiled to and what they do. Now show the Loader app and show the version (3.5). Show the code and point out that with reflection we are loading it – remind the audience to remember this stuff for later Run the app and note it points out v2 NOT 3.5 – cause the CLR hasn’t changed since 2. Click the run 3.5 assembly – works. Click run 4 assembly and note the exception. Now change the assembly version of loader to 4. and do stesp 4 and 5 again and it works! PIA Slide(1) – Explain what PIA is. Problems – rediretibution and size of distributable Go to VS [ALT +1 ] Add the count down method private static void CountDown() { Console.WriteLine("3..."); Thread.Sleep(1000); Console.WriteLine("2..."); Thread.Sleep(1000); Console.WriteLine("1..."); Thread.Sleep(1000); }
  • 8. Add reference to Microsoft.Office.Interop.Excel – add version 14. Properties of the assembly and make sure embed is off. [ALT + 3] Add code to main method and talk through. Since it is automation explain the count down. Run and move back. Go to binary and drag into reflector – point out that it is listed under references which means shipping it. Go back to VS and change the assembly to embed. Build and demo to show it still works. Refresh reflector and show it has moved from references to actually embedding it into the project. Code Contracts [ALT + 4] Show the code and explain how the zune works out dates. [ALT + 5] Add code to call it in the main intdayInYear; intyear = ZuneDate.YearSince1980(300, out dayInYear); Console.WriteLine("It's the {0} day of {1}", dayInYear, year); Now change day to: 10593 and explain the bugon Dec 31 2008 [ALT + 6] – fully updated loop Add to start of loop: intdaysAtStart = daysLeft; Add to end of loop: Contract.Assert(daysLeft < daysAtStart); Now project and enable static code contract checking and build Point out the unproven issue – saying it thinks that there is a scenario that could fail [ALT + 7] Add the else to verify and build else { Contract.Assert(false); } It is the problem – so lets deal with it [ALT +8] Change the else contents to then build and show no errors. Now show dayInYear= 366; return year; Change day to -1 and show it doesn’t make sense. [ALT+9] Add to start of check: Contract.Requires(daysSince1980 > 0); Build and show how it identifies it – that is preconditions. Leave for now. [Ctrl+Alt+1] Add post conditions: Contract.Ensures(Contract.ValueAtReturn<int>(out dayInYear) > 0); Contract.Ensures(Contract.ValueAtReturn<int>(out dayInYear) < 367); Run and show that the code doesn’t fail even though our condition is not enforces the check. Pop into reflector and show that those conditions aren’t there. Turn on runtime checking and build and run – not the failure. Pop into reflector and show the code now and show the new code which has been added to the start and end! Mention sandcastle documentation tool support too
  • 9. MEF Show folder with Movies project in it and run it. Add in the files we removed during the setup and run again. Remind people of reflection we saw before. Switch to VS with Movies Project and tour the code/ Explain we have an interface Show a provider implements it and is attributed with export. Show code of form and show the ImportMany attribute and talk about the initialisation (Catalog, container, and then we can loop over it). Parallel Open Task Manager Slides (1) – explain enhancements in parallel and why it is important Show hunt button code and explain that change it [Ctrl+Alt+2] Parallel.ForEach(movieProviders, movieProvider => { HighlightProvider(movieProvider, HighlightState.Searching); IEnumerable<MovieInfo> movies = movieProvider.Search(MovieNameTextBox.Text); HighlightProvider(movieProvider, HighlightState.Loading); AddRange(results, movies); HighlightProvider(movieProvider, HighlightState.None); }); Run and show in parallel Go to IMDB provider and show the LINQ query and explain that could also be parallele. [CTRL+ALT+3]: varmatchedLines = from l in File.ReadLines("movies.list").AsParallel() Build and show improvement (if any) Location Switch to location demo and tour that code and demo. PRAY
  • 10. All the small things <demo/>
  • 11. IObservable Update Publisher Data Data Data Subscriber Subscriber Subscriber
  • 13. In-process side-by-side (SxS) 2.0 addin 3.0 addin 3.5 addin 4.0 addin .NET 4.0 .NET 3.5 .NET 3.0 .NET 2.0 Host Process (eg: Outlook)
  • 14. In Process SxS <demo/>
  • 15. Primary Interop Assemblies (PIA) .NET Meta Data (Headers) PIA COM Helper classes
  • 17. Tour of .NET 4 Part 2 <demo/>
  • 18. Parallel PLINQ Task Parallel Library .NET Framework ThreadPool Thread OS
  • 21. Location Windows 7 only Status will be Disabled for other platforms Geosense for Windows http://geosenseforwindows.com/
  • 22. Is this everything? Support for Teredo All the new security enhancements in networking Garbage Collection Improved New ways to detect 64bit OS’s and processes Improvements to System.Enviroment Ngen Improved Memory Mapped Files New File and Directory Enumeration options based on generics Tuples F# New options for performance monitoring which are not invasive Improved parsing for GUID New helper method for Thread Improvements for Registries New helper method for Monitors Better stream compression options New helper methods for UIntPtr and IntPtr New helper method for System.IO.Path New helper method for Streams New helper method and parsing options for Enum New helper method for StopWatch New helper method for StringBuilder System.Numerics.Complex TimeSpanParsing Improvements String Improvements
  • 23. Future? http://bcl.codeplex.com BigRational LongPath PerfMonitor TraceEvent
  • 24. Questions and Answers Reminder: www.sadev.co.za <questions/>
  • 25. We Want To Hear From You! Connect with Microsoft South Africa's Developer & Platform Group blogs.msdn.com/southafrica twitter.com/msdevsa Microsoft DevsSA Required Slide
  • 26. Required Slide Win a Wireless Entertainment Desktop 8000! Complete your evaluation and enter to win!
  • 27. Submit an Entry Form at the BB&D Stand and Win*!A Dell Netbook valued at R4,000 * Terms & conditions apply
  • 28. © 2010 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.

Editor's Notes

  1. Size of app 15kbSize of excel interop 1.5Mb
  2. BigRationalBigRational builds on the BigInteger introduced in .NET Framework 4 to create an arbitrary-precision rational number class.Long PathThis library provides functionality to make it easier to work with paths that are longer than the current 259 character limit.PerfMonitorPerfMonitor is a command-line tool for profiling the system using Event Tracing for Windows (ETW). PerfMonitor is built on top of the TraceEvent library.TraceEventAn library that greatly simplifies reading Event Tracing for Windows (ETW) events.