diff --git a/src/Avalonia.Layout/ILayoutManager.cs b/src/Avalonia.Layout/ILayoutManager.cs index c3675c18a2..16814f2e1f 100644 --- a/src/Avalonia.Layout/ILayoutManager.cs +++ b/src/Avalonia.Layout/ILayoutManager.cs @@ -1,3 +1,6 @@ +using System; + +#nullable enable namespace Avalonia.Layout { diff --git a/src/Avalonia.Layout/ILayoutable.cs b/src/Avalonia.Layout/ILayoutable.cs index 5c785613a9..316a017f1d 100644 --- a/src/Avalonia.Layout/ILayoutable.cs +++ b/src/Avalonia.Layout/ILayoutable.cs @@ -1,5 +1,7 @@ using Avalonia.VisualTree; +#nullable enable + namespace Avalonia.Layout { /// diff --git a/src/Avalonia.Layout/LayoutManager.cs b/src/Avalonia.Layout/LayoutManager.cs index e8cb937997..92506fee9a 100644 --- a/src/Avalonia.Layout/LayoutManager.cs +++ b/src/Avalonia.Layout/LayoutManager.cs @@ -3,6 +3,8 @@ using System.Diagnostics; using Avalonia.Logging; using Avalonia.Threading; +#nullable enable + namespace Avalonia.Layout { /// @@ -24,7 +26,7 @@ namespace Avalonia.Layout /// public void InvalidateMeasure(ILayoutable control) { - Contract.Requires(control != null); + control = control ?? throw new ArgumentNullException(nameof(control)); Dispatcher.UIThread.VerifyAccess(); if (!control.IsAttachedToVisualTree) @@ -45,7 +47,7 @@ namespace Avalonia.Layout /// public void InvalidateArrange(ILayoutable control) { - Contract.Requires(control != null); + control = control ?? throw new ArgumentNullException(nameof(control)); Dispatcher.UIThread.VerifyAccess(); if (!control.IsAttachedToVisualTree) @@ -73,7 +75,7 @@ namespace Avalonia.Layout { _running = true; - Stopwatch stopwatch = null; + Stopwatch? stopwatch = null; const LogEventLevel timingLogLevel = LogEventLevel.Information; bool captureTiming = Logger.IsEnabled(timingLogLevel); @@ -117,7 +119,7 @@ namespace Avalonia.Layout if (captureTiming) { - stopwatch.Stop(); + stopwatch!.Stop(); Logger.TryGet(timingLogLevel)?.Log(LogArea.Layout, this, "Layout pass finished in {Time}", stopwatch.Elapsed); } diff --git a/src/Avalonia.Layout/Layoutable.cs b/src/Avalonia.Layout/Layoutable.cs index ce5200f4a4..3b13647681 100644 --- a/src/Avalonia.Layout/Layoutable.cs +++ b/src/Avalonia.Layout/Layoutable.cs @@ -1,8 +1,9 @@ using System; using Avalonia.Logging; -using Avalonia.Utilities; using Avalonia.VisualTree; +#nullable enable + namespace Avalonia.Layout { /// @@ -153,7 +154,7 @@ namespace Avalonia.Layout /// /// Occurs when a layout pass completes for the control. /// - public event EventHandler LayoutUpdated; + public event EventHandler? LayoutUpdated; /// /// Gets or sets the width of the element.