[Mono-dev] Patch to add missing v2 System.Exception constructors, and HResult consistency

Andy Hume andyhume32 at yahoo.co.uk
Wed Jan 10 15:00:09 EST 2007

A project of mine uses #ctor(String,Exception) on ObjectDisposedException, so I looked at adding that, and any other similar constructors missing as per the class status report.

I also spotted inconsistent setting of HResult, and fixed those too.  For instance, ArgumentNullException sets HResult only in three out of the four constuctors; not setting it in the v2 (String,Exception) one -- and correctly not in the Serialization constructor.

So, I fixed the remaining missing (String,Exception) constructors in corlib (2 of), and fixed the Hresult setting in all exceptions there (4 of).

The remaining Exception constructor omission listed was InvalidCastException.ctor(System.String, System.Int32).  MSDN says:
"This constructor supplies an HRESULT value that is accessible to inheritors of the InvalidCastException class, via the protected HResult property of the Exception class."
I added that method too, setting the HResult property from the Int32 argument.

I attach a patch for all that.  A caveat though, as I expect setting up the build environment may take me some time on my Windows box, I added all the corlib files into a Visual Studio project and compiled it there...  So no further testing could be  done...  Don't know whether that's of any use, or just trouble. :-,(


All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 

More information about the Mono-devel-list mailing list