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)


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