2002-11-21 Miguel de Icaza <miguel@ximian.com>
+ * typemanager.cs (FilterWithClosure): Commented out the test for
+ 1540 in typemanager.cs, as it has problems when accessing
+ protected methods from a parent class (see test-174.cs).
+
+ Notice that 1540 is still caught elsewhere.
+
* attribute.cs (Attribute.ValidateGuid): new method.
(Attribute.Resolve): Use above.
MemberInfo[] group;
group = TypeManager.MemberLookup (
- PropertyInfo.DeclaringType, PropertyInfo.DeclaringType,
+ invocation_type, PropertyInfo.DeclaringType,
MemberTypes.Method, flags, accessor_name + "_" + PropertyInfo.Name);
//
foreach (MethodInfo mi in group) {
MethodAttributes ma = mi.Attributes & MethodAttributes.MemberAccessMask;
- // If only accessible to the current class.
+ //
+ // If only accessible to the current class or children
+ //
if (ma == MethodAttributes.Private) {
- if (mi.DeclaringType != invocation_type)
- continue;
- else
+ Type declaring_type = mi.DeclaringType;
+
+ if (invocation_type != declaring_type){
+ if (TypeManager.IsSubclassOrNestedChildOf (invocation_type, mi.DeclaringType))
+ return mi;
+ else
+ continue;
+ } else
return mi;
}
-
//
// FamAndAssem requires that we not only derivate, but we are on the
// same assembly.
if (!IsSubclassOrNestedChildOf (closure_invocation_type, mb.DeclaringType))
return false;
+#if false
+ //
+ // See test 174 for a sample. Essentially, it is ok in a derived
+ // class to invoke a base class protected method. 1540 is still caught
+ // elsewhere
+ //
+
// Although a derived class can access protected members of its base class
// it cannot do so through an instance of the base class (CS1540).
if (!mb.IsStatic && (closure_invocation_type != closure_start_type) &&
- closure_invocation_type.IsSubclassOf (closure_start_type))
+ closure_start_type != mb.DeclaringType)
return false;
-
+#endif
+
return true;
}
if (!IsSubclassOrNestedChildOf (closure_invocation_type, fi.DeclaringType))
return false;
+#if false
+ //
+ // See test-174 for a sample.
+ //
+
// Although a derived class can access protected members of its base class
// it cannot do so through an instance of the base class (CS1540).
if (!fi.IsStatic && (closure_invocation_type != closure_start_type) &&
- closure_invocation_type.IsSubclassOf (closure_start_type))
+ closure_start_type != fi.DeclaringType)
return false;
-
+#endif
+
return true;
}
// If we are a nested class, we always have access to our container
// type names
//
- if (invocation_type != null){
- string invocation_name = invocation_type.FullName;
- if (invocation_name.IndexOf ('+') != -1){
- string container = queried_type.FullName + "+";
- int container_length = container.Length;
-
- if (invocation_name.Length > container_length){
- string shared = invocation_name.Substring (0, container_length);
-
- if (shared == container)
- always_ok_flag = true;
- }
- }
- }
+ if (invocation_type != null)
+ always_ok_flag = IsSubclassOrNestedChildOf (invocation_type, queried_type);
do {
MemberList list;