Use covariant return types.
Use the covariant return type feature of C# 9 to allow method overrides to be more specific about their return type. By exposing this information, e.g. for Widget.Clone(), callers will have more information. This allows various casts to be removed as the information is now available within the type system.
This commit is contained in:
@@ -338,7 +338,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
listPanel.RemoveChildren();
|
||||
foreach (var package in availablePackages)
|
||||
{
|
||||
var containerWidget = (ContainerWidget)checkboxListTemplate.Clone();
|
||||
var containerWidget = checkboxListTemplate.Clone();
|
||||
var checkboxWidget = containerWidget.Get<CheckboxWidget>("PACKAGE_CHECKBOX");
|
||||
var title = FluentProvider.GetMessage(package.Title);
|
||||
checkboxWidget.GetText = () => title;
|
||||
@@ -385,7 +385,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
foreach (var i in kv.Value)
|
||||
{
|
||||
var item = i;
|
||||
var labelWidget = (LabelWidget)labelListTemplate.Clone();
|
||||
var labelWidget = labelListTemplate.Clone();
|
||||
labelWidget.GetText = () => item;
|
||||
listPanel.AddChild(labelWidget);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user