[Mono-bugs] [Bug 61188][Nor] New - Mono.GetOptions fails

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 6 Jul 2004 01:30:44 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by mathpup@mylinuxisp.com.

http://bugzilla.ximian.com/show_bug.cgi?id=61188

--- shadow/61188	2004-07-06 01:30:44.000000000 -0400
+++ shadow/61188.tmp.5362	2004-07-06 01:30:44.000000000 -0400
@@ -0,0 +1,90 @@
+Bug#: 61188
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Mono.POSIX
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mathpup@mylinuxisp.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mono.GetOptions fails
+
+Description of Problem: 
+ 
+I'm not positive whether this is a Mono bug or a Mono.GetOptions bug. I 
+recently added an additional Option to my class, and now I'm getting 
+strange behavior. Based on the example included with the library, if I do 
+not want a long-form option, I should use null for that slot. (If I omit 
+the null, the Options class automatically uses the method name). 
+ 
+Using the following options worked fine (omitting function bodies for 
+brevity): 
+ 
+[Option( 1, "Sets verbosity to quiet (only errors)", 'q', null )] 
+public WhatToDoNext SetQuiet() 
+ 
+[Option( 1, "Sets verbosity to detailed (verbose)", 'v', null )] 
+ 
+[Option( 1, "Sets verbosity to q[uiet], m[inimal], n[ormal], d[etailed], 
+or diag[nostics]", "verbosity" )] 
+public WhatToDoNext SetVerbosity( string value ) 
+ 
+ 
+But when I added the option below 
+ 
+[Option( 1, "Apple", 'p', null  )] 
+public WhatToDoNext SetProperty( string text ) 
+ 
+I began to get errors: 
+ 
+Unhandled Exception: System.NullReferenceException: Object reference not 
+set to an instance of an object 
+in [0x000d4] 
+(at /home/marcus/src/mcs/class/Mono.GetOptions/OptionDetails.cs:170) 
+Mono.GetOptions.OptionDetails:.ctor 
+(System.Reflection.MemberInfo,Mono.GetOptions.OptionAttribute,Mono.GetOptions.Options) 
+in [0x00179] 
+(at /home/marcus/src/mcs/class/Mono.GetOptions/OptionList.cs:193) 
+Mono.GetOptions.OptionList:Initialize (Mono.GetOptions.Options) 
+in [0x0006e] 
+(at /home/marcus/src/mcs/class/Mono.GetOptions/OptionList.cs:203) 
+Mono.GetOptions.OptionList:.ctor (Mono.GetOptions.Options) 
+in [0x00002] (at /home/marcus/src/mcs/class/Mono.GetOptions/Options.cs:46) 
+Mono.GetOptions.Options:ProcessArgs (string[]) 
+in [0x00008] (at /home/marcus/alpha/mubuild/Main.cs:26) MUBuild:Main 
+(string[]) 
+ 
+The problem appears to be that line 170 has 
+	if (this.LongForm.IndexOf(':') >= 0) 
+and this.LongForm is empty when the last attribute/method is processed. 
+Changing it to 
+	if (this.LongForm != null && ...) seems to fix it, but I don't 
+know why the error fails to occur in the first and second attributes. (I 
+inserted some debugging code into the GetOptions source to narrow down 
+that it was this last one that causes the problem.) 
+ 
+Also, the sample application in Mono.GetOptions/GetOptTest fails in the 
+same way. 
+ 
+ 
+Steps to reproduce the problem: 
+1. mcs -r:MonoGetOptions MonoGetOptions/GetOptTest/*.cs 
+2. mono GetOptTest.exe 
+ 
+ 
+Actual Results: 
+ 
+See above 
+ 
+ 
+ 
+How often does this happen?  
+ 
+Always