Small Suggestion Regarding "Correction Comments" in Compiler Error Code Articles (Like this one for CS0230)
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 370
Description
When Visual Studio gives an error code it provides a hyperlink to the official MS article regarding the error (like this one for CS0230). I like this little feature. Very helpful. And I like how these articles provide both (1) an example of C# code that generates the error and (2) a comment showing the correction for the error.
This is often exactly what a coder wants and all they need: A quick example of code clearly demonstrating the error (and the correction) in a style and format that is very easy to "see" and understand quickly. However, I think the "correction comment" should probably "stand-out" more in these articles. Ultimately, that is what the reader is really looking for: the correct way.
The "correction comment" in these articles is a bit mild and understated. It is even written in all lower case letters which is not very "eye catching". When referencing these pages, a coder is looking to "see" and understand them quickly. I think making the "correction comment" a little more "eye catching" would help. This suggestion below might help the coder get to the "correction" a little quicker.
NOTE: I am not necessarily recommending this style of commenting for commenting code in general. But, these pages have a special purpose which they understate in a mild fashion.
Below uses this CS0230 error page as an example.
I would suggest the change described below - or something like it.
Change From:
//try the following line instead
Change To:
// *** CORRECTED CODE BELOW ***
// *** THE COMMENTED CODE BELOW CORRECTS THE ERROR GENERATED BY THE CODE ABOVE
Below, I expand the text in this example taken from this CS0230. I think it demonstrates the difference even more.
Change From:
class MyClass
{
public static void Main()
{
int[] myarray = new int[3] {1,2,3};
foreach (int in myarray) // CS0230
// try the following line instead
// foreach (int x in myarray)
{
Console.WriteLine(x);
}
}
}
Change To:
class MyClass
{
public static void Main()
{
int[] myarray = new int[3] {1,2,3};
foreach (int in myarray) // CS0230
// *** CORRECTED CODE BELOW
// *** THE COMMENTED CODE BELOW CORRECTS THE ERROR GENERATED BY THE CODE ABOVE
// foreach (int x in myarray)
{
Console.WriteLine(x);
}
}
}
Did you see the difference quickly and easily? If so, people referencing these error code pages will likely see the same.
Just a suggestion.
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 416d2cb6-250d-f20a-2351-39c7d31d0ac0
* Version Independent ID: 12889d33-75e4-b698-f020-3f63061f5768
* Content: [Compiler Error CS0230](https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0230?f1url=%3FappId%3Droslyn%26k%3Dk(CS0230))
* Content Source: [docs/csharp/misc/cs0230.md](https://github.com/dotnet/docs/blob/main/docs/csharp/misc/cs0230.md)
* Product: **dotnet-csharp**
* Technology: **csharp-diagnostics**
* GitHub Login: @BillWagner
* Microsoft Alias: **wiwagn**
Contributor guide
Assessment
This issue has not been assessed yet.