Remove Microsoft.Internal from System.Composition.*
authorRedouane Sobaihi <s-redouane@outlook.com>
Sat, 30 Jun 2018 16:53:22 +0000 (17:53 +0100)
committerViktor Hofer <viktor.hofer@microsoft.com>
Thu, 5 Jul 2018 23:20:52 +0000 (01:20 +0200)
Commit migrated from https://github.com/dotnet/corefx/commit/c6f257fdd67e8d7dcdd20f735c192ce3e5d40e5d

104 files changed:
src/libraries/Common/src/Microsoft/Internal/Assumes.InternalErrorException.cs [deleted file]
src/libraries/Common/src/Microsoft/Internal/Assumes.cs [deleted file]
src/libraries/Common/src/Microsoft/Internal/CommonStrings.Designer.cs [deleted file]
src/libraries/Common/src/Microsoft/Internal/CommonStrings.resx [deleted file]
src/libraries/Common/src/Microsoft/Internal/EmptyArray.cs [deleted file]
src/libraries/Common/src/Microsoft/Internal/Requires.cs [deleted file]
src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Collections/CollectionServices.CollectionOfObject.cs
src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Collections/CollectionServices.cs
src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/GenerationServices.cs
src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/LazyServices.cs
src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/ReflectionServices.cs
src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Requires.cs
src/libraries/System.ComponentModel.Composition/src/Resources/Strings.resx
src/libraries/System.ComponentModel.Composition/src/System.ComponentModel.Composition.csproj
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/AttributedModel/AttributedExportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/AttributedModel/AttributedModelDiscovery.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/AttributedModel/AttributedPartCreationInfo.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CatalogReflectionContextAttribute.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionException.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ConstraintServices.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ContractNameServices.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Diagnostics/CompositionTrace.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Diagnostics/CompositionTraceSource.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ErrorBuilder.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ExceptionBuilder.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ExportServices.DisposableLazy.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ExportServices.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ApplicationCatalog.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AtomicComposition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AtomicCompositionExtensions.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CatalogExportProvider.CatalogExport.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CatalogExportProvider.ScopeManager.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CatalogExportProvider.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionBatch.SingleExportComposablePart.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.CompositionServiceShim.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionService.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionServices.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/DirectoryCatalog.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ExportProvider.GetExportOverrides.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ExportProvider.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.DependenciesTraversal.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.DependentsTraversal.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.Traversal.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ImportEngine.EngineContext.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ImportEngine.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ImportSourceImportDefinitionHelpers.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/TypeCatalog.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataServices.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewGenerator.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewProvider.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartCatalog.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartException.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportfactoryCreator.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportingMember.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/GenericServices.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/GenericSpecializationPartCreationInfo.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportType.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportingItem.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportingMember.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/LazyMemberInfo.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/PartCreatorMemberImportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/PartCreatorParameterImportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePartDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionExtensions.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionField.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionMemberExportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionMemberImportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionMethod.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServices.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionParameter.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionParameterImportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionProperty.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionType.cs
src/libraries/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/ConstraintParser.cs
src/libraries/System.Composition.Convention/src/Microsoft/Composition/Diagnostics/CompositionTrace.cs
src/libraries/System.Composition.Convention/src/Microsoft/Composition/Diagnostics/CompositionTraceSource.cs
src/libraries/System.Composition.Convention/src/Resources/Strings.resx
src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj
src/libraries/System.Composition.Convention/src/System/Composition/Convention/ConventionBuilder.cs
src/libraries/System.Composition.Convention/src/System/Composition/Convention/ExportConventionBuilder.cs
src/libraries/System.Composition.Convention/src/System/Composition/Convention/ImportConventionBuilder.cs
src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilder.cs
src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilderOfT.cs
src/libraries/System.Composition.Convention/src/System/Composition/ExceptionBuilder.cs
src/libraries/System.Composition.Hosting/src/Resources/Strings.resx
src/libraries/System.Composition.Hosting/src/System.Composition.Hosting.csproj
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/CompositionHost.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/CompositionDependency.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/CompositionOperation.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/DirectExportDescriptor.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/ExportDescriptorPromise.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/ExportDescriptorRegistryUpdate.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/UpdateResult.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Providers/ExportFactory/ExportFactoryExportDescriptorProvider.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Providers/ExportFactory/ExportFactoryWithMetadataExportDescriptorProvider.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Util/Formatters.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Util/SmallSparseInitonlyArray.cs
src/libraries/System.Composition.TypedParts/src/System.Composition.TypedParts.csproj
src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/ActivationFeatures/ActivationFeature.cs
src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Util/DirectAttributeContext.cs

