Compartilhar via


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

  • Anonymous
    December 21, 2006
    You've been kicked (a good thing) - Trackback from DotNetKicks.com

  • Anonymous
    December 21, 2006
    The comment has been removed

  • Anonymous
    December 22, 2006
    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;
  • Anonymous
    December 22, 2006
    Thank you for all work you have done! Merry X-Mas & Happy New Year!

  • Anonymous
    December 22, 2006
    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.

  • Anonymous
    December 29, 2006
    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
  • Anonymous
    December 29, 2006
    Welcome to the sixteenth Community Convergence. This column comes out about once a week and is designed

  • Anonymous
    January 03, 2007
    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

  • Anonymous
    January 04, 2007
    I won&#39;t lose any sleep over this :), but earlier I wrote a post, C# 3.0 Features - A Brief Mindwalk...,

  • Anonymous
    January 04, 2007
    Recently there has been a change in the syntax for collection initializers in C# 3.0. Charlie Calvert

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

  • Anonymous
    January 11, 2007
    Charlie Calvert announced on his blog the availability of a new Orcas CTP. There is a regular install...

  • Anonymous
    January 12, 2007
    Charlie got the change for Expression.Call backwards, the new form has 'instance' as the first arg and 'method' as the second.

  • Anonymous
    January 16, 2007
    The comment has been removed

  • Anonymous
    January 17, 2007
    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?

  • Anonymous
    January 26, 2007
    There are some changes happened with LINQ Project with the January CTP. The namespace names like System.Xml.XLinq

  • Anonymous
    January 27, 2007
    Da alcuni giorni è stata rilasciata una nuova CTP di Orcas (Visual Studio 200*). Segnalo questo post

  • Anonymous
    January 30, 2007
    This is first time I am writing a BLOG post with an error message J . This error message you will experience

  • Anonymous
    February 28, 2007
    The February CTP (aka as the March CTP) is now available for download as a regular install and as a virtual

  • Anonymous
    March 11, 2007
    February/March Orcas CTP Now Available

  • Anonymous
    March 13, 2007
    E evidente che il luogo e stato fatto dalla persona che realmente conosce il mestiere!

  • Anonymous
    March 15, 2007
    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.

  • Anonymous
    March 15, 2007
    luogo interessante, soddisfare interessante, buon!

  • Anonymous
    March 27, 2007
    This year I've been @ TechDays2007 presenting 2 sessions: DEV011 - C# 3.0 Future Language Directions

  • Anonymous
    April 07, 2007
    9 su 10! Ottenerlo! Siete buoni!

  • Anonymous
    April 11, 2007
    Ich besichtige deinen Aufstellungsort wieder bald fur sicheres!

  • Anonymous
    April 12, 2007
    luogo interessante, soddisfare interessante, buon!

  • Anonymous
    April 15, 2007
    Stupore! Amo questo luogo!:)))))))

  • Anonymous
    April 16, 2007
    pagine piuttosto informative, piacevoli =)

  • Anonymous
    April 21, 2007
    You can now download Visual Studio Orcas Beta 1. The Team Suite Edition on a Virtual PC Team Suite on

  • Anonymous
    May 08, 2007
    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!

  • Anonymous
    May 31, 2007
    is Profile.IsFirstVisit missing?

  • Anonymous
    September 02, 2008
    The comment has been removed