Hacker News new | ask | show | jobs
by darklajid 3169 days ago
Yesterday a colleague wanted to compile _and deploy_ code. Checked it out. It .. failed to compile. Sure enough, he fixed it (and checked the change in) before deploying it (test env, thank god).

The code was generating some JSON using Linq and created JSON properties: new JsonObject(LinqExpressionHere)

The name for the property was defined as

$"SomePrefix_{x.Name}"

which he helpfully changed to

"SomePrefix_{x.Name}"

which then compiled, but crashed in the test environment because of - surprise - duplicate attributes..

1 comments

I just did this in my code! Ported a ton of PHP to C# and forgot to add $ to the front of strings. A compiler warning would be nice for this.