From 1598c5fd3ca32c6a1815981de0c5966f0092e3df Mon Sep 17 00:00:00 2001 From: 000hen Date: Thu, 16 Jul 2026 17:29:41 +0800 Subject: [PATCH 1/7] refactor: Adopt XAML-first localization and tests - Move static UI text into x:Uid resources and add/clean many UIDs and ContentDialog XAML shells - Add JustHostMC.App.ResourceTests to validate RESW/XAML parity, IDs, duplicates, and programmatic exceptions - Document resource architecture and rules in docs/resources.md - Replace custom BoolToVisibility converter with CommunityToolkit.WinUI.Converters and add package reference - Update LocalizationService to map dotted keys to MRT slash lookup and restrict ILocalizer to runtime/backend keys - Introduce PermissionLabel control and refactor viewmodels/models to expose semantic enums/flags instead of inline localized strings --- AGENTS.md | 20 +- JustHostMC.sln | 19 + .../BackupConfigFiniteStateTests.cs | 74 ++ .../ControlLocalizationArchitectureTests.cs | 43 ++ .../ConverterArchitectureTests.cs | 27 + .../FeatureFiniteStateTests.cs | 107 +++ .../JustHostMC.App.ResourceTests.csproj | 21 + .../MainSurfaceFiniteStateTests.cs | 78 ++ .../ModelLocalizationArchitectureTests.cs | 31 + .../RepositoryLayout.cs | 26 + .../ResourceCatalog.cs | 26 + .../ResourceCatalogTests.cs | 32 + .../ResourceIntegrityTests.cs | 268 +++++++ .../UpdateDuplicateComments.ps1 | 52 ++ app/JustHostMC.App/App.xaml | 11 +- .../Controls/AdaptiveFilterLayout.xaml | 2 +- .../Controls/ConfigEntryEditor.xaml | 30 +- .../Controls/InventoryItemDetails.xaml | 71 ++ .../Controls/InventoryItemDetails.xaml.cs | 11 + app/JustHostMC.App/Controls/LogViewer.xaml | 1 + app/JustHostMC.App/Controls/LogViewer.xaml.cs | 5 - .../Controls/PermissionLabel.xaml | 23 + .../Controls/PermissionLabel.xaml.cs | 70 ++ .../Controls/ScriptEntryCard.xaml | 24 +- .../Controls/ScriptEntryCard.xaml.cs | 2 - .../Controls/Server/ServerConfigPanel.xaml | 36 +- .../Controls/Server/ServerConfigPanel.xaml.cs | 9 - .../Controls/Server/ServerHeaderPanel.xaml | 138 +++- .../Controls/Server/ServerHeaderPanel.xaml.cs | 21 +- .../Controls/Server/ServerModsPanel.xaml | 26 +- .../Controls/Server/ServerModsPanel.xaml.cs | 6 - .../Server/ServerPerformancePanel.xaml | 5 +- .../Server/ServerPerformancePanel.xaml.cs | 9 - .../Controls/Server/ServerPlayersPanel.xaml | 21 +- .../Server/ServerPlayersPanel.xaml.cs | 52 +- .../Converters/BoolToVisibilityConverter.cs | 26 - app/JustHostMC.App/JustHostMC.App.csproj | 1 + app/JustHostMC.App/MainWindow.xaml | 15 +- app/JustHostMC.App/MainWindow.xaml.cs | 46 +- app/JustHostMC.App/Models/BanEntryItem.cs | 19 +- app/JustHostMC.App/Models/ConfigEntryItem.cs | 25 +- app/JustHostMC.App/Models/ModFileItem.cs | 3 +- app/JustHostMC.App/Models/ParserItem.cs | 2 +- app/JustHostMC.App/Models/PermissionLabels.cs | 26 - .../Models/PlayerInventoryItemView.cs | 4 + app/JustHostMC.App/Models/ProviderItem.cs | 2 +- app/JustHostMC.App/Models/ScriptEntryItem.cs | 8 +- app/JustHostMC.App/Models/ScriptItem.cs | 2 +- app/JustHostMC.App/Models/ServerItem.cs | 90 ++- app/JustHostMC.App/Services/ILocalizer.cs | 8 +- .../Services/LocalizationService.cs | 21 +- .../Services/MinecraftItemNbtParser.cs | 6 +- .../Strings/en-US/Resources.resw | 727 +++++++++--------- .../Strings/zh-TW/Resources.resw | 721 ++++++++--------- .../ViewModels/BackupsViewModel.cs | 107 ++- .../ViewModels/MainViewModel.cs | 49 +- .../ViewModels/ModsViewModel.cs | 47 +- .../ViewModels/ScriptsViewModel.cs | 15 +- .../ViewModels/ServerConfigViewModel.cs | 54 +- .../ViewModels/SettingsViewModel.cs | 186 +++-- .../ViewModels/ShopDetailViewModel.cs | 51 +- .../ViewModels/ShopViewModel.cs | 18 +- .../Views/BackupsContentDialog.xaml | 11 + .../Views/BackupsContentDialog.xaml.cs | 20 + app/JustHostMC.App/Views/BackupsDialog.xaml | 74 +- .../Views/BackupsDialog.xaml.cs | 18 +- .../Views/BanListContentDialog.xaml | 11 + .../Views/BanListContentDialog.xaml.cs | 13 + app/JustHostMC.App/Views/BanListDialog.xaml | 46 +- .../Views/BanListDialog.xaml.cs | 58 +- app/JustHostMC.App/Views/CloseBusyDialog.xaml | 11 + .../Views/CloseBusyDialog.xaml.cs | 7 + .../Views/CreateServerDialog.xaml | 11 + .../Views/CreateServerDialog.xaml.cs | 22 + .../Views/DeleteServerDialog.xaml | 11 + .../Views/DeleteServerDialog.xaml.cs | 7 + .../Views/EditServerDialog.xaml | 11 + .../Views/EditServerDialog.xaml.cs | 23 + .../Views/EngineStdioWindow.xaml | 3 +- .../Views/EngineStdioWindow.xaml.cs | 3 - app/JustHostMC.App/Views/HomePage.xaml | 144 +++- app/JustHostMC.App/Views/HomePage.xaml.cs | 70 +- .../Views/IncompleteServerRemovalDialog.xaml | 11 + .../IncompleteServerRemovalDialog.xaml.cs | 7 + .../Views/PermissionConsentContentDialog.xaml | 11 + .../PermissionConsentContentDialog.xaml.cs | 19 + .../Views/PermissionConsentDialog.xaml | 8 +- .../Views/PermissionConsentDialog.xaml.cs | 12 +- .../Views/PlayerDataContentDialog.xaml | 11 + .../Views/PlayerDataContentDialog.xaml.cs | 17 + .../Views/PlayerDataDialog.xaml | 11 +- .../Views/PlayerDataDialog.xaml.cs | 9 +- .../Views/PlayerInventoryContentDialog.xaml | 11 + .../PlayerInventoryContentDialog.xaml.cs | 17 + .../Views/PlayerInventoryDialog.xaml | 8 +- .../Views/PlayerInventoryDialog.xaml.cs | 168 +--- .../Views/RenameServerDialog.xaml | 11 + .../Views/RenameServerDialog.xaml.cs | 14 + .../Views/ScriptLogsWindow.xaml | 60 +- .../Views/ScriptLogsWindow.xaml.cs | 7 +- app/JustHostMC.App/Views/ScriptsPage.xaml | 5 + app/JustHostMC.App/Views/ScriptsPage.xaml.cs | 26 +- .../Views/ServerFolderNotFoundDialog.xaml | 11 + .../Views/ServerFolderNotFoundDialog.xaml.cs | 7 + app/JustHostMC.App/Views/ServerPage.xaml.cs | 71 +- app/JustHostMC.App/Views/SettingsPage.xaml | 59 +- .../Views/ShopDependencySelectionDialog.xaml | 17 + .../ShopDependencySelectionDialog.xaml.cs | 28 + app/JustHostMC.App/Views/ShopDetailPage.xaml | 54 +- .../Views/ShopDetailPage.xaml.cs | 32 +- app/JustHostMC.App/Views/ShopHomePage.xaml | 6 +- app/JustHostMC.App/Views/ShopHomePage.xaml.cs | 3 - app/JustHostMC.App/Views/ShopSearchPage.xaml | 4 +- .../Views/ShopSearchPage.xaml.cs | 2 - app/JustHostMC.App/Views/ShopWindow.xaml | 34 +- app/JustHostMC.App/Views/ShopWindow.xaml.cs | 7 +- docs/resources.md | 246 ++++++ 117 files changed, 3615 insertions(+), 1659 deletions(-) create mode 100644 app/JustHostMC.App.ResourceTests/BackupConfigFiniteStateTests.cs create mode 100644 app/JustHostMC.App.ResourceTests/ControlLocalizationArchitectureTests.cs create mode 100644 app/JustHostMC.App.ResourceTests/ConverterArchitectureTests.cs create mode 100644 app/JustHostMC.App.ResourceTests/FeatureFiniteStateTests.cs create mode 100644 app/JustHostMC.App.ResourceTests/JustHostMC.App.ResourceTests.csproj create mode 100644 app/JustHostMC.App.ResourceTests/MainSurfaceFiniteStateTests.cs create mode 100644 app/JustHostMC.App.ResourceTests/ModelLocalizationArchitectureTests.cs create mode 100644 app/JustHostMC.App.ResourceTests/RepositoryLayout.cs create mode 100644 app/JustHostMC.App.ResourceTests/ResourceCatalog.cs create mode 100644 app/JustHostMC.App.ResourceTests/ResourceCatalogTests.cs create mode 100644 app/JustHostMC.App.ResourceTests/ResourceIntegrityTests.cs create mode 100644 app/JustHostMC.App.ResourceTests/UpdateDuplicateComments.ps1 create mode 100644 app/JustHostMC.App/Controls/InventoryItemDetails.xaml create mode 100644 app/JustHostMC.App/Controls/InventoryItemDetails.xaml.cs create mode 100644 app/JustHostMC.App/Controls/PermissionLabel.xaml create mode 100644 app/JustHostMC.App/Controls/PermissionLabel.xaml.cs delete mode 100644 app/JustHostMC.App/Converters/BoolToVisibilityConverter.cs delete mode 100644 app/JustHostMC.App/Models/PermissionLabels.cs create mode 100644 app/JustHostMC.App/Views/BackupsContentDialog.xaml create mode 100644 app/JustHostMC.App/Views/BackupsContentDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/BanListContentDialog.xaml create mode 100644 app/JustHostMC.App/Views/BanListContentDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/CloseBusyDialog.xaml create mode 100644 app/JustHostMC.App/Views/CloseBusyDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/CreateServerDialog.xaml create mode 100644 app/JustHostMC.App/Views/CreateServerDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/DeleteServerDialog.xaml create mode 100644 app/JustHostMC.App/Views/DeleteServerDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/EditServerDialog.xaml create mode 100644 app/JustHostMC.App/Views/EditServerDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/IncompleteServerRemovalDialog.xaml create mode 100644 app/JustHostMC.App/Views/IncompleteServerRemovalDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml create mode 100644 app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/PlayerDataContentDialog.xaml create mode 100644 app/JustHostMC.App/Views/PlayerDataContentDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml create mode 100644 app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/RenameServerDialog.xaml create mode 100644 app/JustHostMC.App/Views/RenameServerDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/ServerFolderNotFoundDialog.xaml create mode 100644 app/JustHostMC.App/Views/ServerFolderNotFoundDialog.xaml.cs create mode 100644 app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml create mode 100644 app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml.cs create mode 100644 docs/resources.md diff --git a/AGENTS.md b/AGENTS.md index a48e764..ecd2531 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -197,13 +197,19 @@ both sides, then implement the Go `*Service` and call it from a C# ViewModel. (`errorStatus` helper); the `ErrorCode` enum is the programmatic discriminator and the frontend maps it to a localized string. The status message is diagnostic only. -- **i18n**: dynamic display messages travel as a localization **key** - `"namespace.method.type"` (+ args) in a `LocalizedMessage`; the frontend resolves - it against `.resw`. Resources live in - `app/JustHostMC.App/Strings/{en-US,zh-Hant}/Resources.resw`; **en-US is the base - and fallback**. Backend keys use `.` separators; `LocalizationService` rewrites - `.` → `_` to match `.resw` keys. Adding a language is a new `.resw` folder, no - code change. +- **i18n/resources**: prefer XAML `x:Uid` property resources for all static UI, + including dialog chrome, InfoBars, tooltips, and automation properties. + Resources live in + `app/JustHostMC.App/Strings/{en-US,zh-TW}/Resources.resw`; **en-US is the base + and fallback**. Dynamic backend messages use dotted + `"namespace.method.type"` keys (+ args) in `LocalizedMessage`; + `LocalizationService` maps `.` → `/` for MRT Core lookup. Localized dialogs + are XAML `ContentDialog` classes, imperative controls select XAML-defined + tooltip styles/templates, and app-wide Community Toolkit converters stay in + `Application.Resources`. Deduplicate by semantic meaning and target property; + document unavoidable duplicates with their canonical identifier. See + [`docs/resources.md`](docs/resources.md) for the complete rules, approved C# + exceptions, assets, language addition, and validation workflow. ### MVVM Toolkit source generation diff --git a/JustHostMC.sln b/JustHostMC.sln index 53e1f32..5ccacfe 100644 --- a/JustHostMC.sln +++ b/JustHostMC.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JustHostMC.Core.Tests", "ap EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JustHostMC.App", "app\JustHostMC.App\JustHostMC.App.csproj", "{E5CDD455-4BC1-459D-AE24-721828C866D4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JustHostMC.App.ResourceTests", "app\JustHostMC.App.ResourceTests\JustHostMC.App.ResourceTests.csproj", "{A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -79,6 +81,22 @@ Global {E5CDD455-4BC1-459D-AE24-721828C866D4}.Release|x86.ActiveCfg = Release|x86 {E5CDD455-4BC1-459D-AE24-721828C866D4}.Release|x86.Build.0 = Release|x86 {E5CDD455-4BC1-459D-AE24-721828C866D4}.Release|x86.Deploy.0 = Release|x86 + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Debug|ARM64.Build.0 = Debug|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Debug|x64.ActiveCfg = Debug|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Debug|x64.Build.0 = Debug|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Debug|x86.ActiveCfg = Debug|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Debug|x86.Build.0 = Debug|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Release|Any CPU.Build.0 = Release|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Release|ARM64.ActiveCfg = Release|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Release|ARM64.Build.0 = Release|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Release|x64.ActiveCfg = Release|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Release|x64.Build.0 = Release|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Release|x86.ActiveCfg = Release|Any CPU + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -87,6 +105,7 @@ Global {6C695E07-80F7-4CDD-89D7-5166A97D4B6E} = {F95F473B-E98A-ACD6-1986-755F447BE36F} {468F0BCC-71DE-4F47-BAD0-80300AE43D03} = {F95F473B-E98A-ACD6-1986-755F447BE36F} {E5CDD455-4BC1-459D-AE24-721828C866D4} = {F95F473B-E98A-ACD6-1986-755F447BE36F} + {A5B1D07E-7E7C-4D72-9C9A-4B86D58C7150} = {F95F473B-E98A-ACD6-1986-755F447BE36F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7D2AD613-A606-4755-BA00-96E200813585} diff --git a/app/JustHostMC.App.ResourceTests/BackupConfigFiniteStateTests.cs b/app/JustHostMC.App.ResourceTests/BackupConfigFiniteStateTests.cs new file mode 100644 index 0000000..55df74c --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/BackupConfigFiniteStateTests.cs @@ -0,0 +1,74 @@ +using Xunit; + +namespace JustHostMC.App.ResourceTests; + +public sealed class BackupConfigFiniteStateTests { + [Fact] + public void BackupWorkflowUsesSemanticStateAndXamlResources() { + var viewModel = File.ReadAllText(RepositoryLayout.AppPath( + "ViewModels", "BackupsViewModel.cs")); + var xaml = File.ReadAllText(RepositoryLayout.AppPath( + "Views", "BackupsDialog.xaml")); + + Assert.Contains("BackupStatus", viewModel, StringComparison.Ordinal); + Assert.DoesNotContain("_localizer.Get(\"Backups_", viewModel, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"BackupsStatusCreating\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"BackupsStatusCreated\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"BackupsStatusRestoring\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"BackupsStatusRestored\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"BackupsStatusDeleting\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"BackupsStatusDeleted\"", xaml, + StringComparison.Ordinal); + Assert.DoesNotContain("_localizer.Get(", + File.ReadAllText(RepositoryLayout.AppPath( + "Views", "BackupsDialog.xaml.cs")), + StringComparison.Ordinal); + } + + [Fact] + public void ConfigWorkflowUsesSemanticStateAndXamlResources() { + var viewModel = File.ReadAllText(RepositoryLayout.AppPath( + "ViewModels", "ServerConfigViewModel.cs")); + var xaml = File.ReadAllText(RepositoryLayout.AppPath( + "Controls", "Server", "ServerConfigPanel.xaml")); + + Assert.Contains("ConfigStatus", viewModel, StringComparison.Ordinal); + Assert.DoesNotContain("_localizer.Get(\"Config_", viewModel, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ConfigStatusSaved\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ConfigStatusLoadFailed\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ConfigStatusSaveFailed\"", xaml, + StringComparison.Ordinal); + } + + [Fact] + public void ConfigValueTypesUseSemanticFlagsAndXamlResources() { + var model = File.ReadAllText(RepositoryLayout.AppPath( + "Models", "ConfigEntryItem.cs")); + var xaml = File.ReadAllText(RepositoryLayout.AppPath( + "Controls", "ConfigEntryEditor.xaml")); + + Assert.DoesNotContain("TypeText", model, StringComparison.Ordinal); + Assert.DoesNotContain("ConfigType_", model, StringComparison.Ordinal); + Assert.Contains("IsBoolean", model, StringComparison.Ordinal); + Assert.Contains("IsInteger", model, StringComparison.Ordinal); + Assert.Contains("IsChoice", model, StringComparison.Ordinal); + Assert.Contains("IsText", model, StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ConfigTypeBooleanText\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ConfigTypeIntegerText\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ConfigTypeChoiceText\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ConfigTypeTextText\"", xaml, + StringComparison.Ordinal); + } +} diff --git a/app/JustHostMC.App.ResourceTests/ControlLocalizationArchitectureTests.cs b/app/JustHostMC.App.ResourceTests/ControlLocalizationArchitectureTests.cs new file mode 100644 index 0000000..bfd8e3c --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/ControlLocalizationArchitectureTests.cs @@ -0,0 +1,43 @@ +using Xunit; + +namespace JustHostMC.App.ResourceTests; + +public sealed class ControlLocalizationArchitectureTests { + [Fact] + public void AssignedControlsDoNotFetchStaticOrFiniteStateStringsFromCode() { + var forbiddenKeys = new[] { + "LogViewer_JumpToLatest", + "Scripts_RemoveConfirmPrimary", + "ServerSectionConfig/Text", + "ServerSectionConfigHint/Text", + "ConfigStoppedHint/Text", + "Server_PortAutoValue", + "Server_ValueUnknown", + "ServerSectionModsHint/Text", + "ModsStoppedHint/Text", + "ServerSectionPerformance/Text", + "ServerSectionPerformanceHint/Text", + "PlayersEmptyHint/Text", + "ServerSectionPlayersHint/Text", + }; + var sourceFiles = new[] { + RepositoryLayout.AppPath("Controls", "LogViewer.xaml.cs"), + RepositoryLayout.AppPath("Controls", "ScriptEntryCard.xaml.cs"), + RepositoryLayout.AppPath("Controls", "Server", "ServerConfigPanel.xaml.cs"), + RepositoryLayout.AppPath("Controls", "Server", "ServerHeaderPanel.xaml.cs"), + RepositoryLayout.AppPath("Controls", "Server", "ServerModsPanel.xaml.cs"), + RepositoryLayout.AppPath("Controls", "Server", "ServerPerformancePanel.xaml.cs"), + RepositoryLayout.AppPath("Controls", "Server", "ServerPlayersPanel.xaml.cs"), + RepositoryLayout.AppPath("Views", "SettingsPage.xaml.cs"), + }; + var source = string.Join('\n', sourceFiles.Select(File.ReadAllText)); + + foreach (var key in forbiddenKeys) + Assert.DoesNotContain($"\"{key}\"", source, StringComparison.Ordinal); + + var settingsXaml = File.ReadAllText(RepositoryLayout.AppPath( + "Views", "SettingsPage.xaml")); + Assert.DoesNotContain("PlaceholderText=\"API Key\"", settingsXaml, + StringComparison.Ordinal); + } +} diff --git a/app/JustHostMC.App.ResourceTests/ConverterArchitectureTests.cs b/app/JustHostMC.App.ResourceTests/ConverterArchitectureTests.cs new file mode 100644 index 0000000..ea4def0 --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/ConverterArchitectureTests.cs @@ -0,0 +1,27 @@ +using System.Xml.Linq; +using Xunit; + +namespace JustHostMC.App.ResourceTests; + +public sealed class ConverterArchitectureTests { + [Fact] + public void AppReferencesCommunityToolkitConverters() { + var project = XDocument.Load( + RepositoryLayout.AppPath("JustHostMC.App.csproj")); + + var packageNames = project.Descendants("PackageReference") + .Select(element => (string?)element.Attribute("Include")); + + Assert.Contains("CommunityToolkit.WinUI.Converters", packageNames); + } + + [Fact] + public void AppDoesNotRetainCustomBoolToVisibilityConverter() { + var converterPath = RepositoryLayout.AppPath( + "Converters", "BoolToVisibilityConverter.cs"); + + Assert.False( + File.Exists(converterPath), + $"Replace the custom converter with CommunityToolkit.WinUI.Converters: {converterPath}"); + } +} diff --git a/app/JustHostMC.App.ResourceTests/FeatureFiniteStateTests.cs b/app/JustHostMC.App.ResourceTests/FeatureFiniteStateTests.cs new file mode 100644 index 0000000..6649e02 --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/FeatureFiniteStateTests.cs @@ -0,0 +1,107 @@ +using Xunit; + +namespace JustHostMC.App.ResourceTests; + +public sealed class FeatureFiniteStateTests { + [Fact] + public void ModsFiniteLabelsUseSemanticStateAndXamlResources() { + var viewModel = RepositoryLayout.ReadAppFile( + "ViewModels", "ModsViewModel.cs"); + var xaml = RepositoryLayout.ReadAppFile( + "Controls", "Server", "ServerModsPanel.xaml"); + + Assert.Contains("ModsWorkflowStatus", viewModel, + StringComparison.Ordinal); + Assert.DoesNotContain("KindLabel", viewModel, + StringComparison.Ordinal); + Assert.DoesNotContain("_localizer.Get(\"Mods_Export", viewModel, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ServerModsTitleConverter\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ModsStatusExported\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ModsStatusExportFailed\"", xaml, + StringComparison.Ordinal); + } + + [Fact] + public void SettingsFiniteLabelsUseSemanticStateAndXamlResources() { + var viewModel = RepositoryLayout.ReadAppFile( + "ViewModels", "SettingsViewModel.cs"); + var xaml = RepositoryLayout.ReadAppFile("Views", "SettingsPage.xaml"); + + Assert.Contains("SettingsWorkflowStatus", viewModel, + StringComparison.Ordinal); + Assert.Contains("ShopKeyConfiguration", viewModel, + StringComparison.Ordinal); + Assert.Contains("BackendMode", viewModel, StringComparison.Ordinal); + Assert.DoesNotContain("ActiveModeText", viewModel, + StringComparison.Ordinal); + Assert.DoesNotContain("CurseForgeKeyStatus", viewModel, + StringComparison.Ordinal); + + foreach (var uid in new[] { + "SettingsBackendModeDocker", + "SettingsBackendModeOnMachine", + "SettingsDockerUnavailable", + "SettingsShopKeyNone", + "SettingsShopKeyUser", + "SettingsShopKeyBuiltin", + "SettingsStatusSaved", + "SettingsStatusSaveFailed", + }) { + Assert.Contains($"x:Uid=\"{uid}\"", xaml, + StringComparison.Ordinal); + } + } + + [Fact] + public void ShopFiniteLabelsUseSemanticStateAndXamlResources() { + var shop = RepositoryLayout.ReadAppFile( + "ViewModels", "ShopViewModel.cs"); + var detail = RepositoryLayout.ReadAppFile( + "ViewModels", "ShopDetailViewModel.cs"); + var window = RepositoryLayout.ReadAppFile("Views", "ShopWindow.xaml"); + var detailXaml = RepositoryLayout.ReadAppFile( + "Views", "ShopDetailPage.xaml"); + + Assert.Contains("HasLoadFailure", shop, StringComparison.Ordinal); + Assert.DoesNotContain("_localizer.Get(\"Shop_LoadFailed\")", shop, + StringComparison.Ordinal); + Assert.Contains("ShopDetailStatus", detail, StringComparison.Ordinal); + Assert.DoesNotContain("_localizer.Get(\"Shop_InstallDone\")", detail, + StringComparison.Ordinal); + Assert.DoesNotContain("_localizer.Get(\"Shop_InstallAction\")", detail, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ShopLoadFailedBar\"", window, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ShopInstallActionText\"", detailXaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ShopStatusInstallDone\"", detailXaml, + StringComparison.Ordinal); + } + + [Fact] + public void ScriptLogFiniteLabelsAreRenderedByXaml() { + var viewModel = RepositoryLayout.ReadAppFile( + "ViewModels", "ScriptsViewModel.cs"); + var xaml = RepositoryLayout.ReadAppFile( + "Views", "ScriptLogsWindow.xaml"); + + foreach (var key in new[] { + "Scripts_SystemLogName", + "Scripts_LogEntryFallbackTitle", + "Scripts_CurrentSessionTitle", + "Scripts_PreviousSessionTitle", + }) { + Assert.DoesNotContain($"_localizer.Get(\"{key}\")", viewModel, + StringComparison.Ordinal); + } + Assert.Contains("x:Uid=\"ScriptLogsSystemName\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ScriptLogsCurrentSessionTitle\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ScriptLogsPreviousSessionTitle\"", xaml, + StringComparison.Ordinal); + } +} diff --git a/app/JustHostMC.App.ResourceTests/JustHostMC.App.ResourceTests.csproj b/app/JustHostMC.App.ResourceTests/JustHostMC.App.ResourceTests.csproj new file mode 100644 index 0000000..78f313c --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/JustHostMC.App.ResourceTests.csproj @@ -0,0 +1,21 @@ + + + + net9.0 + enable + enable + latest + false + true + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/app/JustHostMC.App.ResourceTests/MainSurfaceFiniteStateTests.cs b/app/JustHostMC.App.ResourceTests/MainSurfaceFiniteStateTests.cs new file mode 100644 index 0000000..43890ca --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/MainSurfaceFiniteStateTests.cs @@ -0,0 +1,78 @@ +using Xunit; + +namespace JustHostMC.App.ResourceTests; + +public sealed class MainSurfaceFiniteStateTests { + [Fact] + public void EngineConnectionStateIsSemanticAndLocalizedInHomeXaml() { + var viewModel = RepositoryLayout.ReadAppFile( + "ViewModels", "MainViewModel.cs"); + var xaml = RepositoryLayout.ReadAppFile("Views", "HomePage.xaml"); + + Assert.Contains("EngineConnectionState", viewModel, + StringComparison.Ordinal); + Assert.DoesNotContain("_localizer.Get(\"EngineStatus_", viewModel, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"EngineStatusConnectingText\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"EngineStatusConnectedText\"", xaml, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"EngineStatusFailedText\"", xaml, + StringComparison.Ordinal); + } + + [Fact] + public void InstallErrorsDoNotExposeGrpcDiagnosticDetails() { + var viewModel = RepositoryLayout.ReadAppFile( + "ViewModels", "MainViewModel.cs"); + + Assert.DoesNotContain("ex.Status.Detail", viewModel, + StringComparison.Ordinal); + } + + [Fact] + public void ServerCardAndHeaderFiniteLabelsAreLocalizedInXaml() { + var model = RepositoryLayout.ReadAppFile("Models", "ServerItem.cs"); + var home = RepositoryLayout.ReadAppFile("Views", "HomePage.xaml"); + var header = RepositoryLayout.ReadAppFile( + "Controls", "Server", "ServerHeaderPanel.xaml"); + var xaml = home + '\n' + header; + + foreach (var property in new[] { + "public string StatusText", "public string StateActionText", + "public string DeleteActionText", + }) + Assert.DoesNotContain(property, model, StringComparison.Ordinal); + + foreach (var keyPrefix in new[] { + "ServerState_", "ServerDelete_Action", + "ServerInstallRemove_Action", "ServerType_", + }) + Assert.DoesNotContain($"\"{keyPrefix}", model, + StringComparison.Ordinal); + + foreach (var uid in new[] { + "ServerStatusRunningText", "ServerStatusStoppedText", + "ServerStatusInstallingText", "ServerStatusStartingText", + "ServerStatusStoppingText", "ServerStatusCrashedText", + "ServerStatusUnknownText", "ServerStateStartText", + "ServerStateStopText", "ServerStateStartingText", + "ServerStateStoppingText", "ServerStateInstallingText", + "ServerTypeVanillaText", "ServerTypePaperText", + "ServerTypeSpigotText", "ServerTypeForgeText", + "ServerTypeNeoForgeText", "ServerTypeFabricText", + "ServerTypeUnknownText", + }) + Assert.Contains($"x:Uid=\"{uid}\"", xaml, + StringComparison.Ordinal); + + Assert.Contains("x:Uid=\"HomeCardDeleteMenuItem\"", home, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"HomeCardRemoveIncompleteMenuItem\"", home, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ServerDeleteMenuItem\"", header, + StringComparison.Ordinal); + Assert.Contains("x:Uid=\"ServerRemoveIncompleteMenuItem\"", header, + StringComparison.Ordinal); + } +} diff --git a/app/JustHostMC.App.ResourceTests/ModelLocalizationArchitectureTests.cs b/app/JustHostMC.App.ResourceTests/ModelLocalizationArchitectureTests.cs new file mode 100644 index 0000000..25787ef --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/ModelLocalizationArchitectureTests.cs @@ -0,0 +1,31 @@ +using Xunit; + +namespace JustHostMC.App.ResourceTests; + +public sealed class ModelLocalizationArchitectureTests { + [Fact] + public void BanEntryFiniteLabelsBelongToItsXamlTemplate() { + var model = File.ReadAllText(RepositoryLayout.AppPath( + "Models", "BanEntryItem.cs")); + var xaml = File.ReadAllText(RepositoryLayout.AppPath( + "Views", "BanListDialog.xaml")); + + Assert.DoesNotContain("ILocalizer", model, StringComparison.Ordinal); + Assert.DoesNotContain("BanList_Type", model, StringComparison.Ordinal); + Assert.DoesNotContain("BanList_NoReason", model, StringComparison.Ordinal); + Assert.Contains("BanListEntryIpTypeText", xaml, StringComparison.Ordinal); + Assert.Contains("BanListEntryPlayerTypeText", xaml, + StringComparison.Ordinal); + Assert.Contains("BanListEntryNoReasonText", xaml, + StringComparison.Ordinal); + } + + [Fact] + public void ParserDiagnosticsAreNotFormattedIntoUserFacingModErrors() { + var model = File.ReadAllText(RepositoryLayout.AppPath( + "Models", "ModFileItem.cs")); + + Assert.DoesNotContain("(\"error\", metadata.ParseError)", model, + StringComparison.Ordinal); + } +} diff --git a/app/JustHostMC.App.ResourceTests/RepositoryLayout.cs b/app/JustHostMC.App.ResourceTests/RepositoryLayout.cs new file mode 100644 index 0000000..1752afa --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/RepositoryLayout.cs @@ -0,0 +1,26 @@ +namespace JustHostMC.App.ResourceTests; + +internal static class RepositoryLayout { + public static string Root { get; } = FindRoot(AppContext.BaseDirectory); + + public static string AppPath(params string[] segments) => + Path.Combine([Root, "app", "JustHostMC.App", .. segments]); + + public static string RootPath(params string[] segments) => + Path.Combine([Root, .. segments]); + + public static string ReadAppFile(params string[] segments) => + File.ReadAllText(AppPath(segments)); + + private static string FindRoot(string startPath) { + var directory = new DirectoryInfo(startPath); + while (directory is not null) { + if (File.Exists(Path.Combine(directory.FullName, "JustHostMC.sln"))) + return directory.FullName; + directory = directory.Parent; + } + + throw new DirectoryNotFoundException( + $"Could not find the repository root above '{startPath}'."); + } +} diff --git a/app/JustHostMC.App.ResourceTests/ResourceCatalog.cs b/app/JustHostMC.App.ResourceTests/ResourceCatalog.cs new file mode 100644 index 0000000..4df9032 --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/ResourceCatalog.cs @@ -0,0 +1,26 @@ +using System.Xml.Linq; + +namespace JustHostMC.App.ResourceTests; + +internal sealed record ResourceEntry(string Name, string Value, string Comment); + +internal static class ResourceCatalog { + public static IReadOnlyList Load(string path) { + var document = XDocument.Load(path, LoadOptions.SetLineInfo); + return document.Root?.Elements("data") + .Select(element => new ResourceEntry( + (string?)element.Attribute("name") ?? "", + element.Element("value")?.Value ?? "", + element.Element("comment")?.Value ?? "")) + .ToArray() + ?? []; + } + + public static IReadOnlyList DuplicateNames( + IEnumerable entries) => + entries.GroupBy(entry => entry.Name, StringComparer.OrdinalIgnoreCase) + .Where(group => group.Count() > 1) + .Select(group => group.Key) + .Order(StringComparer.OrdinalIgnoreCase) + .ToArray(); +} diff --git a/app/JustHostMC.App.ResourceTests/ResourceCatalogTests.cs b/app/JustHostMC.App.ResourceTests/ResourceCatalogTests.cs new file mode 100644 index 0000000..88fe9f0 --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/ResourceCatalogTests.cs @@ -0,0 +1,32 @@ +using Xunit; + +namespace JustHostMC.App.ResourceTests; + +public sealed class ResourceCatalogTests { + [Fact] + public void LoadRejectsMalformedXml() { + var path = WriteTemp(""); + try { + Assert.ThrowsAny(() => ResourceCatalog.Load(path)); + } finally { + File.Delete(path); + } + } + + [Fact] + public void DuplicateNamesAreCaseInsensitive() { + var entries = new[] { + new ResourceEntry("Example.Text", "One", ""), + new ResourceEntry("example.text", "Two", ""), + new ResourceEntry("Other.Text", "Three", ""), + }; + + Assert.Equal(["Example.Text"], ResourceCatalog.DuplicateNames(entries)); + } + + private static string WriteTemp(string content) { + var path = Path.GetTempFileName(); + File.WriteAllText(path, content); + return path; + } +} diff --git a/app/JustHostMC.App.ResourceTests/ResourceIntegrityTests.cs b/app/JustHostMC.App.ResourceTests/ResourceIntegrityTests.cs new file mode 100644 index 0000000..6cae618 --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/ResourceIntegrityTests.cs @@ -0,0 +1,268 @@ +using System.Text.RegularExpressions; +using System.Xml.Linq; +using Xunit; + +namespace JustHostMC.App.ResourceTests; + +public sealed partial class ResourceIntegrityTests { + private static readonly string[] Locales = ["en-US", "zh-TW"]; + + [Fact] + public void LocaleFilesHaveUniqueNonEmptyEntries() { + foreach (var locale in Locales) { + var entries = Entries(locale); + Assert.Empty(ResourceCatalog.DuplicateNames(entries)); + Assert.DoesNotContain(entries, entry => + string.IsNullOrWhiteSpace(entry.Name) || + string.IsNullOrWhiteSpace(entry.Value)); + } + } + + [Fact] + public void LocaleFilesHaveIdenticalIdentifiers() { + var english = Entries("en-US").Select(entry => entry.Name).ToHashSet( + StringComparer.OrdinalIgnoreCase); + var chinese = Entries("zh-TW").Select(entry => entry.Name).ToHashSet( + StringComparer.OrdinalIgnoreCase); + + Assert.True(english.SetEquals(chinese), + $"en-US only: {string.Join(", ", english.Except(chinese))}; " + + $"zh-TW only: {string.Join(", ", chinese.Except(english))}"); + } + + [Fact] + public void DuplicateVisibleValuesHaveTranslatorContext() { + foreach (var locale in Locales) { + var undocumented = Entries(locale) + .GroupBy(entry => entry.Value, StringComparer.Ordinal) + .Where(group => group.Count() > 1) + .SelectMany(group => group) + .Where(entry => string.IsNullOrWhiteSpace(entry.Comment)) + .Select(entry => entry.Name) + .Order(StringComparer.OrdinalIgnoreCase) + .ToArray(); + + Assert.True(undocumented.Length == 0, + $"{locale} has undocumented duplicate visible values: " + + string.Join(", ", undocumented)); + } + } + + [Fact] + public void EveryXamlUidHasAResourcePropertyInEveryLocale() { + var uids = Directory.EnumerateFiles(RepositoryLayout.AppPath(), "*.xaml", + SearchOption.AllDirectories) + .Where(path => !IsGenerated(path)) + .SelectMany(path => XamlUidRegex().Matches(File.ReadAllText(path))) + .Select(match => match.Groups[1].Value) + .ToHashSet(StringComparer.OrdinalIgnoreCase); + + foreach (var locale in Locales) { + var names = Entries(locale).Select(entry => entry.Name).ToArray(); + var missing = uids.Where(uid => !names.Any(name => + name.StartsWith(uid + ".", StringComparison.OrdinalIgnoreCase))) + .Order(StringComparer.OrdinalIgnoreCase) + .ToArray(); + Assert.True(missing.Length == 0, + $"{locale} has no property resource for x:Uid values: " + + string.Join(", ", missing)); + } + } + + [Fact] + public void BackendResourceIdentifiersUseDotsNotLegacyUnderscores() { + foreach (var locale in Locales) { + var legacy = Entries(locale).Select(entry => entry.Name) + .Where(name => name.StartsWith("install_progress_", + StringComparison.Ordinal) || + name == "install_ready_to_run" || + name.StartsWith("shop_category_", + StringComparison.Ordinal) || + name.StartsWith("shop.category.curseforge_", + StringComparison.Ordinal) || + name.StartsWith("shop_home_", + StringComparison.Ordinal) || + name == "error_server_running") + .ToArray(); + Assert.Empty(legacy); + } + } + + [Fact] + public void ProgrammaticDottedKeysUseSlashLookupPaths() { + var source = File.ReadAllText(RepositoryLayout.AppPath( + "Services", "LocalizationService.cs")); + Assert.Contains("key.Replace('.', '/')", source, + StringComparison.Ordinal); + Assert.DoesNotContain("key.Replace('.', '_')", source, + StringComparison.Ordinal); + } + + [Fact] + public void LiteralProgrammaticResourceKeysExistInEveryLocale() { + var referenced = SourceFiles("*.cs") + .SelectMany(path => LiteralLocalizerKeyRegex() + .Matches(File.ReadAllText(path))) + .Select(match => match.Groups[1].Value) + .Distinct(StringComparer.OrdinalIgnoreCase) + .Order(StringComparer.OrdinalIgnoreCase) + .ToArray(); + + foreach (var locale in Locales) { + var names = Entries(locale).Select(entry => entry.Name).ToHashSet( + StringComparer.OrdinalIgnoreCase); + var missing = referenced.Where(key => !names.Contains(key)).ToArray(); + Assert.True(missing.Length == 0, + $"{locale} is missing literal C# resource keys: " + + string.Join(", ", missing)); + } + } + + [Fact] + public void ResourceArchitectureIsDocumentedForFutureChanges() { + var guide = RepositoryLayout.RootPath("docs", "resources.md"); + Assert.True(File.Exists(guide), "docs/resources.md is required"); + Assert.Contains("docs/resources.md", + File.ReadAllText(RepositoryLayout.RootPath("AGENTS.md")), + StringComparison.OrdinalIgnoreCase); + } + + [Fact] + public void EveryProgrammaticLocalizationSourceIsDocumented() { + var guide = File.ReadAllText(RepositoryLayout.RootPath( + "docs", "resources.md")); + var undocumented = SourceFiles("*.cs") + .Where(path => ProgrammaticLocalizerCallRegex().IsMatch( + File.ReadAllText(path))) + .Select(path => Path.GetRelativePath(RepositoryLayout.Root, path) + .Replace('\\', '/')) + .Where(path => !guide.Contains($"`{path}`", + StringComparison.Ordinal)) + .Order(StringComparer.OrdinalIgnoreCase) + .ToArray(); + + Assert.True(undocumented.Length == 0, + "Programmatic localization sources missing from the approved " + + "exception inventory: " + string.Join(", ", undocumented)); + } + + [Fact] + public void LocalizedDialogsAreDeclaredInXaml() { + var offenders = SourceFiles("*.cs") + .Where(path => NewContentDialogRegex().IsMatch(File.ReadAllText(path))) + .Select(path => Path.GetRelativePath(RepositoryLayout.Root, path)) + .ToArray(); + Assert.Empty(offenders); + } + + [Fact] + public void LocalizedTooltipsAreNotInjectedFromCode() { + var offenders = SourceFiles("*.cs") + .Where(path => File.ReadAllText(path).Contains( + "ToolTipService.SetToolTip", StringComparison.Ordinal)) + .Select(path => Path.GetRelativePath(RepositoryLayout.Root, path)) + .ToArray(); + Assert.Empty(offenders); + } + + [Fact] + public void LocalizedXamlElementsAreNotUsedAsStringCarriers() { + var offenders = SourceFiles("*.xaml.cs") + .Where(path => XamlTextCarrierRegex().IsMatch(File.ReadAllText(path))) + .Select(path => Path.GetRelativePath(RepositoryLayout.Root, path)) + .ToArray(); + Assert.Empty(offenders); + } + + [Fact] + public void PermissionLabelsAreRenderedFromSemanticKindsInXaml() { + var controlXaml = File.ReadAllText(RepositoryLayout.AppPath( + "Controls", "PermissionLabel.xaml")); + var expectedUids = new[] { + "PermissionLabelNetwork", + "PermissionLabelInstall", + "PermissionLabelFsServer", + "PermissionLabelConsoleRead", + "PermissionLabelConsoleWrite", + "PermissionLabelServerControl", + "PermissionLabelSchedule", + "PermissionLabelServerQuery", + "PermissionLabelPlayerManage", + "PermissionLabelUnknown", + }; + foreach (var uid in expectedUids) + Assert.Contains($"x:Uid=\"{uid}\"", controlXaml, + StringComparison.Ordinal); + + var scriptCard = File.ReadAllText(RepositoryLayout.AppPath( + "Controls", "ScriptEntryCard.xaml")); + Assert.Contains("Item.Granted", scriptCard, StringComparison.Ordinal); + Assert.Contains("controls:PermissionLabel", scriptCard, + StringComparison.Ordinal); + + var consentDialog = File.ReadAllText(RepositoryLayout.AppPath( + "Views", "PermissionConsentDialog.xaml")); + Assert.Contains("controls:PermissionLabel", consentDialog, + StringComparison.Ordinal); + Assert.Contains("Kind=\"{x:Bind Kind}\"", consentDialog, + StringComparison.Ordinal); + + var sources = SourceFiles("*.cs") + .Select(path => (Path: path, Source: File.ReadAllText(path))) + .ToArray(); + Assert.DoesNotContain(sources, item => + item.Source.Contains("PermissionLabels.Label(", + StringComparison.Ordinal) || + item.Source.Contains("GrantedSummary", StringComparison.Ordinal)); + Assert.DoesNotContain("public string Label { get; }", + File.ReadAllText(RepositoryLayout.AppPath( + "Views", "PermissionConsentDialog.xaml.cs")), + StringComparison.Ordinal); + } + + [Fact] + public void RawExceptionDiagnosticsAreNotDisplayedToUsers() { + var forbidden = new[] { + @"ex\.Status\.Detail\.Length\s*>\s*0", + @"\(\""detail\""\s*,\s*ex\.Message\)", + @"ex\.GetType\(\)\.Name", + }; + var offenders = SourceFiles("*.cs") + .Where(path => forbidden.Any(pattern => Regex.IsMatch( + File.ReadAllText(path), pattern))) + .Select(path => Path.GetRelativePath(RepositoryLayout.Root, path)) + .ToArray(); + Assert.Empty(offenders); + } + + private static IEnumerable SourceFiles(string pattern) => + Directory.EnumerateFiles(RepositoryLayout.AppPath(), pattern, + SearchOption.AllDirectories) + .Where(path => !IsGenerated(path)); + + private static bool IsGenerated(string path) => + path.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}", + StringComparison.OrdinalIgnoreCase) || + path.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}", + StringComparison.OrdinalIgnoreCase); + + private static IReadOnlyList Entries(string locale) => + ResourceCatalog.Load(RepositoryLayout.AppPath( + "Strings", locale, "Resources.resw")); + + [GeneratedRegex("x:Uid\\s*=\\s*[\"']([^\"']+)[\"']")] + private static partial Regex XamlUidRegex(); + + [GeneratedRegex("new\\s+ContentDialog\\s*\\{")] + private static partial Regex NewContentDialogRegex(); + + [GeneratedRegex("(?:\\b\\w*[Ll]ocalizer|new\\s+LocalizationService\\(\\))\\.Get\\(\\s*[\"']([^\"']+)[\"']", + RegexOptions.IgnoreCase)] + private static partial Regex LiteralLocalizerKeyRegex(); + + [GeneratedRegex("(?:\\b\\w*[Ll]ocalizer|new\\s+LocalizationService\\(\\))\\.Get\\(", RegexOptions.IgnoreCase)] + private static partial Regex ProgrammaticLocalizerCallRegex(); + + [GeneratedRegex("(?:=\\s*|string\\.Format\\()\\w+(?:Text|Label|Header)\\.Text\\b")] + private static partial Regex XamlTextCarrierRegex(); +} diff --git a/app/JustHostMC.App.ResourceTests/UpdateDuplicateComments.ps1 b/app/JustHostMC.App.ResourceTests/UpdateDuplicateComments.ps1 new file mode 100644 index 0000000..d84395c --- /dev/null +++ b/app/JustHostMC.App.ResourceTests/UpdateDuplicateComments.ps1 @@ -0,0 +1,52 @@ +[CmdletBinding()] +param( + [string]$RepositoryRoot +) + +if ([string]::IsNullOrWhiteSpace($RepositoryRoot)) { + $RepositoryRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path +} + +$resourceFiles = @( + Join-Path $RepositoryRoot "app\JustHostMC.App\Strings\en-US\Resources.resw" + Join-Path $RepositoryRoot "app\JustHostMC.App\Strings\zh-TW\Resources.resw" +) + +foreach ($path in $resourceFiles) { + $document = [System.Xml.XmlDocument]::new() + $document.PreserveWhitespace = $true + $document.Load($path) + + $entries = @($document.DocumentElement.SelectNodes("data")) + $groups = $entries | + Group-Object { $_.SelectSingleNode("value").InnerText } | + Where-Object Count -gt 1 + + foreach ($group in $groups) { + $canonical = $group.Group[0].GetAttribute("name") + foreach ($entry in $group.Group) { + if ($null -ne $entry.SelectSingleNode("comment")) { + continue + } + + $name = $entry.GetAttribute("name") + $comment = $document.CreateElement("comment") + $comment.InnerText = if ($name -eq $canonical) { + "Canonical duplicate value in this locale; semantic identifier: $canonical." + } else { + "Same visible value as $canonical; kept separate for this property or translation context." + } + $null = $entry.AppendChild($comment) + } + } + + $settings = [System.Xml.XmlWriterSettings]::new() + $settings.Encoding = [System.Text.UTF8Encoding]::new($false) + $settings.Indent = $false + $writer = [System.Xml.XmlWriter]::Create($path, $settings) + try { + $document.Save($writer) + } finally { + $writer.Dispose() + } +} diff --git a/app/JustHostMC.App/App.xaml b/app/JustHostMC.App/App.xaml index b161759..e725109 100644 --- a/app/JustHostMC.App/App.xaml +++ b/app/JustHostMC.App/App.xaml @@ -3,7 +3,7 @@ x:Class="JustHostMC.App.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:conv="using:JustHostMC.App.Converters"> + xmlns:conv="using:CommunityToolkit.WinUI.Converters"> @@ -15,6 +15,15 @@ inner element .Resources, so a converter in e.g. throws "Cannot find a resource with the given key" at load time.--> + + + 560 960 560 diff --git a/app/JustHostMC.App/Controls/AdaptiveFilterLayout.xaml b/app/JustHostMC.App/Controls/AdaptiveFilterLayout.xaml index 3a1d41d..8b45e6c 100644 --- a/app/JustHostMC.App/Controls/AdaptiveFilterLayout.xaml +++ b/app/JustHostMC.App/Controls/AdaptiveFilterLayout.xaml @@ -46,7 +46,7 @@ VerticalAlignment="Center"> - + diff --git a/app/JustHostMC.App/Controls/ConfigEntryEditor.xaml b/app/JustHostMC.App/Controls/ConfigEntryEditor.xaml index b7757fc..d4af07d 100644 --- a/app/JustHostMC.App/Controls/ConfigEntryEditor.xaml +++ b/app/JustHostMC.App/Controls/ConfigEntryEditor.xaml @@ -38,12 +38,30 @@ TextTrimming="CharacterEllipsis" /> - + VerticalAlignment="Center"> + + + + + + Visibility="{Binding Entry.HasChoices, ElementName=Root, Converter={StaticResource BoolToVis}, ConverterParameter=True}" /> diff --git a/app/JustHostMC.App/Controls/InventoryItemDetails.xaml b/app/JustHostMC.App/Controls/InventoryItemDetails.xaml new file mode 100644 index 0000000..5079126 --- /dev/null +++ b/app/JustHostMC.App/Controls/InventoryItemDetails.xaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/JustHostMC.App/Controls/InventoryItemDetails.xaml.cs b/app/JustHostMC.App/Controls/InventoryItemDetails.xaml.cs new file mode 100644 index 0000000..112f561 --- /dev/null +++ b/app/JustHostMC.App/Controls/InventoryItemDetails.xaml.cs @@ -0,0 +1,11 @@ +using JustHostMC.App.Models; +using Microsoft.UI.Xaml.Controls; + +namespace JustHostMC.App.Controls; + +public sealed partial class InventoryItemDetails : UserControl { + public InventoryItemDetails(PlayerInventoryItemView item) { + InitializeComponent(); + DataContext = item; + } +} diff --git a/app/JustHostMC.App/Controls/LogViewer.xaml b/app/JustHostMC.App/Controls/LogViewer.xaml index be7d1f0..5580709 100644 --- a/app/JustHostMC.App/Controls/LogViewer.xaml +++ b/app/JustHostMC.App/Controls/LogViewer.xaml @@ -54,6 +54,7 @@ - + + + + + + + + + @@ -86,7 +119,23 @@ IsEnabled="{x:Bind StateEnabled(Server.Status), Mode=OneWay}"> - + + + + + + + @@ -110,7 +159,18 @@ - + + + + + + @@ -145,10 +205,40 @@ Grid.Row="0" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Style="{StaticResource CaptionTextBlockStyle}" /> - + + + + + + + + + + - + + + + - + + + + diff --git a/app/JustHostMC.App/Controls/Server/ServerHeaderPanel.xaml.cs b/app/JustHostMC.App/Controls/Server/ServerHeaderPanel.xaml.cs index 7952a4b..4774148 100644 --- a/app/JustHostMC.App/Controls/Server/ServerHeaderPanel.xaml.cs +++ b/app/JustHostMC.App/Controls/Server/ServerHeaderPanel.xaml.cs @@ -133,14 +133,15 @@ private bool StateEnabled(ServerStatus s) => s is ServerStatus.Stopped or ServerStatus.Crashed or ServerStatus.Running; - private string PortValueText(int port) => port > - 0? port.ToString() - : _localizer.Get("Server_PortAutoValue"); - - private string MemoryText(int memoryMb) => memoryMb > - 0? _localizer - .Get("Server_MemoryValue", - ("memory", - memoryMb.ToString())) - : _localizer.Get("Server_ValueUnknown"); + private Visibility PositiveValueVisibility(int value) => + value > 0 ? Visibility.Visible : Visibility.Collapsed; + + private Visibility NonPositiveValueVisibility(int value) => + value > 0 ? Visibility.Collapsed : Visibility.Visible; + + private string ValueText(int value) => value.ToString(); + + private string MemoryText(int memoryMb) => + _localizer.Get("Server_MemoryValue", + ("memory", memoryMb.ToString())); } diff --git a/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml b/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml index d5a6386..a36f4f7 100644 --- a/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml +++ b/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml @@ -2,6 +2,7 @@ x:Class="JustHostMC.App.Controls.Server.ServerModsPanel" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:converters="using:CommunityToolkit.WinUI.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:models="using:JustHostMC.App.Models" @@ -9,6 +10,13 @@ mc:Ignorable="d"> + + + @@ -216,7 +224,7 @@ x:Uid="ModsUnsupportedHint" Foreground="{ThemeResource TextFillColorSecondaryBrush}" TextWrapping="Wrap" - Visibility="{x:Bind Mods.Supported, Mode=OneWay, Converter={StaticResource BoolToVis}, ConverterParameter=invert}" /> + Visibility="{x:Bind Mods.Supported, Mode=OneWay, Converter={StaticResource BoolToVis}, ConverterParameter=True}" /> + Visibility="{x:Bind Mods.IsInitialLoading, Mode=OneWay, Converter={StaticResource BoolToVis}, ConverterParameter=True}" /> + + diff --git a/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml.cs b/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml.cs index fd565c9..5e62183 100644 --- a/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml.cs +++ b/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml.cs @@ -1,5 +1,4 @@ using JustHostMC.App.Models; -using JustHostMC.App.Services; using JustHostMC.App.ViewModels; using JustHostMC.App.Views; using Microsoft.UI.Xaml; @@ -9,7 +8,6 @@ namespace JustHostMC.App.Controls.Server; public sealed partial class ServerModsPanel : UserControl { - private readonly ILocalizer _localizer = new LocalizationService(); public static readonly DependencyProperty ModsProperty = DependencyProperty.Register( nameof(Mods), typeof(ModsViewModel), typeof(ServerModsPanel), @@ -34,10 +32,6 @@ public ServerModsPanel() { InitializeComponent(); } - private string ModsDescription(bool canModify) => - canModify ? _localizer.Get("ServerSectionModsHint/Text") - : _localizer.Get("ModsStoppedHint/Text"); - private static void OnViewModelChanged( DependencyObject d, DependencyPropertyChangedEventArgs e) { var panel = (ServerModsPanel)d; diff --git a/app/JustHostMC.App/Controls/Server/ServerPerformancePanel.xaml b/app/JustHostMC.App/Controls/Server/ServerPerformancePanel.xaml index 8d2198a..75361d9 100644 --- a/app/JustHostMC.App/Controls/Server/ServerPerformancePanel.xaml +++ b/app/JustHostMC.App/Controls/Server/ServerPerformancePanel.xaml @@ -9,8 +9,7 @@ mc:Ignorable="d"> @@ -94,7 +93,7 @@ Foreground="{ThemeResource TextFillColorSecondaryBrush}" Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="Wrap" - Visibility="{x:Bind Metrics.NetworkAvailable, Mode=OneWay, Converter={StaticResource BoolToVis}, ConverterParameter=invert}" /> + Visibility="{x:Bind Metrics.NetworkAvailable, Mode=OneWay, Converter={StaticResource BoolToVis}, ConverterParameter=True}" /> diff --git a/app/JustHostMC.App/Controls/Server/ServerPerformancePanel.xaml.cs b/app/JustHostMC.App/Controls/Server/ServerPerformancePanel.xaml.cs index f92c99e..f473db9 100644 --- a/app/JustHostMC.App/Controls/Server/ServerPerformancePanel.xaml.cs +++ b/app/JustHostMC.App/Controls/Server/ServerPerformancePanel.xaml.cs @@ -1,4 +1,3 @@ -using JustHostMC.App.Services; using JustHostMC.App.ViewModels; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; @@ -6,8 +5,6 @@ namespace JustHostMC.App.Controls.Server; public sealed partial class ServerPerformancePanel : UserControl { - private readonly ILocalizer _localizer = new LocalizationService(); - public static readonly DependencyProperty MetricsProperty = DependencyProperty.Register( nameof(Metrics), typeof(MetricsViewModel), @@ -23,12 +20,6 @@ public ServerPerformancePanel() { InitializeComponent(); } - private string PerformanceTitle() => - _localizer.Get("ServerSectionPerformance/Text"); - - private string PerformanceDescription() => - _localizer.Get("ServerSectionPerformanceHint/Text"); - private static void OnMetricsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var panel = (ServerPerformancePanel)d; diff --git a/app/JustHostMC.App/Controls/Server/ServerPlayersPanel.xaml b/app/JustHostMC.App/Controls/Server/ServerPlayersPanel.xaml index ef35972..ac3b650 100644 --- a/app/JustHostMC.App/Controls/Server/ServerPlayersPanel.xaml +++ b/app/JustHostMC.App/Controls/Server/ServerPlayersPanel.xaml @@ -8,10 +8,20 @@ xmlns:server="using:JustHostMC.App.Controls.Server" mc:Ignorable="d"> - + + + + + @@ -224,7 +303,23 @@ Orientation="Horizontal" Spacing="8"> - + + + + + + + @@ -313,10 +408,23 @@ - + + + + + + Visibility="{x:Bind ViewModel.HasGallery, Mode=OneWay, Converter={StaticResource BoolToVis}}"> @@ -247,10 +255,18 @@ HorizontalContentAlignment="Center" AutomationProperties.AutomationId="ShopInstallLatestCompact" Click="OnInstallClick" - Content="{x:Bind ViewModel.PrimaryActionLabel, Mode=OneWay}" IsEnabled="{x:Bind ViewModel.CanInstallLatest, Mode=OneWay}" Style="{StaticResource AccentButtonStyle}" - Tag="{x:Bind ViewModel.LatestRelease, Mode=OneWay}" /> + Tag="{x:Bind ViewModel.LatestRelease, Mode=OneWay}"> + + + + + + Tag="{x:Bind}"> + + + + + @@ -396,12 +420,20 @@ + Visibility="{x:Bind ViewModel.IsInstalling, Mode=OneWay, Converter={StaticResource BoolToVis}}" /> + IsOpen="{x:Bind ViewModel.HasStatus, Mode=OneWay}" + Severity="{x:Bind StatusSeverity(ViewModel.InstallSucceeded), Mode=OneWay}"> + + + + + + + + + diff --git a/app/JustHostMC.App/Views/ShopDetailPage.xaml.cs b/app/JustHostMC.App/Views/ShopDetailPage.xaml.cs index 074980f..5d5cae2 100644 --- a/app/JustHostMC.App/Views/ShopDetailPage.xaml.cs +++ b/app/JustHostMC.App/Views/ShopDetailPage.xaml.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using JustHostMC.App.Controls; using JustHostMC.App.Models; using JustHostMC.App.Services; using JustHostMC.App.ViewModels; @@ -96,35 +97,15 @@ private async void OnInstallClick(object sender, RoutedEventArgs e) { } var dependencies = ViewModel.MissingDependencies(version); - var chosen = new List(); + IReadOnlyList chosen = []; if (dependencies.Count > 0) { - var picks = - dependencies - .Select(d => new CheckBox { - Content = d.Title.Length > 0 ? d.Title : d.ProjectId, - IsChecked = true, - Tag = d, - }) - .ToArray(); - var panel = new StackPanel { Spacing = 8 }; - panel.Children.Add(new TextBlock { - Text = _localizer.Get("Shop_DependencyPromptBody"), - TextWrapping = TextWrapping.Wrap, - }); - foreach (var pick in picks) panel.Children.Add(pick); - - var dialog = new ContentDialog { + var dialog = new ShopDependencySelectionDialog(dependencies) { XamlRoot = XamlRoot, - Title = _localizer.Get("Shop_DependencyPromptTitle"), - Content = new ScrollViewer { Content = panel, MaxHeight = 320 }, - PrimaryButtonText = _localizer.Get("Shop_InstallConfirm"), - CloseButtonText = _localizer.Get("Common_Cancel"), - DefaultButton = ContentDialogButton.Primary, }; + ContentDialogSizing.Apply(dialog); if (await dialog.ShowAsync() != ContentDialogResult.Primary) return; - chosen.AddRange(picks.Where(p => p.IsChecked == true) - .Select(p => (ShopDependency)p.Tag)); + chosen = dialog.SelectedDependencies; } await ViewModel.InstallAsync(version, chosen); @@ -139,9 +120,6 @@ private async Task OpenWebsiteAsync() { await Windows.System.Launcher.LaunchUriAsync(uri); } - public Visibility BoolToVisibility(bool value) => - value ? Visibility.Visible : Visibility.Collapsed; - public Visibility BodyVisibility(bool loading, string body) => !loading && body.Length > 0? Visibility.Visible : Visibility.Collapsed; diff --git a/app/JustHostMC.App/Views/ShopHomePage.xaml b/app/JustHostMC.App/Views/ShopHomePage.xaml index fa2f4f9..b9b2c9f 100644 --- a/app/JustHostMC.App/Views/ShopHomePage.xaml +++ b/app/JustHostMC.App/Views/ShopHomePage.xaml @@ -158,12 +158,14 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="8" - Visibility="{x:Bind HasStatus(ViewModel.StatusMessage), Mode=OneWay}"> + Visibility="{x:Bind ViewModel.HasLoadFailure, Converter={StaticResource BoolToVis}, Mode=OneWay}"> - + _ = private void OnDismissWelcome(object sender, RoutedEventArgs e) => WelcomeBanner.Visibility = Visibility.Collapsed; - public Visibility HasStatus(string status) => - status.Length > 0? Visibility.Visible : Visibility.Collapsed; - public static Visibility InvertVisibility(bool value) => value ? Visibility.Collapsed : Visibility.Visible; diff --git a/app/JustHostMC.App/Views/ShopSearchPage.xaml b/app/JustHostMC.App/Views/ShopSearchPage.xaml index 14b1061..67e0dd4 100644 --- a/app/JustHostMC.App/Views/ShopSearchPage.xaml +++ b/app/JustHostMC.App/Views/ShopSearchPage.xaml @@ -275,7 +275,7 @@ Content="{x:Bind ViewModel.LoaderFilterLabel, Mode=OneWay}" IsChecked="{x:Bind ViewModel.UseLoaderFilter, Mode=TwoWay}" Visibility="{x:Bind ViewModel.HasLoaderFilter}" /> - + @@ -370,7 +370,7 @@ IsChecked="{x:Bind ViewModel.UseLoaderFilter, Mode=TwoWay}" Visibility="{x:Bind ViewModel.HasLoaderFilter}" /> - + diff --git a/app/JustHostMC.App/Views/ShopSearchPage.xaml.cs b/app/JustHostMC.App/Views/ShopSearchPage.xaml.cs index 1283362..4b39d3b 100644 --- a/app/JustHostMC.App/Views/ShopSearchPage.xaml.cs +++ b/app/JustHostMC.App/Views/ShopSearchPage.xaml.cs @@ -123,6 +123,4 @@ public Visibility ShowSkeleton(bool loading, int resultCount) => public Visibility ShowLoadMoreIndicator(bool loading, int resultCount) => loading && resultCount > 0? Visibility.Visible : Visibility.Collapsed; - public Visibility BoolToVisibility(bool value) => - value ? Visibility.Visible : Visibility.Collapsed; } diff --git a/app/JustHostMC.App/Views/ShopWindow.xaml b/app/JustHostMC.App/Views/ShopWindow.xaml index 50ce60f..a663ec8 100644 --- a/app/JustHostMC.App/Views/ShopWindow.xaml +++ b/app/JustHostMC.App/Views/ShopWindow.xaml @@ -1,6 +1,7 @@  + + + + @@ -21,6 +34,7 @@ @@ -95,16 +109,24 @@ - + Spacing="8"> + + + /Resources.resw` with exactly the +same identifiers, add the language to the manifest and +`AppxDefaultResourceQualifiers`, run the resource tests, build, and exercise the +complete smoke matrix in that language. + +## Static XAML localization + +Put `x:Uid` on every XAML element with static visible or accessibility text. +The resource identifier is property-qualified: + +```xaml + diff --git a/app/JustHostMC.App/Controls/Server/ServerHeaderPanel.xaml.cs b/app/JustHostMC.App/Controls/Server/ServerHeaderPanel.xaml.cs index 4774148..4ff5c67 100644 --- a/app/JustHostMC.App/Controls/Server/ServerHeaderPanel.xaml.cs +++ b/app/JustHostMC.App/Controls/Server/ServerHeaderPanel.xaml.cs @@ -134,14 +134,13 @@ s is ServerStatus.Stopped or ServerStatus.Crashed or ServerStatus.Running; private Visibility PositiveValueVisibility(int value) => - value > 0 ? Visibility.Visible : Visibility.Collapsed; + value > 0? Visibility.Visible : Visibility.Collapsed; private Visibility NonPositiveValueVisibility(int value) => - value > 0 ? Visibility.Collapsed : Visibility.Visible; + value > 0? Visibility.Collapsed : Visibility.Visible; private string ValueText(int value) => value.ToString(); private string MemoryText(int memoryMb) => - _localizer.Get("Server_MemoryValue", - ("memory", memoryMb.ToString())); + _localizer.Get("Server_MemoryValue", ("memory", memoryMb.ToString())); } diff --git a/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml b/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml index a36f4f7..525b838 100644 --- a/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml +++ b/app/JustHostMC.App/Controls/Server/ServerModsPanel.xaml @@ -10,12 +10,8 @@ mc:Ignorable="d"> - - + + - + diff --git a/app/JustHostMC.App/Controls/Server/ServerPlayersPanel.xaml b/app/JustHostMC.App/Controls/Server/ServerPlayersPanel.xaml index ac3b650..6de0a3b 100644 --- a/app/JustHostMC.App/Controls/Server/ServerPlayersPanel.xaml +++ b/app/JustHostMC.App/Controls/Server/ServerPlayersPanel.xaml @@ -22,114 +22,114 @@ Title="{x:Bind PlayersHeader(Players.Count), Mode=OneWay}" Description="{x:Bind PlayersDescription(Players.Count), Mode=OneWay}" IconGlyph=""> - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - + Margin="0,0,8,0" + Background="{ThemeResource ControlFillColorDefaultBrush}" + CornerRadius="4"> + + + + + + + + + diff --git a/app/JustHostMC.App/Models/BanEntryItem.cs b/app/JustHostMC.App/Models/BanEntryItem.cs index 7b09f95..67cd83a 100644 --- a/app/JustHostMC.App/Models/BanEntryItem.cs +++ b/app/JustHostMC.App/Models/BanEntryItem.cs @@ -6,14 +6,14 @@ namespace JustHostMC.App.Models; /// banned-ips.json. public sealed class BanEntryItem { public BanEntryItem(BanEntry entry) { - Type = entry.Type; - Target = entry.Target; - Name = entry.Name; - Uuid = entry.Uuid; - Created = entry.Created; - Source = entry.Source; - Expires = entry.Expires; - Reason = entry.Reason; + Type = entry.Type; + Target = entry.Target; + Name = entry.Name; + Uuid = entry.Uuid; + Created = entry.Created; + Source = entry.Source; + Expires = entry.Expires; + Reason = entry.Reason; IdentityText = !string.IsNullOrWhiteSpace(Uuid) ? Uuid : Source; CreatedText = string.IsNullOrWhiteSpace(Created) ? Expires : Created; } @@ -26,7 +26,7 @@ public BanEntryItem(BanEntry entry) { public string Source { get; } public string Expires { get; } public string Reason { get; } - public bool IsIpBan => Type == BanListType.IpBans; + public bool IsIpBan => Type == BanListType.IpBans; public bool HasReason => !string.IsNullOrWhiteSpace(Reason); public string IdentityText { get; } public string CreatedText { get; } diff --git a/app/JustHostMC.App/Models/ConfigEntryItem.cs b/app/JustHostMC.App/Models/ConfigEntryItem.cs index f7c4f7b..c140256 100644 --- a/app/JustHostMC.App/Models/ConfigEntryItem.cs +++ b/app/JustHostMC.App/Models/ConfigEntryItem.cs @@ -28,8 +28,8 @@ public ConfigEntryItem(ConfigEntry entry, ILocalizer localizer) { public ConfigValueType Type { get; } public bool IsBoolean => Type == ConfigValueType.ConfigBoolean; public bool IsInteger => Type == ConfigValueType.ConfigInteger; - public bool IsChoice => Type == ConfigValueType.ConfigEnum; - public bool IsText => !IsBoolean && !IsInteger && !IsChoice; + public bool IsChoice => Type == ConfigValueType.ConfigEnum; + public bool IsText => !IsBoolean && !IsInteger && !IsChoice; public bool Supported { get; } public string SinceVersion { get; } public string Description { get; } diff --git a/app/JustHostMC.App/Models/PlayerInventoryItemView.cs b/app/JustHostMC.App/Models/PlayerInventoryItemView.cs index 1c880a2..87fa8d0 100644 --- a/app/JustHostMC.App/Models/PlayerInventoryItemView.cs +++ b/app/JustHostMC.App/Models/PlayerInventoryItemView.cs @@ -49,9 +49,10 @@ private PlayerInventoryItemView(PlayerInventoryItem item) { public string Tooltip => HasItem ? $"{StyledName}\n{ItemId}\n{SlotName}" : SlotName; public IReadOnlyList NbtSections => Nbt.Sections; - public string FormattedNbt => Nbt.FormattedJson; + public string FormattedNbt => Nbt.FormattedJson; public bool HasNbtParseFailure => Nbt.ParseError is not null; - public bool HasNoNbtDetails => Nbt.Sections.Count == 0 && !HasNbtParseFailure; + public bool HasNoNbtDetails => + Nbt.Sections.Count == 0 && !HasNbtParseFailure; public static PlayerInventoryItemView Empty(int slot, string slotName) => new(slot, slotName); diff --git a/app/JustHostMC.App/Models/ScriptEntryItem.cs b/app/JustHostMC.App/Models/ScriptEntryItem.cs index a5ad6f0..20fef2f 100644 --- a/app/JustHostMC.App/Models/ScriptEntryItem.cs +++ b/app/JustHostMC.App/Models/ScriptEntryItem.cs @@ -10,13 +10,13 @@ protected ScriptEntryItem(string id, string name, string author, string version, string description, IEnumerable permissions, IEnumerable granted) { - Id = id; - Name = string.IsNullOrEmpty(name) ? id : name; - Author = author; - Version = version; - Description = description; - Permissions = permissions.ToList(); - Granted = granted.ToList(); + Id = id; + Name = string.IsNullOrEmpty(name) ? id : name; + Author = author; + Version = version; + Description = description; + Permissions = permissions.ToList(); + Granted = granted.ToList(); } public string Id { get; } diff --git a/app/JustHostMC.App/Models/ServerItem.cs b/app/JustHostMC.App/Models/ServerItem.cs index 894349b..3d3d7aa 100644 --- a/app/JustHostMC.App/Models/ServerItem.cs +++ b/app/JustHostMC.App/Models/ServerItem.cs @@ -167,42 +167,43 @@ public string TypeText { return ProviderId; } } - public bool HasTypeText => !string.IsNullOrWhiteSpace(TypeText); - public bool IsVanillaProvider => ProviderId == "vanilla"; - public bool IsPaperProvider => ProviderId == "paper"; - public bool IsSpigotProvider => ProviderId == "spigot"; - public bool IsForgeProvider => ProviderId == "forge"; + public bool HasTypeText => !string.IsNullOrWhiteSpace(TypeText); + public bool IsVanillaProvider => ProviderId == "vanilla"; + public bool IsPaperProvider => ProviderId == "paper"; + public bool IsSpigotProvider => ProviderId == "spigot"; + public bool IsForgeProvider => ProviderId == "forge"; public bool IsNeoForgeProvider => ProviderId == "neoforge"; - public bool IsFabricProvider => ProviderId == "fabric"; - public bool IsTypeUnknown => string.IsNullOrWhiteSpace(ProviderId); - private bool IsBuiltInProvider => - IsVanillaProvider || IsPaperProvider || IsSpigotProvider || - IsForgeProvider || IsNeoForgeProvider || IsFabricProvider; + public bool IsFabricProvider => ProviderId == "fabric"; + public bool IsTypeUnknown => string.IsNullOrWhiteSpace(ProviderId); + private bool IsBuiltInProvider => IsVanillaProvider || IsPaperProvider || + IsSpigotProvider || IsForgeProvider || + IsNeoForgeProvider || IsFabricProvider; public bool CanStart => Status is ServerStatus.Stopped or ServerStatus.Crashed; public bool CanStop => Status is ServerStatus.Running or ServerStatus.Starting; - public bool CanToggleState => CanStart || CanStop; - public bool IsRunning => Status is ServerStatus.Running; - public bool IsStopped => Status is ServerStatus.Stopped; - public bool IsInstalling => Status is ServerStatus.Installing; - public bool IsStarting => Status is ServerStatus.Starting; - public bool IsStopping => Status is ServerStatus.Stopping; - public bool IsCrashed => Status is ServerStatus.Crashed; - public bool IsStatusUnknown => Status is not ( + public bool CanToggleState => CanStart || CanStop; + public bool IsRunning => Status is ServerStatus.Running; + public bool IsStopped => Status is ServerStatus.Stopped; + public bool IsInstalling => Status is ServerStatus.Installing; + public bool IsStarting => Status is ServerStatus.Starting; + public bool IsStopping => Status is ServerStatus.Stopping; + public bool IsCrashed => Status is ServerStatus.Crashed; + public bool IsStatusUnknown => Status is not( ServerStatus.Running or ServerStatus.Stopped or - ServerStatus.Installing or ServerStatus.Starting or - ServerStatus.Stopping or ServerStatus.Crashed); - public bool ShowStartAction => Status is not ( + ServerStatus.Installing or ServerStatus.Starting or + ServerStatus.Stopping or ServerStatus.Crashed); + public bool ShowStartAction => Status is not( ServerStatus.Running or ServerStatus.Installing or - ServerStatus.Starting or ServerStatus.Stopping); + ServerStatus.Starting or ServerStatus.Stopping); public bool IsIncompleteInstallation => Status is ServerStatus.Installing; public bool CanEditLaunchSettings => Status is ServerStatus.Stopped or ServerStatus.Crashed; public bool HasEndpoint => Port > 0; - public string EndpointText => Port <= 0 ? "" : ConnectHost.Value - is { Length : > 0 } host + public string EndpointText => + Port <= 0 ? "" + : ConnectHost.Value is { Length : > 0 } host ? $"{host}:{Port}" : _localizer.Get("Server_PortLabel", ("port", Port.ToString())); public string StateActionGlyph => Status switch { diff --git a/app/JustHostMC.App/Services/ILocalizer.cs b/app/JustHostMC.App/Services/ILocalizer.cs index 18c16c0..420a12a 100644 --- a/app/JustHostMC.App/Services/ILocalizer.cs +++ b/app/JustHostMC.App/Services/ILocalizer.cs @@ -6,7 +6,8 @@ namespace JustHostMC.App.Services; /// translator-controlled formats, error mappings, and non-XAML OS surfaces. /// public interface ILocalizer { - /// Resolves a dotted key to the current language's string. + /// Resolves a dotted key to the current language's + /// string. string Get(string key); /// Resolves a key and substitutes {name} diff --git a/app/JustHostMC.App/Services/LocalizationService.cs b/app/JustHostMC.App/Services/LocalizationService.cs index 94fed75..713cf74 100644 --- a/app/JustHostMC.App/Services/LocalizationService.cs +++ b/app/JustHostMC.App/Services/LocalizationService.cs @@ -19,7 +19,8 @@ public string Get(string key) { Debug.WriteLine($"Missing localization resource: {key}"); return key; } catch (Exception ex) { - Debug.WriteLine($"Failed to load localization resource '{key}': {ex}"); + Debug.WriteLine( + $"Failed to load localization resource '{key}': {ex}"); return key; } } @@ -29,7 +30,8 @@ public string Get(string key, params(string Name, string Value)[] args) { try { format = _loader.GetString(NormalizeKey(key)); } catch (Exception ex) { - Debug.WriteLine($"Failed to load localization resource '{key}': {ex}"); + Debug.WriteLine( + $"Failed to load localization resource '{key}': {ex}"); format = key; } foreach (var (name, value) in args) diff --git a/app/JustHostMC.App/Services/MinecraftItemNbtParser.cs b/app/JustHostMC.App/Services/MinecraftItemNbtParser.cs index 4792c6c..54da577 100644 --- a/app/JustHostMC.App/Services/MinecraftItemNbtParser.cs +++ b/app/JustHostMC.App/Services/MinecraftItemNbtParser.cs @@ -15,10 +15,10 @@ public enum NbtDetailKind { Code, } -public sealed record NbtDetailEntry( - string Label, string Value, NbtDetailKind Kind = NbtDetailKind.Default); +public sealed record NbtDetailEntry(string Label, string Value, + NbtDetailKind Kind = NbtDetailKind.Default); public sealed record NbtDetailSection(string Title, - IReadOnlyList Entries); + IReadOnlyList Entries); internal sealed record MinecraftItemNbtPresentation( string? DisplayName, IReadOnlyList Sections, diff --git a/app/JustHostMC.App/ViewModels/BackupsViewModel.cs b/app/JustHostMC.App/ViewModels/BackupsViewModel.cs index 8e93f1c..b1152b7 100644 --- a/app/JustHostMC.App/ViewModels/BackupsViewModel.cs +++ b/app/JustHostMC.App/ViewModels/BackupsViewModel.cs @@ -55,13 +55,19 @@ public partial bool SafeOnline { [NotifyPropertyChangedFor(nameof(IsRestoreBlockedStatus))] [NotifyPropertyChangedFor(nameof(IsFolderMissingStatus))] [NotifyPropertyChangedFor(nameof(IsErrorStatus))] - public partial BackupStatus Status { get; private set; } + public partial BackupStatus Status { + get; private set; + } [ObservableProperty] - public partial string ErrorMessage { get; private set; } = ""; + public partial string ErrorMessage { + get; private set; + } = ""; [ObservableProperty] - public partial string ExportPath { get; private set; } = ""; + public partial string ExportPath { + get; private set; + } = ""; public BackupsViewModel(string serverId, bool serverRunning, DispatcherQueue dispatcher, ILocalizer localizer) { @@ -83,20 +89,19 @@ public BackupsViewModel(string serverId, bool serverRunning, public bool CanRestore => !ServerRunning && !IsBusy; - public bool IsCreatingStatus => Status == BackupStatus.Creating; - public bool IsCreatedStatus => Status == BackupStatus.Created; + public bool IsCreatingStatus => Status == BackupStatus.Creating; + public bool IsCreatedStatus => Status == BackupStatus.Created; public bool IsRestoringStatus => Status == BackupStatus.Restoring; - public bool IsRestoredStatus => Status == BackupStatus.Restored; - public bool IsDeletingStatus => Status == BackupStatus.Deleting; - public bool IsDeletedStatus => Status == BackupStatus.Deleted; + public bool IsRestoredStatus => Status == BackupStatus.Restored; + public bool IsDeletingStatus => Status == BackupStatus.Deleting; + public bool IsDeletedStatus => Status == BackupStatus.Deleted; public bool IsExportSourceMissingStatus => Status == BackupStatus.ExportSourceMissing; - public bool IsExportedStatus => Status == BackupStatus.Exported; - public bool IsExportFailedStatus => Status == BackupStatus.ExportFailed; - public bool IsRestoreBlockedStatus => - Status == BackupStatus.RestoreBlocked; - public bool IsFolderMissingStatus => Status == BackupStatus.FolderMissing; - public bool IsErrorStatus => Status == BackupStatus.Error; + public bool IsExportedStatus => Status == BackupStatus.Exported; + public bool IsExportFailedStatus => Status == BackupStatus.ExportFailed; + public bool IsRestoreBlockedStatus => Status == BackupStatus.RestoreBlocked; + public bool IsFolderMissingStatus => Status == BackupStatus.FolderMissing; + public bool IsErrorStatus => Status == BackupStatus.Error; public void ReportExportSourceMissing() => SetStatus(BackupStatus.ExportSourceMissing); @@ -111,8 +116,7 @@ public void ReportExported(string path) { public void ReportRestoreBlocked() => SetStatus(BackupStatus.RestoreBlocked); - public void ReportFolderMissing() => - SetStatus(BackupStatus.FolderMissing); + public void ReportFolderMissing() => SetStatus(BackupStatus.FolderMissing); /// Loads (or reloads) the server's backups, newest /// first. @@ -206,7 +210,7 @@ private void SetStatus(BackupStatus status) { ErrorMessage = ""; if (status != BackupStatus.Exported) ExportPath = ""; - Status = status; + Status = status; } private void SetError(RpcException ex) { diff --git a/app/JustHostMC.App/ViewModels/MainViewModel.cs b/app/JustHostMC.App/ViewModels/MainViewModel.cs index f10e83f..2fbad62 100644 --- a/app/JustHostMC.App/ViewModels/MainViewModel.cs +++ b/app/JustHostMC.App/ViewModels/MainViewModel.cs @@ -70,8 +70,7 @@ public BoundedObservableCollection InstallLog { [NotifyPropertyChangedFor(nameof(IsEngineConnected))] [NotifyPropertyChangedFor(nameof(IsEngineConnectionFailed))] public partial EngineConnectionStatus EngineConnectionState { - get; - private set; + get; private set; } = EngineConnectionStatus.Connecting; public bool IsEngineConnecting => @@ -82,9 +81,7 @@ public partial EngineConnectionStatus EngineConnectionState { EngineConnectionState == EngineConnectionStatus.Failed; [ObservableProperty] - public partial bool IsInstalling { - get; private set; - } + public partial bool IsInstalling { get; private set; } [ObservableProperty] public partial bool InstallFailed { @@ -135,7 +132,8 @@ await daemon.Engine.HealthAsync( _serverChangesSession ??= CreateServerChangeSession(daemon); await _serverChangesSession.StartAsync(); } catch (Exception) { - RunOnUI(() => EngineConnectionState = EngineConnectionStatus.Failed); + RunOnUI(() => EngineConnectionState = + EngineConnectionStatus.Failed); } } @@ -198,8 +196,7 @@ public async Task InstallServerAsync(CreateServerRequest request) { tracker.IsReadyToRun = false; tracker.IsIndeterminate = true; tracker.ProgressFraction = 0; - tracker.CurrentStep = - _localizer.Get("install.progress.preparing"); + tracker.CurrentStep = _localizer.Get("install.progress.preparing"); InstallLog.Clear(); InstallFailed = false; @@ -226,9 +223,9 @@ public async Task InstallServerAsync(CreateServerRequest request) { tracker.IsInstalling = false; tracker.IsActive = false; tracker.IsReadyToRun = true; - tracker.CurrentStep = - _localizer.Get("install.progress.done") + " " + - _localizer.Get("install.ready_to_run"); + tracker.CurrentStep = _localizer.Get("install.progress.done") + + " " + + _localizer.Get("install.ready_to_run"); }); } catch (RpcException ex) { await progressBuffer.FlushAsync(); diff --git a/app/JustHostMC.App/ViewModels/ModsViewModel.cs b/app/JustHostMC.App/ViewModels/ModsViewModel.cs index 79fc384..ee22b23 100644 --- a/app/JustHostMC.App/ViewModels/ModsViewModel.cs +++ b/app/JustHostMC.App/ViewModels/ModsViewModel.cs @@ -111,7 +111,8 @@ public partial ModsWorkflowStatus WorkflowStatus { get; private set; } - public bool IsExportedStatus => WorkflowStatus == ModsWorkflowStatus.Exported; + public bool IsExportedStatus => + WorkflowStatus == ModsWorkflowStatus.Exported; public bool IsExportFailedStatus => WorkflowStatus == ModsWorkflowStatus.ExportFailed; @@ -309,8 +310,8 @@ public async Task UploadAsync(StorageFile file) { using var backgroundTask = App.Current.BackgroundTasks.Begin("mod-upload"); RunOnUI(() => { - IsBusy = true; - StatusMessage = ""; + IsBusy = true; + StatusMessage = ""; WorkflowStatus = ModsWorkflowStatus.None; }); try { @@ -397,8 +398,8 @@ public async Task ExportAllAsync(string destPath) { using var backgroundTask = App.Current.BackgroundTasks.Begin("mod-export"); RunOnUI(() => { - IsBusy = true; - StatusMessage = ""; + IsBusy = true; + StatusMessage = ""; WorkflowStatus = ModsWorkflowStatus.None; }); try { diff --git a/app/JustHostMC.App/ViewModels/ScriptsViewModel.cs b/app/JustHostMC.App/ViewModels/ScriptsViewModel.cs index 3fc2de8..e8cc7eb 100644 --- a/app/JustHostMC.App/ViewModels/ScriptsViewModel.cs +++ b/app/JustHostMC.App/ViewModels/ScriptsViewModel.cs @@ -325,8 +325,7 @@ private void AppendLogLine(string scriptId, string line, var session = GetOrCreateLogSession(sessionId, sessionStartedAt, isCurrentSession); session.Entries.Insert( - 0, new ScriptLogEntry( - displayId, scriptName, line, timestamp, "")); + 0, new ScriptLogEntry(displayId, scriptName, line, timestamp, "")); while (session.Entries.Count > MaxLogLinesPerSession) session.Entries.RemoveAt(session.Entries.Count - 1); @@ -362,8 +361,8 @@ private ScriptLogSession GetOrCreateLogSession(string sessionId, // Title is intentionally a semantic marker: empty means current, // non-empty means historical. ScriptLogsWindow owns the localized // presentation for both branches. - var session = new ScriptLogSession( - sessionId, startedAt, isCurrentSession ? "" : "previous"); + var session = new ScriptLogSession(sessionId, startedAt, + isCurrentSession ? "" : "previous"); _logSessionsById[sessionId] = session; var index = 0; diff --git a/app/JustHostMC.App/ViewModels/ServerConfigViewModel.cs b/app/JustHostMC.App/ViewModels/ServerConfigViewModel.cs index 3a427e5..7b33018 100644 --- a/app/JustHostMC.App/ViewModels/ServerConfigViewModel.cs +++ b/app/JustHostMC.App/ViewModels/ServerConfigViewModel.cs @@ -79,9 +79,7 @@ public partial bool GameRulesWorldExists { [ObservableProperty] [NotifyPropertyChangedFor(nameof(HasGameRulesMessage))] - public partial string GameRulesMessage { - get; private set; - } = ""; + public partial string GameRulesMessage { get; private set; } = ""; public bool HasGameRulesMessage => !string.IsNullOrWhiteSpace(GameRulesMessage); diff --git a/app/JustHostMC.App/ViewModels/SettingsViewModel.cs b/app/JustHostMC.App/ViewModels/SettingsViewModel.cs index 15bea32..3a6f176 100644 --- a/app/JustHostMC.App/ViewModels/SettingsViewModel.cs +++ b/app/JustHostMC.App/ViewModels/SettingsViewModel.cs @@ -88,14 +88,14 @@ public partial SettingsWorkflowStatus WorkflowStatus { public bool IsRemoveDataFailedStatus => WorkflowStatus == SettingsWorkflowStatus.RemoveDataFailed; public bool IsRemovingIncompleteStatus => - WorkflowStatus == SettingsWorkflowStatus.RemovingIncompleteInstallations; + WorkflowStatus == + SettingsWorkflowStatus.RemovingIncompleteInstallations; public bool IsRemoveIncompleteFailedStatus => - WorkflowStatus == SettingsWorkflowStatus.RemoveIncompleteInstallationsFailed; + WorkflowStatus == + SettingsWorkflowStatus.RemoveIncompleteInstallationsFailed; [ObservableProperty] - public partial bool IsBusy { - get; private set; - } + public partial bool IsBusy { get; private set; } [ObservableProperty] [NotifyPropertyChangedFor(nameof(HasIncompleteInstallations))] @@ -115,14 +115,12 @@ public partial int IncompleteInstallationCount { [NotifyPropertyChangedFor(nameof(IsDockerUnavailable))] public partial BackendMode ActiveBackendMode { get; private set; } - public bool IsDockerMode => ActiveBackendMode == BackendMode.Docker; + public bool IsDockerMode => ActiveBackendMode == BackendMode.Docker; public bool IsOnMachineMode => ActiveBackendMode == BackendMode.OnMachine; [ObservableProperty] [NotifyPropertyChangedFor(nameof(IsDockerUnavailable))] - public partial bool IsDockerAvailable { - get; private set; - } + public partial bool IsDockerAvailable { get; private set; } public bool IsDockerUnavailable => ActiveBackendMode != BackendMode.Unknown && !IsDockerAvailable; @@ -266,11 +264,11 @@ private async Task LoadBackendAsync() { ? BackendMode.Docker : BackendMode.OnMachine; IsDockerAvailable = info.DockerAvailable; - DockerAvailableText = info.DockerAvailable - ? _localizer.Get( - "Backend_DockerAvailable", - ("version", info.DockerVersion)) - : ""; + DockerAvailableText = + info.DockerAvailable + ? _localizer.Get("Backend_DockerAvailable", + ("version", info.DockerVersion)) + : ""; _loadingBackend = true; UseDocker = info.UseDocker; _loadingBackend = false; @@ -334,7 +332,8 @@ private async Task PurgeNow() { ("count", result.RemovedFiles.ToString()), ("size", FormatSize(result.FreedBytes))))); } catch (RpcException) { - RunOnUI(() => SetWorkflowStatus(SettingsWorkflowStatus.PurgeFailed)); + RunOnUI(() => + SetWorkflowStatus(SettingsWorkflowStatus.PurgeFailed)); } finally { RunOnUI(() => IsBusy = false); } @@ -350,7 +349,8 @@ private async Task RemoveAllData() { var daemon = await App.Current.DaemonReady; await daemon.Servers.RemoveAllDataAsync( new Empty(), deadline: DateTime.UtcNow.AddMinutes(2)); - RunOnUI(() => SetWorkflowStatus(SettingsWorkflowStatus.DataRemoved)); + RunOnUI(() => + SetWorkflowStatus(SettingsWorkflowStatus.DataRemoved)); } catch (RpcException) { RunOnUI(() => SetWorkflowStatus( SettingsWorkflowStatus.RemoveDataFailed)); @@ -384,7 +384,8 @@ await daemon.Servers.DeleteAsync( ("count", incomplete.Length.ToString())))); } catch (RpcException) { RunOnUI(() => SetWorkflowStatus( - SettingsWorkflowStatus.RemoveIncompleteInstallationsFailed)); + SettingsWorkflowStatus + .RemoveIncompleteInstallationsFailed)); } finally { await RefreshIncompleteInstallationsAsync(); RunOnUI(() => IsBusy = false); diff --git a/app/JustHostMC.App/ViewModels/ShopDetailViewModel.cs b/app/JustHostMC.App/ViewModels/ShopDetailViewModel.cs index 720f183..18bb831 100644 --- a/app/JustHostMC.App/ViewModels/ShopDetailViewModel.cs +++ b/app/JustHostMC.App/ViewModels/ShopDetailViewModel.cs @@ -118,9 +118,7 @@ public partial ShopDetailStatus DetailStatus { DetailStatus == ShopDetailStatus.InstallFailed; [ObservableProperty] - public partial bool InstallSucceeded { - get; private set; - } + public partial bool InstallSucceeded { get; private set; } [ObservableProperty] public partial string WebsiteUrl { @@ -160,7 +158,8 @@ await RunOnUIAsync(() => { RefreshPrimaryAction(); }); } catch { - await RunOnUIAsync(() => DetailStatus = ShopDetailStatus.LoadFailed); + await RunOnUIAsync(() => DetailStatus = + ShopDetailStatus.LoadFailed); } finally { await RunOnUIAsync(() => IsLoading = false); } @@ -192,7 +191,8 @@ await RunOnUIAsync(() => { RefreshPrimaryAction(); }); } catch { - await RunOnUIAsync(() => DetailStatus = ShopDetailStatus.LoadFailed); + await RunOnUIAsync(() => DetailStatus = + ShopDetailStatus.LoadFailed); } finally { await RunOnUIAsync(() => IsVersionsLoading = false); } @@ -263,7 +263,8 @@ await RunOnUIAsync(() => { StatusMessage = _localizer.Get(key); }); } catch { - await RunOnUIAsync(() => DetailStatus = ShopDetailStatus.InstallFailed); + await RunOnUIAsync(() => DetailStatus = + ShopDetailStatus.InstallFailed); } finally { await RunOnUIAsync(() => { IsInstalling = false; }); } diff --git a/app/JustHostMC.App/ViewModels/ShopViewModel.cs b/app/JustHostMC.App/ViewModels/ShopViewModel.cs index 0e79cae..e819c53 100644 --- a/app/JustHostMC.App/ViewModels/ShopViewModel.cs +++ b/app/JustHostMC.App/ViewModels/ShopViewModel.cs @@ -97,7 +97,7 @@ partial void OnSelectedShopChanged(ShopInfo? value) { // source. Interlocked.Increment(ref _homeGeneration); HomeSections.Clear(); - IsHomeLoading = false; + IsHomeLoading = false; HasLoadFailure = false; OnPropertyChanged(nameof(SelectedShopName)); @@ -195,7 +195,7 @@ public async Task LoadHomeAsync() { } var generation = Interlocked.Increment(ref _homeGeneration); await RunOnUIAsync(() => { - IsHomeLoading = true; + IsHomeLoading = true; HasLoadFailure = false; }); try { @@ -247,7 +247,7 @@ private string GetSectionDescription(string titleKey) { public async Task StartSearchAsync() { await RunOnUIAsync(() => { HasLoadFailure = false; - TotalResults = 0; + TotalResults = 0; SearchResults.Reset(); }); // The ListView pulls the first page through ISupportIncrementalLoading, diff --git a/app/JustHostMC.App/Views/BackupsContentDialog.xaml b/app/JustHostMC.App/Views/BackupsContentDialog.xaml index cfff503..0066890 100644 --- a/app/JustHostMC.App/Views/BackupsContentDialog.xaml +++ b/app/JustHostMC.App/Views/BackupsContentDialog.xaml @@ -1,9 +1,9 @@ - + diff --git a/app/JustHostMC.App/Views/BackupsContentDialog.xaml.cs b/app/JustHostMC.App/Views/BackupsContentDialog.xaml.cs index 47c4d30..8e3d55d 100644 --- a/app/JustHostMC.App/Views/BackupsContentDialog.xaml.cs +++ b/app/JustHostMC.App/Views/BackupsContentDialog.xaml.cs @@ -12,9 +12,9 @@ public BackupsContentDialog(string serverId, string serverName, InitializeComponent(); Title = serverName; - _content = new BackupsDialog(serverId, serverName, serverRunning, - dispatcher); - DialogBody.Content = _content; + _content = + new BackupsDialog(serverId, serverName, serverRunning, dispatcher); + DialogBody.Content = _content; Opened += async (_, _) => await _content.LoadAsync(); } } diff --git a/app/JustHostMC.App/Views/BackupsDialog.xaml.cs b/app/JustHostMC.App/Views/BackupsDialog.xaml.cs index ef19935..18d1819 100644 --- a/app/JustHostMC.App/Views/BackupsDialog.xaml.cs +++ b/app/JustHostMC.App/Views/BackupsDialog.xaml.cs @@ -32,8 +32,9 @@ public BackupsDialog(string serverId, string serverName, bool serverRunning, /// busy. public bool Not(bool value) => !value; - public Visibility ShowWhenEmpty(int count) => - count == 0 ? Visibility.Visible : Visibility.Collapsed; + public Visibility ShowWhenEmpty(int count) => count == 0 + ? Visibility.Visible + : Visibility.Collapsed; private async void OnExportBackupClick(object sender, RoutedEventArgs e) { if (ViewModel.IsBusy) diff --git a/app/JustHostMC.App/Views/BanListContentDialog.xaml b/app/JustHostMC.App/Views/BanListContentDialog.xaml index f495f93..fb3a264 100644 --- a/app/JustHostMC.App/Views/BanListContentDialog.xaml +++ b/app/JustHostMC.App/Views/BanListContentDialog.xaml @@ -1,9 +1,9 @@ - + diff --git a/app/JustHostMC.App/Views/BanListDialog.xaml b/app/JustHostMC.App/Views/BanListDialog.xaml index 981f473..95ddaeb 100644 --- a/app/JustHostMC.App/Views/BanListDialog.xaml +++ b/app/JustHostMC.App/Views/BanListDialog.xaml @@ -234,11 +234,26 @@ x:Name="BusyBar" IsIndeterminate="True" Visibility="Collapsed" /> - - - - - + + + + + diff --git a/app/JustHostMC.App/Views/BanListDialog.xaml.cs b/app/JustHostMC.App/Views/BanListDialog.xaml.cs index fc0cba4..e360052 100644 --- a/app/JustHostMC.App/Views/BanListDialog.xaml.cs +++ b/app/JustHostMC.App/Views/BanListDialog.xaml.cs @@ -107,11 +107,8 @@ private void ShowStatus(TextBlock status) { status.Visibility = Visibility.Visible; } - private IEnumerable StatusElements => [ - LoadFailedText, - TargetRequiredText, - AddFailedText, - StoppedRequiredText, - RemoveFailedText, + private IEnumerable + StatusElements => [LoadFailedText, TargetRequiredText, AddFailedText, + StoppedRequiredText, RemoveFailedText, ]; } diff --git a/app/JustHostMC.App/Views/CloseBusyDialog.xaml b/app/JustHostMC.App/Views/CloseBusyDialog.xaml index 5f61aed..828ca68 100644 --- a/app/JustHostMC.App/Views/CloseBusyDialog.xaml +++ b/app/JustHostMC.App/Views/CloseBusyDialog.xaml @@ -1,11 +1,10 @@ - + - + diff --git a/app/JustHostMC.App/Views/CreateServerDialog.xaml b/app/JustHostMC.App/Views/CreateServerDialog.xaml index 2326223..d36e717 100644 --- a/app/JustHostMC.App/Views/CreateServerDialog.xaml +++ b/app/JustHostMC.App/Views/CreateServerDialog.xaml @@ -1,9 +1,9 @@ - + diff --git a/app/JustHostMC.App/Views/CreateServerDialog.xaml.cs b/app/JustHostMC.App/Views/CreateServerDialog.xaml.cs index 6d93bc7..8374b2b 100644 --- a/app/JustHostMC.App/Views/CreateServerDialog.xaml.cs +++ b/app/JustHostMC.App/Views/CreateServerDialog.xaml.cs @@ -12,9 +12,9 @@ public CreateServerDialog(MainViewModel viewModel) { _content = new ServerDialog(viewModel, ServerDialogMode.Create); DialogBody.Content = _content; - IsPrimaryButtonEnabled = _content.CanSubmit; - _content.CanSubmitChanged += (_, _) => - IsPrimaryButtonEnabled = _content.CanSubmit; + IsPrimaryButtonEnabled = _content.CanSubmit; + _content.CanSubmitChanged += (_, _) => IsPrimaryButtonEnabled = + _content.CanSubmit; } public CreateServerRequest? BuildCreateRequest() => diff --git a/app/JustHostMC.App/Views/DeleteServerDialog.xaml b/app/JustHostMC.App/Views/DeleteServerDialog.xaml index c751dbd..079974a 100644 --- a/app/JustHostMC.App/Views/DeleteServerDialog.xaml +++ b/app/JustHostMC.App/Views/DeleteServerDialog.xaml @@ -1,11 +1,10 @@ - + - + diff --git a/app/JustHostMC.App/Views/EditServerDialog.xaml b/app/JustHostMC.App/Views/EditServerDialog.xaml index da2b2c7..beef37b 100644 --- a/app/JustHostMC.App/Views/EditServerDialog.xaml +++ b/app/JustHostMC.App/Views/EditServerDialog.xaml @@ -1,9 +1,9 @@ - + diff --git a/app/JustHostMC.App/Views/EditServerDialog.xaml.cs b/app/JustHostMC.App/Views/EditServerDialog.xaml.cs index 8118790..703e3e7 100644 --- a/app/JustHostMC.App/Views/EditServerDialog.xaml.cs +++ b/app/JustHostMC.App/Views/EditServerDialog.xaml.cs @@ -13,9 +13,9 @@ public EditServerDialog(MainViewModel viewModel, ServerItem server) { _content = new ServerDialog(viewModel, ServerDialogMode.Edit, server); DialogBody.Content = _content; - IsPrimaryButtonEnabled = _content.CanSubmit; - _content.CanSubmitChanged += (_, _) => - IsPrimaryButtonEnabled = _content.CanSubmit; + IsPrimaryButtonEnabled = _content.CanSubmit; + _content.CanSubmitChanged += (_, _) => IsPrimaryButtonEnabled = + _content.CanSubmit; } public UpdateServerRequest BuildUpdateRequest() => diff --git a/app/JustHostMC.App/Views/HomePage.xaml b/app/JustHostMC.App/Views/HomePage.xaml index 1a1a5c5..21d83e7 100644 --- a/app/JustHostMC.App/Views/HomePage.xaml +++ b/app/JustHostMC.App/Views/HomePage.xaml @@ -304,21 +304,11 @@ Spacing="8"> - - - - - + + + + + diff --git a/app/JustHostMC.App/Views/HomePage.xaml.cs b/app/JustHostMC.App/Views/HomePage.xaml.cs index 7a27ee0..8970e18 100644 --- a/app/JustHostMC.App/Views/HomePage.xaml.cs +++ b/app/JustHostMC.App/Views/HomePage.xaml.cs @@ -90,7 +90,7 @@ private async void OnCardDeleteClick(object sender, RoutedEventArgs e) { ContentDialog confirm = item.IsIncompleteInstallation ? new IncompleteServerRemovalDialog() : new DeleteServerDialog(); - confirm.XamlRoot = XamlRoot; + confirm.XamlRoot = XamlRoot; if (await confirm.ShowAsync() == ContentDialogResult.Primary) Main.DeleteServerCommand.Execute(item); } diff --git a/app/JustHostMC.App/Views/IncompleteServerRemovalDialog.xaml b/app/JustHostMC.App/Views/IncompleteServerRemovalDialog.xaml index 5c66212..5b65703 100644 --- a/app/JustHostMC.App/Views/IncompleteServerRemovalDialog.xaml +++ b/app/JustHostMC.App/Views/IncompleteServerRemovalDialog.xaml @@ -1,11 +1,10 @@ - + - + diff --git a/app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml b/app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml index 4d73f3f..231dcf5 100644 --- a/app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml +++ b/app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml @@ -1,9 +1,9 @@ - + diff --git a/app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml.cs b/app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml.cs index 547e336..ae3cb75 100644 --- a/app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml.cs +++ b/app/JustHostMC.App/Views/PermissionConsentContentDialog.xaml.cs @@ -6,13 +6,13 @@ namespace JustHostMC.App.Views; public sealed partial class PermissionConsentContentDialog : ContentDialog { public PermissionConsentDialog Body { get; } - public PermissionConsentContentDialog( - string scriptName, IEnumerable permissions) { + public PermissionConsentContentDialog(string scriptName, + IEnumerable permissions) { Body = new PermissionConsentDialog(permissions); InitializeComponent(); - Title = Title?.ToString()?.Replace( - "{name}", scriptName, StringComparison.Ordinal); + Title = Title?.ToString()?.Replace("{name}", scriptName, + StringComparison.Ordinal); } public IReadOnlyList Granted => Body.Granted; diff --git a/app/JustHostMC.App/Views/PermissionConsentDialog.xaml b/app/JustHostMC.App/Views/PermissionConsentDialog.xaml index ac346e8..82c40ea 100644 --- a/app/JustHostMC.App/Views/PermissionConsentDialog.xaml +++ b/app/JustHostMC.App/Views/PermissionConsentDialog.xaml @@ -3,9 +3,9 @@ x:Class="JustHostMC.App.Views.PermissionConsentDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:controls="using:JustHostMC.App.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:controls="using:JustHostMC.App.Controls" xmlns:views="using:JustHostMC.App.Views" mc:Ignorable="d"> diff --git a/app/JustHostMC.App/Views/PlayerDataContentDialog.xaml b/app/JustHostMC.App/Views/PlayerDataContentDialog.xaml index 8de6a02..d1ea898 100644 --- a/app/JustHostMC.App/Views/PlayerDataContentDialog.xaml +++ b/app/JustHostMC.App/Views/PlayerDataContentDialog.xaml @@ -1,9 +1,9 @@ - + diff --git a/app/JustHostMC.App/Views/PlayerDataContentDialog.xaml.cs b/app/JustHostMC.App/Views/PlayerDataContentDialog.xaml.cs index a56a457..e93b099 100644 --- a/app/JustHostMC.App/Views/PlayerDataContentDialog.xaml.cs +++ b/app/JustHostMC.App/Views/PlayerDataContentDialog.xaml.cs @@ -8,7 +8,7 @@ public sealed partial class PlayerDataContentDialog : ContentDialog { public PlayerDataContentDialog(string serverId, PlayerItem player) { var view = new PlayerDataDialog(serverId, player); - Body = new PlayerDialogBase(player, view); + Body = new PlayerDialogBase(player, view); InitializeComponent(); Title = string.Format(Title?.ToString() ?? "{0}", player.Name); diff --git a/app/JustHostMC.App/Views/PlayerDataDialog.xaml.cs b/app/JustHostMC.App/Views/PlayerDataDialog.xaml.cs index dccea20..8c0aed8 100644 --- a/app/JustHostMC.App/Views/PlayerDataDialog.xaml.cs +++ b/app/JustHostMC.App/Views/PlayerDataDialog.xaml.cs @@ -21,7 +21,7 @@ public PlayerDataDialog(string serverId, PlayerItem player) { } private async Task LoadAsync() { - BusyBar.Visibility = Microsoft.UI.Xaml.Visibility.Visible; + BusyBar.Visibility = Microsoft.UI.Xaml.Visibility.Visible; LoadFailedText.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed; try { var daemon = await App.Current.DaemonReady; diff --git a/app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml b/app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml index b6c5f10..1f22b03 100644 --- a/app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml +++ b/app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml @@ -1,9 +1,9 @@ - + diff --git a/app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml.cs b/app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml.cs index 4249a23..acba42c 100644 --- a/app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml.cs +++ b/app/JustHostMC.App/Views/PlayerInventoryContentDialog.xaml.cs @@ -8,7 +8,7 @@ public sealed partial class PlayerInventoryContentDialog : ContentDialog { public PlayerInventoryContentDialog(string serverId, PlayerItem player) { var view = new PlayerInventoryDialog(serverId, player); - Body = new PlayerDialogBase(player, view); + Body = new PlayerDialogBase(player, view); InitializeComponent(); Title = string.Format(Title?.ToString() ?? "{0}", player.Name); diff --git a/app/JustHostMC.App/Views/PlayerInventoryDialog.xaml.cs b/app/JustHostMC.App/Views/PlayerInventoryDialog.xaml.cs index 0a73c23..03658ed 100644 --- a/app/JustHostMC.App/Views/PlayerInventoryDialog.xaml.cs +++ b/app/JustHostMC.App/Views/PlayerInventoryDialog.xaml.cs @@ -70,7 +70,7 @@ private async Task LoadAsync() { var enderBySlot = ender.ToDictionary(item => item.Slot); var inventorySlotFormat = _localizer.Get("player.inventory.slot"); - var hotbarSlotFormat = _localizer.Get("player.inventory.hotbar"); + var hotbarSlotFormat = _localizer.Get("player.inventory.hotbar"); var enderSlotFormat = _localizer.Get("player.inventory.ender_slot"); FillSlots(MainSlots, Enumerable.Range(9, 27), inventoryBySlot, slot => string.Format(inventorySlotFormat, slot - 8)); @@ -104,17 +104,18 @@ private static void FillSlots( private string EquipmentName(int slot) { var key = slot switch { - 103 => "player.inventory.helmet", - 102 => "player.inventory.chestplate", - 101 => "player.inventory.leggings", - 100 => "player.inventory.boots", - -106 => "player.inventory.offhand", - _ => "", + 103 => "player.inventory.helmet", + 102 => "player.inventory.chestplate", + 101 => "player.inventory.leggings", + 100 => "player.inventory.boots", + - + 106 => "player.inventory.offhand", + _ => "", }; return key.Length > 0 ? _localizer.Get(key) : string.Format( - _localizer.Get("player.inventory.generic_slot"), slot); + _localizer.Get("player.inventory.generic_slot"), slot); } private void OnInventorySlotClick(object sender, RoutedEventArgs e) { @@ -126,9 +127,9 @@ private void OnInventorySlotClick(object sender, RoutedEventArgs e) { var flyout = new Flyout { Content = new ScrollViewer { - Content = new InventoryItemDetails(item), - MaxHeight = 540, - HorizontalContentAlignment = HorizontalAlignment.Stretch, + Content = new InventoryItemDetails(item), + MaxHeight = 540, + HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, }, }; diff --git a/app/JustHostMC.App/Views/RenameServerDialog.xaml b/app/JustHostMC.App/Views/RenameServerDialog.xaml index 2f05d04..eae9fa2 100644 --- a/app/JustHostMC.App/Views/RenameServerDialog.xaml +++ b/app/JustHostMC.App/Views/RenameServerDialog.xaml @@ -1,12 +1,11 @@ - + - + diff --git a/app/JustHostMC.App/Views/ScriptLogsWindow.xaml.cs b/app/JustHostMC.App/Views/ScriptLogsWindow.xaml.cs index 657b783..b74122a 100644 --- a/app/JustHostMC.App/Views/ScriptLogsWindow.xaml.cs +++ b/app/JustHostMC.App/Views/ScriptLogsWindow.xaml.cs @@ -13,14 +13,15 @@ public sealed partial class ScriptLogsWindow : Window { public ObservableCollection LogSessions { get; } - public Visibility ShowWhenEmpty(int count) => - count == 0 ? Visibility.Visible : Visibility.Collapsed; + public Visibility ShowWhenEmpty(int count) => count == 0 + ? Visibility.Visible + : Visibility.Collapsed; public ScriptLogsWindow( ObservableCollection logSessions) { LogSessions = logSessions; InitializeComponent(); - Title = LogsTitleBar.Title; + Title = LogsTitleBar.Title; Root.DataContext = this; ExtendsContentIntoTitleBar = true; diff --git a/app/JustHostMC.App/Views/ScriptsPage.xaml.cs b/app/JustHostMC.App/Views/ScriptsPage.xaml.cs index 3fbc83e..9cc6f8f 100644 --- a/app/JustHostMC.App/Views/ScriptsPage.xaml.cs +++ b/app/JustHostMC.App/Views/ScriptsPage.xaml.cs @@ -163,10 +163,10 @@ private static string ResolveDataRoot() { private async Task?> RequestConsentAsync( string scriptName, string luaSource) { var permissions = LuaPermissions.Parse(luaSource); - var dialog = new PermissionConsentContentDialog( - scriptName, permissions) { - XamlRoot = XamlRoot, - }; + var dialog = + new PermissionConsentContentDialog(scriptName, permissions) { + XamlRoot = XamlRoot, + }; ContentDialogSizing.Apply(dialog); if (await dialog.ShowAsync() != ContentDialogResult.Primary) diff --git a/app/JustHostMC.App/Views/ServerDialog.xaml.cs b/app/JustHostMC.App/Views/ServerDialog.xaml.cs index 938b4a8..ee0955d 100644 --- a/app/JustHostMC.App/Views/ServerDialog.xaml.cs +++ b/app/JustHostMC.App/Views/ServerDialog.xaml.cs @@ -62,10 +62,10 @@ private void InitializeEditMode(ServerItem server) { VersionHint.Visibility = Visibility.Collapsed; LaunchLockedInfo.Visibility = Visibility.Visible; - NameBox.Text = server.Name; - EditTypeBox.Text = string.IsNullOrWhiteSpace(server.TypeText) - ? server.ProviderId - : server.TypeText; + NameBox.Text = server.Name; + EditTypeBox.Text = string.IsNullOrWhiteSpace(server.TypeText) + ? server.ProviderId + : server.TypeText; VersionBox.IsEditable = false; VersionBox.ItemsSource = new[] { server.McVersion }; VersionBox.SelectedIndex = 0; diff --git a/app/JustHostMC.App/Views/ServerFolderNotFoundDialog.xaml b/app/JustHostMC.App/Views/ServerFolderNotFoundDialog.xaml index 7386803..1e069e8 100644 --- a/app/JustHostMC.App/Views/ServerFolderNotFoundDialog.xaml +++ b/app/JustHostMC.App/Views/ServerFolderNotFoundDialog.xaml @@ -1,11 +1,10 @@ - + - + diff --git a/app/JustHostMC.App/Views/ServerPage.xaml.cs b/app/JustHostMC.App/Views/ServerPage.xaml.cs index d26cf79..b9f685d 100644 --- a/app/JustHostMC.App/Views/ServerPage.xaml.cs +++ b/app/JustHostMC.App/Views/ServerPage.xaml.cs @@ -239,7 +239,7 @@ private async void OnDeleteClick(object sender, RoutedEventArgs e) { ContentDialog confirm = Server.IsIncompleteInstallation ? new IncompleteServerRemovalDialog() : new DeleteServerDialog(); - confirm.XamlRoot = XamlRoot; + confirm.XamlRoot = XamlRoot; if (await confirm.ShowAsync() != ContentDialogResult.Primary) return; _main.DeleteServerCommand.Execute(Server); diff --git a/app/JustHostMC.App/Views/SettingsPage.xaml b/app/JustHostMC.App/Views/SettingsPage.xaml index 6e963b4..6a5e5e8 100644 --- a/app/JustHostMC.App/Views/SettingsPage.xaml +++ b/app/JustHostMC.App/Views/SettingsPage.xaml @@ -162,15 +162,9 @@ - - - + + + diff --git a/app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml b/app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml index 2f4c764..bb7c692 100644 --- a/app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml +++ b/app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml @@ -1,17 +1,15 @@ - + - + diff --git a/app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml.cs b/app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml.cs index befd357..8ef1581 100644 --- a/app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml.cs +++ b/app/JustHostMC.App/Views/ShopDependencySelectionDialog.xaml.cs @@ -10,15 +10,16 @@ public ShopDependencySelectionDialog( IReadOnlyList dependencies) { InitializeComponent(); - _choices = dependencies.Select(dependency => new CheckBox { - Content = dependency.Title.Length > 0 - ? dependency.Title - : dependency.ProjectId, - IsChecked = true, - Tag = dependency, - }).ToArray(); - foreach (var choice in _choices) - ChoicesPanel.Children.Add(choice); + _choices = dependencies + .Select(dependency => new CheckBox { + Content = dependency.Title.Length > 0 + ? dependency.Title + : dependency.ProjectId, + IsChecked = true, + Tag = dependency, + }) + .ToArray(); + foreach (var choice in _choices) ChoicesPanel.Children.Add(choice); } public IReadOnlyList SelectedDependencies => diff --git a/app/JustHostMC.App/Views/ShopDetailPage.xaml b/app/JustHostMC.App/Views/ShopDetailPage.xaml index f8e515d..27c255f 100644 --- a/app/JustHostMC.App/Views/ShopDetailPage.xaml +++ b/app/JustHostMC.App/Views/ShopDetailPage.xaml @@ -123,12 +123,8 @@ Style="{StaticResource AccentButtonStyle}" Tag="{x:Bind ViewModel.LatestRelease, Mode=OneWay}"> - - + + @@ -259,12 +255,8 @@ Style="{StaticResource AccentButtonStyle}" Tag="{x:Bind ViewModel.LatestRelease, Mode=OneWay}"> - - + + - - + + diff --git a/app/JustHostMC.App/Views/ShopHomePage.xaml b/app/JustHostMC.App/Views/ShopHomePage.xaml index b9b2c9f..84eca1b 100644 --- a/app/JustHostMC.App/Views/ShopHomePage.xaml +++ b/app/JustHostMC.App/Views/ShopHomePage.xaml @@ -163,9 +163,7 @@ FontSize="28" Foreground="{ThemeResource TextFillColorTertiaryBrush}" Glyph="" /> - + public Visibility ShowLoadMoreIndicator(bool loading, int resultCount) => loading && resultCount > 0? Visibility.Visible : Visibility.Collapsed; - } diff --git a/app/JustHostMC.App/Views/ShopWindow.xaml b/app/JustHostMC.App/Views/ShopWindow.xaml index fa9ba4a..799b5cf 100644 --- a/app/JustHostMC.App/Views/ShopWindow.xaml +++ b/app/JustHostMC.App/Views/ShopWindow.xaml @@ -14,9 +14,11 @@ - +