Intellisense can's see XML comments when 2-dimensional array is present
I ran into a problem with Intellisense not seeing the XML comments on some (but not all) of my methods. It appears that this happens whenever a 2-dimensional array is in the argument list. For example, if I compile the code below into a DLL, then call that method in another solution, Intellisense doesn't show my XML comments. However, another method in that class does the same thing except that it takes a 1-dimensional array, and Intellisense shows its comments OK. (I had to leave the latter method out because the forum editor kept deletng a big chunk of my message, possibly because the code snippet was too big.)
The code itself works fine -- it's just that Intellisense fails to show some of my XML comments.
Looking at the XML generated by the compiler, I noticed that it contains this:
<member name="M:XmlTest1.PrintArray.PrintArray1(System.Int32[])">
for the 1-dimensional method. On the other hand, for the troublesome method that takes a 2-dimensional array, the XML says:
<member name="M:XmlTest1.PrintArray.PrintArray2(System.Int32[0:,0:])">
The difference is (System.Int32[]) vs. (System.Int32[0:,0:]). I thought that maybe the 0: stuff was to blame, so I edited the XML manually to change [0:,0:] to [,]. That cured the Intellisense problem! So is this a bug, or is something wrong with my source code?
I can live with the fix I discovered, as long as there are no side effects waiting to bite me.
Code Snippet
namespace XmlTest1
{
/// <summary>
/// Class to investigate XML comments problem.
/// </summary>
public static class PrintArray
{
/// <summary>
/// Print first element of a 2-dimensional array.
/// </summary>
/// <param name="a">array</param>
public static void PrintArray2(int[,] a)
{
Console.WriteLine(a[0, 0]);
}
}
}
One thing I may have failed to make clear -- Intellisense *does* work fine within the same Solution. I.e., if another Project within that Solution uses my example class, Intellisense sees the XML comments. But if you create a new Solution, adding the example DLL to the References, then it's as if there are no XML comments for the DLL.
So, to recap, build the code in my original post as a .NET Framework DLL, e.g. XmlTest1.dll. Close out that Solution, and create a new one, say, XmlTest2:
Code Snippet
namespace XmlTest2
{
class Program
{
static void Main(string[] args)
{
int[,] a2 = new int[,] { { 11, 12 }, { 21, 22 } };
XmlTest1.PrintArray.PrintArray2(a2);
}
}
}
Note that when typing in the call to PrintArray (or hovering the cursor over it), Intellisense doesn't show any of the XML comments. The program runs OK, though.
By the way, I'm using .NET Framework 2.0.