A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Addressed tons of warnings, mostly related to lack of documentation in code. (#1034)
Etienne BAUDOUXb15597db1f22
diff --git a/src/app/dev/DevToys.Api/Core/DictionaryExtensions.cs b/src/app/dev/DevToys.Api/Core/DictionaryExtensions.csindex 7e22950ae..59e92b4cb 100644--- a/src/app/dev/DevToys.Api/Core/DictionaryExtensions.cs+++ b/src/app/dev/DevToys.Api/Core/DictionaryExtensions.cs@@ -1,10 +1,18 @@namespace DevToys.Api;+/// <summary>+/// Provides extension methods for dictionaries.+/// </summary>public static class DictionaryExtensions{/// <summary>/// Gets the value at the given key, or a default value./// </summary>+ /// <typeparam name="TKey">The type of the keys in the dictionary.</typeparam>+ /// <typeparam name="TValue">The type of the values in the dictionary.</typeparam>+ /// <param name="dictionary">The dictionary to retrieve the value from.</param>+ /// <param name="key">The key to retrieve the value for.</param>+ /// <returns>The value associated with the specified key, or the default value if the key is not found.</returns>public static TValue? GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key){return dictionary.TryGetValue(key, out TValue? value) ? value : default;diff --git a/src/app/dev/DevToys.Api/Core/IFileStorage.cs b/src/app/dev/DevToys.Api/Core/IFileStorage.csindex 52e072c3f..d4e960902 100644--- a/src/app/dev/DevToys.Api/Core/IFileStorage.cs+++ b/src/app/dev/DevToys.Api/Core/IFileStorage.cs@@ -69,7 +69,6 @@ public interface IFileStorage/// <summary>/// Creates a new temporary file in <see cref="AppCacheDirectory"/> that will be deleted when the app stops, or the next time is starts./// </summary>- /// </summary>/// <param name="desiredFileExtension">(optional) The extension the temporary file should use.</param>/// <returns>Returns information to the file.</returns>FileInfo CreateSelfDestroyingTempFile(string? desiredFileExtension = null);diff --git a/src/app/dev/DevToys.Api/Core/LoggingExtensions.cs b/src/app/dev/DevToys.Api/Core/LoggingExtensions.csindex 1a54b4edd..829e348d5 100644--- a/src/app/dev/DevToys.Api/Core/LoggingExtensions.cs+++ b/src/app/dev/DevToys.Api/Core/LoggingExtensions.cs@@ -2,6 +2,9 @@namespace DevToys.Api;+/// <summary>+/// Provides extension methods for logging.+/// </summary>public static class LoggingExtensions{private static ILoggerFactory _loggerFactory = default!;@@ -22,12 +25,17 @@ public static class LoggingExtensions/// <summary>/// Creates an instance of <see cref="ILogger"/> for the specified type./// </summary>+ /// <param name="forType">The type to create the logger for.</param>+ /// <returns>An instance of <see cref="ILogger"/>.</returns>public static ILogger Log(this Type forType)=> LoggerFactory.CreateLogger(forType);/// <summary>/// Creates an instance of <see cref="ILogger"/> for the given object's type./// </summary>+ /// <typeparam name="T">The type of the object.</typeparam>+ /// <param name="instance">The object instance.</param>+ /// <returns>An instance of <see cref="ILogger"/>.</returns>public static ILogger Log<T>(this T instance){Guard.IsNotNull(instance);diff --git a/src/app/dev/DevToys.Api/Core/ObservableCollectionExtensions.cs b/src/app/dev/DevToys.Api/Core/ObservableCollectionExtensions.csindex 312913f0f..ee8dfe19c 100644--- a/src/app/dev/DevToys.Api/Core/ObservableCollectionExtensions.cs+++ b/src/app/dev/DevToys.Api/Core/ObservableCollectionExtensions.cs@@ -2,11 +2,17 @@namespace DevToys.Api;+/// <summary>+/// Provides extension methods for <see cref="ObservableCollection{T}"/>.+/// </summary>public static class ObservableCollectionExtensions{/// <summary>- /// Adds the elements of the specified collection to the end of the ObservableCollection(Of T).+ /// Adds the elements of the specified collection to the end of the <see cref="ObservableCollection{T}"/>./// </summary>+ /// <typeparam name="T">The type of elements in the collection.</typeparam>+ /// <param name="origin">The <see cref="ObservableCollection{T}"/> to add elements to.</param>+ /// <param name="newItems">The collection whose elements should be added to the end of the <see cref="ObservableCollection{T}"/>.</param>public static void AddRange<T>(this ObservableCollection<T> origin, IEnumerable<T> newItems){Guard.IsNotNull(origin);diff --git a/src/app/dev/DevToys.Api/Core/OneOfExtensions.cs b/src/app/dev/DevToys.Api/Core/OneOfExtensions.csindex d8c0f169b..aa9e629eb 100644--- a/src/app/dev/DevToys.Api/Core/OneOfExtensions.cs+++ b/src/app/dev/DevToys.Api/Core/OneOfExtensions.cs@@ -2,8 +2,18 @@namespace DevToys.Api;+/// <summary>+/// Extension methods for working with OneOf types.+/// </summary>public static class OneOfExtensions{+ /// <summary>+ /// Gets a stream asynchronously based on the input OneOf type.+ /// </summary>+ /// <param name="input">The input OneOf type.</param>+ /// <param name="fileStorage">The file storage implementation.</param>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>A task that represents the asynchronous operation. The task result contains the stream and a flag indicating if the stream was successfully retrieved.</returns>public static Task<ResultInfo<Stream>> GetStreamAsync(this OneOf<string, FileInfo> input,IFileStorage fileStorage,@@ -17,6 +27,13 @@ public static class OneOfExtensionsreturn GetStreamAsync(OneOf<FileInfo, string>.FromT1(input.AsT0), fileStorage, cancellationToken);}+ /// <summary>+ /// Gets a stream asynchronously based on the input OneOf type.+ /// </summary>+ /// <param name="input">The input OneOf type.</param>+ /// <param name="fileStorage">The file storage implementation.</param>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>A task that represents the asynchronous operation. The task result contains the stream and a flag indicating if the stream was successfully retrieved.</returns>public static async Task<ResultInfo<Stream>> GetStreamAsync(this OneOf<FileInfo, string> input,IFileStorage fileStorage,@@ -24,14 +41,14 @@ public static class OneOfExtensions{return awaitinput.Match(- async inputFile =>+ inputFile =>{if (!fileStorage.FileExists(inputFile.FullName)){- return new ResultInfo<Stream>(Stream.Null, false);+ return Task.FromResult(new ResultInfo<Stream>(Stream.Null, false));}- return new ResultInfo<Stream>(fileStorage.OpenReadFile(inputFile.FullName), true);+ return Task.FromResult(new ResultInfo<Stream>(fileStorage.OpenReadFile(inputFile.FullName), true));},async inputString =>{@@ -47,6 +64,13 @@ public static class OneOfExtensions});}+ /// <summary>+ /// Reads all text asynchronously based on the input OneOf type.+ /// </summary>+ /// <param name="input">The input OneOf type.</param>+ /// <param name="fileStorage">The file storage implementation.</param>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>A task that represents the asynchronous operation. The task result contains the text content and a flag indicating if the content was successfully read.</returns>public static async Task<ResultInfo<string>> ReadAllTextAsync(this OneOf<string, FileInfo> input,IFileStorage fileStorage,@@ -60,6 +84,13 @@ public static class OneOfExtensionsreturn await ReadAllTextAsync(OneOf<FileInfo, string>.FromT1(input.AsT0), fileStorage, cancellationToken);}+ /// <summary>+ /// Reads all text asynchronously based on the input OneOf type.+ /// </summary>+ /// <param name="input">The input OneOf type.</param>+ /// <param name="fileStorage">The file storage implementation.</param>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>A task that represents the asynchronous operation. The task result contains the text content and a flag indicating if the content was successfully read.</returns>public static async Task<ResultInfo<string>> ReadAllTextAsync(this OneOf<FileInfo, string> input,IFileStorage fileStorage,diff --git a/src/app/dev/DevToys.Api/Core/SandboxedFileReader.cs b/src/app/dev/DevToys.Api/Core/SandboxedFileReader.csindex c73706935..b573143d2 100644--- a/src/app/dev/DevToys.Api/Core/SandboxedFileReader.cs+++ b/src/app/dev/DevToys.Api/Core/SandboxedFileReader.cs@@ -11,12 +11,20 @@[DebuggerDisplay($"FileName = {{{nameof(FileName)}}}")]public abstract class SandboxedFileReader : IDisposable{+ /// <summary>+ /// The buffer size used for reading the file in chunks.+ /// </summary>public const int BufferSize = 4096; // 4 KB chunksprivate readonly DisposableSemaphore _semaphore = new();private bool _disposed;private List<Stream>? _fileAccesses;+ /// <summary>+ /// Creates a new instance of the <see cref="SandboxedFileReader"/> class from a <see cref="FileInfo"/> object.+ /// </summary>+ /// <param name="fileInfo">The <see cref="FileInfo"/> object representing the file.</param>+ /// <returns>A new instance of the <see cref="SandboxedFileReader"/> class.</returns>public static SandboxedFileReader FromFileInfo(FileInfo fileInfo){Guard.IsNotNull(fileInfo);@@ -26,6 +34,7 @@ public abstract class SandboxedFileReader : IDisposable/// <summary>/// Initializes a new instance of the <see cref="SandboxedFileReader"/> class./// </summary>+ /// <param name="fileName">The name of the file, including its extension.</param>protected SandboxedFileReader(string fileName){FileName = Path.GetFileName(fileName);@@ -41,8 +50,16 @@ public abstract class SandboxedFileReader : IDisposable/// </summary>public event EventHandler? Disposed;+ /// <summary>+ /// Opens the file for reading asynchronously.+ /// </summary>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>A task representing the asynchronous operation.</returns>protected abstract ValueTask<Stream> OpenReadFileAsync(CancellationToken cancellationToken);+ /// <summary>+ /// Disposes the <see cref="SandboxedFileReader"/> and releases any resources used.+ /// </summary>public void Dispose(){lock (_semaphore)@@ -56,11 +73,13 @@ public abstract class SandboxedFileReader : IDisposable}/// <summary>- /// Get a new stream that can be used to read the file. The stream gets disposed automatically+ /// Gets a new stream that can be used to read the file. The stream gets disposed automatically/// when the <see cref="SandboxedFileReader"/> is disposed./// </summary>/// <remarks>In some cases, the returned stream is non-seekable.</remarks>+ /// <param name="cancellationToken">The cancellation token.</param>/// <exception cref="ObjectDisposedException">The <see cref="SandboxedFileReader"/> has been disposed.</exception>"+ /// <returns>A task representing the asynchronous operation.</returns>public async Task<Stream> GetNewAccessToFileContentAsync(CancellationToken cancellationToken){using (await _semaphore.WaitAsync(cancellationToken))@@ -78,8 +97,11 @@ public abstract class SandboxedFileReader : IDisposable}/// <summary>- /// Copy the content of the file to the given stream.+ /// Copies the content of the file to the given stream./// </summary>+ /// <param name="destinationStream">The destination stream.</param>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>/// <exception cref="ObjectDisposedException">The <see cref="SandboxedFileReader"/> has been disposed.</exception>"public async Task CopyFileContentToAsync(Stream destinationStream, CancellationToken cancellationToken){diff --git a/src/app/dev/DevToys.Api/Core/Threading/AsyncLazy.cs b/src/app/dev/DevToys.Api/Core/Threading/AsyncLazy.csindex a3b491777..b7ff5b0af 100644--- a/src/app/dev/DevToys.Api/Core/Threading/AsyncLazy.cs+++ b/src/app/dev/DevToys.Api/Core/Threading/AsyncLazy.cs@@ -1,55 +1,98 @@namespace DevToys.Api;+/// <summary>+/// Represents an asynchronous lazy initialization.+/// </summary>+/// <typeparam name="T">The type of the value being lazily initialized.</typeparam>[DebuggerDisplay($"IsValueCreated = {{{nameof(IsValueCreated)}}}")]public class AsyncLazy<T>{- private static Func<Task<T>> FromFuncT(Func<T> valueFunc)- {- Guard.IsNotNull(valueFunc);- return () => Task.FromResult(valueFunc());- }-private readonly Lazy<Task<T>> _innerLazy;- public bool IsValueCreated => _innerLazy.IsValueCreated && _innerLazy.Value.IsCompletedSuccessfully;-+ /// <summary>+ /// Creates a new instance of the <see cref="AsyncLazy{T}"/> class with the specified value.+ /// </summary>+ /// <param name="value">The value to initialize the <see cref="AsyncLazy{T}"/> instance with.</param>public AsyncLazy(T value){_innerLazy = new Lazy<Task<T>>(Task.FromResult(value));}+ /// <summary>+ /// Creates a new instance of the <see cref="AsyncLazy{T}"/> class with the specified value factory.+ /// </summary>+ /// <param name="valueFactory">The delegate that represents the value factory.</param>public AsyncLazy(Func<T> valueFactory){_innerLazy = new Lazy<Task<T>>(FromFuncT(valueFactory));}+ /// <summary>+ /// Creates a new instance of the <see cref="AsyncLazy{T}"/> class with the specified value factory and thread safety option.+ /// </summary>+ /// <param name="valueFactory">The delegate that represents the value factory.</param>+ /// <param name="isThreadSafe">A boolean value indicating whether the lazy initialization is thread-safe.</param>public AsyncLazy(Func<T> valueFactory, bool isThreadSafe){_innerLazy = new Lazy<Task<T>>(FromFuncT(valueFactory), isThreadSafe);}+ /// <summary>+ /// Creates a new instance of the <see cref="AsyncLazy{T}"/> class with the specified value factory and thread safety mode.+ /// </summary>+ /// <param name="valueFactory">The delegate that represents the value factory.</param>+ /// <param name="mode">The thread safety mode for the lazy initialization.</param>public AsyncLazy(Func<T> valueFactory, LazyThreadSafetyMode mode){_innerLazy = new Lazy<Task<T>>(FromFuncT(valueFactory), mode);}+ /// <summary>+ /// Creates a new instance of the <see cref="AsyncLazy{T}"/> class with the specified asynchronous value factory.+ /// </summary>+ /// <param name="valueFactory">The delegate that represents the asynchronous value factory.</param>public AsyncLazy(Func<Task<T>> valueFactory){_innerLazy = new Lazy<Task<T>>(valueFactory);}+ /// <summary>+ /// Creates a new instance of the <see cref="AsyncLazy{T}"/> class with the specified asynchronous value factory and thread safety option.+ /// </summary>+ /// <param name="valueFactory">The delegate that represents the asynchronous value factory.</param>+ /// <param name="isThreadSafe">A boolean value indicating whether the lazy initialization is thread-safe.</param>public AsyncLazy(Func<Task<T>> valueFactory, bool isThreadSafe){_innerLazy = new Lazy<Task<T>>(valueFactory, isThreadSafe);}+ /// <summary>+ /// Creates a new instance of the <see cref="AsyncLazy{T}"/> class with the specified asynchronous value factory and thread safety mode.+ /// </summary>+ /// <param name="valueFactory">The delegate that represents the asynchronous value factory.</param>+ /// <param name="mode">The thread safety mode for the lazy initialization.</param>public AsyncLazy(Func<Task<T>> valueFactory, LazyThreadSafetyMode mode){_innerLazy = new Lazy<Task<T>>(valueFactory, mode);}+ /// <summary>+ /// Gets a task that represents the asynchronous initialization of the value.+ /// </summary>+ /// <returns>A task that represents the asynchronous initialization of the value.</returns>public Task<T> GetValueAsync(){return IsValueCreated ? Task.FromResult(_innerLazy.Value.Result) : _innerLazy.Value;}++ /// <summary>+ /// Determines whether the value has been created.+ /// </summary>+ public bool IsValueCreated => _innerLazy.IsValueCreated && _innerLazy.Value.IsCompletedSuccessfully;++ private static Func<Task<T>> FromFuncT(Func<T> valueFunc)+ {+ Guard.IsNotNull(valueFunc);+ return () => Task.FromResult(valueFunc());+ }}diff --git a/src/app/dev/DevToys.Api/Core/Threading/DisposableSemaphore.cs b/src/app/dev/DevToys.Api/Core/Threading/DisposableSemaphore.csindex b9aaac4a6..8d1509f39 100644--- a/src/app/dev/DevToys.Api/Core/Threading/DisposableSemaphore.cs+++ b/src/app/dev/DevToys.Api/Core/Threading/DisposableSemaphore.cs@@ -1,7 +1,7 @@namespace DevToys.Api;/// <summary>-/// Represents a semaphore that free other threads when disposing the result of the <see cref="WaitAsync(CancellationToken)"/> method..+/// Represents a semaphore that free other threads when disposing the result of the <see cref="WaitAsync(CancellationToken)"/> method./// </summary>[DebuggerDisplay($"IsBusy = {{{nameof(IsBusy)}}}, Disposed = {{{nameof(Disposed)}}}")]public sealed class DisposableSemaphore : IDisposable@@ -9,15 +9,28 @@ public sealed class DisposableSemaphore : IDisposableprivate readonly object _lockObject = new();private readonly SemaphoreSlim _semaphore;+ /// <summary>+ /// Gets a value indicating whether the semaphore has been disposed.+ /// </summary>public bool Disposed { get; private set; }+ /// <summary>+ /// Gets a value indicating whether the semaphore is currently busy.+ /// </summary>public bool IsBusy => _semaphore.CurrentCount == 0;+ /// <summary>+ /// Initializes a new instance of the <see cref="DisposableSemaphore"/> class.+ /// </summary>+ /// <param name="maxTasksCount">The maximum number of concurrent tasks that can be executed.</param>public DisposableSemaphore(int maxTasksCount = 1){_semaphore = new SemaphoreSlim(maxTasksCount, maxTasksCount);}+ /// <summary>+ /// Releases all resources used by the <see cref="DisposableSemaphore"/>.+ /// </summary>public void Dispose(){lock (_lockObject)@@ -30,6 +43,11 @@ public sealed class DisposableSemaphore : IDisposable}}+ /// <summary>+ /// Asynchronously waits for the semaphore to be available.+ /// </summary>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>An <see cref="IDisposable"/> object that should be disposed to release the semaphore.</returns>public async Task<IDisposable> WaitAsync(CancellationToken cancellationToken){await _semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);@@ -46,6 +64,9 @@ public sealed class DisposableSemaphore : IDisposable_semaphore = semaphore;}+ /// <summary>+ /// Releases the semaphore.+ /// </summary>public void Dispose(){_semaphore.Release();diff --git a/src/app/dev/DevToys.Api/Core/Threading/TaskExtensions.cs b/src/app/dev/DevToys.Api/Core/Threading/TaskExtensions.csindex 3f4918d4f..0b6c24c1b 100644--- a/src/app/dev/DevToys.Api/Core/Threading/TaskExtensions.cs+++ b/src/app/dev/DevToys.Api/Core/Threading/TaskExtensions.cs@@ -8,6 +8,7 @@ public static class TaskExtensions/// <summary>/// Runs a task without waiting for its result./// </summary>+ /// <param name="_">The task to run.</param>public static void Forget(this Task _){}@@ -15,6 +16,8 @@ public static class TaskExtensions/// <summary>/// Runs a task without waiting for its result./// </summary>+ /// <typeparam name="T">The type of the task result.</typeparam>+ /// <param name="_">The task to run.</param>public static void Forget<T>(this Task<T> _){}@@ -22,6 +25,7 @@ public static class TaskExtensions/// <summary>/// Runs a task without waiting for its result./// </summary>+ /// <param name="_">The task to run.</param>public static void Forget(this ValueTask _){}@@ -29,6 +33,8 @@ public static class TaskExtensions/// <summary>/// Runs a task without waiting for its result./// </summary>+ /// <typeparam name="T">The type of the task result.</typeparam>+ /// <param name="_">The task to run.</param>public static void Forget<T>(this ValueTask<T> _){}@@ -36,6 +42,7 @@ public static class TaskExtensions/// <summary>/// Runs a task without waiting for its result. Swallows or handle any exception caused by the task./// </summary>+ /// <param name="task">The task to run.</param>/// <param name="errorHandler">The action to run when an exception is caught.</param>public static async void ForgetSafely(this Task task, Action<Exception>? errorHandler = null){@@ -52,6 +59,7 @@ public static class TaskExtensions/// <summary>/// Runs a task without waiting for its result. Swallows or handle any exception caused by the task./// </summary>+ /// <param name="task">The task to run.</param>/// <param name="errorHandler">The action to run when an exception is caught.</param>public static async void ForgetSafely(this ValueTask task, Action<Exception>? errorHandler = null){@@ -68,6 +76,7 @@ public static class TaskExtensions/// <summary>/// Gets the result of the task synchronously, on the current thread./// </summary>+ /// <param name="task">The task to complete.</param>public static void CompleteOnCurrentThread(this Task task){task.GetAwaiter().GetResult();@@ -76,6 +85,9 @@ public static class TaskExtensions/// <summary>/// Gets the result of the task synchronously, on the current thread./// </summary>+ /// <typeparam name="T">The type of the task result.</typeparam>+ /// <param name="task">The task to complete.</param>+ /// <returns>The result of the task.</returns>public static T CompleteOnCurrentThread<T>(this Task<T> task){return task.GetAwaiter().GetResult();diff --git a/src/app/dev/DevToys.Api/Core/Threading/TaskSchedulerAwaiter.cs b/src/app/dev/DevToys.Api/Core/Threading/TaskSchedulerAwaiter.csindex e38fd7fa4..ca78a1668 100644--- a/src/app/dev/DevToys.Api/Core/Threading/TaskSchedulerAwaiter.cs+++ b/src/app/dev/DevToys.Api/Core/Threading/TaskSchedulerAwaiter.cs@@ -3,10 +3,16 @@namespace DevToys.Api;/// <summary>-/// An awaiter returned from <see cref="GetAwaiter(TaskScheduler)"/>.+/// An awaiter returned from <see cref="GetAwaiter()"/>./// </summary>public readonly struct TaskSchedulerAwaiter : ICriticalNotifyCompletion{+ /// <summary>+ /// Switches the execution context off the main thread asynchronously.+ /// </summary>+ /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param>+ /// <returns>A <see cref="TaskSchedulerAwaiter"/> configured to the appropriate <see cref="TaskScheduler"/>.</returns>+ /// <exception cref="OperationCanceledException">The token has had cancellation requested.</exception>public static TaskSchedulerAwaiter SwitchOffMainThreadAsync(CancellationToken cancellationToken){cancellationToken.ThrowIfCancellationRequested();@@ -32,6 +38,7 @@ public readonly struct TaskSchedulerAwaiter : ICriticalNotifyCompletion/// Initializes a new instance of the <see cref="TaskSchedulerAwaiter"/> struct./// </summary>/// <param name="scheduler">The scheduler for continuations.</param>+ /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param>/// <param name="alwaysYield">A value indicating whether the caller should yield even if/// already executing on the desired task scheduler.</param>public TaskSchedulerAwaiter(TaskScheduler scheduler, CancellationToken cancellationToken, bool alwaysYield = false)diff --git a/src/app/dev/DevToys.Api/IDataGridRow.cs b/src/app/dev/DevToys.Api/IDataGridRow.csindex c9903b200..95cc6430a 100644--- a/src/app/dev/DevToys.Api/IDataGridRow.cs+++ b/src/app/dev/DevToys.Api/IDataGridRow.cs@@ -1,5 +1,9 @@namespace DevToys.Api;+/// <summary>+/// Represents a data grid row with optional detail information.+/// </summary>+/// <typeparam name="T">The type of the detail information.</typeparam>public interface IDataGridRow<T> where T : class{/// <summary>diff --git a/src/app/dev/DevToys.Api/Settings/SettingChangedEventArgs.cs b/src/app/dev/DevToys.Api/Settings/SettingChangedEventArgs.csindex 5015086ca..07c51e2b7 100644--- a/src/app/dev/DevToys.Api/Settings/SettingChangedEventArgs.cs+++ b/src/app/dev/DevToys.Api/Settings/SettingChangedEventArgs.cs@@ -15,6 +15,11 @@ public sealed class SettingChangedEventArgs : EventArgs/// </summary>public object? NewValue { get; }+ /// <summary>+ /// Initializes a new instance of the <see cref="SettingChangedEventArgs"/> class.+ /// </summary>+ /// <param name="settingName">The name of the setting that changed.</param>+ /// <param name="newValue">The new value of the setting.</param>public SettingChangedEventArgs(string settingName, object? newValue){SettingName = settingName;diff --git a/src/app/dev/DevToys.Api/Settings/SettingDefinition.cs b/src/app/dev/DevToys.Api/Settings/SettingDefinition.csindex 21db69491..d9721d08d 100644--- a/src/app/dev/DevToys.Api/Settings/SettingDefinition.cs+++ b/src/app/dev/DevToys.Api/Settings/SettingDefinition.cs@@ -18,7 +18,7 @@ public readonly struct SettingDefinition<T> : IEquatable<SettingDefinition<T>>public T DefaultValue { get; }/// <summary>- /// Initializes a new instance of the <see cref="SettingDefinition"/> structure.+ /// Initializes a new instance of the <see cref="SettingDefinition{T}"/> structure./// </summary>/// <param name="name">The name of the setting. Should be unique.</param>/// <param name="defaultValue">The default value of the setting.</param>@@ -31,7 +31,7 @@ public readonly struct SettingDefinition<T> : IEquatable<SettingDefinition<T>>// Come one! Make it shorter!ThrowHelper.ThrowArgumentOutOfRangeException(nameof(name), "Setting name is limited to 255 characters.");}- else if (name.Contains("="))+ else if (name.Contains('=')){// For portable apps, settings are stored in a .ini file where the format is "setting_name=value".// Therefore, the setting name shouldn't contain "=".@@ -42,6 +42,11 @@ public readonly struct SettingDefinition<T> : IEquatable<SettingDefinition<T>>DefaultValue = defaultValue;}+ /// <summary>+ /// Determines whether the specified object is equal to the current object.+ /// </summary>+ /// <param name="obj">The object to compare with the current object.</param>+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>public override bool Equals(object? obj){if (obj is SettingDefinition<T> definition)@@ -52,6 +57,11 @@ public readonly struct SettingDefinition<T> : IEquatable<SettingDefinition<T>>return false;}+ /// <summary>+ /// Determines whether the specified <see cref="SettingDefinition{T}"/> is equal to the current <see cref="SettingDefinition{T}"/>.+ /// </summary>+ /// <param name="other">The <see cref="SettingDefinition{T}"/> to compare with the current <see cref="SettingDefinition{T}"/>.</param>+ /// <returns>true if the specified <see cref="SettingDefinition{T}"/> is equal to the current <see cref="SettingDefinition{T}"/>; otherwise, false.</returns>public bool Equals(SettingDefinition<T> other){return string.Equals(other.Name, Name, StringComparison.Ordinal)@@ -59,17 +69,33 @@ public readonly struct SettingDefinition<T> : IEquatable<SettingDefinition<T>>&& other.DefaultValue.Equals(DefaultValue);}+ /// <summary>+ /// Returns the hash code for this <see cref="SettingDefinition{T}"/>.+ /// </summary>+ /// <returns>A 32-bit signed integer hash code.</returns>public override int GetHashCode(){return (Name.GetHashCode() ^ 47)* (DefaultValue is null ? 13 : DefaultValue.GetHashCode() ^ 73);}+ /// <summary>+ /// Determines whether two specified <see cref="SettingDefinition{T}"/> objects have the same value.+ /// </summary>+ /// <param name="left">The first <see cref="SettingDefinition{T}"/> to compare.</param>+ /// <param name="right">The second <see cref="SettingDefinition{T}"/> to compare.</param>+ /// <returns>true if the value of left is the same as the value of right; otherwise, false.</returns>public static bool operator ==(SettingDefinition<T> left, SettingDefinition<T> right){return left.Equals(right);}+ /// <summary>+ /// Determines whether two specified <see cref="SettingDefinition{T}"/> objects have different values.+ /// </summary>+ /// <param name="left">The first <see cref="SettingDefinition{T}"/> to compare.</param>+ /// <param name="right">The second <see cref="SettingDefinition{T}"/> to compare.</param>+ /// <returns>true if the value of left is different from the value of right; otherwise, false.</returns>public static bool operator !=(SettingDefinition<T> left, SettingDefinition<T> right){return !(left == right);diff --git a/src/app/dev/DevToys.Api/Tool/CLI/ConsoleProgressBar.cs b/src/app/dev/DevToys.Api/Tool/CLI/ConsoleProgressBar.csindex 4a50cd9fc..ca2bbbc3e 100644--- a/src/app/dev/DevToys.Api/Tool/CLI/ConsoleProgressBar.cs+++ b/src/app/dev/DevToys.Api/Tool/CLI/ConsoleProgressBar.cs@@ -20,6 +20,9 @@ public class ConsoleProgressBar : IDisposable, IProgress<double>private bool _disposed = false;private int _animationIndex = 0;+ /// <summary>+ /// Initializes a new instance of the <see cref="ConsoleProgressBar"/> class.+ /// </summary>public ConsoleProgressBar(){_timer = new Timer(TimerHandler);@@ -33,6 +36,7 @@ public class ConsoleProgressBar : IDisposable, IProgress<double>}}+ /// <inheritdoc/>public void Dispose(){lock (_timer)@@ -44,6 +48,7 @@ public class ConsoleProgressBar : IDisposable, IProgress<double>GC.SuppressFinalize(this);}+ /// <inheritdoc/>public void Report(double value){Guard.IsBetweenOrEqualTo(value, 0, 100);diff --git a/src/app/dev/DevToys.Api/Tool/CLI/ICommandLineTool.cs b/src/app/dev/DevToys.Api/Tool/CLI/ICommandLineTool.csindex 18801c057..9177365a9 100644--- a/src/app/dev/DevToys.Api/Tool/CLI/ICommandLineTool.cs+++ b/src/app/dev/DevToys.Api/Tool/CLI/ICommandLineTool.cs@@ -25,7 +25,7 @@ namespace DevToys.Api;/// [CommandLineOption(Name = "utf8", DescriptionResourceName = nameof(Strings.Utf8OptionDescription))]/// internal bool Utf8 { get; set; } = true; // Default value is true.///-/// public ValueTask<int> InvokeAsync(CancellationToken cancellationToken)+/// public ValueTask<int> InvokeAsync(CancellationToken cancellationToken)/// {/// // [...]/// return 0; // Exit code.diff --git a/src/app/dev/DevToys.Api/Tool/FontDefinition.cs b/src/app/dev/DevToys.Api/Tool/FontDefinition.csindex 515a40f5b..6e91d6ba4 100644--- a/src/app/dev/DevToys.Api/Tool/FontDefinition.cs+++ b/src/app/dev/DevToys.Api/Tool/FontDefinition.cs@@ -1,7 +1,15 @@namespace DevToys.Api;+/// <summary>+/// Represents a font definition.+/// </summary>public sealed class FontDefinition : IDisposable{+ /// <summary>+ /// Initializes a new instance of the <see cref="FontDefinition"/> class.+ /// </summary>+ /// <param name="fontFamily">The font family.</param>+ /// <param name="fontReader">The stream to read the font file.</param>public FontDefinition(string fontFamily, Stream fontReader){Guard.IsNotNullOrWhiteSpace(fontFamily);@@ -11,10 +19,19 @@ public sealed class FontDefinition : IDisposableFontReader = fontReader;}+ /// <summary>+ /// Gets the font family.+ /// </summary>public string FontFamily { get; }+ /// <summary>+ /// Gets the stream to read the font file.+ /// </summary>public Stream FontReader { get; }+ /// <summary>+ /// Disposes the font reader.+ /// </summary>public void Dispose(){FontReader?.Dispose();diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIButton.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIButton.csindex b3bca59b3..1f0b52694 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIButton.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIButton.cs@@ -131,6 +131,7 @@ public static partial class GUI/// <summary>/// Create a component that represents a button, which reacts when clicking on it./// </summary>+ /// <returns>The created <see cref="IUIButton"/> instance.</returns>public static IUIButton Button(){return Button(null);@@ -140,6 +141,7 @@ public static partial class GUI/// Create a component that represents a button, which reacts when clicking on it./// </summary>/// <param name="id">An optional unique identifier for this UI element.</param>+ /// <returns>The created <see cref="IUIButton"/> instance.</returns>public static IUIButton Button(string? id){return new UIButton(id);@@ -158,6 +160,9 @@ public static partial class GUI/// <summary>/// Sets the <see cref="IUIButton.Text"/> of the button./// </summary>+ /// <param name="element">The <see cref="IUIButton"/> instance.</param>+ /// <param name="text">The text to display in the button.</param>+ /// <returns>The updated <see cref="IUIButton"/> instance.</returns>public static IUIButton Text(this IUIButton element, string? text){((UIButton)element).Text = text;@@ -167,6 +172,9 @@ public static partial class GUI/// <summary>/// Sets the action to run when clicking on the button./// </summary>+ /// <param name="element">The <see cref="IUIButton"/> instance.</param>+ /// <param name="actionOnClick">The action to run when clicking on the button.</param>+ /// <returns>The updated <see cref="IUIButton"/> instance.</returns>public static IUIButton OnClick(this IUIButton element, Func<ValueTask>? actionOnClick){((UIButton)element).OnClickAction = actionOnClick;@@ -176,6 +184,9 @@ public static partial class GUI/// <summary>/// Sets the action to run when clicking on the button./// </summary>+ /// <param name="element">The <see cref="IUIButton"/> instance.</param>+ /// <param name="actionOnClick">The action to run when clicking on the button.</param>+ /// <returns>The updated <see cref="IUIButton"/> instance.</returns>public static IUIButton OnClick(this IUIButton element, Action? actionOnClick){((UIButton)element).OnClickAction@@ -190,6 +201,8 @@ public static partial class GUI/// <summary>/// Sets the button to appear as accented./// </summary>+ /// <param name="element">The <see cref="IUIButton"/> instance.</param>+ /// <returns>The updated <see cref="IUIButton"/> instance.</returns>public static IUIButton AccentAppearance(this IUIButton element){((UIButton)element).IsAccent = true;@@ -199,6 +212,8 @@ public static partial class GUI/// <summary>/// Sets the button to appear as a hyperlink./// </summary>+ /// <param name="element">The <see cref="IUIButton"/> instance.</param>+ /// <returns>The updated <see cref="IUIButton"/> instance.</returns>public static IUIButton HyperlinkAppearance(this IUIButton element){((UIButton)element).IsHyperlink = true;@@ -208,6 +223,8 @@ public static partial class GUI/// <summary>/// Sets the button to appear as neutral./// </summary>+ /// <param name="element">The <see cref="IUIButton"/> instance.</param>+ /// <returns>The updated <see cref="IUIButton"/> instance.</returns>public static IUIButton NeutralAppearance(this IUIButton element){((UIButton)element).IsAccent = false;@@ -217,6 +234,10 @@ public static partial class GUI/// <summary>/// Sets the icon of the button./// </summary>+ /// <param name="element">The <see cref="IUIButton"/> instance.</param>+ /// <param name="fontName">The name of the font containing the icon.</param>+ /// <param name="glyph">The glyph corresponding to the icon in the <paramref name="fontName"/>.</param>+ /// <returns>The updated <see cref="IUIButton"/> instance.</returns>public static IUIButton Icon(this IUIButton element, string fontName, char glyph){var button = (UIButton)element;diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUICard.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUICard.csindex c53a461a5..e70e30e60 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUICard.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUICard.cs@@ -1,6 +1,4 @@-using System.Xml.Linq;--namespace DevToys.Api;+namespace DevToys.Api;/// <summary>/// A component that represents a empty card and <see cref="IUIElement"/> for the option value.@@ -23,7 +21,7 @@ internal class UICard : UIElement, IUICardUIElement = uiElement;}- public IUIElement UIElement { get; }+ public IUIElement UIElement { get; }}public static partial class GUIdiff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDataGrid.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDataGrid.csindex 8072d1cf9..3d17daae0 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDataGrid.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDataGrid.cs@@ -36,7 +36,7 @@ public interface IUIDataGrid : IUITitledElementWithChildren/// Gets whether the element can be expanded to take the size of the whole tool boundaries. Default is false./// </summary>/// <remarks>- /// When <see cref="IUIDataGrid.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode.+ /// When <see cref="IUIElement.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode./// </remarks>bool IsExtendableToFullScreen { get; }@@ -305,7 +305,7 @@ public static partial class GUI/// Indicates that the control can be extended to take the size of the whole tool boundaries./// </summary>/// <remarks>- /// When <see cref="IUIDataGrid.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode.+ /// When <see cref="IUIElement.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode./// </remarks>public static IUIDataGrid Extendable(this IUIDataGrid element){diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDiffTextInput.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDiffTextInput.csindex e8c2b32de..c88496ebf 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDiffTextInput.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDiffTextInput.cs@@ -27,7 +27,7 @@ public interface IUIDiffTextInput : IUISingleLineTextInput/// Gets whether the element can be expanded to take the size of the whole tool boundaries./// </summary>/// <remarks>- /// When <see cref="IUIDiffTextInput.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode.+ /// When <see cref="IUIElement.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode./// </remarks>bool IsExtendableToFullScreen { get; }@@ -153,7 +153,7 @@ public static partial class GUI/// Indicates that the control can be extended to take the size of the whole tool boundaries./// </summary>/// <remarks>- /// When <see cref="IUIDiffTextInput.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode.+ /// When <see cref="IUIElement.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode./// </remarks>public static IUIDiffTextInput Extendable(this IUIDiffTextInput element){diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIImageViewer.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIImageViewer.csindex 82db13a5e..f2f5fa36c 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIImageViewer.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIImageViewer.cs@@ -43,6 +43,7 @@ internal sealed class UIImageViewer : UITitledElement, IUIImageViewer, IDisposabinternal bool DisposeAutomatically { get; set; }+ /// <inheritdoc/>public OneOf<FileInfo, Image, SandboxedFileReader>? ImageSource{get => _imageSource;@@ -57,15 +58,20 @@ internal sealed class UIImageViewer : UITitledElement, IUIImageViewer, IDisposab}}+ /// <inheritdoc/>public IReadOnlyDictionary<string, Func<FileStream, ValueTask>> CustomActionPerFileExtensionOnSaving{get => _customActionPerFileExtensionOnSaving;internal set => SetPropertyValue(ref _customActionPerFileExtensionOnSaving, value, CustomActionPerFileExtensionOnSavingChanged);}+ /// <inheritdoc/>public event EventHandler? ImageSourceChanged;++ /// <inheritdoc/>public event EventHandler? CustomActionPerFileExtensionOnSavingChanged;+ /// <inheritdoc/>public void Dispose(){if (ImageSource.HasValue && ImageSource.Value.Value is IDisposable disposable && DisposeAutomatically)@@ -81,6 +87,7 @@ public static partial class GUI/// A component that displays an image and allows the user to perform some read-only actions on it./// By default, image viewer supports BMP, GIF, JPEG, PBM, PNG, TIFF, TGA, WEBP, SVG formats./// </summary>+ /// <returns>The created <see cref="IUIImageViewer"/> instance.</returns>public static IUIImageViewer ImageViewer(){return ImageViewer(id: null);@@ -91,6 +98,7 @@ public static partial class GUI/// By default, image viewer supports BMP, GIF, JPEG, PBM, PNG, TIFF, TGA, WEBP, SVG formats./// </summary>/// <param name="id">An optional unique identifier for this UI element.</param>+ /// <returns>The created <see cref="IUIImageViewer"/> instance.</returns>public static IUIImageViewer ImageViewer(string? id){return new UIImageViewer(id);@@ -99,6 +107,9 @@ public static partial class GUI/// <summary>/// Sets the <see cref="IUIImageViewer.ImageSource"/> from a <see cref="FileInfo"/>./// </summary>+ /// <param name="element">The <see cref="IUIImageViewer"/> instance.</param>+ /// <param name="imageFile">The <see cref="FileInfo"/> representing the image file.</param>+ /// <returns>The updated <see cref="IUIImageViewer"/> instance.</returns>public static IUIImageViewer WithFile(this IUIImageViewer element, FileInfo imageFile){ValidateFileExtension(imageFile.Name);@@ -109,8 +120,10 @@ public static partial class GUI/// <summary>/// Sets the <see cref="IUIImageViewer.ImageSource"/> from a <see cref="SandboxedFileReader"/>./// </summary>- /// <param name="pickedFile">The file to display.</param>- /// <param name="disposeAutomatically">Indicates whether <paramref name="pickedFile"/> should be disposed when not displayed in the UI anymore.</param>+ /// <param name="element">The <see cref="IUIImageViewer"/> instance.</param>+ /// <param name="pickedFile">The <see cref="SandboxedFileReader"/> representing the picked file.</param>+ /// <param name="disposeAutomatically">Indicates whether the <paramref name="pickedFile"/> should be disposed when not displayed in the UI anymore.</param>+ /// <returns>The updated <see cref="IUIImageViewer"/> instance.</returns>public static IUIImageViewer WithPickedFile(this IUIImageViewer element, SandboxedFileReader pickedFile, bool disposeAutomatically){ValidateFileExtension(pickedFile.FileName);@@ -123,8 +136,10 @@ public static partial class GUI/// <summary>/// Sets the <see cref="IUIImageViewer.ImageSource"/> from an <see cref="Image"/>./// </summary>- /// <param name="image">The image to display</param>- /// <param name="disposeAutomatically">Indicates whether <paramref name="image"/> should be disposed when not displayed in the UI anymore.</param>+ /// <param name="element">The <see cref="IUIImageViewer"/> instance.</param>+ /// <param name="image">The <see cref="Image"/> to display.</param>+ /// <param name="disposeAutomatically">Indicates whether the <paramref name="image"/> should be disposed when not displayed in the UI anymore.</param>+ /// <returns>The updated <see cref="IUIImageViewer"/> instance.</returns>public static IUIImageViewer WithImage(this IUIImageViewer element, Image image, bool disposeAutomatically){var imageViewer = (UIImageViewer)element;@@ -141,8 +156,10 @@ public static partial class GUI/// When the user saves the image with the specified <paramref name="fileExtension"/>, the specified <paramref name="action"/> will be invoked/// with a <see cref="FileStream"/> pointing to the file to save. The <paramref name="action"/> is responsible for writing the image to the file./// </remarks>- /// <param name="fileExtension">The file extension to handle</param>+ /// <param name="element">The <see cref="IUIImageViewer"/> instance.</param>+ /// <param name="fileExtension">The file extension to handle.</param>/// <param name="action">The action to perform when the user wishes to save the image with the given <paramref name="fileExtension"/>.</param>+ /// <returns>The updated <see cref="IUIImageViewer"/> instance.</returns>public static IUIImageViewer ManuallyHandleSaveAs(this IUIImageViewer element, string fileExtension, Func<FileStream, ValueTask> action){fileExtension = "." + fileExtension.ToLowerInvariant().Trim().TrimStart('.');@@ -159,7 +176,9 @@ public static partial class GUI/// <summary>/// Removes the custom action to perform when the user saves the image with a specific file extension./// </summary>+ /// <param name="element">The <see cref="IUIImageViewer"/> instance.</param>/// <param name="fileExtension">The file extension to remove.</param>+ /// <returns>The updated <see cref="IUIImageViewer"/> instance.</returns>public static IUIImageViewer RemoveManuallyHandleSaveAs(this IUIImageViewer element, string fileExtension){fileExtension = "." + fileExtension.ToLowerInvariant().Trim().TrimStart('.');@@ -174,6 +193,8 @@ public static partial class GUI/// <summary>/// Clears the value of <see cref="IUIImageViewer.ImageSource"/>./// </summary>+ /// <param name="element">The <see cref="IUIImageViewer"/> instance.</param>+ /// <returns>The updated <see cref="IUIImageViewer"/> instance.</returns>public static IUIImageViewer Clear(this IUIImageViewer element){((UIImageViewer)element).ImageSource = default;diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultiLineTextInput.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultiLineTextInput.csindex fb25905f8..b0e7a866a 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultiLineTextInput.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultiLineTextInput.cs@@ -19,7 +19,7 @@ public interface IUIMultiLineTextInput : IUISingleLineTextInput/// Gets whether the element can be expanded to take the size of the whole tool boundaries. Default is false./// </summary>/// <remarks>- /// When <see cref="IUIMultiLineTextInput.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode.+ /// When <see cref="IUIElement.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode./// </remarks>bool IsExtendableToFullScreen { get; }@@ -189,7 +189,7 @@ public static partial class GUI/// Indicates that the control can be extended to take the size of the whole tool boundaries./// </summary>/// <remarks>- /// When <see cref="IUIMultiLineTextInput.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode.+ /// When <see cref="IUIElement.IsVisible"/> is false and that the element is in full screen mode, the element goes back to normal mode./// </remarks>public static IUIMultiLineTextInput Extendable(this IUIMultiLineTextInput element){diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUINumberInput.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUINumberInput.csindex 1ff416d67..a4b05a7f5 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUINumberInput.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUINumberInput.cs@@ -80,8 +80,12 @@ internal class UINumberInput : UISingleLineTextInput, IUINumberInput{get{- double.TryParse(Text, out double value);- return Math.Min(Math.Max(value, Min), Max);+ if (double.TryParse(Text, out double value))+ {+ return Math.Min(Math.Max(value, Min), Max);+ }++ return Math.Min(Math.Max(0, Min), Max);}}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIProgressBar.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIProgressBar.csindex 169ef33f3..4a9f18cdc 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIProgressBar.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIProgressBar.cs@@ -47,22 +47,30 @@ internal class UIProgressBar : UIElement, IUIProgressBar, IDisposableTimeSpan.FromMilliseconds(10));}+ /// <inheritdoc/>public double Value{get => _value;internal set => SetPropertyValue(ref _value, value, ValueChanged);}+ /// <inheritdoc/>public bool IsIndeterminate{get => _isIndeterminate;internal set => SetPropertyValue(ref _isIndeterminate, value, IsIndeterminateChanged);}+ /// <inheritdoc/>public event EventHandler? ValueChanged;++ /// <inheritdoc/>public event EventHandler<double>? ValueChangingAsynchronously;++ /// <inheritdoc/>public event EventHandler? IsIndeterminateChanged;+ /// <inheritdoc/>public void Dispose(){_asyncProgressReporter.Flush();@@ -85,6 +93,7 @@ public static partial class GUI/// <summary>/// Create a component that indicates the progress of an operation./// </summary>+ /// <returns>The created <see cref="IUIProgressBar"/> instance.</returns>public static IUIProgressBar ProgressBar(){return ProgressBar(null);@@ -94,6 +103,7 @@ public static partial class GUI/// Create a component that indicates the progress of an operation./// </summary>/// <param name="id">An optional unique identifier for this UI element.</param>+ /// <returns>The created <see cref="IUIProgressBar"/> instance.</returns>public static IUIProgressBar ProgressBar(string? id){return new UIProgressBar(id);@@ -103,6 +113,7 @@ public static partial class GUI/// Synchronously set the <see cref="IUIProgressBar.Value"/> property./// </summary>/// <remarks>It is highly recommended to call this method when being on the UI thread.</remarks>+ /// <param name="element">The <see cref="IUIProgressBar"/> instance.</param>/// <param name="percentage">A value between 0 and 100.</param>public static T Progress<T>(this T element, double percentage) where T : IUIProgressBar{@@ -119,6 +130,7 @@ public static partial class GUI/// progress bar's value without blocking the caller./// </summary>/// <remarks>It is highly recommended to call this method when being off the UI thread.</remarks>+ /// <param name="element">The <see cref="IUIProgressBar"/> instance.</param>/// <param name="percentage">A value between 0 and 100.</param>public static ValueTask ProgressAsync<T>(this T element, double percentage) where T : IUIProgressBar{@@ -134,6 +146,7 @@ public static partial class GUI/// <summary>/// Indicates the progress bar should a generic, continuous progress feedback./// </summary>+ /// <param name="element">The <see cref="IUIProgressBar"/> instance.</param>public static T StartIndeterminateProgress<T>(this T element) where T : IUIProgressBar{if (element is UIProgressBar progressBar)@@ -147,6 +160,7 @@ public static partial class GUI/// <summary>/// Indicates the progress bar should show actual values./// </summary>+ /// <param name="element">The <see cref="IUIProgressBar"/> instance.</param>public static T StopIndeterminateProgress<T>(this T element) where T : IUIProgressBar{if (element is UIProgressBar progressBar)diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.csindex 4247d644c..f4398fa83 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs@@ -67,33 +67,44 @@ internal class UISetting : UITitledElementWithChildren, IUISetting}}+ /// <inheritdoc/>public string? Description{get => _description;internal set => SetPropertyValue(ref _description, value, DescriptionChanged);}+ /// <inheritdoc/>public string? StateDescription{get => _stateDescription;internal set => SetPropertyValue(ref _stateDescription, value, StateDescriptionChanged);}+ /// <inheritdoc/>public IUIIcon? Icon{get => _icon;internal set => SetPropertyValue(ref _icon, value, IconChanged);}+ /// <inheritdoc/>public IUIElement? InteractiveElement{get => _interactiveElement;internal set => SetPropertyValue(ref _interactiveElement, value, InteractiveElementChanged);}+ /// <inheritdoc/>public event EventHandler? DescriptionChanged;++ /// <inheritdoc/>public event EventHandler? StateDescriptionChanged;++ /// <inheritdoc/>public event EventHandler? IconChanged;++ /// <inheritdoc/>public event EventHandler? InteractiveElementChanged;}@@ -102,6 +113,7 @@ public static partial class GUI/// <summary>/// A component that represents a setting, with a title, description, icon and <see cref="IUIElement"/> for the option value./// </summary>+ /// <returns>The created <see cref="IUISetting"/> instance.</returns>public static IUISetting Setting(){return Setting(null);@@ -111,6 +123,7 @@ public static partial class GUI/// A component that represents a setting, with a title, description, icon and <see cref="IUIElement"/> for the option value./// </summary>/// <param name="id">An optional unique identifier for this UI element.</param>+ /// <returns>The created <see cref="IUISetting"/> instance.</returns>public static IUISetting Setting(string? id){return new UISetting(id);@@ -119,6 +132,9 @@ public static partial class GUI/// <summary>/// Sets the <see cref="IUISetting.Description"/> of the setting./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>+ /// <param name="text">The description text.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting Description(this IUISetting element, string? text){((UISetting)element).Description = text;@@ -128,6 +144,9 @@ public static partial class GUI/// <summary>/// Sets the <see cref="IUISetting.StateDescription"/> of the setting./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>+ /// <param name="text">The state description text.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting StateDescription(this IUISetting element, string? text){((UISetting)element).StateDescription = text;@@ -137,6 +156,10 @@ public static partial class GUI/// <summary>/// Sets the <see cref="IUISetting.Icon"/> of the setting./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>+ /// <param name="fontName">The font name of the icon.</param>+ /// <param name="glyph">The glyph of the icon.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting Icon(this IUISetting element, string fontName, char glyph){((UISetting)element).Icon = Icon(fontName, glyph);@@ -146,6 +169,9 @@ public static partial class GUI/// <summary>/// Sets the <see cref="IUISetting.InteractiveElement"/> of the setting./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>+ /// <param name="uiElement">The interactive UI element.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting InteractiveElement(this IUISetting element, IUIElement? uiElement){((UISetting)element).InteractiveElement = uiElement;@@ -156,9 +182,11 @@ public static partial class GUI/// Sets a <see cref="IUISwitch"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>- /// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>- /// <param name="onToggled">(optional) A method to invoke when the setting value changed.</param>+ /// <param name="settingDefinition">The definition of the setting to associate with this <see cref="IUISetting"/>.</param>+ /// <param name="onToggled">(optional) A method to invoke when the setting value changes.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting Handle(this IUISetting element,ISettingsProvider settingsProvider,@@ -179,9 +207,11 @@ public static partial class GUI/// Sets a <see cref="IUISwitch"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>- /// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>- /// <param name="onToggled">(optional) A method to invoke when the setting value changed.</param>+ /// <param name="settingDefinition">The definition of the setting to associate with this <see cref="IUISetting"/>.</param>+ /// <param name="onToggled">(optional) A method to invoke when the setting value changes.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting Handle(this IUISetting element,ISettingsProvider settingsProvider,@@ -206,11 +236,13 @@ public static partial class GUI/// Sets a <see cref="IUISwitch"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>/// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>/// <param name="stateDescriptionWhenOn">The <see cref="IUISetting.StateDescription"/> to use when the option is On.</param>/// <param name="stateDescriptionWhenOff">The <see cref="IUISetting.StateDescription"/> to use when the option is Off.</param>/// <param name="onToggled">(optional) A method to invoke when the setting value changed.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting Handle(this IUISetting element,ISettingsProvider settingsProvider,@@ -233,11 +265,13 @@ public static partial class GUI/// Sets a <see cref="IUISwitch"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>/// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>/// <param name="stateDescriptionWhenOn">The <see cref="IUISetting.StateDescription"/> to use when the option is On.</param>/// <param name="stateDescriptionWhenOff">The <see cref="IUISetting.StateDescription"/> to use when the option is Off.</param>/// <param name="onToggled">(optional) A method to invoke when the setting value changed.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting Handle(this IUISetting element,ISettingsProvider settingsProvider,@@ -264,10 +298,12 @@ public static partial class GUI/// Sets a <see cref="IUISelectDropDownList"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>/// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>/// <param name="onOptionSelected">(optional) A method to invoke when the setting value changed.</param>/// <param name="dropDownListItems">(optional) A list of items to be displayed in the drop down list. <see cref="IUIDropDownListItem.Value"/> should be of type <typeparamref name="T"/>.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting Handle<T>(this IUISetting element,ISettingsProvider settingsProvider,@@ -291,10 +327,12 @@ public static partial class GUI/// Sets a <see cref="IUISelectDropDownList"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <param name="element">The <see cref="IUISetting"/> instance.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>/// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>/// <param name="onOptionSelected">(optional) A method to invoke when the setting value changed.</param>/// <param name="dropDownListItems">(optional) A list of items to be displayed in the drop down list. <see cref="IUIDropDownListItem.Value"/> should be of type <typeparamref name="T"/>.</param>+ /// <returns>The updated <see cref="IUISetting"/> instance.</returns>public static IUISetting Handle<T>(this IUISetting element,ISettingsProvider settingsProvider,diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.csindex 6f9f7e3d6..715c6df7b 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs@@ -50,14 +50,17 @@ internal sealed class UISettingGroup : UISetting, IUISettingGroup}}+ /// <inheritdoc/>public IUIElement[]? Children{get => _children;internal set => SetPropertyValue(ref _children, value, ChildrenChanged);}+ /// <inheritdoc/>public bool ChildrenAreAllSettings { get; internal set; }+ /// <inheritdoc/>public event EventHandler? ChildrenChanged;}@@ -81,17 +84,24 @@ public static partial class GUI}/// <summary>- /// Sets the <see cref="IUISettingGroup.Description"/> of the setting.+ /// Sets the <see cref="IUISetting.Description"/> of the setting./// </summary>- public static IUISettingGroup Description(this IUISettingGroup element, string? text)+ /// <param name="element">The <see cref="IUISettingGroup"/> element.</param>+ /// <param name="description">The description.</param>+ /// <returns>The updated <see cref="IUISettingGroup"/> element.</returns>+ public static IUISettingGroup Description(this IUISettingGroup element, string? description){- ((UISettingGroup)element).Description = text;+ ((UISettingGroup)element).Description = description;return element;}/// <summary>- /// Sets the <see cref="IUISettingGroup.Icon"/> of the setting.+ /// Sets the <see cref="IUISetting.Icon"/> of the setting./// </summary>+ /// <param name="element">The <see cref="IUISettingGroup"/> element.</param>+ /// <param name="fontName">The font name.</param>+ /// <param name="glyph">The glyph character.</param>+ /// <returns>The updated <see cref="IUISettingGroup"/> element.</returns>public static IUISettingGroup Icon(this IUISettingGroup element, string fontName, char glyph){((UISettingGroup)element).Icon = Icon(fontName, glyph);@@ -99,8 +109,11 @@ public static partial class GUI}/// <summary>- /// Sets the <see cref="IUISettingGroup.InteractiveElement"/> of the setting.+ /// Sets the <see cref="IUISetting.InteractiveElement"/> of the setting./// </summary>+ /// <param name="element">The <see cref="IUISettingGroup"/> element.</param>+ /// <param name="uiElement">The interactive UI element.</param>+ /// <returns>The updated <see cref="IUISettingGroup"/> element.</returns>public static IUISettingGroup InteractiveElement(this IUISettingGroup element, IUIElement? uiElement){((UISettingGroup)element).InteractiveElement = uiElement;@@ -108,12 +121,14 @@ public static partial class GUI}/// <summary>- /// Sets a <see cref="IUISwitch"/> to <see cref="IUISettingGroup.InteractiveElement"/> and automatically associate the+ /// Sets a <see cref="IUISwitch"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <param name="element">The <see cref="IUISettingGroup"/> element.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>/// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISettingGroup"/>.</param>/// <param name="onToggled">(optional) A method to invoke when the setting value changed.</param>+ /// <returns>The updated <see cref="IUISettingGroup"/> element.</returns>public static IUISettingGroup Handle(this IUISettingGroup element,ISettingsProvider settingsProvider,@@ -127,10 +142,13 @@ public static partial class GUI/// Sets a <see cref="IUISelectDropDownList"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <typeparam name="T">The type of the setting value.</typeparam>+ /// <param name="element">The <see cref="IUISettingGroup"/> element.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>/// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>/// <param name="onOptionSelected">(optional) A method to invoke when the setting value changed.</param>/// <param name="dropDownListItems">(optional) A list of items to be displayed in the drop down list. <see cref="IUIDropDownListItem.Value"/> should be of type <typeparamref name="T"/>.</param>+ /// <returns>The updated <see cref="IUISettingGroup"/> element.</returns>public static IUISettingGroup Handle<T>(this IUISettingGroup element,ISettingsProvider settingsProvider,@@ -143,12 +161,14 @@ public static partial class GUI}/// <summary>- /// Sets a <see cref="IUISwitch"/> to <see cref="IUISettingGroup.InteractiveElement"/> and automatically associate the+ /// Sets a <see cref="IUISwitch"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <param name="element">The <see cref="IUISettingGroup"/> element.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>/// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISettingGroup"/>.</param>/// <param name="onToggled">(optional) A method to invoke when the setting value changed.</param>+ /// <returns>The updated <see cref="IUISettingGroup"/> element.</returns>public static IUISettingGroup Handle(this IUISettingGroup element,ISettingsProvider settingsProvider,@@ -166,10 +186,13 @@ public static partial class GUI/// Sets a <see cref="IUISelectDropDownList"/> to <see cref="IUISetting.InteractiveElement"/> and automatically associate the/// given <paramref name="settingDefinition"/> to the switch state./// </summary>+ /// <typeparam name="T">The type of the setting value.</typeparam>+ /// <param name="element">The <see cref="IUISettingGroup"/> element.</param>/// <param name="settingsProvider">The settings provider used for handling the given <paramref name="settingDefinition"/>.</param>/// <param name="settingDefinition">The definition of the setting to associate to this <see cref="IUISetting"/>.</param>/// <param name="onOptionSelected">(optional) A method to invoke when the setting value changed.</param>/// <param name="dropDownListItems">(optional) A list of items to be displayed in the drop down list. <see cref="IUIDropDownListItem.Value"/> should be of type <typeparamref name="T"/>.</param>+ /// <returns>The updated <see cref="IUISettingGroup"/> element.</returns>public static IUISettingGroup Handle<T>(this IUISettingGroup element,ISettingsProvider settingsProvider,@@ -188,6 +211,9 @@ public static partial class GUI/// <summary>/// Sets the children to be displayed in the group./// </summary>+ /// <param name="element">The <see cref="IUISettingGroup"/> element.</param>+ /// <param name="children">The child elements.</param>+ /// <returns>The updated <see cref="IUISettingGroup"/> element.</returns>public static IUISettingGroup WithChildren(this IUISettingGroup element, params IUIElement[] children){var settingGroup = (UISettingGroup)element;@@ -199,6 +225,9 @@ public static partial class GUI/// <summary>/// Sets the children to be displayed in the group./// </summary>+ /// <param name="element">The <see cref="IUISettingGroup"/> element.</param>+ /// <param name="settings">The settings to be displayed in the group.</param>+ /// <returns>The updated <see cref="IUISettingGroup"/> element.</returns>public static IUISettingGroup WithSettings(this IUISettingGroup element, params IUISetting[] settings){var settingGroup = (UISettingGroup)element;diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIDialog.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIDialog.csindex e9f634136..a0140bf22 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIDialog.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIDialog.cs@@ -1,14 +1,28 @@namespace DevToys.Api;+/// <summary>+/// Represents a modal dialog.+/// </summary>public sealed class UIDialog : IDisposable{private readonly TaskCompletionSource _dialogCloseCompletionSource = new();+ /// <summary>+ /// Initializes a new instance of the <see cref="UIDialog"/> class with the specified dialog content and dismissible flag.+ /// </summary>+ /// <param name="dialogContent">The dialog content.</param>+ /// <param name="isDismissible">A flag indicating whether the dialog can be closed by clicking outside of it.</param>internal UIDialog(IUIElement dialogContent, bool isDismissible): this(dialogContent, null, isDismissible){}+ /// <summary>+ /// Initializes a new instance of the <see cref="UIDialog"/> class with the specified dialog content, footer content, and dismissible flag.+ /// </summary>+ /// <param name="dialogContent">The dialog content.</param>+ /// <param name="footerContent">The footer content.</param>+ /// <param name="isDismissible">A flag indicating whether the dialog can be closed by clicking outside of it.</param>internal UIDialog(IUIElement dialogContent, IUIElement? footerContent, bool isDismissible){DialogContent = dialogContent;@@ -18,18 +32,39 @@ public sealed class UIDialog : IDisposableDialogCloseAwaiter = _dialogCloseCompletionSource.Task;}+ /// <summary>+ /// Gets a value indicating whether the dialog is opened.+ /// </summary>public bool IsOpened { get; private set; }+ /// <summary>+ /// Gets a value indicating whether the dialog can be closed by clicking outside of it, pressing Escape key, or losing focus.+ /// </summary>public bool IsDismissible { get; }+ /// <summary>+ /// Gets the dialog content.+ /// </summary>public IUIElement? DialogContent { get; }+ /// <summary>+ /// Gets the footer content.+ /// </summary>public IUIElement? FooterContent { get; }+ /// <summary>+ /// Gets the task that completes when the dialog closes.+ /// </summary>public Task DialogCloseAwaiter { get; }+ /// <summary>+ /// Occurs when the <see cref="IsOpened"/> property changes.+ /// </summary>public event EventHandler? IsOpenedChanged;+ /// <summary>+ /// Closes the dialog.+ /// </summary>public void Close(){IsOpened = false;@@ -37,6 +72,9 @@ public sealed class UIDialog : IDisposable_dialogCloseCompletionSource.TrySetResult();}+ /// <summary>+ /// Disposes the dialog.+ /// </summary>public void Dispose(){Close();diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridLength.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridLength.csindex 85de656ec..22576a588 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridLength.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridLength.cs@@ -1,5 +1,8 @@namespace DevToys.Api;+/// <summary>+/// Represents the length of a row or column.+/// </summary>[DebuggerDisplay($"{{{nameof(ToString)}}}")]public readonly struct UIGridLength : IEquatable<UIGridLength>{@@ -135,6 +138,10 @@ public readonly struct UIGridLength : IEquatable<UIGridLength>return _value.GetHashCode() ^ _type.GetHashCode();}+ /// <summary>+ /// Returns a string that represents the current <see cref="UIGridLength"/>.+ /// </summary>+ /// <returns>A string that represents the current <see cref="UIGridLength"/>.</returns>public override string ToString(){if (IsAuto)diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridUnitType.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridUnitType.csindex 38460d085..cfbc6a473 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridUnitType.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridUnitType.cs@@ -1,5 +1,8 @@namespace DevToys.Api;+/// <summary>+/// Represents the unit type of a row or column.+/// </summary>public enum UIGridUnitType{/// <summary>diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHighlightedTextSpan.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHighlightedTextSpan.csindex 7241ea004..b04110112 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHighlightedTextSpan.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHighlightedTextSpan.cs@@ -1,13 +1,27 @@namespace DevToys.Api;+/// <summary>+/// Represents a highlighted span in a text.+/// </summary>public record UIHighlightedTextSpan : TextSpan{+ /// <summary>+ /// Initializes a new instance of the <see cref="UIHighlightedTextSpan"/> class.+ /// </summary>+ /// <param name="startPosition">The start position of the highlighted text span.</param>+ /// <param name="length">The length of the highlighted text span.</param>+ /// <param name="color">The color of the highlighted text span.</param>public UIHighlightedTextSpan(int startPosition, int length, UIHighlightedTextSpanColor color = UIHighlightedTextSpanColor.Default): base(startPosition, length){Color = color;}+ /// <summary>+ /// Initializes a new instance of the <see cref="UIHighlightedTextSpan"/> class based on the original <see cref="TextSpan"/>.+ /// </summary>+ /// <param name="original">The original <see cref="TextSpan"/>.</param>+ /// <param name="color">The color of the highlighted text span.</param>protected UIHighlightedTextSpan(TextSpan original, UIHighlightedTextSpanColor color = UIHighlightedTextSpanColor.Default): base(original){diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHighlightedTextSpanColor.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHighlightedTextSpanColor.csindex 56e4cf35a..904a155dc 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHighlightedTextSpanColor.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHighlightedTextSpanColor.cs@@ -1,12 +1,42 @@namespace DevToys.Api;+/// <summary>+/// Represents the color options for a highlighted text span in the UI.+/// </summary>public enum UIHighlightedTextSpanColor{+ /// <summary>+ /// The default color.+ /// </summary>Default,++ /// <summary>+ /// The blue color.+ /// </summary>Blue,++ /// <summary>+ /// The green color.+ /// </summary>Green,++ /// <summary>+ /// The red color.+ /// </summary>Red,++ /// <summary>+ /// The yellow color.+ /// </summary>Yellow,++ /// <summary>+ /// The purple color.+ /// </summary>Purple,++ /// <summary>+ /// The teal color.+ /// </summary>Teal}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIInfoBarSeverity.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIInfoBarSeverity.csindex e059c9def..3fc8e4bd4 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIInfoBarSeverity.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIInfoBarSeverity.cs@@ -1,9 +1,27 @@namespace DevToys.Api;+/// <summary>+/// Represents the severity level of a <see cref="IUIInfoBar"/>.+/// </summary>public enum UIInfoBarSeverity{+ /// <summary>+ /// Informational severity.+ /// </summary>Informational,++ /// <summary>+ /// Error severity.+ /// </summary>Error,++ /// <summary>+ /// Success severity.+ /// </summary>Success,++ /// <summary>+ /// Warning severity.+ /// </summary>Warning}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UILabelStyle.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UILabelStyle.csindex bb3350364..056f043d5 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UILabelStyle.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UILabelStyle.cs@@ -1,13 +1,47 @@namespace DevToys.Api;+/// <summary>+/// Represents the style of a <see cref="IUILabel"/>.+/// </summary>public enum UILabelStyle{+ /// <summary>+ /// The caption style.+ /// </summary>Caption,++ /// <summary>+ /// The body style.+ /// </summary>Body,++ /// <summary>+ /// The strong body style.+ /// </summary>BodyStrong,++ /// <summary>+ /// The large body style.+ /// </summary>BodyLarge,++ /// <summary>+ /// The subtitle style.+ /// </summary>Subtitle,++ /// <summary>+ /// The title style.+ /// </summary>Title,++ /// <summary>+ /// The large title style.+ /// </summary>TitleLarge,++ /// <summary>+ /// The display style.+ /// </summary>Display}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.csindex 77bb58c36..c8f8a2654 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.cs@@ -33,7 +33,6 @@ public class UIToolView : INotifyPropertyChanged/// Creates a new instance of the <see cref="UIToolView"/> class./// </summary>/// <param name="isScrollable">Indicates whether the UI of the tool is scrollable or should fits to the window boundaries.</param>- /// <param name="rootElement">The root element of the tool's UI.</param>public UIToolView(bool isScrollable): this(isScrollable, null){@@ -92,6 +91,9 @@ public class UIToolView : INotifyPropertyChanged/// </summary>public event EventHandler? RootElementChanged;+ /// <summary>+ /// Raised when a property value changes.+ /// </summary>public event PropertyChangedEventHandler? PropertyChanged;/// <summary>@@ -159,6 +161,14 @@ public class UIToolView : INotifyPropertyChanged}}+ /// <summary>+ /// Sets the property value and raises the property changed event if the value has changed.+ /// </summary>+ /// <typeparam name="T">The type of the property.</typeparam>+ /// <param name="field">The reference to the field storing the property value.</param>+ /// <param name="value">The new value to set.</param>+ /// <param name="propertyChangedEventHandler">The event handler to raise the property changed event.</param>+ /// <param name="propertyName">The name of the property. Automatically inferred if not provided.</param>protected void SetPropertyValue<T>(ref T field,T value,@@ -173,6 +183,10 @@ public class UIToolView : INotifyPropertyChanged}}+ /// <summary>+ /// Raises the property changed event for the specified property.+ /// </summary>+ /// <param name="propertyName">The name of the property. Automatically inferred if not provided.</param>protected void OnPropertyChanged([CallerMemberName] string? propertyName = null){PropertyChanged?.Invoke(this, new(propertyName));diff --git a/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.cs b/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.csindex b0f613e08..9dddb0d94 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.cs@@ -54,7 +54,7 @@ public interface IGuiTool/// The expected behavior of this method is to pass the <paramref name="parsedData"/> to the <see cref="IUIElement"/>/// that fits the given data./// </summary>- /// <param name="dataTypeName">The data type name, as defined by <see cref="AcceptedDataTypeNameAttribute"/>.<param>+ /// <param name="dataTypeName">The data type name, as defined by <see cref="AcceptedDataTypeNameAttribute"/>.</param>/// <param name="parsedData">The data returned by the corresponding <see cref="IDataTypeDetector"/>.</param>void OnDataReceived(string dataTypeName, object? parsedData);}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/PredefinedCommonToolGroupNames.cs b/src/app/dev/DevToys.Api/Tool/GUI/PredefinedCommonToolGroupNames.csindex e3c4547c5..235a7a258 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/PredefinedCommonToolGroupNames.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/PredefinedCommonToolGroupNames.cs@@ -1,12 +1,42 @@namespace DevToys.Api;+/// <summary>+/// Represents the predefined common tool group names.+/// </summary>public static class PredefinedCommonToolGroupNames{+ /// <summary>+ /// Represents the tool group for encoders and decoders.+ /// </summary>public const string EncodersDecoders = "Encoders / Decoders";++ /// <summary>+ /// Represents the tool group for converters.+ /// </summary>public const string Converters = "Converters";++ /// <summary>+ /// Represents the tool group for formatters.+ /// </summary>public const string Formatters = "Formatters";++ /// <summary>+ /// Represents the tool group for generators.+ /// </summary>public const string Generators = "Generators";++ /// <summary>+ /// Represents the tool group for graphics.+ /// </summary>public const string Graphic = "Graphic";++ /// <summary>+ /// Represents the tool group for testers.+ /// </summary>public const string Testers = "Testers";++ /// <summary>+ /// Represents the tool group for text.+ /// </summary>public const string Text = "Text";}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/PredefinedSupportedImageFormats.cs b/src/app/dev/DevToys.Api/Tool/GUI/PredefinedSupportedImageFormats.csindex bd215cac9..aeeb3107b 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/PredefinedSupportedImageFormats.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/PredefinedSupportedImageFormats.cs@@ -1,5 +1,8 @@namespace DevToys.Api;+/// <summary>+/// Represents a predefined list of supported image formats.+/// </summary>public static class PredefinedSupportedImageFormats{/// <summary>diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/AcceptedDataTypeNameAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/AcceptedDataTypeNameAttribute.csindex 210c52750..e63a8fc30 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/AcceptedDataTypeNameAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/AcceptedDataTypeNameAttribute.cs@@ -9,8 +9,15 @@[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]public sealed class AcceptedDataTypeNameAttribute : Attribute{+ /// <summary>+ /// Gets the name of the accepted data type.+ /// </summary>public string DataTypeName { get; }+ /// <summary>+ /// Initializes a new instance of the <see cref="AcceptedDataTypeNameAttribute"/> class.+ /// </summary>+ /// <param name="name">The name of the accepted data type.</param>public AcceptedDataTypeNameAttribute(string name){Guard.IsNotEmpty(name);diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/CommandLineOptionAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/CommandLineOptionAttribute.csindex 37d318353..e51295c88 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/CommandLineOptionAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/CommandLineOptionAttribute.cs@@ -9,7 +9,7 @@ public sealed class CommandLineOptionAttribute : CommandNameAttribute{/// <summary>/// Gets the name of the option. Example, "file".- /// Implicitly, an option named "file" will be usable in a command line through "--file <value>".+ /// Implicitly, an option named "file" will be usable in a command line through "--file <value>"./// </summary>public new string Name{@@ -19,7 +19,7 @@ public sealed class CommandLineOptionAttribute : CommandNameAttribute/// <summary>/// Gets or sets the alias name of the option. Example, "f".- /// Implicitly, an option named "f" will be usable in a command line through "-f <value>".+ /// Implicitly, an option named "f" will be usable in a command line through "-f <value>"./// </summary>public new string Alias{diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/DataTypeNameAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/DataTypeNameAttribute.csindex ce44e271f..e8860e040 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/DataTypeNameAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/DataTypeNameAttribute.cs@@ -7,10 +7,21 @@[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]public sealed class DataTypeNameAttribute : Attribute{+ /// <summary>+ /// Gets the data type name.+ /// </summary>public string DataTypeName { get; }+ /// <summary>+ /// Gets the data type base name.+ /// </summary>public string? DataTypeBaseName { get; }+ /// <summary>+ /// Initializes a new instance of the <see cref="DataTypeNameAttribute"/> class.+ /// </summary>+ /// <param name="name">The data type name.</param>+ /// <param name="baseName">The data type base name.</param>public DataTypeNameAttribute(string name, string? baseName = null){Guard.IsNotEmpty(name);diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/MenuPlacement.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/MenuPlacement.csindex cb1aa8a57..aaba32f88 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/MenuPlacement.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/MenuPlacement.cs@@ -1,7 +1,17 @@namespace DevToys.Api;+/// <summary>+/// Represents the placement of a menu.+/// </summary>public enum MenuPlacement{+ /// <summary>+ /// The menu is placed in the body.+ /// </summary>Body,++ /// <summary>+ /// The menu is placed in the footer.+ /// </summary>Footer}diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/MenuPlacementAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/MenuPlacementAttribute.csindex a11b26946..35adf581c 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/MenuPlacementAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/MenuPlacementAttribute.cs@@ -7,8 +7,15 @@[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]public sealed class MenuPlacementAttribute : Attribute{+ /// <summary>+ /// Gets the menu placement for the <see cref="IGuiTool"/>.+ /// </summary>public MenuPlacement MenuPlacement { get; }+ /// <summary>+ /// Initializes a new instance of the <see cref="MenuPlacementAttribute"/> class with the specified menu placement.+ /// </summary>+ /// <param name="menuPlacement">The menu placement for the <see cref="IGuiTool"/>.</param>public MenuPlacementAttribute(MenuPlacement menuPlacement){MenuPlacement = menuPlacement;diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NameAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NameAttribute.csindex ee2c97c1f..741bb0825 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NameAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NameAttribute.cs@@ -7,8 +7,15 @@[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]public sealed class NameAttribute : Attribute{+ /// <summary>+ /// Gets the internal name of this component.+ /// </summary>public string InternalComponentName { get; }+ /// <summary>+ /// Initializes a new instance of the <see cref="NameAttribute"/> class with the specified internal component name.+ /// </summary>+ /// <param name="internalComponentName">The internal name of the component.</param>public NameAttribute(string internalComponentName){Guard.IsNotEmpty(internalComponentName);diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NoCompactOverlaySupportAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NoCompactOverlaySupportAttribute.csindex e8514eccd..f622a8c88 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NoCompactOverlaySupportAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NoCompactOverlaySupportAttribute.cs@@ -7,5 +7,8 @@[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]public sealed class NoCompactOverlaySupportAttribute : Attribute{+ /// <summary>+ /// Gets a value indicating whether the <see cref="IGuiTool"/> supports Compact Overlay mode.+ /// </summary>public bool NoCompactOverlaySupport { get; } = true;}diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NotFavorableAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NotFavorableAttribute.csindex 8e5910e03..f671b6c0e 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NotFavorableAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NotFavorableAttribute.cs@@ -7,5 +7,8 @@[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]public sealed class NotFavorableAttribute : Attribute{+ /// <summary>+ /// Gets a value indicating whether the <see cref="IGuiTool"/> is not favorable.+ /// </summary>public bool NotFavorable { get; } = true;}diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NotSearchableAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NotSearchableAttribute.csindex 9371dea95..c7f969f29 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NotSearchableAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/NotSearchableAttribute.cs@@ -7,5 +7,8 @@[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]public sealed class NotSearchableAttribute : Attribute{+ /// <summary>+ /// Gets a value indicating whether the <see cref="IGuiTool"/> is not searchable.+ /// </summary>public bool NotSearchable { get; } = true;}diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/Platform.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/Platform.csindex 07cedc750..9128de6af 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/Platform.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/Platform.cs@@ -1,9 +1,27 @@namespace DevToys.Api;+/// <summary>+/// Represents the platform on which the application runs.+/// </summary>public enum Platform{+ /// <summary>+ /// The Windows platform.+ /// </summary>Windows,- MacCatalyst,++ /// <summary>+ /// The MacOS or MacCatalyst platform.+ /// </summary>+ MacOS,++ /// <summary>+ /// The Linux platform.+ /// </summary>Linux,++ /// <summary>+ /// The WebAssembly platform.+ /// </summary>WASM}diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/TargetPlatformAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/TargetPlatformAttribute.csindex c6d60ccbb..73188ecc5 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/TargetPlatformAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/TargetPlatformAttribute.cs@@ -7,8 +7,15 @@[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]public sealed class TargetPlatformAttribute : Attribute{+ /// <summary>+ /// Gets the target platform.+ /// </summary>public Platform TargetPlatform { get; }+ /// <summary>+ /// Initializes a new instance of the <see cref="TargetPlatformAttribute"/> class.+ /// </summary>+ /// <param name="platform">The target platform.</param>public TargetPlatformAttribute(Platform platform){TargetPlatform = platform;diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Metadata/IOrderableMetadata.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Metadata/IOrderableMetadata.csindex 6033a4bab..a4e99d96c 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Metadata/IOrderableMetadata.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Metadata/IOrderableMetadata.cs@@ -1,10 +1,22 @@namespace DevToys.Api;+/// <summary>+/// Represents an orderable component.+/// </summary>public interface IOrderableMetadata{+ /// <summary>+ /// Gets the list of items that should come before this component.+ /// </summary>IReadOnlyList<string> Before { get; }+ /// <summary>+ /// Gets the list of items that should come after this component.+ /// </summary>IReadOnlyList<string> After { get; }+ /// <summary>+ /// Gets the internal component name.+ /// </summary>string InternalComponentName { get; }}diff --git a/src/app/dev/DevToys.Api/Tool/SmartDetection/DataDetectionResult.cs b/src/app/dev/DevToys.Api/Tool/SmartDetection/DataDetectionResult.csindex 58ae41262..98bfa7163 100644--- a/src/app/dev/DevToys.Api/Tool/SmartDetection/DataDetectionResult.cs+++ b/src/app/dev/DevToys.Api/Tool/SmartDetection/DataDetectionResult.cs@@ -1,8 +1,29 @@namespace DevToys.Api;+/// <summary>+/// Represents the result of data detection.+/// </summary>+/// <param name="Success">A value indicating whether the data detection was successful.</param>+/// <param name="Data">The detected data.</param>public record DataDetectionResult(bool Success, object? Data){- public static readonly DataDetectionResult Unsuccessful = new(false, null);+ /// <summary>+ /// Gets a value indicating whether the data detection was successful.+ /// </summary>+ public bool Success { get; init; } = Success;++ /// <summary>+ /// Gets the detected data.+ /// </summary>+ public object? Data { get; init; } = Data;+ /// <summary>+ /// Gets the type of the detected data.+ /// </summary>public Type? DataType => Data?.GetType();++ /// <summary>+ /// Represents an unsuccessful data detection result.+ /// </summary>+ public static readonly DataDetectionResult Unsuccessful = new(false, null);}diff --git a/src/app/dev/DevToys.Api/Tool/SmartDetection/IDataTypeDetector.cs b/src/app/dev/DevToys.Api/Tool/SmartDetection/IDataTypeDetector.csindex 7b1cd148c..f26d4afb1 100644--- a/src/app/dev/DevToys.Api/Tool/SmartDetection/IDataTypeDetector.cs+++ b/src/app/dev/DevToys.Api/Tool/SmartDetection/IDataTypeDetector.cs@@ -19,7 +19,7 @@public interface IDataTypeDetector{/// <summary>- /// Tries to detect whether the given <paramref name="data"/> match the expected format known by this+ /// Tries to detect whether the given <paramref name="rawData"/> match the expected format known by this/// <see cref="IDataTypeDetector"/>, often by trying to reading and/or parsing it./// </summary>/// <remarks>@@ -34,6 +34,7 @@ public interface IDataTypeDetector/// <param name="rawData">The data to analyze, often coming from the OS's clipboard.</param>/// <param name="resultFromBaseDetector">The result coming from the <see cref="IDataTypeDetector"/> corresponding to the given <see cref="DataTypeNameAttribute.DataTypeBaseName"/>./// Since, the <see cref="DataTypeNameAttribute.DataTypeBaseName"/> is optional, this parameter can be null.</param>+ /// <param name="cancellationToken">A <see cref="CancellationToken"/> that gets canceled within 2 seconds.</param>/// <returns>/// Returns a <see cref="DataDetectionResult"/> that indicates whether the data could be analyzed / parsed / read/// correctly, along with the parsed data, if any change has been made to it during parsing (for example, string todiff --git a/src/app/dev/DevToys.Api/Tool/SmartDetection/PredefinedCommonDataTypeNames.cs b/src/app/dev/DevToys.Api/Tool/SmartDetection/PredefinedCommonDataTypeNames.csindex de3ab80dd..298918944 100644--- a/src/app/dev/DevToys.Api/Tool/SmartDetection/PredefinedCommonDataTypeNames.cs+++ b/src/app/dev/DevToys.Api/Tool/SmartDetection/PredefinedCommonDataTypeNames.cs@@ -1,19 +1,77 @@namespace DevToys.Api;+/// <summary>+/// Predefined common data type names.+/// </summary>public static class PredefinedCommonDataTypeNames{+ /// <summary>+ /// Represents the text data type.+ /// </summary>public const string Text = "text";++ /// <summary>+ /// Represents the JSON data type.+ /// </summary>public const string Json = "json";++ /// <summary>+ /// Represents the JSON array data type.+ /// </summary>public const string JsonArray = "jsonArray";++ /// <summary>+ /// Represents the YAML data type.+ /// </summary>public const string Yaml = "yaml";++ /// <summary>+ /// Represents the XML data type.+ /// </summary>public const string Xml = "xml";++ /// <summary>+ /// Represents the XSD data type.+ /// </summary>public const string Xsd = "xsd";++ /// <summary>+ /// Represents the Base64 text data type.+ /// </summary>public const string Base64Text = "base64Text";++ /// <summary>+ /// Represents the Base64 image data type.+ /// </summary>public const string Base64Image = "base64Image";++ /// <summary>+ /// Represents the "mage data type.+ /// </summary>public const string Image = "image";++ /// <summary>+ /// Represents the image file data type.+ /// </summary>public const string ImageFile = "imageFile";++ /// <summary>+ /// Represents the file data type.+ /// </summary>public const string File = "file";++ /// <summary>+ /// Represents the files data type.+ /// </summary>public const string Files = "files";++ /// <summary>+ /// Represents the GZIP data type.+ /// </summary>public const string GZip = "gzip";++ /// <summary>+ /// Represents the date data type.+ /// </summary>public const string Date = "date";}diff --git a/src/app/dev/DevToys.Blazor/BuiltInTools/ExtensionsManager/ExtensionsManagerGuiTool.cs b/src/app/dev/DevToys.Blazor/BuiltInTools/ExtensionsManager/ExtensionsManagerGuiTool.csindex be0f29dd5..4d81c4742 100644--- a/src/app/dev/DevToys.Blazor/BuiltInTools/ExtensionsManager/ExtensionsManagerGuiTool.cs+++ b/src/app/dev/DevToys.Blazor/BuiltInTools/ExtensionsManager/ExtensionsManagerGuiTool.cs@@ -22,7 +22,7 @@ namespace DevToys.Blazor.BuiltInTools.ExtensionsManager;[Order(Before = SettingsGuiTool.SettingsInternalToolName)][TargetPlatform(Platform.Windows)][TargetPlatform(Platform.Linux)]-[TargetPlatform(Platform.MacCatalyst)]+[TargetPlatform(Platform.MacOS)]internal sealed class ExtensionsManagerGuiTool : IGuiTool{internal const string ExtensionmanagerToolName = "Extensions Manager";diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.cs b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.csindex 7a74a77f2..ce9bb4515 100644--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.cs@@ -50,7 +50,7 @@ public partial class ComboBox<TElement> : SelectBase<TElement> where TElement :}}- private void OpenDropDown(MouseEventArgs ev)+ private void OpenDropDown(MouseEventArgs _){if (IsActuallyEnabled && ContextMenuService.TryOpenContextMenu()){@@ -70,7 +70,7 @@ public partial class ComboBox<TElement> : SelectBase<TElement> where TElement :}}- private void CloseDropDown(MouseEventArgs? ev)+ private void CloseDropDown(MouseEventArgs? __){ContextMenuService.CloseContextMenuRequested -= ContextMenuService_CloseContextMenuRequested;ContextMenuService.CloseContextMenu();diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownButton/DropDownButton.razor.cs b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownButton/DropDownButton.razor.csindex 00e806fe0..6b8c7103a 100644--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownButton/DropDownButton.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownButton/DropDownButton.razor.cs@@ -90,7 +90,7 @@ public partial class DropDownButton<TItem> : StyledComponentBase, IDisposable wh}}- private void OpenDropDown(MouseEventArgs ev)+ private void OpenDropDown(MouseEventArgs _){if (IsActuallyEnabled && ContextMenuService.TryOpenContextMenu()){@@ -100,7 +100,7 @@ public partial class DropDownButton<TItem> : StyledComponentBase, IDisposable wh}}- private void CloseDropDown(MouseEventArgs? ev)+ private void CloseDropDown(MouseEventArgs? _){ContextMenuService.CloseContextMenuRequested -= ContextMenuService_CloseContextMenuRequested;ContextMenuService.CloseContextMenu();@@ -116,7 +116,7 @@ public partial class DropDownButton<TItem> : StyledComponentBase, IDisposable wh}}- private void OnDropDowlListItemSelected(int itemIndex)+ private void OnDropDowlListItemSelected(int _){if (_listBox is not null && _listBox.SelectedItem is not null && _listBox.SelectedItem.IsEnabled){diff --git a/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor.cs b/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor.csindex cb2acf78a..0553f211c 100644--- a/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor.cs@@ -88,7 +88,7 @@ public partial class ContextMenu : StyledComponentBase}}- private async Task CloseMenuAsync(MouseEventArgs? ev)+ private async Task CloseMenuAsync(MouseEventArgs? _){ContextMenuService.CloseContextMenuRequested -= ContextMenuService_CloseContextMenuRequested;ContextMenuService.CloseContextMenu();diff --git a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditorHelper.cs b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditorHelper.csindex d4fd32da6..d4714ee57 100644--- a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditorHelper.cs+++ b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditorHelper.cs@@ -11,6 +11,12 @@ namespace DevToys.Blazor.Components;internal static class MonacoEditorHelper{+ private static readonly JsonSerializerOptions jsonSerializerOptions = new()+ {+ DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase+ };+/// <summary>/// Create a new editor under `domElement`./// `domElement` should be empty (not contain other dom nodes).@@ -29,11 +35,7 @@ internal static class MonacoEditorHelperGuard.IsNotNull(dotnetObjectRef);// Convert the options object into a JsonElement to get rid of the properties with null values- string optionsJson = JsonSerializer.Serialize(options, new JsonSerializerOptions- {- DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,- PropertyNamingPolicy = JsonNamingPolicy.CamelCase- });+ string optionsJson = JsonSerializer.Serialize(options, jsonSerializerOptions);JsonElement optionsDict = JsonSerializer.Deserialize<JsonElement>(optionsJson);// Create the editor@@ -64,11 +66,7 @@ internal static class MonacoEditorHelperoptions ??= new StandaloneDiffEditorConstructionOptions();// Convert the options object into a JsonElement to get rid of the properties with null values- string optionsJson = JsonSerializer.Serialize(options, new JsonSerializerOptions- {- DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,- PropertyNamingPolicy = JsonNamingPolicy.CamelCase- });+ string optionsJson = JsonSerializer.Serialize(options, jsonSerializerOptions);JsonElement optionsDict = JsonSerializer.Deserialize<JsonElement>(optionsJson);// Create the editordiff --git a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/RicherMonacoEditorDiffBase.cs b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/RicherMonacoEditorDiffBase.csindex 5db246863..80f0aab1d 100644--- a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/RicherMonacoEditorDiffBase.cs+++ b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/RicherMonacoEditorDiffBase.cs@@ -8,6 +8,12 @@ namespace DevToys.Blazor.Components;public abstract class RicherMonacoEditorDiffBase : MonacoEditorBase{+ private static readonly JsonSerializerOptions jsonSerializerOptions = new()+ {+ DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase+ };+protected RicherMonacoEditorBase? _originalEditor;protected RicherMonacoEditorBase? _modifiedEditor;@@ -346,11 +352,7 @@ public abstract class RicherMonacoEditorDiffBase : MonacoEditorBasepublic async ValueTask<bool> UpdateOptionsAsync(DiffEditorOptions newOptions){// Convert the options object into a JsonElement to get rid of the properties with null values- string optionsJson = JsonSerializer.Serialize(newOptions, new JsonSerializerOptions- {- DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,- PropertyNamingPolicy = JsonNamingPolicy.CamelCase- });+ string optionsJson = JsonSerializer.Serialize(newOptions, jsonSerializerOptions);JsonElement optionsDict = JsonSerializer.Deserialize<JsonElement>(optionsJson);bool success = await JSRuntime.InvokeVoidWithErrorHandlingAsync("devtoys.MonacoEditor.updateOptions", Id, optionsDict);diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.csindex 2a9a8e934..3c4099a67 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.cs@@ -351,7 +351,7 @@ public partial class UITextInputWrapper : MefComponentBaseCancellationTokenSource? cancellationSourceToken = _cancellationTokenSource;cancellationSourceToken?.Cancel();cancellationSourceToken?.Dispose();- Interlocked.Exchange(ref _cancellationTokenSource, new(TimeSpan.FromSeconds(5)));+ Interlocked.Exchange(ref _cancellationTokenSource, new(TimeSpan.FromSeconds(2)));SmartDetectToolsAsync(UITextInput.Text, _cancellationTokenSource.Token).ForgetSafely();}}diff --git a/src/app/dev/DevToys.Blazor/Core/Converters/PolymorphicConverterFactory.cs b/src/app/dev/DevToys.Blazor/Core/Converters/PolymorphicConverterFactory.csindex 50ad531bd..7df49e757 100644--- a/src/app/dev/DevToys.Blazor/Core/Converters/PolymorphicConverterFactory.cs+++ b/src/app/dev/DevToys.Blazor/Core/Converters/PolymorphicConverterFactory.cs@@ -19,7 +19,7 @@ internal sealed class PolymorphicConverterFactory : JsonConverterFactorytypeof(PolymorphicConverter<>).MakeGenericType(typeToConvert),BindingFlags.Instance | BindingFlags.Public,null,- new object[] { },+ Array.Empty<object>(),null)!;}}diff --git a/src/app/dev/DevToys.Core/Debugger/DebuggerHelper.cs b/src/app/dev/DevToys.Core/Debugger/DebuggerHelper.csindex 0690c2a4d..cbd61571f 100644--- a/src/app/dev/DevToys.Core/Debugger/DebuggerHelper.cs+++ b/src/app/dev/DevToys.Core/Debugger/DebuggerHelper.cs@@ -8,7 +8,7 @@ public static class DebuggerHelperlimit ??= TimeSpan.FromSeconds(60);using var source = new CancellationTokenSource(limit.Value);- Console.WriteLine($"◉ Waiting {limit.Value.TotalSeconds} secs for debugger (PID: {Process.GetCurrentProcess().Id})...");+ Console.WriteLine($"◉ Waiting {limit.Value.TotalSeconds} secs for debugger (PID: {Environment.ProcessId})...");try{diff --git a/src/app/dev/DevToys.Api/Core/ExtensionOrderer.cs b/src/app/dev/DevToys.Core/ExtensionOrderer.cssimilarity index 78%rename from src/app/dev/DevToys.Api/Core/ExtensionOrderer.csrename to src/app/dev/DevToys.Core/ExtensionOrderer.csindex 1f08cb88d..105a3f02d 100644--- a/src/app/dev/DevToys.Api/Core/ExtensionOrderer.cs+++ b/src/app/dev/DevToys.Core/ExtensionOrderer.cs@@ -1,8 +1,18 @@-namespace DevToys.Api;+namespace DevToys.Core;-public static class ExtensionOrderer+/// <summary>+/// Provides methods for ordering and checking cycles in extensions.+/// </summary>+internal static class ExtensionOrderer{- public static IEnumerable<Lazy<TExtension, TMetadata>> Order<TExtension, TMetadata>(+ /// <summary>+ /// Orders the extensions based on their metadata.+ /// </summary>+ /// <typeparam name="TExtension">The type of the extension.</typeparam>+ /// <typeparam name="TMetadata">The type of the metadata.</typeparam>+ /// <param name="extensions">The extensions to be ordered.</param>+ /// <returns>The ordered extensions.</returns>+ internal static IEnumerable<Lazy<TExtension, TMetadata>> Order<TExtension, TMetadata>(IEnumerable<Lazy<TExtension, TMetadata>> extensions)where TMetadata : IOrderableMetadata{@@ -10,7 +20,13 @@ public static class ExtensionOrdererreturn graph.TopologicalSort();}- public static void CheckForCycles<TExtension, TMetadata>(+ /// <summary>+ /// Checks for cycles in the extensions.+ /// </summary>+ /// <typeparam name="TExtension">The type of the extension.</typeparam>+ /// <typeparam name="TMetadata">The type of the metadata.</typeparam>+ /// <param name="extensions">The extensions to be checked.</param>+ internal static void CheckForCycles<TExtension, TMetadata>(IEnumerable<Lazy<TExtension, TMetadata>> extensions)where TMetadata : IOrderableMetadata{diff --git a/src/app/dev/DevToys.Core/Mef/RecursiveDirectoryCatalog.cs b/src/app/dev/DevToys.Core/Mef/RecursiveDirectoryCatalog.csindex 45ea68234..3791d5e0c 100644--- a/src/app/dev/DevToys.Core/Mef/RecursiveDirectoryCatalog.cs+++ b/src/app/dev/DevToys.Core/Mef/RecursiveDirectoryCatalog.cs@@ -41,17 +41,6 @@ internal sealed partial class RecursiveDirectoryCatalog : ComposablePartCatalog,Initialize(path, searchPattern);}- private static IEnumerable<string> GetFoldersRecursive(string path)- {- var result = new List<string> { path };- foreach (string child in Directory.GetDirectories(path))- {- result.AddRange(GetFoldersRecursive(child));- }-- return result;- }-private void Initialize(string path, string searchPattern){IEnumerable<string> filesdiff --git a/src/app/dev/DevToys.Core/OSHelper.cs b/src/app/dev/DevToys.Core/OSHelper.csindex b491b33b2..79a066739 100644--- a/src/app/dev/DevToys.Core/OSHelper.cs+++ b/src/app/dev/DevToys.Core/OSHelper.cs@@ -13,7 +13,7 @@ public static class OSHelper}else if (OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst()){- currentPlatform = Platform.MacCatalyst;+ currentPlatform = Platform.MacOS;}else if (OperatingSystem.IsWindows()){diff --git a/src/app/dev/DevToys.Core/Tools/SmartDetectionService.cs b/src/app/dev/DevToys.Core/Tools/SmartDetectionService.csindex a54587e67..bad905f63 100644--- a/src/app/dev/DevToys.Core/Tools/SmartDetectionService.cs+++ b/src/app/dev/DevToys.Core/Tools/SmartDetectionService.cs@@ -121,7 +121,7 @@ public sealed partial class SmartDetectionServiceDetectorNode detectorNode = detectorHierarchy[i];// Detect data types from raw data using the current detector.- DataDetectionResult resultFromDetector = await DetectAsync(cancellationToken, detectorNode.Detector.Value, rawData, resultFromBaseDetector);+ DataDetectionResult resultFromDetector = await DetectAsync(detectorNode.Detector.Value, rawData, resultFromBaseDetector, cancellationToken);// If the detection was successfulif (resultFromDetector.Success)@@ -162,10 +162,10 @@ public sealed partial class SmartDetectionService}private async ValueTask<DataDetectionResult> DetectAsync(- CancellationToken cancellationToken,IDataTypeDetector detector,object rawData,- DataDetectionResult? resultFromBaseDetector)+ DataDetectionResult? resultFromBaseDetector,+ CancellationToken cancellationToken){try{diff --git a/src/app/dev/DevToys.Tools/Helpers/Base64Helper.cs b/src/app/dev/DevToys.Tools/Helpers/Base64Helper.csindex 62f9f281a..1f5c835c4 100644--- a/src/app/dev/DevToys.Tools/Helpers/Base64Helper.cs+++ b/src/app/dev/DevToys.Tools/Helpers/Base64Helper.cs@@ -56,14 +56,12 @@ internal static partial class Base64Helperreturn false;}-#pragma warning disable IDE0078 // Use pattern matchingif (!(current == 0x9|| current == 0xA|| current == 0xD|| current >= 0x20 && current <= 0xD7FF|| current >= 0xE000 && current <= 0xFFFD|| current >= 0x10000 && current <= 0x10FFFF))-#pragma warning restore IDE0078 // Use pattern matching{return false;}diff --git a/src/app/dev/DevToys.Tools/Helpers/Core/CryptoRandom.cs b/src/app/dev/DevToys.Tools/Helpers/Core/CryptoRandom.csindex 4e2fef8b8..1f2385fcd 100644--- a/src/app/dev/DevToys.Tools/Helpers/Core/CryptoRandom.cs+++ b/src/app/dev/DevToys.Tools/Helpers/Core/CryptoRandom.cs@@ -62,8 +62,7 @@ internal sealed class CryptoRandom : Random/// </exception>public override int Next(int maxValue){- if (maxValue < 0)- throw new ArgumentOutOfRangeException(nameof(maxValue));+ ArgumentOutOfRangeException.ThrowIfNegative(maxValue);return Next(0, maxValue);}@@ -81,8 +80,7 @@ internal sealed class CryptoRandom : Random/// </exception>public override int Next(int minValue, int maxValue){- if (minValue > maxValue)- throw new ArgumentOutOfRangeException(nameof(minValue));+ ArgumentOutOfRangeException.ThrowIfGreaterThan(minValue, maxValue);if (minValue == maxValue)return minValue;@@ -123,8 +121,7 @@ internal sealed class CryptoRandom : Random/// </exception>public override void NextBytes(byte[] buffer){- if (buffer == null)- throw new ArgumentNullException(nameof(buffer));+ ArgumentNullException.ThrowIfNull(buffer);Rng.GetBytes(buffer);}diff --git a/src/app/dev/DevToys.Tools/Helpers/JsonHelper.cs b/src/app/dev/DevToys.Tools/Helpers/JsonHelper.csindex 7ca200f37..8743aa7b0 100644--- a/src/app/dev/DevToys.Tools/Helpers/JsonHelper.cs+++ b/src/app/dev/DevToys.Tools/Helpers/JsonHelper.cs@@ -265,7 +265,7 @@ internal static partial class JsonHelper}catch (Exception ex){- logger.LogError("Yaml to Json Converter", ex);+ logger.LogError(ex, "Yaml to Json Converter");return new(string.Empty, false);}}diff --git a/src/app/dev/DevToys.Tools/Helpers/LoremIpsum/LipsumGenerator.cs b/src/app/dev/DevToys.Tools/Helpers/LoremIpsum/LipsumGenerator.csindex b83944875..2fa127f97 100644--- a/src/app/dev/DevToys.Tools/Helpers/LoremIpsum/LipsumGenerator.cs+++ b/src/app/dev/DevToys.Tools/Helpers/LoremIpsum/LipsumGenerator.cs@@ -12,7 +12,7 @@ internal sealed class LipsumGenerator{private const string LoremIpsumStartText = "Lorem ipsum dolor sit amet";- private LipsumsCorpus _lipsum = LipsumsCorpus.LoremIpsum;+ private readonly LipsumsCorpus _lipsum = LipsumsCorpus.LoremIpsum;private StringBuilder _lipsumText = new();private IReadOnlyList<string> _preparedWords = Array.Empty<string>();@@ -165,7 +165,7 @@ internal sealed class LipsumGenerator* refactored into one method that takes a count* and a TextFeature. */string[] paragraphs = new string[count];- string[] sentences = new string[] { };+ string[] sentences;for (int i = 0; i < count; i++){/* Get a random amount of sentences based on the@@ -216,7 +216,7 @@ internal sealed class LipsumGeneratorinternal string[] GenerateSentences(int count, Sentence options){string[] sentences = new string[count];- string[] words = new string[] { };+ string[] words;for (int i = 0; i < count; i++){diff --git a/src/app/dev/DevToys.Tools/Helpers/XmlHelper.cs b/src/app/dev/DevToys.Tools/Helpers/XmlHelper.csindex eb21a103a..8b786d7b4 100644--- a/src/app/dev/DevToys.Tools/Helpers/XmlHelper.cs+++ b/src/app/dev/DevToys.Tools/Helpers/XmlHelper.cs@@ -118,7 +118,7 @@ internal static class XmlHelper}catch (Exception ex) // some other exception{- logger.LogError(ex, "Xml formatter", $"Indentation: {indentationMode}");+ logger.LogError(ex, "Xml formatter. Indentation: {indentationMode}", indentationMode);return new(ex.Message, false);}}diff --git a/src/app/dev/DevToys.Tools/Helpers/XsdHelper.cs b/src/app/dev/DevToys.Tools/Helpers/XsdHelper.csindex 6654451c9..8329543cc 100644--- a/src/app/dev/DevToys.Tools/Helpers/XsdHelper.cs+++ b/src/app/dev/DevToys.Tools/Helpers/XsdHelper.cs@@ -78,8 +78,8 @@ internal static class XsdHelper{// XML will always be valid if it doesn't define a namespace. Let's verify that namespaces aren't missing.var xsdDocument = XDocument.Parse(xsd);- IEnumerable<XmlNamespace> xsdNamespaces = GetAllNamespaces(xsdDocument);- IEnumerable<XmlNamespace> xmlNamespaces = GetAllNamespaces(xmlDocument);+ IReadOnlyList<XmlNamespace> xsdNamespaces = GetAllNamespaces(xsdDocument);+ IReadOnlyList<XmlNamespace> xmlNamespaces = GetAllNamespaces(xmlDocument);cancellationToken.ThrowIfCancellationRequested();@@ -187,7 +187,7 @@ internal static class XsdHelper/// </summary>/// <param name="xmlDocument">XML document containing namespaces.</param>/// <returns></returns>- private static IEnumerable<XmlNamespace> GetAllNamespaces(XDocument xmlDocument)+ private static IReadOnlyList<XmlNamespace> GetAllNamespaces(XDocument xmlDocument){XPathNavigator? navigator = xmlDocument.CreateNavigator();navigator.MoveToFollowing(XPathNodeType.Element);diff --git a/src/app/dev/DevToys.Tools/Helpers/YamlHelper.cs b/src/app/dev/DevToys.Tools/Helpers/YamlHelper.csindex b8ffeed6c..cd532d151 100644--- a/src/app/dev/DevToys.Tools/Helpers/YamlHelper.cs+++ b/src/app/dev/DevToys.Tools/Helpers/YamlHelper.cs@@ -103,7 +103,7 @@ internal static partial class YamlHelper}catch (Exception ex){- logger.LogError("Yaml to Json Converter", ex);+ logger.LogError(ex, "Yaml to Json Converter");return new(string.Empty, false);}}diff --git a/src/app/dev/DevToys.Tools/SmartDetection/DateDataTypeDetector.cs b/src/app/dev/DevToys.Tools/SmartDetection/DateDataTypeDetector.csindex 3b7b8b59e..6b152c1a2 100644--- a/src/app/dev/DevToys.Tools/SmartDetection/DateDataTypeDetector.cs+++ b/src/app/dev/DevToys.Tools/SmartDetection/DateDataTypeDetector.cs@@ -11,7 +11,6 @@ internal sealed partial class DateDataTypeDetector : IDataTypeDetector&& !long.TryParse(dataString, out _)&& !string.IsNullOrWhiteSpace(dataString)){-if (long.TryParse(dataString, out long potentialTimestamp)){try@@ -28,8 +27,8 @@ internal sealed partial class DateDataTypeDetector : IDataTypeDetector{return ValueTask.FromResult(new DataDetectionResult(Success: true, Data: dateTimeOffset));}-}+return ValueTask.FromResult(DataDetectionResult.Unsuccessful);}}diff --git a/src/app/dev/DevToys.Tools/SmartDetection/JsonArrayDataTypeDetector.cs b/src/app/dev/DevToys.Tools/SmartDetection/JsonArrayDataTypeDetector.csindex cec2aab60..15a3ac8d9 100644--- a/src/app/dev/DevToys.Tools/SmartDetection/JsonArrayDataTypeDetector.cs+++ b/src/app/dev/DevToys.Tools/SmartDetection/JsonArrayDataTypeDetector.cs@@ -10,14 +10,6 @@ namespace DevToys.Tools.SmartDetection;[DataTypeName(PredefinedCommonDataTypeNames.JsonArray, baseName: PredefinedCommonDataTypeNames.Json)]internal sealed partial class JsonArrayDataTypeDetector : IDataTypeDetector{- private readonly ILogger _logger;-- [ImportingConstructor]- public JsonArrayDataTypeDetector()- {- _logger = this.Log();- }-public ValueTask<DataDetectionResult> TryDetectDataAsync(object data,DataDetectionResult? resultFromBaseDetector,diff --git a/src/app/dev/DevToys.Tools/Tools/Converters/Date/DateConverterGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Converters/Date/DateConverterGuiTool.csindex 9dfc35681..3b828f1ae 100644--- a/src/app/dev/DevToys.Tools/Tools/Converters/Date/DateConverterGuiTool.cs+++ b/src/app/dev/DevToys.Tools/Tools/Converters/Date/DateConverterGuiTool.cs@@ -82,7 +82,7 @@ internal sealed partial class DateConverterGuiTool : IGuiTool, IDisposable}set{- _settingsProvider.SetSetting(timeZoneIdSettings, value.Value!.ToString());+ _settingsProvider.SetSetting(timeZoneIdSettings, value.Value!.ToString() ?? string.Empty);}}diff --git a/src/app/dev/DevToys.Tools/Tools/Formatters/Json/JsonFormatterGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Formatters/Json/JsonFormatterGuiTool.csindex 54521353f..383541a34 100644--- a/src/app/dev/DevToys.Tools/Tools/Formatters/Json/JsonFormatterGuiTool.cs+++ b/src/app/dev/DevToys.Tools/Tools/Formatters/Json/JsonFormatterGuiTool.cs@@ -106,7 +106,7 @@ internal sealed partial class JsonFormatterGuiTool : IGuiTool, IDisposableGridRow.Content,GridColumn.Content,SplitGrid()- .Vertical()+ .Vertical().WithLeftPaneChild(_inputTextArea.Title(JsonFormatter.Input)diff --git a/src/app/dev/DevToys.Tools/Tools/Generators/HashAndChecksum/HashAndChecksumGeneratorGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Generators/HashAndChecksum/HashAndChecksumGeneratorGuiTool.csindex 191fd34ff..df2be30f1 100644--- a/src/app/dev/DevToys.Tools/Tools/Generators/HashAndChecksum/HashAndChecksumGeneratorGuiTool.cs+++ b/src/app/dev/DevToys.Tools/Tools/Generators/HashAndChecksum/HashAndChecksumGeneratorGuiTool.cs@@ -353,7 +353,7 @@ internal sealed class HashAndChecksumGeneratorGuiTool : IGuiTool, IDisposable}}- private async Task<string> ComputeHashFromStreamAsync(+ private static async Task<string> ComputeHashFromStreamAsync(Stream inputStream,HashAlgorithmType hashAlgorithm,bool uppercase,diff --git a/src/app/dev/DevToys.Tools/Tools/Text/EscapeUnescape/EscapeUnescapeGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Text/EscapeUnescape/EscapeUnescapeGuiTool.csindex 457a43bbf..8c93648ee 100644--- a/src/app/dev/DevToys.Tools/Tools/Text/EscapeUnescape/EscapeUnescapeGuiTool.cs+++ b/src/app/dev/DevToys.Tools/Tools/Text/EscapeUnescape/EscapeUnescapeGuiTool.cs@@ -39,7 +39,6 @@ internal sealed class EscapeUnescapeGuiTool : IGuiTool, IDisposableStretch}-private readonly DisposableSemaphore _semaphore = new();private readonly ILogger _logger;private readonly ISettingsProvider _settingsProvider;diff --git a/src/app/dev/platforms/desktop/DevToys.CLI/OptionToICommandLineToolMap.cs b/src/app/dev/platforms/desktop/DevToys.CLI/OptionToICommandLineToolMap.csindex 882583d25..8cb3b0aa3 100644--- a/src/app/dev/platforms/desktop/DevToys.CLI/OptionToICommandLineToolMap.cs+++ b/src/app/dev/platforms/desktop/DevToys.CLI/OptionToICommandLineToolMap.cs@@ -133,7 +133,7 @@ internal sealed class OptionToICommandLineToolMapreturn option;}- private static Option CreateOneOfTypeOption(+ private static OneOfOption CreateOneOfTypeOption(CommandLineOptionAttribute commandLineOptionAttribute,string optionName,string? optionDescription,diff --git a/src/app/tests/DevToys.UnitTests/Api/Core/ObservableHashSetTests.cs b/src/app/tests/DevToys.UnitTests/Api/Core/ObservableHashSetTests.csindex 91d7f3212..2abcaad21 100644--- a/src/app/tests/DevToys.UnitTests/Api/Core/ObservableHashSetTests.cs+++ b/src/app/tests/DevToys.UnitTests/Api/Core/ObservableHashSetTests.cs@@ -38,7 +38,7 @@ public class ObservableHashSetTestsint collectionChanged = 0;int currentCount = 0;int countChange = 1;- string[] adding = Array.Empty<string>();+ string[] adding = [];hashSet.PropertyChanging += (s, a) => AssertCountChanging(hashSet, s, a, currentCount, ref countChanging);hashSet.PropertyChanged += (s, a) => AssertCountChanged(hashSet, s, a, ref currentCount, countChange, ref countChanged);@@ -50,28 +50,28 @@ public class ObservableHashSetTestscollectionChanged++;};- adding = new[] { "Palmer" };+ adding = ["Palmer"];hashSet.Add("Palmer").Should().BeTrue();countChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.Should().BeEquivalentTo(new[] { "Palmer" });+ hashSet.Should().BeEquivalentTo(["Palmer"]);- adding = new[] { "Carmack" };+ adding = ["Carmack"];hashSet.Add("Carmack").Should().BeTrue();countChanging.Should().Be(2);countChanged.Should().Be(2);collectionChanged.Should().Be(2);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Carmack", "Palmer" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Carmack", "Palmer"]);hashSet.Add("Palmer").Should().BeFalse();countChanging.Should().Be(2);countChanged.Should().Be(2);collectionChanged.Should().Be(2);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Carmack", "Palmer" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Carmack", "Palmer"]);}[Fact]@@ -167,7 +167,7 @@ public class ObservableHashSetTestsint collectionChanged = 0;int currentCount = 2;int countChange = -1;- string[] removing = Array.Empty<string>();+ string[] removing = [];hashSet.PropertyChanging += (s, a) => AssertCountChanging(hashSet, s, a, currentCount, ref countChanging);hashSet.PropertyChanged += (s, a) => AssertCountChanged(hashSet, s, a, ref currentCount, countChange, ref countChanged);@@ -179,15 +179,15 @@ public class ObservableHashSetTestscollectionChanged++;};- removing = new[] { "Palmer" };+ removing = ["Palmer"];hashSet.Remove("Palmer").Should().BeTrue();countChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.Should().BeEquivalentTo(new[] { "Carmack" });+ hashSet.Should().BeEquivalentTo(["Carmack"]);- removing = new[] { "Carmack" };+ removing = ["Carmack"];hashSet.Remove("Carmack").Should().BeTrue();countChanging.Should().Be(2);@@ -216,7 +216,7 @@ public class ObservableHashSetTestsint collectionChanged = 0;int currentCount = 2;int countChange = 2;- string[] adding = new[] { "Brendan", "Nate" };+ string[] adding = ["Brendan", "Nate"];hashSet.PropertyChanging += (s, a) => AssertCountChanging(hashSet, s, a, currentCount, ref countChanging);hashSet.PropertyChanged += (s, a) => AssertCountChanged(hashSet, s, a, ref currentCount, countChange, ref countChanged);@@ -233,14 +233,14 @@ public class ObservableHashSetTestscountChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Brendan", "Carmack", "Nate", "Palmer" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Brendan", "Carmack", "Nate", "Palmer"]);hashSet.UnionWith(new[] { "Brendan" });countChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Brendan", "Carmack", "Nate", "Palmer" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Brendan", "Carmack", "Nate", "Palmer"]);}[Fact]@@ -258,7 +258,7 @@ public class ObservableHashSetTestsint collectionChanged = 0;int currentCount = 4;int countChange = -2;- string[] removing = new[] { "Brendan", "Nate" };+ string[] removing = ["Brendan", "Nate"];hashSet.PropertyChanging += (s, a) => AssertCountChanging(hashSet, s, a, currentCount, ref countChanging);hashSet.PropertyChanged += (s, a) => AssertCountChanged(hashSet, s, a, ref currentCount, countChange, ref countChanged);@@ -275,14 +275,14 @@ public class ObservableHashSetTestscountChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Carmack", "Palmer" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Carmack", "Palmer"]);hashSet.IntersectWith(new[] { "Carmack", "Palmer", "Abrash" });countChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Carmack", "Palmer" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Carmack", "Palmer"]);}[Fact]@@ -300,7 +300,7 @@ public class ObservableHashSetTestsint collectionChanged = 0;int currentCount = 4;int countChange = -2;- string[] removing = new[] { "Carmack", "Palmer" };+ string[] removing = ["Carmack", "Palmer"];hashSet.PropertyChanging += (s, a) => AssertCountChanging(hashSet, s, a, currentCount, ref countChanging);hashSet.PropertyChanged += (s, a) => AssertCountChanged(hashSet, s, a, ref currentCount, countChange, ref countChanged);@@ -317,14 +317,14 @@ public class ObservableHashSetTestscountChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Brendan", "Nate" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Brendan", "Nate"]);hashSet.ExceptWith(new[] { "Abrash", "Carmack", "Palmer" });countChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Brendan", "Nate" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Brendan", "Nate"]);}[Fact]@@ -342,8 +342,8 @@ public class ObservableHashSetTestsint collectionChanged = 0;int currentCount = 4;int countChange = -1;- string[] removing = new[] { "Carmack", "Palmer" };- string[] adding = new[] { "Abrash" };+ string[] removing = ["Carmack", "Palmer"];+ string[] adding = ["Abrash"];hashSet.PropertyChanging += (s, a) => AssertCountChanging(hashSet, s, a, currentCount, ref countChanging);hashSet.PropertyChanged += (s, a) => AssertCountChanged(hashSet, s, a, ref currentCount, countChange, ref countChanged);@@ -360,14 +360,14 @@ public class ObservableHashSetTestscountChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Abrash", "Brendan", "Nate" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Abrash", "Brendan", "Nate"]);hashSet.SymmetricExceptWith(Array.Empty<string>());countChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Abrash", "Brendan", "Nate" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Abrash", "Brendan", "Nate"]);}[Fact]@@ -454,7 +454,7 @@ public class ObservableHashSetTestsint collectionChanged = 0;int currentCount = 4;int countChange = -2;- string[] removing = new[] { "Carmack", "Palmer" };+ string[] removing = ["Carmack", "Palmer"];hashSet.PropertyChanging += (s, a) => AssertCountChanging(hashSet, s, a, currentCount, ref countChanging);hashSet.PropertyChanged += (s, a) => AssertCountChanged(hashSet, s, a, ref currentCount, countChange, ref countChanged);@@ -471,14 +471,14 @@ public class ObservableHashSetTestscountChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Brendan", "Nate" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Brendan", "Nate"]);hashSet.RemoveWhere(i => i.Contains('m')).Should().Be(0);countChanging.Should().Be(1);countChanged.Should().Be(1);collectionChanged.Should().Be(1);- hashSet.OrderBy(i => i).Should().BeEquivalentTo(new[] { "Brendan", "Nate" });+ hashSet.OrderBy(i => i).Should().BeEquivalentTo(["Brendan", "Nate"]);}private static void AssertCountChanging<T>(diff --git a/src/app/tests/DevToys.UnitTests/Blazor/Core/Helpers/CssBuilderTests.cs b/src/app/tests/DevToys.UnitTests/Blazor/Core/Helpers/CssBuilderTests.csindex b71682175..ba83f283c 100644--- a/src/app/tests/DevToys.UnitTests/Blazor/Core/Helpers/CssBuilderTests.cs+++ b/src/app/tests/DevToys.UnitTests/Blazor/Core/Helpers/CssBuilderTests.cs@@ -31,7 +31,7 @@ public class CssBuilderTests//arrangebool hasTwo = false;bool hasThree = true;- Func<bool> hasFive = () => false;+ static bool hasFive() => false;//actstring classToRender = new CssBuilder("item-one")@@ -50,7 +50,7 @@ public class CssBuilderTests//arrangebool hasTwo = false;bool hasThree = true;- Func<bool> hasFive = () => false;+ static bool hasFive() => false;//actstring classToRender = new CssBuilder("item-one")@@ -86,7 +86,7 @@ public class CssBuilderTests{//arrange// Simulates Razor Components attribute splatting feature- IDictionary<string, object> attributes = new Dictionary<string, object> { { "class", "my-custom-class-1" } };+ var attributes = new Dictionary<string, object> { { "class", "my-custom-class-1" } };//actstring classToRender = new CssBuilder("item-one")@@ -103,7 +103,7 @@ public class CssBuilderTests{//arrange// Simulates Razor Components attribute splatting feature- IDictionary<string, object> attributes = new Dictionary<string, object> { { "class", "my-custom-class-1" } };+ var attributes = new Dictionary<string, object> { { "class", "my-custom-class-1" } };//actstring classToRender = new CssBuilder("item-one")@@ -154,7 +154,7 @@ public class CssBuilderTests{//arrange// Simulates Razor Components attribute splatting feature- IDictionary<string, object> attributes = new Dictionary<string, object> { { "foo", "bar" } };+ var attributes = new Dictionary<string, object> { { "foo", "bar" } };//actstring classToRender = new CssBuilder("item-one")diff --git a/src/app/tests/DevToys.UnitTests/Api/Core/ExtensionOrdererTests.cs b/src/app/tests/DevToys.UnitTests/Core/ExtensionOrdererTests.cssimilarity index 98%rename from src/app/tests/DevToys.UnitTests/Api/Core/ExtensionOrdererTests.csrename to src/app/tests/DevToys.UnitTests/Core/ExtensionOrdererTests.csindex 87962e888..16dce91a4 100644--- a/src/app/tests/DevToys.UnitTests/Api/Core/ExtensionOrdererTests.cs+++ b/src/app/tests/DevToys.UnitTests/Core/ExtensionOrdererTests.cs@@ -1,4 +1,6 @@-namespace DevToys.UnitTests.Api.Core;+using DevToys.Core;++namespace DevToys.UnitTests.Core;public class ExtensionOrdererTests{diff --git a/src/app/tests/DevToys.UnitTests/Mocks/MockIFileStorage.cs b/src/app/tests/DevToys.UnitTests/Mocks/MockIFileStorage.csindex 1421dc8f9..cfc4ff3d8 100644--- a/src/app/tests/DevToys.UnitTests/Mocks/MockIFileStorage.cs+++ b/src/app/tests/DevToys.UnitTests/Mocks/MockIFileStorage.cs@@ -50,7 +50,7 @@ internal class MockIFileStorage : IFileStoragethrow new NotImplementedException();}- public FileInfo CreateSelfDestroyingTempFile(string? desiredFileExtension = null)+ public FileInfo CreateSelfDestroyingTempFile(string desiredFileExtension = null){var assembly = Assembly.GetExecutingAssembly();string assemblyDirectory = Path.GetDirectoryName(assembly.Location);diff --git a/src/app/tests/DevToys.UnitTests/Tools/Converters/DateConverterCommandLineToolTests.cs b/src/app/tests/DevToys.UnitTests/Tools/Converters/DateConverterCommandLineToolTests.csindex 099dd8d98..be99af641 100644--- a/src/app/tests/DevToys.UnitTests/Tools/Converters/DateConverterCommandLineToolTests.cs+++ b/src/app/tests/DevToys.UnitTests/Tools/Converters/DateConverterCommandLineToolTests.cs@@ -303,5 +303,4 @@ public sealed class DateConverterCommandLineToolTests : MefBasedTeststring consoleOutput = _consoleWriter.ToString().Trim();consoleOutput.Should().Be(exceptedDateTimeString);}-}diff --git a/src/app/tests/DevToys.UnitTests/Tools/Helpers/PasswordGeneratorHelperTests.cs b/src/app/tests/DevToys.UnitTests/Tools/Helpers/PasswordGeneratorHelperTests.csindex 2bf4ae6e1..017a960e2 100644--- a/src/app/tests/DevToys.UnitTests/Tools/Helpers/PasswordGeneratorHelperTests.cs+++ b/src/app/tests/DevToys.UnitTests/Tools/Helpers/PasswordGeneratorHelperTests.cs@@ -12,7 +12,7 @@ public class PasswordGeneratorHelperTests[InlineData(100, true, true, true, true, null)][InlineData(100, true, true, true, true, "bcdefghijklmnopqrstuvwxyz")][InlineData(100, false, true, false, false, "bcdefghijklmnopqrstuvwxyz")]- internal void GeneratePassword(int length, bool hasUppercase, bool hasLowercase, bool hasNumber, bool hasSpecialCharacters, string? excludedCharacters)+ internal void GeneratePassword(int length, bool hasUppercase, bool hasLowercase, bool hasNumber, bool hasSpecialCharacters, string excludedCharacters){string password= PasswordGeneratorHelper.GeneratePassword(diff --git a/src/app/tests/DevToys.UnitTests/Tools/Helpers/UuidHelperTests.cs b/src/app/tests/DevToys.UnitTests/Tools/Helpers/UuidHelperTests.csindex 00e3ac57a..30513f762 100644--- a/src/app/tests/DevToys.UnitTests/Tools/Helpers/UuidHelperTests.cs+++ b/src/app/tests/DevToys.UnitTests/Tools/Helpers/UuidHelperTests.cs@@ -24,10 +24,10 @@ public class UuidHelperTestsTestUuid(newUuid, hyphens, uppercase);}- private void TestUuid(string uuid, bool hyphens, bool uppercase)+ private static void TestUuid(string uuid, bool hyphens, bool uppercase){Guid.TryParse(uuid, out _).Should().BeTrue();- uuid.Contains("-").Should().Be(hyphens);+ uuid.Contains('-').Should().Be(hyphens);uuid.Length.Should().Be(hyphens ? 36 : 32);uuid.Should().Be(uppercase ? uuid.ToUpperInvariant() : uuid.ToLowerInvariant());}