Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AOT compatible] Clean up some AOT build issue in PowerAccent.Core #36264

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/modules/poweraccent/PowerAccent.Core/Languages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal sealed class Languages
{
public static string[] GetDefaultLetterKey(LetterKey letter, Language[] langs)
{
if (langs.Length == Enum.GetValues(typeof(Language)).Length)
if (langs.Length == Enum.GetValues<Language>().Length)
{
return GetDefaultLetterKeyALL(letter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- Look at Directory.Build.props in root for common stuff as well -->
<Import Project="..\..\..\Common.Dotnet.CsWinRT.props" />
<Import Project="..\..\..\Common.SelfContained.props" />
<Import Project="..\..\..\Common.Dotnet.AotCompatibility.props" />

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace PowerAccent.Core;

public class PowerAccent : IDisposable
public partial class PowerAccent : IDisposable
{
private readonly SettingsService _settingService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ public SettingsService(KeyboardListener keyboardListener)
_watcher = Helper.GetFileWatcher(PowerAccentModuleName, "settings.json", () => { ReadSettings(); });
}

private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
{
WriteIndented = true,
};

private void ReadSettings()
{
// TODO this IO call should by Async, update GetFileWatcher helper to support async
Expand All @@ -46,9 +41,8 @@ private void ReadSettings()
{
Logger.LogInfo("QuickAccent settings.json was missing, creating a new one");
var defaultSettings = new PowerAccentSettings();
var options = _serializerOptions;

_settingsUtils.SaveSettings(JsonSerializer.Serialize(this, options), PowerAccentModuleName);
_settingsUtils.SaveSettings(JsonSerializer.Serialize(this, SourceGenerationContext.Default.SettingsService), PowerAccentModuleName);
}

var settings = _settingsUtils.GetSettingsOrDefault<PowerAccentSettings>(PowerAccentModuleName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Text.Json.Serialization;

namespace PowerAccent.Core.Services
{
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(SettingsService))]
public partial class SourceGenerationContext : JsonSerializerContext
{
}
}
Loading