Last Week Mike Flasko from the ADO.NET Data Services (Astoria) Team blogged about what’s coming in V1.5 which will ship prior to VS 2010. I applaud these out of band releases.
One of the new features is support for two-way data binding in the client library generated proxy classes. These classes currently do not implement INotifyPropertyChanged events nor project into ObservableCollections out of the box.
Last week at the MVP Summit I had the chance to see a demo of this and other great things coming down the road from the broader Data Programmability Team. It seems like more and more teams are turning to T4 Templates for code generation which is great for our extensibility purposes. At first I was hopeful that the team had implemented these proxy generation changes via changing to T4 templates along with a corresponding “better” template. Unfortunately, this is not the case and we won’t see any T4 templates in v1.5. It’s too bad – would it really have been that much more work to invest the time in implementing T4 templates than to add new switches to datasvcutil and new code generation (along with testing that code).
Anyway, after seeing some other great uses of T4 templates coming from product teams for VS 2010, I thought I would invest some of my own time to see if I couldn’t come up with a way of implementing INotifyPropertyChanged all on my own. The problem with the existing code gen is that while there are partial methods created and called for each property setter (i.e. FoobarChanged() ), there is no generic event fired that would allow us to in turn raise a InotifyPropertyChanged.PropertyChanged event. So you can manually added this for each and every property on every class – but it’s tedious.
I couldn’t have been the first person to think of doing this, and after a bit of googling, I confirmed that. Alexey Zakharov’s post on generating custom proxies with T4 has been completely ripped off, er, inspirational in this derivative work. What I didn’t like about Alexy’s solution was that it completely over wrote the proxy client. I would have preferred a solution that just implemented the partial methods in a partial class to fire the PropertyChanged event. This way, any changes, improvements, etc. to the core MS codegen can still be expected down the road. Of course, Alexey’s template is a better solution if there are indeed other things that you want to customize about the template in its entirely should you find that what you need to accomplish can’t be done with a partial class.
What I did like about Alexey’s solution is that it uses the service itself to query the service meta data directly. I had planned on using reflection to accomplish the same thing but in hindsight, that would be difficult to generate a partial class of a class I’m currently reflecting on in the same project (of course). Duh.
So what do you need to do to get this solution working?
- Add the MetadataHelper.tt file to the project where you have your reference/proxies to the data service. You will want to make sure there is no custom tool associated with this file – it’s just included as a reference in the next one. This file wraps up all the calls to get the meta data I’ve made a couple of small changes to Alexey’s -- Added support for Byte and Boolean (typo in AZ’s).
- Copy the DataServiceProxy.tt file to the same project. If you have more than one data service, you’ll want one of these files for each reference. So for starters you may want to rename it accordingly. You are going to need to edit this bad boy as well.
- There are two options you’ll need to specify inside of the proxy template. The MetadataUri should be the uri to your service suffixed with $metadata. I’ve found that if your service is secured with integrated authentication, then the the metadata helper won’t pass those credentials along so for the purposes of code generation you’d best leave anonymous access on. Secondly is the Namespace. You will want to use the same namespace used by your service reference. You might have to do a Show All Files and drill into the Reference.cs file to see exactly what that is.
var options = new {
MetadataUri = "http://localhost/ObjectSharpSample.Service/SampleDataService.svc/$metadata",
Namespace = "ObjectSharp.SampleApplication.ServiceClient.DataServiceReference"
};
That’s it. When you save your file, should everything work, you’ll have a .cs file generate that implements through a partial class an INotifyProxyChanged interface. Something like…..
public partial class Address : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string property)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(property));
}
}
partial void OnAddressIdChanged()
{
OnPropertyChanged("AddressId");
}
partial void OnAddressLine1Changed()
{
OnPropertyChanged("AddressLine1");
}
}
This past week we saw the final bits of SQL Server 2005 and Visual Studio 2005 get shipped up to MSDN Subscriber Downloads. Next week we'll see the official launch of these same products to the rest of the world, ushered in with a rolling thunder of launch events and parties stretching into the rest of the month and beyond. Microsoft does a great job of fostering community with events like this.
Technically there is a lot to like about the updates to the platform and I share most of Joel's top picks. I've been building applications, consulting and teaching developers on this platform for 4 years now and it feels quite legacy, if not common place, to me now. However, in many peoples' eyes, this becomes a critical moment in time: .NET is no longer a 1.0 product. Of course I'm speaking about groups who are not developing anything significant in .NET today, and with this maturity milestone, allows them into this “new“ world.
We've been watching the adoption and market maturity of .NET closely for the past few years, and a bit to my surprise I'm starting to see a lot of groups come to .NET for the very first time with 2.0.
This coming Tuesday I have the great pleasure of being involved in the ushering in of this new era at the Toronto launch where we are expecting between 3,000 and 4,000 developers and IT professionals come together. Early statistics are showing that somewhere between 35-50% of these folks are new to .NET. Similar events are taking place all over the world during this week and stretching out into December and beyond. For Canada, Toronto is just the first stop in a long list of cities from coast to coast. Personally, I'll be presenting at Toronto, Ottawa, Vancouver, Montreal, Quebec City and Halifax.
The overwhelming registration statics tics in all cities tells me two things: Firstly that .NET 2.0 is going to be adopted very quickly. Secondly, and more importantly, is that the software development industry in Canada is vibrantly growing and that indeed....Software Matters!
Consider two things:
- Software costs a lot of money to design, build, test and deploy. Much more than it should.
- Software projects fail at an alarming rate. Failure can be defined as any of the following: Late, Over Budget, Under Functionality, Buggy, Doesn't meet requirements.
Yet despite these two glaring issues, the business value of software is so compelling, that people are willing to keep investing in building software at increasing rates.
And then there is Visual Studio and SQL Server 2005:
- One of ASP.NET 2.0's design goals was to reduce the number of lines of code in a typical application by over 50%.
- SQL Server 2005 has been enhanced to be more reliable and secure, while at the same time bringing the 4GL productivity associated with C#, VB.NET and the .NET Framework into the database engine itself.
- Visual Studio Team System 2005 was built from the ground up to help project's stay on track by integrating developers, architects, testers, project managers and other stakeholders into a common extensible repository known as Team Foundation Server.
Coincidence? I hope not ;)
Bill Gates gave a pretty typical high level keynote to introduce the keynote this morning. He talked about the past, how far we've come, and how now is the most exciting time, and that we are in most exciting industry. Not that I don't disagree, but I swear I've heard this keynote before.
After Bill, a series of VP's and Architect's ran through more product details. Things started to get much more interesting at this point. Chris Capossela gave an end user run down of Windows Vista and Office 12 - which will be both released at the same time near the end of 2006.
The UI is just stunning (as it always is in these demos). It was also nice to see the QuickSearch text box integrated through both products. Not unlike Google Desktop Search, and using the same engine as MSN Desktop Search, the QuickSearch text box gives context sensitive searching through the application. If you're in a document explorer - you can search there for documents. If you are in the start menu, you can easily search for applications (and recent documents). If you are in outlook you can easily search your in-box, contacts, etc. Of course you can do broad computer searches too, but that context is nice.
Chris also showed off Sidebar which isn't really big news, but he also showed the audience Sideshow. Sideshow uses the same dock-able gadgets that Sidebar does, but re-use them on what I can only describe as a built in Pocket PC device that is built into the cabinetry of your laptop. This allows you to check real-time information (email, appointments, etc.) without turning on or booting up your laptop. Expedia had a nice gadget working in Sideshow that showed up to the minute flight status. Nice.
RSS is also taking a prominent position in Vista and Office. An RSS store was announced that would store subscribed RSS feed content. This content would be regularly downloaded automatically, and the content would be available to the Sidebar, Outlook, IE7, and your own applications. Cool.
Office 12 has a new user interface that hopes to make more of its features discoverable. At first glance I wasn't all too excited about this, but I'll reserve my judgment until I play around with it. The quick “wizard“ like features were absolutely stunning though.
The integration with Outlook and Sharepoint is quite impressive. We are all accustomed to having our email/contacts/appointments offline stored in our outlook store. With Office 12, you can keep in sync with any Sharepoint folder to keep those files on your local store. Sweet. Better yet, a special new Sharepoint List for sharing PowerPoint decks. When you upload a PowerPoint file, an item appears in the list for each slide. From within PowerPoint, I can create a new deck, and pull individual slides from the Sharepoint server. You can optionally have it keep that slide up to date so if a new version is uploaded to the server, you'll automatically get it. Corporate plagiarism has just become so much easier.
After Chris's “consumer“ demos, Jim Alchin came out with Don Box, Chris Anderson, Anders Hejlsberg and Scott Guthrie. Jim started by giving some demos of some interesting plumbing bits. One cool thing in Vista is Super Fetch. Super Fetch is a preloaded memory cache of things you'll likely need, but unlike typical hard drive caches, it basis it's decisions on analyzing your behavior over days, weeks, months to determine what an idle machine should be preloading. The second part of his demo tied in very nicely where he showed that any USB Memory Stick could be plugged into a Vista machine and it would automatically start using it for expanded virtual ram. That totally rocks for laptops which can quickly max out their ram capacities.
Don and Anders went on to talk about some big news, namely the Language Integrated Query (LINQ) project. Linq provides a query engine on top of XML, Object and Relational data stores using a common query language reminiscent of SQL. No, this isn't an O/R mapping tool, but you can see how they may have wanted to delay ObjectSpaces until they got Linq out the door. I'll have more on this in my blog in the coming days. Attendees at PDC are getting Linq bits to try out, and don't forget to stop by the track lounge to pick up a copy of a Linq whitepaper.
Next Don and Chris messed around with Indigo, and they also created a goofy Avalon application. Scott Guthrie came out to show off the Atlas product which is a set of cross browser javascripts and server side ASP.NET 2 controls to make Ajax style programming a snap.
To close out the lengthy presentation, Jim brought out a few other people to demonstrate complete applications to bring up the wow factor, including Microsoft Max and a kiosk application created for the North Face.
UPDATE: Dinesh Kulkarni gives some inside scoop on how ObjectSpaces is dead, or rather morphed into DLinq. It would appear ObjectsSpaces is not something you'll see built down the road on top of Linq.
The MicrosoftMax application that was demoed today at PDC is now available for download here.
The application allows you to share and publish photo slide shows using an Indigo Peer to Peer channel. The beautiful presentation layer is provided by Avalon.
Why would you want to do that you ask? Well for developers, probably the main reason would be to rewrite or wrap up some ugly lotus notes application (or all of lotus notes for that matter) and expose it in outlook. But seriously, there is a good chance your end user might spend more time in Outlook then any other application they have installed. And then of course, outlook has some context that might be helpful. Maybe, just maybe, when a user wants to talk to a customer, they open up their contact details in outlook first. Nothing worst than having to then alt-tab to another application and lookup the same contact in another system, perhaps to lookup their order history, etc. Or maybe you'd just like to rip through the information in outlook (contacts, appointments, emails) and integrate that data with some other application.
The outlook support for VSTO 2005 was a well kept secret until yesterday at TechEd when this was demonstrated at the keynote. How long are you going to have to wait before you can get your hands on this? How fast is your internet connection?
I'm going to be heading out in a couple of weeks to DevTeach in Montreal. In addition to my regular session talk on Datasets, I'll also be participating in an architecture panel discussion as part of Groupe d’usagers Visual Studio Montréal, Software Architecture Special Interest Group's Special Software Architecture Meeting. The meeting is open to conference attendees, members of the user group, and anybody else for $5. Here's the details....
Speaker: Joel Semeniuk, Microsoft Regional Director, Winnipeg
Subject: Software architecture from the trenches
Architecture is the soul of our software. Software Architecture truly helps to define our success since if our architecture fails us, our software fails us. However, what makes a good architecture? What truly drives architectural decisions? Is one architecture better than another? In this session we will explore and discuss some of these questions while taking a close look at a few real-world examples. In each real-world scenario we will explore the resulting architecture and review the constraints the project faced both during design and during production and maintenance phases. We will also look retrospectively at each architecture presented and discuss ways that it could be improved upon with Microsoft .NET 2.0.
Joel Semeniuk is a founder and VP of Software Development at ImagiNET Resources Corp, a Manitoba based Microsoft Gold Partner in Ecommerce and Enterprise Systems. Joel is also the Microsoft Regional Director for Winnipeg, Manitoba. With a degree in Computer Science from the University of Manitoba, Joel has spent the last twelve years providing educational, development and infrastructure consulting services to clients throughout North America. Joel is the author of "Exchange and Outlook: Constructing Collaborative Solutions", from New Riders Publishing and contributing author of "Microsoft Visual Basic.NET 2003 KickStart" from SAMS. Joel has also acted as a technical reviewer on many other books and regularly writes articles for .NET Magazine and Exchange and Outlook Magazine on a variety of infrastructure and development related topics. Reach Joel by email at joels@imaginets.com.
Followed by a software architecture expert panel:
Beth Massi, Software Architecture MVP
Joel Semeniuk, Software Architecture MVP, Microsoft Regional Director Winnipeg
Barry Gervin, Software Architecture MVP, Microsoft Regional Director Toronto
Mario Cardinal, Software Architecture MVP
Carol Roy, Microsoft Canada .NET architecture specialist for the public sector
Well known Nick Landry (MVP .NET Compact Framework) will act as the moderator.
Come hear these experts talk about software architecture hot topics. You'll also have the chance to ask questions and talk to the panelists.
Monday June 20th, 5:30PM to 9:30PM
Location: Sheraton Centre, 1201 Boulevard Rene-Levesque West
Cost: free for all the DevTeach attendees and the Groupe d’usagers Visual Studio Montréal members. $5 for non members or non DevTeach attendees.
Note: this session will be held in English
More info: www.guvsm.net or http://www.devteach.com/BonusSession.asp
Use the following voucher number MSAU113E1020. Good until August 31, 2005.
I'm just heading back home from Vancouver tonight on a red eye. When I get home, I have time for a load of laundry or two and then I'm flying to Mexico. Not just for some R&R, but I've also arranged to speak at the Mayan Riviera .NET User Group. (MR. Nug). I'm not sure what is better - going on vacation, or being able to write it off as a business expense. Unfortunately the only Spanish I know is “Dos cervasa por favor“ therefore this talk will be in English. My apologies.
I'm going to be speaking about the new DataSet that is coming in Whidbey. By the time I get there, beta 2 should be available for download and it should be public knowledge that ObjectSpaces will finally be shipping as part of the whidbey release. I just got a preliminary build last night, so I'm going to try to do a demo of using a dataset with O/R mapping via ObjectSpaces.
As you may have also heard, bundled into 2.0 Typed Datasets are Typed DataAdapters, also known as TableAdapters. In addition to TableAdapters, beta 2 will introduce typed forms, known as TypedForms. These will be precanned forms for both Web and Windows access that couples an easily painted form right on top of a dataset...with zero code. The cool thing about this is that you can simply add a column to your database table, and this will automatically change your data access layer, your middle tier entity and data entry forms. Likewise, you'll be able to simply drag a text box onto your TypedForms and this will automatically modify your database schema to add a new column to the table.
There is also some discussion going on about also adding a TypedReport into the dataset that couples Sql Reporting Services Reports directly into your typed dataset class. This stuff is going to be so easy to use, that it is likely going to make it's way into InfoPath as part of the Office product so that end users can create their own data entry forms and reports in InfoPath. This new edition of InfoPath is going to be named “InfoMaker“. More information on this is available here. This new collection of classes in the dataset are now going to be collectively known as a "DataWindow". Again, more details here. No, it's not a snowy day hell. Hard to believe isn't it. This is surely a day to mark on your calendar.
It's been a theme for me over the past couple of weeks where people have mentioned that they can't afford the time to do modeling. If you've done a lot of UML modeling, you know what I'm talking about. But it doesn't have to be that way. Now just to ward of the UML flames, even when UML modeling seems like a waste of time, it may actual pay for itself if you uncover a requirement or a design flaw that you wouldn't have otherwise. Certainly catching this kind of thing early than later pays for itself. But that's not what I'm talking about.
In my days as an ERwin/ERX user, doing data modeling was done in this tool not only because it was good to visualize something quickly before committing to code. Using ERwin/ERX was just plain faster than cutting DDL code manually - or heck, even using the Database diagramming in SQL Server. One simple feature was foreign key migration - you drew a relationship from parent to child and bam - it copied down the pk from the parent table and set it up as a fk on the child table.
For the VSTS class designer to be successful (or any of the designers for that matter) MS needs to make using them just plain faster than stubbing out the code manually. Visual Studio has a great editor so they have their work cut out for them. It gets even better with things like code snippets. Why not enable some of the code snippets in the class designer? I can still create a single field wrapped up by a public property faster in the code editor using a snippet (in C# “prop“) than using the class designer - but I don't see why they couldn't add support for that in the class designer too.
A feature I stumbled upon last week was the ability to override a member. Simply right click on the descended class, and select “Override Member“ and you'll see a list of members from the ancestor that are overridable. Select the member to override and bam - you have the code stub. This reminds me a bit of the Inherited Class Skeleton Generator. This represents the kinds of productivity features that can make models/designers more usable, even if just for productivity sake.
There are obviously some types of edits that are better performed in the code editor, such as actually editing code fragments. Other types of edits can be performed more appropriately in the model such as stubbing out the api/members of a class, overriding members, etc. Let's not forget the other types of edits which are much better done in a WYSIWYG designer such as the windows or web forms designer.
One thing I'd like to see come in the Class Designer is a flattened out view of a class that collapses all inherited members into one layer. I'll call this the consumer or intellisense view of a class. It's helpful for viewing the entire interface to a class so I can see how the whole thing makes sense to a user. I would propose a greyed out notation or perhaps a lock icon or something similar to the online help view of a class.
DevTeach is a really nice conference. I went to it for the first time last year and it's a very intimate and interactive conference. While smaller than your TechEd's and PDC's, it manages to attract a very good set of speakers....Kevin McNeish, Brian Noyes, Julia Lerman, Don Kiely, Patrick Hynds, Carl Franklins, Mario Cardinal, Ted Neward, Nick Landry, Etienne Tremblay, Sam Gentile, Jim Duffy, Guy Barrette, Eric Cote, Markus Egger, Kate Gregory and me too. I'll be doing a DataSet tips and tricks talk - but mostly just so I can get a free pass to go and see all the other great talks. This year it is being held once again in Montreal which is a beautiful city with a great night life.
And last but not least, here is a rebate code for $50.00 "TO000OBJSHARP". You can register at http://www.devteach.com