Update: Targetting 1.1 .NET Framework with MSBuild

A while back I post a sample that shows you how to target the 1.1 framework with MSBuild. Now, another team within Microsoft is working on turning it into a more polished add-on for VS 2005: http://blogs.msdn.com/msbuild/archive/2005/11/09/490817.aspx I’ve chatted with many of you on my blog and I think I know some of your top requests…


C# 3.0 Expression Trees

IanG gives a brilliant explanation of C# 3.0 expression trees and how they enable efficient queries in DLinq: http://www.interact-sw.co.uk/iangblog/2005/09/30/expressiontrees   This posting is provided “AS IS” with no warranties, and confers no rights.


Creating Custom Aggregate Functions in LINQ

Jomo Fisher—Adriane asks whether it’s possible to create your own aggregate function like Sum, Avg, Count, etc. For object queries, the answer is yes. First, let’s look at the actual implementation of Sum:   public static int Sum(this IEnumerable<int> source) {     int sum = 0;     foreach (int v in source) sum += v;…


Evolution of a C# Query—Step by step from C# 1.1 to LINQ

  Jomo Fisher—The future of C# was recently unveiled at PDC. Object, XML and relational data will be integrated deeply into the language. This isn’t really a new direction for C#, it’s the next step down a path that C# has always been headed. To see this, let’s look at a simple task—filtering a set…


How to plug your own C# compiler into VS 2005.

Jomo Fisher–A bunch of future C# compiler features (think 3.0 and beyond) will be on display at PDC in a couple of weeks. We wanted to ship a nice installation that lets people try out the new features of the compiler while still leaving VS 2005 working for regular 2005 C# projects. MSBuild made this…


Code Quality Tip #3: Switch Gears, Eat your Dogfood

Jomo Fisher–Recently, the whole C# product unit took a week off from our regular work to do some App Building. We split up into teams and competed to see who could build the coolest application and find the most bugs in VS 2005. Given where we are in the schedule we’re trying hard to reveal…


Hack the Build: Use the Whole Test-First Whale

Jomo Fisher—  Try lots of things to improve quality. Keep doing what works, stop doing what doesn’t. Writing code with Test-Driven-Development (TDD) takes about 30% longer than writing code without it. This was my experience on MSBuild. Still, as I noted here and here, I’m a fan of TDD. Code quality tip #2 explains why……


Mock Grid Implementation

class Grid : IGrid { int left; int right; int bottom; int top; public int TotalCalls = 0; public Grid(int left, int right, int bottom, int top) { this.left = left; this.right = right; this.bottom = bottom; this.top = top; } public int CountBlocksSet(int x1, int x2, int y1, int y2) { ++TotalCalls; int intersectRight…


Recognizer Driver

static void Main(string[] args) { int totalCalls = 0; int totalGridsEvaluated = 0; for (int left = 0; left<WIDTH; ++left) for (int right = left; right<WIDTH; ++right) for (int bottom = 0; bottom<HEIGHT; ++bottom) for (int top = bottom; top<HEIGHT; ++top) { Grid grid = new Grid(left, right, bottom, top); Shape shape = Recognize(grid); totalCalls…


Naive Recognizer

static Shape Recognize(IGrid grid) { int left = Int32.MaxValue; int right = -1; int bottom = Int32.MaxValue; int top = -1; for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { if (grid.CountBlocksSet(x, x, y, y) == 1) { left = Math.Min(left, x); right =…