Re: [Mono-dev] Compiling Mono on Cygwin
Hi, Kevin Thompson [EMAIL PROTECTED] writes: ok i got past that but now i am having another problem. it says that I need to have a version of mcs installed... so I installed the latest release and added it to my path but I get some basic-profile-check error. Any ideas? I also tried to download yesterday's daily monolite package but that failed with an error from mcs.exe I'm assuming you're building an SVN snapshot. Try doing make get-monolite-latest make - Hari ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Compiling Mono on Cygwin
Looks like it is compiling now. Thank you for the help. On 10/27/05, Raja R Harinath [EMAIL PROTECTED] wrote:Hi,Kevin Thompson [EMAIL PROTECTED] writes: ok i got past that but now i am having another problem. it says that I need to have a version of mcs installed... so I installed the latest release and added it to my path but I get some basic-profile-check error. Any ideas? I also tried to download yesterday's daily monolite package but that failed with an error from mcs.exeI'm assuming you're building an SVN snapshot.Try doing make get-monolite-latestmake- Hari-- Kevin ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Problem when compiling (at runtime) a user web control
I've made a very simple web control: namespace MonoTestLib { public class TestComposant:System.Web.UI.WebControls.Label { public enum CWebContextMenuStyle { Test1, Test2, Standard } public TestComposant():base() { } public CWebContextMenuStyle MenuStyle { get { if (ViewState[CSSPREFIX]==null) return CWebContextMenuStyle.Standard; else return (CWebContextMenuStyle)ViewState[CSSPREFIX]; } set { ViewState[CSSPREFIX]=value; } } } } I've got compilation problems with it at runtime : i've opened a bug (76580) in bugzilla with a big description and a test case! ___Ce message et les éventuels documents joints peuvent contenir des informations confidentielles.Au cas où il ne vous serait pas destiné, nous vous remercions de bien vouloir le supprimer et en aviser immédiatement l'expéditeur. Toute utilisation de ce message non conforme à sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.Les communications sur internet n'étant pas sécurisées, l'intégrité de ce message n'est pas assurée et la société émettrice ne peut être tenue pour responsable de son contenu. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] [PATCH] Friend access for class members
Hey, 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'm also attaching the error reported when using it (cs0281) and some tests for various scenarios. Thanks in advance for the comments. Carlos. Index: typemanager.cs === --- typemanager.cs (revisión: 52299) +++ typemanager.cs (copia de trabajo) @@ -265,6 +265,8 @@ static Hashtable fieldbuilders_to_fields; static Hashtable fields; + static PtrHashtable assembly_internals_vis_attrs; + struct Signature { public string name; public Type [] args; @@ -289,6 +291,8 @@ priv_fields_events = null; type_hash = null; + + assembly_internals_vis_attrs = null; CleanUpGenerics (); TypeHandle.CleanUp (); @@ -393,6 +397,8 @@ fieldbuilders_to_fields = new Hashtable (); fields = new Hashtable (); type_hash = new DoubleHash (); + + assembly_internals_vis_attrs = new PtrHashtable (); InitGenerics (); } @@ -1822,6 +1828,80 @@ return false; } + // + // Checks whether `extern_type' is friend of the output assembly + // + public static bool IsFriendAssembly (Assembly assembly) + { + if (assembly_internals_vis_attrs.Contains (assembly)) + return (bool)(assembly_internals_vis_attrs [assembly]); + + object [] attrs = assembly.GetCustomAttributes (internals_visible_attr_type, false); + if (attrs.Length == 0) { + AddFriendAssembly (assembly, false); + return false; + } + + AssemblyName this_name = CodeGen.Assembly.Name; + byte [] this_token = this_name.GetPublicKeyToken (); + bool is_friend = false; + foreach (object o in attrs) { + InternalsVisibleToAttribute attr = o as InternalsVisibleToAttribute; + if (attr.AssemblyName == null || attr.AssemblyName.Length == 0) +continue; + + AssemblyName aname = null; + try { +aname = new AssemblyName (attr.AssemblyName); + } catch (FileLoadException) { + } catch (ArgumentException) { + } + + if (aname == null || aname.Name != this_name.Name) +continue; + + byte [] key_token = aname.GetPublicKeyToken (); + if (key_token != null) { +if (this_token == null) { + // Same name, but key token is null + Error_FriendAccessNameNotMatching (aname.FullName); + break; +} + +if (!CompareKeyTokens (this_token, key_token)) + continue; + } + + is_friend = true; + break; + } + + AddFriendAssembly (assembly, is_friend); + return is_friend; + } + + static bool CompareKeyTokens (byte [] token1, byte [] token2) + { + for (int i = 0; i token1.Length; i++) + if (token1 [i] != token2 [i]) +return false; + + return true; + } + + static string this_fullname; + + static void Error_FriendAccessNameNotMatching (string other_name) + { + if (this_fullname == null) + this_fullname = CodeGen.Assembly.Name.FullName; + + Report.Error (281, Friend access was granted to ` + other_name + +', but the output assembly is named ` + this_fullname + +'. Try adding a reference to ` + other_name + +' or change the output assembly name to match it.); + } + // // Do the right thing when returning the element type of an // array type based on whether we are compiling corlib or not @@ -2646,25 +2726,38 @@ MethodBase mb = (MethodBase) m; MethodAttributes ma = mb.Attributes MethodAttributes.MemberAccessMask; +if (ma == MethodAttributes.Public) + return true; + 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; + +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); +if (!IsFriendAssembly
Re: [Mono-dev] [PATCH] Friend access for class members
Hi, Carlos Alberto Cortez [EMAIL PROTECTED] 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 ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Relocatable Mono.
On 10/26/05 Miguel de Icaza wrote: The following patch makes Mono relocatable. Currently our installer uses a bunch of wrapper scripts around everything (mono, monodis and others) to overwrite the built-in prefixes that we use during the build process. With this patch, Mono becomes relocatable, as long as the whole Mono installation from the prefix is preserved in the layout expected by Mono. This patch has a special case: if Mono is installed with prefix=/usr, it assumes that configuration is on /etc (which is how we configure Mono today when we distribute it). Other than this case, the patch will work with a relocated Mono. This will also aid for those who need to bundle Mono with their applications without having to rebuild Mono: they can just ship the Mono files that we distribute from packages. Am running my Mono environment with this patch. Any objections to get this in? I think we should leave the default as it is now, instead of always trying to figure out the prefix. This lowers the maintainance issues, because the default build will work on operating systems that are not handled with the /proc hacks and that can't be handled in a similar way. As it is the patch likely breaks OS X, *BSD. lupus -- - [EMAIL PROTECTED] debian/rules [EMAIL PROTECTED] Monkeys do it better ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] [PATCH] Friend access for class members
Hey, I applied your suggestion and also removed some redundant comparations in the same place (for family, famor and famand). Also I've applied the changes to access friend internal classes. Finally, more tests are added, so I'm attaching them. Carlos. BTW, the tests are running just fine. El vie, 28-10-2005 a las 16:23 +0530, Raja R Harinath escribió: Hi, Carlos Alberto Cortez [EMAIL PROTECTED] 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 ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] [PATCH] Friend access for class members
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 [EMAIL PROTECTED] 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 Index: typemanager.cs === --- typemanager.cs (revisión: 52315) +++ typemanager.cs (copia de trabajo) @@ -252,6 +252,8 @@ static Hashtable fieldbuilders_to_fields; static Hashtable fields; + static PtrHashtable assembly_internals_vis_attrs; + struct Signature { public string name; public Type [] args; @@ -274,6 +276,8 @@ priv_fields_events = null; type_hash = null; + + assembly_internals_vis_attrs = null; CleanUpGenerics (); TypeHandle.CleanUp (); @@ -375,6 +379,8 @@ fieldbuilders_to_fields = new Hashtable (); fields = new Hashtable (); type_hash = new DoubleHash (); + + assembly_internals_vis_attrs = new PtrHashtable (); InitGenerics (); } @@ -1654,6 +1660,80 @@ return false; } + // + // Checks whether `extern_type' is friend of the output assembly + // + public static bool IsFriendAssembly (Assembly assembly) + { + if (assembly_internals_vis_attrs.Contains (assembly)) + return (bool)(assembly_internals_vis_attrs [assembly]); + + object [] attrs = assembly.GetCustomAttributes (internals_visible_attr_type, false); + if (attrs.Length == 0) { + AddFriendAssembly (assembly, false); + return false; + } + + AssemblyName this_name = CodeGen.Assembly.Name; + byte [] this_token = this_name.GetPublicKeyToken (); + bool is_friend = false; + foreach (object o
Re: [Mono-dev] [PATCH] Friend access for class members
Hello Carlos, My comments. +foreach (object o in attrs) { +InternalsVisibleToAttribute attr = o as InternalsVisibleToAttribute; I think you can use InternalsVisibleToAttribute directly in foreach +static string this_fullname; + +static void Error_FriendAccessNameNotMatching (string other_name) +{ +if (this_fullname == null) +this_fullname = CodeGen.Assembly.Name.FullName; + +Report.Error (281, Friend access was granted to ` + other_name + +', but the output assembly is named ` + this_fullname + +'. Try adding a reference to ` + other_name + +' or change the output assembly name to match it.); +} 1. Do you really need this `string this_fullname' 2. Please don't end error message with '.' 3. Please use bla `{0}' bla syntax, it is easier to read. Marek 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 [EMAIL PROTECTED] 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 Index: typemanager.cs === --- typemanager.cs (revisión: 52315) +++ typemanager.cs (copia de trabajo) @@ -252,6 +252,8 @@ static Hashtable fieldbuilders_to_fields; static Hashtable fields; + static PtrHashtable assembly_internals_vis_attrs; + struct Signature {
Re: [Mono-dev] [PATCH] Friend access for class members
Hey Marek, Comments below: El vie, 28-10-2005 a las 14:51 +0100, Marek Safar escribió: Hello Carlos, My comments. +foreach (object o in attrs) { +InternalsVisibleToAttribute attr = o as InternalsVisibleToAttribute; I think you can use InternalsVisibleToAttribute directly in foreach +static string this_fullname; + +static void Error_FriendAccessNameNotMatching (string other_name) +{ +if (this_fullname == null) +this_fullname = CodeGen.Assembly.Name.FullName; + +Report.Error (281, Friend access was granted to ` + other_name + +', but the output assembly is named ` + this_fullname + +'. Try adding a reference to ` + other_name + +' or change the output assembly name to match it.); +} 1. Do you really need this `string this_fullname' Well, every time we access to AssemblyName.FullName, a new string is created. I know keeping this temporary string could be a little ugly, so I created this method. 2. Please don't end error message with '.' 3. Please use bla `{0}' bla syntax, it is easier to read. Ok, fixed the styles of the error messages. Carlos. Marek 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 [EMAIL PROTECTED] 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 Index: typemanager.cs === ---
Re: [Mono-dev] [PATCH] Friend access for class members
Hello, My comments. +foreach (object o in attrs) { +InternalsVisibleToAttribute attr = o as InternalsVisibleToAttribute; I think you can use InternalsVisibleToAttribute directly in foreach +static string this_fullname; + +static void Error_FriendAccessNameNotMatching (string other_name) +{ +if (this_fullname == null) +this_fullname = CodeGen.Assembly.Name.FullName; + +Report.Error (281, Friend access was granted to ` + other_name + +', but the output assembly is named ` + this_fullname + +'. Try adding a reference to ` + other_name + +' or change the output assembly name to match it.); +} 1. Do you really need this `string this_fullname' Well, every time we access to AssemblyName.FullName, a new string is created. I know keeping this temporary string could be a little ugly, so I created this method. I think it is not worthwhile as this is used only when multiple errors occur. It would be nice to implement errors 1725 and 1726 as well. Marek 2. Please don't end error message with '.' 3. Please use bla `{0}' bla syntax, it is easier to read. Ok, fixed the styles of the error messages. Carlos. Marek 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 [EMAIL PROTECTED] 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
Re: [Mono-dev] [PATCH] Friend access for class members
Hey +foreach (object o in attrs) { +InternalsVisibleToAttribute attr = o as InternalsVisibleToAttribute; I think you can use InternalsVisibleToAttribute directly in foreach +static string this_fullname; + +static void Error_FriendAccessNameNotMatching (string other_name) +{ +if (this_fullname == null) +this_fullname = CodeGen.Assembly.Name.FullName; + +Report.Error (281, Friend access was granted to ` + other_name + +', but the output assembly is named ` + this_fullname + +'. Try adding a reference to ` + other_name + +' or change the output assembly name to match it.); +} 1. Do you really need this `string this_fullname' Well, every time we access to AssemblyName.FullName, a new string is created. I know keeping this temporary string could be a little ugly, so I created this method. I think it is not worthwhile as this is used only when multiple errors occur. It would be nice to implement errors 1725 and 1726 as well. Ok, then lemme remove that static element. BTW, 1726 is being reported already ;-) I will commit if you don't mind (I will add the test for 1725 as soon as I find it ;-) ) Carlos. Marek 2. Please don't end error message with '.' 3. Please use bla `{0}' bla syntax, it is easier to read. Ok, fixed the styles of the error messages. Carlos. Marek 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 [EMAIL PROTECTED] 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 || -
Re: [Mono-dev] [PATCH] Friend access for class members
Hello, One final comment: please profile the code before and after, and lets explore if there are any regressions memory-allocation wise. Miguel. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] XSP crash and patch
I've run into a problem with the latest xsp from the trunk. Under mono 1.1.9.1 I can repeatedly cause xsp to crash by simply pointing Microsoft's Web Application Stress Tool at it and having it request any file, even a static file. When the Stress tool finishes its run xsp crashes from what appears to be the result of a socket exception. The included patch seems to solve the issue, but I don't claim to have a solid understanding of the inner workings of xsp and what else this may effect. If I can provide more information that may help please let me know what you need. Link to Microsoft's Web Application Stress Tool: http://www.microsoft.com/downloads/details.aspx?FamilyID=E2C0585A-062A-439E- A67D-75A89AA36495displaylang=en Mike Glenn xspSocketException.patch Description: Binary data ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] System.Colletions.Generic.SortedList
Hi I implemented a SortedList for the Mono Framework. I would be great if we can put it to the Source Tree. I need if for a implementation of the BitTorrent Protokol in C#. Sorry, for this question i know that i will find it some where on the wiki, but it's simpler in this way =). When is planed to bring up a stable C# 2.0 version of the Mono Project? felix // // System.Collections.Generic.SortedList // // Author: //Felix Marthaler // // (C) 2005 Felix Marthaler ([EMAIL PROTECTED]) // // // Copyright (C) 2005 Felix Marthaler // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // Software), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #if NET_2_0 using System; using System.Collections; using System.Runtime.Serialization; using System.Runtime.InteropServices; namespace System.Collections.Generic { [SerializableAttribute, ComVisibleAttribute(false)] public class SortedListTKey,TValue : IDictionaryTKey, TValue, ICollectionKeyValuePairTKey, TValue, IEnumerableKeyValuePairTKey, TValue, IDictionary, ICollection, IEnumerable { private IComparerTKey comparer = null; private uint size = 0; private uint capacity = 0; private uint version = 0; private TKey[] sortedKeys = null; private TValue[] sortedValues = null; private object syncRoot = null; public SortedList() { if (this.capacity == 0) this.Capacity = 8; if (this.sortedKeys == null this.sortedValues == null) { this.sortedKeys = new TKey[this.Capacity]; this.sortedValues = new TValue[this.Capacity]; } if (this.comparer == null) this.comparer = ComparerTKey.Default; this.syncRoot = new object(); } public SortedList(IComparerTKey comparer) : this() { if (comparer != null) this.comparer = comparer; } public SortedList(IDictionaryTKey, TValue dictionary) : this() { foreach( KeyValuePairTKey, TValue entry in dictionary ) { this.Add(entry.Key, entry.Value); } } public SortedList(int capacity) : this() { this.Capacity = capacity; } public SortedList(IDictionaryTKey, TValue dictionary, IComparerTKey comparer) : this(dictionary) { if (comparer != null) this.comparer = comparer; } public SortedList(int capacity, IComparerTKey comparer) : this(comparer) { this.Capacity = capacity; } public void Add(TKey key, TValue value) { if (key == null) throw new ArgumentNullException(); int pos = Array.BinarySearch(this.sortedKeys, 0, (int)this.size, key, this.comparer); if (pos = 0) throw new ArgumentException(key allready exists); this.InsertAt(~pos, key, value); this.version++; } void IDictionary.Add(object key, object value) { if (key is TKey value is TValue) this.Add((TKey)key, (TValue)value); else throw new ArgumentException(); } void ICollectionKeyValuePairTKey,TValue.Add(KeyValuePairTKey,TValue kvPair) { this.Add(kvPair.Key, kvPair.Value); } public void Clear() { this.size = 0; Array.Clear(this.sortedKeys, 0, this.Capacity); Array.Clear(this.sortedValues, 0, this.Capacity); this.version++; } public bool ContainsKey(TKey key) { int pos = Array.IndexOf(this.sortedKeys, key); if (pos = 0) return true; return false; } public bool ContainsValue(TValue value) { int pos =
Re: [Mono-dev] System.Colletions.Generic.SortedList
This is looking pretty good: * Since the enumerator is private, can you use a `yield' based one? that will be cleaner. * The indentation is a bit funkey, please use tags * When you do int pos = Array.IndexOf(this.sortedKeys, key); for Contains, etc, you should use binary search, as it will be faster * It's cleaner to do if (blah) throw Exception; ... rather than if (!blah) ...; else throw Exception (); * IDictionary.Remove argument checking is incorrect * Needs test cases * (does msft use some sort of tree structure here? -- this is only an initial impl, so it's not really necessary to be fully optimal). -- Ben ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list