[Mono-dev] [PATCH] Friend access for class members

Carlos Alberto Cortez calberto.cortez at gmail.com
Fri Oct 28 07:02:03 EDT 2005


I forgot to attach the patch ;-)

Carlos.


El vie, 28-10-2005 a las 16:23 +0530, Raja R Harinath escribió:
> Hi,
> 
> Carlos Alberto Cortez <calberto.cortez at gmail.com> writes:
> 
> > The attached patch implements friend access for class members (methods,
> > properties, fields). 
> >
> > I'm not including the type-check section, since that part will be
> > modified (next merge to gmcs) and I'm waiting for that to happen.
> > However, that change should be small (I will send the patch).
> 
> I have completed the merge of the relevant parts.  Please post an
> updated patch.
> 
> Meanwhile, I have some comments:
> 
> [snip]
> > @@ -2646,25 +2726,38 @@
> >  				MethodBase mb = (MethodBase) m;
> >  				MethodAttributes ma = mb.Attributes & MethodAttributes.MemberAccessMask;
> >  
> > +				if (ma == MethodAttributes.Public)
> > +					return true;
> 
> Ok.
> 
> >  				if (ma == MethodAttributes.Private)
> >  					return private_ok ||
> >  						IsPrivateAccessible (invocation_type, m.DeclaringType) ||
> >  						IsNestedChildOf (invocation_type, m.DeclaringType);
> >  
> > -				if (invocation_assembly == mb.DeclaringType.Assembly) {
> > +				if (invocation_assembly == mb.DeclaringType.Assembly)
> >  					if (ma == MethodAttributes.Assembly || ma == MethodAttributes.FamORAssem)
> >  						return true;
> > -				} else {
> > -					if (ma == MethodAttributes.Assembly || ma == MethodAttributes.FamANDAssem)
> > -						return false;
> 
> I would retain the old code, and change the check to:
> 
>   if (invocation_assembly == mb.DeclaringType.Assembly ||
>       TypeManager.InternalsVisibleTo (invocation_assembly, mb.DeclaringType.Assembly)) 
> 
> > +					
> > +				if (ma == MethodAttributes.Family ||
> > +				    ma == MethodAttributes.FamANDAssem ||
> > +				    ma == MethodAttributes.FamORAssem) {
> > +					if (!CheckValidFamilyAccess (mb.IsStatic, m)) {
> > +						if (ma == MethodAttributes.Family || ma == MethodAttributes.FamANDAssem)
> > +							return false;
> > +					} else {
> > +						// We are valid
> > +						if (ma == MethodAttributes.Family || ma == MethodAttributes.FamORAssem)
> > +							return true;
> > +						
> > +						// Check for FamANDAssem
> > +						if (invocation_assembly == mb.DeclaringType.Assembly)
> > +							return true;
> > +					}
> >  				}
> > -				if (ma == MethodAttributes.Family ||
> > -				    ma == MethodAttributes.FamANDAssem ||
> > -				    ma == MethodAttributes.FamORAssem)
> > -					return CheckValidFamilyAccess (mb.IsStatic, m);
> 
> I don't like this too much.  I'd much rather keep the old code.
> 
> - Hari
-------------- next part --------------
A non-text attachment was scrubbed...
Name: friend.diff
Type: text/x-patch
Size: 9195 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20051028/11b00ef1/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: friend-test.tar.gz
Type: application/x-compressed-tar
Size: 2710 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20051028/11b00ef1/attachment-0001.bin 


More information about the Mono-devel-list mailing list