[Mono-dev] Generic Variance

Rodrigo Kumpera kumpera at gmail.com
Mon Feb 2 09:13:08 EST 2009


On Mon, Feb 2, 2009 at 11:54 AM, <lunchtimemama at gmail.com> wrote:

>
> > 2)mono_class_is_assignable_from
> > Don't do unneeded changes to existing conditions that just make your
> patch harder to read. By merging the two conditions your
> > patch got huge for no reason at all. Please revert this change so the
> patch is smaller.
>
> The chunk of code was extracted into the mono_class_is_variant_of method
> because it is also needed in mono_class_interface_offset. Duplicating the
> code in both places would just cause problems in the long-run.
>

Makes sense. Keep it that way then.



>
>
> > 3)mono_class_interface_offset
> > This function is used to define layout of classes, vtables and the such.
> You patch lacks neither a proper Changelog notice on why this change is
> needed or tests that evidence it.
>
> Tests are a bit of a chicken-and-egg problem. They can't be written in C#
> until it has variance support (there is a patch for that on the list which
> Marek is handling), and the C# patch has tests which require these VM
> changes. I _could_ write a test in IL, but that would take me a while. The
> changes to mono_class_interface_offset look for a legal variant of the
> supplied interface if nothing was found with the binary search. How specific
> do you want me to be in the ChangeLog?
>
>
Why this change is required to make variance works?
mono_class_interface_offset is a low level function used mainly to setup
vtable layout.

This change affects vtable layout code, remoting and reflection. Without
proper testing to make sure it doesn't break stuff and is compatible with MS
this patch is a no go.

The chicken and egg situation for testing can be overcome by either using IL
just for the interfaces, the rest can be done with C#; or you can use
System.Reflection.Emit to build types with variance.


Cheers,
Rodrigo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090202/29a0f890/attachment.html 


More information about the Mono-devel-list mailing list