runtime icon indicating copy to clipboard operation
runtime copied to clipboard

ArgumentNullException not thrown from delegate serialization if 'info' is null

Open fadimounir opened this issue 9 years ago • 5 comments

Calling GetObjectData() on delegates with a null 'info' parameter should throw an ArgumentNullException, not a NullReferenceException.

MSDN documentation: https://msdn.microsoft.com/en-us/library/system.multicastdelegate.getobjectdata(v=vs.110).aspx

fadimounir avatar Feb 15 '17 00:02 fadimounir

This code should be added to MulticastDelegate.GetObjectData:

        if (info == null)
            throw new ArgumentNullException(nameof(info));
        Contract.EndContractBlock();

fadimounir avatar Feb 15 '17 00:02 fadimounir

I just tried this in desktop and it seems to throwing System.NullReferenceException same as .net core. I believe this will be a breaking change for desktop if we decide to change it for desktop. And looking at mono code I believe it will also throw NullReferenceException. For net core we should be maintain the same behavior. So I do not intend to make any change here.

rahku avatar Feb 17 '17 00:02 rahku

The NullReferenceException is incorrect. On ProjectN/CoreRT, we are throwing the correct exception and we should fix the Desktop/netcore to achieve the correct documented behavior. This is an acceptable breaking change.

fadimounir avatar Feb 17 '17 01:02 fadimounir

This will not be fixed in desktop and it is not worth fixing this for net core if we are not fixing for desktop. @fadimounir are you ok with closing this issue?

rahku avatar Mar 02 '17 20:03 rahku

ok

fadimounir avatar Mar 02 '17 20:03 fadimounir