VSM Cover Story

Visual Studio 2008 Kicks Off

Visual Studio 2008 is all about integrating new .NET Framework 3.x Web and smart-client technology, increasing developer productivity, and managing the application lifecycle. Find out how VS 2008's greatly expanded feature set and new .NET Fx 3.5 namespaces can boost your career as a professional developer and add to your programming enjoyment.

Technology Toolbox: C#, ASP.NET, XML

When Visual Studio 2008 officially launches on Feb. 27, 2008, the fourth iteration of Microsoft's flagship development environment and .NET Framework 3.x will have gone through a three-plus year gestation period. Some industry pundits claim that the Redmond elephant labored mightily and brought forth a mouse; others see VS 2008 as an optimum combination of new technology integration with improved developer productivity.

I've tested every pre-beta, community technical preview (CTP), and beta version of VS 2008--code-named "Orcas"--as well as the early previews of Language Integrated Query (LINQ) extensions for VS 2005, and I'm convinced that the nay-sayers are misguided: VS 2008 is a must-have release for all professional .NET developers and hobbyists alike. JavaScript IntelliSense, type inference and debugging, nested master Web pages, C# 3.0 and VB 9.0 language enhancements, and Windows Communication Foundation's self-hosted services are enough to convince me.

I'll give you an overview of what's new in VS 2008, brief descriptions of the more important new features and why I think they're important, and outline the new platform's forthcoming attractions in the article, "Visual Studio 2008: The Road Ahead." I also point out some loose ends in "Visual Studio 2008: Missing in Action."

Microsoft spawned a plethora of new, complex technologies in the Orcas beta timeframe. .NET Framework (Fx) 3.0 (formerly WinFX) delivered Windows Communication Foundation (WCF) for supporting service-oriented architecture (SOA), Windows Presentation Foundation (WPF) and XML Application Markup Language (XAML) for declaratively programming dazzling user interfaces, Windows Workflow Foundation (WF) for orchestrating business processes, and CardSpace (formerly InfoCard) for user identity management. .NET Fx 3.5 incorporates ASP.NET Asynchronous JavaScript and XML (AJAX) extensions--formerly code-named "Atlas"--for improving the Web client UI.

Microsoft Research dreamed up the C-Omega (Cw) language, which morphed into LINQ and the most recent Common Language Runtime (CLR) language, F#, for functional programming. The forthcoming members of the Dynamic Language Runtime (DLR)--IronPython now, IronRuby shortly, and Visual Basic 10 later--supplement the CLR with loosely typed, late-bound programming. Silverlight 1.1 promises "rich internet applications" with WPF UIs, the .NET Fx 3.5 Core library, AJAX, and VB, C#, IronPython, and IronRuby (see Additional Resources on p. 27). You can find more detailed information on the new C# 3.0 and VB 9.0 language features in the C# Corner and On VB columns, respectively. You can also learn more about what's new with mobility and the Compact Framework in the sidebar "Inside Mobility."

