Category Archives: 8325

Announcing The Microsoft Roslyn CTP

The Roslyn team has announced general availability of the Roslyn CTP!

The official launch is at http://msdn.com/roslyn, and there were a number of blogs to publicize the availability broadly (soma, ericli, vsteam, vbteam, c#faq) and across twitter.

This release marks a significant step to the new way of thinking of compilers, and the agility that is now possible with language innovation, IDE tooling, and powering the ecosystem. The C# and VB compilers are no longer black boxes – something we put source text into, do some magic on, and get an assembly out.  All that rich information about code is no longer thrown away, but is now exposed as a full-fidelity object model that can be easily consumed by all.  In addition, it was released a preview of the first-ever Interactive window for C# that contains full IDE support – including IntelliSense and even automatically detecting missing using directives.

How to get started:

  • Download the CTP.  The CTP installs on Visual Studio 2010 SP1 and can be safely installed side-by-side with Visual Studio 11.
  • Go to Start -> All Programs ->  Microsoft Codename Roslyn CTP -> Getting Started to launch the entry point into all the documentation, samples, and tools.
  • Read the Roslyn Project Overview for a good overview of the project.
  • Learn from the rich samples included (paste as C#/VB, refactorings, code analysis, and code generation tools).
  • Run the walkthroughs to learn about the Compiler APIs, the Services API, or using the Interactive window.
  • For those of you that aren’t extension writers, download the CTP to try out the Interactive window and use the Copy Paste C#/VB extensions that were built to help with your daily work now!

The release includes the following features:

  • Visual Studio Project Templates
    These project templates help you get started using the Roslyn APIs and building new Visual Studio extensions using the C# or VB APIs.
  • Reference Assemblies
    The Roslyn assemblies can be added to projects via the Add Reference dialog.
  • Interactive Window
    A new tool window called C# Interactive is available in Visual Studio by invoking View -> Other Windows -> C# Interactive from the menu. You can explore by either executing snippets of code in the C# Interactive tool window, or cumulatively building up execution context as you experiment.
  • Script File Editing Support
    C# Script (.csx) files allow top-level statements much like the C# Interactive window. You can create a new C# Script file by invoking File -> New File -> Script -> Visual C# Script from the Visual Studio menu. In addition to typing directly into the tool window, you can also select code in C# and C# Script (.csx) files and invoke "Execute in Interactive" or "Copy to Interactive" from the context menu. C# Script editing features like IntelliSense are powered by the Roslyn Language Service.

Please keep in mind that this is only a technology preview, and it’s not done yet! The primary goal of this CTP is to gather feedback on the public APIs and give an early look at the Interactive window feature. The shape of the APIs are in a fairly stable state, especially the Compiler ones, but there are still a set of known limitations and only a subset of the C# and Visual Basic languages are implemented in the current release.  For a full list of non-implemented language features, see here. The Interactive window is only available for C# at this time, but VB is following shortly.

The Roslyn team looks forward to hearing your feedback on the forums e through Connect.

LINQ With C# Book Is Finally Out

It’s finally out!

The LINQ Com C# (LINQ With C#) book that Luís and I wrote is out. Well, mostly Luís than I.

This book, published by FCA, is targeted at anyone that already knows C# 2.0 and wants to know learn the new features introduced with C# 3.0 that made possible LINQ (Language INtegrated Query). The examples in the book are written in C#, but Visual Basic get be get from the book’s site.

Livro LINQ Com C# Title: LINQ Com C#
Authors: Luís Abreu / Paulo Morgado
ISBN: 978-972-722-547-7
Number of Pages: 216
Format: 17,0 x 24,0 x 1,3 cm (6.7 x 9.4 x 0.5 in)

The book can be found here:

Help Typemock Launch Its New Visual Basic .NET Friendly API And You Might Get A Free License


Typemock is announcing today a new version of Typemock Isolator (5.2).


One of the coolest features in the new version is the inclusion of a new VB .NET unit testing API. This ‘VB friendly’ API was designed and written in VB.NET, for VB.NET developers. It uses the strengths of the VB.NET language to allow easy and intuitive use of the isolation API, for easier unit tests on any piece of .NET code.


If you are you a blogger, webmaster, or internet columnist, you can get your free personal license by helping Typemock launch their new 5.2 version for Isolator – the best tool to unit test VB.NET applications.


Although this version is targeted to unit test VB.NET applications, C# applications with unit tests built using Visual Studio 2005 can also benefit from this API.


How can you get the free license?


Post the text below on your blog (as is, with links) and tell them about it . If you are in the first 25 to mail them after posting, your license will be on its way!


If you have a VB.NET dedicated blog, you’ll get a license automatically (even if more than 25 submit) during the first week of this announcement.


A few simple requirements:


  1. You must own a website, blog space or internet column, older than 2 months, or get permission from the owner of such a site.
  2. Your post must include the text below (including the links) between *Begin* and *End*.

_


*Begin*


Programming Visual Basic applications?


Typemock have released a new version of their unit testing tool, Typemock Isolator 5.2.
This version includes a new friendly VB.NET API which makes Isolator the best Isolation tool for unit testing A Visual Basic (VB) .NET application.


Isolator now allows unit testing in VB or C# for many ‘hard to test’ technologies such as SharePoint, ASP.NET MVC, partial support for Silverlight, WPF, LINQ, WF, Entity Framework, WCF unit testing and more.


Note that the first 25 bloggers who blog this text in their blog and tell us about it, will get a Free Full Isolator license (worth $139). If you post this in a VB.NET dedicated blog, you’ll get a license automatically (even if more than 25 submit) during the first week of this announcement.


Go ahead, click the following link for more information on how to get your free license.


_


*End*


Once you post this in your site, just drop them a line at vb@typemock.com with your name and the post URL to get your free license.


Hurry up – this offer is limited to the first 25 general bloggers, or to VB.NET dedicated bloggers who will post this in the first week.



Disclaimer: This is an offer from Typemock as announced at http://blog.typemock.com/2009/01/get-free-isolator-licnese-for-helping.html. I’m just a fan.

The Future Of C#


If you were able to attend this session at PDC or Tech-Ed EMEA Developers, you were presented with a first class presentation of the future of C#, presented, respectively, by Anders Hejlsberg and Mads Torgersen.


For the near future (.NET 4.0) C# will have:


  • Dynamically Typed Objects
  • Optional and Named Parameters
  • Improved COM Interoperability
  • Co- and Contra-variance

A preview of the compiler as a service was shown, but that’s not for the .NET 4.0 / Visual Studio 2010 timeframe. Probably, not even for the next.


Starting with .NET 4.0, C# and Visual Basic will converge in terms of features and follow a path of co-evolution going into the future.


No! That doesn’t mean that XML literals will be in C# in a foreseeable future. What that means is that the above list also applies to Visual Basic.


Talking of Visual Basic evolution, the _ line continuation character has been retired. If you have any use for the underscore, please visit http://www.unemployedunderscores.com/.


Resources:


MSDN Ramp Up Program

MSDN Ramp Up Program

I just came across this: www.MyRampUp

Ramp Up is a free, online, community-based program that can help users save time in learning Microsoft technology.

The easy-to-access content (provided by subject-matter gurus) is specifically tailored to the Ramp Up program, and offered in a variety of forms (whitepaper, v-lab, codecast and slidecast).

Program Guide

The currently available routes are:

SharePoint for Developers track - learn more

Visual Studio 2008 track - learn more

Aspiring Developer - learn more

Success with Java and C# - learn more

Next Level Visual Basic - learn more

Next Level Microsoft.NET - learn more

Currently, there are no assessments in the program, so it’s quicker than ever to graduate and receive the reward (25% off on certification and 50% off on e-Learning – only for graduates of Ramp Up).

C# And Visual Basic Generate Different Expression Trees


(This was pointed out to me by Frans Bouma and explained by Jon Skeet)


Imagine you have this set of classes:

public class A
{
    public virtual string P
    {
        get { return “A”; }
    }
}

public class B : A
{
}

public class C : B
{
    public override string P
    {
        get { return “C”; }
    }
}

And this class:

public static class Reporter
{
    public static void Report<T>(T target, Expression<Func<T, string>> expression)
    {
        Console.WriteLine(“Expression: {0}”, expression);
        Console.WriteLine(“\tDeclaring Type: {0}”, ((expression as LambdaExpression).Body as MemberExpression).Member.DeclaringType);
        Console.WriteLine(“\tInvocation Result: {0} for {1}”, expression.Compile().Invoke(target), target.GetType());
        Console.WriteLine();
    }
}

The above class writes to the console the lambda expression, the declaring type of the property and the value of the property for the target and the target’s type.


Now, let’s look at what happens when used from this C# code:

Reporter.Report(new C(), (A a) => a.P);
Reporter.Report(new C(), (B b) => b.P);
Reporter.Report(new C(), (C c) => c.P);

Reporter.Report(new B(), (A a) => a.P);
Reporter.Report(new B(), (B b) => b.P);

Reporter.Report(new A(), (A a) => a.P);

The output will be:

Expression: a => a.P
        Declaring Type: A
        Invocation Result: C for C

Expression: b => b.P
        Declaring Type: A
        Invocation Result: C for C

Expression: c => c.P
        Declaring Type: A
        Invocation Result: C for C

Expression: a => a.P
        Declaring Type: A
        Invocation Result: A for B

Expression: b => b.P
        Declaring Type: A
        Invocation Result: A for B

Expression: a => a.P
        Declaring Type: A
        Invocation Result: A for A

On the other hand, if used from the equivalent Visual Basic code:

Reporter.Report(New C(), Function(a As A) a.P)
Reporter.Report(New C(), Function(b As B) b.P)
Reporter.Report(New C(), Function(c As C) c.P)

Reporter.Report(New B(), Function(a As A) a.P)
Reporter.Report(New B(), Function(b As B) b.P)

Reporter.Report(New A(), Function(a As A) a.P)

The output will be:

Expression: a => a.P
        Declaring Type: A
        Invocation Result: C for C

Expression: b => b.P
        Declaring Type: A
        Invocation Result: C for C

Expression: c => c.P
        Declaring Type: C
        Invocation Result: C for C

Expression: a => a.P
        Declaring Type: A
        Invocation Result: A for B

Expression: b => b.P
        Declaring Type: A
        Invocation Result: A for B

Expression: a => a.P
        Declaring Type: A
        Invocation Result: A for A

Why the differences? It’s because of each language’s specification and compiler:


  • The C# compiler will issue a virtual call to the virtual member in the class where it’s declared as virtual.
  • The Visual Basic compiler will issue a virtual call to the overriding member on the class that overrides it.