Browse by Tags

Tagged Content List
  • Blog Post: Every public change is a breaking change

    Here's an inconvenient truth: just about every "public surface area" change you make to your code is a potential breaking change. First off, I should clarify what I mean by a "breaking change" for the purposes of this article. If you provide a component to a third party, then a "breaking change" is a...
  • Blog Post: Breaking changes and named arguments

    Before I get into the subject of today's post, thanks so much to all of you who have given us great feedback on the Roslyn CTP. Please keep it coming . I'm definitely going to do some articles on Roslyn in the future; the past few weeks I have been too busy actually implementing it to write much about...
  • Blog Post: Optional argument corner cases, part four

    (This is the fourth and final part of a series on the corner cases of optional arguments in C# 4; part three is here .) Last time we discussed how some people think that an optional argument generates a bunch of overloads that call each other. People also sometimes incorrectly think that void M(string...
  • Blog Post: Asynchrony in C# 5 Part Six: Whither async?

    A number of people have asked me what motivates the design decision to require any method that contains an "await" expression to be prefixed with the contextual keyword "async". Like any design decision there are pros and cons here that have to be evaluated in the context of many different competing...
  • Blog Post: A Definite Assignment Anomaly

    UPDATE: I have discovered that this issue is considerably weirder than the initial bug report led me to believe. I've rewritten the examples in this article; the previous ones did not actually demonstrate the bug. Consider the following code: struct S { private string blah; public S(string blah...
  • Blog Post: Why Can't I Access A Protected Member From A Derived Class? Part Six

    Reader Jesse McGrew asks an excellent follow-up question to my 2005 post about why you cannot access a protected member from a derived class . (You probably want to re-read that post in order to make sense of this one.) I want to be clear in my terminology, so I’m going to define some terms. Suppose...
  • Blog Post: Closing over the loop variable, part two

    (This is part two of a two-part series on the loop-variable-closure problem. Part one is here .) UPDATE : We are taking the breaking change. In C# 5, the loop variable of a foreach will be logically inside the loop, and therefore closures will close over a fresh copy of the variable each time . The ...
  • Blog Post: Closing over the loop variable considered harmful

    (This is part one of a two-part series on the loop-variable-closure problem. Part two is here .) UPDATE : We are taking the breaking change. In C# 5, the loop variable of a foreach will be logically inside the loop, and therefore closures will close over a fresh copy of the variable each time . The ...
  • Blog Post: The void is invariant

    [UPDATES below] A while back I described a kind of variance that we’ve supported since C# 2.0. When assigning a method group to a delegate type, such that both the selected method and the delegate target agree that their return type is a reference type, then the conversion is allowed to be covariant...
  • Blog Post: Reserved and Contextual Keywords

    Many programming languages, C# included, treat certain sequences of letters as “special”. Some sequences are so special that they cannot be used as identifiers. Let’s call those the “reserved keywords” and the remaining special sequences we’ll call the “contextual keywords”. They are “contextual” because...
  • Blog Post: Future-Proofing A Design

    Last time on FAIC a user asked for guidance on the potential pitfalls of refactoring an automatic property into a regular explicit property. This is just an example of a far more general problem: how can we design programs so that they are easy to get right when things inevitably change in the future...
  • Blog Post: Automatic vs Explicit Properties

    Here's a question I got from a C# user last year, a question I get fairly frequently: User: With “regular” explicit properties, I tend to use the private backing field directly from within the class. Of course, with an automatic property, you can’t do this. My concern is that in the future, if I decide...
  • Blog Post: Why Can't I Access A Protected Member From A Derived Class, Part Two: Why Can I?

    This is a follow-up to my 2005 post on the same subject which I believe sets a personal record for the longest time between parts of a series. (Of course, I didn't know it was a series when I started it.) Please read the previous article in this series, as this post assumes knowledge of part one. .....
  • Blog Post: Covariance and Contravariance in C#, Part Nine: Breaking Changes

    Today in the last entry in my ongoing saga of covariance and contravariance I’ll discuss what breaking changes adding this feature might cause. Simply adding variance awareness to the conversion rules should never cause any breaking change. However, the combination of adding variance to the conversion...
  • Blog Post: Future Breaking Changes, Part Three

    As I said earlier , we hate causing breaking changes in our product, the C# compiler, because they cause our customers pain. Said customers are also software developers, and presumably they hate causing breaking changes for their customers as much as we do. We want to throw our customers into the...
  • Blog Post: Future Breaking Changes, Part Two

    Last time I mentioned that one of the subtleties of programming language design is weighing the benefit of adding a feature against the pain it will cause you in the future. This is a specific subset of a more general set of problems. Languages run into the same problem that other large, multiply-versioned...
  • Blog Post: Future Breaking Changes, Part One

    We on the C# team hate making breaking changes. As my colleague Neal called out in his article on the subject from a couple years ago , by “breaking change” we mean a change in the compiler behaviour which causes an existing program to either stop compiling entirely, or start behaving differently...
  • Blog Post: Chained user-defined explicit conversions in C#

    Reader Niall asked me why the following code compiles but produces an exception at runtime: class Base {} class Derived : Base {} class Castable { public static explicit operator Base() { return new Base(); } } // ... Derived d = (Derived)(new Castable()); It should be clear why this produces an...
  • Blog Post: Odious ambiguous overloads, part two

    There were a number of ideas in the comments for what we should do about the unfortunate situation I described yesterday . We considered all of these options and more. I thought I might talk a bit about the pros and cons of each. I suggested do nothing . We shipped with this behaviour in C# 2.0, the...
  • Blog Post: Odious ambiguous overloads, part one

    As you might have gathered, a lot of the decisions we have to make day-to-day here involve potential breaking changes on odd edge cases. Here's another one. Consider the following terrible but legal code: public interface I1<U> { void M(U i); void M(int i); } My intense pain begins when...
  • Blog Post: The Root of All Evil, Part Two

    There were a number of interesting comments to yesterday's posting about premature optimization. Several readers pointed out that there are various options we could take: Do nothing. Maintain backwards compatibility and spec incompatibility. Change the spec to exactly match the current implementation...
  • Blog Post: The Root Of All Evil, Part One

    People often quote Knuth's famous statement that premature optimization is the root of all evil. Boy, has that ever been the theme of my life these last few weeks as I've been banging my head against the compiler trying to figure out how we're going to make it work with LINQ without breaking backwards...
  • Blog Post: Do not use string hashes for security purposes

    A recent question I got about the .NET CLR's hashing algorithm for strings is apropos of our discussion from January on using salted hashes for security purposes . The question was basically "my database of password hashes doesn't seem to work with .NET v2.0, what's up with that?" To make a long story...
  • Blog Post: FYI, C# 2.0 Has A Breaking Change in Enum Subtraction

    A customer brought to my attention the other day that the C# 2.0 beta release has a breaking change from the previous release. Namely, this code enum E : byte { A = 1, B = 2 }; // . . . E a = E.A; E b = E.B; int j = a - b; sets j to -1 in the previous release but to 255 in the upcoming release...
Page 1 of 1 (24 items)