A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Added dynamic font load
Etienne Baudouxc426a9f09009
diff --git a/src/app/dev/DevToys.Api/Settings/PredefinedSettings.cs b/src/app/dev/DevToys.Api/Settings/PredefinedSettings.csdeleted file mode 100644index b791b64c4..000000000--- a/src/app/dev/DevToys.Api/Settings/PredefinedSettings.cs+++ /dev/null@@ -1,90 +0,0 @@-namespace DevToys.Api;--public static class PredefinedSettings-{- /// <summary>- /// Whether the compact mode is enabled or not.- /// </summary>- public static readonly SettingDefinition<bool> CompactMode- = new(- name: nameof(CompactMode),- defaultValue: false);-- /// <summary>- /// Preferred default fonts. The app will the first font in this list that is available on the system.- /// </summary>- public static readonly string[] DefaultFonts- = new[]- {- // Popular fonts developers install. If it's on the system, users likely want to use it.- "Fira Code",- "Source Code Pro",- "DejaVu Sans Mono",- "Hack",-- // Default Visual Studio fonts.- "Cascadia Mono",- "Cascadia Code",-- // Fonts included on MacOS.- "Menlo",- "Monaco",- "SF Mono",- "SF Pro",-- // Fonts included on Windows and MacOS.- "Consolas",- "Courier New",-- // Fonts included on Windows.- "Segoe UI",- };-- /// <summary>- /// The font family name to use in the text editor.- /// </summary>- public static readonly SettingDefinition<string> TextEditorFont- = new(- name: nameof(TextEditorFont),- defaultValue: string.Empty); // Default value will be defined by the app depending on the operating system.-- /// <summary>- /// Whether the text in the text editor should wrap.- /// </summary>- public static readonly SettingDefinition<bool> TextEditorTextWrapping- = new(- name: nameof(TextEditorTextWrapping),- defaultValue: false);-- /// <summary>- /// Whether the line numbers should be displayed in the text editor.- /// </summary>- public static readonly SettingDefinition<bool> TextEditorLineNumbers- = new(- name: nameof(TextEditorLineNumbers),- defaultValue: true);-- /// <summary>- /// Whether the line where the caret is should be highlighted in the text editor.- /// </summary>- public static readonly SettingDefinition<bool> TextEditorHighlightCurrentLine- = new(- name: nameof(TextEditorHighlightCurrentLine),- defaultValue: true);-- /// <summary>- /// Whether white spaces should be rendered in the text editor.- /// </summary>- public static readonly SettingDefinition<bool> TextEditorRenderWhitespace- = new(- name: nameof(TextEditorRenderWhitespace),- defaultValue: false);-- /// <summary>- /// Whether when using the Paste command, the text in the editor should be replaced or appended.- /// </summary>- public static readonly SettingDefinition<bool> TextEditorPasteClearsText- = new(- name: nameof(TextEditorPasteClearsText),- defaultValue: true);-}diff --git a/src/app/dev/DevToys.Api/Tool/FontDefinition.cs b/src/app/dev/DevToys.Api/Tool/FontDefinition.csnew file mode 100644index 000000000..515a40f5b--- /dev/null+++ b/src/app/dev/DevToys.Api/Tool/FontDefinition.cs@@ -0,0 +1,22 @@+namespace DevToys.Api;++public sealed class FontDefinition : IDisposable+{+ public FontDefinition(string fontFamily, Stream fontReader)+ {+ Guard.IsNotNullOrWhiteSpace(fontFamily);+ Guard.IsNotNull(fontReader);+ Guard.CanRead(fontReader);+ FontFamily = fontFamily;+ FontReader = fontReader;+ }++ public string FontFamily { get; }++ public Stream FontReader { get; }++ public void Dispose()+ {+ FontReader?.Dispose();+ }+}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.csindex 57c2501ca..1c0d1a68d 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs@@ -110,7 +110,7 @@ public static partial class GUI/// <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>public static IUISettingGroup Handle<T>(this IUISettingGroup element, ISettingsProvider settingsProvider, SettingDefinition<T> settingDefinition, Func<T, ValueTask>? onOptionSelected, params IUIDropDownListItem[] dropDownListItems) where T : struct, IConvertible{- return (IUISettingGroup)((IUISetting)element).Handle<T>(settingsProvider, settingDefinition, onOptionSelected, dropDownListItems);+ return (IUISettingGroup)((IUISetting)element).Handle(settingsProvider, settingDefinition, onOptionSelected, dropDownListItems);}/// <summary>diff --git a/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.cs b/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.csindex beef9539c..d69ed0a41 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.cs@@ -6,7 +6,7 @@/// <remarks>/// <para>/// The project containing the <see cref="System.Resources.ResourceManager"/> with all the strings for the tool should contain an implementation-/// of <see cref="IResourceManagerAssemblyIdentifier"/> as shown in the example.+/// of <see cref="IResourceAssemblyIdentifier"/> as shown in the example./// </para>/// <example>/// <code>@@ -16,7 +16,7 @@/// IconFontName = "FluentSystemIcons",/// IconGlyph = "\u0108",/// GroupName = "Encoders / Decoders", // <seealso cref="GuiToolGroup"/>-/// ResourceManagerAssemblyIdentifier = nameof(MyResourceManagerAssemblyIdentifier), // <seealso cref="IResourceManagerAssemblyIdentifier"/>+/// ResourceManagerAssemblyIdentifier = nameof(MyResourceManagerAssemblyIdentifier), // <seealso cref="IResourceAssemblyIdentifier"/>/// ResourceManagerBaseName = "MyProject.Strings",/// ShortDisplayTitleResourceName = nameof(MyProject.Strings.ShortDisplayTitle),/// LongDisplayTitleResourceName = nameof(MyProject.Strings.LongDisplayTitle), // Optionaldiff --git a/src/app/dev/DevToys.Api/Tool/IResourceAssemblyIdentifier.cs b/src/app/dev/DevToys.Api/Tool/IResourceAssemblyIdentifier.csnew file mode 100644index 000000000..6bc070ac5--- /dev/null+++ b/src/app/dev/DevToys.Api/Tool/IResourceAssemblyIdentifier.cs@@ -0,0 +1,27 @@+namespace DevToys.Api;++/// <summary>+/// Represents the factory to access some resources of the current assembly such as strings stored in RESX files, or Fonts.+/// </summary>+/// <remarks>+/// <example>+/// <code>+/// [Export(typeof(MyResourceAssemblyIdentifier))]+/// [Name(nameof(MyResourceAssemblyIdentifier))]+/// internal sealed class MyResourceAssemblyIdentifier : IResourceAssemblyIdentifier+/// {+/// }+/// </code>+/// </example>+/// </remarks>+public interface IResourceAssemblyIdentifier+{+ /// <summary>+ /// Get access to fonts that can be used by <see cref="IGuiTool"/>.+ /// </summary>+ /// <remarks>+ /// The font is expected to be a TTF or OTF. WOFF and WOFF2 aren't supported at the moment.+ /// </remarks>+ /// <returns>An array of font definition with a stream to access it.</returns>+ ValueTask<FontDefinition[]> GetFontDefinitionsAsync();+}diff --git a/src/app/dev/DevToys.Api/Tool/IResourceManagerAssemblyIdentifier.cs b/src/app/dev/DevToys.Api/Tool/IResourceManagerAssemblyIdentifier.csdeleted file mode 100644index b6ff9c943..000000000--- a/src/app/dev/DevToys.Api/Tool/IResourceManagerAssemblyIdentifier.cs+++ /dev/null@@ -1,19 +0,0 @@-namespace DevToys.Api;--/// <summary>-/// Represents the factory for command line tool.-/// </summary>-/// <remarks>-/// <example>-/// <code>-/// [Export(typeof(IResourceManagerAssemblyIdentifier))]-/// [Name(nameof(MyResourceManagerAssemblyIdentifier))]-/// internal sealed class MyResourceManagerAssemblyIdentifier : IResourceManagerAssemblyIdentifier-/// {-/// }-/// </code>-/// </example>-/// </remarks>-public interface IResourceManagerAssemblyIdentifier-{-}diff --git a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/ToolDisplayInformationAttribute.cs b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/ToolDisplayInformationAttribute.csindex f452d81a4..cc8c8061a 100644--- a/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/ToolDisplayInformationAttribute.cs+++ b/src/app/dev/DevToys.Api/Tool/Metadata/Attributes/ToolDisplayInformationAttribute.cs@@ -34,7 +34,7 @@ public sealed class ToolDisplayInformationAttribute : Attribute}/// <summary>- /// Gets or sets the name of the <see cref="IResourceManagerAssemblyIdentifier"/> that contains the type indicated by+ /// Gets or sets the name of the <see cref="IResourceAssemblyIdentifier"/> that contains the type indicated by/// <see cref="ResourceManagerBaseName"/>./// </summary>public string ResourceManagerAssemblyIdentifierdiff --git a/src/app/dev/DevToys.Blazor/.eslintrc.json b/src/app/dev/DevToys.Blazor/.eslintrc.jsonindex e53e65c87..f67a849dd 100644--- a/src/app/dev/DevToys.Blazor/.eslintrc.json+++ b/src/app/dev/DevToys.Blazor/.eslintrc.json@@ -24,7 +24,7 @@],"linebreak-style": ["error",- "unix"+ "windows"],"quotes": ["error",diff --git a/src/app/dev/DevToys.Blazor/Assets/javascript/dom.ts b/src/app/dev/DevToys.Blazor/Assets/javascript/dom.tsindex 069e2f6da..1fb3de75a 100644--- a/src/app/dev/DevToys.Blazor/Assets/javascript/dom.ts+++ b/src/app/dev/DevToys.Blazor/Assets/javascript/dom.ts@@ -32,6 +32,12 @@ class DOM {"[tabindex]:not([tabindex='-1'])," +"[contentEditable=true]:not([tabindex='-1']");}++ public static addFontToDocument(fontDefinition: string): void {+ const css: HTMLStyleElement = document.createElement("style");+ css.innerHTML = fontDefinition;+ document.head.appendChild(css);+ }}export default DOM;\ No newline at end of filediff --git a/src/app/dev/DevToys.Blazor/Assets/sass/_typography.scss b/src/app/dev/DevToys.Blazor/Assets/sass/_typography.scssindex 246665ad2..93792c302 100644--- a/src/app/dev/DevToys.Blazor/Assets/sass/_typography.scss+++ b/src/app/dev/DevToys.Blazor/Assets/sass/_typography.scss@@ -1,19 +1,3 @@-@font-face {- font-family: "FluentSystemIcons-Regular";- src: url("../fonts/FluentSystemIcons-Regular.woff2?b48ba7b19a15536ed3d062b9b6c8fa0e") format("woff2"), url("../fonts/FluentSystemIcons-Regular.woff?b48ba7b19a15536ed3d062b9b6c8fa0e") format("woff"), url("../fonts/FluentSystemIcons-Regular.ttf?b48ba7b19a15536ed3d062b9b6c8fa0e") format("truetype");-}--i[class^="FluentSystemIcons"]:before, i[class*=" FluentSystemIcons"]:before {- font-family: FluentSystemIcons-Regular !important;- font-style: normal;- font-weight: normal !important;- font-variant: normal;- text-transform: none;- line-height: 1;- -webkit-font-smoothing: antialiased;- -moz-osx-font-smoothing: grayscale;-}-* {text-rendering: geometricPrecision;}diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Card/Card.razor b/src/app/dev/DevToys.Blazor/Components/Layout/Card/Card.razorindex 1bf704e36..af9fe7212 100644--- a/src/app/dev/DevToys.Blazor/Components/Layout/Card/Card.razor+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Card/Card.razor@@ -28,12 +28,18 @@Height="20"/><div class="card-context"><div class="card-title">- <TextBlock Appearance="TextBlockAppearance.Body" Text="@Title" NoWrap="true" CanTrim="true" />+ <TextBlock Appearance="TextBlockAppearance.Body"+ Text="@Title"+ NoWrap="true"+ CanTrim="true"+ Style="display: flex;" /></div>@if (!string.IsNullOrWhiteSpace(Description)){<div class="card-description">- <TextBlock Appearance="TextBlockAppearance.Caption" Text="@Description" />+ <TextBlock Appearance="TextBlockAppearance.Caption"+ Text="@Description"+ Style="display: flex;" /></div>}</div>diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.csindex b18020147..e10cd3e34 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.cs@@ -1,5 +1,6 @@using CommunityToolkit.Mvvm.Messaging;using DevToys.Core.Models;+using DevToys.Core.Settings;using DevToys.Core.Tools;using Microsoft.AspNetCore.Components.Forms;using Microsoft.Extensions.Logging;diff --git a/src/app/dev/DevToys.Blazor/Core/Services/FontService.cs b/src/app/dev/DevToys.Blazor/Core/Services/FontService.csnew file mode 100644index 000000000..9e53ab5aa--- /dev/null+++ b/src/app/dev/DevToys.Blazor/Core/Services/FontService.cs@@ -0,0 +1,141 @@+using System.Text;+using System.Threading;+using DevToys.Core.Tools;+using Microsoft.Extensions.Logging;+using Uno.Extensions;++namespace DevToys.Blazor.Core.Services;++public sealed partial class FontService+{+ private readonly ILogger _logger;+ private readonly IJSRuntime _jsRuntime;++ [ImportMany]+ private IEnumerable<Lazy<IResourceAssemblyIdentifier, ResourceAssemblyIdentifierMetadata>> _resourceAssemblyIdentifiers = default!;++ public FontService(IMefProvider mefProvider, IJSRuntime jsRuntime)+ {+ _logger = this.Log();+ _jsRuntime = jsRuntime;+ mefProvider.SatisfyImports(this);+ }++ internal async Task ImportThirdPartyFontsAsync()+ {+ DateTime startTime = DateTime.Now;+ await TaskSchedulerAwaiter.SwitchOffMainThreadAsync(CancellationToken.None);++ var tasks = new List<Task<string>>();+ await foreach (FontDefinition fontDefinition in GetFontDefinitionsAsync())+ {+ tasks.Add(GenerateCssForFontAsync(fontDefinition));+ }++ var allFontCss = new StringBuilder();++ string[] fonts = await Task.WhenAll(tasks);+ for (int i = 0; i < fonts.Length; i++)+ {+ allFontCss.AppendLine(fonts[i]);+ }++ double loadDuration = (DateTime.Now - startTime).TotalMilliseconds;+ startTime = DateTime.Now;++ await _jsRuntime.InvokeVoidWithErrorHandlingAsync("devtoys.DOM.addFontToDocument", allFontCss.ToString());++ LogImportThirdPartyFontsAsync(fonts.Length, loadDuration, (DateTime.Now - startTime).TotalMilliseconds);+ }++ private async IAsyncEnumerable<FontDefinition> GetFontDefinitionsAsync()+ {+ var tasks = new List<Task<FontDefinition[]>>();++ foreach (Lazy<IResourceAssemblyIdentifier, ResourceAssemblyIdentifierMetadata> resourceAssemblyIdentifier in _resourceAssemblyIdentifiers)+ {+ tasks.Add(GetFontDefinitionsAsync(resourceAssemblyIdentifier));+ }++ while (tasks.Count > 0)+ {+ var task = await Task.WhenAny(tasks);+ tasks.Remove(task);+ FontDefinition[] fontDefinitions = await task.ConfigureAwait(false);+ for (int i = 0; i < fontDefinitions.Length; i++)+ {+ yield return fontDefinitions[i];+ }+ }+ }++ private async Task<FontDefinition[]> GetFontDefinitionsAsync(Lazy<IResourceAssemblyIdentifier, ResourceAssemblyIdentifierMetadata> resourceAssemblyIdentifier)+ {+ try+ {+ return await resourceAssemblyIdentifier.Value.GetFontDefinitionsAsync();+ }+ catch (NotImplementedException) { }+ catch (Exception ex)+ {+ LogGetFontDefinitionsAsyncFailed(ex, resourceAssemblyIdentifier.Metadata.InternalComponentName);+ }++ return Array.Empty<FontDefinition>();+ }++ private async Task<string> GenerateCssForFontAsync(FontDefinition fontDefinition)+ {+ try+ {+ string base64FontString = await ConvertFontToBase64Async(fontDefinition);++ var cssStringBuilder = new StringBuilder();++ cssStringBuilder.AppendLine("@font-face {");+ cssStringBuilder.AppendLine($" font-family: \"{fontDefinition.FontFamily}\";");+ cssStringBuilder.AppendLine($" src: url(data:application/font-ttf;charset=utf-8;base64,{base64FontString}) format('truetype');");+ cssStringBuilder.AppendLine("}");+ cssStringBuilder.AppendLine("");+ cssStringBuilder.AppendLine($"i[class^=\"{fontDefinition.FontFamily}\"]:before, i[class*=\" {fontDefinition.FontFamily}\"]:before {{");+ cssStringBuilder.AppendLine($" font-family: {fontDefinition.FontFamily} !important;");+ cssStringBuilder.AppendLine(" font-style: normal;");+ cssStringBuilder.AppendLine(" font-weight: normal !important;");+ cssStringBuilder.AppendLine(" font-variant: normal;");+ cssStringBuilder.AppendLine(" text-transform: none;");+ cssStringBuilder.AppendLine(" line-height: 1;");+ cssStringBuilder.AppendLine(" -webkit-font-smoothing: antialiased;");+ cssStringBuilder.AppendLine(" -moz-osx-font-smoothing: grayscale;");+ cssStringBuilder.AppendLine("}");++ return cssStringBuilder.ToString();+ }+ catch (Exception ex)+ {+ LogGenerateCssForFontAsyncFailed(ex, fontDefinition.FontFamily);+ }++ return string.Empty;+ }++ private async Task<string> ConvertFontToBase64Async(FontDefinition fontDefinition)+ {+ byte[] buffer = new byte[fontDefinition.FontReader.Length];++ await fontDefinition.FontReader.ReadAsync(buffer);++ string base64String = Convert.ToBase64String(buffer);++ fontDefinition.Dispose();+ return base64String;+ }++ [LoggerMessage(0, LogLevel.Error, "Unexpectedly failed to get font definitions from '{resourceAssemblyIdentifierName}'.")]+ partial void LogGetFontDefinitionsAsyncFailed(Exception ex, string resourceAssemblyIdentifierName);++ [LoggerMessage(1, LogLevel.Error, "Unexpectedly failed to load the font '{fontName}'.")]+ partial void LogGenerateCssForFontAsyncFailed(Exception ex, string fontName);++ [LoggerMessage(2, LogLevel.Information, "Loaded {fontCount} font(s) in {loadingDuration} ms and injected them in {injectionDuration} ms")]+ partial void LogImportThirdPartyFontsAsync(int fontCount, double loadingDuration, double injectionDuration);+}diff --git a/src/app/dev/DevToys.Blazor/Pages/MainLayout.razor.cs b/src/app/dev/DevToys.Blazor/Pages/MainLayout.razor.csindex a28fd63f1..6e0c3d2e3 100644--- a/src/app/dev/DevToys.Blazor/Pages/MainLayout.razor.cs+++ b/src/app/dev/DevToys.Blazor/Pages/MainLayout.razor.cs@@ -1,4 +1,7 @@-namespace DevToys.Blazor.Pages;+using DevToys.Blazor.Core.Services;+using DevToys.Core.Settings;++namespace DevToys.Blazor.Pages;public partial class MainLayout : LayoutComponentBase{@@ -14,6 +17,9 @@ public partial class MainLayout : LayoutComponentBase[Import]private IFontProvider FontProvider { get; set; } = default!;+ [Inject]+ internal FontService FontService { get; set; } = default!;+[Parameter]public string ThemeName { get; set; } = default!;@@ -34,6 +40,12 @@ public partial class MainLayout : LayoutComponentBaseSetDefaultTextEditorFont();}+ protected override Task OnInitializedAsync()+ {+ FontService.ImportThirdPartyFontsAsync().ForgetSafely();+ return base.OnInitializedAsync();+ }+protected override async Task OnAfterRenderAsync(bool firstRender){if (firstRender)diff --git a/src/app/dev/DevToys.Blazor/wwwroot/fonts/FluentSystemIcons-Regular.woff b/src/app/dev/DevToys.Blazor/wwwroot/fonts/FluentSystemIcons-Regular.woffdeleted file mode 100644index 78c68773b..000000000Binary files a/src/app/dev/DevToys.Blazor/wwwroot/fonts/FluentSystemIcons-Regular.woff and /dev/null differdiff --git a/src/app/dev/DevToys.Blazor/wwwroot/fonts/FluentSystemIcons-Regular.woff2 b/src/app/dev/DevToys.Blazor/wwwroot/fonts/FluentSystemIcons-Regular.woff2deleted file mode 100644index 2ef2f2083..000000000Binary files a/src/app/dev/DevToys.Blazor/wwwroot/fonts/FluentSystemIcons-Regular.woff2 and /dev/null differdiff --git a/src/app/dev/DevToys.Blazor/wwwroot/fonts/FluentSystemIcons-Regular.ttf b/src/app/dev/DevToys.Core/Assets/Fonts/FluentSystemIcons-Regular.ttfsimilarity index 66%rename from src/app/dev/DevToys.Blazor/wwwroot/fonts/FluentSystemIcons-Regular.ttfrename to src/app/dev/DevToys.Core/Assets/Fonts/FluentSystemIcons-Regular.ttfindex 5a64afb3a..2df813a44 100644Binary files a/src/app/dev/DevToys.Blazor/wwwroot/fonts/FluentSystemIcons-Regular.ttf and b/src/app/dev/DevToys.Core/Assets/Fonts/FluentSystemIcons-Regular.ttf differdiff --git a/src/app/dev/DevToys.Core/BuiltInTools/DevToysCoreResourceManagerAssemblyIdentifier.cs b/src/app/dev/DevToys.Core/BuiltInTools/DevToysCoreResourceManagerAssemblyIdentifier.csnew file mode 100644index 000000000..3c8ebb566--- /dev/null+++ b/src/app/dev/DevToys.Core/BuiltInTools/DevToysCoreResourceManagerAssemblyIdentifier.cs@@ -0,0 +1,20 @@+using System.Reflection;++namespace DevToys.Core.BuiltInTools;++[Export(typeof(IResourceAssemblyIdentifier))]+[Name(nameof(DevToysCoreResourceManagerAssemblyIdentifier))]+public sealed class DevToysCoreResourceManagerAssemblyIdentifier : IResourceAssemblyIdentifier+{+ public ValueTask<FontDefinition[]> GetFontDefinitionsAsync()+ {+ var assembly = Assembly.GetExecutingAssembly();+ string resourceName = "DevToys.Core.Assets.Fonts.FluentSystemIcons-Regular.ttf";++ Stream stream = assembly.GetManifestResourceStream(resourceName)!;+ return new ValueTask<FontDefinition[]>(new[]+ {+ new FontDefinition("FluentSystemIcons", stream)+ });+ }+}diff --git a/src/app/dev/DevToys.Tools/Tools/Settings/Settings.Designer.cs b/src/app/dev/DevToys.Core/BuiltInTools/Settings/Settings.Designer.cssimilarity index 95%rename from src/app/dev/DevToys.Tools/Tools/Settings/Settings.Designer.csrename to src/app/dev/DevToys.Core/BuiltInTools/Settings/Settings.Designer.csindex 5bd73da95..9cfdc136a 100644--- a/src/app/dev/DevToys.Tools/Tools/Settings/Settings.Designer.cs+++ b/src/app/dev/DevToys.Core/BuiltInTools/Settings/Settings.Designer.cs@@ -8,7 +8,7 @@// </auto-generated>//-------------------------------------------------------------------------------namespace DevToys.Tools.Tools.Settings {+namespace DevToys.Core.BuiltInTools.Settings {using System;@@ -39,7 +39,7 @@ namespace DevToys.Tools.Tools.Settings {internal static global::System.Resources.ResourceManager ResourceManager {get {if (object.ReferenceEquals(resourceMan, null)) {- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DevToys.Tools.Tools.Settings.Settings", typeof(Settings).Assembly);+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DevToys.Core.BuiltInTools.Settings.Settings", typeof(Settings).Assembly);resourceMan = temp;}return resourceMan;diff --git a/src/app/dev/DevToys.Tools/Tools/Settings/Settings.resx b/src/app/dev/DevToys.Core/BuiltInTools/Settings/Settings.resxsimilarity index 100%rename from src/app/dev/DevToys.Tools/Tools/Settings/Settings.resxrename to src/app/dev/DevToys.Core/BuiltInTools/Settings/Settings.resxdiff --git a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs b/src/app/dev/DevToys.Core/BuiltInTools/Settings/SettingsGuiTool.cssimilarity index 88%rename from src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.csrename to src/app/dev/DevToys.Core/BuiltInTools/Settings/SettingsGuiTool.csindex f245800ad..521a448ac 100644--- a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs+++ b/src/app/dev/DevToys.Core/BuiltInTools/Settings/SettingsGuiTool.cs@@ -1,24 +1,14 @@-namespace DevToys.Tools.Tools.Settings;+using DevToys.Core.Settings;-internal enum GridTestRow-{- FileSelection,- InputTextBox,- Output-}--internal enum GridTestColumn-{- UniqueColumn-}+namespace DevToys.Core.BuiltInTools.Settings;[Export(typeof(IGuiTool))][Name("Settings")][ToolDisplayInformation(IconFontName = "FluentSystemIcons",IconGlyph = '\uF6A9',- ResourceManagerAssemblyIdentifier = nameof(DevToysToolsResourceManagerAssemblyIdentifier),- ResourceManagerBaseName = "DevToys.Tools.Tools.Settings.Settings",+ ResourceManagerAssemblyIdentifier = nameof(DevToysCoreResourceManagerAssemblyIdentifier),+ ResourceManagerBaseName = "DevToys.Core.BuiltInTools.Settings.Settings",ShortDisplayTitleResourceName = nameof(Settings.ShortDisplayTitle),DescriptionResourceName = nameof(Settings.Description),AccessibleNameResourceName = nameof(Settings.AccessibleName))]diff --git a/src/app/dev/DevToys.Core/DevToys.Core.csproj b/src/app/dev/DevToys.Core/DevToys.Core.csprojindex 544968672..7336c630e 100644--- a/src/app/dev/DevToys.Core/DevToys.Core.csproj+++ b/src/app/dev/DevToys.Core/DevToys.Core.csproj@@ -17,4 +17,21 @@<PackageReference Include="Uno.Core.Extensions.Logging" /><PackageReference Include="Uno.Core.Extensions.Logging.Singleton" /></ItemGroup>+ <ItemGroup>+ <EmbeddedResource Include="Assets\Fonts\FluentSystemIcons-Regular.ttf">+ <ExcludeFromSingleFile>true</ExcludeFromSingleFile>+ <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>+ </EmbeddedResource>+ <Compile Update="BuiltInTools\Settings\Settings.Designer.cs">+ <DependentUpon>Settings.resx</DependentUpon>+ <DesignTime>True</DesignTime>+ <AutoGen>True</AutoGen>+ </Compile>+ </ItemGroup>+ <ItemGroup>+ <EmbeddedResource Update="BuiltInTools\Settings\Settings.resx">+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>+ <Generator>ResXFileCodeGenerator</Generator>+ </EmbeddedResource>+ </ItemGroup></Project>\ No newline at end of filediff --git a/src/app/dev/DevToys.Core/Logging/FileLoggerProvider.cs b/src/app/dev/DevToys.Core/Logging/FileLoggerProvider.csindex 82ab0745d..1f2aa53b1 100644--- a/src/app/dev/DevToys.Core/Logging/FileLoggerProvider.cs+++ b/src/app/dev/DevToys.Core/Logging/FileLoggerProvider.cs@@ -1,5 +1,4 @@using System.Collections.Concurrent;-using DevToys.Api;using Microsoft.Extensions.Logging;namespace DevToys.Core.Logging;diff --git a/src/app/dev/DevToys.Core/Logging/LoggingBuilderExtensions.cs b/src/app/dev/DevToys.Core/Logging/LoggingBuilderExtensions.csindex f42f370e0..192dfd941 100644--- a/src/app/dev/DevToys.Core/Logging/LoggingBuilderExtensions.cs+++ b/src/app/dev/DevToys.Core/Logging/LoggingBuilderExtensions.cs@@ -1,5 +1,4 @@-using DevToys.Api;-using Microsoft.Extensions.DependencyInjection;+using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Logging;namespace DevToys.Core.Logging;diff --git a/src/app/dev/DevToys.Core/Mef/MefComposer.cs b/src/app/dev/DevToys.Core/Mef/MefComposer.csindex 15cc8315c..18dbb06b4 100644--- a/src/app/dev/DevToys.Core/Mef/MefComposer.cs+++ b/src/app/dev/DevToys.Core/Mef/MefComposer.cs@@ -1,6 +1,5 @@using System.ComponentModel.Composition.Hosting;using System.Reflection;-using DevToys.Api;using Microsoft.Extensions.Logging;using Uno.Extensions;diff --git a/src/app/dev/DevToys.Core/Mef/MefProvider.cs b/src/app/dev/DevToys.Core/Mef/MefProvider.csindex 303b4f6d5..215b2df16 100644--- a/src/app/dev/DevToys.Core/Mef/MefProvider.cs+++ b/src/app/dev/DevToys.Core/Mef/MefProvider.cs@@ -1,5 +1,4 @@using System.ComponentModel.Composition.Hosting;-using DevToys.Api;namespace DevToys.Core.Mef;diff --git a/src/app/dev/DevToys.Core/OSHelper.cs b/src/app/dev/DevToys.Core/OSHelper.csindex a0282d8e5..b491b33b2 100644--- a/src/app/dev/DevToys.Core/OSHelper.cs+++ b/src/app/dev/DevToys.Core/OSHelper.cs@@ -1,6 +1,4 @@-using DevToys.Api;--namespace DevToys.Core;+namespace DevToys.Core;public static class OSHelper{diff --git a/src/app/dev/DevToys.Core/Properties/AdditionGlobalUsings.cs b/src/app/dev/DevToys.Core/Properties/AdditionGlobalUsings.csnew file mode 100644index 000000000..b6402eb11--- /dev/null+++ b/src/app/dev/DevToys.Core/Properties/AdditionGlobalUsings.cs@@ -0,0 +1,2 @@+global using DevToys.Api;+global using static DevToys.Api.GUI;diff --git a/src/app/dev/DevToys.Core/Settings/PredefinedSettings.cs b/src/app/dev/DevToys.Core/Settings/PredefinedSettings.csindex 98c769c50..646706a4f 100644--- a/src/app/dev/DevToys.Core/Settings/PredefinedSettings.cs+++ b/src/app/dev/DevToys.Core/Settings/PredefinedSettings.cs@@ -1,9 +1,37 @@-using DevToys.Api;--namespace DevToys.Core.Settings;+namespace DevToys.Core.Settings;public static class PredefinedSettings{+ /// <summary>+ /// Preferred default fonts. The app will the first font in this list that is available on the system.+ /// </summary>+ public static readonly string[] DefaultFonts+ = new[]+ {+ // Popular fonts developers install. If it's on the system, users likely want to use it.+ "Fira Code",+ "Source Code Pro",+ "DejaVu Sans Mono",+ "Hack",++ // Default Visual Studio fonts.+ "Cascadia Mono",+ "Cascadia Code",++ // Fonts included on MacOS.+ "Menlo",+ "Monaco",+ "SF Mono",+ "SF Pro",++ // Fonts included on Windows and MacOS.+ "Consolas",+ "Courier New",++ // Fonts included on Windows.+ "Segoe UI",+ };+/// <summary>/// The language to use for the texts in the user interface./// </summary>@@ -51,4 +79,59 @@ public static class PredefinedSettings= new(name: nameof(SmartDetection),defaultValue: true);+ /// <summary>+ /// Whether the compact mode is enabled or not.+ /// </summary>+ public static readonly SettingDefinition<bool> CompactMode+ = new(+ name: nameof(CompactMode),+ defaultValue: false);++ /// <summary>+ /// The font family name to use in the text editor.+ /// </summary>+ public static readonly SettingDefinition<string> TextEditorFont+ = new(+ name: nameof(TextEditorFont),+ defaultValue: string.Empty); // Default value will be defined by the app depending on the operating system.++ /// <summary>+ /// Whether the text in the text editor should wrap.+ /// </summary>+ public static readonly SettingDefinition<bool> TextEditorTextWrapping+ = new(+ name: nameof(TextEditorTextWrapping),+ defaultValue: false);++ /// <summary>+ /// Whether the line numbers should be displayed in the text editor.+ /// </summary>+ public static readonly SettingDefinition<bool> TextEditorLineNumbers+ = new(+ name: nameof(TextEditorLineNumbers),+ defaultValue: true);++ /// <summary>+ /// Whether the line where the caret is should be highlighted in the text editor.+ /// </summary>+ public static readonly SettingDefinition<bool> TextEditorHighlightCurrentLine+ = new(+ name: nameof(TextEditorHighlightCurrentLine),+ defaultValue: true);++ /// <summary>+ /// Whether white spaces should be rendered in the text editor.+ /// </summary>+ public static readonly SettingDefinition<bool> TextEditorRenderWhitespace+ = new(+ name: nameof(TextEditorRenderWhitespace),+ defaultValue: false);++ /// <summary>+ /// Whether when using the Paste command, the text in the editor should be replaced or appended.+ /// </summary>+ public static readonly SettingDefinition<bool> TextEditorPasteClearsText+ = new(+ name: nameof(TextEditorPasteClearsText),+ defaultValue: true);}diff --git a/src/app/dev/DevToys.Core/Settings/SettingsProvider.cs b/src/app/dev/DevToys.Core/Settings/SettingsProvider.csindex 5fa9908c6..0960750f3 100644--- a/src/app/dev/DevToys.Core/Settings/SettingsProvider.cs+++ b/src/app/dev/DevToys.Core/Settings/SettingsProvider.cs@@ -1,6 +1,5 @@using System.Collections;using System.Globalization;-using DevToys.Api;using Microsoft.Extensions.Logging;using Newtonsoft.Json;using Uno.Extensions;diff --git a/src/app/dev/DevToys.Core/Tools/GuiToolInstance.cs b/src/app/dev/DevToys.Core/Tools/GuiToolInstance.csindex 6c3d5cdd8..4c8c3a37b 100644--- a/src/app/dev/DevToys.Core/Tools/GuiToolInstance.cs+++ b/src/app/dev/DevToys.Core/Tools/GuiToolInstance.cs@@ -1,7 +1,6 @@using System.Reflection;using System.Resources;using CommunityToolkit.Mvvm.ComponentModel;-using DevToys.Api;using DevToys.Core.Tools.Metadata;using Microsoft.Extensions.Logging;using Uno.Extensions;@@ -37,13 +36,13 @@ public sealed partial class GuiToolInstance : ObservableObject_instance = new(() =>{IGuiTool instance = _guiToolDefinition.Value;- LogInstanceCreated(_guiToolDefinition.Metadata.InternalComponentName);+ LogInstanceCreated(InternalComponentName);return instance;});_view = new(() => _instance.Value.View); // TODO: Try Catch and log?- LogInitialized(_guiToolDefinition.Metadata.InternalComponentName);+ LogInitialized(InternalComponentName);}public string InternalComponentName => _guiToolDefinition.Metadata.InternalComponentName;@@ -91,7 +90,15 @@ public sealed partial class GuiToolInstance : ObservableObject/// </summary>public void PassSmartDetectedData(string dataTypeName, object? parsedData){- _instance.Value.OnDataReceived(dataTypeName, parsedData);+ try+ {+ _instance.Value.OnDataReceived(dataTypeName, parsedData);+ }+ catch (NotImplementedException) { }+ catch (Exception ex)+ {+ LogPassSmartDetectedDataFailed(ex, InternalComponentName);+ }}private ResourceManager? GetResourceManager(Assembly? resourceManagerAssembly)@@ -122,4 +129,7 @@ public sealed partial class GuiToolInstance : ObservableObject[LoggerMessage(1, LogLevel.Information, "Instance of '{toolName}' tool created.")]partial void LogInstanceCreated(string toolName);++ [LoggerMessage(2, LogLevel.Warning, "Unexpectedly failed to pass smart detection data to '{toolName}'.")]+ partial void LogPassSmartDetectedDataFailed(Exception ex, string toolName);}diff --git a/src/app/dev/DevToys.Core/Tools/GuiToolProvider.cs b/src/app/dev/DevToys.Core/Tools/GuiToolProvider.csindex 33e863df5..da85dbad9 100644--- a/src/app/dev/DevToys.Core/Tools/GuiToolProvider.cs+++ b/src/app/dev/DevToys.Core/Tools/GuiToolProvider.cs@@ -1,6 +1,5 @@using System.Collections.ObjectModel;using System.Reflection;-using DevToys.Api;using DevToys.Core.Tools.Metadata;using DevToys.Core.Tools.ViewItems;using DevToys.Localization;@@ -36,7 +35,7 @@ public sealed partial class GuiToolProvidershowLongDisplayTitle: true);private readonly ILogger _logger;- private readonly IEnumerable<Lazy<IResourceManagerAssemblyIdentifier, ResourceManagerAssemblyIdentifierMetadata>> _resourceManagerAssemblyIdentifiers;+ private readonly IEnumerable<Lazy<IResourceAssemblyIdentifier, ResourceAssemblyIdentifierMetadata>> _resourceAssemblyIdentifiers;private readonly IEnumerable<Lazy<GuiToolGroup, GuiToolGroupMetadata>> _guiToolGroups;private readonly ISettingsProvider _settingsProvider;private readonly IReadOnlyList<GuiToolInstance> _footerToolInstances;@@ -54,11 +53,11 @@ public sealed partial class GuiToolProviderpublic GuiToolProvider([ImportMany] IEnumerable<Lazy<IGuiTool, GuiToolMetadata>> guiTools,[ImportMany] IEnumerable<Lazy<GuiToolGroup, GuiToolGroupMetadata>> guiToolGroups,- [ImportMany] IEnumerable<Lazy<IResourceManagerAssemblyIdentifier, ResourceManagerAssemblyIdentifierMetadata>> resourceManagerAssemblyIdentifiers,+ [ImportMany] IEnumerable<Lazy<IResourceAssemblyIdentifier, ResourceAssemblyIdentifierMetadata>> resourceAssemblyIdentifiers,ISettingsProvider settingsProvider){_logger = this.Log();- _resourceManagerAssemblyIdentifiers = resourceManagerAssemblyIdentifiers;+ _resourceAssemblyIdentifiers = resourceAssemblyIdentifiers;_settingsProvider = settingsProvider;_guiToolGroups = guiToolGroups;@@ -563,7 +562,7 @@ public sealed partial class GuiToolProviderprivate Assembly GetResourceManagerAssembly(string resourceManagerAssemblyIdentifier){- foreach (Lazy<IResourceManagerAssemblyIdentifier, ResourceManagerAssemblyIdentifierMetadata> item in _resourceManagerAssemblyIdentifiers)+ foreach (Lazy<IResourceAssemblyIdentifier, ResourceAssemblyIdentifierMetadata> item in _resourceAssemblyIdentifiers){if (string.Equals(item.Metadata.InternalComponentName, resourceManagerAssemblyIdentifier, StringComparison.Ordinal)){diff --git a/src/app/dev/DevToys.Core/Tools/Metadata/DataTypeDetectorMetadata.cs b/src/app/dev/DevToys.Core/Tools/Metadata/DataTypeDetectorMetadata.csindex 3a0ceaef2..3486f04ab 100644--- a/src/app/dev/DevToys.Core/Tools/Metadata/DataTypeDetectorMetadata.cs+++ b/src/app/dev/DevToys.Core/Tools/Metadata/DataTypeDetectorMetadata.cs@@ -1,6 +1,4 @@-using DevToys.Api;--namespace DevToys.Core.Tools.Metadata;+namespace DevToys.Core.Tools.Metadata;[DebuggerDisplay($"DataTypeName = {{{nameof(DataTypeName)}}}, DataTypeBaseName = {{{nameof(DataTypeBaseName)}}}")]public sealed class DataTypeDetectorMetadatadiff --git a/src/app/dev/DevToys.Core/Tools/Metadata/GuiToolGroupMetadata.cs b/src/app/dev/DevToys.Core/Tools/Metadata/GuiToolGroupMetadata.csindex 974ec7253..1614905e7 100644--- a/src/app/dev/DevToys.Core/Tools/Metadata/GuiToolGroupMetadata.cs+++ b/src/app/dev/DevToys.Core/Tools/Metadata/GuiToolGroupMetadata.cs@@ -1,6 +1,4 @@-using DevToys.Api;--namespace DevToys.Core.Tools.Metadata;+namespace DevToys.Core.Tools.Metadata;[DebuggerDisplay($"InternalComponentName = {{{nameof(InternalComponentName)}}}")]public sealed class GuiToolGroupMetadata : IOrderableMetadatadiff --git a/src/app/dev/DevToys.Core/Tools/Metadata/GuiToolMetadata.cs b/src/app/dev/DevToys.Core/Tools/Metadata/GuiToolMetadata.csindex 253cf7cad..f73a427ab 100644--- a/src/app/dev/DevToys.Core/Tools/Metadata/GuiToolMetadata.cs+++ b/src/app/dev/DevToys.Core/Tools/Metadata/GuiToolMetadata.cs@@ -1,6 +1,4 @@-using DevToys.Api;--namespace DevToys.Core.Tools.Metadata;+namespace DevToys.Core.Tools.Metadata;[DebuggerDisplay($"InternalComponentName = {{{nameof(InternalComponentName)}}}")]public sealed class GuiToolMetadata : IOrderableMetadatadiff --git a/src/app/dev/DevToys.Core/Tools/ResourceManagerAssemblyIdentifierMetadata.cs b/src/app/dev/DevToys.Core/Tools/ResourceAssemblyIdentifierMetadata.cssimilarity index 62%rename from src/app/dev/DevToys.Core/Tools/ResourceManagerAssemblyIdentifierMetadata.csrename to src/app/dev/DevToys.Core/Tools/ResourceAssemblyIdentifierMetadata.csindex 67dcb84a0..1e2139697 100644--- a/src/app/dev/DevToys.Core/Tools/ResourceManagerAssemblyIdentifierMetadata.cs+++ b/src/app/dev/DevToys.Core/Tools/ResourceAssemblyIdentifierMetadata.cs@@ -1,13 +1,11 @@-using DevToys.Api;--namespace DevToys.Core.Tools;+namespace DevToys.Core.Tools;[DebuggerDisplay($"InternalComponentName = {{{nameof(InternalComponentName)}}}")]-public sealed class ResourceManagerAssemblyIdentifierMetadata+public sealed class ResourceAssemblyIdentifierMetadata{public string InternalComponentName { get; }- public ResourceManagerAssemblyIdentifierMetadata(IDictionary<string, object> metadata)+ public ResourceAssemblyIdentifierMetadata(IDictionary<string, object> metadata){InternalComponentName = metadata.GetValueOrDefault(nameof(NameAttribute.InternalComponentName)) as string ?? string.Empty;Guard.IsNotNullOrWhiteSpace(InternalComponentName);diff --git a/src/app/dev/DevToys.Core/Tools/SmartDetectionService.cs b/src/app/dev/DevToys.Core/Tools/SmartDetectionService.csindex e20f64fbf..e964445f3 100644--- a/src/app/dev/DevToys.Core/Tools/SmartDetectionService.cs+++ b/src/app/dev/DevToys.Core/Tools/SmartDetectionService.cs@@ -1,5 +1,4 @@-using DevToys.Api;-using DevToys.Core.Tools.Metadata;+using DevToys.Core.Tools.Metadata;using Microsoft.Extensions.Logging;using Uno.Extensions;diff --git a/src/app/dev/DevToys.Core/Tools/ViewItems/GroupViewItem.cs b/src/app/dev/DevToys.Core/Tools/ViewItems/GroupViewItem.csindex 3c0edf234..d80a636d2 100644--- a/src/app/dev/DevToys.Core/Tools/ViewItems/GroupViewItem.cs+++ b/src/app/dev/DevToys.Core/Tools/ViewItems/GroupViewItem.cs@@ -1,6 +1,5 @@using System.Collections.ObjectModel;using CommunityToolkit.Mvvm.ComponentModel;-using DevToys.Api;namespace DevToys.Core.Tools.ViewItems;diff --git a/src/app/dev/DevToys.Core/Tools/ViewItems/GuiToolViewItem.cs b/src/app/dev/DevToys.Core/Tools/ViewItems/GuiToolViewItem.csindex 5479d866d..76ccb8229 100644--- a/src/app/dev/DevToys.Core/Tools/ViewItems/GuiToolViewItem.cs+++ b/src/app/dev/DevToys.Core/Tools/ViewItems/GuiToolViewItem.cs@@ -1,5 +1,4 @@using CommunityToolkit.Mvvm.ComponentModel;-using DevToys.Api;namespace DevToys.Core.Tools.ViewItems;diff --git a/src/app/dev/DevToys.Localization/DevToysLocalizationResourceManagerAssemblyIdentifier.cs b/src/app/dev/DevToys.Localization/DevToysLocalizationResourceManagerAssemblyIdentifier.csindex 27a7b8d20..05b4cb07d 100644--- a/src/app/dev/DevToys.Localization/DevToysLocalizationResourceManagerAssemblyIdentifier.cs+++ b/src/app/dev/DevToys.Localization/DevToysLocalizationResourceManagerAssemblyIdentifier.cs@@ -2,8 +2,12 @@namespace DevToys.Localization;-[Export(typeof(IResourceManagerAssemblyIdentifier))]+[Export(typeof(IResourceAssemblyIdentifier))][Name(nameof(DevToysLocalizationResourceManagerAssemblyIdentifier))]-public sealed class DevToysLocalizationResourceManagerAssemblyIdentifier : IResourceManagerAssemblyIdentifier+public sealed class DevToysLocalizationResourceManagerAssemblyIdentifier : IResourceAssemblyIdentifier{+ public ValueTask<FontDefinition[]> GetFontDefinitionsAsync()+ {+ throw new NotImplementedException();+ }}diff --git a/src/app/dev/DevToys.Tools/DevToys.Tools.csproj b/src/app/dev/DevToys.Tools/DevToys.Tools.csprojindex 2d98a3372..89072ef2f 100644--- a/src/app/dev/DevToys.Tools/DevToys.Tools.csproj+++ b/src/app/dev/DevToys.Tools/DevToys.Tools.csproj@@ -25,11 +25,6 @@<AutoGen>True</AutoGen><DependentUpon>Sample.resx</DependentUpon></Compile>- <Compile Update="Tools\Settings\Settings.Designer.cs">- <DependentUpon>Settings.resx</DependentUpon>- <DesignTime>True</DesignTime>- <AutoGen>True</AutoGen>- </Compile><Compile Update="Tools\Test\Test.Designer.cs"><DependentUpon>Test.resx</DependentUpon><DesignTime>True</DesignTime>@@ -41,10 +36,6 @@<Generator>ResXFileCodeGenerator</Generator><LastGenOutput>Sample.Designer.cs</LastGenOutput></EmbeddedResource>- <EmbeddedResource Update="Tools\Settings\Settings.resx">- <LastGenOutput>Settings.Designer.cs</LastGenOutput>- <Generator>ResXFileCodeGenerator</Generator>- </EmbeddedResource><EmbeddedResource Update="Tools\Test\Test.resx"><LastGenOutput>Test.Designer.cs</LastGenOutput><Generator>ResXFileCodeGenerator</Generator>diff --git a/src/app/dev/DevToys.Tools/DevToysToolsResourceManagerAssemblyIdentifier.cs b/src/app/dev/DevToys.Tools/DevToysToolsResourceManagerAssemblyIdentifier.csindex c06fe31aa..15a9fa60a 100644--- a/src/app/dev/DevToys.Tools/DevToysToolsResourceManagerAssemblyIdentifier.cs+++ b/src/app/dev/DevToys.Tools/DevToysToolsResourceManagerAssemblyIdentifier.cs@@ -1,7 +1,11 @@namespace DevToys.Tools;-[Export(typeof(IResourceManagerAssemblyIdentifier))]+[Export(typeof(IResourceAssemblyIdentifier))][Name(nameof(DevToysToolsResourceManagerAssemblyIdentifier))]-public sealed class DevToysToolsResourceManagerAssemblyIdentifier : IResourceManagerAssemblyIdentifier+public sealed class DevToysToolsResourceManagerAssemblyIdentifier : IResourceAssemblyIdentifier{+ public ValueTask<FontDefinition[]> GetFontDefinitionsAsync()+ {+ throw new NotImplementedException();+ }}diff --git a/src/app/dev/DevToys.Tools/Properties/AdditionGlobalUsings.cs b/src/app/dev/DevToys.Tools/Properties/AdditionGlobalUsings.csindex 52bb7cd80..b6402eb11 100644--- a/src/app/dev/DevToys.Tools/Properties/AdditionGlobalUsings.cs+++ b/src/app/dev/DevToys.Tools/Properties/AdditionGlobalUsings.cs@@ -1,2 +1,2 @@-global using global::DevToys.Api;-global using static global::DevToys.Api.GUI;+global using DevToys.Api;+global using static DevToys.Api.GUI;diff --git a/src/app/dev/DevToys.Tools/Tools/Test/TestGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Test/TestGuiTool.csindex 8c6cf019f..13639a991 100644--- a/src/app/dev/DevToys.Tools/Tools/Test/TestGuiTool.cs+++ b/src/app/dev/DevToys.Tools/Tools/Test/TestGuiTool.cs@@ -1,5 +1,4 @@#if DEBUG-using DevToys.Api;using Newtonsoft.Json.Linq;namespace DevToys.Tools.Tools.Test;diff --git a/src/app/dev/platforms/desktop/DevToys.CLI/Program.cs b/src/app/dev/platforms/desktop/DevToys.CLI/Program.csindex 7119172e7..9322443ca 100644--- a/src/app/dev/platforms/desktop/DevToys.CLI/Program.cs+++ b/src/app/dev/platforms/desktop/DevToys.CLI/Program.cs@@ -35,7 +35,7 @@ internal partial class Program#endif});- global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = loggerFactory;+ Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = loggerFactory;logger = new Logger<Program>(loggerFactory);LogLoggerInitialization(logger, (DateTime.Now - startTime).TotalMilliseconds);diff --git a/src/app/dev/platforms/desktop/DevToys.MacOS/MauiProgram.cs b/src/app/dev/platforms/desktop/DevToys.MacOS/MauiProgram.csindex 6e79d3f77..b82a70bcf 100644--- a/src/app/dev/platforms/desktop/DevToys.MacOS/MauiProgram.cs+++ b/src/app/dev/platforms/desktop/DevToys.MacOS/MauiProgram.cs@@ -2,6 +2,7 @@using DevToys.Blazor.Core.Languages;using DevToys.Blazor.Core.Services;using DevToys.Business.ViewModels;+using DevToys.Core.BuiltInTools;using DevToys.Core.Logging;using DevToys.Core.Mef;using DevToys.MacOS.Core;@@ -51,7 +52,8 @@ public partial class MauiProgramMefComposer= new MefComposer(new[] {- typeof(MainWindowViewModel).Assembly+ typeof(MainWindowViewModel).Assembly,+ typeof(DevToysBlazorResourceManagerAssemblyIdentifier).Assembly},pluginFolder: "../Resources/Plugins");@@ -103,6 +105,7 @@ public partial class MauiProgramserviceCollection.AddSingleton<IWindowService, WindowService>();serviceCollection.AddScoped<PopoverService, PopoverService>();serviceCollection.AddScoped<ContextMenuService, ContextMenuService>();+ serviceCollection.AddScoped<FontService, FontService>();ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();diff --git a/src/app/dev/platforms/desktop/DevToys.Windows/Core/ThemeListener.cs b/src/app/dev/platforms/desktop/DevToys.Windows/Core/ThemeListener.csindex 04ddafa31..48e55f784 100644--- a/src/app/dev/platforms/desktop/DevToys.Windows/Core/ThemeListener.cs+++ b/src/app/dev/platforms/desktop/DevToys.Windows/Core/ThemeListener.cs@@ -1,6 +1,7 @@using System.Windows;using DevToys.Api;using DevToys.Blazor.Components;+using DevToys.Core.Settings;using Microsoft.Win32;namespace DevToys.Windows.Core;diff --git a/src/app/dev/platforms/desktop/DevToys.Windows/MainWindow.xaml.cs b/src/app/dev/platforms/desktop/DevToys.Windows/MainWindow.xaml.csindex 74fdc8637..b57ce4fa0 100644--- a/src/app/dev/platforms/desktop/DevToys.Windows/MainWindow.xaml.cs+++ b/src/app/dev/platforms/desktop/DevToys.Windows/MainWindow.xaml.cs@@ -3,6 +3,7 @@ using DevToys.Blazor.Core.Languages;using DevToys.Blazor.Core.Services;using DevToys.Business.ViewModels;using DevToys.Core;+using DevToys.Core.BuiltInTools;using DevToys.Core.Logging;using DevToys.Core.Mef;using DevToys.Windows.Controls;@@ -42,7 +43,8 @@ public partial class MainWindow : MicaWindowWithOverlay_mefComposer= new MefComposer(new[] {- typeof(MainWindowViewModel).Assembly+ typeof(MainWindowViewModel).Assembly,+ typeof(DevToysCoreResourceManagerAssemblyIdentifier).Assembly});LogInitialization((DateTime.Now - startTime).TotalMilliseconds);@@ -143,6 +145,7 @@ public partial class MainWindow : MicaWindowWithOverlayserviceCollection.AddSingleton<IWindowService, WindowService>();serviceCollection.AddScoped<PopoverService, PopoverService>();serviceCollection.AddScoped<ContextMenuService, ContextMenuService>();+ serviceCollection.AddScoped<FontService, FontService>();ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();diff --git a/src/app/dev/shared/GlobalUsings.cs b/src/app/dev/shared/GlobalUsings.csindex 0662922d6..fca6a1eb8 100644--- a/src/app/dev/shared/GlobalUsings.cs+++ b/src/app/dev/shared/GlobalUsings.cs@@ -1,14 +1,14 @@-global using global::CommunityToolkit.Diagnostics;-global using global::System;-global using global::System.Collections.Generic;-global using global::System.ComponentModel;-global using global::System.ComponentModel.Composition;-global using global::System.Diagnostics;-global using global::System.Diagnostics.CodeAnalysis;-global using global::System.Linq;-global using global::System.Threading;-global using global::System.Threading.Tasks;-global using ExportAttribute = global::System.ComponentModel.Composition.ExportAttribute;+global using CommunityToolkit.Diagnostics;+global using System;+global using System.Collections.Generic;+global using System.ComponentModel;+global using System.ComponentModel.Composition;+global using System.Diagnostics;+global using System.Diagnostics.CodeAnalysis;+global using System.Linq;+global using System.Threading;+global using System.Threading.Tasks;+global using ExportAttribute = System.ComponentModel.Composition.ExportAttribute;#if __MACCATALYST__[assembly: System.Runtime.Versioning.SupportedOSPlatform("ios14.0")] // MacCatalyst is a superset of iOS, therefore it's also supported.diff --git a/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockResourceManagerAssemblyIdentifier.cs b/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockResourceManagerAssemblyIdentifier.csindex 7f8e58f20..bc993cb42 100644--- a/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockResourceManagerAssemblyIdentifier.cs+++ b/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockResourceManagerAssemblyIdentifier.cs@@ -1,9 +1,14 @@using System.ComponentModel.Composition;+using System.Threading.Tasks;namespace DevToys.UnitTests.Mocks.Tools;-[Export(typeof(IResourceManagerAssemblyIdentifier))]+[Export(typeof(IResourceAssemblyIdentifier))][Name(nameof(MockResourceManagerAssemblyIdentifier))]-internal sealed class MockResourceManagerAssemblyIdentifier : IResourceManagerAssemblyIdentifier+internal sealed class MockResourceManagerAssemblyIdentifier : IResourceAssemblyIdentifier{+ public ValueTask<FontDefinition[]> GetFontDefinitionsAsync()+ {+ throw new NotImplementedException();+ }}