[mcs] Validate more nameof argument expressions
[mono.git] / mcs / class / System.ComponentModel.Composition / src / ComponentModel / System / ComponentModel / Composition / AttributedModel / AttributedPartCreationInfo.cs
index c46da4adaebd2b7772e418d3d0722cf4df24dac7..9bc3d2f705b4eea13747f641713772438de37844 100644 (file)
@@ -193,7 +193,10 @@ namespace System.ComponentModel.Composition.AttributedModel
 \r
         private void DiscoverExportsAndImports()\r
         {\r
-            if (this._exports != null)\r
+            // NOTE : in most cases both of these will be null or not null at the same time\r
+            // the only situation when that is not the case is when there was a failure during the previous discovery\r
+            // and one of them ended up not being set. In that case we will force the discovery again so that the same exception is thrown.\r
+            if ((this._exports != null) && (this._imports != null))\r
             {\r
                 return;\r
             }\r
@@ -325,10 +328,11 @@ namespace System.ComponentModel.Composition.AttributedModel
             {\r
                 yield break;\r
             }\r
-\r
+            \r
             // Stopping at object instead of null to help with performance. It is a noticable performance\r
             // gain (~5%) if we don't have to try and pull the attributes we know don't exist on object.\r
-            while (currentType != CompositionServices.ObjectType)\r
+            // We also need the null check in case we're passed a type that doesn't live in the runtime context.\r
+            while (currentType != null && currentType != CompositionServices.ObjectType)\r
             {\r
                 if (IsInheritedExport(currentType))\r
                 {\r
@@ -399,7 +403,8 @@ namespace System.ComponentModel.Composition.AttributedModel
 \r
                 // Stopping at object instead of null to help with performance. It is a noticable performance\r
                 // gain (~5%) if we don't have to try and pull the attributes we know don't exist on object.\r
-                while (baseType != CompositionServices.ObjectType)\r
+                // We also need the null check in case we're passed a type that doesn't live in the runtime context.\r
+                while (baseType != null && baseType != CompositionServices.ObjectType)\r
                 {\r
                     foreach (MemberInfo member in GetDeclaredOnlyImportMembers(baseType))\r
                     {\r