Rework gc descriptor to include size information in more cases.
[mono.git] / mcs / mcs / import.cs
index 137c5ccb381189b1079cd76372e1219f75957b68..7a3081c7cbbf8d660c279480fcf9446993c0a097 100644 (file)
@@ -5,7 +5,8 @@
 //
 // Dual licensed under the terms of the MIT X11 or GNU GPL
 //
-// Copyright 2009, 2010 Novell, Inc
+// Copyright 2009-2011 Novell, Inc
+// Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
 //
 
 using System;
@@ -168,7 +169,8 @@ namespace Mono.CSharp
                                        break;
                                default:
                                        // Ignore private fields (even for error reporting) to not require extra dependencies
-                                       if (IgnorePrivateMembers || HasAttribute (CustomAttributeData.GetCustomAttributes (fi), "CompilerGeneratedAttribute", CompilerServicesNamespace))
+                                       if ((IgnorePrivateMembers && !declaringType.IsStruct) ||
+                                               HasAttribute (CustomAttributeData.GetCustomAttributes (fi), "CompilerGeneratedAttribute", CompilerServicesNamespace))
                                                return null;
 
                                        mod = Modifiers.PRIVATE;
@@ -962,6 +964,15 @@ namespace Mono.CSharp
                        if (spec.BaseType != null) {
                                var bifaces = spec.BaseType.Interfaces;
                                if (bifaces != null) {
+                                       //
+                                       // Before adding base class interfaces close defined interfaces
+                                       // on type parameter
+                                       //
+                                       var tp = spec as TypeParameterSpec;
+                                       if (tp != null && tp.InterfacesDefined == null) {
+                                               tp.InterfacesDefined = TypeSpec.EmptyTypes;
+                                       }
+
                                        foreach (var iface in bifaces)
                                                spec.AddInterface (iface);
                                }
@@ -1877,7 +1888,13 @@ namespace Mono.CSharp
                                        if ((t.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate && importer.IgnorePrivateMembers)
                                                continue;
 
-                                       imported = importer.CreateNestedType (t, declaringType);
+                                       try {
+                                               imported = importer.CreateNestedType (t, declaringType);
+                                       } catch (Exception e) {
+                                               throw new InternalErrorException (e, "Could not import nested type `{0}' from `{1}'",
+                                                       t.FullName, declaringType.MemberDefinition.DeclaringAssembly.FullName);
+                                       }
+
                                        cache.AddMemberImported (imported);
                                }
 
@@ -1894,6 +1911,15 @@ namespace Mono.CSharp
                                }
                        }
 
+                       //
+                       // Load base interfaces first to minic behaviour of compiled members
+                       //
+                       if (declaringType.IsInterface && declaringType.Interfaces != null) {
+                               foreach (var iface in declaringType.Interfaces) {
+                                       cache.AddInterface (iface);
+                               }
+                       }
+
                        if (!onlyTypes) {
                                //
                                // The logic here requires methods to be returned first which seems to work for both Mono and .NET
@@ -2024,12 +2050,6 @@ namespace Mono.CSharp
                                        cache.AddMemberImported (imported);
                                }
                        }
-
-                       if (declaringType.IsInterface && declaringType.Interfaces != null) {
-                               foreach (var iface in declaringType.Interfaces) {
-                                       cache.AddInterface (iface);
-                               }
-                       }
                }
        }