12. New Visual Studio 2010 Features… Generate From Usage HTML Snippets Breakpoint Grouping Parallel Tasks Window New Look & Feel Extensible Test Runner Dynamic Data Tooling Click-Once Enhancements for Office Highlight References WPF-based Editor Breakpoint Labeling MVC Tooling Call Hierarchy Improved WPF Tooling Sharepoint Tooling Historical Debugging Web Deploy Inline Call Tree Quick Search Concurrency Profiler Breakpoint Import/Export Document Map Margin 64-bit Mixed-Mode Parallel Stacks Window Minidump Debugging Improved Multi-Monitor JQueryIntellisense web.config Transformation
13. What’s changed in VS.NET? Full WPF IDE (including code editors) Multi-targeting Frameworks: 2.0, 3.0, 3.5, 4.0 General: F# development F# Explorer No dynamic help No object test bench Design Time: Call Hierarchy Explorer Generate from usage Live semantic errors Intellisense Completion vs. Suggestion Mode
14. What’s changed in VS.NET? (Cont.) Enhanced editors and project templates. ASP.NET WPF Silverlight WYSIWYG Editors Entity Framework Architecture Modeling UML Editors Debugging Intellitrace
15. What’s changed in VS.NET? (Cont.) Extensibility Extension Manager MEF
16. Highlighting References CTRL+SHIFT+DOWN ARROW (forward) CTRL+SHIFT+UP ARROW (reverse) Automatic highlighting of a symbol Can be used with declarations, references, and many other symbols
17. Navigate To CTRL + , Provides search-as-you-type support for symbols Enables quick searching based on case usage
18. Docking Windows New Guide Diamond Windows can be docked anywhere Can now pull document windows outside the IDE
19. Call Hierarchy (C# only) CTRL + K, T Used to see calls to and from a method Great way to see calls at design time
20. Zoom CTRL + Mouse Wheel New feature that enhances the size of your code Very useful for pair programming (or similar scenarios)
21. Generate from Usage Used to automatically create stub code Enables you to use classes and members before you define them
22. Intellisense Suggestion Mode CTRL + ALT + SPACE Used when classes and members are used before they are defined Helps to reduce situations where IntelliSense inserts unintended text into the editor
23. Breakpoints Can add labels to breakpoints All breakpoints are now searchable Import / Export now available
28. Base Class Library Core types and services Common Language Runtime Assembly load and execution
29. Base Class Library Improvements Numerics BigInteger, Complex Data Structures Tuple SortedSet<T>, ISet<T> I/O Memory-Mapped File Unified Cancellation Model
30. .NET 4.0 New Runtime First new .NET runtime since 2.0 Side by Side Execution Functional Programming – F# Moving towards language parity – C#/VB Dynamic Language Runtime(DLR) Co- and Contra- Variance Code Contracts Parallel Computing
31. From There to Here… SP1 3.5 3.0 .NET 1.0 .NET 1.1 .NET 2.0 .NET 4 2002 2003 2010 2005-08 CLR 1.0 CLR 1.1 CLR 2.0 CLR 4
33. Functional Programming – F# F# is a functional programming language that runs on top of .NET Function is a first class citizen of a program General PurposeLanguage Important domains Scientific data analysis, data mining, domain-specificmodeling,… open System.IO openSystem.Collections.Generic letreadAllLines(file) = useinp = File.OpenText file let res = new List<_>() while not(inp.EndOfStream) do res.Add(inp.ReadLine()) res.ToArray()
41. Optional and Named Parameters Optional parameters publicStreamReaderOpenTextFile( string path, Encodingencoding, booldetectEncoding, intbufferSize); publicStreamReaderOpenTextFile( string path, Encodingencoding = null, booldetectEncoding = true, intbufferSize = 1024); Named argument OpenTextFile("foo.txt", Encoding.UTF8); OpenTextFile("foo.txt", Encoding.UTF8, bufferSize: 4096); Arguments evaluated in order written Named arguments can appear in any order Named arguments must be last OpenTextFile( bufferSize: 4096, path: "foo.txt", detectEncoding: false); Non-optional must be specified
45. Ceremony in C# 3.0 Ugly COM Interop and the ever-present “ref Missing.Value” var word = newWord.Application(); word.Documents.Add(ref Missing.Value, ref Missing.Value, ref Missing.Value, ref Missing.Value);
49. Ceremony in VB 9 Backing fields for properties are explicit Privatem_nameAs String Public Property Name() As String Get Name = m_name End Get Set(ByValvalueAs String) m_name = value End End Property
50. Ceremony in VB 9 Popularity of lambda-based libraries cause problems for VB developers SubMyMethod() LambdaCall(Function(i) TempMethod(i) End Function) End Sub FunctionTempMethod(ByValparamasInteger) As Object Console.WriteLine(param) Return Nothing End Function Introduction of temporary functions “Hacks” since statement lambdas not supported
51. Ceremony in VB 9 Line continuations must be specified by the developer SomeLongMethodCall(firstParam, _ secondParam, _ thirdParam, _ fourthParam, _ fifthParam)
52. Ceremony in VB 9 Creating collections takes a lot of code Dimnames = NewList(Of String) names.Add("Jason") names.Add("Drew") names.Add("Jonathan")
59. Ceremony in C# 3.0 Dynamic Language interop is painful Calculator calc = GetCalculator(); int sum = calc.Add(10, 20);
60. Ceremony in C# 3.0 Dynamic Language interop is painful object calc = GetCalculator(); TypecalcType = calc.GetType(); object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 }); int sum = Convert.ToInt32(res);
61. Ceremony in C# 3.0 Dynamic Language interop is painful ScriptObject calc = GetCalculator(); object res = calc.Invoke("Add", 10, 20); int sum = Convert.ToInt32(res);
62. Essence in C# 4.0 Dynamic Language interop doesn’t have to be painful! Statically typed to be dynamic dynamic calc = GetCalculator(); int sum = calc.Add(10, 20); Dynamic method invocation Dynamic conversion
63. Dynamically Typed Objects Calculator calc = GetCalculator(); int sum = calc.Add(10, 20); object calc = GetCalculator(); TypecalcType = calc.GetType(); object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, newobject[] { 10, 20 }); int sum = Convert.ToInt32(res); ScriptObject calc = GetCalculator(); object res = calc.Invoke("Add", 10, 20); int sum = Convert.ToInt32(res); Statically typed to be dynamic dynamic calc = GetCalculator(); int sum = calc.Add(10, 20); Dynamic method invocation Dynamic conversion
67. Dynamic Language Runtime Provides a common implementation and interoperation substrate for dynamic languages, similar to what the Common Language Runtime and Common Type System provide for statically typed languages Developed for IronPython and IronRuby Included in .NET 4.0 as part of the runtime and type system (e.g. C# 4 knows about the DLR IDynamicObject convention)
71. Co- and Contra-variance .NET arrays are co-variant string[] strings = GetStringArray(); Process(strings); …but not safelyco-variant void Process(object[] objects){ … } void Process(object[] objects) { objects[0] = "Hello"; // Ok objects[1] = newButton(); // Exception! } Until now, C# generics have been invariant List<string> strings = GetStringList(); Process(strings); C# 4.0 supports safe co- and contra-variance void Process(IEnumerable<object> objects) { // IEnumerable<T> is read-only and // therefore safely co-variant } void Process(IEnumerable<object> objects) { … }
72. Safe Co- and Contra-variance publicinterfaceIEnumerable<out T> { IEnumerator<T> GetEnumerator(); } out= Co-variantOutput positions only Can be treated asless derived publicinterfaceIEnumerator<out T> { T Current { get; } boolMoveNext(); } IEnumerable<string> strings = GetStrings(); IEnumerable<object> objects = strings; in= Contra-variantInput positions only publicinterfaceIComparer<in T> { int Compare(T x, T y); } Can be treated asmore derived IComparer<object> objComp = GetComparer(); IComparer<string> strComp = objComp;
73. Generic co- and contravariance If T appears only as an output, it’s safe to passX<TDerived> for X<T> We call this covariance If T appears only as an input, it’s safe to passX<TBase> for X<T> We call this contravariance
74. Fixing The Type System… Covariance and Contravariance… sounds complicated… But it’s not! sort of…
75. Fixing The Type System… How are generic types “broken” today? class Animal { } class Sheep : Animal { } void Speak(IEnumerable<Animal> animals) { // Do something with Animals } Not Allowed: IEnumerable<Animal> != IEnumerable<Sheep> var sheep = new List<Sheep>(); Speak(sheep);
79. Design By Contract Code Contracts introduce a way to specify contractual information that is not represented by a method or type’s signature alone.
80. Code Contracts What does it expect? (Preconditions) Contract.Requires() What does it guarantee? (Postconditions) Contract.Ensures() What does it maintain? (Invariants) Contract.Invariant()
81. A Contract contains… Pre-conditions - must be true before public Rational(int numerator, int denominator) { Contract.Requires(denominator > 0); … } Post-conditions - must be true after public string GetPassword() { Contract.Ensures(Contract.Result<string>() != null); … return password; }
82. A Contract contains… Invariants - must always be true [ContractInvariantMethod] protectedvoidObjectInvariant() { Contract.Invariant(denominator > 0); }
83. Let’s Fix It For Once And All! Design-by-Contract meets .NET! stringGetDescription(intx) { Contract.Requires( 0 < x ); Contract.Ensures(Contract.Result<string>()!=null); … }
96. Additional operators for parallel operationsfrom n in names.AsParallel().WithDegreeOfParallelism(ProcessorsToUse.Value) where n.Name.Equals(queryInfo.Name, StringComparison.InvariantCultureIgnoreCase) && n.State == queryInfo.State && n.Year >= yearStart && n.Year <= yearEnd orderbyn.Year ascending select n;
97. Declarative Data Parallelism Parallel LINQ-to-Objects (PLINQ) Built on top of Tasks Enables LINQ devs to leverage multiple cores Fully supports all .NET standard query operators Minimal impact to existing LINQ model var q = from p in people wherep.Name == queryInfo.Name && p.State == queryInfo.State && p.Year >= yearStart && p.Year <= yearEnd orderbyp.Yearascending select p; .AsParallel()
98. Structured Parallelism Parallel class static (overloaded) methods helper methods to create/work with Tasks encapsulates common patterns
101. Managed Extensibility Framework? The Managed Extensibility Framework (MEF) is a new libraryin the .NET Framework that enables greater reuse of applications and components. Using MEF, .NET applications can make the shift from being statically compiled to dynamically composed
111. Conclusion Visual Studio 2010 and .NET 4.0 is a major release Essence vsCeremony Generic types are no longer “broken” Design by Contract Parallel Developmentbecomes easy
Editor's Notes
About me
One of the coolest new features that you don’t have to do anything to get: Reference Highlighting. When you click on a symbol (variable name, method name, etc…) the IDE will automatically highlight all the references to that symbol.The best part is you can navigate between the highlighted references! NOTE: For demo info, go here-> http://blogs.msdn.com/zainnab/archive/2010/01/18/how-to-use-reference-highlighting.aspx
Menu: Edit -> Navigate ToThe new Navigate To dialog allows you to search for symbols by narrowing the search as you type. But it doesn’t stop there! If you use Pascal Case for your symbols then you can use just the upper-case letters to search.NOTE: For demo info, go here-> http://blogs.msdn.com/zainnab/archive/2010/01/20/how-to-use-navigate-to-vstiptool0006.aspx
The docking guides are very much improved over the previous experience with an updated Guide Diamond. But that’s not the best part…You can NOW FINALLY pull document windows out of the IDE! NOTE: This demo is very straightforward simply dock and undock windows then pull a document tab out of the IDE.
For the C# folks this is one heck of a great tool: Call Hierarchy. It allows you to "visualize all calls to and from a selected method, property, or constructor". To see how it works just right-click on any method, property, or constructor in the Editor and select View Call Hierarchy.It not only allows you to visualize calls To and From but you can Go to references, copy code, and even rearrange the view in the hierarchy.NOTE: Normally you can just stick to right-clicking a method in C# and choosing NOTE: For demo info, go here-> http://blogs.msdn.com/zainnab/archive/2010/01/19/using-the-call-hierarchy-c-only-vstiptool0005.aspx
This is the first of the set of enhancements for agile programming. In pair programing scenarios, you often have two people looking at one set of code at the same time. When you want to focus in on a set of code to make it easier to read you can now just use CTRL + Mouse Wheel to zoom your text.NOTE: This demo is very simple just show zooming behavior. Pair programming is the reason given here but this is also very useful for just making code easier to read when you need it.
The idea behind this feature is simple, it allows you to use classes and members before you define them. Why would you want to do that? Well, Test Driven Development folks like to use classes and members before we create them. There are a lot of reasons for this we won’t go into here but this is an awesome new feature for TDD.NOTE: For demo info, go here-> http://blogs.msdn.com/zainnab/archive/2010/01/21/using-generate-from-usage-vstipedit0011.aspx
In the last demo you may have noticed that Intellisense kicked in. This can be annoying sometimes if you accidentally use one of its suggestions instead of what you meant to type. For this situation we now have Suggestion Mode. By hitting CTRL + ALT + SPACE or going to Edit -> Intellisense -> Toggle Completion Mode. By using this option you can avoid getting unwanted choices.NOTE: This is an easy demo just use the keyboard shortcut or menu option to enable Suggestion Mode. The hardest part here is getting people to understand why they would want to use it. Agile developers will mostly get it while most others will not so be prepared to have offline discussions for those interested.For demo info, go here-> http://blogs.msdn.com/zainnab/archive/2010/01/22/intellisense-suggestion-mode-vstipedit0012.aspx
Breakpoints have undergone some MAJOR improvements to make your life easier. Most notably you can now add labels, search breakpoints, and even do import/export tasks.NOTE: For demo info, go here-> Labels: http://blogs.msdn.com/zainnab/archive/2010/01/26/adding-labels-to-breakpoints-vstipdebug0001.aspxSearching (avail 1/27): http://blogs.msdn.com/zainnab/archive/2010/01/27/searching-breakpoints-vstipdebug0002.aspxImport/Export (avail 1/28): http://blogs.msdn.com/zainnab/archive/2010/01/28/how-to-import-and-export-breakpoints-vstipdebug0003.aspx
DataTips are now like a Super Quick Watch. They can be pinned to source, have comments, and tell you values.NOTE: See the demo doc (Pin a DataTip to source.docx) for a sample demo.
WPF BasedEditorCode Editing & Navigation(QuickSearch, CallHierarchy, …)IntellisensesuggestionvscompletionExtension ManagerBreakpoints and labels SuperQuickwatchDebug export and import datatipsCleanupweb.configJqueryintegrationJqueryIntelisenseHtml snippetsGeneratedependencygraph Beginnen met VS2010TrainingKit demo
Before we get started, I thought it would be a good idea to review where we have come from:In the past we have delivered monolithic releases. You saw this with .NET versions 1.0 and 1.1 before. When .NET 2.0 shipped we decided to make a “layer cake” of improvements where we added on 3.0, 3.5, and finally 3.5 service pack 1. There were a number of reasons for doing this but chief among them was to make sure you didn’t have to completely retest the CLR every time we incremented it. We did this for about 5 years.You can only keep that system up for so long, however, and 4.0 represents some pretty significant changes and updates to the Framework and the CLR. Because of this we decided to make it stand on its own and have incremented the CLR version accordingly. As such, it will probably have to undergo the testing your security teams have in place and we want to set expectations accordingly. NOTE: This is to make sure folks know the bad news up front. We will use the rest of the session to deliver the good news. Here is where you can find the history of .NET Framework versions: http://en.wikipedia.org/wiki/.NET_Framework_version_list
Optional and named parameters
Optional and named parametersDEMO:Shows how the combination of named and optional parameters combine to allow a developer to write simpler code or to simplify existing code. Use One.SimplifyYourCSharpCode from the LanguagesTenInOne solution.FAQ:[Q] Are optional parameters a compiler feature, or a runtime feature?[A] It is a compiler feature. The value of the optional parameter is compiled into the callsite at compile time. This means that if the value of the optional parameters is changed at a later date and the code isn’t recompiled, you could have code that doesn’t work as you expected and could introduce subtle bugs
Tonen code om word doc te openenProblemen is 1 dat we missing moeten gebruiken voor optionele parameters, 2 dat de elementen van het type object moeten zijnDaarna herschrijven naar simpele PIA call
Use Three.VbLanguageImprovements from the LanguagesTenInOne solution.
Auto-Implemented PropertiesCollection InitializersImplicit Line ContinuationMultiline Lambda Support
DynamicDemoAnd Extra Dynamic DynamicObjectCalling the Random shuffler in IronPython from C# (passing in an IEnumerable<int> generated in C#). Use Two.IronPythonInterop from the LanguagesTenInOne solution.
Tonenstringarray vragen of de assignment zalwerkenTonen stringlist vragen of toewijzing aan Ilist werkt, vragen of toewijzing aan Ienumerable werktHanden laten opsteken(Wie denkt dat dit werkt?)
Eerst zonder tonenDan code contracts toevoegenDan opzetten in compilerTonen in reflector
Microsoft has made a major investment in parallel programming. In Visual Studio 2010 there are major additions that have been made: Task Parallel Library (TPL)Parallel LINQ (PLINQ)Data Structures for Parallel ProgrammingParallel Diagnostic ToolsLet’s look at the TPL:The Task Parallel Library (TPL) is a set of public types and APIs in the System.Threading and System.Threading.Tasks namespaces in the .NET Framework version 4. These types rely on a task scheduler that is integrated with the .NET ThreadPool. The purpose of the TPL is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications.The TPL scales the degree of concurrency dynamically to most efficiently use all the processors that are available. Parallel code that is based on the TPL not only works on dual-core and quad-core computers. It will also automatically scale, without recompilation, to manycore computers.When you use the TPL, writing a multithreaded for loop closely resembles writing a sequential for loop. The following code automatically partitions the work into tasks, based on the number of processors on the computer.NOTE:You definitely want them to know about the Concurrency site on MSDN for parallel programming:http://msdn.microsoft.com/en-us/concurrency/My favorite demo to do here is in the training kit. Just show the parallel and non-parallel code samples:C:VS2010TrainingKitDemosParallelForLoopSourceFor more demos, sample code with links to descriptions and pretty much everything else you need can be found here:http://code.msdn.microsoft.com/ParExtSamplesThere is also a parallel demo in the VS2010 Training Kit that can be found here:C:VS2010TrainingKitLabsParallelExtensionsLab.htmlhtmlDocSet_default.html
Parallel LINQ (PLINQ) is a parallel implementation of LINQ to Objects. PLINQ implements the full set of LINQ standard query operators as extension methods for the T:System.Linq namespace and has additional operators for parallel operations. PLINQ combines the simplicity and readability of LINQ syntax with the power of parallel programming. Just like code that targets the Task Parallel Library, PLINQ queries scale in the degree of concurrency based on the capabilities of the host computer.NOTE:The perfect demo here is the Baby Names example in the VS2010 Training Kit. This thing is just great for showing parallel and non-parallel code as well as visually seeing performance:C:VS2010TrainingKitDemosParallelBabyNamesSource
* TaskDemo:Uitleggen wat we juist gaan doen op elke threadRunPool(); Maaktgebruik van threads op de threadpool traag en weinigcontroleRunThreads(); Maaktexplicietalle threads aan weinig efficientRunTasks(); Systeem beslist zelf wat de optimale hoeveelheid tasks is en maakt er optimaal gebruik van* PLinqDemo:Uitvoeren linq query zonder AsParallelDaarna opnieuw uitvoeren met AsParallel toegevoegd* ParallelDemoUitvoeren nonparallelmethod
Nearly 80% of software development costs is in the maintenance of software.
MESSAGING:So, if a MEF-aware application is built of parts, parts can be thought of as the “heart” of a MEF-aware application. Let’s take a look at a simple Part. In this case, it is a class called SimpleMortgageCalculator that has one dependency it needs satisfied, an ILogger. Let’s see how we would use MEF to declare the needs this part has in order to be composed.
MESSAGING:So, if a MEF-aware application is built of parts, parts can be thought of as the “heart” of a MEF-aware application. Let’s take a look at a simple Part. In this case, it is a class called SimpleMortgageCalculator that has one dependency it needs satisfied, an ILogger. Let’s see how we would use MEF to declare the needs this part has in order to be composed.
MESSAGING:So, if a MEF-aware application is built of parts, parts can be thought of as the “heart” of a MEF-aware application. Let’s take a look at a simple Part. In this case, it is a class called SimpleMortgageCalculator that has one dependency it needs satisfied, an ILogger. Let’s see how we would use MEF to declare the needs this part has in order to be composed.
MESSAGING:Now that we’ve declared all our Imports and Exports, how are they all matched up together? This is the job of the container. The container is the “match maker” if you will. An application will ask the configured container for an object of a given type, then the container will take care of building up the entire object graph and returning the necessary object. All of this matching is handled by the container itself, the user doesn’t have to think about it at all.
* Show MEFGameToon App klasse met AggregateCatalogToon Shape klasse in AdditionalShapes met GameShapeAttribute Leg uit dat deze overerft van ExportAttribute* http://devlicio.us/blogs/derik_whittaker/archive/2009/10/27/simple-kick-start-example-using-mef-preview-8.aspx