Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Dec 14, 2024
1 parent dff2e4b commit f9f2c24
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions src/Avalonia.Controls.Recycling/ControlRecycling.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Avalonia.Controls.Recycling.Model;
using Avalonia.Controls.Templates;
Expand Down Expand Up @@ -64,14 +63,13 @@ public void Add(object data, object control)
/// <returns></returns>
public object? Build(object? data, object? existing, object? parent)
{
if (data is null)
var key = data;
if (key is null)
{
return null;
}

var key = data;

if (TryToUseIdAsKey && data is IControlRecyclingIdProvider idProvider)
if (TryToUseIdAsKey && key is IControlRecyclingIdProvider idProvider)
{
if (!string.IsNullOrWhiteSpace(idProvider.GetControlRecyclingId()))
{
Expand All @@ -84,15 +82,15 @@ public void Add(object data, object control)
return control;
}

var dataTemplate = (parent as Control)?.FindDataTemplate(data);
var dataTemplate = (parent as Control)?.FindDataTemplate(key);

control = dataTemplate?.Build(data);
control = dataTemplate?.Build(key);
if (control is null)
{
return null;
}

Add(key, control);
Add(key!, control);

return control;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Dock.Model/FactoryBase.Dockable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ public void PreviewPinnedDockable(IDockable dockable)

Debug.Assert(rootDock.PinnedDock != null);

RemoveAllVisibleDockables(rootDock.PinnedDock);
RemoveAllVisibleDockables(rootDock.PinnedDock!);

dockable.OriginalOwner = dockable.Owner;
AddVisibleDockable(rootDock.PinnedDock, dockable);
AddVisibleDockable(rootDock.PinnedDock!, dockable);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -527,7 +527,7 @@ public virtual void PinDockable(IDockable dockable)
else
{
Debug.Assert(dockable.OriginalOwner is IDock);
var originalOwner = (IDock)dockable.OriginalOwner;
var originalOwner = (IDock)dockable.OriginalOwner!;
HidePreviewingDockables(rootDock);
AddVisibleDockable(originalOwner, dockable);
}
Expand Down

0 comments on commit f9f2c24

Please sign in to comment.