Notes on the January CTP


The January CTP (formerly known as the December CTP) should be out shortly after the new year. We are sorry about the delay; it is due in part to the huge December 14 storm that knocked out the power for over a million residents here in the Seattle area.

During and after the storm I kept myself busy translating about 50 projects from the May CTP and other sources so that they would compile and run using the new Orcas builds that the team rolls out each day here in Redmond. Here are some random notes I kept while I was working. They might be useful to others who are interested in taking the May CTP code and getting it ready to run on Orcas.

Syntax and References Changes

Here are some changes to the using directives found at the top of most C# files.

  • The familiar using System.Query directive is now obsolete. Instead, add one or more of the following: using System.Linq; using System.Xml.Linq; or using System.Data.Linq.
    • System.Query => System.Linq
    • System.Expressions => System.Linq.Expressions
    • System.Xml.XLinq = System.Xml.Linq
  • System.Linq.Script appears to me to be obsolete
  • In the Solution Explorer (usually found on the right of the IDE, go to the references section and add one or more of the following: System.Core.dll, System.Xml.Linq.dll and System.Data.Linq.dll. You can find these files on your hard drive in the \Windows\Microsoft.NET\Framework\v3.5.XXXXX\ directory. They will be added for you automatically in later builds of Orcas, but in these early pre-beta builds you may have to add them yourself. Don’t forget to remove any references to the old assemblies, such as System.Query.

Project File Changes

LINQ Projects that shipped with the May CTP used a special version of csc.exe to compile. This was necessary because the May CTP was running on top of Whidbey which knew nothing about LINQ. Since Orcas compiler has native knowledge of LINQ there is no need to reference a special compiler. If you have projects based on the May LINQ CTP, you may need to comment out or delete any code in your project file (.csproj) that looks like this:

<Import Project="$(ProjectRoot)\Query.targets" Condition="Exists('$(ProjectRoot)\Query.targets')" />
<Import Project="..\Samples.Settings" Condition="!Exists('$(ProjectRoot)\Query.targets')" />

This code pointed at the special compiler that shipped with the May CTP. In all the code I encountered, I was able these replace these lines with the following code:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

If you want, you can perform these edits by first closing your project, and then opening the .csproj file in a text editor. Alternatively, you can right click on your project in the Solution Explorer and choose Unload Project. Right click on the project and choose Edit [MyProject].csproj. Make your edits. Close the csproj file. Right click on your project node again and choose Reload Project.

Array or Collection Initializers

In this section I will talk briefly about changes to the way Array and Collection Initializers work in Orcas as compared to the way they worked in the May CTP.

You now have to explicitly call new on each separate class that you add to an array or a collection using an initializer. For instance, the code for creating an array in Listing One should be changed so that it looks like the code in Listing 2. Code for creating a collection is shown in Listing 3. Note the parenthesis at the end of the code on line 1 of listing 3.

Listing 1: This code will no longer compile cleanly.

   1:      static Person[] persons = new Person[] {
   2:          {Name="Matt", Level=3},
   3:          {Name="Luca", Level=3},
   4:          {Name="Jomo", Level=5},
   5:          {Name="Dinesh", Level=3},
   6:          {Name="Anders", Level=9}
   7:          };

Listing 2: The code in Listing 1 should now include a call to new for each object that is be inserted into the array.

   1:      static Person[] persons = new Person[] {
   2:          new Person {Name="Matt", Level=3},
   3:          new Person {Name="Luca", Level=3},
   4:          new Person {Name="Jomo", Level=5},
   5:          new Person {Name="Dinesh", Level=3},
   6:          new Person {Name="Anders", Level=9}
   7:          };

Listing 3: A collection initializer

   1:  return new List<PhoneBookEntry>()
   2:  {
   3:     new PhoneBookEntry { FirstName = "Sam", LastName = "King" },
   4:     new PhoneBookEntry { FirstName = "Paul", LastName = "Douglas" }
   5:  };

Other API Changes

The items on the left in Table 1 should be converted into the items on the right. For instance, calls to the method or property NE in the May CTP should be renamed to NotEqual. Please don’t arbitrarily make global changes in your code with Search and Replace. Instead, try to compile, and if you encounter problems, look at this list and see if it helps you find a solution. After you understand what changes need to be made, you might then find it useful to use Search and Replace — but proceed with caution!

  • NE = NotEqual
  • GT = GreaterThan
  • LE = LessThanOrEqual
  • LT = LessThan
  • GE = GreaterThanOrEqual
  • EQ = Equals
  • EqualAll = SequenceEqual // At least in some cases
  • Notification = Action // for instance new Notification<OrderDetail> = new Action<OrderDetail>;
  • System.Data.DLinq = System.Data.Linq
    • System.Data.DLinq.MappingSource = System.Data.Linq.MappingSource
    • System.Data.DLinq.INotifyPropertyChanging = System.Data.Linq.InotifyPropertyChanging
    • System.Data.DLinq.UpdateCheck = System.Data.Linq.UpdateCheck
  • Args = Arguments // For LINQ code that calls Microsoft APIs.
  • Parameters = Arguments // sometimes
  • MethodCallVirtual = CallVirtual
  • Len=ArrayLength
  • BitwiseNot = not
  • As=TypeAs
  • Index=ArrayIndex
  • BitwiseAnd=And
  • BitwiseXor=ExclusiveOr
  • LShift=LeftShift
  • RShift=RightShift
  • Binding=MemberBinding
  • Binding=MemberMemberBinding
  • AddBeforeThis = AddBeforeSelf
  • SetAttribute = SetAttributeValue
  • SetElement = SetElementValue 
  • EqualAll = SequenceEqual
  • Expression.Cast = Expression.Convert
  • Expression.Call(instance, method, Expression[]) = Expression.Call(method, instance, Expression[]) // parameter order changed
  • Sequence = Queryable
  • new XElement(Reader) = (XElement)XNode.ReadFrom(reader);
  • OptimisticConcurrencyException=ChangeConflictException
  • OptimisticConcurrencyException.Conflicts = DataContext.ChangeConflicts
  • OptimisticConcurrencyException.Resolve = DataContext.ChangeConflicts.ResolveAlls
  • OptimisticConcurrencyConflict=ObjectChangeConflict
  • OptimisticConcurrencyMemberConflict=MemberChangeConflict
  • OptimisticConcurrencyConflict.GetMemberConflict = ObjectChangeConflict.MemberChangeConflict
  • DataContext.LocalTransaction=Transaction
  • Include=No longer included
  • DataContext.RejectChanges=No longer included
  • DataContext.AcceptChanges=No longer included
  • Query.ToBindingList = Query // ie X.DataSource = Query; Assign the datasource directly to the query.
  • MemberInfo = Member
  • HasModified = IsModified
  • When beta 1 comes out: XElement.Namespace.URI = XElement.namespace.NamespaceName
  • Also beta 1: XElement order; order.Xml = order.ToString(SaveOptions.DisableFormatting)

Summary

Remember, this is not an official list; these are just my notes that I took while massaging thousands of lines of code so they would compile under the new Orcas bits. I did, however, find these notes useful. There were quite a few changes that needed to be made, and keeping them all in my head proved to be difficult. This list, however, helped me move fairly quickly as I patched together my samples so that they compiled under Orcas.

kick it on DotNetKicks.com

Comments (33)

  1. You’ve been kicked (a good thing) – Trackback from DotNetKicks.com

  2. Oh no! Did the download staging servers blow away? Here’s hoping makes it out in the first half of January 2007. I’m really looking forward to being able to install this (sans Virtual PC 2007) on Vista.

    Seasons greetings to the C# team. Many thanks for the viable alternative to worn tooth enamel that is unmanaged development. Evolution is a wonderful thing! 🙂

  3. Just for clarification:

    Is it using System.Data.DLinq (you mention this in the syntax and references heading) OR System.Data.Linq (you mention further down in the API changes)?

    Please let it be System.Data.Linq so the using references are consistent-

    using System.Linq;

    using System.Xml.Linq;

    using System.Data.Linq;

    – NOT –

    using System.Linq;

    using System.Xml.Linq;

    using System.Data.DLinq;

  4. G. T. Field says:

    Thank you for all work you have done!

    Merry X-Mas & Happy New Year!

  5. Alex James says:

    It seems global warming has had another victim… the December CTP of Visual Studio Orcas is no more, enter the January CTP.

    … tongue retracted from cheek.

  6. ccalvert says:

    Troy,

    You get your wish. It is System.Data.Linq. Thanks for catching this one.

    System.Data.DLinq is now obsolete and will not compile by default in Orcas.

    – Charlie

  7. Welcome to the sixteenth Community Convergence. This column comes out about once a week and is designed

  8. Octavio Hernandez says:

    Hi Charlie,

    Thanks for your great work.

    I believe that the order of parameters in

     Expression.Call(method, instance, Expression[])

    has not changed at all – that was the correct order already in the May CTP.

    Best regards,

    Octavio Hernandez

    Madrid, SPAIN

  9. I won&#39;t lose any sleep over this :), but earlier I wrote a post, C# 3.0 Features – A Brief Mindwalk…,

  10. Recently there has been a change in the syntax for collection initializers in C# 3.0. Charlie Calvert

  11. The January Orcas CTP went out last night about 8:30 Pacific time. It is available both as a regular

  12. Charlie Calvert announced on his blog the availability of a new Orcas CTP. There is a regular install…

  13. mattwar says:

    Charlie got the change for Expression.Call backwards, the new form has ‘instance’ as the first arg and ‘method’ as the second.

  14. I don’t like the change from "Query" to "Linq" at all. Consistency is good, but System.Query, System.Data.Query and System.Xml.Query would be so much nicer. Linq is a brand name, Query is what it does.

    That’s why we have System.* instead of DotNet.* and System.Data instead of System.Ado and System.Web instead of System.Asp and why WPF and WCF and WF don’t live in System.Wpf etc.

    Right now Linq is a hot buzzword but 20 years down the line when trying to explain to a new programmer how to work with queries, how are you going to explain to them why they have to type this "Linq" thing in?

  15. Alfred Myers says:

    Stuart made a good point but what would happen if a given technology was superseded by another? What namespace would we use for an API intended to replace ADO.NET or ASP.NET?

  16. Wriju's BLOG says:

    There are some changes happened with LINQ Project with the January CTP. The namespace names like System.Xml.XLinq

  17. Da alcuni giorni è stata rilasciata una nuova CTP di Orcas (Visual Studio 200*). Segnalo questo post

  18. Wriju's BLOG says:

    This is first time I am writing a BLOG post with an error message J . This error message you will experience

  19. The February CTP (aka as the March CTP) is now available for download as a regular install and as a virtual

  20. naive1010 says:

    February/March Orcas CTP Now Available

  21. ... says:

    E evidente che il luogo e stato fatto dalla persona che realmente conosce il mestiere!

  22. Halo_Four says:

    I agree with the previous poster.  I prefered the name System.Query because it has a context that anybody can understand.  LINQ is at best a project name and will have little actual meaning.  Besides that, it makes little sense to use the name like that because LINQ stands for Language INtegrated Query, and the Language INtegrated part has more to do with the enhancements to the actual languages than a namespace in an assembly.  That leaves you with the Q, which stands for Query, so System.Query makes more sense.

  23. ... says:

    luogo interessante, soddisfare interessante, buon!

  24. This year I’ve been @ TechDays2007 presenting 2 sessions: DEV011 – C# 3.0 Future Language Directions

  25. ... says:

    9 su 10! Ottenerlo! Siete buoni!

  26. ... says:

    Ich besichtige deinen Aufstellungsort wieder bald fur sicheres!

  27. ... says:

    luogo interessante, soddisfare interessante, buon!

  28. ... says:

    Stupore! Amo questo luogo!:)))))))

  29. ... says:

    pagine piuttosto informative, piacevoli =)

  30. You can now download Visual Studio Orcas Beta 1. The Team Suite Edition on a Virtual PC Team Suite on

  31. Sumo says:

    Terrible! What are they thinking?? Change it back to System.Query!

    Microsoft, stop ruining one of the best inventions ever!

    This breaks (almost) every API design rule in the book.

    Has anyone even blogged about why? Please for the love of Anders, change them back!

  32. Song says:

    is Profile.IsFirstVisit missing?

  33. Lexapro. says:

    One get off lexapro. Lexapro weight gain. Stop taking lexapro. Lexapro. Can you take lexapro while pregnant.