-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix covariant array conversion can cause runtime exception linq error.
- Loading branch information
1 parent
5dfe873
commit 43b7bd1
Showing
1 changed file
with
20 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using osu.Framework.Allocation; | ||
|
@@ -64,22 +65,32 @@ public void ShowWithNoFetch() | |
|
||
Schedule(() => | ||
{ | ||
var columns = colourName.Select(c => new TitleTableColumn(c)).OfType<TableColumn>().ToArray(); | ||
var content = providers.Select(provider => | ||
{ | ||
if (provider == null) | ||
throw new ArgumentNullException(nameof(provider)); | ||
|
||
return colourName.Select(c => | ||
{ | ||
var value = provider.GetType().GetProperty(c)?.GetValue(provider); | ||
if (value == null) | ||
throw new ArgumentNullException(nameof(value)); | ||
|
||
var colour = (Color4)value; | ||
return new PreviewColourDrawable(colour); | ||
}).OfType<Drawable>(); | ||
}).To2DArray(); | ||
|
||
Child = new OsuScrollContainer(Direction.Horizontal) | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Child = new TableContainer | ||
{ | ||
RelativeSizeAxes = Axes.Y, | ||
AutoSizeAxes = Axes.X, | ||
Columns = colourName.Select(c => new TitleTableColumn(c)).ToArray(), | ||
Content = providers.Select(p => | ||
{ | ||
return colourName.Select(c => | ||
{ | ||
var colour = (Color4)p.GetType().GetProperty(c).GetValue(p); | ||
return new PreviewColourDrawable(colour); | ||
}); | ||
}).To2DArray(), | ||
Columns = columns, | ||
Content = content, | ||
} | ||
}; | ||
}); | ||
|