Fixes for extra path separators
authorVitek Karas <vitek.karas@microsoft.com>
Thu, 4 Apr 2019 10:37:46 +0000 (03:37 -0700)
committerVitek Karas <vitek.karas@microsoft.com>
Thu, 4 Apr 2019 10:37:46 +0000 (03:37 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/6ba1ba9183efd0bf44e46bbb86bab96604a019c6

src/coreclr/src/System.Private.CoreLib/Resources/Strings.resx
src/coreclr/src/System.Private.CoreLib/src/System/StartupHookProvider.cs

index a653c63..0ca283f 100644 (file)
   <data name="Argument_InvalidSerializedString" xml:space="preserve">
     <value>The specified serialized string '{0}' is not supported.</value>
   </data>
-  <data name="Argument_InvalidStartupHookSyntax" xml:space="preserve">
-    <value>The syntax of the startup hook variable was invalid.</value>
-  </data>
   <data name="Argument_InvalidStartupHookSignature" xml:space="preserve">
     <value>The signature of the startup hook '{0}' in assembly '{1}' was invalid. It must be 'public static void Initialize()'.</value>
   </data>
index 393671c..051b379 100644 (file)
@@ -50,6 +50,7 @@ namespace System
                 string startupHookPart = startupHookParts[i];
                 if (string.IsNullOrEmpty(startupHookPart))
                 {
+                    // Leave the slot in startupHooks empty (nulls for everything). This is simpler than shifting and resizing the array.
                     continue;
                 }
 
@@ -98,8 +99,6 @@ namespace System
         // "static void Initialize()" method.
         private static void CallStartupHook(StartupHookNameOrPath startupHook)
         {
-            Debug.Assert(startupHook.Path != null || startupHook.AssemblyName != null);
-
             Assembly assembly;
             try
             {
@@ -108,11 +107,16 @@ namespace System
                     Debug.Assert(Path.IsPathFullyQualified(startupHook.Path));
                     assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(startupHook.Path);
                 }
-                else
+                else if (startupHook.AssemblyName != null)
                 {
                     Debug.Assert(startupHook.AssemblyName != null);
                     assembly = AssemblyLoadContext.Default.LoadFromAssemblyName(startupHook.AssemblyName);
                 }
+                else
+                {
+                    // Empty slot - skip it
+                    return;
+                }
             }
             catch (Exception assemblyLoadException)
             {