[Mono-dev] DriveInfo implementation

Robert Jordan robertj at gmx.net
Thu Dec 6 10:44:34 EST 2007


Javier Martín wrote:
> Robert Jordan wrote:
>> Hi Javier,
>>
>> The PLATFORM_WIN32 conditional in icall.c must be avoided.
>> Since you're going to implement GetDiskFreeSpaceEx in io-layer
>> it will be not necessary. But I guess you already know this
>> and tried to keep the code compilable, correct?
> 
> Er, no. At the time I wrote that code I was in doubt. I didn't know if
> I would take the Win32+iolayer way (which seems the most probable now)
> or the ifdef+posix way (which is used in other icalls like the ones
> from System.Environment). The first way seems cleaner at first, but
> the second avoids double marshaling of strings (first to utf16 at the
> icall for the win32 API, then to utf8 at io-layer for the POSIX call).
> Also, as you said, I wanted my patch to keep the SVN tree compilable
> on all supported platforms. So, when I get to the posix port, I will
> either remove that #ifdef or fill the #else case.

There is no double marshaling because the utf-16 conversion is cheap.
The double allocation is not so relevant in this case. More important
is API cleanliness.

>> Also, do not use g_assert if you already thrown an exception.
>> This will kill the runtime.
> 
> Ok, so I'm leaving the checks code as exceptions, not as assertions.
> By the way, does the unmanaged method return immediately when an
> exception is raised or does it need to actually execute a "return"?

Indeed, it won't be reached anyways.

> Conclusion: since all the fuss is about two coments (one about
> assertions in icall.c and one about the Unix PlatformID hack in
> DriveInfo.cs), I'm too lazy to submit an updated patch just for that
> u_u. I'll remove them (if noone does it first) when I submit the posix
> port patch.

Feel free to post patches only if you have questions, as we
won't test them until you've finished.

Robert




More information about the Mono-devel-list mailing list