Catch VS 2008's UI Changes
VS 2008 integrates all these technologies (plus at least as many more that aren't included in the preceding laundry list) into a UI provided by a single framework called the Visual Studio 2008 Shell. Other development tool vendors can use the royalty-free Shell to integrate their products with VS 2008 or redistribute it with stand-alone tools that run in "isolated mode."

There are relatively few obvious changes to the VS 2008 UI. The first you'll probably notice in VS 2008 Professional Edition or higher is the added Test command in the menu bar. VS 2008 Pro integrates an automated unit testing environment that implements most features offered by Visual Studio Team System (VSTS) 2008 Test edition (for a complete list of VS 2008 SKU names, see "It Comes in Many Shapes and Sizes"). When you autogenerate a test suite for an existing assembly, reflection produces a test stub named for each class and method, sets up parameter values, instantiates the class, calls each method, saves the result as the actual value, and asserts equality of the actual with the expected value that you supply.

To test-drive a unit test project, create a new project, select the Project Type list's Test node for C# or VB, rename TestProject1 to an appropriate ProjectName for your assembly, and click on OK to create the test project. Right-click on the ProjectName node, choose Add, and select Unit Test to open the Create Unit Test dialog. Next, click on the Add Assembly button, navigate to and double-click on a compiled assembly, expand the tree view of the classes you want to test, and mark the check box to test their methods (see Figure 1). Click on OK to generate the test project with an individual ClassName Test.cs or ClassName Test.vb class file for each class your project defines. Press F5 to build and run the tests and display the results in VS 2008's lower pane (see Figure 2). Autogenerating the test code is a major productivity boost because you usually need only minor tweaks to make the tests operative. Another plus:

The unit testing feature also works with Windows Compact Framework projects.

If you're using VSTS 2008 Developer Edition or Team Suite, you'll also see a new Analyze command that replaces and extends VSTS 2005's Tools | Performance command's Profiler features. The two new editions add a Code Metrics command that opens a new tool window for obtaining an overview of the "health" of your applications and aids in locating hard-to-maintain and/or complex-code hotspots. Code Metrics for Visual Studio 2008 ships with Cyclomatic Complexity, Depth of Inheritance, Class Coupling, Lines of Code, and Maintainability Index metrics. Future VSM articles will cover VSTS 2008; additional new VSTS features are beyond the scope of this article.

The proliferation of new Project Types and Templates in the expanded New Project dialog reflects the addition of .NET Fx 3.0's WPF, WCF, and WF technologies and the integration of the Fx 3.5 version of ASP.NET AJAX with VS 2008. Downloading and installing the optional AJAX Controls Toolkit adds 34 AJAX-enabled client-side controls to the Toolbox. The New Project dialog is where you set the latest .NET Fx version that your project requires (see Figure 3) to take advantage of VS 2008's new multi-targeting feature. The capability to set the appropriate .NET Fx version from the drop-down list eliminates the necessity to keep both VS 2005 and VS 2008 on your development machines. It also means that clients don't have to download frameworks that aren't required by their applications.

You specify the target .NET Fx version when you upgrade VS 2005 or earlier projects to VS 2008 with the migration wizard; you also can specify the version on the Project Properties page. VS 2008 upgrades the integrated FxCop code analysis tool to issue warnings if you target your code to .NET Fx 2.0 and you call any red bits. Red bits are .NET Fx 2.0 assemblies that versions 3.0 or 3.5 modified to enable multi-targeting in a single release, while Green bits are assemblies that were added either in the version 3.0 or 3.5. You'll probably be hearing a lot of noise about red and green bits as more developers adopt VS 2008's multi-targeting feature.

Another new UI feature becomes evident when you create your first ASP.NET Web form: You can split the Designer's display horizontally to display the graphical layout and code by clicking on the Split button at the bottom of the window. You won't find the new Cascading Style Sheets (CSS) properties window unless you choose the View | CSS Properties menu command (see Figure 4). There's also a new Manage Styles window that displays the CSS and rules for the page you're editing in Source, Split, or Design view. However, VS 2008's new nested master pages capabilities and JavaScript IntelliSense/debugging probably will vie for the title of ASP.NET aficionados' favorite new feature.

VS 2008's WPF designer--better known by its former code name "Cider"--appears when you select the WPF Application, WPF Browser Application, WPF User Control Library, or WPF Custom Control Library template from the Windows Project Type's list (see Figure 5). If you've installed the Microsoft Silverlight Tools for Visual Studio 2008 add-in, you can edit XAML content for Silverlight in the WPF Designer, but Expression Blend is a much better choice for graphic artists. Future VSM articles will throw the spotlight on this new technology.

Take Advantage of New Integrated Features
VS 2008's WCF implementation increases developer productivity by supplying stubs for required interfaces and classes, as well as by generating a default app.config file for a SOAP service that implements WS-* security. Selecting the WCF Project Type and WCF Service Library template autogenerates code for Public Interface IService1 that's decorated with a <ServiceContract()> attribute, as well as <DataContract()>Public Class CompositeObject with <DataMember()>Public Property BoolValue As Boolean, and <DataMember()>Public Property StringValue As String stubs for defining your service. Selecting WCF Syndication Service adds this interface stub for Atom 1.0 and RSS 2.0:

<ServiceContract()> _
<ServiceKnownType(GetType( _
	Atom10FeedFormatter))> _
<ServiceKnownType(GetType( _
	Rss20FeedFormatter))> _
Public Interface IFeed1
	<OperationContract()> _
	<WebGet(UriTemplate:="*", _
		BodyStyle:= _
		WebMessageBodyStyle.Bare)> _
	Function CreateFeed() As _
		SyndicationFeedFormatter(Of _
	' TODO: Add your service operations here
End Interface

The autogenerated Public Class Feed1 and Public Function CreateFeed() As SyndicationFeedFormatter(Of SyndicationFeed) stubs each implement IFeed1. .NET Fx 3.5 adds Atom, RSS, and JSON serialization.

Managing human-computer interaction with workflows is a new discipline for most Windows developers. .NET Fx 3.0 delivered the current Workflow Runtime and Workflow Designer. VS 2008 integrates the runtime into templates and the Designer into the UI for hosting in Workflow projects and libraries (see Figure 6). .NET Fx 3.5 lets you expose workflows as WCF services in projects you create from the Sequential Workflow Services Library or State Machine Services Library templates in the WCF Project Type category. Programming workflows for SharePoint document libraries is a particularly hot topic at present. Workflow deserves more coverage than this article permits, so watch for articles dedicated to WF in future VSM issues.

Visual Studio Tools for Office (VSTO) was an expensive add-in for early versions of VS, but Visual Studio 2005 Tools for the Office 2007 System (VSTO 2005 SE) became a free download for VS 2005 Professional Edition or higher in November 2006. The VS 2008 Pro or Team Systems Setup program installs VSTO 2008, but you won't see an Office Project Type and its VSTO templates unless you have Office 2003 or 2007 installed. You can develop only for the Office version you've installed on your development machine running VS 2008. New VSTO features in VS 2008 include the capability to customize Word and Excel documents, create sequential or state machine workflows for SharePoint, customize the Office 2007 Ribbon, structure documents with Word content controls, extend Outlook forms with importable custom form regions, and create custom task panes.

Opening the Add New Item dialog displays several new or renamed templates. For example, new items for Windows forms include Local Database Cache, which opens a Configure Data Synchronization designer for creating a local SQL Server 2005 Compact Edition (SSCE) 3.5 database and a DataBase .sync file to enable synchronization with the SQL Server 200x [Express] database you specify. The Local Database Cache takes advantage of Sync Services, a member of the new Microsoft Synchronization Framework, to enable your app to implement the SQL Server Data Programmability Team's Occasionally Connected Systems architecture (see Resources).

Other data-related enhancements include the DataSet.DataTableManager component, which will save programmers who use DataSets many hours of manual coding and testing. In a nutshell, the component orchestrates updates to the underlying database tables when you invoke the DataSet.SaveChanges method. The SqlClient data provider has been updated to support SQL Server 2008's table-valued parameters and date, time, datetime2, and datetimeoffset datatypes, as well as the new T-SQL MERGE command that lets you combine INSERT, UPDATE, and DELETE operations into a single statement.

Grok .NET Language Enhancements
Spoken languages are living, growing entities. The Oxford Dictionary of New Words has cataloged more than 2,500 new words and phrases added to the English language and popularized since the late 1980s. Similarly, Visual Studio's programming languages are expanding their vocabularies at an ever-increasing pace. VS 2005 added partial classes, generic and nullable types, and the Using/using keyword to guarantee resource disposal to C# and VB. C# 2.0 gained refactoring, iterators, and anonymous and static classes. VB 8.0 introduced the Continue statement for loops, the IsNot operator shortcut, the TryCast() method, operator overloading, unsigned integers, and custom events. But these few additions pale in comparison to the myriad of new language features introduced by VS 2008's C# 3.0 and VB 9.0. Kathleen Dollard's C# Corner column on p. 58 gives you the lowdown on additions to C# 3.0, while Bill McCarthy's On VB column (p. 50), spells out new VB 9.0 features. Implementing LINQ provided the impetus for almost all new C# 3.0 and VB 9.0 language features; the On VB and C# Corner columns describe LINQ to Objects, the fundamental link implementation for querying in-memory collections and their members.

VS 2008 includes three custom LINQ implementations: LINQ to SQL (originally DLinq), LINQ to XML (formerly XLinq), and LINQ to DataSets. These implementations extend LINQ to Objects with domain-specific features. A fourth LINQ flavor, LINQ to Entities, is part of the Entity Framework that's scheduled to release as an add-in around the date of SQL Server 2008's release to manufacturing (see "Visual Studio 2008: Missing in Action," p. 28). All four LINQ APIs use the same query syntax and Standard Query Operators, which demonstrate the universality of the LINQ query language.

LINQ to SQL is an object/relational mapping (O/RM) tool and data access layer (DAL) that persists in-memory business objects to SQL Server 200x [Express] and SSCE 3.5 databases (see the "Go Online" section on p. 27 for details). LINQ to SQL comes with a command-line mapping tool, SqlMetal.exe, which generates entity classes and their associations from database tables and relationships. Most developers use the graphical O/R Designer that you bring up by adding a LINQ to SQL Classes template from the New Item dialog to a project, class library, or Web site. You expand the Server Explorer's SQL Server connection node for your database and drag table nodes to the designer's surface to add entity class widgets for each table. Lines between object properties that correspond to primary and foreign key fields represent associations between entities (see Figure 7). LINQ to SQL increases productivity by enabling developers to quickly substitute a DAL with strongly typed business entities for conventional typed or untyped DataSets.

LINQ to DataSets lets you substitute typed or untyped datasets for in-memory collections or business entities from SQL Server tables as the data source for LINQ queries. You can sort or filter a DataSet's DataTable objects, and you can query or join them. LINQ to DataSets enables complex queries against joined DataTables and emulates DataSet views. You also can create a DataTable with a LINQ to DataSets query by invoking the Query.CopyToDataTable<DataRow> method and then databind it to a BindingSource or directly to a DataGridView.

LINQ to XML is a LINQ implementation for querying and generating XML documents and fragments that can substitute for the more complex XPath and XQuery languages, and XSL/T transformations in most cases. LINQ is unique in its ability to join XML documents with business entities and in-memory objects to produce a queryable data source. In most cases, the query output is an XML fragment. VB has the unique capability to generate XML content from a combination of literal XML tags and values supplied by replacing <%= Query.Property %> with the results of a LINQ query. For example, consider this query:

Dim xml As XElement = _
	<%= From o In OrderList _
		Where o.ShipCountry = _
		"USA" And o.ShippedDate >= _
		"1/1/1996" Select _
		<order orderId=<%= o.OrderID %>>
	<custId><%= o.CustomerID %></custId>
	<orderDate><%= o.OrderDate %></orderDate>
	<shipDate><%= o.ShippedDate %></shipDate>
	</order> %>

Running the query returns this (abbreviated) XML fragment:

	<order orderId="10262">
	<order orderId="10346">

In addition to the ASP.NET AJAX, JavaScript, and UI features mentioned earlier, Web developers get integration with Windows Server 2008's IIS 7.0, nested master pages, a ListView data control with an easily customizable UI, the LinqDataSource control to simplify binding LINQ to SQL queries to GridView and other databound controls, Aspnet_merge.exe for merging precompiled assemblies and server-based forms authentication, roles management, and profile services exposed as Web services. The SQL Database Publishing Wizard is integrated into VS 2008's Setup program. Microsoft's willingness to expend resources to enhance open source software, such as the new dynamic languages and the SubSonic toolkit for the ASP.NET MVC add-in, is an encouraging sign to most developers.

The rallying cry at Microsoft has changed from "Developers! Developers! Developers!" to "Integration! Integration! Integration!" The VS Team appears to have integrated everything but the kitchen sink into VS 2008, which threatens to overload developers with the learning curves for new technologies or products that Microsoft brands as foundations or platforms. VS 2008 marks the turning point where few, if any, developers can claim to be masters of all .NET technologies, frameworks, and platforms. On the other hand, VS 2008 appears to me to include enough productivity enhancements that it's practical for the majority of .NET developers to become masters of the majority.

comments powered by Disqus
Upcoming Events

.NET Insight

Sign up for our newsletter.

I agree to this site's Privacy Policy.