[Mono-osx] MonoMac: NSUrlConnection

Duane Wandless duane at wandless.net
Sat Jul 17 11:58:40 EDT 2010


Miguel - I saw that you added a handwritten method for
SendSynchronousRequest.  I understand the motivation for this but in general
I do not think we want to hand write methods that use NSError**.  And as
written it does not function.

The ByRefPostProcessing change I already submitted for generator.cs works
for binding NSError** as out NSError.  However it has one side affect that
you cannot choose to ignore the parameter.  Which I believe was at least
part of the motivation for the handwritten method.

I have the beginnings of a modification to generator.cs to bind NSError** as
ref NSError, instead of out NSError.  With this you are required to pass in
an object, but if you pass null the parameter is ignored.

            NSURLResponse respUrl;
            NSError respErr = new NSError(NSObjectFlag.Empty);

            NSData data = NSUrlConnection.SendSynchronousRequest(m_urlReq,
out respUrl, ref respErr);

Technically all Type** arguments should then be bound as ref.  Which I think
is less than ideal.  As you have to create a dummy C# object that is then
replaced.  Though as bindings are added we can choose to use either out or
ref depending on context.

So there are two solutions that I see:

   1. use with the current ByRefPostProcessing of out, which means the
   parameter is never ignored
   2. add code to supporting binding by ref as well as by out

I think it is sufficient to go with #1.  I cannot think of a huge advantage
to providing #2.  And requiring the use of NSObjectFlag.Empty seems
cumbersome.

For now I have commented out Foundation/NSUrlConnection.cs (as it prevents
the binding from compiling).  And I am using this binding in foundation.cs:

                [Static, Export
("sendSynchronousRequest:returningResponse:error:")]
                NSData SendSynchronousRequest (NSUrlRequest request, out
NSUrlResponse response, out NSError error);

And everything works as expected.

If you want to go with #2 I can finish that code and submit a patch.  Let me
know.

Thanks,
Duane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100717/5d4514a4/attachment-0001.html 


More information about the Mono-osx mailing list