Skip to content

Commit

Permalink
Avoid converting from IEnumerable to IList
Browse files Browse the repository at this point in the history
Casting is wrong and can throw exception.

mono/mono#14729
  • Loading branch information
BrzVlad committed Jun 6, 2019
1 parent 55c4073 commit 992c539
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/bcl-test/templates/common/TestRunner.Core/TestRunner.cs
Expand Up @@ -30,7 +30,7 @@ protected TestRunner (LogWriter logger)
Logger = logger ?? throw new ArgumentNullException (nameof (logger));
}

public abstract void Run (IList <TestAssemblyInfo> testAssemblies);
public abstract void Run (IEnumerable<TestAssemblyInfo> testAssemblies);
public abstract string WriteResultsToFile ();
public abstract void WriteResultsToFile (TextWriter writer);
public abstract void SkipTests (IEnumerable<string> tests);
Expand Down Expand Up @@ -102,4 +102,4 @@ protected virtual string GetResultsFilePath ()
return Path.Combine (resultsPath, ResultsFileName);
}
}
}
}
Expand Up @@ -35,7 +35,7 @@ public NUnitTestRunner (LogWriter logger) : base (logger)
builderSettings = new Dictionary<string, object> (StringComparer.OrdinalIgnoreCase);
}

public override void Run (IList<TestAssemblyInfo> testAssemblies)
public override void Run (IEnumerable<TestAssemblyInfo> testAssemblies)
{
if (testAssemblies == null)
throw new ArgumentNullException (nameof (testAssemblies));
Expand Down
Expand Up @@ -679,7 +679,7 @@ void do_log (string message, Action<string> log = null, StringBuilder sb = null)
log (message);
}

public override void Run (IList <TestAssemblyInfo> testAssemblies)
public override void Run (IEnumerable<TestAssemblyInfo> testAssemblies)
{
if (testAssemblies == null)
throw new ArgumentNullException (nameof (testAssemblies));
Expand Down
2 changes: 1 addition & 1 deletion tests/bcl-test/templates/iOSApp/ViewController.cs
Expand Up @@ -111,7 +111,7 @@ public async override void ViewDidLoad ()
runner.SkipTests (skippedTests);
}

runner.Run ((IList<TestAssemblyInfo>)testAssemblies);
runner.Run (testAssemblies);
if (options.EnableXml) {
runner.WriteResultsToFile (writer);
logger.Info ("Xml file was written to the tcp listener.");
Expand Down
2 changes: 1 addition & 1 deletion tests/bcl-test/templates/macOS/MacTestMain.cs
Expand Up @@ -82,7 +82,7 @@ static int RunTests (string [] original_args)
// ensure that we skip those tests that have been passed via the ignore files
runner.SkipTests (skippedTests);
}
runner.Run (testAssemblies.ToList ());
runner.Run (testAssemblies);

if (options.ResultFile != null) {
using (var writer = new StreamWriter (options.ResultFile)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/bcl-test/templates/today/TodayExtensionMain.cs
Expand Up @@ -87,7 +87,7 @@ public void WidgetPerformUpdate (Action<NCUpdateResult> completionHandler)
{
BeginInvokeOnMainThread (() =>
{
runner.Run ((IList<TestAssemblyInfo>)testAssemblies);
runner.Run (testAssemblies);
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/bcl-test/templates/tvOSApp/ViewController.cs
Expand Up @@ -109,7 +109,7 @@ public async override void ViewDidLoad ()
runner.SkipTests (skippedTests);
}

runner.Run ((IList<TestAssemblyInfo>)testAssemblies);
runner.Run (testAssemblies);
if (options.EnableXml) {
runner.WriteResultsToFile (writer);
logger.Info ("Xml file was written to the tcp listener.");
Expand Down
Expand Up @@ -150,7 +150,7 @@ void RunTests ()
BeginInvokeOnMainThread (() =>
{
lblStatus.SetText (string.Format ("{0} tests", runner.TotalTests));
runner.Run ((IList<TestAssemblyInfo>)testAssemblies);
runner.Run (testAssemblies);
RenderResults ();
cmdRun.SetEnabled (true);
cmdRun.SetHidden (false);
Expand Down

0 comments on commit 992c539

Please sign in to comment.