diff --git a/src/libraries/Common/src/Microsoft/Internal/Assumes.InternalErrorException.cs b/src/libraries/Common/src/Microsoft/Internal/Assumes.InternalErrorException.cs
deleted file mode 100644 (file)
index ded2c2f..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-
-namespace Microsoft.Internal
-{
-    internal partial class Assumes
-    {
-        // The exception that is thrown when an internal assumption failed.
-        [SuppressMessage("Microsoft.Design", "CA1064:ExceptionsShouldBePublic")]
-        private sealed class InternalErrorException : Exception
-        {
-            public InternalErrorException(string message)
-                : base(string.Format(CultureInfo.CurrentCulture, CommonStrings.Diagnostic_InternalExceptionMessage, message))
-            {
-            }
-        }
-    }
-}
diff --git a/src/libraries/Common/src/Microsoft/Internal/Assumes.cs b/src/libraries/Common/src/Microsoft/Internal/Assumes.cs
deleted file mode 100644 (file)
index b81f14f..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Diagnostics;
-
-namespace Microsoft.Internal
-{
-    internal static partial class Assumes
-    {
-        [DebuggerStepThrough]
-        internal static void NotNull<T>(T value)
-            where T : class
-        {
-            IsTrue(value != null);
-        }
-
-        [DebuggerStepThrough]
-        internal static void NotNull<T1, T2>(T1 value1, T2 value2)
-            where T1 : class
-            where T2 : class
-        {
-            NotNull(value1);
-            NotNull(value2);
-        }
-
-        [DebuggerStepThrough]
-        internal static void NotNull<T1, T2, T3>(T1 value1, T2 value2, T3 value3)
-            where T1 : class
-            where T2 : class
-            where T3 : class
-        {
-            NotNull(value1);
-            NotNull(value2);
-            NotNull(value3);
-        }
-
-        [DebuggerStepThrough]
-        internal static void NotNullOrEmpty(string value)
-        {
-            NotNull(value);
-            IsTrue(value.Length > 0);
-        }
-
-        [DebuggerStepThrough]
-        internal static void IsTrue(bool condition)
-        {
-            if (!condition)
-            {
-                throw UncatchableException(null);
-            }
-        }
-
-        [DebuggerStepThrough]
-        internal static void IsTrue(bool condition, /*[Localizable(false)]*/string message)
-        {
-            if (!condition)
-            {
-                throw UncatchableException(message);
-            }
-        }
-
-        [DebuggerStepThrough]
-        internal static void IsTrue(bool condition, /*[Localizable(false)]*/string message, object arg0)
-        {
-            if (!condition)
-            {
-                throw UncatchableException(string.Format(message, arg0));
-            }
-        }
-
-        [DebuggerStepThrough]
-        internal static void IsTrue(bool condition, /*[Localizable(false)]*/string message, object arg0, object arg1)
-        {
-            if (!condition)
-            {
-                throw UncatchableException(string.Format(message, arg0, arg1));
-            }
-        }
-
-        [DebuggerStepThrough]
-        internal static void IsTrue(bool condition, /*[Localizable(false)]*/string message, object arg0, object arg1, object arg2)
-        {
-            if (!condition)
-            {
-                throw UncatchableException(string.Format(message, arg0, arg1, arg2));
-            }
-        }
-
-        [DebuggerStepThrough]
-        internal static void IsTrue(bool condition, /*[Localizable(false)]*/string message, params object[] args)
-        {
-            if (!condition)
-            {
-                throw UncatchableException(string.Format(message, args));
-            }
-        }
-
-        [DebuggerStepThrough]
-        internal static T NotReachable<T>()
-        {
-            throw UncatchableException("Code path should never be reached!");
-        }
-
-        [DebuggerStepThrough]
-        private static Exception UncatchableException(/*[Localizable(false)]*/string message)
-        {
-            return new InternalErrorException(message);
-        }
-    }
-}
diff --git a/src/libraries/Common/src/Microsoft/Internal/CommonStrings.Designer.cs b/src/libraries/Common/src/Microsoft/Internal/CommonStrings.Designer.cs
deleted file mode 100644 (file)
index 105f240..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-//     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
-//
-//     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace Microsoft.Internal
-{
-    using System.Reflection;
-
-
-    /// <summary>
-    ///   A strongly-typed resource class, for looking up localized strings, etc.
-    /// </summary>
-    // This class was auto-generated by the StronglyTypedResourceBuilder
-    // class via a tool like ResGen or Visual Studio.
-    // To add or remove a member, edit your .ResX file then rerun ResGen
-    // with the /str option, or rebuild your VS project.
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
-    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class CommonStrings {
-        
-        private static global::System.Resources.ResourceManager resourceMan;
-        
-        private static global::System.Globalization.CultureInfo resourceCulture;
-        
-        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal CommonStrings() {
-        }
-        
-        /// <summary>
-        ///   Returns the cached ResourceManager instance used by this class.
-        /// </summary>
-        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager {
-            get {
-                if (object.ReferenceEquals(resourceMan, null)) {
-                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Internal.CommonStrings", typeof(CommonStrings).GetTypeInfo().Assembly);
-                    resourceMan = temp;
-                }
-                return resourceMan;
-            }
-        }
-        
-        /// <summary>
-        ///   Overrides the current thread's CurrentUICulture property for all
-        ///   resource lookups using this strongly typed resource class.
-        /// </summary>
-        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture {
-            get {
-                return resourceCulture;
-            }
-            set {
-                resourceCulture = value;
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to &apos;{0}&apos; cannot be an empty string (&quot;&quot;)..
-        /// </summary>
-        internal static string ArgumentException_EmptyString {
-            get {
-                return ResourceManager.GetString("ArgumentException_EmptyString", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Internal error occurred. Additional information: &apos;{0}&apos;..
-        /// </summary>
-        internal static string Diagnostic_InternalExceptionMessage {
-            get {
-                return ResourceManager.GetString("Diagnostic_InternalExceptionMessage", resourceCulture);
-            }
-        }
-    }
-}
diff --git a/src/libraries/Common/src/Microsoft/Internal/CommonStrings.resx b/src/libraries/Common/src/Microsoft/Internal/CommonStrings.resx
deleted file mode 100644 (file)
index 7cdbf07..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
-  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
-    <xsd:element name="root" msdata:IsDataSet="true">
-      <xsd:complexType>
-        <xsd:choice maxOccurs="unbounded">
-          <xsd:element name="metadata">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" />
-              </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string" />
-              <xsd:attribute name="type" type="xsd:string" />
-              <xsd:attribute name="mimetype" type="xsd:string" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="assembly">
-            <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string" />
-              <xsd:attribute name="name" type="xsd:string" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="data">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="resheader">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" />
-            </xsd:complexType>
-          </xsd:element>
-        </xsd:choice>
-      </xsd:complexType>
-    </xsd:element>
-  </xsd:schema>
-  <resheader name="resmimetype">
-    <value>text/microsoft-resx</value>
-  </resheader>
-  <resheader name="version">
-    <value>2.0</value>
-  </resheader>
-  <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <data name="ArgumentException_EmptyString" xml:space="preserve">
-    <value>'{0}' cannot be an empty string ("").</value>
-  </data>
-  <data name="Diagnostic_InternalExceptionMessage" xml:space="preserve">
-    <value>Internal error occurred. Additional information: '{0}'.</value>
-  </data>
-</root>
\ No newline at end of file
diff --git a/src/libraries/Common/src/Microsoft/Internal/EmptyArray.cs b/src/libraries/Common/src/Microsoft/Internal/EmptyArray.cs
deleted file mode 100644 (file)
index 6061819..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace Microsoft.Internal
-{
-    internal static class EmptyArray<T>
-    {
-        public static readonly T[] Value = new T[0];
-    }
-}
diff --git a/src/libraries/Common/src/Microsoft/Internal/Requires.cs b/src/libraries/Common/src/Microsoft/Internal/Requires.cs
deleted file mode 100644 (file)
index b5ddb47..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.Contracts;
-using System.Globalization;
-using System.Reflection;
-
-namespace Microsoft.Internal
-{
-    internal static partial class Requires
-    {
-        [DebuggerStepThrough]
-        [ContractArgumentValidator]
-        public static void NotNull<T>(T value, string parameterName)
-            where T : class
-        {
-            if (value == null)
-            {
-                throw new ArgumentNullException(parameterName);
-            }
-            Contract.EndContractBlock();
-        }
-
-        [DebuggerStepThrough]
-        [ContractArgumentValidator]
-        public static void NotNullOrEmpty(string value, string parameterName)
-        {
-            NotNull(value, parameterName);
-
-            if (value.Length == 0)
-            {
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, CommonStrings.ArgumentException_EmptyString, parameterName), parameterName);
-            }
-            Contract.EndContractBlock();
-        }
-    }
-}
index e5db4ec..f44f247 100644 (file)
@@ -12,7 +12,15 @@ namespace Microsoft.Internal.Collections
     {
         public static ICollection<object> GetCollectionWrapper(Type itemType, object collectionObject)
         {
-            Assumes.NotNull(itemType, collectionObject);
+            if(itemType == null)
+            {
+                throw new ArgumentNullException(nameof(itemType));
+            }
+
+            if(collectionObject == null)
+            {
+                throw new ArgumentNullException(nameof(collectionObject));
+            }
 
             var underlyingItemType = itemType.UnderlyingSystemType;
 
@@ -55,17 +63,17 @@ namespace Microsoft.Internal.Collections
 
             public bool Contains(object item)
             {
-                return Assumes.NotReachable<bool>();
+                throw new NotImplementedException();
             }
 
             public void CopyTo(object[] array, int arrayIndex)
             {
-                Assumes.NotReachable<object>();
+                throw new NotImplementedException();
             }
 
             public int Count
             {
-                get { return Assumes.NotReachable<int>(); }
+                get { throw new NotImplementedException(); }
             }
 
             public bool IsReadOnly
@@ -75,17 +83,17 @@ namespace Microsoft.Internal.Collections
 
             public bool Remove(object item)
             {
-                return Assumes.NotReachable<bool>();
+                throw new NotImplementedException();
             }
 
             public IEnumerator<object> GetEnumerator()
             {
-                return Assumes.NotReachable<IEnumerator<object>>();
+                throw new NotImplementedException();
             }
 
             IEnumerator IEnumerable.GetEnumerator()
             {
-                return Assumes.NotReachable<IEnumerator>();
+                throw new NotImplementedException();
             }
         }
 
@@ -110,17 +118,17 @@ namespace Microsoft.Internal.Collections
 
             public bool Contains(object item)
             {
-                return Assumes.NotReachable<bool>();
+                throw new NotImplementedException();
             }
 
             public void CopyTo(object[] array, int arrayIndex)
             {
-                Assumes.NotReachable<object>();
+                throw new NotImplementedException();
             }
 
             public int Count
             {
-                get { return Assumes.NotReachable<int>(); }
+                get { throw new NotImplementedException(); }
             }
 
             public bool IsReadOnly
@@ -130,17 +138,17 @@ namespace Microsoft.Internal.Collections
 
             public bool Remove(object item)
             {
-                return Assumes.NotReachable<bool>();
+                throw new NotImplementedException();
             }
 
             public IEnumerator<object> GetEnumerator()
             {
-                return Assumes.NotReachable<IEnumerator<object>>();
+                throw new NotImplementedException();
             }
 
             IEnumerator IEnumerable.GetEnumerator()
             {
-                return Assumes.NotReachable<IEnumerator>();
+                throw new NotImplementedException();
             }
         }
     }
index 6f3c0ee..5955686 100644 (file)
@@ -60,7 +60,10 @@ namespace Microsoft.Internal.Collections
 
         public static ReadOnlyCollection<T> ToReadOnlyCollection<T>(this IEnumerable<T> source)
         {
-            Assumes.NotNull(source);
+            if(source == null)
+            {
+                throw new ArgumentNullException(nameof(source));
+            }
 
             return new ReadOnlyCollection<T>(source.AsArray());
         }
@@ -168,7 +171,10 @@ namespace Microsoft.Internal.Collections
 
         public static EnumerableCardinality GetCardinality<T>(this IEnumerable<T> source)
         {
-            Assumes.NotNull(source);
+            if(source == null)
+            {
+                throw new ArgumentNullException(nameof(source));
+            }
 
             // Cast to ICollection instead of ICollection<T> for performance reasons.
             ICollection collection = source as ICollection;
@@ -221,7 +227,10 @@ namespace Microsoft.Internal.Collections
 
         public static Stack<T> Copy<T>(this Stack<T> stack)
         {
-            Assumes.NotNull(stack);
+            if(stack == null)
+            {
+                throw new ArgumentNullException(nameof(stack));
+            }
 
             // Stack<T>.GetEnumerator walks from top to bottom 
             // of the stack, whereas Stack<T>(IEnumerable<T>) 
index 200956a..0b8b22f 100644 (file)
@@ -4,6 +4,7 @@
 
 using System;
 using System.Collections;
+using System.Diagnostics;
 using System.Globalization;
 using System.Linq;
 using System.Reflection;
@@ -71,7 +72,7 @@ namespace Microsoft.Internal
         /// <returns></returns>
         public static void LoadValue(this ILGenerator ilGenerator, object value)
         {
-            Assumes.NotNull(ilGenerator);
+            Debug.Assert(ilGenerator != null);
 
             //
             // Get nulls out of the way - they are basically typeless, so we just load null
@@ -168,10 +169,22 @@ namespace Microsoft.Internal
         /// <returns></returns>
         public static void AddItemToLocalDictionary(this ILGenerator ilGenerator, LocalBuilder dictionary, object key, object value)
         {
-            Assumes.NotNull(ilGenerator);
-            Assumes.NotNull(dictionary);
-            Assumes.NotNull(key);
-            Assumes.NotNull(value);
+            Debug.Assert(ilGenerator != null);
+
+            if (dictionary == null)
+            {
+                throw new ArgumentNullException(nameof(dictionary));
+            }
+
+            if (key == null)
+            {
+                throw new ArgumentNullException(nameof(key));
+            }
+
+            if (value == null)
+            {
+                throw new ArgumentNullException(nameof(value));
+            }
 
             ilGenerator.Emit(OpCodes.Ldloc, dictionary);
             ilGenerator.LoadValue(key);
@@ -187,10 +200,22 @@ namespace Microsoft.Internal
         /// <returns></returns>
         public static void AddLocalToLocalDictionary(this ILGenerator ilGenerator, LocalBuilder dictionary, object key, LocalBuilder value)
         {
-            Assumes.NotNull(ilGenerator);
-            Assumes.NotNull(dictionary);
-            Assumes.NotNull(key);
-            Assumes.NotNull(value);
+            Debug.Assert(ilGenerator != null);
+
+            if (dictionary == null)
+            {
+                throw new ArgumentNullException(nameof(dictionary));
+            }
+
+            if (key == null)
+            {
+                throw new ArgumentNullException(nameof(key));
+            }
+
+            if (value == null)
+            {
+                throw new ArgumentNullException(nameof(value));
+            }
 
             ilGenerator.Emit(OpCodes.Ldloc, dictionary);
             ilGenerator.LoadValue(key);
@@ -206,9 +231,17 @@ namespace Microsoft.Internal
         /// <returns></returns>
         public static void GetExceptionDataAndStoreInLocal(this ILGenerator ilGenerator, LocalBuilder exception, LocalBuilder dataStore)
         {
-            Assumes.NotNull(ilGenerator);
-            Assumes.NotNull(exception);
-            Assumes.NotNull(dataStore);
+            Debug.Assert(ilGenerator != null);
+
+            if (exception == null)
+            {
+                throw new ArgumentNullException(nameof(exception));
+            }
+
+            if (dataStore == null)
+            {
+                throw new ArgumentNullException(nameof(dataStore));
+            }
 
             ilGenerator.Emit(OpCodes.Ldloc, exception);
             ilGenerator.Emit(OpCodes.Callvirt, ExceptionGetData);
@@ -217,8 +250,12 @@ namespace Microsoft.Internal
 
         private static void LoadEnumerable(this ILGenerator ilGenerator, IEnumerable enumerable)
         {
-            Assumes.NotNull(ilGenerator);
-            Assumes.NotNull(enumerable);
+            Debug.Assert(ilGenerator != null);
+
+            if (enumerable == null)
+            {
+                throw new ArgumentNullException(nameof(enumerable));
+            }
 
             // We load enumerable as an array - this is the most compact and efficient way of representing it
             Type elementType = null;
@@ -281,7 +318,8 @@ namespace Microsoft.Internal
 
         private static void LoadString(this ILGenerator ilGenerator, string s)
         {
-            Assumes.NotNull(ilGenerator);
+            Debug.Assert(ilGenerator != null);
+
             if (s == null)
             {
                 ilGenerator.LoadNull();
@@ -294,31 +332,36 @@ namespace Microsoft.Internal
 
         private static void LoadInt(this ILGenerator ilGenerator, int value)
         {
-            Assumes.NotNull(ilGenerator);
+            Debug.Assert(ilGenerator != null);
+
             ilGenerator.Emit(OpCodes.Ldc_I4, value);
         }
 
         private static void LoadLong(this ILGenerator ilGenerator, long value)
         {
-            Assumes.NotNull(ilGenerator);
+            Debug.Assert(ilGenerator != null);
+
             ilGenerator.Emit(OpCodes.Ldc_I8, value);
         }
 
         private static void LoadFloat(this ILGenerator ilGenerator, float value)
         {
-            Assumes.NotNull(ilGenerator);
+            Debug.Assert(ilGenerator != null);
+
             ilGenerator.Emit(OpCodes.Ldc_R4, value);
         }
 
         private static void LoadDouble(this ILGenerator ilGenerator, double value)
         {
-            Assumes.NotNull(ilGenerator);
+            Debug.Assert(ilGenerator != null);
+
             ilGenerator.Emit(OpCodes.Ldc_R8, value);
         }
 
         private static void LoadTypeOf(this ILGenerator ilGenerator, Type type)
         {
-            Assumes.NotNull(ilGenerator);
+            Debug.Assert(ilGenerator != null);
+
             //typeofs() translate into ldtoken and Type::GetTypeFromHandle call
             ilGenerator.Emit(OpCodes.Ldtoken, type);
             ilGenerator.EmitCall(OpCodes.Call, GenerationServices._typeGetTypeFromHandleMethod, null);
index 7ee721d..0d42670 100644 (file)
@@ -12,7 +12,11 @@ namespace Microsoft.Internal
         public static T GetNotNullValue<T>(this Lazy<T> lazy, string argument)
             where T : class
         {
-            Assumes.NotNull(lazy);
+            if (lazy == null)
+            {
+                throw new ArgumentNullException(nameof(lazy));
+            }
+
             T value = lazy.Value;
             if (value == null)
             {
index 62d2f29..4f59996 100644 (file)
@@ -56,14 +56,20 @@ namespace Microsoft.Internal
 
         public static string GetDisplayName(Type declaringType, string name)
         {
-            Assumes.NotNull(declaringType);
+            if(declaringType == null)
+            {
+                throw new ArgumentNullException(nameof(name));
+            }
 
             return declaringType.GetDisplayName() + "." + name;
         }
 
         public static string GetDisplayName(this MemberInfo member)
         {
-            Assumes.NotNull(member);
+            if(member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             switch (member.MemberType)
             {
@@ -79,9 +85,12 @@ namespace Microsoft.Internal
         internal static bool TryGetGenericInterfaceType(Type instanceType, Type targetOpenInterfaceType, out Type targetClosedInterfaceType)
         {
             // The interface must be open
-            Assumes.IsTrue(targetOpenInterfaceType.IsInterface);
-            Assumes.IsTrue(targetOpenInterfaceType.IsGenericTypeDefinition);
-            Assumes.IsTrue(!instanceType.IsGenericTypeDefinition);
+            if(!targetOpenInterfaceType.IsInterface ||
+                !targetOpenInterfaceType.IsGenericTypeDefinition ||
+                instanceType.IsGenericTypeDefinition)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             // if instanceType is an interface, we must first check it directly
             if (instanceType.IsInterface &&
index e9475ba..ce70225 100644 (file)
@@ -95,6 +95,26 @@ namespace Microsoft.Internal
                 throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_InvalidEnumInSet, parameterName, value, enumFlagSet.ToString()), parameterName);
             }
             Contract.EndContractBlock();
-        }        
+        }
+
+        public static void NotNull<T>(T value, string parameterName)
+            where T : class
+        {
+            if (value == null)
+            {
+                throw new ArgumentNullException(parameterName);
+            }
+        }
+
+        public static void NotNullOrEmpty(string value, string parameterName)
+        {
+            NotNull(value, parameterName);
+
+            if (value.Length == 0)
+            {
+                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ArgumentException_EmptyString, parameterName), parameterName);
+            }
+        }
+
     }
 }
index f8728c3..de69685 100644 (file)
   <data name="PlatformNotSupported_ComponentModel_Composition" xml:space="preserve">
     <value>System.ComponentModel.Composition APIs are not supported on this platform.</value>
   </data>
+  <data name="Expecting_AtleastOne_Type" xml:space="preserve">
+    <value>Expecting genericTypeArguments to contain at least one Type</value>
+  </data>
+  <data name="Expecting_Empty_Queue" xml:space="preserve">
+    <value>Expecting genericTypeArguments queue to be empty.</value>
+  </data>
+  <data name="Expecting_Generic_Type" xml:space="preserve">
+    <value>Expecting type to be a generic type</value>
+  </data>
+  <data name="Diagnostic_InternalExceptionMessage" xml:space="preserve">
+    <value>Internal error occurred. Additional information: '{0}'.</value>
+  </data>
+  <data name="Trace_Level_Not_Enabled" xml:space="preserve">
+    <value>To avoid unnecessary work when a trace level has not been enabled, check CanWriteXXX before calling this method.</value>
+  </data>
 </root>
index 65ee8ce..48e8356 100644 (file)
     <Compile Include="System\ComponentModel\Composition\ReflectionModel\ReflectionProperty.cs" />
     <Compile Include="System\ComponentModel\Composition\ReflectionModel\ReflectionType.cs" />
     <Compile Include="System\ComponentModel\Composition\ReflectionModel\ReflectionWritableMember.cs" />
-    <Compile Include="$(CommonPath)\Microsoft\Internal\Assumes.cs">
-      <Link>Microsoft\Internal\Assumes.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\Assumes.InternalErrorException.cs">
-      <Link>Microsoft\Internal\Assumes.InternalErrorException.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\CommonStrings.Designer.cs">
-      <Link>Microsoft\Internal\CommonStrings.Designer.cs</Link>
-      <AutoGen>True</AutoGen>
-      <DesignTime>True</DesignTime>
-      <DependentUpon>CommonStrings.resx</DependentUpon>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\Requires.cs">
-      <Link>Microsoft\Internal\Requires.cs</Link>
-    </Compile>
-  </ItemGroup>
-  <ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
-    <EmbeddedResource Include="$(CommonPath)\Microsoft\Internal\CommonStrings.resx">
-      <Link>Microsoft\Internal\CommonStrings.resx</Link>
-      <Generator>ResXFileCodeGenerator</Generator>
-      <LastGenOutput>CommonStrings.Designer.cs</LastGenOutput>
-      <CustomToolNamespace>Microsoft.Internal</CustomToolNamespace>
-    </EmbeddedResource>
   </ItemGroup>
   <ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
     <Reference Include="Microsoft.Win32.Primitives" />
     <Reference Include="System.Security.Permissions" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-</Project>
\ No newline at end of file
+</Project>
index 5c5c14a..d1b213c 100644 (file)
@@ -7,7 +7,6 @@ using System.ComponentModel.Composition.Hosting;
 using System.ComponentModel.Composition.Primitives;
 using System.ComponentModel.Composition.ReflectionModel;
 using System.Reflection;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.AttributedModel
 {
@@ -23,9 +22,20 @@ namespace System.ComponentModel.Composition.AttributedModel
         public AttributedExportDefinition(AttributedPartCreationInfo partCreationInfo, MemberInfo member, ExportAttribute exportAttribute, Type typeIdentityType, string contractName)
             : base(contractName, (IDictionary<string, object>)null)
         {
-            Assumes.NotNull(partCreationInfo);
-            Assumes.NotNull(member);
-            Assumes.NotNull(exportAttribute);
+            if(partCreationInfo == null)
+            {
+                throw new ArgumentNullException(nameof(partCreationInfo));
+            }
+
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
+
+            if (exportAttribute == null)
+            {
+                throw new ArgumentNullException(nameof(exportAttribute));
+            }
 
             _partCreationInfo = partCreationInfo;
             _member = member;
index f008d9b..d91c9f9 100644 (file)
@@ -27,7 +27,10 @@ namespace System.ComponentModel.Composition.AttributedModel
 
         public static ReflectionComposablePartDefinition CreatePartDefinition(Type type, PartCreationPolicyAttribute partCreationPolicy, bool ignoreConstructorImports, ICompositionElement origin)
         {
-            Assumes.NotNull(type);
+            if(type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             AttributedPartCreationInfo creationInfo = new AttributedPartCreationInfo(type, partCreationPolicy, ignoreConstructorImports, origin);
 
@@ -36,7 +39,10 @@ namespace System.ComponentModel.Composition.AttributedModel
 
         public static ReflectionComposablePart CreatePart(object attributedPart)
         {
-            Assumes.NotNull(attributedPart);
+            if (attributedPart == null)
+            {
+                throw new ArgumentNullException(nameof(attributedPart));
+            }
 
             // If given an instance then we want to pass the default composition options because we treat it as a shared part
             ReflectionComposablePartDefinition definition = AttributedModelDiscovery.CreatePartDefinition(attributedPart.GetType(), PartCreationPolicyAttribute.Shared, true, (ICompositionElement)null);
@@ -46,8 +52,15 @@ namespace System.ComponentModel.Composition.AttributedModel
         
         public static ReflectionComposablePart CreatePart(object attributedPart, ReflectionContext reflectionContext)
         {
-            Assumes.NotNull(attributedPart);
-            Assumes.NotNull(reflectionContext);
+            if (attributedPart == null)
+            {
+                throw new ArgumentNullException(nameof(attributedPart));
+            }
+
+            if (reflectionContext == null)
+            {
+                throw new ArgumentNullException(nameof(reflectionContext));
+            }
 
             // If given an instance then we want to pass the default composition options because we treat it as a shared part
             var mappedType = reflectionContext.MapType(IntrospectionExtensions.GetTypeInfo(attributedPart.GetType()));
@@ -63,8 +76,16 @@ namespace System.ComponentModel.Composition.AttributedModel
 
         public static ReflectionComposablePart CreatePart(ComposablePartDefinition partDefinition, object attributedPart)
         {
-            Assumes.NotNull(partDefinition);
-            Assumes.NotNull(attributedPart);
+            if (partDefinition == null)
+            {
+                throw new ArgumentNullException(nameof(partDefinition));
+            }
+
+            if (attributedPart == null)
+            {
+                throw new ArgumentNullException(nameof(attributedPart));
+            }
+
 
             return new ReflectionComposablePart((ReflectionComposablePartDefinition)partDefinition, attributedPart);
         }
index 4928236..9e472a2 100644 (file)
@@ -27,7 +27,10 @@ namespace System.ComponentModel.Composition.AttributedModel
 
         public AttributedPartCreationInfo(Type type, PartCreationPolicyAttribute partCreationPolicy, bool ignoreConstructorImports, ICompositionElement origin)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             _type = type;
             _ignoreConstructorImports = ignoreConstructorImports;
@@ -187,7 +190,10 @@ namespace System.ComponentModel.Composition.AttributedModel
 
         private static ConstructorInfo SelectPartConstructor(Type type)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             if (type.IsAbstract)
             {
index bcc6773..bb7df2a 100644 (file)
@@ -29,7 +29,10 @@ namespace System.ComponentModel.Composition
 
         public ReflectionContext CreateReflectionContext()
         {
-            Assumes.NotNull<Type>(_reflectionContextType);
+            if (_reflectionContextType == null)
+            {
+                throw new ArgumentNullException(nameof(_reflectionContextType));
+            }
 
             if (!_reflectionContextType.IsPublic)
             {
index 8feac41..50a70db 100644 (file)
@@ -8,7 +8,6 @@ using System.ComponentModel.Composition.Primitives;
 using System.Diagnostics;
 using System.Globalization;
 using System.Linq;
-using System.Runtime.Serialization;
 using System.Text;
 using Microsoft.Internal;
 using Microsoft.Internal.Collections;
@@ -193,8 +192,10 @@ namespace System.ComponentModel.Composition
             }
             else
             {
-                Assumes.IsTrue(errorsCount == 1);
-                Assumes.IsTrue(pathCount == 1);
+                if(errorsCount != 1 || pathCount != 1)
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
 
                 // The composition produced a single composition error. The root cause is provided below.
                 writer.AppendFormat(
index d45dc42..6c4fee0 100644 (file)
@@ -7,7 +7,6 @@ using System.ComponentModel.Composition.Hosting;
 using System.ComponentModel.Composition.Primitives;
 using System.Linq.Expressions;
 using System.Reflection;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition
 {
@@ -57,7 +56,10 @@ namespace System.ComponentModel.Composition
 
         private static Expression CreateContractConstraintBody(string contractName, ParameterExpression parameter)
         {
-            Assumes.NotNull(parameter);
+            if(parameter == null)
+            {
+                throw new ArgumentNullException(nameof(parameter));
+            }
 
             // export.ContractName=<contract>;
             return Expression.Equal(
@@ -67,8 +69,15 @@ namespace System.ComponentModel.Composition
 
         private static Expression CreateMetadataConstraintBody(IEnumerable<KeyValuePair<string, Type>> requiredMetadata, ParameterExpression parameter)
         {
-            Assumes.NotNull(requiredMetadata);
-            Assumes.NotNull(parameter);
+            if (requiredMetadata == null)
+            {
+                throw new ArgumentNullException(nameof(requiredMetadata));
+            }
+
+            if (parameter == null)
+            {
+                throw new ArgumentNullException(nameof(parameter));
+            }
 
             Expression body = null;
             foreach (KeyValuePair<string, Type> requiredMetadataItem in requiredMetadata)
@@ -85,8 +94,15 @@ namespace System.ComponentModel.Composition
 
         private static Expression CreateCreationPolicyContraint(CreationPolicy policy, ParameterExpression parameter)
         {
-            Assumes.IsTrue(policy != CreationPolicy.Any);
-            Assumes.NotNull(parameter);
+            if(policy == CreationPolicy.Any)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
+
+            if(parameter == null)
+            {
+                throw new ArgumentNullException(nameof(parameter));
+            }
 
             //    !definition.Metadata.ContainsKey(CompositionConstants.PartCreationPolicyMetadataName) ||
             //        CreationPolicy.Any.Equals(definition.Metadata[CompositionConstants.PartCreationPolicyMetadataName]) ||
@@ -101,8 +117,15 @@ namespace System.ComponentModel.Composition
 
         private static Expression CreateTypeIdentityContraint(string requiredTypeIdentity, ParameterExpression parameter)
         {
-            Assumes.NotNull(requiredTypeIdentity);
-            Assumes.NotNull(parameter);
+            if(requiredTypeIdentity == null)
+            {
+                throw new ArgumentNullException(requiredTypeIdentity);
+            }
+
+            if(parameter == null)
+            {
+                throw new ArgumentException(nameof(parameter));
+            }
 
             //    definition.Metadata.ContainsKey(CompositionServices.ExportTypeIdentity) &&
             //        requiredTypeIdentity.Equals(definition.Metadata[CompositionConstants.ExportTypeIdentityMetadataName]);
@@ -114,7 +137,15 @@ namespace System.ComponentModel.Composition
 
         private static Expression CreateMetadataContainsKeyExpression(ParameterExpression parameter, string constantKey)
         {
-            Assumes.NotNull(parameter, constantKey);
+            if (parameter == null)
+            {
+                throw new ArgumentException(nameof(parameter));
+            }
+
+            if (constantKey == null)
+            {
+                throw new ArgumentException(nameof(constantKey));
+            }
 
             // definition.Metadata.ContainsKey(constantKey)
             return  Expression.Call(
@@ -125,8 +156,20 @@ namespace System.ComponentModel.Composition
 
         private static Expression CreateMetadataOfTypeExpression(ParameterExpression parameter, string constantKey, Type constantType)
         {
-            Assumes.NotNull(parameter, constantKey);
-            Assumes.NotNull(parameter, constantType);
+            if(parameter == null)
+            {
+                throw new ArgumentException(nameof(parameter));
+            }
+
+            if (constantKey == null)
+            {
+                throw new ArgumentException(nameof(constantKey));
+            }
+
+            if (constantType == null)
+            {
+                throw new ArgumentException(nameof(constantType));
+            }
 
             // constantType.IsInstanceOfType(definition.Metadata[constantKey])
             return Expression.Call(
@@ -141,7 +184,15 @@ namespace System.ComponentModel.Composition
 
         private static Expression CreateMetadataValueEqualsExpression(ParameterExpression parameter, object constantValue, string metadataName)
         {
-            Assumes.NotNull(parameter, constantValue);
+            if (parameter == null)
+            {
+                throw new ArgumentException(nameof(parameter));
+            }
+
+            if (constantValue == null)
+            {
+                throw new ArgumentException(nameof(constantValue));
+            }
 
             // constantValue.Equals(definition.Metadata[CompositionServices.PartCreationPolicyMetadataName])
             return  Expression.Call(
index bbac735..685e925 100644 (file)
@@ -44,7 +44,11 @@ namespace System.ComponentModel.Composition
 
         internal static string GetTypeIdentity(Type type, bool formatGenericName)
         {
-            Assumes.NotNull(type);
+            if(type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
             string typeIdentity = null;
 
             if (!TypeIdentityCache.TryGetValue(type, out typeIdentity))
@@ -68,7 +72,10 @@ namespace System.ComponentModel.Composition
                     typeIdentity = typeIdentityStringBuilder.ToString();
                 }
 
-                Assumes.IsTrue(!string.IsNullOrEmpty(typeIdentity));
+                if(string.IsNullOrEmpty(typeIdentity))
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
                 TypeIdentityCache.Add(type, typeIdentity);
             }
 
@@ -126,7 +133,10 @@ namespace System.ComponentModel.Composition
                 //
                 Queue<Type> genericTypeArguments = new Queue<Type>(type.GetGenericArguments());
                 WriteGenericType(typeName, type, type.IsGenericTypeDefinition, genericTypeArguments, formatGenericName);
-                Assumes.IsTrue(genericTypeArguments.Count == 0, "Expecting genericTypeArguments queue to be empty.");
+                if(genericTypeArguments.Count != 0) 
+                {
+                    throw new Exception(SR.Expecting_Empty_Queue);
+                }
             }
             else
             {
@@ -239,7 +249,10 @@ namespace System.ComponentModel.Composition
             //
             // Writes generic type name, e.g. generic name and generic arguments
             //
-            Assumes.IsTrue(type.IsGenericType, "Expecting type to be a generic type");
+            if(!type.IsGenericType) 
+            {
+                throw new Exception(SR.Expecting_Generic_Type);
+            }
             int genericArity = GetGenericArity(type);
             string genericTypeName = FindGenericTypeName(type.GetGenericTypeDefinition().Name);
             typeName.Append(genericTypeName);
@@ -258,7 +271,10 @@ namespace System.ComponentModel.Composition
             typeName.Append(ContractNameGenericOpeningBracket);
             for (int i = 0; i < argumentsCount; i++)
             {
-                Assumes.IsTrue(genericTypeArguments.Count > 0, "Expecting genericTypeArguments to contain at least one Type");
+                if(genericTypeArguments.Count == 0)
+                {
+                    throw new Exception(SR.Expecting_AtleastOne_Type);
+                }
                 Type genericTypeArgument = genericTypeArguments.Dequeue();
                 WriteTypeArgument(typeName, isDefinition, genericTypeArgument, formatGenericName);
             }
@@ -292,7 +308,10 @@ namespace System.ComponentModel.Composition
             typeName.Append(customKeyword);
             Queue<Type> typeArguments = new Queue<Type>(types);
             WriteTypeArgumentsString(typeName, types.Length, false, typeArguments, formatGenericName);
-            Assumes.IsTrue(typeArguments.Count == 0, "Expecting genericTypeArguments queue to be empty.");
+            if(typeArguments.Count != 0) 
+            {
+                throw new Exception(SR.Expecting_Empty_Queue);
+            }
         }
 
         private static Type FindArrayElementType(Type type)
@@ -333,7 +352,10 @@ namespace System.ComponentModel.Composition
             int delclaringTypeGenericArguments = type.DeclaringType.GetGenericArguments().Length;
             int typeGenericArguments = type.GetGenericArguments().Length;
 
-            Assumes.IsTrue(typeGenericArguments >= delclaringTypeGenericArguments);
+            if(typeGenericArguments < delclaringTypeGenericArguments)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             return typeGenericArguments - delclaringTypeGenericArguments;
         }
index e34cc73..dd2ad52 100644 (file)
@@ -14,7 +14,10 @@ namespace System.ComponentModel.Composition.Diagnostics
     {
         internal static void PartDefinitionResurrected(ComposablePartDefinition definition)
         {
-            Assumes.NotNull(definition);
+            if(definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
 
             if (CompositionTraceSource.CanWriteInformation)
             {
@@ -26,7 +29,16 @@ namespace System.ComponentModel.Composition.Diagnostics
 
         internal static void PartDefinitionRejected(ComposablePartDefinition definition, ChangeRejectedException exception)
         {
-            Assumes.NotNull(definition, exception);
+            if(definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
+
+            if(exception == null)
+            {
+                throw new ArgumentNullException(nameof(exception));
+            }
+
 
             if (CompositionTraceSource.CanWriteWarning)
             {
@@ -39,8 +51,25 @@ namespace System.ComponentModel.Composition.Diagnostics
 
         internal static void AssemblyLoadFailed(DirectoryCatalog catalog, string fileName, Exception exception)
         {
-            Assumes.NotNull(catalog, exception);
-            Assumes.NotNullOrEmpty(fileName);
+            if(catalog == null)
+            {
+                throw new ArgumentNullException(nameof(catalog));
+            }
+
+            if(exception == null)
+            {
+                throw new ArgumentNullException(nameof(exception));
+            }
+
+            if(fileName == null)
+            {
+                throw new ArgumentNullException(nameof(fileName));
+            }
+
+            if(fileName.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(fileName)), nameof(fileName));
+            }
 
             if (CompositionTraceSource.CanWriteWarning)
             {
@@ -54,7 +83,10 @@ namespace System.ComponentModel.Composition.Diagnostics
 
         internal static void DefinitionMarkedWithPartNotDiscoverableAttribute(Type type)
         {
-            Assumes.NotNull(type);
+            if(type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             if (CompositionTraceSource.CanWriteInformation)
             {
@@ -66,8 +98,15 @@ namespace System.ComponentModel.Composition.Diagnostics
 
         internal static void DefinitionMismatchedExportArity(Type type, MemberInfo member)
         {
-            Assumes.NotNull(type);
-            Assumes.NotNull(member);
+            if(type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
+            if(member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             if (CompositionTraceSource.CanWriteInformation)
             {
@@ -79,7 +118,10 @@ namespace System.ComponentModel.Composition.Diagnostics
 
         internal static void DefinitionContainsNoExports(Type type)
         {
-            Assumes.NotNull(type);
+            if(type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             if (CompositionTraceSource.CanWriteInformation)
             {
@@ -91,7 +133,10 @@ namespace System.ComponentModel.Composition.Diagnostics
 
         internal static void MemberMarkedWithMultipleImportAndImportMany(ReflectionItem item)
         {
-            Assumes.NotNull(item);
+            if(item == null)
+            {
+                throw new ArgumentNullException(nameof(item));
+            }
 
             if (CompositionTraceSource.CanWriteError)
             {
index 334a333..898af1c 100644 (file)
@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.Diagnostics
 {
@@ -48,7 +47,10 @@ namespace System.ComponentModel.Composition.Diagnostics
 
         private static void EnsureEnabled(bool condition)
         {
-            Assumes.IsTrue(condition, "To avoid unnecessary work when a trace level has not been enabled, check CanWriteXXX before calling this method.");
+            if(!condition)
+            {
+                throw new Exception(SR.Trace_Level_Not_Enabled);
+            }
         }
     }
 }
index 05af206..e3c98f2 100644 (file)
@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information.
 
 using System.ComponentModel.Composition.Primitives;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition
 {
@@ -36,7 +35,15 @@ namespace System.ComponentModel.Composition
 
         public static CompositionError CreateImportCardinalityMismatch(ImportCardinalityMismatchException exception, ImportDefinition definition)
         {
-            Assumes.NotNull(exception, definition);
+            if(exception == null)
+            {
+                throw new ArgumentNullException(nameof(exception));
+            }
+
+            if(definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
 
             return CompositionError.Create(
                 CompositionErrorId.ImportEngine_ImportCardinalityMismatch, 
@@ -47,7 +54,15 @@ namespace System.ComponentModel.Composition
 
         public static CompositionError CreatePartCannotActivate(ComposablePart part, Exception innerException)
         {
-            Assumes.NotNull(part, innerException);
+            if(part == null)
+            {
+                throw new ArgumentNullException(nameof(part));
+            }
+
+            if(innerException == null)
+            {
+                throw new ArgumentNullException(nameof(innerException));
+            }
 
             ICompositionElement element = part.ToElement();
             return CompositionError.Create(
@@ -60,7 +75,20 @@ namespace System.ComponentModel.Composition
 
         public static CompositionError CreatePartCannotSetImport(ComposablePart part, ImportDefinition definition, Exception innerException)
         {
-            Assumes.NotNull(part, definition, innerException);
+            if(part == null)
+            {
+                throw new ArgumentNullException(nameof(part));
+            }
+
+            if(definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
+
+            if(innerException == null)
+            {
+                throw new ArgumentNullException(nameof(innerException));
+            }
 
             ICompositionElement element = definition.ToElement();
             return CompositionError.Create(
@@ -74,7 +102,20 @@ namespace System.ComponentModel.Composition
 
         public static CompositionError CreateCannotGetExportedValue(ComposablePart part, ExportDefinition definition, Exception innerException)
         {
-            Assumes.NotNull(part, definition, innerException);
+            if(part == null)
+            {
+                throw new ArgumentNullException(nameof(part));
+            }
+
+            if(definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
+
+            if(innerException == null)
+            {
+                throw new ArgumentNullException(nameof(innerException));
+            }
 
             ICompositionElement element = definition.ToElement();
             return CompositionError.Create(
@@ -88,7 +129,10 @@ namespace System.ComponentModel.Composition
 
         public static CompositionError CreatePartCycle(ComposablePart part)
         {
-            Assumes.NotNull(part);
+            if(part == null)
+            {
+                throw new ArgumentNullException(nameof(part));
+            }
 
             ICompositionElement element = part.ToElement();
             return CompositionError.Create(
index b0f0024..7a8042b 100644 (file)
@@ -5,7 +5,6 @@
 using System.ComponentModel.Composition;
 using System.ComponentModel.Composition.Primitives;
 using System.Globalization;
-using Microsoft.Internal;
 
 namespace System.ComponentModel
 {
@@ -20,7 +19,10 @@ namespace System.ComponentModel
 
         public static ArgumentException CreateContainsNullElement(string parameterName)
         {
-            Assumes.NotNull(parameterName);
+            if(parameterName == null)
+            {
+                throw new ArgumentNullException(nameof(parameterName));
+            }
 
             string message = Format(SR.Argument_NullElement, parameterName);
 
@@ -29,14 +31,25 @@ namespace System.ComponentModel
 
         public static ObjectDisposedException CreateObjectDisposed(object instance)
         {
-            Assumes.NotNull(instance);
+            if(instance == null)
+            {
+                throw new ArgumentNullException(nameof(instance));
+            }
 
             return new ObjectDisposedException(instance.GetType().ToString());
         }
 
         public static NotImplementedException CreateNotOverriddenByDerived(string memberName)
         {
-            Assumes.NotNullOrEmpty(memberName);
+            if(memberName == null)
+            {
+                throw new ArgumentNullException(nameof(memberName));
+            }
+
+            if(memberName.Length == 0) 
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(memberName)), nameof(memberName));
+            }
 
             string message = Format(SR.NotImplemented_NotOverriddenByDerived, memberName);
 
@@ -45,7 +58,16 @@ namespace System.ComponentModel
 
         public static ArgumentException CreateExportDefinitionNotOnThisComposablePart(string parameterName)
         {
-            Assumes.NotNullOrEmpty(parameterName);
+            if(parameterName == null)
+            {
+                throw new ArgumentNullException(nameof(parameterName));
+            }
+
+            if(parameterName.Length == 0) 
+            {
+                throw new ArgumentException(SR.ArgumentException_EmptyString);
+            }
+
 
             string message = Format(SR.ExportDefinitionNotOnThisComposablePart, parameterName);
 
@@ -54,7 +76,15 @@ namespace System.ComponentModel
 
         public static ArgumentException CreateImportDefinitionNotOnThisComposablePart(string parameterName)
         {
-            Assumes.NotNullOrEmpty(parameterName);
+            if(parameterName == null)
+            {
+                throw new ArgumentNullException(nameof(parameterName));
+            }
+
+            if(parameterName.Length == 0) 
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(parameterName)), nameof(parameterName));
+            }
 
             string message = Format(SR.ImportDefinitionNotOnThisComposablePart, parameterName);
 
@@ -63,7 +93,20 @@ namespace System.ComponentModel
 
         public static CompositionException CreateCannotGetExportedValue(ComposablePart part, ExportDefinition definition, Exception innerException)
         {
-            Assumes.NotNull(part, definition, innerException);
+            if(part == null)
+            {
+                throw new ArgumentNullException(nameof(part));
+            }
+            
+            if(definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
+
+            if(innerException == null)
+            {
+                throw new ArgumentNullException(nameof(innerException));
+            }
 
             return new CompositionException(
                 ErrorBuilder.CreateCannotGetExportedValue(part, definition, innerException));
@@ -71,15 +114,35 @@ namespace System.ComponentModel
 
         public static ArgumentException CreateReflectionModelInvalidPartDefinition(string parameterName, Type partDefinitionType)
         {
-            Assumes.NotNullOrEmpty(parameterName);
-            Assumes.NotNull(partDefinitionType);
+            if(parameterName == null)
+            {
+                throw new ArgumentNullException(nameof(parameterName));
+            }
+
+            if(parameterName.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(parameterName)), nameof(parameterName));
+            }
+
+            if(partDefinitionType == null)
+            {
+                throw new ArgumentNullException(nameof(partDefinitionType));
+            }
 
             return new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ReflectionModel_InvalidPartDefinition, partDefinitionType), parameterName);
         }
 
         public static ArgumentException ExportFactory_TooManyGenericParameters(string typeName)
         {
-            Assumes.NotNullOrEmpty(typeName);
+            if(typeName == null)
+            {
+                throw new ArgumentNullException(nameof(typeName));
+            }
+
+            if(typeName.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(typeName)), nameof(typeName));
+            }
 
             string message = Format(SR.ExportFactory_TooManyGenericParameters, typeName);
 
index 2cbc3f9..cd20141 100644 (file)
@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information.
 
 using System.Threading;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition
 {
@@ -16,7 +15,10 @@ namespace System.ComponentModel.Composition
             public DisposableLazy(Func<T> valueFactory, TMetadataView metadataView, IDisposable disposable, LazyThreadSafetyMode mode)
                 : base(valueFactory, metadataView, mode)
             {
-                Assumes.NotNull(disposable);
+                if(disposable == null)
+                {
+                    throw new ArgumentNullException(nameof(disposable));
+                }
 
                 _disposable = disposable;
             }
@@ -34,7 +36,10 @@ namespace System.ComponentModel.Composition
             public DisposableLazy(Func<T> valueFactory, IDisposable disposable, LazyThreadSafetyMode mode)
                 : base(valueFactory, mode)
             {
-                Assumes.NotNull(disposable);
+                if(disposable == null)
+                {
+                    throw new ArgumentNullException(nameof(disposable));
+                }
 
                 _disposable = disposable;
             }
index c674734..8bcc93f 100644 (file)
@@ -26,7 +26,10 @@ namespace System.ComponentModel.Composition
 
         internal static bool IsDefaultMetadataViewType(Type metadataViewType)
         {
-            Assumes.NotNull(metadataViewType);
+            if(metadataViewType == null)
+            {
+                throw new ArgumentNullException(nameof(metadataViewType));
+            }
 
             // Consider all types that IDictionary<string, object> derives from, such
             // as ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>> 
@@ -36,7 +39,10 @@ namespace System.ComponentModel.Composition
 
         internal static bool IsDictionaryConstructorViewType(Type metadataViewType)
         {
-            Assumes.NotNull(metadataViewType);
+            if(metadataViewType == null)
+            {
+                throw new ArgumentNullException(nameof(metadataViewType));
+            }
 
             // Does the view type have a constructor that is a Dictionary<string, object>
             return metadataViewType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
@@ -56,7 +62,12 @@ namespace System.ComponentModel.Composition
             {
                 genericMethod = _createStronglyTypedLazyOfT.MakeGenericMethod(exportType ?? ExportServices.DefaultExportedValueType);
             }
-            Assumes.NotNull(genericMethod);
+
+            if(genericMethod == null)
+            {
+                throw new ArgumentNullException(nameof(genericMethod));
+            }
+
             return (Func<Export, object>)Delegate.CreateDelegate(typeof(Func<Export, object>), genericMethod);
         }
 
@@ -65,7 +76,10 @@ namespace System.ComponentModel.Composition
             MethodInfo genericMethod = _createSemiStronglyTypedLazy.MakeGenericMethod(
                 exportType ?? ExportServices.DefaultExportedValueType,
                 metadataViewType ?? ExportServices.DefaultMetadataViewType);
-            Assumes.NotNull(genericMethod);
+            if(genericMethod == null)
+            {
+                throw new ArgumentNullException(nameof(genericMethod));
+            }
             return (Func<Export, Lazy<object, object>>)Delegate.CreateDelegate(typeof(Func<Export, Lazy<object, object>>), genericMethod);
         }
 
@@ -176,7 +190,10 @@ namespace System.ComponentModel.Composition
                     break;
 
                 default:
-                    Assumes.IsTrue(actualCardinality == EnumerableCardinality.One);
+                    if(actualCardinality != EnumerableCardinality.One)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     break;
 
             }
index 122a7ff..50137ac 100644 (file)
@@ -74,7 +74,10 @@ namespace System.ComponentModel.Composition.Hosting
                         if(_innerCatalog == null)
                         {
                             var location = AppDomain.CurrentDomain.BaseDirectory;
-                            Assumes.NotNull(location);
+                            if(location == null)
+                            {
+                                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                            }
         
                             var catalogs = new List<ComposablePartCatalog>();
                             catalogs.Add(CreateCatalog(location, "*.exe"));
index 39ee345..af55678 100644 (file)
@@ -232,7 +232,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private void CopyComplete()
         {
-            Assumes.NotNull(_outerAtomicComposition);
+            if (_outerAtomicComposition == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             _outerAtomicComposition.ContainsInnerAtomicComposition = false;
 
index 447fa46..b22c8c2 100644 (file)
@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.Hosting
 {
@@ -10,7 +9,10 @@ namespace System.ComponentModel.Composition.Hosting
     {
         internal static T GetValueAllowNull<T>(this AtomicComposition atomicComposition, T defaultResultAndKey) where T : class
         {
-            Assumes.NotNull(defaultResultAndKey);
+            if (defaultResultAndKey == null)
+            {
+                throw new ArgumentNullException(nameof(defaultResultAndKey));
+            }
 
             return GetValueAllowNull<T>(atomicComposition, defaultResultAndKey, defaultResultAndKey);
         }
@@ -28,7 +30,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         internal static void AddRevertActionAllowNull(this AtomicComposition atomicComposition, Action action)
         {
-            Assumes.NotNull(action);
+            if (action == null)
+            {
+                throw new ArgumentNullException(nameof(action));
+            }
 
             if (atomicComposition == null)
             {
@@ -42,7 +47,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         internal static void AddCompleteActionAllowNull(this AtomicComposition atomicComposition, Action action)
         {
-            Assumes.NotNull(action);
+            if (action == null)
+            {
+                throw new ArgumentNullException(nameof(action));
+            }
 
             if (atomicComposition == null)
             {
index 5940d29..fda7e10 100644 (file)
@@ -5,7 +5,6 @@
 using System.ComponentModel.Composition.Primitives;
 using System.Diagnostics.CodeAnalysis;
 using System.Threading;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.Hosting
 {
@@ -100,14 +99,19 @@ namespace System.ComponentModel.Composition.Hosting
 
                     case CreationPolicy.NonShared:
                         {
-                            Assumes.IsTrue(importPolicy != CreationPolicy.Shared);
+                            if (importPolicy == CreationPolicy.Shared)
+                            {
+                                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                            }
                             return false;
                         }
 
                     default:
                         {
-                            Assumes.IsTrue(partPolicy == CreationPolicy.Shared);
-                            Assumes.IsTrue(importPolicy != CreationPolicy.NonShared);
+                            if (partPolicy != CreationPolicy.Shared || importPolicy == CreationPolicy.NonShared)
+                            {
+                                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                            }
                             return true;
                         }
                 }
index 24136e2..98b4e5b 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.ComponentModel.Composition.Primitives;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.Hosting
 {
@@ -17,8 +16,14 @@ namespace System.ComponentModel.Composition.Hosting
 
             public ScopeManager(CatalogExportProvider catalogExportProvider, CompositionScopeDefinition scopeDefinition)
             {
-                Assumes.NotNull(catalogExportProvider);
-                Assumes.NotNull(scopeDefinition);
+                if (catalogExportProvider == null)
+                {
+                    throw new ArgumentNullException(nameof(catalogExportProvider));
+                }
+                if (scopeDefinition == null)
+                {
+                    throw new ArgumentNullException(nameof(scopeDefinition));
+                }
 
                 _scopeDefinition = scopeDefinition;
                 _catalogExportProvider = catalogExportProvider;
index f30bac0..2ce88c2 100644 (file)
@@ -26,7 +26,10 @@ namespace System.ComponentModel.Composition.Hosting
 
             public InnerCatalogExportProvider(CatalogExportProvider outerExportProvider)
             {
-                Assumes.NotNull(outerExportProvider);
+                if(outerExportProvider == null)
+                {
+                    throw new ArgumentNullException(nameof(outerExportProvider));
+                }
                 _outerExportProvider = outerExportProvider;
             }
 
@@ -310,7 +313,10 @@ namespace System.ComponentModel.Composition.Hosting
             ThrowIfDisposed();
             EnsureRunning();
 
-            Assumes.NotNull(_innerExportProvider);
+            if (_innerExportProvider == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             IEnumerable<Export> exports;
             _innerExportProvider.TryGetExports(definition, atomicComposition, out exports);
@@ -524,8 +530,15 @@ namespace System.ComponentModel.Composition.Hosting
         {
             ThrowIfDisposed();
             EnsureRunning();
+            if (part == null)
+            {
+                throw new ArgumentNullException(nameof(part));
+            }
 
-            Assumes.NotNull(part, export);
+            if (export == null)
+            {
+                throw new ArgumentNullException(nameof(export));
+            }
 
             // We don't protect against thread racing here, as "importsSatisfied" is merely an optimization
             // if two threads satisfy imports twice, the results is the same, just the perf hit is heavier.
@@ -562,7 +575,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private void DisposePart(object exportedValue, CatalogPart catalogPart, AtomicComposition atomicComposition)
         {
-            Assumes.NotNull(catalogPart);
+            if (catalogPart == null)
+            {
+                throw new ArgumentNullException(nameof(catalogPart));
+            }
 
             if (_isDisposed)
                 return;
@@ -614,7 +630,15 @@ namespace System.ComponentModel.Composition.Hosting
 
         private void PreventPartCollection(object exportedValue, ComposablePart part)
         {
-            Assumes.NotNull(exportedValue, part);
+            if (exportedValue == null)
+            {
+                throw new ArgumentNullException(nameof(exportedValue));
+            }
+
+            if (part == null)
+            {
+                throw new ArgumentNullException(nameof(part));
+            }
 
             using (_lock.LockStateForWrite())
             {
@@ -673,7 +697,10 @@ namespace System.ComponentModel.Composition.Hosting
                         forceRejectionTest = true;
                         break;
                     default:
-                        Assumes.IsTrue(state == AtomicCompositionQueryState.Unknown);
+                        if (state != AtomicCompositionQueryState.Unknown)
+                        {
+                            throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                        }
                         // Need to do the work to determine the state
                         break;
                 }
index 6d2ef1f..5ae073b 100644 (file)
@@ -154,7 +154,10 @@ namespace System.ComponentModel.Composition.Hosting
             {
                 if (_importEngine == null)
                 {
-                    Assumes.NotNull(_sourceProvider);
+                    if (_sourceProvider == null)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     ImportEngine importEngine = new ImportEngine(_sourceProvider, _compositionOptions);
                     using (_lock.LockStateForWrite())
                     {
@@ -316,7 +319,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private List<ComposablePart> GetUpdatedPartsList(ref CompositionBatch batch)
         {
-            Assumes.NotNull(batch);
+            if (batch == null)
+            {
+                throw new ArgumentNullException(nameof(batch));
+            }
 
             // Copy the current list of parts - we are about to modify it
             // This is an OK thing to do as this is the only method that can modify the List AND Compose can
@@ -356,7 +362,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private void Recompose(CompositionBatch batch, AtomicComposition atomicComposition)
         {
-            Assumes.NotNull(batch);
+            if (batch == null)
+            {
+                throw new ArgumentNullException(nameof(batch));
+            }
 
             // Unregister any removed component parts
             foreach (ComposablePart part in batch.PartsToRemove)
index 35d5b69..686e976 100644 (file)
@@ -18,7 +18,10 @@ namespace System.ComponentModel.Composition.Hosting
 
             public SingleExportComposablePart(Export export)
             {
-                Assumes.NotNull(export);
+                if (export == null)
+                {
+                    throw new ArgumentNullException(nameof(export));
+                }
 
                 _export = export;
             }
index 99d79b4..c60fa4b 100644 (file)
@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information.
 
 using System.ComponentModel.Composition.Primitives;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.Hosting
 {
@@ -15,7 +14,10 @@ namespace System.ComponentModel.Composition.Hosting
 
             public CompositionServiceShim(CompositionContainer innerContainer)
             {
-                Assumes.NotNull(innerContainer);
+                if (innerContainer == null)
+                {
+                    throw new ArgumentNullException(nameof(innerContainer));
+                }
                 _innerContainer = innerContainer;
             }
 
index 09b71ea..8ef89f5 100644 (file)
@@ -610,11 +610,17 @@ namespace System.ComponentModel.Composition.Hosting
             switch((ImportSource)source)
             {
                 case ImportSource.Any:
-                    Assumes.NotNull(_rootProvider);
+                    if (_rootProvider == null)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     _rootProvider.TryGetExports(definition, atomicComposition, out exports);
                     break;
                 case ImportSource.Local:
-                    Assumes.NotNull(_localExportProvider);
+                    if (_localExportProvider == null)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     _localExportProvider.TryGetExports(definition.RemoveImportSource(), atomicComposition, out exports);
                     break;
                 case ImportSource.NonLocal:
index 3a8d85a..88951e6 100644 (file)
@@ -189,7 +189,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         internal IEnumerable<Tuple<ComposablePartDefinition, ExportDefinition>> GetExportsFromPublicSurface(ImportDefinition definition)
         {
-            Assumes.NotNull(definition, nameof(definition));
+            if (definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
 
             var exports = new List<Tuple<ComposablePartDefinition, ExportDefinition>>();
 
index e4139e0..555bc3a 100644 (file)
@@ -20,7 +20,11 @@ namespace System.ComponentModel.Composition.Hosting
 
         internal CompositionService(ComposablePartCatalog composablePartCatalog)
         {
-            Assumes.NotNull(composablePartCatalog);
+            if (composablePartCatalog == null)
+            {
+                throw new ArgumentNullException(nameof(composablePartCatalog));
+            }
+
             _notifyCatalog = composablePartCatalog as INotifyComposablePartCatalogChanged;
             try
             {
@@ -47,13 +51,19 @@ namespace System.ComponentModel.Composition.Hosting
         public void SatisfyImportsOnce(ComposablePart part)
         {
             Requires.NotNull(part, nameof(part));
-            Assumes.NotNull(_compositionContainer);
+            if(_compositionContainer == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
             _compositionContainer.SatisfyImportsOnce(part);
         }
 
         public void Dispose()
         {
-            Assumes.NotNull(_compositionContainer);
+            if (_compositionContainer == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
             
             // Delegates are cool there is no concern if you try to remove an item from them and they don't exist
             if (_notifyCatalog != null)
index 4074acc..1e14c94 100644 (file)
@@ -26,7 +26,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         internal static Type GetDefaultTypeFromMember(this MemberInfo member)
         {
-            Assumes.NotNull(member);
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             switch (member.MemberType)
             {
@@ -39,7 +42,10 @@ namespace System.ComponentModel.Composition.Hosting
 
                 case MemberTypes.Field:
                 default:
-                    Assumes.IsTrue(member.MemberType == MemberTypes.Field);
+                    if(member.MemberType != MemberTypes.Field)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     return ((FieldInfo)member).FieldType;
             }
         }
@@ -58,7 +64,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         internal static Type AdjustSpecifiedTypeIdentityType(this Type specifiedContractType, Type memberType)
         {
-            Assumes.NotNull(specifiedContractType);
+            if (specifiedContractType == null)
+            {
+                throw new ArgumentNullException(nameof(specifiedContractType));
+            }
 
             if ((memberType != null) && memberType.IsGenericType && specifiedContractType.IsGenericType)
             {
@@ -120,7 +129,10 @@ internal static string GetTypeIdentityFromExport(this MemberInfo member, Type ty
             else
             {
                 MethodInfo method = member as MethodInfo;
-                Assumes.NotNull(method);
+                if (method == null) 
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
                 return AttributedModelServices.GetTypeIdentity(method);
             }
         }
@@ -398,7 +410,10 @@ internal static Type GetContractTypeFromImport(this IAttributedImport import, Im
 
             private void InferArrayType(Type itemType)
             {
-                Assumes.NotNull(itemType);
+                if (itemType == null)
+                {
+                    throw new ArgumentNullException(nameof(itemType));
+                }
 
                 if (_arrayType == null)
                 {
@@ -618,7 +633,11 @@ internal static Type GetContractTypeFromImport(this IAttributedImport import, Im
 
         private static bool IsValidAttributeType(Type type, bool arrayAllowed)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
             // Definitions of valid attribute type taken from C# 3.0 Specification section 17.1.3.
 
             // One of the following types: bool, byte, char, double, float, int, long, sbyte, short, string, uint, ulong, ushort.
index f5078fd..868e77f 100644 (file)
@@ -572,7 +572,10 @@ namespace System.ComponentModel.Composition.Hosting
         public void Refresh()
         {
             ThrowIfDisposed();
-            Assumes.NotNull(_loadedFiles);
+            if (_loadedFiles == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             List<Tuple<string, AssemblyCatalog>> catalogsToAdd;
             List<Tuple<string, AssemblyCatalog>> catalogsToRemove;
index 0fb680c..47ff7dd 100644 (file)
@@ -728,7 +728,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private T GetExportedValueCore<T>(string contractName, ImportCardinality cardinality)
         {
-            Assumes.IsTrue(cardinality.IsAtMostOne());
+            if (!cardinality.IsAtMostOne())
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             Export export = GetExportsCore(typeof(T), (Type)null, contractName, cardinality).SingleOrDefault();
 
@@ -799,7 +802,20 @@ namespace System.ComponentModel.Composition.Hosting
 
         private static ImportDefinition BuildImportDefinition(Type type, Type metadataViewType, string contractName, ImportCardinality cardinality)
         {
-            Assumes.NotNull(type, metadataViewType, contractName);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
+            if (metadataViewType == null)
+            {
+                throw new ArgumentNullException(nameof(metadataViewType));
+            }
+
+            if (contractName == null)
+            {
+                throw new ArgumentNullException(nameof(contractName));
+            }
 
             IEnumerable<KeyValuePair<string, Type>> requiredMetadata = CompositionServices.GetRequiredMetadata(metadataViewType);
             IDictionary<string, object> metadata = CompositionServices.GetImportMetadata(type, null);
index 6ff56b1..0ee867b 100644 (file)
@@ -108,7 +108,10 @@ namespace System.ComponentModel.Composition.Hosting
                 case ExportCardinalityCheckResult.NoExports:
                     throw new ImportCardinalityMismatchException(string.Format(CultureInfo.CurrentCulture, SR.CardinalityMismatch_NoExports, definition.ToString()));
                 default:
-                    Assumes.IsTrue(result == ExportCardinalityCheckResult.TooManyExports);
+                    if (result != ExportCardinalityCheckResult.TooManyExports)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     throw new ImportCardinalityMismatchException(string.Format(CultureInfo.CurrentCulture, SR.CardinalityMismatch_TooManyExports_Constraint, definition.ToString()));
             }
         }
@@ -204,7 +207,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private ExportCardinalityCheckResult TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, out IEnumerable<Export> exports)
         {
-            Assumes.NotNull(definition);
+            if (definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
 
             exports = GetExportsCore(definition, atomicComposition);
 
index a149639..7428f38 100644 (file)
@@ -5,7 +5,6 @@
 using System.Collections.Generic;
 using System.ComponentModel.Composition.Primitives;
 using System.Linq;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.Hosting
 {
@@ -19,9 +18,15 @@ namespace System.ComponentModel.Composition.Hosting
 
             public DependenciesTraversal(FilteredCatalog catalog, Func<ImportDefinition, bool> importFilter)
             {
-                Assumes.NotNull(catalog);
-                Assumes.NotNull(importFilter);
+                if (catalog == null)
+                {
+                    throw new ArgumentNullException(nameof(catalog));
+                }
 
+                if (importFilter == null)
+                {
+                    throw new ArgumentNullException(nameof(importFilter));
+                }
                 _parts = catalog._innerCatalog;
                 _importFilter = importFilter;
             }
index e927078..e8c1a20 100644 (file)
@@ -5,7 +5,6 @@
 using System.Collections.Generic;
 using System.ComponentModel.Composition.Primitives;
 using System.Linq;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.Hosting
 {
@@ -25,8 +24,14 @@ namespace System.ComponentModel.Composition.Hosting
 
             public DependentsTraversal(FilteredCatalog catalog, Func<ImportDefinition, bool> importFilter)
             {
-                Assumes.NotNull(catalog);
-                Assumes.NotNull(importFilter);
+                if (catalog == null)
+                {
+                    throw new ArgumentNullException(nameof(catalog));
+                }
+                if (importFilter == null)
+                {
+                    throw new ArgumentNullException(nameof(importFilter));
+                }
 
                 _parts = catalog._innerCatalog;
                 _importFilter = importFilter;
index 942b20c..0e8899a 100644 (file)
@@ -59,7 +59,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private FilteredCatalog Traverse(IComposablePartCatalogTraversal traversal)
         {
-            Assumes.NotNull(traversal);
+            if (traversal == null)
+            {
+                throw new ArgumentNullException(nameof(traversal));
+            }
 
             // we make sure that the underlyiong catalog cannot change while we are doing the trasversal
             // After thaty traversal is done, the freeze is lifted, and the catalog is free to change, but the changes 
@@ -80,8 +83,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private static HashSet<ComposablePartDefinition> GetTraversalClosure(IEnumerable<ComposablePartDefinition> parts, IComposablePartCatalogTraversal traversal)
         {
-            Assumes.NotNull(traversal);
-
+            if (traversal == null)
+            {
+                throw new ArgumentNullException(nameof(traversal));
+            }
             var traversedParts = new HashSet<ComposablePartDefinition>();
             GetTraversalClosure(parts, traversedParts, traversal);
             return traversedParts;
index 9610878..592be57 100644 (file)
@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information.
 
 using System.Collections.Generic;
-using Microsoft.Internal;
 using Microsoft.Internal.Collections;
 
 namespace System.ComponentModel.Composition.Hosting
@@ -29,7 +28,11 @@ namespace System.ComponentModel.Composition.Hosting
 
             public void AddPartManager(PartManager part)
             {
-                Assumes.NotNull(part);
+                if (part == null)
+                {
+                    throw new ArgumentNullException(nameof(part));
+                }
+
                 if (!_removedPartManagers.Remove(part))
                 {
                     _addedPartManagers.Add(part);
@@ -38,7 +41,11 @@ namespace System.ComponentModel.Composition.Hosting
 
             public void RemovePartManager(PartManager part)
             {
-                Assumes.NotNull(part);
+                if (part == null)
+                {
+                    throw new ArgumentNullException(nameof(part));
+                }
+
                 if (!_addedPartManagers.Remove(part))
                 {
                     _removedPartManagers.Add(part);
index 9c013fc..0fc6d70 100644 (file)
@@ -410,8 +410,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private CompositionResult TrySatisfyImports(PartManager partManager, ComposablePart part, bool shouldTrackImports)
         {
-            Assumes.NotNull(part);
-
+            if (part == null)
+            {
+                throw new ArgumentNullException(nameof(part));
+            }
             var result = CompositionResult.SucceededResult;
 
             // get out if the part is already composed
@@ -688,7 +690,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         private EngineContext GetEngineContext(AtomicComposition atomicComposition)
         {
-            Assumes.NotNull(atomicComposition);
+            if (atomicComposition == null)
+            {
+                throw new ArgumentNullException(nameof(atomicComposition));
+            }
 
             EngineContext engineContext;
             if (!atomicComposition.TryGetValue(this, true, out engineContext))
@@ -722,7 +727,10 @@ namespace System.ComponentModel.Composition.Hosting
             }
 
             // This should only be called when a loop has been detected - so it should always be on the stack
-            Assumes.IsTrue(lastPart == firstPart);
+            if (lastPart != firstPart)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
             return false;
         }
 
index 7399b0d..f5203b4 100644 (file)
@@ -33,7 +33,10 @@ namespace System.ComponentModel.Composition.Hosting
 
             public NonImportSourceImportDefinition(ContractBasedImportDefinition sourceDefinition)
             {
-                Assumes.NotNull(sourceDefinition);
+                if (sourceDefinition == null)
+                {
+                    throw new ArgumentNullException(nameof(sourceDefinition));
+                }
                 _sourceDefinition = sourceDefinition;
                 _metadata = null;
             }
index 446fd02..fe3c2cc 100644 (file)
@@ -258,7 +258,10 @@ namespace System.ComponentModel.Composition.Hosting
                     {
                         if (_parts == null)
                         {
-                            Assumes.NotNull(_types);
+                            if (_types == null)
+                            {
+                                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                            }
 
                             var collection = new List<ComposablePartDefinition>();
                             foreach (Type type in _types)
@@ -283,7 +286,10 @@ namespace System.ComponentModel.Composition.Hosting
 
         internal override IEnumerable<ComposablePartDefinition> GetCandidateParts(ImportDefinition definition)
         {
-            Assumes.NotNull(definition);
+            if (definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
 
             string contractName = definition.ContractName;
             if (string.IsNullOrEmpty(contractName))
index 274f5b4..bf67cce 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition
 {
@@ -29,7 +28,10 @@ namespace System.ComponentModel.Composition
 
         public static T GetValue<T>(this IDictionary<string, object> metadata, string key)
         {
-            Assumes.NotNull(metadata, nameof(metadata));
+            if(metadata == null)
+            {
+                throw new ArgumentNullException(nameof(metadata));
+            }
 
             object untypedValue = null;
             if (!metadata.TryGetValue(key, out untypedValue))
index 1094d68..f19f6e4 100644 (file)
@@ -91,8 +91,15 @@ namespace System.ComponentModel.Composition
 
         public static MetadataViewFactory GetMetadataViewFactory(Type viewType)
         {
-            Assumes.NotNull(viewType);
-            Assumes.IsTrue(viewType.IsInterface);
+            if(viewType == null)
+            {
+                throw new ArgumentNullException(nameof(viewType));
+            }
+
+            if(!viewType.IsInterface)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             MetadataViewFactory metadataViewFactory;
             bool foundMetadataViewFactory;
@@ -107,11 +114,17 @@ namespace System.ComponentModel.Composition
             {
                 // Try again under a write lock if still none generate the proxy
                 Type generatedProxyType = GenerateInterfaceViewProxyType(viewType);
-                Assumes.NotNull(generatedProxyType);
+                if(generatedProxyType == null)
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
 
                 MetadataViewFactory generatedMetadataViewFactory = (MetadataViewFactory)Delegate.CreateDelegate(
                     typeof(MetadataViewFactory), generatedProxyType.GetMethod(MetadataViewGenerator.MetadataViewFactoryName, BindingFlags.Public | BindingFlags.Static));
-                Assumes.NotNull(generatedMetadataViewFactory);
+                if(generatedMetadataViewFactory == null)
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
 
                 using (new WriteLock(_lock))
                 {
@@ -127,7 +140,10 @@ namespace System.ComponentModel.Composition
 
         public static TMetadataView CreateMetadataView<TMetadataView>(MetadataViewFactory metadataViewFactory, IDictionary<string, object> metadata)
         {
-            Assumes.NotNull(metadataViewFactory);
+            if(metadataViewFactory == null)
+            {
+                throw new ArgumentNullException(nameof(metadataViewFactory));
+            }
             // we are simulating the Activator.CreateInstance behavior by wrapping everything in a TargetInvocationException
             try
             {
index f6cfb74..a98277b 100644 (file)
@@ -15,7 +15,10 @@ namespace System.ComponentModel.Composition
         [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
         public static TMetadataView GetMetadataView<TMetadataView>(IDictionary<string, object> metadata)
         {
-            Assumes.NotNull(metadata);
+            if(metadata == null)
+            {
+                throw new ArgumentNullException(nameof(metadata));
+            }
 
             Type metadataViewType = typeof(TMetadataView);
 
@@ -79,7 +82,10 @@ namespace System.ComponentModel.Composition
                     }
                     else
                     {
-                        Assumes.NotNull(proxyType);
+                        if(proxyType == null)
+                        {
+                            throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                        }
                         return (TMetadataView)proxyType.SafeCreateInstance(metadata);
                     }
                 }
@@ -123,7 +129,10 @@ namespace System.ComponentModel.Composition
 
         public static bool IsViewTypeValid(Type metadataViewType)
         {
-            Assumes.NotNull(metadataViewType);
+            if(metadataViewType == null)
+            {
+                throw new ArgumentNullException(nameof(metadataViewType));
+            }
 
             // If the Metadata dictionary is cast compatible with the passed in type
             if (ExportServices.IsDefaultMetadataViewType(metadataViewType)
index 1d1b532..126f0a2 100644 (file)
@@ -64,7 +64,10 @@ namespace System.ComponentModel.Composition.Primitives
 #pragma warning disable 420
                     Interlocked.CompareExchange(ref _queryableParts, p, null);
 #pragma warning restore 420
-                    Assumes.NotNull(_queryableParts);
+                    if (_queryableParts == null)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                 }
                 return _queryableParts;
             }
index 0fb131e..44854f3 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.ComponentModel.Composition.Primitives;
 using System.Reflection;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -17,7 +16,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ExportFactoryCreator(Type exportFactoryType)
         {
-            Assumes.NotNull(exportFactoryType);
+            if(exportFactoryType == null)
+            {
+                throw new ArgumentNullException(nameof(exportFactoryType));
+            }
 
             _exportFactoryType = exportFactoryType;
         }
@@ -34,7 +36,11 @@ namespace System.ComponentModel.Composition.ReflectionModel
                 genericMethod = _createStronglyTypedExportFactoryOfTM.MakeGenericMethod(exportType, metadataViewType);
             }
 
-            Assumes.NotNull(genericMethod);
+            if(genericMethod == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
+            
             Func<Export, object> exportFactoryFactory = (Func<Export, object>)Delegate.CreateDelegate(typeof(Func<Export, object>), this, genericMethod);
             return (e) => exportFactoryFactory.Invoke(e);
         }
index f9b5cd6..fec4f25 100644 (file)
@@ -6,7 +6,6 @@ using System.ComponentModel.Composition.Primitives;
 using System.Globalization;
 using System.Reflection;
 using System.Threading;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -19,7 +18,15 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ExportingMember(ExportDefinition definition, ReflectionMember member)
         {
-            Assumes.NotNull(definition, member);
+            if(definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
+
+            if(member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             _definition = definition;
             _member = member;
index ed2dac5..875da0d 100644 (file)
@@ -6,7 +6,6 @@ using System.Collections.Generic;
 using System.Globalization;
 using System.Linq;
 using System.Reflection;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -14,7 +13,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
     {
         internal static IList<Type> GetPureGenericParameters(this Type type)
         {
-            Assumes.NotNull(type);
+            if(type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             if (type.IsGenericType && type.ContainsGenericParameters)
             {
@@ -36,7 +38,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         internal static int GetPureGenericArity(this Type type)
         {
-            Assumes.NotNull(type);
+            if(type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             int genericArity = 0;
             if (type.IsGenericType && type.ContainsGenericParameters)
index 121e56c..235289d 100644 (file)
@@ -31,9 +31,20 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public GenericSpecializationPartCreationInfo(IReflectionPartCreationInfo originalPartCreationInfo, ReflectionComposablePartDefinition originalPart, Type[] specialization)
         {
-            Assumes.NotNull(originalPartCreationInfo);
-            Assumes.NotNull(specialization);
-            Assumes.NotNull(originalPart);
+            if(originalPartCreationInfo == null)
+            {
+                throw new ArgumentNullException(nameof(originalPartCreationInfo));
+            }
+
+            if(originalPart == null)
+            {
+                throw new ArgumentNullException(nameof(originalPart));
+            }
+
+            if(specialization == null)
+            {
+                throw new ArgumentNullException(nameof(specialization));
+            }
 
             _originalPartCreationInfo = originalPartCreationInfo;
             _originalPart = originalPart;
@@ -112,7 +123,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
         private MemberInfo[] GetAccessors(LazyMemberInfo originalLazyMember)
         {
             BuildTables();
-            Assumes.NotNull(_membersTable);
+            if(_membersTable == null)
+            {
+                throw new ArgumentNullException(nameof(_membersTable));
+            }
 
             return _membersTable[originalLazyMember];
         }
@@ -120,7 +134,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
         private ParameterInfo GetParameter(Lazy<ParameterInfo> originalParameter)
         {
             BuildTables();
-            Assumes.NotNull(_parametersTable);
+            if (_parametersTable == null)
+            {
+                throw new ArgumentNullException(nameof(_parametersTable));
+            }
 
             return _parametersTable[originalParameter];
         }
@@ -143,7 +160,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     members = _members;
                     parameters = _parameters;
 
-                    Assumes.NotNull(members);
+                    if (members == null)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                 }
             }
 
@@ -170,7 +190,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         private Dictionary<LazyMemberInfo, MemberInfo[]> BuildMembersTable(List<LazyMemberInfo> members)
         {
-            Assumes.NotNull(members);
+            if (members == null)
+            {
+                throw new ArgumentNullException(nameof(members));
+            }
 
             Dictionary<LazyMemberInfo, MemberInfo[]> membersTable = new Dictionary<LazyMemberInfo, MemberInfo[]>();
             Dictionary<int, MemberInfo> specializedPartMembers = new Dictionary<int, MemberInfo>();
@@ -219,7 +242,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     if (genericAccessors[i] != null)
                     {
                         specializedPartMembers.TryGetValue(genericAccessors[i].MetadataToken, out accessors[i]);
-                        Assumes.NotNull(accessors[i]);
+                        if (accessors[i] == null)
+                        {
+                            throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                        }
                     }
                 }
 
@@ -326,7 +352,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
             else
             {
                 ReflectionParameterImportDefinition parameterImport = reflectionImport as ReflectionParameterImportDefinition;
-                Assumes.NotNull(parameterImport);
+                if (parameterImport == null)
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
 
                 Lazy<ParameterInfo> lazyParameter = parameterImport.ImportingLazyParameter;
                 Lazy<ParameterInfo> parameter = new Lazy<ParameterInfo>(() => GetParameter(lazyParameter));
index 192dfc8..ed430f4 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.ComponentModel.Composition.Primitives;
-using Microsoft.Internal;
 using Microsoft.Internal.Collections;
 
 namespace System.ComponentModel.Composition.ReflectionModel
@@ -36,7 +35,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ImportType(Type type, ImportCardinality cardinality)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             _type = type;
             Type contractType = type;
@@ -72,7 +74,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
         {
             get
             {
-                Assumes.IsTrue(!_isOpenGeneric);
+                if (_isOpenGeneric)
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
                 return _castSingleValue;
             }
         }
@@ -106,8 +111,15 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public static bool IsDescendentOf(Type type, Type baseType)
         {
-            Assumes.NotNull(type);
-            Assumes.NotNull(baseType);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
+            if (baseType == null)
+            {
+                throw new ArgumentNullException(nameof(baseType));
+            }
 
             if (!baseType.IsGenericTypeDefinition)
             {
index 92de6c8..4f85335 100644 (file)
@@ -15,7 +15,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         protected ImportingItem(ContractBasedImportDefinition definition, ImportType importType)
         {
-            Assumes.NotNull(definition);
+            if (definition == null)
+            {
+                throw new ArgumentNullException(nameof(definition));
+            }
 
             _definition = definition;
             _importType = importType;
@@ -45,7 +48,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         private object CastExportsToCollectionImportType(Export[] exports)
         {
-            Assumes.NotNull(exports);
+            if (exports == null)
+            {
+                throw new ArgumentNullException(nameof(exports));
+            }
 
             // Element type could be null if the actually import type of the member is not a collection
             // This particular case will end up failing when we set the member.
@@ -65,8 +71,15 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         private object CastExportsToSingleImportType(Export[] exports)
         {
-            Assumes.NotNull(exports);
-            Assumes.IsTrue(exports.Length < 2);
+            if (exports == null)
+            {
+                throw new ArgumentNullException(nameof(exports));
+            }
+
+            if (exports.Length >= 2) 
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             if (exports.Length == 0)
             {   
index 5333004..d7a5d68 100644 (file)
@@ -20,7 +20,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
         public ImportingMember(ContractBasedImportDefinition definition, ReflectionWritableMember member, ImportType importType)
             : base(definition, importType)
         {
-            Assumes.NotNull(definition, member);
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             _member = member;
         }
@@ -105,7 +108,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         private void SetCollectionMemberValue(object instance, IEnumerable values)
         {
-            Assumes.NotNull(values);
+            if (values == null)
+            {
+                throw new ArgumentNullException(nameof(values));
+            }
 
             ICollection<object> collection = null;
             Type itemType = CollectionServices.GetCollectionElementType(ImportType.ActualType);
@@ -120,7 +126,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         private ICollection<object> GetNormalizedCollection(Type itemType, object instance)
         {
-            Assumes.NotNull(itemType);
+            if (itemType == null)
+            {
+                throw new ArgumentNullException(nameof(itemType));
+            }
 
             object collectionObject = null;
 
@@ -215,7 +224,15 @@ namespace System.ComponentModel.Composition.ReflectionModel
         [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
         private void PopulateCollection(ICollection<object> collection, IEnumerable values)
         {
-            Assumes.NotNull(collection, values);
+            if (collection == null)
+            {
+                throw new ArgumentNullException(nameof(collection));
+            }
+
+            if (values == null)
+            {
+                throw new ArgumentNullException(nameof(values));
+            }
 
             try
             {
index ebc4933..4ffdc8e 100644 (file)
@@ -27,7 +27,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
             {
                 case MemberTypes.Property:
                     PropertyInfo property = (PropertyInfo)member;
-                    Assumes.NotNull(property);
+                    if (property == null)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     _accessors = new MemberInfo[] { property.GetGetMethod(true), property.GetSetMethod(true) };
                     break;
                 case MemberTypes.Event:
@@ -97,8 +100,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
             }
             else
             {
-                Assumes.NotNull(_accessors);
-                Assumes.NotNull(_accessors[0]);
+                if(_accessors == null || _accessors[0] == null)
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
                 return MemberType.GetHashCode() ^ _accessors[0].GetHashCode();
             }
         }
@@ -120,8 +125,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
             }
 
             // we are dealing with explicitly passed accessors in both cases
-            Assumes.NotNull(_accessors);
-            Assumes.NotNull(that._accessors);
+            if(_accessors == null || that._accessors == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
             return _accessors.SequenceEqual(that._accessors);
         }
 
index b67295f..d35e2f4 100644 (file)
@@ -6,7 +6,6 @@ using System.ComponentModel.Composition.Hosting;
 using System.ComponentModel.Composition.Primitives;
 using System.Linq.Expressions;
 using System.Text;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -21,7 +20,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
             : base(importingLazyMember, CompositionConstants.PartCreatorContractName, CompositionConstants.PartCreatorTypeIdentity,
                 productImportDefinition.RequiredMetadata, productImportDefinition.Cardinality, productImportDefinition.IsRecomposable, false, productImportDefinition.RequiredCreationPolicy, MetadataServices.EmptyMetadata, origin)
         {
-            Assumes.NotNull(productImportDefinition);
+            if (productImportDefinition == null)
+            {
+                throw new ArgumentNullException(nameof(productImportDefinition));
+            }
             _productImportDefinition = productImportDefinition;
         }
 
index b9efa11..8a27db6 100644 (file)
@@ -7,7 +7,6 @@ using System.ComponentModel.Composition.Primitives;
 using System.Linq.Expressions;
 using System.Reflection;
 using System.Text;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -22,7 +21,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
             : base(importingLazyParameter, CompositionConstants.PartCreatorContractName, CompositionConstants.PartCreatorTypeIdentity,
                 productImportDefinition.RequiredMetadata, productImportDefinition.Cardinality, CreationPolicy.Any, MetadataServices.EmptyMetadata, origin)
         {
-            Assumes.NotNull(productImportDefinition);
+            if (productImportDefinition == null)
+            {
+                throw new ArgumentNullException(nameof(productImportDefinition));
+            }
             _productImportDefinition = productImportDefinition;
         }
 
index 586b7e9..a6c6079 100644 (file)
@@ -403,7 +403,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     throw new ArgumentException(SR.Argument_ExportsTooMany, nameof(exports));
 
                 default:
-                    Assumes.IsTrue(result == ExportCardinalityCheckResult.Match);
+                    if(result != ExportCardinalityCheckResult.Match)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     break;
             }
         }
index cddb6db..98cbfc3 100644 (file)
@@ -8,7 +8,6 @@ using System.ComponentModel.Composition.Primitives;
 using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Reflection;
-using Microsoft.Internal;
 using Microsoft.Internal.Collections;
 
 namespace System.ComponentModel.Composition.ReflectionModel
@@ -25,7 +24,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ReflectionComposablePartDefinition(IReflectionPartCreationInfo creationInfo)
         {
-            Assumes.NotNull(creationInfo);
+            if (creationInfo == null)
+            {
+                throw new ArgumentNullException(nameof(creationInfo));
+            }
             _creationInfo = creationInfo;
         }
 
index b6f4a7b..44c2006 100644 (file)
@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information.
 
 using System.Reflection;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -17,11 +16,17 @@ namespace System.ComponentModel.Composition.ReflectionModel
             switch (memberType)
             {
                 case MemberTypes.Field:
-                    Assumes.IsTrue(accessors.Length == 1);
+                    if(accessors.Length != 1)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     return ((FieldInfo)accessors[0]).ToReflectionField();
 
                 case MemberTypes.Property:
-                    Assumes.IsTrue(accessors.Length == 2);
+                    if(accessors.Length != 2)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     return ReflectionExtensions.CreateReflectionProperty((MethodInfo)accessors[0], (MethodInfo)accessors[1]);
 
                 case MemberTypes.NestedType:
@@ -29,19 +34,28 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     return ((Type)accessors[0]).ToReflectionType();
 
                 default:
-                    Assumes.IsTrue(memberType == MemberTypes.Method);
+                    if(memberType != MemberTypes.Method)
+                    {
+                        throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                    }
                     return ((MethodInfo)accessors[0]).ToReflectionMethod();
             }
         }
 
         public static LazyMemberInfo ToLazyMember(this MemberInfo member)
         {
-            Assumes.NotNull(member);
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             if (member.MemberType == MemberTypes.Property)
             {
                 PropertyInfo property = member as PropertyInfo;
-                Assumes.NotNull(property);
+                if (property == null)
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
 
                 MemberInfo[] accessors = new MemberInfo[] { property.GetGetMethod(true), property.GetSetMethod(true) };
                 return new LazyMemberInfo(MemberTypes.Property, accessors);
@@ -54,54 +68,87 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public static ReflectionWritableMember ToReflectionWriteableMember(this LazyMemberInfo lazyMember)
         {
-            Assumes.IsTrue((lazyMember.MemberType == MemberTypes.Field) || (lazyMember.MemberType == MemberTypes.Property));
+            if((lazyMember.MemberType != MemberTypes.Field) && (lazyMember.MemberType != MemberTypes.Property))
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             ReflectionWritableMember reflectionMember = lazyMember.ToReflectionMember() as ReflectionWritableMember;
-            Assumes.NotNull(reflectionMember);
+            if (reflectionMember == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             return reflectionMember;
         }
 
         public static ReflectionProperty ToReflectionProperty(this PropertyInfo property)
         {
-            Assumes.NotNull(property);
+            if (property == null)
+            {
+                throw new ArgumentNullException(nameof(property));
+            }
+
             return CreateReflectionProperty(property.GetGetMethod(true), property.GetSetMethod(true));
         }
 
         public static ReflectionProperty CreateReflectionProperty(MethodInfo getMethod, MethodInfo setMethod)
         {
-            Assumes.IsTrue(getMethod != null || setMethod != null);
+            if(getMethod == null && setMethod == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             return new ReflectionProperty(getMethod, setMethod);
         }
 
         public static ReflectionParameter ToReflectionParameter(this ParameterInfo parameter)
         {
-            Assumes.NotNull(parameter);
+            if (parameter == null)
+            {
+                throw new ArgumentNullException(nameof(parameter));
+            }
+
             return new ReflectionParameter(parameter);
         }
 
         public static ReflectionMethod ToReflectionMethod(this MethodInfo method)
         {
-            Assumes.NotNull(method);
+            if (method == null)
+            {
+                throw new ArgumentNullException(nameof(method));
+            }
+
             return new ReflectionMethod(method);
         }
 
         public static ReflectionField ToReflectionField(this FieldInfo field)
         {
-            Assumes.NotNull(field);
+            if (field == null)
+            {
+                throw new ArgumentNullException(nameof(field));
+            }
+
             return new ReflectionField(field);
         }
 
         public static ReflectionType ToReflectionType(this Type type)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
             return new ReflectionType(type);
         }
 
         public static ReflectionWritableMember ToReflectionWritableMember(this MemberInfo member)
         {
-            Assumes.NotNull(member);
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
+
             if (member.MemberType == MemberTypes.Property)
             {
                 return ((PropertyInfo)member).ToReflectionProperty();
index 64a0282..a098321 100644 (file)
@@ -13,7 +13,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ReflectionField(FieldInfo field)
         {
-            Assumes.NotNull(field);
+            if (field == null)
+            {
+                throw new ArgumentNullException(nameof(field));
+            }
 
             _field = field;
         }
index 9c25965..620ef10 100644 (file)
@@ -5,7 +5,6 @@
 using System.Collections.Generic;
 using System.ComponentModel.Composition.Primitives;
 using System.Globalization;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -18,7 +17,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ReflectionMemberExportDefinition(LazyMemberInfo member, ExportDefinition exportDefinition, ICompositionElement origin)
         {
-            Assumes.NotNull(exportDefinition);
+            if (exportDefinition == null)
+            {
+                throw new ArgumentNullException(nameof(exportDefinition));
+            }
 
             _member = member;
             _exportDefinition = exportDefinition;
index d1d40fc..cbc4eb8 100644 (file)
@@ -5,7 +5,6 @@
 using System.Collections.Generic;
 using System.ComponentModel.Composition.Primitives;
 using System.Globalization;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -26,7 +25,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
             ICompositionElement origin) 
             : base(contractName, requiredTypeIdentity, requiredMetadata, cardinality, isRecomposable, isPrerequisite, requiredCreationPolicy, metadata, origin)
         {
-            Assumes.NotNull(contractName);
+            if (contractName == null)
+            {
+                throw new ArgumentNullException(nameof(contractName));
+            }
 
             _importingLazyMember = importingLazyMember;
         }
index 56ab1bc..0f5824e 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.ComponentModel.Composition.Primitives;
 using System.Reflection;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -14,7 +13,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ReflectionMethod(MethodInfo method)
         {
-            Assumes.NotNull(method);
+            if (method == null)
+            {
+                throw new ArgumentNullException(nameof(method));
+            }
 
             _method = method;
         }
index 9c74b2c..45c5dc5 100644 (file)
@@ -346,7 +346,10 @@ internal class ReflectionPartCreationInfo : IReflectionPartCreationInfo
             Lazy<IDictionary<string, object>> metadata,
             ICompositionElement origin)
         {
-            Assumes.NotNull(partType);
+            if (partType == null)
+            {
+                throw new ArgumentNullException(nameof(partType));
+            }
 
             _partType = partType;
             _isDisposalRequired = isDisposalRequired;
index 905528d..57d5437 100644 (file)
@@ -14,7 +14,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ReflectionParameter(ParameterInfo parameter)
         {
-            Assumes.NotNull(parameter);
+           if (parameter == null)
+           {
+                throw new ArgumentNullException(nameof(parameter));
+            }
 
             _parameter = parameter;
         }
index 8b55873..f861e54 100644 (file)
@@ -25,7 +25,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
             ICompositionElement origin)
             : base(contractName, requiredTypeIdentity, requiredMetadata, cardinality, false, true, requiredCreationPolicy, metadata, origin)
         {
-            Assumes.NotNull(importingLazyParameter);
+            if (importingLazyParameter == null)
+            {
+                throw new ArgumentNullException(nameof(importingLazyParameter));
+            }
 
             _importingLazyParameter = importingLazyParameter;
         }
index ee482ba..b2c031e 100644 (file)
@@ -22,7 +22,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ReflectionProperty(MethodInfo getMethod, MethodInfo setMethod)
         {
-            Assumes.IsTrue(getMethod != null || setMethod != null);
+            if (getMethod == null && setMethod == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             _getMethod = getMethod;
             _setMethod = setMethod;
@@ -61,7 +64,11 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
                 string name = method.Name;
 
-                Assumes.IsTrue(name.Length > 4);
+                if (name.Length <= 4)
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
+
 
                 // Remove 'get_' or 'set_'
                 return name.Substring(4);
@@ -94,8 +101,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
                 ParameterInfo[] parameters = UnderlyingSetMethod.GetParameters();
 
-                Assumes.IsTrue(parameters.Length > 0);
-
+                if (parameters.Length == 0)
+                {
+                    throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                }
                 return parameters[parameters.Length - 1].ParameterType;
             }
         }
@@ -107,15 +116,20 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public override object GetValue(object instance)
         {
-            Assumes.NotNull(_getMethod);
+            if (_getMethod == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             return UnderlyingGetMethod.SafeInvoke(instance);
         }
 
         public override void SetValue(object instance, object value)
         {
-            Assumes.NotNull(_setMethod);
-
+            if (_setMethod == null)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
             UnderlyingSetMethod.SafeInvoke(instance, value);
         }
 
index e03c48e..abae6c8 100644 (file)
@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information.
 
 using System.Reflection;
-using Microsoft.Internal;
 
 namespace System.ComponentModel.Composition.ReflectionModel
 {
@@ -13,7 +12,10 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public ReflectionType(Type type)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             _type = type;
         }
index de6f5c5..36d19a0 100644 (file)
@@ -4,6 +4,7 @@
 
 using System.Collections.Generic;
 using System.ComponentModel.Composition.Primitives;
+using System.Globalization;
 using System.Linq.Expressions;
 using System.Reflection;
 using Microsoft.Internal;
@@ -136,7 +137,15 @@ namespace System.ComponentModel.Composition
 
         private static bool TryParseExpressionAsMetadataConstraintBody(Expression expression, Expression parameter, out string requiredMetadataKey, out Type requiredMetadataType)
         {
-            Assumes.NotNull(expression, parameter);
+            if (expression == null)
+            {
+                throw new ArgumentNullException(nameof(expression));
+            }
+
+            if (parameter == null)
+            {
+                throw new ArgumentNullException(nameof(parameter));
+            }
 
             requiredMetadataKey = null;
             requiredMetadataType = null;
@@ -153,7 +162,10 @@ namespace System.ComponentModel.Composition
             {
                 return false;
             }
-            Assumes.IsTrue(outerMethodCall.Arguments.Count == 1);
+            if (outerMethodCall.Arguments.Count != 1)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             // 'this' should be a constant expression pointing at a Type object
             ConstantExpression targetType = outerMethodCall.Object as ConstantExpression;
@@ -188,8 +200,10 @@ namespace System.ComponentModel.Composition
 
             // There should only ever be one argument; otherwise, 
             // we've got the wrong IDictionary.get_Item method.
-            Assumes.IsTrue(methodCall.Arguments.Count == 1);
-
+            if(methodCall.Arguments.Count != 1)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
             // Argument should a constant expression containing the metadata key
             ConstantExpression requiredMetadataKeyConstant = methodCall.Arguments[0] as ConstantExpression;
             if (requiredMetadataKeyConstant == null)
@@ -208,7 +222,10 @@ namespace System.ComponentModel.Composition
         private static bool TryParseConstant<T>(ConstantExpression constant, out T result)
             where T : class
         {
-            Assumes.NotNull(constant);
+            if (constant == null)
+            {
+                throw new ArgumentNullException(nameof(constant));
+            }
 
             if (constant.Type == typeof(T) && constant.Value != null)
             {
index 51b8967..1598f0d 100644 (file)
@@ -12,7 +12,10 @@ namespace Microsoft.Composition.Diagnostics
     {
         internal static void Registration_ConstructorConventionOverridden(Type type)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             if (CompositionTraceSource.CanWriteInformation)
             {
@@ -24,7 +27,10 @@ namespace Microsoft.Composition.Diagnostics
 
         internal static void Registration_TypeExportConventionOverridden(Type type)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             if (CompositionTraceSource.CanWriteWarning)
             {
@@ -36,7 +42,15 @@ namespace Microsoft.Composition.Diagnostics
 
         internal static void Registration_MemberExportConventionOverridden(Type type, MemberInfo member)
         {
-            Assumes.NotNull(type, member);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             if (CompositionTraceSource.CanWriteWarning)
             {
@@ -48,7 +62,15 @@ namespace Microsoft.Composition.Diagnostics
 
         internal static void Registration_MemberImportConventionOverridden(Type type, MemberInfo member)
         {
-            Assumes.NotNull(type, member);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             if (CompositionTraceSource.CanWriteWarning)
             {
@@ -60,7 +82,15 @@ namespace Microsoft.Composition.Diagnostics
 
         internal static void Registration_OnSatisfiedImportNotificationOverridden(Type type, MemberInfo member)
         {
-            Assumes.NotNull(type, member);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             if (CompositionTraceSource.CanWriteWarning)
             {
@@ -72,7 +102,10 @@ namespace Microsoft.Composition.Diagnostics
 
         internal static void Registration_PartCreationConventionOverridden(Type type)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             if (CompositionTraceSource.CanWriteWarning)
             {
@@ -84,7 +117,15 @@ namespace Microsoft.Composition.Diagnostics
 
         internal static void Registration_MemberImportConventionMatchedTwice(Type type, MemberInfo member)
         {
-            Assumes.NotNull(type, member);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
+
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             if (CompositionTraceSource.CanWriteWarning)
             {
@@ -96,7 +137,10 @@ namespace Microsoft.Composition.Diagnostics
 
         internal static void Registration_PartMetadataConventionOverridden(Type type)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             if (CompositionTraceSource.CanWriteWarning)
             {
@@ -108,7 +152,15 @@ namespace Microsoft.Composition.Diagnostics
 
         internal static void Registration_ParameterImportConventionOverridden(ParameterInfo parameter, ConstructorInfo constructor)
         {
-            Assumes.NotNull(parameter, constructor);
+            if (parameter == null)
+            {
+                throw new ArgumentNullException(nameof(parameter));
+            }
+
+            if (constructor == null)
+            {
+                throw new ArgumentNullException(nameof(constructor));
+            }
 
             if (CompositionTraceSource.CanWriteWarning)
             {
index 225e4d0..c181e4f 100644 (file)
@@ -53,7 +53,10 @@ namespace Microsoft.Composition.Diagnostics
 
         private static void EnsureEnabled(bool condition)
         {
-            Assumes.IsTrue(condition, "To avoid unnecessary work when a trace level has not been enabled, check CanWriteXXX before calling this method.");
+            if (!condition)
+            {
+                throw new Exception(SR.Trace_Level_Not_Enabled);
+            }
         }
     }
 }
index 7ead305..51d0e71 100644 (file)
   <data name="Registration_OnSatisfiedImportNotificationOverridden" xml:space="preserve">
     <value>A OnSatisfiedImports specification convention that would apply to Type '{0}' has been overridden by attributes applied in the source file or by a prior convention.</value>
   </data>
-</root>
\ No newline at end of file
+  <data name="Diagnostic_InternalExceptionMessage" xml:space="preserve">
+    <value>Internal error occurred. Additional information: '{0}'.</value>
+  </data>
+  <data name="Trace_Level_Not_Enabled" xml:space="preserve">
+    <value>To avoid unnecessary work when a trace level has not been enabled, check CanWriteXXX before calling this method.</value>
+  </data>
+  <data name="ArgumentException_EmptyString" xml:space="preserve">
+    <value>'{0}' cannot be an empty string ("").</value>
+  </data>
+</root>
index 5b4e063..1ab437f 100644 (file)
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard1.0-Debug|AnyCPU'" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard1.0-Release|AnyCPU'" />
   <ItemGroup>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\Assumes.cs">
-      <Link>Microsoft\Internal\Assumes.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\Assumes.InternalErrorException.cs">
-      <Link>Microsoft\Internal\Assumes.InternalErrorException.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\CommonStrings.Designer.cs">
-      <Link>Microsoft\Internal\CommonStrings.Designer.cs</Link>
-      <AutoGen>True</AutoGen>
-      <DesignTime>True</DesignTime>
-      <DependentUpon>CommonStrings.resx</DependentUpon>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\EmptyArray.cs">
-      <Link>Microsoft\Internal\EmptyArray.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\Requires.cs">
-      <Link>Microsoft\Internal\Requires.cs</Link>
-    </Compile>
     <Compile Include="Microsoft\Composition\Diagnostics\CompositionTrace.cs" />
     <Compile Include="Microsoft\Composition\Diagnostics\CompositionTraceId.cs" />
     <Compile Include="Microsoft\Composition\Diagnostics\CompositionTraceSource.cs" />
     <Compile Include="System\Composition\ExceptionBuilder.cs" />
   </ItemGroup>
   <ItemGroup>
-    <EmbeddedResource Include="$(CommonPath)\Microsoft\Internal\CommonStrings.resx">
-      <Link>Microsoft\Internal\CommonStrings.resx</Link>
-      <Generator>ResXFileCodeGenerator</Generator>
-      <LastGenOutput>CommonStrings.Designer.cs</LastGenOutput>
-      <CustomToolNamespace>Microsoft.Internal</CustomToolNamespace>
-    </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\System.Composition.AttributedModel\src\System.Composition.AttributedModel.csproj">
index a4ad699..3c6d188 100644 (file)
@@ -51,7 +51,10 @@ namespace System.Composition.Convention
         /// <returns>A <see cref="PartConventionBuilder"/> that must be used to specify the rule.</returns>
         public PartConventionBuilder ForTypesDerivedFrom(Type type)
         {
-            Requires.NotNull(type, nameof(type));
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             var partBuilder = new PartConventionBuilder((t) => IsDescendentOf(t, type));
             _conventions.Add(partBuilder);
@@ -77,7 +80,10 @@ namespace System.Composition.Convention
         /// <returns>A <see cref="PartConventionBuilder"/> that must be used to specify the rule.</returns>
         public PartConventionBuilder ForType(Type type)
         {
-            Requires.NotNull(type, nameof(type));
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             var partBuilder = new PartConventionBuilder((t) => t == type);
             _conventions.Add(partBuilder);
@@ -93,7 +99,10 @@ namespace System.Composition.Convention
         /// <returns>A <see cref="PartConventionBuilder{T}"/> that must be used to specify the rule.</returns>
         public PartConventionBuilder<T> ForTypesMatching<T>(Predicate<Type> typeFilter)
         {
-            Requires.NotNull(typeFilter, nameof(typeFilter));
+            if (typeFilter == null)
+            {
+                throw new ArgumentNullException(nameof(typeFilter));
+            }
 
             var partBuilder = new PartConventionBuilder<T>(typeFilter);
             _conventions.Add(partBuilder);
@@ -108,7 +117,10 @@ namespace System.Composition.Convention
         /// <returns>A <see cref="PartConventionBuilder{T}"/> that must be used to specify the rule.</returns>
         public PartConventionBuilder ForTypesMatching(Predicate<Type> typeFilter)
         {
-            Requires.NotNull(typeFilter, nameof(typeFilter));
+            if (typeFilter == null)
+            {
+                throw new ArgumentNullException(nameof(typeFilter));
+            }
 
             var partBuilder = new PartConventionBuilder(typeFilter);
             _conventions.Add(partBuilder);
@@ -151,7 +163,10 @@ namespace System.Composition.Convention
         /// <returns>The list of applied attributes.</returns>
         public override IEnumerable<Attribute> GetCustomAttributes(Type reflectedType, System.Reflection.MemberInfo member)
         {
-            Requires.NotNull(member, nameof(member));
+            if (member == null)
+            {
+                throw new ArgumentNullException(nameof(member));
+            }
 
             // Now edit the attributes returned from the base type
             List<Attribute> cachedAttributes = null;
@@ -198,7 +213,10 @@ namespace System.Composition.Convention
                                     else
                                     {
                                         var pi = element.Item1 as ParameterInfo;
-                                        Assumes.NotNull(pi);
+                                        if (pi == null)
+                                        {
+                                            throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+                                        }
                                         List<Attribute> parameterAttributes;
 
                                         // Item contains as Constructor parameter to configure
@@ -288,7 +306,11 @@ namespace System.Composition.Convention
         /// <returns>The list of applied attributes.</returns>
         public override IEnumerable<Attribute> GetCustomAttributes(Type reflectedType, System.Reflection.ParameterInfo parameter)
         {
-            Requires.NotNull(parameter, nameof(parameter));
+            if (parameter == null)
+            {
+                throw new ArgumentNullException(nameof(parameter));
+            }
+
             var attributes = parameter.GetCustomAttributes<Attribute>(false);
             List<Attribute> cachedAttributes = ReadParameterCustomAttributes(reflectedType, parameter);
             return cachedAttributes == null ? attributes : attributes.Concat(cachedAttributes);
index 07503eb..16b91d2 100644 (file)
@@ -9,8 +9,6 @@ using System.Linq;
 using System.Text;
 using System.Reflection;
 
-using Microsoft.Internal;
-
 namespace System.Composition.Convention
 {
     /// <summary>
@@ -43,7 +41,10 @@ namespace System.Composition.Convention
         /// <returns>An export builder allowing further configuration.</returns>
         public ExportConventionBuilder AsContractType(Type type)
         {
-            Requires.NotNull(type, nameof(type));
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
             _contractType = type;
             return this;
         }
@@ -55,7 +56,14 @@ namespace System.Composition.Convention
         /// <returns>An export builder allowing further configuration.</returns>
         public ExportConventionBuilder AsContractName(string contractName)
         {
-            Requires.NotNullOrEmpty(contractName, nameof(contractName));
+            if(contractName == null)
+            {
+                throw new ArgumentNullException(nameof(contractName));
+            }
+            if(contractName.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(contractName)), nameof(contractName));
+            }
             _contractName = contractName;
             return this;
         }
@@ -67,7 +75,10 @@ namespace System.Composition.Convention
         /// <returns>An export builder allowing further configuration.</returns>
         public ExportConventionBuilder AsContractName(Func<Type, string> getContractNameFromPartType)
         {
-            Requires.NotNull(getContractNameFromPartType, nameof(getContractNameFromPartType));
+            if (getContractNameFromPartType == null)
+            {
+                throw new ArgumentNullException(nameof(getContractNameFromPartType));
+            }
             _getContractNameFromPartType = getContractNameFromPartType;
             return this;
         }
@@ -80,7 +91,15 @@ namespace System.Composition.Convention
         /// <returns>An export builder allowing further configuration.</returns>
         public ExportConventionBuilder AddMetadata(string name, object value)
         {
-            Requires.NotNullOrEmpty(name, nameof(name));
+            if (name == null)
+            {
+                throw new ArgumentNullException(nameof(name));
+            }
+
+            if (name.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(name)), nameof(name));
+            }
             if (_metadataItems == null)
             {
                 _metadataItems = new List<Tuple<string, object>>();
@@ -97,8 +116,20 @@ namespace System.Composition.Convention
         /// <returns>An export builder allowing further configuration.</returns>
         public ExportConventionBuilder AddMetadata(string name, Func<Type, object> getValueFromPartType)
         {
-            Requires.NotNullOrEmpty(name, nameof(name));
-            Requires.NotNull(getValueFromPartType, nameof(getValueFromPartType));
+            if (name == null)
+            {
+                throw new ArgumentNullException(nameof(name));
+            }
+            if (name.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(name)), nameof(name));
+            }
+
+            if (getValueFromPartType == null)
+            {
+                throw new ArgumentNullException(nameof(getValueFromPartType));
+            }
+            
             if (_metadataItemFuncs == null)
             {
                 _metadataItemFuncs = new List<Tuple<string, Func<Type, object>>>();
index fce4cfc..0ff0829 100644 (file)
@@ -36,7 +36,14 @@ namespace System.Composition.Convention
         /// <returns>An import builder allowing further configuration.</returns>
         public ImportConventionBuilder AsContractName(string contractName)
         {
-            Requires.NotNullOrEmpty(contractName, nameof(contractName));
+            if (contractName == null)
+            {
+                throw new ArgumentNullException(nameof(contractName));
+            }
+            if(contractName.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(contractName)), nameof(contractName));
+            }
             _contractName = contractName;
             return this;
         }
@@ -48,7 +55,10 @@ namespace System.Composition.Convention
         /// <returns>An export builder allowing further configuration.</returns>
         public ImportConventionBuilder AsContractName(Func<Type, string> getContractNameFromPartType)
         {
-            Requires.NotNull(getContractNameFromPartType, nameof(getContractNameFromPartType));
+            if (getContractNameFromPartType == null)
+            {
+                throw new ArgumentNullException(nameof(getContractNameFromPartType));
+            }
             _getContractNameFromPartType = getContractNameFromPartType;
             return this;
         }
@@ -92,7 +102,14 @@ namespace System.Composition.Convention
         /// <returns>An import builder allowing further configuration.</returns>
         public ImportConventionBuilder AddMetadataConstraint(string name, object value)
         {
-            Requires.NotNullOrEmpty(name, nameof(name));
+            if (name == null)
+            {
+                throw new ArgumentNullException(nameof(name));
+            }
+            if (name.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(name)), nameof(name));
+            }
             if (_metadataConstraintItems == null)
             {
                 _metadataConstraintItems = new List<Tuple<string, object>>();
@@ -109,8 +126,19 @@ namespace System.Composition.Convention
         /// <returns>An export builder allowing further configuration.</returns>
         public ImportConventionBuilder AddMetadataConstraint(string name, Func<Type, object> getConstraintValueFromPartType)
         {
-            Requires.NotNullOrEmpty(name, nameof(name));
-            Requires.NotNull(getConstraintValueFromPartType, nameof(getConstraintValueFromPartType));
+            if (name == null)
+            {
+                throw new ArgumentNullException(nameof(name));
+            }
+            if (name.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(name)), nameof(name));
+            }
+
+            if(getConstraintValueFromPartType == null)
+            {
+                throw new ArgumentNullException(nameof(getConstraintValueFromPartType));
+            }
 
             if (_metadataConstraintItemFuncs == null)
             {
index fdcafba..cefac65 100644 (file)
@@ -20,7 +20,7 @@ namespace System.Composition.Convention
     /// </summary>
     public class PartConventionBuilder
     {
-        private readonly Type[] _emptyTypeArray = EmptyArray<Type>.Value;
+        private readonly Type[] _emptyTypeArray = Array.Empty<Type>();
         private static List<Attribute> s_onImportsSatisfiedAttributeList;
         private static readonly List<Attribute> s_importingConstructorList = new List<Attribute>() { new ImportingConstructorAttribute() };
         private static readonly Type s_exportAttributeType = typeof(ExportAttribute);
@@ -74,7 +74,11 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder Export(Action<ExportConventionBuilder> exportConfiguration)
         {
-            Requires.NotNull(exportConfiguration, nameof(exportConfiguration));
+            if (exportConfiguration == null)
+            {
+                throw new ArgumentNullException(nameof(exportConfiguration));
+            }
+
             var exportBuilder = new ExportConventionBuilder();
             exportConfiguration(exportBuilder);
             _typeExportBuilders.Add(exportBuilder);
@@ -99,7 +103,11 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder Export<T>(Action<ExportConventionBuilder> exportConfiguration)
         {
-            Requires.NotNull(exportConfiguration, nameof(exportConfiguration));
+            if (exportConfiguration == null)
+            {
+                throw new ArgumentNullException(nameof(exportConfiguration));
+            }
+
             var exportBuilder = new ExportConventionBuilder().AsContractType<T>();
             exportConfiguration(exportBuilder);
             _typeExportBuilders.Add(exportBuilder);
@@ -113,7 +121,10 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder SelectConstructor(Func<IEnumerable<ConstructorInfo>, ConstructorInfo> constructorSelector)
         {
-            Requires.NotNull(constructorSelector, nameof(constructorSelector));
+            if (constructorSelector == null)
+            {
+                throw new ArgumentNullException(nameof(constructorSelector));
+            }
             _constructorFilter = constructorSelector;
             return this;
         }
@@ -128,7 +139,10 @@ namespace System.Composition.Convention
             Func<IEnumerable<ConstructorInfo>, ConstructorInfo> constructorSelector,
             Action<ParameterInfo, ImportConventionBuilder> importConfiguration)
         {
-            Requires.NotNull(importConfiguration, nameof(importConfiguration));
+            if (importConfiguration == null)
+            {
+                throw new ArgumentNullException(nameof(importConfiguration));
+            }
             SelectConstructor(constructorSelector);
             _configureConstuctorImports = importConfiguration;
             return this;
@@ -141,7 +155,11 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder ExportInterfaces(Predicate<Type> interfaceFilter)
         {
-            Requires.NotNull(interfaceFilter, nameof(interfaceFilter));
+            if (interfaceFilter == null)
+            {
+                throw new ArgumentNullException(nameof(interfaceFilter));
+            }
+
             return ExportInterfacesImpl(interfaceFilter, null);
         }
 
@@ -164,8 +182,16 @@ namespace System.Composition.Convention
             Predicate<Type> interfaceFilter,
             Action<Type, ExportConventionBuilder> exportConfiguration)
         {
-            Requires.NotNull(interfaceFilter, nameof(interfaceFilter));
-            Requires.NotNull(exportConfiguration, nameof(exportConfiguration));
+            if (interfaceFilter == null)
+            {
+                throw new ArgumentNullException(nameof(interfaceFilter));
+            }
+
+            if (exportConfiguration == null)
+            {
+                throw new ArgumentNullException(nameof(exportConfiguration));
+            }
+
             return ExportInterfacesImpl(interfaceFilter, exportConfiguration);
         }
 
@@ -184,7 +210,10 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder ExportProperties(Predicate<PropertyInfo> propertyFilter)
         {
-            Requires.NotNull(propertyFilter, nameof(propertyFilter));
+            if (propertyFilter == null)
+            {
+                throw new ArgumentNullException(nameof(propertyFilter));
+            }
 
             return ExportPropertiesImpl(propertyFilter, null);
         }
@@ -199,8 +228,16 @@ namespace System.Composition.Convention
             Predicate<PropertyInfo> propertyFilter,
             Action<PropertyInfo, ExportConventionBuilder> exportConfiguration)
         {
-            Requires.NotNull(propertyFilter, nameof(propertyFilter));
-            Requires.NotNull(exportConfiguration, nameof(exportConfiguration));
+            if (propertyFilter == null)
+            {
+                throw new ArgumentNullException(nameof(propertyFilter));
+            }
+
+            if (exportConfiguration == null)
+            {
+                throw new ArgumentNullException(nameof(exportConfiguration));
+            }
+
             return ExportPropertiesImpl(propertyFilter, exportConfiguration);
         }
 
@@ -220,7 +257,10 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder ExportProperties<T>(Predicate<PropertyInfo> propertyFilter)
         {
-            Requires.NotNull(propertyFilter, nameof(propertyFilter));
+            if (propertyFilter == null)
+            {
+                throw new ArgumentNullException(nameof(propertyFilter));
+            }
 
             return ExportPropertiesImpl<T>(propertyFilter, null);
         }
@@ -236,8 +276,15 @@ namespace System.Composition.Convention
             Predicate<PropertyInfo> propertyFilter,
             Action<PropertyInfo, ExportConventionBuilder> exportConfiguration)
         {
-            Requires.NotNull(propertyFilter, nameof(propertyFilter));
-            Requires.NotNull(exportConfiguration, nameof(exportConfiguration));
+            if (propertyFilter == null)
+            {
+                throw new ArgumentNullException(nameof(propertyFilter));
+            }
+
+            if (exportConfiguration == null)
+            {
+                throw new ArgumentNullException(nameof(exportConfiguration));
+            }
 
             return ExportPropertiesImpl<T>(propertyFilter, exportConfiguration);
         }
@@ -257,7 +304,10 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder ImportProperties(Predicate<PropertyInfo> propertyFilter)
         {
-            Requires.NotNull(propertyFilter, nameof(propertyFilter));
+            if (propertyFilter == null)
+            {
+                throw new ArgumentNullException(nameof(propertyFilter));
+            }
 
             return ImportPropertiesImpl(propertyFilter, null);
         }
@@ -272,8 +322,15 @@ namespace System.Composition.Convention
             Predicate<PropertyInfo> propertyFilter,
             Action<PropertyInfo, ImportConventionBuilder> importConfiguration)
         {
-            Requires.NotNull(propertyFilter, nameof(propertyFilter));
-            Requires.NotNull(importConfiguration, nameof(importConfiguration));
+            if (propertyFilter == null)
+            {
+                throw new ArgumentNullException(nameof(propertyFilter));
+            }
+
+            if (importConfiguration == null)
+            {
+                throw new ArgumentNullException(nameof(importConfiguration));
+            }
 
             return ImportPropertiesImpl(propertyFilter, importConfiguration);
         }
@@ -294,7 +351,10 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder ImportProperties<T>(Predicate<PropertyInfo> propertyFilter)
         {
-            Requires.NotNull(propertyFilter, nameof(propertyFilter));
+            if (propertyFilter == null)
+            {
+                throw new ArgumentNullException(nameof(propertyFilter));
+            }
 
             return ImportPropertiesImpl<T>(propertyFilter, null);
         }
@@ -310,8 +370,15 @@ namespace System.Composition.Convention
             Predicate<PropertyInfo> propertyFilter,
             Action<PropertyInfo, ImportConventionBuilder> importConfiguration)
         {
-            Requires.NotNull(propertyFilter, nameof(propertyFilter));
-            Requires.NotNull(importConfiguration, nameof(importConfiguration));
+            if (propertyFilter == null)
+            {
+                throw new ArgumentNullException(nameof(propertyFilter));
+            }
+
+            if (importConfiguration == null)
+            {
+                throw new ArgumentNullException(nameof(importConfiguration));
+            }
 
             return ImportPropertiesImpl<T>(propertyFilter, importConfiguration);
         }
@@ -351,7 +418,16 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder Shared(string sharingBoundary)
         {
-            Requires.NotNullOrEmpty(sharingBoundary, nameof(sharingBoundary));
+            if (sharingBoundary == null)
+            {
+                throw new ArgumentNullException(nameof(sharingBoundary));
+            }
+
+            if(sharingBoundary.Length == 0)
+            {
+                throw new ArgumentException(SR.ArgumentException_EmptyString);
+            }
+
             return SharedImpl(sharingBoundary);
         }
 
@@ -370,7 +446,14 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder AddPartMetadata(string name, object value)
         {
-            Requires.NotNullOrEmpty(name, nameof(name));
+            if (name == null)
+            {
+                throw new ArgumentNullException(nameof(name));
+            }
+            if (name.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(name)), nameof(name));
+            }
 
             if (_metadataItems == null)
             {
@@ -388,8 +471,19 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder AddPartMetadata(string name, Func<Type, object> getValueFromPartType)
         {
-            Requires.NotNullOrEmpty(name, nameof(name));
-            Requires.NotNull(getValueFromPartType, nameof(getValueFromPartType));
+            if (name == null)
+            {
+                throw new ArgumentNullException(nameof(name));
+            }
+            if (name.Length == 0)
+            {
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, nameof(name)), nameof(name));
+            }
+
+            if (getValueFromPartType == null)
+            {
+                throw new ArgumentNullException(nameof(getValueFromPartType));
+            }
 
             if (_metadataItemFuncs == null)
             {
index ccf32bd..28e6eb5 100644 (file)
@@ -35,7 +35,10 @@ namespace System.Composition.Convention
 
             private static MethodInfo SelectMethods(Expression<Action<T>> methodSelector)
             {
-                Requires.NotNull(methodSelector, nameof(methodSelector));
+                if (methodSelector == null)
+                {
+                    throw new ArgumentNullException(nameof(methodSelector));
+                }
 
                 var expr = Reduce(methodSelector).Body;
                 if (expr.NodeType == ExpressionType.Call)
@@ -109,7 +112,10 @@ namespace System.Composition.Convention
 
             private static PropertyInfo SelectProperties(Expression<Func<T, object>> propertySelector)
             {
-                Requires.NotNull(propertySelector, nameof(propertySelector));
+                if (propertySelector == null)
+                {
+                    throw new ArgumentNullException(nameof(propertySelector));
+                }
 
                 var expr = Reduce(propertySelector).Body;
                 if (expr.NodeType == ExpressionType.MemberAccess)
@@ -166,7 +172,10 @@ namespace System.Composition.Convention
 
             private void ParseSelectConstructor(Expression<Func<ParameterImportConventionBuilder, T>> constructorSelector)
             {
-                Requires.NotNull(constructorSelector, nameof(constructorSelector));
+                if (constructorSelector == null)
+                {
+                    throw new ArgumentNullException(nameof(constructorSelector));
+                }
 
                 var expr = Reduce(constructorSelector).Body;
                 if (expr.NodeType != ExpressionType.New)
@@ -224,7 +233,10 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder<T> SelectConstructor(Expression<Func<ParameterImportConventionBuilder, T>> constructorSelector)
         {
-            Requires.NotNull(constructorSelector, nameof(constructorSelector));
+            if (constructorSelector == null)
+            {
+                throw new ArgumentNullException(nameof(constructorSelector));
+            }
 
             var adapter = new ConstructorExpressionAdapter(constructorSelector);
             base.SelectConstructor(adapter.SelectConstructor, adapter.ConfigureConstructorImports);
@@ -251,7 +263,10 @@ namespace System.Composition.Convention
             Expression<Func<T, object>> propertySelector,
             Action<ExportConventionBuilder> exportConfiguration)
         {
-            Requires.NotNull(propertySelector, nameof(propertySelector));
+            if (propertySelector == null)
+            {
+                throw new ArgumentNullException(nameof(propertySelector));
+            }
 
             var adapter = new PropertyExpressionAdapter(propertySelector, null, exportConfiguration);
             base.ExportProperties(adapter.VerifyPropertyInfo, adapter.ConfigureExport);
@@ -281,7 +296,10 @@ namespace System.Composition.Convention
             Expression<Func<T, object>> propertySelector,
             Action<ExportConventionBuilder> exportConfiguration)
         {
-            Requires.NotNull(propertySelector, nameof(propertySelector));
+            if (propertySelector == null)
+            {
+                throw new ArgumentNullException(nameof(propertySelector));
+            }
 
             var adapter = new PropertyExpressionAdapter(propertySelector, null, exportConfiguration);
             base.ExportProperties<TContract>(adapter.VerifyPropertyInfo, adapter.ConfigureExport);
@@ -308,7 +326,10 @@ namespace System.Composition.Convention
             Expression<Func<T, object>> propertySelector,
             Action<ImportConventionBuilder> importConfiguration)
         {
-            Requires.NotNull(propertySelector, nameof(propertySelector));
+            if (propertySelector == null)
+            {
+                throw new ArgumentNullException(nameof(propertySelector));
+            }
 
             var adapter = new PropertyExpressionAdapter(propertySelector, importConfiguration, null);
             base.ImportProperties(adapter.VerifyPropertyInfo, adapter.ConfigureImport);
@@ -337,7 +358,10 @@ namespace System.Composition.Convention
             Expression<Func<T, object>> propertySelector,
             Action<ImportConventionBuilder> importConfiguration)
         {
-            Requires.NotNull(propertySelector, nameof(propertySelector));
+            if (propertySelector == null)
+            {
+                throw new ArgumentNullException(nameof(propertySelector));
+            }
 
             var adapter = new PropertyExpressionAdapter(propertySelector, importConfiguration, null);
             base.ImportProperties<TContract>(adapter.VerifyPropertyInfo, adapter.ConfigureImport);
@@ -350,7 +374,10 @@ namespace System.Composition.Convention
         /// <returns>A part builder allowing further configuration of the part.</returns>
         public PartConventionBuilder<T> NotifyImportsSatisfied(Expression<Action<T>> methodSelector)
         {
-            Requires.NotNull(methodSelector, nameof(methodSelector));
+            if (methodSelector == null)
+            {
+                throw new ArgumentNullException(nameof(methodSelector));
+            }
 
             var adapter = new MethodExpressionAdapter(methodSelector);
             base.NotifyImportsSatisfied(adapter.VerifyMethodInfo);
index 73b5611..f9f407c 100644 (file)
@@ -25,7 +25,10 @@ namespace System.Composition
 
         private static ArgumentException CreateArgumentException(string message, string parameterName)
         {
-            Assumes.NotNull(parameterName);
+            if (parameterName == null)
+            {
+                throw new ArgumentNullException(nameof(parameterName));
+            }
 
             return new ArgumentException(SR.Format(message, parameterName), parameterName);
         }
index 02af30d..023c3bb 100644 (file)
   <data name="Formatter_ListSeparatorWithSpace" xml:space="preserve">
     <value>, </value>
   </data>
-</root>
\ No newline at end of file
+  <data name="Dependency_Not_In_Error_State" xml:space="preserve">
+    <value>Dependency is not in an error state.</value>
+  </data>
+  <data name="Sharing_Lock_Required" xml:space="preserve">
+    <value>Sharing lock is required</value>
+  </data>
+  <data name="Sharing_Lock_Taken" xml:space="preserve">
+    <value>Sharing lock already taken in this operation.</value>
+  </data>
+  <data name="Dependencies_Should_Be_Requested_Earlier" xml:space="preserve">
+    <value>Update is finished - dependencies should have been requested earlier.</value>
+  </data>
+  <data name="Key_Already_Exist" xml:space="preserve">
+    <value>An item with the key '{0}' has already been added.</value>
+  </data>
+  <data name="Providers_Remain_To_Be_Queried" xml:space="preserve">
+    <value>Providers remain to be queried.</value>
+  </data>
+  <data name="Diagnostic_InternalExceptionMessage" xml:space="preserve">
+    <value>Internal error occurred. Additional information: '{0}'.</value>
+  </data>
+</root>
index 0f9a8f7..9a77627 100644 (file)
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\Assumes.cs">
-      <Link>Microsoft\Internal\Assumes.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\Assumes.InternalErrorException.cs">
-      <Link>Microsoft\Internal\Assumes.InternalErrorException.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\CommonStrings.Designer.cs">
-      <Link>Microsoft\Internal\CommonStrings.Designer.cs</Link>
-      <AutoGen>True</AutoGen>
-      <DesignTime>True</DesignTime>
-      <DependentUpon>CommonStrings.resx</DependentUpon>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\EmptyArray.cs">
-      <Link>Microsoft\Internal\EmptyArray.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\Microsoft\Internal\Requires.cs">
-      <Link>Microsoft\Internal\Requires.cs</Link>
-    </Compile>
     <Compile Include="Microsoft\Internal\ThrowHelper.cs" />
     <Compile Include="System\Composition\Hosting\CompositionHost.cs" />
     <Compile Include="System\Composition\Hosting\Core\CompositeActivator.cs" />
     <Compile Include="System\Composition\Hosting\Util\MethodInfoExtensions.cs" />
     <Compile Include="System\Composition\Hosting\Util\SmallSparseInitonlyArray.cs" />
   </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="$(CommonPath)\Microsoft\Internal\CommonStrings.resx">
-      <Link>Microsoft\Internal\CommonStrings.resx</Link>
-      <Generator>ResXFileCodeGenerator</Generator>
-      <LastGenOutput>CommonStrings.Designer.cs</LastGenOutput>
-      <CustomToolNamespace>Microsoft.Internal</CustomToolNamespace>
-    </EmbeddedResource>
-  </ItemGroup>
   <ItemGroup Condition="'$(TargetGroup)' == 'netstandard1.0'">
     <Reference Include="System.Collections" />
     <Reference Include="System.Diagnostics.Contracts" />
@@ -88,4 +62,4 @@
     <Reference Include="System.Threading" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-</Project>
\ No newline at end of file
+</Project>
index d4cf251..51dbb56 100644 (file)
@@ -20,13 +20,16 @@ namespace System.Composition.Hosting
     /// </summary>
     public sealed class CompositionHost : CompositionContext, IDisposable
     {
-        private static readonly string[] s_noBoundaries = EmptyArray<string>.Value;
+        private static readonly string[] s_noBoundaries = Array.Empty<string>();
 
         private readonly LifetimeContext _rootLifetimeContext;
 
         private CompositionHost(LifetimeContext rootLifetimeContext)
         {
-            Requires.NotNull(rootLifetimeContext, nameof(rootLifetimeContext));
+            if(rootLifetimeContext == null)
+            {
+                throw new ArgumentNullException(nameof(rootLifetimeContext));
+            }
 
             _rootLifetimeContext = rootLifetimeContext;
         }
@@ -46,7 +49,10 @@ namespace System.Composition.Hosting
         /// <returns>The container as an <see cref="CompositionHost"/>.</returns>
         public static CompositionHost CreateCompositionHost(IEnumerable<ExportDescriptorProvider> providers)
         {
-            Requires.NotNull(providers, nameof(providers));
+            if (providers == null)
+            {
+                throw new ArgumentNullException(nameof(providers));
+            }
 
             var allProviders = new ExportDescriptorProvider[] {
                 new LazyExportDescriptorProvider(),
index f5bc71e..46a23ee 100644 (file)
@@ -6,7 +6,6 @@ using System.Collections.Generic;
 using System.Composition.Hosting.Util;
 using System.Linq;
 using System.Text;
-using Microsoft.Internal;
 
 namespace System.Composition.Hosting.Core
 {
@@ -40,9 +39,20 @@ namespace System.Composition.Hosting.Core
         /// <param name="contract">The contract required by the dependency.</param>
         public static CompositionDependency Satisfied(CompositionContract contract, ExportDescriptorPromise target, bool isPrerequisite, object site)
         {
-            Requires.NotNull(target, nameof(target));
-            Requires.NotNull(site, nameof(site));
-            Requires.NotNull(contract, nameof(contract));
+            if (contract == null)
+            {
+                throw new ArgumentNullException(nameof(contract));
+            }
+
+            if (target == null)
+            {
+                throw new ArgumentNullException(nameof(target));
+            }
+
+            if (site == null)
+            {
+                throw new ArgumentNullException(nameof(site));
+            }
 
             return new CompositionDependency(contract, target, isPrerequisite, site);
         }
@@ -56,8 +66,15 @@ namespace System.Composition.Hosting.Core
         /// <param name="contract">The contract required by the dependency.</param>
         public static CompositionDependency Missing(CompositionContract contract, object site)
         {
-            Requires.NotNull(contract, nameof(contract));
-            Requires.NotNull(site, nameof(site));
+            if (contract == null)
+            {
+                throw new ArgumentNullException(nameof(contract));
+            }
+
+            if (site == null)
+            {
+                throw new ArgumentNullException(nameof(site));
+            }
 
             return new CompositionDependency(contract, site);
         }
@@ -72,9 +89,20 @@ namespace System.Composition.Hosting.Core
         /// <param name="contract">The contract required by the dependency.</param>
         public static CompositionDependency Oversupplied(CompositionContract contract, IEnumerable<ExportDescriptorPromise> targets, object site)
         {
-            Requires.NotNull(targets, nameof(targets));
-            Requires.NotNull(site, nameof(site));
-            Requires.NotNull(contract, nameof(contract));
+            if (contract == null)
+            {
+                throw new ArgumentNullException(nameof(contract));
+            }
+
+            if (targets == null)
+            {
+                throw new ArgumentNullException(nameof(targets));
+            }
+
+            if (site == null)
+            {
+                throw new ArgumentNullException(nameof(site));
+            }
 
             return new CompositionDependency(contract, targets, site);
         }
@@ -140,7 +168,10 @@ namespace System.Composition.Hosting.Core
 
         internal void DescribeError(StringBuilder message)
         {
-            Assumes.IsTrue(IsError, "Dependency is not in an error state.");
+            if(!IsError)
+            {
+                throw new Exception(SR.Dependency_Not_In_Error_State);
+            }
 
             if (_oversuppliedTargets != null)
             {
index 364ec3f..280ed39 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Threading;
-using Microsoft.Internal;
 
 namespace System.Composition.Hosting.Core
 {
@@ -31,8 +30,15 @@ namespace System.Composition.Hosting.Core
         /// <returns>The composed object graph.</returns>
         public static object Run(LifetimeContext outermostLifetimeContext, CompositeActivator compositionRootActivator)
         {
-            Requires.NotNull(outermostLifetimeContext, nameof(outermostLifetimeContext));
-            Requires.NotNull(compositionRootActivator, nameof(compositionRootActivator));
+            if (outermostLifetimeContext == null)
+            {
+                throw new ArgumentNullException(nameof(outermostLifetimeContext));
+            }
+
+            if (compositionRootActivator == null)
+            {
+                throw new ArgumentNullException(nameof(compositionRootActivator));
+            }
 
             using (var operation = new CompositionOperation())
             {
@@ -65,7 +71,10 @@ namespace System.Composition.Hosting.Core
         /// <param name="action">Action to run.</param>
         public void AddPostCompositionAction(Action action)
         {
-            Requires.NotNull(action, nameof(action));
+            if (action == null)
+            {
+                throw new ArgumentNullException(nameof(action));
+            }
 
             if (_postCompositionActions == null)
                 _postCompositionActions = new List<Action>();
@@ -75,7 +84,10 @@ namespace System.Composition.Hosting.Core
 
         internal void EnterSharingLock(object sharingLock)
         {
-            Assumes.NotNull(sharingLock, "Sharing lock is required");
+            if (sharingLock == null)
+            {
+                throw new ArgumentException(SR.Sharing_Lock_Required);
+            }
 
             if (_sharingLock == null)
             {
@@ -83,7 +95,10 @@ namespace System.Composition.Hosting.Core
                 Monitor.Enter(sharingLock);
             }
 
-            Assumes.IsTrue(_sharingLock == sharingLock, "Sharing lock already taken in this operation.");
+            if (_sharingLock != sharingLock)
+            {
+                throw new Exception(SR.Sharing_Lock_Taken);
+            }
         }
 
         private void Complete()
index 3f39772..2da9302 100644 (file)
@@ -14,9 +14,14 @@ namespace System.Composition.Hosting.Core
 
         public DirectExportDescriptor(CompositeActivator activator, IDictionary<string, object> metadata)
         {
-            Requires.NotNull(activator, nameof(activator));
-            Requires.NotNull(metadata, nameof(metadata));
-
+            if (activator == null)
+            {
+                throw new ArgumentNullException(nameof(activator));
+            }
+            if (metadata == null)
+            {
+                throw new ArgumentNullException(nameof(metadata));
+            }
             _activator = activator;
             _metadata = metadata;
         }
index 77ee542..0d15ce9 100644 (file)
@@ -84,7 +84,10 @@ namespace System.Composition.Hosting.Core
             try
             {
                 ExportDescriptor relay = _descriptor.Value;
-                Requires.NotNull(relay, "descriptor");
+                if(relay == null)
+                {
+                    throw new ArgumentNullException("descriptor");
+                }
                 return relay;
             }
             finally
index ce33688..0615763 100644 (file)
@@ -15,7 +15,7 @@ namespace System.Composition.Hosting.Core
         private readonly ExportDescriptorProvider[] _exportDescriptorProviders;
         private readonly IDictionary<CompositionContract, UpdateResult> _updateResults = new Dictionary<CompositionContract, UpdateResult>();
 
-        private static readonly CompositionDependency[] s_noDependenciesValue = EmptyArray<CompositionDependency>.Value;
+        private static readonly CompositionDependency[] s_noDependenciesValue = Array.Empty<CompositionDependency>();
         private static readonly Func<CompositionDependency[]> s_noDependencies = () => s_noDependenciesValue;
 
         private bool _updateFinished;
@@ -128,8 +128,10 @@ namespace System.Composition.Hosting.Core
 
         protected override IEnumerable<ExportDescriptorPromise> GetPromises(CompositionContract contract)
         {
-            Assumes.IsTrue(!_updateFinished, "Update is finished - dependencies should have been requested earlier.");
-
+            if (_updateFinished)
+            {
+                throw new Exception(SR.Dependencies_Should_Be_Requested_Earlier);
+            }
             ExportDescriptor[] definitions;
             if (_partDefinitions.TryGetValue(contract, out definitions))
                 return definitions.Select(d => new ExportDescriptorPromise(contract, "Preexisting", false, s_noDependencies, _ => d)).ToArray();
index 0ebc57d..879a77e 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Linq;
-using Microsoft.Internal;
 
 namespace System.Composition.Hosting.Core
 {
@@ -13,7 +12,7 @@ namespace System.Composition.Hosting.Core
     // providers, with providers being removed from the list before querying.
     internal class UpdateResult
     {
-        private static readonly ExportDescriptorPromise[] s_noPromises = EmptyArray<ExportDescriptorPromise>.Value;
+        private static readonly ExportDescriptorPromise[] s_noPromises = Array.Empty<ExportDescriptorPromise>();
 
         private readonly Queue<ExportDescriptorProvider> _remainingProviders;
         private readonly IList<ExportDescriptorPromise> _providedDescriptors = new List<ExportDescriptorPromise>();
@@ -46,7 +45,10 @@ namespace System.Composition.Hosting.Core
         {
             if (_results == null)
             {
-                Assumes.IsTrue(_remainingProviders.Count == 0, "Providers remain to be queried.");
+                if(_remainingProviders.Count != 0)
+                {
+                    throw new Exception(SR.Providers_Remain_To_Be_Queried);
+                }
 
                 if (_providedDescriptors.Count == 0)
                     _results = s_noPromises;
index 8c88cf5..2967a5a 100644 (file)
@@ -28,14 +28,14 @@ namespace System.Composition.Hosting.Providers.ExportFactory
         private static ExportDescriptorPromise[] GetExportFactoryDescriptors<TProduct>(CompositionContract exportFactoryContract, DependencyAccessor definitionAccessor)
         {
             var productContract = exportFactoryContract.ChangeType(typeof(TProduct));
-            var boundaries = EmptyArray<string>.Value;
+            var boundaries = Array.Empty<string>();
 
             IEnumerable<string> specifiedBoundaries;
             CompositionContract unwrapped;
             if (exportFactoryContract.TryUnwrapMetadataConstraint(Constants.SharingBoundaryImportMetadataConstraintName, out specifiedBoundaries, out unwrapped))
             {
                 productContract = unwrapped.ChangeType(typeof(TProduct));
-                boundaries = (specifiedBoundaries ?? EmptyArray<string>.Value).ToArray();
+                boundaries = (specifiedBoundaries ?? Array.Empty<string>()).ToArray();
             }
 
             return definitionAccessor.ResolveDependencies("product", productContract, false)
index c6960aa..52815e2 100644 (file)
@@ -31,14 +31,14 @@ namespace System.Composition.Hosting.Providers.ExportFactory
         private static ExportDescriptorPromise[] GetExportFactoryDescriptors<TProduct, TMetadata>(CompositionContract exportFactoryContract, DependencyAccessor definitionAccessor)
         {
             var productContract = exportFactoryContract.ChangeType(typeof(TProduct));
-            var boundaries = EmptyArray<string>.Value;
+            var boundaries = Array.Empty<string>();
 
             IEnumerable<string> specifiedBoundaries;
             CompositionContract unwrapped;
             if (exportFactoryContract.TryUnwrapMetadataConstraint(Constants.SharingBoundaryImportMetadataConstraintName, out specifiedBoundaries, out unwrapped))
             {
                 productContract = unwrapped.ChangeType(typeof(TProduct));
-                boundaries = (specifiedBoundaries ?? EmptyArray<string>.Value).ToArray();
+                boundaries = (specifiedBoundaries ?? Array.Empty<string>()).ToArray();
             }
 
             var metadataProvider = MetadataViewProvider.GetMetadataViewProvider<TMetadata>();
index 604bf5e..ad934f6 100644 (file)
@@ -4,7 +4,6 @@
 
 using System.Collections.Generic;
 using System.Linq;
-using Microsoft.Internal;
 
 namespace System.Composition.Hosting.Util
 {
@@ -12,7 +11,10 @@ namespace System.Composition.Hosting.Util
     {
         public static string ReadableList(IEnumerable<string> items)
         {
-            Assumes.NotNull(items);
+            if (items == null)
+            {
+                throw new ArgumentNullException(nameof(items));
+            }
 
             string reply = string.Join(SR.Formatter_ListSeparatorWithSpace, items.OrderBy(t => t));
             return !string.IsNullOrEmpty(reply) ? reply : SR.Formatter_None;
@@ -20,7 +22,10 @@ namespace System.Composition.Hosting.Util
 
         public static string Format(Type type)
         {
-            Assumes.NotNull(type);
+            if (type == null)
+            {
+                throw new ArgumentNullException(nameof(type));
+            }
 
             if (type.IsConstructedGenericType)
             {
@@ -31,8 +36,15 @@ namespace System.Composition.Hosting.Util
 
         private static string FormatClosedGeneric(Type closedGenericType)
         {
-            Assumes.NotNull(closedGenericType);
-            Assumes.IsTrue(closedGenericType.IsConstructedGenericType);
+            if (closedGenericType == null)
+            {
+                throw new ArgumentNullException(nameof(closedGenericType));
+            }
+
+            if (!closedGenericType.IsConstructedGenericType)
+            {
+                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
+            }
 
             var name = closedGenericType.Name.Substring(0, closedGenericType.Name.IndexOf("`"));
             var args = closedGenericType.GenericTypeArguments.Select(t => Format(t));
index 2ba8e60..1dfc024 100644 (file)
@@ -2,8 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using Microsoft.Internal;
-
 namespace System.Composition.Hosting.Util
 {
     // Extremely performance-sensitive.
@@ -35,9 +33,10 @@ namespace System.Composition.Hosting.Util
                 return;
             }
 
-            // This overload of IsTrue doesn't call String.Format unless required.
-            // Do, not switch to other version as it affects performance.
-            Assumes.IsTrue(e.Index != index, "An item with the key '{0}' has already been added.", index);
+            if(e.Index == index)
+            {
+                throw new ArgumentException(SR.Format(SR.Key_Already_Exist, index), nameof(index));
+            }
 
             for (int offset = 1; offset <= LocalOffsetMax; ++offset)
             {
@@ -49,7 +48,10 @@ namespace System.Composition.Hosting.Util
                     return;
                 }
 
-                Assumes.IsTrue(e.Index != index, "An item with the key '{0}' has already been added.", index);
+                if (e.Index == index)
+                {
+                    throw new ArgumentException(SR.Format(SR.Key_Already_Exist, index), nameof(index));
+                }
             }
 
             if (_overflow == null)
index d7095e9..e3ff3a5 100644 (file)
@@ -30,9 +30,6 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="..\..\Common\src\Microsoft\Internal\EmptyArray.cs">
-      <Link>Microsoft\Internal\EmptyArray.cs</Link>
-    </Compile>
     <Compile Include="System\Composition\CompositionContextExtensions.cs" />
     <Compile Include="System\Composition\Convention\AttributedModelProviderExtensions.cs" />
     <Compile Include="System\Composition\Debugging\ContainerConfigurationDebuggerProxy.cs" />
@@ -72,4 +69,4 @@
     <Reference Include="System.Runtime.Extensions" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-</Project>
\ No newline at end of file
+</Project>
index 5ec4d56..980f2f8 100644 (file)
@@ -17,7 +17,7 @@ namespace System.Composition.TypedParts.ActivationFeatures
         /// <summary>
         /// A constant shared for subclass use.
         /// </summary>
-        protected static readonly CompositionDependency[] NoDependencies = EmptyArray<CompositionDependency>.Value;
+        protected static readonly CompositionDependency[] NoDependencies = Array.Empty<CompositionDependency>();
 
         /// <summary>
         /// Participate in the activator creation process.
index 3345256..5dab73a 100644 (file)
@@ -17,7 +17,7 @@ namespace System.Composition.TypedParts.Util
             if (member == null) throw new ArgumentNullException(nameof(member));
 
             if (!(member is TypeInfo) && member.DeclaringType != reflectedType)
-                return EmptyArray<Attribute>.Value;
+                return Array.Empty<Attribute>();
 #if netstandard10
             return member.GetCustomAttributes(false);
 #else