[Mono-dev] [PATCH] NRE in gmcs with -doc flag

Bill Holmes billholmes54 at gmail.com
Sat Jul 21 11:53:22 EDT 2007

Resent with the correct subject line (Mono-dev).  Sorry for the double post.

I was wondering if someone close to generating XML documentation in
gmcs (or some other expert) could review this patch and give me the ok
to commit.  I thought I would try sending an e-mail to the list before
filing a bug with the patch like I usually do.  To validate this patch
I performed the usual complete rebuild of mono and make check and the
results look good.

I found a null reference exception with the latest version of gmcs.
Compiling the attached test.cs with the -doc flag I see the following

error CS1569: Error generating XML documentation file `MyTest.xml'
(`Object reference not set to an instance of an object')

I was able to track it down to
Mono.CSharp.DocUtil.GetMethodDocCommentName.  Exception occurs on line
883 because mc.MemberName.TypeArguments is null for this case.

I found a property in the Mono.CSharp.MemberName class
CountTypeArguments does null checking and returns the count of
TypeArguments or zero.  I changed this property to also check the Left
member variable before returning 0.  Checking the Left variable is
more consistent with the IsGeneric property in the same class.  I did
a reference lookup and found no other code using this property.

Then I changed GetMethodDocCommentName to use the CountTypeArguments
property to avoid the NRE.

It is my guess that this area of the code is still a work in progress
since the output xml doc file does not match MS csc.  The difference I
notice is as follows

Mono output :
<member name="M:Test.TestItf2.TestMethod``2">

MS output :
<member name="M:Test.TestItf2{System#Int32 at System#Double}#TestMethod">

The attached proposed patch does not attempt to match the MS's output
format; it avoids the NRE and follows the output format of current
mono.  Or at least what the original code was attempting to construct.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.cs
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070721/be2f5ebd/attachment.pl 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: docBug.diff
Type: application/octet-stream
Size: 1643 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070721/be2f5ebd/attachment.obj 

More information about the Mono-devel-list mailing list