<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>GrantRi's WebLog [MS] : Error Messages and Warnings</title><link>http://blogs.msdn.com/grantri/archive/tags/Error+Messages+and+Warnings/default.aspx</link><description>Tags: Error Messages and Warnings</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>More on Compiler Error Messages (and their text)</title><link>http://blogs.msdn.com/grantri/archive/2004/05/03/125139.aspx</link><pubDate>Mon, 03 May 2004 17:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:125139</guid><dc:creator>grantri</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/grantri/comments/125139.aspx</comments><wfw:commentRss>http://blogs.msdn.com/grantri/commentrss.aspx?PostID=125139</wfw:commentRss><wfw:comment>http://blogs.msdn.com/grantri/rsscomments.aspx?PostID=125139</wfw:comment><description>&lt;P&gt;I wish we had more UE (User Education for those not familiar with Microsoft acronyms) interaction when writing error messages.&amp;nbsp; Usually, it is just a one or more devs that try and write some English (but remember we're CS or EE&amp;nbsp;majors, not English or communications) that explains: what the compiler knows is wrong, why it is wrong, and hopefully the most likely way to correct it.&amp;nbsp; I think this blog is sufficient proof of my English skills.&lt;/P&gt;
&lt;P&gt;Somebody with real writing skills usually doesn't see it until a few weeks or months later when the UE teams goes to write help topics for the error message.&amp;nbsp; And at that point very few UE guys understand enough of how a compiler works to properly document an error message to write a good topic not to mention improve the grammar or wording of the&amp;nbsp;error message itself.&amp;nbsp;UE&amp;nbsp;usually rely on dev or QA to write some code that causes the error (a repro) and then more code that shows how to 'fix' the error.&amp;nbsp; Then some UE are still really lost so they have dev write more of the topic, and they fix the grammar of that and publish it.&lt;/P&gt;
&lt;P&gt;Now there have been some really good UE guys that have actually helped me (and hopefully others) write good error messages.&amp;nbsp; There have also been some good devs or QAs that actually know proper English and are able to write good ones themselves.&amp;nbsp; My word of advice: if you ever find somebody that understands a compiler, but for some strange reason still like writing English docs, don't ever let him go!&lt;/P&gt;
&lt;P&gt;--Grant&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=125139" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/grantri/archive/tags/Error+Messages+and+Warnings/default.aspx">Error Messages and Warnings</category></item><item><title>A good author writes better than a good developer</title><link>http://blogs.msdn.com/grantri/archive/2004/03/30/104048.aspx</link><pubDate>Tue, 30 Mar 2004 18:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:104048</guid><dc:creator>grantri</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/grantri/comments/104048.aspx</comments><wfw:commentRss>http://blogs.msdn.com/grantri/commentrss.aspx?PostID=104048</wfw:commentRss><wfw:comment>http://blogs.msdn.com/grantri/rsscomments.aspx?PostID=104048</wfw:comment><description>&lt;P&gt;So here's a recent MSDN article that I actually had the chance of reviewing several months ago.&amp;nbsp; They've done a much better job at capturing the good new stuff in C# than I could ever do.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/vcsharp/default.aspx?pull=/msdnmag/issues/04/05/c20/default.aspx"&gt;http://msdn.microsoft.com/vcsharp/default.aspx?pull=/msdnmag/issues/04/05/c20/default.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I do still have a few personal corrections:&lt;/P&gt;
&lt;P&gt;I commented that the internal names that the compiler generates have changed and will probably change again, and so the article should probably just mention that the name is compiler generated and not give the actual name (those that care can run ILDASM and see for themselves), but they didn't listen.&amp;nbsp; At least they did mention that is might change.&amp;nbsp; For those of you who have the community drop you'll notice that the compiler generated names&amp;nbsp;have changed from&amp;nbsp;what's in the article.&lt;/P&gt;
&lt;P&gt;I also commented that using the binary tree wasn't exactly the best example of iterators because of it's miserable performance.&amp;nbsp; Yes it is clean and neat code, but if you have a binary tree with 5000 nodes and you foreach it a few times, you can watch your machine crawl as it is forced to spend more and more time in the GC rather than running your code.&amp;nbsp;&amp;nbsp;At least&amp;nbsp;they&amp;nbsp;mentioned this potential problem (see the last paragraph before the Partial Types section).&amp;nbsp; Too bad my brain wasn't thinking and I got the numbers wrong.&amp;nbsp; It should state, &amp;#8220;approximately &lt;I&gt;n&lt;/I&gt;&lt;STRIKE&gt;/2&lt;/STRIKE&gt; iterator instantiations, where &lt;I&gt;n&lt;/I&gt; is the number of nodes in the tree.&amp;#8221;&lt;/P&gt;
&lt;P&gt;Also note the small paragraph on #pragma warning that now gives you line-level control over individual warnings!&lt;/P&gt;
&lt;P&gt;--Grant&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=104048" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/grantri/archive/tags/Anonymous+Methods/default.aspx">Anonymous Methods</category><category domain="http://blogs.msdn.com/grantri/archive/tags/Error+Messages+and+Warnings/default.aspx">Error Messages and Warnings</category><category domain="http://blogs.msdn.com/grantri/archive/tags/Iterators/default.aspx">Iterators</category></item><item><title>Warning Levels</title><link>http://blogs.msdn.com/grantri/archive/2004/03/30/103449.aspx</link><pubDate>Tue, 30 Mar 2004 15:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:103449</guid><dc:creator>grantri</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/grantri/comments/103449.aspx</comments><wfw:commentRss>http://blogs.msdn.com/grantri/commentrss.aspx?PostID=103449</wfw:commentRss><wfw:comment>http://blogs.msdn.com/grantri/rsscomments.aspx?PostID=103449</wfw:comment><description>&lt;P&gt;It's not documented very well, but the C# compiler actually has 4 levels of warnings.&amp;nbsp; I like to think of them this way:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Level 1 - These warnings are cases the compiler is 99.9% sure you did something wrong, but the code is syntactically and semantically legal.&lt;/LI&gt;
&lt;LI&gt;Level 4 - These warnings are cases where the naive user probably did something unintended, and we want to make sure they're aware of it.&lt;/LI&gt;
&lt;LI&gt;Level 2 and 3 are just somewhere in between.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;This seems like a pretty reasonable set, although I've often wondered if 4 levels is the right number, maybe 3 or 2 would be better.&amp;nbsp; Anyway, often times we get requests from the ASP.NET team to raise or lowere the level of certain warnings.&amp;nbsp; Now the whole point of a warning is that it points out a &lt;STRONG&gt;possible&lt;/STRONG&gt; problem with the code.&amp;nbsp; As such the compiler team has always mandated that we will feel free to add new warnings where appropriate, so those people who build with /warnaserror are just asking to be broken when they upgrade (there's a better way to do this and I'll get to it later).&amp;nbsp; Now back to ASP.NET, as anybody who has used it already knows, ASP.NET does not have a way of reporting warnings.&amp;nbsp; They don't go to a log or anything useful like that.&amp;nbsp; Instead they build with /warnaserror turned on and the warning level set to 1.&amp;nbsp; So all of our level 1 warnings become errors and break people's web sites.&amp;nbsp; Anybody see the problem here?&lt;/P&gt;
&lt;P&gt;As promisied, here's the right way to use /warnaserror: on your developer machines, before submitting changes.&amp;nbsp; Then on your offical builds turn it off.&amp;nbsp; Keep a warning log and send it to the developers, but don't break your build because of a warning.&amp;nbsp; I don't know about your organization, but here a build break is &lt;STRONG&gt;&lt;EM&gt;painful!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;--Grant&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=103449" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/grantri/archive/tags/Error+Messages+and+Warnings/default.aspx">Error Messages and Warnings</category></item><item><title>Error Number Trivia</title><link>http://blogs.msdn.com/grantri/archive/2004/03/12/88812.aspx</link><pubDate>Fri, 12 Mar 2004 22:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:88812</guid><dc:creator>grantri</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/grantri/comments/88812.aspx</comments><wfw:commentRss>http://blogs.msdn.com/grantri/commentrss.aspx?PostID=88812</wfw:commentRss><wfw:comment>http://blogs.msdn.com/grantri/rsscomments.aspx?PostID=88812</wfw:comment><description>&lt;P&gt;Have you ever wondered how we come up with the error and warning numbers?&amp;nbsp; Well if you've looked at the SSCLI source for the C# compiler, you'll see that we use a file full of macros to define the error numbers, their severity, and the resource ID that has their text (errors.h).&amp;nbsp; Now like most version control systems ours has a hard time merging changes that are too close to each other.&amp;nbsp; So to prevent such conflicts each of the C# compiler developers was assigned ranges, and as long as we stuck to our ranges, we never had problems.&amp;nbsp; I started here at Microsoft well after the compiler was started, so I got the highest range starting at error CS1500.&amp;nbsp; My most recent addition was error CS1715.&amp;nbsp; Now there are some blanks or holes in the numbering.&amp;nbsp; That usually comes from adding an error or warning, and then later removing it (all between releases so your lucky customers never saw it).&amp;nbsp; I doubt anybody will ever go back an reuse those numbers, at least not until we run out of 4-digit numbers.&lt;/P&gt;
&lt;P&gt;There are a few exceptions to these rules.&amp;nbsp; Originally the command-line driver (csc.exe) did not share errors.h with the compiler (cscomp.dll).&amp;nbsp; And that worked for a while, but became too cumbersome, so we moved it's errors into the same file and moved all of it's error numbers to start at 2000 and up.&amp;nbsp; You'll also see one special error message: error CS2018.&amp;nbsp; It has no corresponding resource ID.&amp;nbsp; Why?&amp;nbsp; Because it is the error the compiler reports when it can't find any resource DLL, and thus can't load any strings.&amp;nbsp; So that one single error message will never be localized, and will always be hard-coded in the driver (csc.exe).&lt;/P&gt;
&lt;P&gt;The last notable section are the CLS errors and warnings that start at 3000.&amp;nbsp; First of all, I added most of those errors, so there wasn't much problem of merging.&amp;nbsp; Secondly CLS checking was not always part of the compiler.&amp;nbsp; When we did add it the Frameworks team had already written a ton of code that violated a ton of the rules.&amp;nbsp; So they wanted a way to have the compiler tell them about the problems but not break the daily build.&amp;nbsp; So we added&amp;nbsp; special temporary switch that would force all of the errors in the 3000 range down to warnings.&amp;nbsp; They used that switch until they had enough time to fix all of their code, and then we removed the switch.&lt;/P&gt;
&lt;P&gt;How many of you ever look in the docs (inside VS or online at MSDN) for extra help on specific error messages or warnings?&amp;nbsp; Our UE team likes to have a sample that reproduces the error or warning with a comment or another sample that shows how to fix it or work-around it.&amp;nbsp; I personally don't think the first sample is all that useful (except for maybe setting the stage for the second sample).&amp;nbsp; It just seems to me that if you've hit an error message, you don't need another sample of another way to cause the error, you just need a sample of what to do right.&amp;nbsp; I am partly asking because right now the UE guys are asking me for samples for most of the new errors and warnings I've added.&lt;/P&gt;
&lt;P&gt;--Grant&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=88812" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/grantri/archive/tags/Error+Messages+and+Warnings/default.aspx">Error Messages and Warnings</category></item><item><title>Compiler Error Messages Clarification</title><link>http://blogs.msdn.com/grantri/archive/2004/03/01/82150.aspx</link><pubDate>Mon, 01 Mar 2004 18:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:82150</guid><dc:creator>grantri</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/grantri/comments/82150.aspx</comments><wfw:commentRss>http://blogs.msdn.com/grantri/commentrss.aspx?PostID=82150</wfw:commentRss><wfw:comment>http://blogs.msdn.com/grantri/rsscomments.aspx?PostID=82150</wfw:comment><description>&lt;P&gt;First of all, I am not acutally talking about decreasing or removing any errors (unless somebody can prove that a given error is a total duplicate of another one, but I seriously doubt that).&amp;nbsp; I'm really talking about how big an error message can be before it should be split up.&amp;nbsp; I can think of two dimensions to measure right now: the scenarios that the error message covers (how many different ways can you break a given grammar or semmantic rule and how many error messages should be used for each of those different ways); and the raw length of the error message (how much text and verbage should be put in the error message itself, and at what point should the user be forced to consult the help text or manual for clarification or futher assistance).&amp;nbsp; I personally love error messages that tell you not jsut what you did wrong, but how to fix it.&amp;nbsp; However in those cases I wish there was just a button that said, &amp;#8220;fix it for me&amp;#8221;,&amp;nbsp;especially for missing semicolons, close parenthesis, and close curlys.&lt;/P&gt;
&lt;P&gt;My other pet peeve is that fact that inside the IDE, it does not display the related locations, which as many of you have noticed, cripples some of the compiler's diagnostics.&amp;nbsp; I am told that something is being done to correct that...&lt;/P&gt;
&lt;P&gt;Thanks for the feedback on my previous post, keep it coming.&lt;BR&gt;--Grant&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=82150" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/grantri/archive/tags/Error+Messages+and+Warnings/default.aspx">Error Messages and Warnings</category></item><item><title>Compiler Error Messages</title><link>http://blogs.msdn.com/grantri/archive/2004/02/27/81349.aspx</link><pubDate>Sat, 28 Feb 2004 00:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:81349</guid><dc:creator>grantri</dc:creator><slash:comments>19</slash:comments><comments>http://blogs.msdn.com/grantri/comments/81349.aspx</comments><wfw:commentRss>http://blogs.msdn.com/grantri/commentrss.aspx?PostID=81349</wfw:commentRss><wfw:comment>http://blogs.msdn.com/grantri/rsscomments.aspx?PostID=81349</wfw:comment><description>&lt;P&gt;I've spent a fair amount of time lately tweaking the C# compiler's error messages.&amp;nbsp; At some point I begin to wonder, how clearly do we have to spell things out for end users?&amp;nbsp; There are at least 2 dozen different error messages that could be summarized with just &amp;#8220;not an l-value&amp;#8221;.&amp;nbsp; Now granted, there is an extreme.&amp;nbsp; Some compilers and tools do little more than tell you an error happened, and sometimes where it happened.&amp;nbsp; I believe an error message should indicate what&amp;nbsp;is wrong, and if possible how to fix it.&amp;nbsp; So my question for anybody who reads this an actually uses C#, do you feel like the compiler error messages are good or bad?&amp;nbsp; If you can give me specific examples maybe I can get a few things fixed before we ship ;)&lt;/P&gt;
&lt;P&gt;--Grant&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=81349" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/grantri/archive/tags/Error+Messages+and+Warnings/default.aspx">Error Messages and Warnings</category></item></channel></rss>