Remove dead code from Composition.Hosting (dotnet/corefx#35131)
authorHugh Bellamy <hughbellars@gmail.com>
Thu, 7 Feb 2019 02:14:53 +0000 (02:14 +0000)
committerStephen Toub <stoub@microsoft.com>
Thu, 7 Feb 2019 02:14:53 +0000 (21:14 -0500)
Commit migrated from https://github.com/dotnet/corefx/commit/4d180567e9dc5500006b58480184f0dcfe967c1e

src/libraries/System.Composition.Hosting/src/Resources/Strings.resx
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/Providers/Metadata/MetadataViewProvider.cs

index 023c3bb..9fc699a 100644 (file)
   <data name="Formatter_ListSeparatorWithSpace" xml:space="preserve">
     <value>, </value>
   </data>
-  <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>
index 6661454..4b850b2 100644 (file)
@@ -8,6 +8,7 @@ using System.Composition.Hosting.Providers.CurrentScope;
 using System.Composition.Hosting.Providers.ExportFactory;
 using System.Composition.Hosting.Providers.ImportMany;
 using System.Composition.Hosting.Providers.Lazy;
+using System.Diagnostics;
 using System.Linq;
 
 namespace System.Composition.Hosting
@@ -24,11 +25,7 @@ namespace System.Composition.Hosting
 
         private CompositionHost(LifetimeContext rootLifetimeContext)
         {
-            if(rootLifetimeContext == null)
-            {
-                throw new ArgumentNullException(nameof(rootLifetimeContext));
-            }
-
+            Debug.Assert(rootLifetimeContext != null);
             _rootLifetimeContext = rootLifetimeContext;
         }
 
index 46a23ee..389d639 100644 (file)
@@ -4,6 +4,7 @@
 
 using System.Collections.Generic;
 using System.Composition.Hosting.Util;
+using System.Diagnostics;
 using System.Linq;
 using System.Text;
 
@@ -168,10 +169,7 @@ namespace System.Composition.Hosting.Core
 
         internal void DescribeError(StringBuilder message)
         {
-            if(!IsError)
-            {
-                throw new Exception(SR.Dependency_Not_In_Error_State);
-            }
+            Debug.Assert(IsError, "Should be in error state.");
 
             if (_oversuppliedTargets != null)
             {
index 280ed39..4be3456 100644 (file)
@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Threading;
 
 namespace System.Composition.Hosting.Core
@@ -84,10 +85,7 @@ namespace System.Composition.Hosting.Core
 
         internal void EnterSharingLock(object sharingLock)
         {
-            if (sharingLock == null)
-            {
-                throw new ArgumentException(SR.Sharing_Lock_Required);
-            }
+            Debug.Assert(sharingLock != null, "Expected a sharing lock to be passed.");
 
             if (_sharingLock == null)
             {
index 7a88f28..3439ea5 100644 (file)
@@ -13,7 +13,7 @@ namespace System.Composition.Hosting.Providers.Metadata
 {
     internal static class MetadataViewProvider
     {
-        private static readonly MethodInfo s_getMetadataValueMethod = typeof(MetadataViewProvider).GetTypeInfo().GetDeclaredMethod("GetMetadataValue");
+        private static readonly MethodInfo s_getMetadataValueMethod = typeof(MetadataViewProvider).GetTypeInfo().GetDeclaredMethod(nameof(GetMetadataValue));
 
         // While not called through the composition pipeline, we use the dependency mechanism to surface errors
         // with appropriate context information.