Tuesday, August 25, 2009

All for that small Drop Down Box – Part 2

Web MultiTargeting (Web MT) for VS 2010 has been a great journey of fine technology and a tons of learning for me in person, I am sure everyone in the team feels very similar (although some may add “+ lot of pain” into the mix :-))…  Yesterday, I published some of the details around what Web MT offers web developers in VS 2010… You can read it at:

All for that small Drop Down Box – Part 1

I covered approx 10 different features of MultiTargeting in the previous post, today I am going to time box myself to a couple of hours to write as much as I can and then see if we need Part –3 of this series in few more days or not… :-)

Anyways, let us get started!!

Filtering Markup Intellisense

One of the essential benefits of working within IDE like Visual Studio is that you get your code colorized correctly and intellisense keeps showing up as and when you need it…  Before working on many of these feature areas I often use to take things like keywords getting colorized and intellisense showing up etc pretty much for granted, now I don’t, now I appreciate that ultimately everything is a text pad before it becomes as fancy as VS 2010 code editor is… :-)

The MT team did a reasonable amount of work to make sure that when you go about typing <asp: in HTML editor of VS 2010 and you start getting intellisense as below:

markup intellisense

then that is actually customized to the correct ASP.NET version… Imagine if folks got <asp:ListBox in .NET 2.0 project (where ListBox control is not supported) and they started using the ListBox only to find out when the web project is deployed it will not work…  Well, VS 2010 will not show you <asp:List Box in .NET 2.0 project but in order to do that there was work done to filter out the mark up from intellisense which does not apply in a particular framework… After we got the filtering working then the team was assigned to do some more work to make sure that the design was refined in a way that it did not adversely impact performance…

Correct JavaScript Intellisense

You must have already heard that VS 2010 gives great JavaScript intellisense support… In fact in VS 2010 there was a lot of work in this area (out side of MT work) to ensure that you get intellisense everywhere, hopefully I will write about that also in a different post but whether or not I do I am sure you will start noticing the difference in JavaScript intellisense in VS 2010 over VS 2008…

Anyways, for now what is interesting to know is that for Microsoft AJAX the JavaScript files are embedded inside the assemblies like System.Web.Extensions etc…  The AJAX support has only been growing in every .NET framework release and it is one of the reasons why people move from .NET 2.0 to 3.5 and will hopefully move to .NET 4 too… 

You might recollect the reference assemblies discussion from my Part 1 post and that reference assemblies are meta data only assemblies… You might also recollect that VS 2010 process loads only .NET 4 and then reference assemblies are used to mask .NET 4 features in lower level targets like .NET 2.0/3.0 and 3.5… 

Now the AJAX JavaScript files are embedded inside assemblies and they actually differ from framework to framework…  If VS 2010 would use the embedded JavaScript files from .NET 4 assemblies all the time then .NET 2.0/3.5 projects would land up consuming some JavaScript functions which may not be available in that framework…  Due to such scenarios the Reference assemblies actually always contain embedded resources (even though they do not actually contain the source code implementations)… Web MT team worked on getting these embedded resources from the correct reference assemblies and feeding to the JavaScript intellisense engine to ensure that you get correct AJAX intellisense when you are using Microsoft AJAX feature sets…  It was kind of cool to see even JavaScript intellisense get target aware, I hope folks who use a lot of Microsoft AJAX will be able to appreciate this :-)

Special support for AJAX Control Toolkit (ACT)

It is funny that we land up calling AJAX Control Toolkit as “ACT”, I guess not many web developers using and contributing to ACT don’t do so!!  Anyways, ACT 1.0 was an out of band release (i.e. it did not ship as part of .NET 2.0) and offered various controls and extenders which are used by many many web developers…  Eventually ACT 3.5 and now community previews of recent ACT release are becoming available…  When you download and use ACT then you get controls and extenders in your toolbox and your web controls get options to add or remove extenders (e.g. A TextBox control can have a ColorPicker extender)… When all this things come together in VS 2010 there are a lot of possibilities like what if you have .NET 2.o project what kind of ACT should be made available, what if you have ACT 1.0 as well as ACT 3.5  on your box how should VS 2010 react to it, what should be allowed and what should be prevented via errors and intellisense so that web developers do not land up getting their webs into a bad state… ACT in itself with all its combinations keeps several members of our QA team busy for extended period of time… Their goal is  that things should just work and web developers should remain blissfully unaware of the complexity behind the scene… 

Actually the entire MultiTargeting feature in a way is like that “If you as a developer never realized MTs existence throughout your project lifespan--> from creation, to editing to deployment in production, to end of maintenance life then it is “mission accomplished” for us:-)”…  It feels like working in the entertainment industry, making movies everyday and contributing in the category of work which is pivotal but does not have an Oscar category associated with it!!  As long as our movie is loved by the people watching it we will be happy and satisfied, so in short the ask from you is “Love VS 2010 and .NET 4”  it is indeed great!!

