From e3a75b869bba63fccec09062b8d7dcbcae44e34e Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 22 Mar 2023 15:23:56 +0600 Subject: [PATCH] QoL --- .../Threading/DispatcherPriority.cs | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Base/Threading/DispatcherPriority.cs b/src/Avalonia.Base/Threading/DispatcherPriority.cs index a4386370f0..a71140d288 100644 --- a/src/Avalonia.Base/Threading/DispatcherPriority.cs +++ b/src/Avalonia.Base/Threading/DispatcherPriority.cs @@ -57,7 +57,7 @@ namespace Avalonia.Threading /// /// A dispatcher priority for jobs that shouldn't be executed yet /// - public static DispatcherPriority Inactive => new(MinimumActiveValue - 1); + public static readonly DispatcherPriority Inactive = new(MinimumActiveValue - 1); /// /// Minimum valid priority @@ -67,7 +67,7 @@ namespace Avalonia.Threading /// /// Used internally in dispatcher code /// - public static DispatcherPriority Invalid => new(MinimumActiveValue - 2); + public static readonly DispatcherPriority Invalid = new(MinimumActiveValue - 2); /// @@ -158,5 +158,42 @@ namespace Avalonia.Threading if (priority < Inactive || priority > MaxValue) throw new ArgumentException("Invalid DispatcherPriority value", parameterName); } + +#pragma warning disable CS0618 + public override string ToString() + { + if (this == Invalid) + return nameof(Invalid); + if (this == Inactive) + return nameof(Inactive); + if (this == SystemIdle) + return nameof(SystemIdle); + if (this == ContextIdle) + return nameof(ContextIdle); + if (this == ApplicationIdle) + return nameof(ApplicationIdle); + if (this == Background) + return nameof(Background); + if (this == Input) + return nameof(Input); + if (this == Default) + return nameof(Default); + if (this == Loaded) + return nameof(Loaded); + if (this == Render) + return nameof(Render); + if (this == Composition) + return nameof(Composition); + if (this == PreComposition) + return nameof(PreComposition); + if (this == DataBind) + return nameof(DataBind); + if (this == Normal) + return nameof(Normal); + if (this == Send) + return nameof(Send); + return Value.ToString(); + } +#pragma warning restore CS0618 } }