Make sure we specify arguments only when the test ask for it (#80947)
authorAndrew Au <andrewau@microsoft.com>
Fri, 27 Jan 2023 20:10:51 +0000 (12:10 -0800)
committerGitHub <noreply@github.com>
Fri, 27 Jan 2023 20:10:51 +0000 (12:10 -0800)
src/tests/GC/Stress/Framework/ReliabilityFramework.cs
src/tests/GC/Stress/Framework/ReliabilityTest.cs

index 1b6e214..3eb6d36 100644 (file)
@@ -992,7 +992,12 @@ public class ReliabilityFramework
 
                         try
                         {
-                            daTest.EntryPointMethod.Invoke(null, new object[] { (daTest.Arguments == null) ? new string[0] : daTest.GetSplitArguments() });
+                            object[] parameters = null;
+                            if (daTest.EntryPointMethod.GetParameters().Length == 1)
+                            {
+                                parameters = new object[] { (daTest.Arguments == null) ? new string[0] : daTest.GetSplitArguments() };
+                            }
+                            daTest.EntryPointMethod.Invoke(null, parameters);
                         }
                         catch (Exception e)
                         {
index 4ef123c..0efc1ec 100644 (file)
@@ -48,7 +48,11 @@ public class TestAssemblyLoadContext : AssemblyLoadContext
     public int ExecuteAssembly(string path, string[] args)
     {
         Assembly assembly = LoadFromAssemblyPath(Path.Combine(_applicationBase, path));
-        object[] actualArgs = new object[] { args != null ? args : new string[0] };
+        object[] actualArgs = null;
+        if (assembly.EntryPoint.GetParameters().Length == 1)
+        {
+            actualArgs = new object[] { args != null ? args : new string[0] };
+        }
         return (int)assembly.EntryPoint.Invoke(null, actualArgs);
     }