Support for 3rd party controls

Ensuring that 3rd party controls from likes of Infragistics and Dundas work seamlessly across framework versions (based on how they are designed) was also important… Some people want to be able to not keep buying same control over and over again after upgrading their framework version (sounds familiar :-))…  There is a reasonable amount of work done in verifying controls from many of our partners and also working with many control vendors to provide them with the guidance on how to work within VS 2010 to make sure things continue to work find when people migrate their projects into VS 2010…  The central MT team across the division worked together to come up with a guidance document for control vendors to integrate into VS 2010, even this simple blog post series is long enough so I will leave to you to imagine how much information must be poured into that document which will be used by various companies to build controls which will work within VS 2010…  You will be surprised on how versioning, licensing and naming is done by various partners… Ensuring that nothing of this broke in VS 2010 was not easy…:-)

ASP.NET Compilation System

With .NET 4 running in VS 2010 process the ASP.NET Compilation System used is also .NET 4… Before we talk more about this let me tell you what ASP.NET Compilation System does – it is the system which actually takes the web pages, parses the various ASP.NET related syntax present inside the HTML e.g. <asp:GridView etc and converts that into code… It also pulls out all of the inline C# or VB code out of your web page and calls the correct C#/VB compiler on it… This is the core ASP.NET Compiler which runs inside of Visual Studio…

Now imagine that the ASP.NET Compiler within VS 2010 was required to be made target aware… What I mean by that is when you are targeting .NET 2.0 and you have .NET 4.0 syntax in your web then the compiler needs to throw an error which shows up in your VS 2010 error list which you can then double click and you are taken to the line on which there was an error…  This actually is the same kind of error reporting mechanism that happens even when there is a typo in source code… In essence ASP.NET 4 compiler needs to get into the “correct framework mode” to provide the accurate error messaging and to avoid any type bleeding from happening…

There are also MT implications on C# and VB compilers which I will possibly cover in a separate post… In any case trust me that making compilation system target aware is a significant endeavor…

IIS Application Pool Mappings

As you know we have Visual Studio Development Server (aka Cassini) that is used to debug/run your project within VS without needing IIS…  I talked a little bit about this in my previous post… The other possibility for running and debugging your app is by using IIS on your local box itself…

VS allows you to create a WAP or a Web Site which uses IIS instead of Cassini… Even here MT needs to intervene; if you are creating a .NET 2.0 IIS Web then VS 2010 needs to go access IIS and create Virtual Directories, IIS Apps and map them to the correct App Pools running in correct target frameworks… Simply put VS 2010 needs to put .NET 2.0 project in .NET 2.0 App Pool and .NET 4 project in .NET 4 App Pool…  I wish it was just limited to this but there are instances when correct App Pools are not available and then VS 2010 needs to go and create them for that framework… Sometime the project is mapped to use .NET 2.0 App Pool and now it is being upgraded to .NET 4… In this scenario VS needs to go and change the IIS App to use the correct App Pool too…

VS 2010 actually uses IIS 6 Metabase APIs to make these changes and even when you are using IIS 7.0 or 7.5 VS 2010 continues to use the same Metabase APIs and hence if you are using IIS as your development server with VS 2010 with Vista/Win7 you will need to have IIS 6 Metabase Compatibility Layer turned on in Control Panel –> Programs–> Turn Windows Features On/Off  as shown below:

metabse compatibility

It is not only when VS 2010 flips/flops Virtual Directory App Pools when this compatibility layer is used… It is also used when IIS App is created for the first time, in short it is used every time you use IIS based web project within VS 2010…

In all honesty, in VS we could write code to get rid of the IIS 6 Metabase compatibility dependency and instead start using IIS 7 configuration system API but there was a lot work needed to do that we could never get to completely finishing it on time… :-( I totally understand that it is going to be an inconvenience to have the compatibility layer enabled and I apologize for the same but I hope that you will recognize the fact that we do have the intent to finish the work but just from cost and schedule standpoint we could not fit this work into VS 2010…

Anyways, I have reached at the end of my stipulated couple of hours of time to write this post… I assumed that if I give myself couple of hours to write then the content will be at reasonable reading length without making everyone bored, it will also ensure that I do not start writing gibberish :-)

I certainly have more inner workings to tell you about Web MT but I guess that the content is interesting enough to deserve “All for that small Drop Down Box - Part 3”…!!

So until then please do feel free to let me know if any of this is any good to anyone reading :-)

-Vishal

The remaining posts in the Web MultiTargeting Series are:

3 comments:

Jack said...

More intellisense is involved, and help us a lot in write code instead of using IDE drag and drop controls

KeepingItSimple said...

Good Write up Vishal. Keep it up. Looking forward to what you are going to cover next.

Thank you.

Balaje Sankar said...

Yet another detailed post on MT. Kudos Vishal.