Skip to content

A Swiss Army knife for developers.

Disabled trimming. Added cross-platform file storage service. Added File logger. Fixed resx generator

Etienne Baudoux9299e28998a7
diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json
index b962341b4..5ba738955 100644
--- a/.nuke/build.schema.json
+++ b/.nuke/build.schema.json
@@ -93,6 +93,8 @@
"items": {
"type": "string",
"enum": [
+ "BuildGenerators",
+ "BuildPlugins",
"Clean",
"PreliminaryCheck",
"Publish",
@@ -108,6 +110,8 @@
"items": {
"type": "string",
"enum": [
+ "BuildGenerators",
+ "BuildPlugins",
"Clean",
"PreliminaryCheck",
"Publish",
diff --git a/src/DevToys-Windows.sln b/src/DevToys-Windows.sln
index b3809518b..bdcab91b5 100644
--- a/src/DevToys-Windows.sln
+++ b/src/DevToys-Windows.sln
@@ -20,6 +20,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{9771D1F8-D331-4B26-8E96-6024893009F4}"
ProjectSection(SolutionItems) = preProject
app\dev\shared\GlobalUsings.cs = app\dev\shared\GlobalUsings.cs
+ app\dev\shared\LinkerConfig.xml = app\dev\shared\LinkerConfig.xml
app\dev\shared\SharedAssemblyInfo.cs = app\dev\shared\SharedAssemblyInfo.cs
app\dev\shared\SharedAssemblyVersion.cs = app\dev\shared\SharedAssemblyVersion.cs
EndProjectSection
@@ -35,6 +36,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "desktops", "desktops", "{22EE9386-CEFA-47D8-97B2-09A63EDF7F2E}"
ProjectSection(SolutionItems) = preProject
+ app\dev\platforms\desktop\Directory.Build.props = app\dev\platforms\desktop\Directory.Build.props
app\dev\platforms\desktop\Directory.Build.targets = app\dev\platforms\desktop\Directory.Build.targets
EndProjectSection
EndProject
@@ -79,20 +81,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.Wasdk", "app\dev\pl
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.Localization", "app\dev\DevToys.Localization\DevToys.Localization.csproj", "{12A1461D-3357-4007-BE15-9622E9513D09}"
+ ProjectSection(ProjectDependencies) = postProject
+ {DB6B033B-584E-43CF-AC96-4F6548C96ECA} = {DB6B033B-584E-43CF-AC96-4F6548C96ECA}
+ EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "generators", "generators", "{FA3821C4-74BB-4927-ABCC-0D0A12E097A2}"
+ ProjectSection(SolutionItems) = preProject
+ generators\Directory.Build.props = generators\Directory.Build.props
+ generators\Directory.Build.targets = generators\Directory.Build.targets
+ EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResxHelperGenerator", "generators\ResxHelperGenerator\ResxHelperGenerator.csproj", "{DB6B033B-584E-43CF-AC96-4F6548C96ECA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
- Debug|AnyCPU = Debug|AnyCPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
- Release|AnyCPU = Release|AnyCPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
@@ -100,8 +107,6 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Debug|ARM64.Build.0 = Debug|Any CPU
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -110,8 +115,6 @@ Global
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Debug|x86.Build.0 = Debug|Any CPU
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|Any CPU.Build.0 = Release|Any CPU
- {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|AnyCPU.Build.0 = Release|Any CPU
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|ARM64.ActiveCfg = Release|Any CPU
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|ARM64.Build.0 = Release|Any CPU
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|x64.ActiveCfg = Release|Any CPU
@@ -120,8 +123,6 @@ Global
{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}.Release|x86.Build.0 = Release|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|ARM64.Build.0 = Debug|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -130,8 +131,6 @@ Global
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Debug|x86.Build.0 = Debug|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|Any CPU.Build.0 = Release|Any CPU
- {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|AnyCPU.Build.0 = Release|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|ARM64.ActiveCfg = Release|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|ARM64.Build.0 = Release|Any CPU
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x64.ActiveCfg = Release|Any CPU
@@ -140,8 +139,6 @@ Global
{745FD4CA-84CC-45D8-A3E2-814A0B9C16C4}.Release|x86.Build.0 = Release|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|ARM64.Build.0 = Debug|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -150,8 +147,6 @@ Global
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Debug|x86.Build.0 = Debug|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Release|Any CPU.Build.0 = Release|Any CPU
- {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Release|AnyCPU.Build.0 = Release|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Release|ARM64.ActiveCfg = Release|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Release|ARM64.Build.0 = Release|Any CPU
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Release|x64.ActiveCfg = Release|Any CPU
@@ -160,8 +155,6 @@ Global
{89A4D88F-5AC0-436A-8EC5-8E98728CA89E}.Release|x86.Build.0 = Release|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Debug|ARM64.Build.0 = Debug|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -170,8 +163,6 @@ Global
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Debug|x86.Build.0 = Debug|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Release|Any CPU.Build.0 = Release|Any CPU
- {CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Release|AnyCPU.Build.0 = Release|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Release|ARM64.ActiveCfg = Release|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Release|ARM64.Build.0 = Release|Any CPU
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Release|x64.ActiveCfg = Release|Any CPU
@@ -180,8 +171,6 @@ Global
{CCAB7530-4341-4C24-B4E8-28679BB6C4FB}.Release|x86.Build.0 = Release|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B6D48157-5257-4B60-B065-3B231B610A54}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {B6D48157-5257-4B60-B065-3B231B610A54}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Debug|ARM64.Build.0 = Debug|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -190,8 +179,6 @@ Global
{B6D48157-5257-4B60-B065-3B231B610A54}.Debug|x86.Build.0 = Debug|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Release|Any CPU.Build.0 = Release|Any CPU
- {B6D48157-5257-4B60-B065-3B231B610A54}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {B6D48157-5257-4B60-B065-3B231B610A54}.Release|AnyCPU.Build.0 = Release|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Release|ARM64.ActiveCfg = Release|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Release|ARM64.Build.0 = Release|Any CPU
{B6D48157-5257-4B60-B065-3B231B610A54}.Release|x64.ActiveCfg = Release|Any CPU
@@ -200,8 +187,6 @@ Global
{B6D48157-5257-4B60-B065-3B231B610A54}.Release|x86.Build.0 = Release|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A730FA8A-3713-4F7A-915D-79098CA12DF0}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {A730FA8A-3713-4F7A-915D-79098CA12DF0}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Debug|ARM64.Build.0 = Debug|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -210,8 +195,6 @@ Global
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Debug|x86.Build.0 = Debug|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Release|Any CPU.Build.0 = Release|Any CPU
- {A730FA8A-3713-4F7A-915D-79098CA12DF0}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {A730FA8A-3713-4F7A-915D-79098CA12DF0}.Release|AnyCPU.Build.0 = Release|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Release|ARM64.ActiveCfg = Release|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Release|ARM64.Build.0 = Release|Any CPU
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Release|x64.ActiveCfg = Release|Any CPU
@@ -220,8 +203,6 @@ Global
{A730FA8A-3713-4F7A-915D-79098CA12DF0}.Release|x86.Build.0 = Release|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {723A3D71-2425-49EE-B669-1A0DF3A8B486}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {723A3D71-2425-49EE-B669-1A0DF3A8B486}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Debug|ARM64.Build.0 = Debug|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -230,8 +211,6 @@ Global
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Debug|x86.Build.0 = Debug|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Release|Any CPU.ActiveCfg = Release|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Release|Any CPU.Build.0 = Release|Any CPU
- {723A3D71-2425-49EE-B669-1A0DF3A8B486}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {723A3D71-2425-49EE-B669-1A0DF3A8B486}.Release|AnyCPU.Build.0 = Release|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Release|ARM64.ActiveCfg = Release|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Release|ARM64.Build.0 = Release|Any CPU
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Release|x64.ActiveCfg = Release|Any CPU
@@ -240,8 +219,6 @@ Global
{723A3D71-2425-49EE-B669-1A0DF3A8B486}.Release|x86.Build.0 = Release|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Debug|ARM64.Build.0 = Debug|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -250,8 +227,6 @@ Global
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Debug|x86.Build.0 = Debug|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Release|Any CPU.Build.0 = Release|Any CPU
- {104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Release|AnyCPU.Build.0 = Release|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Release|ARM64.ActiveCfg = Release|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Release|ARM64.Build.0 = Release|Any CPU
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Release|x64.ActiveCfg = Release|Any CPU
@@ -260,8 +235,6 @@ Global
{104F1E4B-E0D3-4D87-9DA0-3FE82FE2573A}.Release|x86.Build.0 = Release|Any CPU
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Debug|ARM64.ActiveCfg = Debug|arm64
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Debug|ARM64.Build.0 = Debug|arm64
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Debug|x64.ActiveCfg = Debug|x64
@@ -270,8 +243,6 @@ Global
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Debug|x86.Build.0 = Debug|x86
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Release|Any CPU.Build.0 = Release|Any CPU
- {CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Release|AnyCPU.Build.0 = Release|Any CPU
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Release|ARM64.ActiveCfg = Release|arm64
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Release|ARM64.Build.0 = Release|arm64
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Release|x64.ActiveCfg = Release|x64
@@ -280,8 +251,6 @@ Global
{CDD8B469-ACA6-4A7D-91A0-66ADB0563AE8}.Release|x86.Build.0 = Release|x86
{9E59352A-836D-47DE-AB02-F404A8345242}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E59352A-836D-47DE-AB02-F404A8345242}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9E59352A-836D-47DE-AB02-F404A8345242}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {9E59352A-836D-47DE-AB02-F404A8345242}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{9E59352A-836D-47DE-AB02-F404A8345242}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{9E59352A-836D-47DE-AB02-F404A8345242}.Debug|ARM64.Build.0 = Debug|Any CPU
{9E59352A-836D-47DE-AB02-F404A8345242}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -290,8 +259,6 @@ Global
{9E59352A-836D-47DE-AB02-F404A8345242}.Debug|x86.Build.0 = Debug|Any CPU
{9E59352A-836D-47DE-AB02-F404A8345242}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E59352A-836D-47DE-AB02-F404A8345242}.Release|Any CPU.Build.0 = Release|Any CPU
- {9E59352A-836D-47DE-AB02-F404A8345242}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {9E59352A-836D-47DE-AB02-F404A8345242}.Release|AnyCPU.Build.0 = Release|Any CPU
{9E59352A-836D-47DE-AB02-F404A8345242}.Release|ARM64.ActiveCfg = Release|Any CPU
{9E59352A-836D-47DE-AB02-F404A8345242}.Release|ARM64.Build.0 = Release|Any CPU
{9E59352A-836D-47DE-AB02-F404A8345242}.Release|x64.ActiveCfg = Release|Any CPU
@@ -301,9 +268,6 @@ Global
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|AnyCPU.ActiveCfg = Debug|x86
- {64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|AnyCPU.Build.0 = Debug|x86
- {64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|AnyCPU.Deploy.0 = Debug|x86
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|ARM64.Build.0 = Debug|Any CPU
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|ARM64.Deploy.0 = Debug|Any CPU
@@ -315,9 +279,6 @@ Global
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Debug|x86.Deploy.0 = Debug|Any CPU
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Release|Any CPU.Build.0 = Release|Any CPU
- {64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Release|AnyCPU.Build.0 = Release|Any CPU
- {64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Release|AnyCPU.Deploy.0 = Release|Any CPU
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Release|ARM64.ActiveCfg = Release|Any CPU
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Release|ARM64.Build.0 = Release|Any CPU
{64B8DB6D-3168-48DE-95BD-BBE7BAB3A262}.Release|ARM64.Deploy.0 = Release|Any CPU
@@ -330,9 +291,6 @@ Global
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Debug|Any CPU.ActiveCfg = Debug|x86
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Debug|Any CPU.Build.0 = Debug|x86
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Debug|Any CPU.Deploy.0 = Debug|x86
- {804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Debug|AnyCPU.ActiveCfg = Debug|x64
- {804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Debug|AnyCPU.Build.0 = Debug|x64
- {804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Debug|AnyCPU.Deploy.0 = Debug|x64
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Debug|ARM64.ActiveCfg = Debug|ARM64
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Debug|ARM64.Build.0 = Debug|ARM64
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Debug|ARM64.Deploy.0 = Debug|ARM64
@@ -345,9 +303,6 @@ Global
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|Any CPU.ActiveCfg = Release|x64
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|Any CPU.Build.0 = Release|x64
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|Any CPU.Deploy.0 = Release|x64
- {804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|AnyCPU.ActiveCfg = Release|x64
- {804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|AnyCPU.Build.0 = Release|x64
- {804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|AnyCPU.Deploy.0 = Release|x64
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|ARM64.ActiveCfg = Release|ARM64
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|ARM64.Build.0 = Release|ARM64
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|ARM64.Deploy.0 = Release|ARM64
@@ -359,8 +314,6 @@ Global
{804DBC7B-FBF4-4B2E-AAE9-D74C32985D3F}.Release|x86.Deploy.0 = Release|x86
{12A1461D-3357-4007-BE15-9622E9513D09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12A1461D-3357-4007-BE15-9622E9513D09}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {12A1461D-3357-4007-BE15-9622E9513D09}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {12A1461D-3357-4007-BE15-9622E9513D09}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{12A1461D-3357-4007-BE15-9622E9513D09}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{12A1461D-3357-4007-BE15-9622E9513D09}.Debug|ARM64.Build.0 = Debug|Any CPU
{12A1461D-3357-4007-BE15-9622E9513D09}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -369,8 +322,6 @@ Global
{12A1461D-3357-4007-BE15-9622E9513D09}.Debug|x86.Build.0 = Debug|Any CPU
{12A1461D-3357-4007-BE15-9622E9513D09}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12A1461D-3357-4007-BE15-9622E9513D09}.Release|Any CPU.Build.0 = Release|Any CPU
- {12A1461D-3357-4007-BE15-9622E9513D09}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {12A1461D-3357-4007-BE15-9622E9513D09}.Release|AnyCPU.Build.0 = Release|Any CPU
{12A1461D-3357-4007-BE15-9622E9513D09}.Release|ARM64.ActiveCfg = Release|Any CPU
{12A1461D-3357-4007-BE15-9622E9513D09}.Release|ARM64.Build.0 = Release|Any CPU
{12A1461D-3357-4007-BE15-9622E9513D09}.Release|x64.ActiveCfg = Release|Any CPU
@@ -379,8 +330,6 @@ Global
{12A1461D-3357-4007-BE15-9622E9513D09}.Release|x86.Build.0 = Release|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
- {DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Debug|ARM64.Build.0 = Debug|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -389,8 +338,6 @@ Global
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Debug|x86.Build.0 = Debug|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Release|Any CPU.Build.0 = Release|Any CPU
- {DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Release|AnyCPU.ActiveCfg = Release|Any CPU
- {DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Release|AnyCPU.Build.0 = Release|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Release|ARM64.ActiveCfg = Release|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Release|ARM64.Build.0 = Release|Any CPU
{DB6B033B-584E-43CF-AC96-4F6548C96ECA}.Release|x64.ActiveCfg = Release|Any CPU
diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index 5d3d20e20..d44b8579b 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -8,8 +8,8 @@
<DotNetVersion>7.0.0</DotNetVersion>
<MicrosoftFastComponentsFluentUIVersion>2.0.1</MicrosoftFastComponentsFluentUIVersion>
<MicrosoftNETCoreUniversalWindowsPlatformVersion>6.2.14</MicrosoftNETCoreUniversalWindowsPlatformVersion>
- <MicrosoftWindowsSDKBuildToolsVersion>10.0.22621.1</MicrosoftWindowsSDKBuildToolsVersion>
- <UnoVersion>4.7.30</UnoVersion>
+ <MicrosoftWindowsSDKBuildToolsVersion>10.0.22621.755</MicrosoftWindowsSDKBuildToolsVersion>
+ <UnoVersion>4.7.37</UnoVersion>
<UnoWasmBootstrapVersion>8.0.0-dev.65</UnoWasmBootstrapVersion>
<WebView2Version>1.0.1462.37</WebView2Version>
<MicrosoftTypeScriptMSBuildVersion>4.9.4</MicrosoftTypeScriptMSBuildVersion>
diff --git a/src/app/dev/DevToys.Api/Core/IFileStorage.cs b/src/app/dev/DevToys.Api/Core/IFileStorage.cs
new file mode 100644
index 000000000..b6ba02ce9
--- /dev/null
+++ b/src/app/dev/DevToys.Api/Core/IFileStorage.cs
@@ -0,0 +1,45 @@
+namespace DevToys.Api.Core;
+
+/// <summary>
+/// Provides a platform agnostic way to interact with the file system of the operating system the app is running on.
+/// </summary>
+public interface IFileStorage
+{
+ /// <summary>
+ /// Gets application's directory to store cache data.
+ /// Cache data can be used for any data that needs to persist longer than temporary data, but shouldn't be data that is
+ /// required to operate the app, as the operating system may clear this storage.
+ /// </summary>
+ string AppCacheDirectory { get; }
+
+ /// <summary>
+ /// Prompt the user to select a location to save a file, and decide of the file name.
+ /// </summary>
+ /// <param name="fileTypes">The list of file types the user can choose. For example, ".txt". Use "*" for any file type.</param>
+ /// <returns>If succeeded, returns the file path selected by the user, otherwise, returns null.</returns>
+ ValueTask<string?> PickSaveFileAsync(string[] fileTypes);
+
+ /// <summary>
+ /// Determines whether the file indicated by the given <paramref name="relativeOrAbsoluteFilePath"/> exists.
+ /// </summary>
+ /// <param name="relativeOrAbsoluteFilePath">The path to the file to check.</param>
+ /// <returns>Returns true if the file exist</returns>
+ bool FileExists(string relativeOrAbsoluteFilePath);
+
+ /// <summary>
+ /// Tries to open the given <paramref name="relativeOrAbsoluteFilePath"/> with read access rights.
+ /// If a relative path is indicated, use the <see cref="AppCacheDirectory"/> as working directory.
+ /// </summary>
+ /// <param name="relativeOrAbsoluteFilePath">The path to the file to read.</param>
+ /// <returns>Returns a read-only stream if the file exist and can be read, otherwise, raise an exception.</returns>
+ Stream OpenReadFile(string relativeOrAbsoluteFilePath);
+
+ /// <summary>
+ /// Tries to open the given <paramref name="relativeOrAbsoluteFilePath"/> with write access rights. The file will be created if it doesn't exist.
+ /// If a relative path is indicated, use the <see cref="AppCacheDirectory"/> as working directory.
+ /// </summary>
+ /// <param name="relativeOrAbsoluteFilePath">The path to the file to write.</param>
+ /// <param name="replaceIfExist">If true and that the file indicated by <paramref name="relativeOrAbsoluteFilePath"/> already exist, overwrite it. Otherwise, open it without replacing it.</param>
+ /// <returns>Returns a write-only stream.</returns>
+ Stream OpenWriteFile(string relativeOrAbsoluteFilePath, bool replaceIfExist);
+}
diff --git a/src/app/dev/DevToys.Api/Settings/SettingDefinition.cs b/src/app/dev/DevToys.Api/Settings/SettingDefinition.cs
index b65a41572..54647a61c 100644
--- a/src/app/dev/DevToys.Api/Settings/SettingDefinition.cs
+++ b/src/app/dev/DevToys.Api/Settings/SettingDefinition.cs
@@ -23,14 +23,22 @@ public readonly struct SettingDefinition<T> : IEquatable<SettingDefinition<T>>
/// <param name="name">The name of the setting. Should be unique.</param>
/// <param name="isRoaming">Defines whether the setting can be synchronized with the user's Microsoft account.</param>
/// <param name="defaultValue">The default value of the setting.</param>
- public SettingDefinition(string name, bool isRoaming, T defaultValue)
+ public SettingDefinition(string name, T defaultValue)
{
- if (string.IsNullOrEmpty(name) || name.Length > 255)
+ Guard.IsNotNullOrWhiteSpace(name);
+
+ if (name.Length > 255)
{
// For both LocalSettings and RoamingSettings on Windows, the name of each setting
// can be 255 characters in length at most.
// see https://docs.microsoft.com/en-us/uwp/api/windows.storage.applicationdata.localsettings?view=winrt-22000#remarks
- throw new ArgumentOutOfRangeException(nameof(name));
+ ThrowHelper.ThrowArgumentOutOfRangeException(nameof(name), "Setting name is limited to 255 characters.");
+ }
+ else if (name.Contains("="))
+ {
+ // For portable apps, settings are stored in a .ini file where the format is "setting_name=value".
+ // Therefore, the setting name shouldn't contain "=".
+ ThrowHelper.ThrowArgumentException(nameof(name), "Setting name cannot contain '='.");
}
Name = name;
diff --git a/src/app/dev/DevToys.Core/DevToys.Core.csproj b/src/app/dev/DevToys.Core/DevToys.Core.csproj
index 8c1f08c3f..2d8eabb79 100644
--- a/src/app/dev/DevToys.Core/DevToys.Core.csproj
+++ b/src/app/dev/DevToys.Core/DevToys.Core.csproj
@@ -11,5 +11,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.ComponentModel.Composition" />
+ <PackageReference Include="Uno.Core.Extensions.Logging" />
+ <PackageReference Include="Uno.Core.Extensions.Logging.Singleton" />
</ItemGroup>
</Project>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Core/Logging/FileLogger.cs b/src/app/dev/DevToys.Core/Logging/FileLogger.cs
new file mode 100644
index 000000000..faaa70d81
--- /dev/null
+++ b/src/app/dev/DevToys.Core/Logging/FileLogger.cs
@@ -0,0 +1,69 @@
+using System.Text;
+using Microsoft.Extensions.Logging;
+
+namespace DevToys.Core.Logging;
+
+internal sealed class FileLogger : ILogger
+{
+ private readonly string _logName;
+ private readonly FileLoggerProvider _fileLoggerProvider;
+
+ internal FileLogger(string logName, FileLoggerProvider fileLoggerProvider)
+ {
+ Guard.IsNotNull(logName);
+ Guard.IsNotNull(fileLoggerProvider);
+ _logName = logName;
+ _fileLoggerProvider = fileLoggerProvider;
+ }
+
+ public IDisposable? BeginScope<TState>(TState state) where TState : notnull
+ {
+ return null;
+ }
+
+ public bool IsEnabled(LogLevel logLevel)
+ {
+ return true;
+ }
+
+ public void Log<TState>(
+ LogLevel logLevel,
+ EventId eventId,
+ TState state,
+ Exception? exception,
+ Func<TState, Exception?, string> formatter)
+ {
+ if (formatter is null)
+ {
+ ThrowHelper.ThrowArgumentNullException(nameof(formatter));
+ }
+
+ string message = formatter(state, exception);
+
+ var logBuilder = new StringBuilder();
+ if (!string.IsNullOrEmpty(message))
+ {
+ DateTime timeStamp = DateTime.Now;
+ logBuilder.Append(timeStamp.ToString("o"));
+ logBuilder.Append('\t');
+ logBuilder.Append(logLevel.ToString());
+ logBuilder.Append("\t[");
+ logBuilder.Append(_logName);
+ logBuilder.Append("]");
+ logBuilder.Append("\t[");
+ logBuilder.Append(eventId);
+ logBuilder.Append("]\t");
+ logBuilder.Append(message);
+ }
+
+ if (exception != null)
+ {
+ // exception message
+ logBuilder.AppendLine();
+ logBuilder.AppendLine(exception.Message);
+ logBuilder.AppendLine(exception.ToString());
+ }
+
+ _fileLoggerProvider.WriteEntry(logBuilder.ToString());
+ }
+}
diff --git a/src/app/dev/DevToys.Core/Logging/FileLoggerProvider.cs b/src/app/dev/DevToys.Core/Logging/FileLoggerProvider.cs
new file mode 100644
index 000000000..1afb58e24
--- /dev/null
+++ b/src/app/dev/DevToys.Core/Logging/FileLoggerProvider.cs
@@ -0,0 +1,109 @@
+using System.Collections.Concurrent;
+using DevToys.Api.Core;
+using DevToys.Api.Core.Threading;
+using Microsoft.Extensions.Logging;
+
+namespace DevToys.Core.Logging;
+
+[ProviderAlias("File")]
+internal sealed class FileLoggerProvider : ILoggerProvider
+{
+ private readonly ConcurrentDictionary<string, FileLogger> _loggers = new();
+ private readonly BlockingCollection<string> _entryQueue = new(1024);
+ private readonly Task _processQueueTask;
+ private readonly IFileStorage _fileStorage;
+ private readonly Lazy<TextWriter> _textWriter;
+ private readonly Lazy<Stream> _fileStream;
+
+ internal FileLoggerProvider(IFileStorage fileStorage)
+ {
+ Guard.IsNotNull(fileStorage);
+ _fileStorage = fileStorage;
+
+ // TODO: Delete older log files?
+
+ string logFileName = $"log-{DateTime.Now.ToString("s").Replace(":", string.Empty).Replace("-", string.Empty)}.txt";
+ _fileStream = new(() => _fileStorage.OpenWriteFile(logFileName, replaceIfExist: true));
+ _textWriter = new(() => new StreamWriter(_fileStream.Value));
+
+ _processQueueTask
+ = Task.Factory.StartNew(
+ ProcessQueue,
+ this,
+ TaskCreationOptions.LongRunning);
+ }
+
+ public ILogger CreateLogger(string categoryName)
+ {
+ return _loggers.GetOrAdd(categoryName, new FileLogger(categoryName, this));
+ }
+
+ public void Dispose()
+ {
+ _entryQueue.CompleteAdding();
+ try
+ {
+ _processQueueTask.Wait(1500); // the same as in ConsoleLogger
+ }
+ catch (TaskCanceledException) { }
+ catch (AggregateException ex) when (ex.InnerExceptions.Count == 1 && ex.InnerExceptions[0] is TaskCanceledException) { }
+
+ _textWriter.Value.Dispose();
+ _fileStream.Value.Dispose();
+ }
+
+ internal void WriteEntry(string message)
+ {
+ if (!_entryQueue.IsAddingCompleted)
+ {
+ try
+ {
+ _entryQueue.Add(message);
+ return;
+ }
+ catch (InvalidOperationException) { }
+ }
+
+ // do nothing
+ }
+
+ private static void ProcessQueue(object? state)
+ {
+ Guard.IsNotNull(state);
+ Guard.IsOfType<FileLoggerProvider>(state);
+ var fileLogger = (FileLoggerProvider)state;
+ fileLogger.ProcessQueue();
+ }
+
+ private void ProcessQueue()
+ {
+ TextWriter textWriter;
+ try
+ {
+ textWriter = _textWriter.Value;
+ foreach (string message in _entryQueue.GetConsumingEnumerable())
+ {
+ WriteMessage(textWriter, message, _entryQueue.Count == 0);
+ }
+ }
+ catch
+ {
+#if DEBUG
+ System.Diagnostics.Debugger.Launch();
+#endif
+ }
+ }
+
+ private static void WriteMessage(TextWriter textWriter, string message, bool flush)
+ {
+ textWriter.WriteLine(message);
+ if (flush)
+ {
+ try
+ {
+ textWriter.Flush();
+ }
+ catch (NotSupportedException) { } // May not work in WASM.
+ }
+ }
+}
diff --git a/src/app/dev/DevToys.Core/Logging/LoggingBuilderExtensions.cs b/src/app/dev/DevToys.Core/Logging/LoggingBuilderExtensions.cs
new file mode 100644
index 000000000..1d0c0b88c
--- /dev/null
+++ b/src/app/dev/DevToys.Core/Logging/LoggingBuilderExtensions.cs
@@ -0,0 +1,22 @@
+using DevToys.Api.Core;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+
+namespace DevToys.Core.Logging;
+
+public static class LoggingBuilderExtensions
+{
+ /// <summary>
+ /// Adds a file logger.
+ /// </summary>
+ public static ILoggingBuilder AddFile(this ILoggingBuilder builder, IFileStorage fileStorage)
+ {
+ builder.Services.Add(ServiceDescriptor.Singleton<ILoggerProvider, FileLoggerProvider>(
+ (srvPrv) =>
+ {
+ return new FileLoggerProvider(fileStorage);
+ }
+ ));
+ return builder;
+ }
+}
diff --git a/src/app/dev/DevToys.Core/Mef/MefComposer.cs b/src/app/dev/DevToys.Core/Mef/MefComposer.cs
index e415f16b2..50a5bfc50 100644
--- a/src/app/dev/DevToys.Core/Mef/MefComposer.cs
+++ b/src/app/dev/DevToys.Core/Mef/MefComposer.cs
@@ -1,6 +1,8 @@
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
using DevToys.Api;
+using Microsoft.Extensions.Logging;
+using Uno.Extensions;
namespace DevToys.Core.Mef;
@@ -9,6 +11,7 @@ namespace DevToys.Core.Mef;
/// </summary>
public sealed class MefComposer : IDisposable
{
+ private readonly ILogger _logger;
private readonly Assembly[] _assemblies;
private readonly object[] _customExports;
private bool _isExportProviderDisposed = true;
@@ -24,6 +27,8 @@ public sealed class MefComposer : IDisposable
throw new InvalidOperationException("Mef composer already initialized.");
}
+ _logger = this.Log();
+
_assemblies = assemblies ?? Array.Empty<Assembly>();
_customExports = customExports ?? Array.Empty<object>();
ExportProvider = InitializeMef();
@@ -72,13 +77,14 @@ public sealed class MefComposer : IDisposable
// try to discover MEF extensions in them.
foreach (string pluginFolder in GetPotentialPluginFolders())
{
+ _logger.LogInformation($"Discovering plugin in '{pluginFolder}'...");
try
{
catalog.Catalogs.Add(new RecursiveDirectoryCatalog(pluginFolder));
}
- catch
+ catch (Exception ex)
{
- // TODO: Log this. We maybe failed to load a plugin.
+ _logger.LogError(ex, $"Unable to load plugin in '{pluginFolder}'...");
}
}
@@ -93,6 +99,7 @@ public sealed class MefComposer : IDisposable
}
container.Compose(batch);
+ _logger.LogInformation($"MEF composed.");
ExportProvider = container;
diff --git a/src/app/dev/DevToys.Core/Mef/RecursiveDirectoryCatalog.cs b/src/app/dev/DevToys.Core/Mef/RecursiveDirectoryCatalog.cs
index 3eb3c2a6d..f50369d5a 100644
--- a/src/app/dev/DevToys.Core/Mef/RecursiveDirectoryCatalog.cs
+++ b/src/app/dev/DevToys.Core/Mef/RecursiveDirectoryCatalog.cs
@@ -2,6 +2,7 @@
using System.ComponentModel.Composition.Primitives;
using System.Globalization;
using System.IO;
+using System.Reflection;
namespace DevToys.Core.Mef;
@@ -49,11 +50,11 @@ internal sealed class RecursiveDirectoryCatalog : ComposablePartCatalog, INotify
private void Initialize(string path, string searchPattern)
{
- IEnumerable<DirectoryCatalog> directoryCatalogs
- = GetFoldersRecursive(path)
- .Select(dir => new DirectoryCatalog(dir, searchPattern));
+ IEnumerable<string> files
+ = Directory.EnumerateFiles(path, searchPattern, SearchOption.AllDirectories);
_aggregateCatalog = new AggregateCatalog();
+
_aggregateCatalog.Changed += (o, e) =>
{
Changed?.Invoke(o, e);
@@ -64,9 +65,25 @@ internal sealed class RecursiveDirectoryCatalog : ComposablePartCatalog, INotify
Changing?.Invoke(o, e);
};
- foreach (DirectoryCatalog catalog in directoryCatalogs)
+ foreach (string file in files)
{
- _aggregateCatalog.Catalogs.Add(catalog);
+ try
+ {
+ var asmCat = new AssemblyCatalog(file);
+
+ // Force MEF to load the plugin and figure out if there are any exports
+ // good assemblies will not throw the RTLE exception and can be added to the catalog
+ if (asmCat.Parts.ToList().Count > 0)
+ {
+ _aggregateCatalog.Catalogs.Add(asmCat);
+ }
+ }
+ catch (ReflectionTypeLoadException)
+ {
+ }
+ catch (BadImageFormatException)
+ {
+ }
}
}
diff --git a/src/app/dev/DevToys.Core/Settings/PredefinedSettings.cs b/src/app/dev/DevToys.Core/Settings/PredefinedSettings.cs
index 397843613..d1bcdde8d 100644
--- a/src/app/dev/DevToys.Core/Settings/PredefinedSettings.cs
+++ b/src/app/dev/DevToys.Core/Settings/PredefinedSettings.cs
@@ -11,7 +11,6 @@ public static class PredefinedSettings
public static readonly SettingDefinition<string> Language
= new(
name: nameof(Language),
- isRoaming: false,
defaultValue: "default");
/// <summary>
@@ -20,6 +19,5 @@ public static class PredefinedSettings
public static readonly SettingDefinition<AvailableApplicationTheme> Theme
= new(
name: nameof(Theme),
- isRoaming: false,
defaultValue: AvailableApplicationTheme.Default);
}
diff --git a/src/app/dev/DevToys.Localization/DevToys.Localization.csproj b/src/app/dev/DevToys.Localization/DevToys.Localization.csproj
index aa010c109..c4af19f99 100644
--- a/src/app/dev/DevToys.Localization/DevToys.Localization.csproj
+++ b/src/app/dev/DevToys.Localization/DevToys.Localization.csproj
@@ -9,9 +9,6 @@
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.ComponentModel.Composition" />
</ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\generators\ResxHelperGenerator\ResxHelperGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
- </ItemGroup>
<ItemGroup>
<Compile Update="Strings\MainWindow\MainWindow.Designer.cs">
<DesignTime>True</DesignTime>
@@ -34,5 +31,10 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
-
+ <ItemGroup>
+ <AdditionalFiles Include="**\*.resx" />
+ </ItemGroup>
+ <ItemGroup>
+ <Analyzer Include="$(RepoRoot)src\generators\ResxHelperGenerator\bin\netstandard2.0\ResxHelperGenerator.dll" />
+ </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.MonacoEditor/DevToys.MonacoEditor.csproj b/src/app/dev/DevToys.MonacoEditor/DevToys.MonacoEditor.csproj
index a5c554a50..003e592d1 100644
--- a/src/app/dev/DevToys.MonacoEditor/DevToys.MonacoEditor.csproj
+++ b/src/app/dev/DevToys.MonacoEditor/DevToys.MonacoEditor.csproj
@@ -74,9 +74,6 @@
</Content>
<ConfigFiles Include="ts-helpermethods\ts-helpermethods-Wasm\tsconfig.json" />
<None Include="highlightjs\**" />
- <EmbeddedResource Include="LinkerConfig.xml">
- <LogicalName>$(AssemblyName).xml</LogicalName>
- </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WasmScripts\WASM\uno-monaco-helpers.g.js" />
diff --git a/src/app/dev/DevToys.MonacoEditor/LinkerConfig.xml b/src/app/dev/DevToys.MonacoEditor/LinkerConfig.xml
deleted file mode 100644
index 7a7ef3d14..000000000
--- a/src/app/dev/DevToys.MonacoEditor/LinkerConfig.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<linker>
- <assembly fullname="Uno.UI" />
- <assembly fullname="Microsoft.Extensions.Options" />
-
- <assembly fullname="DevToys.MonacoEditor">
- <type fullname="DevToys.MonacoEditor*" />
- </assembly>
-
- <assembly fullname="System.Core">
- <!-- This is required by JSon.NET and any expression.Compile caller -->
- <type fullname="System.Linq.Expressions*" />
- </assembly>
-</linker>
diff --git a/src/app/dev/DevToys.UI.Framework/Controls/BackdropPage.cs b/src/app/dev/DevToys.UI.Framework/Controls/BackdropPage.cs
index a04808c41..2e1aab3ca 100644
--- a/src/app/dev/DevToys.UI.Framework/Controls/BackdropPage.cs
+++ b/src/app/dev/DevToys.UI.Framework/Controls/BackdropPage.cs
@@ -68,6 +68,11 @@ public abstract partial class BackdropPage : Page
/// </summary>
public event TypedEventHandler<BackdropWindow, EventArgs>? Closing;
+ /// <summary>
+ /// Raised when the window is closing.
+ /// </summary>
+ public event TypedEventHandler<BackdropWindow, EventArgs>? Closed;
+
/// <summary>
/// Raised when the window got activated.
/// </summary>
@@ -121,6 +126,8 @@ public abstract partial class BackdropPage : Page
Window.Closing -= Window_Closing;
Window.Shown -= Window_Shown;
_themeListener.ThemeChanged -= ThemeListener_ThemeChanged;
+
+ Closed?.Invoke(Window, EventArgs.Empty);
}
#if HAS_UNO
diff --git a/src/app/dev/Directory.Build.props b/src/app/dev/Directory.Build.props
index 502c0e557..045b49a8c 100644
--- a/src/app/dev/Directory.Build.props
+++ b/src/app/dev/Directory.Build.props
@@ -14,13 +14,24 @@
<!-- https://github.com/dotnet/project-system/blob/main/docs/build-acceleration.md -->
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
+
+ <EnableTrimAnalyzer>true</EnableTrimAnalyzer>
+
+ <NoWarm>$(NoWarm);IL2007;IL2091;IL2077;IL2055;IL2075</NoWarm>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<Optimize>true</Optimize>
+
+ <!-- Trimming settings -->
+ <!-- https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?source=recommendations&pivots=dotnet-7-0 -->
+ <TrimMode>partial</TrimMode>
</PropertyGroup>
<ItemGroup>
+ <TrimmerRootDescriptor Include="$(RepoRoot)\src\app\dev\shared\LinkerConfig.xml" Link="Properties\$(MSBuildProjectName).xml">
+ <LogicalName>$(MSBuildProjectName).xml</LogicalName>
+ </TrimmerRootDescriptor>
<Compile Include="$(RepoRoot)\src\app\dev\shared\GlobalUsings.cs" Link="Properties\GlobalUsings.cs" />
<Compile Include="$(RepoRoot)\src\app\dev\shared\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
<Compile Include="$(RepoRoot)\src\app\dev\shared\SharedAssemblyVersion.cs" Link="Properties\SharedAssemblyVersion.cs" />
diff --git a/src/app/dev/platforms/desktop/DevToys.CLI/Core/FileStorage/FileStorage.cs b/src/app/dev/platforms/desktop/DevToys.CLI/Core/FileStorage/FileStorage.cs
new file mode 100644
index 000000000..2341cb428
--- /dev/null
+++ b/src/app/dev/platforms/desktop/DevToys.CLI/Core/FileStorage/FileStorage.cs
@@ -0,0 +1,67 @@
+using DevToys.Api.Core;
+
+namespace DevToys.CLI.Core.FileStorage;
+
+[Export(typeof(IFileStorage))]
+internal sealed class FileStorage : IFileStorage
+{
+ [ImportingConstructor]
+ internal FileStorage()
+ {
+ AppCacheDirectory = Path.Combine(AppContext.BaseDirectory, "Cache");
+ }
+
+ public string AppCacheDirectory { get; }
+
+ public bool FileExists(string relativeOrAbsoluteFilePath)
+ {
+ if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
+ {
+ relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
+ }
+
+ return File.Exists(relativeOrAbsoluteFilePath);
+ }
+
+ public Stream OpenReadFile(string relativeOrAbsoluteFilePath)
+ {
+ if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
+ {
+ relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
+ }
+
+ if (!File.Exists(relativeOrAbsoluteFilePath))
+ {
+ throw new FileNotFoundException("Unable to find the indicated file.", relativeOrAbsoluteFilePath);
+ }
+
+ return File.OpenRead(relativeOrAbsoluteFilePath);
+ }
+
+ public Stream OpenWriteFile(string relativeOrAbsoluteFilePath, bool replaceIfExist)
+ {
+ if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
+ {
+ relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
+ }
+
+ if (File.Exists(relativeOrAbsoluteFilePath) && replaceIfExist)
+ {
+ File.Delete(relativeOrAbsoluteFilePath);
+ }
+
+ string parentDirectory = Path.GetDirectoryName(relativeOrAbsoluteFilePath)!;
+ if (!Directory.Exists(parentDirectory))
+ {
+ Directory.CreateDirectory(parentDirectory);
+ }
+
+ return File.OpenWrite(relativeOrAbsoluteFilePath);
+ }
+
+ public ValueTask<string?> PickSaveFileAsync(string[] fileTypes)
+ {
+ // TODO: prompt the user to type in the console a relative or absolute file path that has one of the file types indicated.
+ throw new NotImplementedException();
+ }
+}
diff --git a/src/app/dev/platforms/desktop/DevToys.CLI/Core/Settings/SettingsStorage.cs b/src/app/dev/platforms/desktop/DevToys.CLI/Core/Settings/SettingsStorage.cs
index dc4695b20..e889c5cca 100644
--- a/src/app/dev/platforms/desktop/DevToys.CLI/Core/Settings/SettingsStorage.cs
+++ b/src/app/dev/platforms/desktop/DevToys.CLI/Core/Settings/SettingsStorage.cs
@@ -1,22 +1,94 @@
-using DevToys.Core.Settings;
+using DevToys.Api.Core;
+using DevToys.Api;
+using System.Collections.Concurrent;
+using DevToys.Core.Settings;
namespace DevToys.CLI.Core.Settings;
[Export(typeof(ISettingsStorage))]
internal sealed class SettingsStorage : ISettingsStorage
{
+ private const string SettingsFileName = "settings.ini";
+
+ private readonly IFileStorage _fileStorage;
+ private readonly Lazy<ConcurrentDictionary<string, string>> _settings;
+
+ [ImportingConstructor]
+ public SettingsStorage(IFileStorage fileStorage)
+ {
+ _fileStorage = fileStorage;
+
+ _settings
+ = new Lazy<ConcurrentDictionary<string, string>>(
+ LoadAllSettings());
+ }
+
public void ResetSetting(string settingName)
{
- throw new NotImplementedException();
+ _settings.Value.Remove(settingName, out string _);
}
public bool TryReadSetting(string settingName, out object? value)
{
- throw new NotImplementedException();
+ if (_settings.Value.ContainsKey(settingName))
+ {
+ value = _settings.Value[settingName];
+ return true;
+ }
+
+ value = null;
+ return false;
}
public void WriteSetting(string settingName, object? value)
{
- throw new NotImplementedException();
+ _settings.Value[settingName] = value?.ToString() ?? string.Empty;
+ SaveAllSettingsAsync().Forget();
+ }
+
+ private ConcurrentDictionary<string, string> LoadAllSettings()
+ {
+ var result = new ConcurrentDictionary<string, string>();
+
+ if (_fileStorage.FileExists(SettingsFileName))
+ {
+ using Stream stream = _fileStorage.OpenReadFile(SettingsFileName);
+ using TextReader textReader = new StreamReader(stream);
+
+ string? line = null;
+ do
+ {
+ line = textReader.ReadLine();
+ if (!string.IsNullOrWhiteSpace(line))
+ {
+ int equalSign = line.IndexOf('=');
+ if (equalSign > 0)
+ {
+ string settingName = line.Substring(0, equalSign);
+ string settingValue = line.Substring(equalSign + 1);
+ result[settingName] = settingValue;
+ }
+ }
+ } while (line != null);
+ }
+
+ return result;
+ }
+
+ private Task SaveAllSettingsAsync()
+ {
+ return Task.Run(() =>
+ {
+ lock (_fileStorage)
+ {
+ using Stream stream = _fileStorage.OpenWriteFile(SettingsFileName, replaceIfExist: true);
+ using TextWriter textWriter = new StreamWriter(stream);
+
+ foreach (KeyValuePair<string, string> item in _settings.Value)
+ {
+ textWriter.WriteLine($"{item.Key}={item.Value}");
+ }
+ }
+ });
}
}
diff --git a/src/app/dev/platforms/desktop/DevToys.CLI/Program.cs b/src/app/dev/platforms/desktop/DevToys.CLI/Program.cs
index 62165999a..e99b25ed4 100644
--- a/src/app/dev/platforms/desktop/DevToys.CLI/Program.cs
+++ b/src/app/dev/platforms/desktop/DevToys.CLI/Program.cs
@@ -1,11 +1,13 @@
using System.CommandLine;
using System.CommandLine.Invocation;
-using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using DevToys.Api;
+using DevToys.CLI.Core.FileStorage;
+using DevToys.Core.Logging;
using DevToys.Core.Mef;
using Microsoft.Extensions.Logging;
+using Uno.Extensions;
namespace DevToys.CLI;
@@ -21,9 +23,19 @@ internal class Program
builder
.AddFilter("Microsoft", LogLevel.Warning)
.AddFilter("System", LogLevel.Warning)
- .AddFilter("DevToys", LogLevel.Debug)
+ .AddFile(new FileStorage()) // To save logs on local hard drive.
.AddDebug();
+
+ // Exclude logs below this level
+#if DEBUG
+ builder.SetMinimumLevel(LogLevel.Trace);
+#else
+ builder.SetMinimumLevel(LogLevel.Information);
+#endif
});
+
+ global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = loggerFactory;
+ loggerFactory.Log().LogInformation("App is starting...");
}
private static void Main(string[] args)
@@ -35,6 +47,7 @@ internal class Program
MainAsync(args).GetAwaiter().GetResult();
+ loggerFactory.Log().LogInformation("App is shutting down...");
loggerFactory.Dispose();
}
@@ -96,7 +109,11 @@ internal class Program
// Invoke the command line tool.
ILogger logger = loggerFactory.CreateLogger(commandLineTool.Value.GetType());
+ logger.LogInformation($"Invoking '{command.CommandDefinition.Name}' command...");
+
int exitCode = await commandLineTool.Value.InvokeAsync(logger, context.GetCancellationToken());
+ logger.LogInformation($"Exit code: {exitCode}");
+
context.ExitCode = exitCode;
});
diff --git a/src/app/dev/platforms/desktop/DevToys.MauiBlazor/App.xaml.cs b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/App.xaml.cs
index 8ffe1afe8..7b66a653b 100644
--- a/src/app/dev/platforms/desktop/DevToys.MauiBlazor/App.xaml.cs
+++ b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/App.xaml.cs
@@ -9,7 +9,7 @@ public partial class App : Application
InitializeComponent();
// Apply the app color theme.
- MauiProgram.MefComposer.Provider.Import<IThemeListener>().ApplyDesiredColorTheme();
+ MauiProgram.MefComposer.Value.Provider.Import<IThemeListener>().ApplyDesiredColorTheme();
MainPage = new MainPage();
}
diff --git a/src/app/dev/platforms/desktop/DevToys.MauiBlazor/Core/FileStorage/FileStorage.cs b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/Core/FileStorage/FileStorage.cs
new file mode 100644
index 000000000..0c06e182c
--- /dev/null
+++ b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/Core/FileStorage/FileStorage.cs
@@ -0,0 +1,61 @@
+using DevToys.Api.Core;
+
+namespace DevToys.MauiBlazor.Core.FileStorage;
+
+[Export(typeof(IFileStorage))]
+internal sealed class FileStorage : IFileStorage
+{
+ public string AppCacheDirectory => FileSystem.CacheDirectory;
+
+ public bool FileExists(string relativeOrAbsoluteFilePath)
+ {
+ if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
+ {
+ relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
+ }
+
+ return File.Exists(relativeOrAbsoluteFilePath);
+ }
+
+ public Stream OpenReadFile(string relativeOrAbsoluteFilePath)
+ {
+ if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
+ {
+ relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
+ }
+
+ if (!File.Exists(relativeOrAbsoluteFilePath))
+ {
+ throw new FileNotFoundException("Unable to find the indicated file.", relativeOrAbsoluteFilePath);
+ }
+
+ return File.OpenRead(relativeOrAbsoluteFilePath);
+ }
+
+ public Stream OpenWriteFile(string relativeOrAbsoluteFilePath, bool replaceIfExist)
+ {
+ if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
+ {
+ relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
+ }
+
+ if (File.Exists(relativeOrAbsoluteFilePath) && replaceIfExist)
+ {
+ File.Delete(relativeOrAbsoluteFilePath);
+ }
+
+ string parentDirectory = Path.GetDirectoryName(relativeOrAbsoluteFilePath)!;
+ if (!Directory.Exists(parentDirectory))
+ {
+ Directory.CreateDirectory(parentDirectory);
+ }
+
+ return File.OpenWrite(relativeOrAbsoluteFilePath);
+ }
+
+ public ValueTask<string?> PickSaveFileAsync(string[] fileTypes)
+ {
+ // TODO
+ throw new NotImplementedException();
+ }
+}
diff --git a/src/app/dev/platforms/desktop/DevToys.MauiBlazor/MauiProgram.cs b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/MauiProgram.cs
index 7d95ae8de..6fa61a7a4 100644
--- a/src/app/dev/platforms/desktop/DevToys.MauiBlazor/MauiProgram.cs
+++ b/src/app/dev/platforms/desktop/DevToys.MauiBlazor/MauiProgram.cs
@@ -1,16 +1,19 @@
using DevToys.Api;
+using DevToys.Core.Logging;
using DevToys.Core.Mef;
using DevToys.Core.Settings;
+using DevToys.MauiBlazor.Core.FileStorage;
using DevToys.MauiBlazor.Core.Languages;
using Microsoft.Extensions.Logging;
using Microsoft.Fast.Components.FluentUI;
using Microsoft.Fast.Components.FluentUI.Infrastructure;
+using Uno.Extensions;
namespace DevToys.MauiBlazor;
public static class MauiProgram
{
- internal static readonly MefComposer MefComposer = new();
+ internal static readonly Lazy<MefComposer> MefComposer = new(() => new MefComposer());
public static MauiApp CreateMauiApp()
{
@@ -32,15 +35,26 @@ public static class MauiProgram
builder.Logging.AddDebug();
#endif
- builder.Services.AddSingleton(provider => MefComposer.Provider);
+ builder.Logging.AddFilter("Microsoft", LogLevel.Warning);
+ builder.Logging.AddFilter("System", LogLevel.Warning);
+ builder.Logging.AddFile(new FileStorage());
+
+ builder.Services.AddSingleton(provider => MefComposer.Value.Provider);
+
+ MauiApp app = builder.Build();
+
+ ILoggerFactory loggerFactory = app.Services.GetRequiredService<ILoggerFactory>();
+ global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = loggerFactory;
+
+ app.Log().LogInformation("App is starting...");
// Set the user-defined language.
- string? languageIdentifier = MefComposer.Provider.Import<ISettingsProvider>().GetSetting(PredefinedSettings.Language);
+ string? languageIdentifier = MefComposer.Value.Provider.Import<ISettingsProvider>().GetSetting(PredefinedSettings.Language);
LanguageDefinition languageDefinition
= LanguageManager.Instance.AvailableLanguages.FirstOrDefault(l => string.Equals(l.InternalName, languageIdentifier))
?? LanguageManager.Instance.AvailableLanguages[0];
LanguageManager.Instance.SetCurrentCulture(languageDefinition);
- return builder.Build();
+ return app;
}
}
diff --git a/src/app/dev/platforms/desktop/Directory.Build.props b/src/app/dev/platforms/desktop/Directory.Build.props
new file mode 100644
index 000000000..a35f697b5
--- /dev/null
+++ b/src/app/dev/platforms/desktop/Directory.Build.props
@@ -0,0 +1,8 @@
+<Project>
+ <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
+
+ <!-- Include DevToys.Tools and other plugins to the output -->
+ <ItemGroup>
+ <Content Include="$(RepoRoot)bin\$(Configuration)\Plugins\**\*" Link="Plugins\%(RecursiveDir)%(Filename)%(Extension)" />
+ </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/src/app/dev/platforms/desktop/Directory.Build.targets b/src/app/dev/platforms/desktop/Directory.Build.targets
index 691c15182..087650400 100644
--- a/src/app/dev/platforms/desktop/Directory.Build.targets
+++ b/src/app/dev/platforms/desktop/Directory.Build.targets
@@ -1,28 +1,14 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
- <Target Name="ImportPluginAfterBuild" AfterTargets="Build">
+ <Target Name="ImportPluginOnPublish" BeforeTargets="Publish">
<Message Text="Importing plugins..." Importance="high" />
<ItemGroup>
<PluginOutput Include="$(RepoRoot)bin\$(Configuration)\Plugins\**\*" />
</ItemGroup>
<Copy
SourceFiles="@(PluginOutput)"
- DestinationFolder="$(OutputPath)\Plugins\%(RecursiveDir)"
- SkipUnchangedFiles="true"
- OverwriteReadOnlyFiles="true"
- Retries="10"
- RetryDelayMilliseconds="1000" />
- <Message Text="Plugins importanted!" Importance="high" />
- </Target>
- <Target Name="ImportPluginInAppxAfterBuild" BeforeTargets="_CalculateAppxBundleProperties">
- <Message Text="Importing plugins..." Importance="high" />
- <ItemGroup>
- <PluginOutput Include="$(RepoRoot)bin\$(Configuration)\Plugins\**\*" />
- </ItemGroup>
- <Copy
- SourceFiles="@(PluginOutput)"
- DestinationFolder="$(OutputPath)\Appx\Plugins\%(RecursiveDir)"
+ DestinationFolder="$(PublishDir)\Plugins\%(RecursiveDir)"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="true"
Retries="10"
diff --git a/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/FileStorage/FileStorage.cs b/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/FileStorage/FileStorage.cs
new file mode 100644
index 000000000..ca2e6b21b
--- /dev/null
+++ b/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/FileStorage/FileStorage.cs
@@ -0,0 +1,67 @@
+using System.IO;
+using DevToys.Api.Core;
+using Windows.Storage;
+
+namespace DevToys.Wasdk.Core.FileStorage;
+
+[Export(typeof(IFileStorage))]
+internal sealed class FileStorage : IFileStorage
+{
+#if MSIX_PACKAGED || __WASM__
+ public string AppCacheDirectory => ApplicationData.Current.LocalCacheFolder.Path;
+#else
+ public string AppCacheDirectory { get; } = Path.Combine(AppContext.BaseDirectory, "Cache");
+#endif
+
+ public bool FileExists(string relativeOrAbsoluteFilePath)
+ {
+ if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
+ {
+ relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
+ }
+
+ return File.Exists(relativeOrAbsoluteFilePath);
+ }
+
+ public Stream OpenReadFile(string relativeOrAbsoluteFilePath)
+ {
+ if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
+ {
+ relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
+ }
+
+ if (!File.Exists(relativeOrAbsoluteFilePath))
+ {
+ throw new FileNotFoundException("Unable to find the indicated file.", relativeOrAbsoluteFilePath);
+ }
+
+ return File.OpenRead(relativeOrAbsoluteFilePath);
+ }
+
+ public Stream OpenWriteFile(string relativeOrAbsoluteFilePath, bool replaceIfExist)
+ {
+ if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
+ {
+ relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
+ }
+
+ if (File.Exists(relativeOrAbsoluteFilePath) && replaceIfExist)
+ {
+ File.Delete(relativeOrAbsoluteFilePath);
+ }
+
+ string parentDirectory = Path.GetDirectoryName(relativeOrAbsoluteFilePath)!;
+ if (!Directory.Exists(parentDirectory))
+ {
+ Directory.CreateDirectory(parentDirectory);
+ }
+
+ return File.OpenWrite(relativeOrAbsoluteFilePath);
+ }
+
+ public ValueTask<string?> PickSaveFileAsync(string[] fileTypes)
+ {
+ // TODO: prompt the user to type in the console a relative or absolute file path that has one of the file types indicated.
+ throw new NotImplementedException();
+ }
+}
diff --git a/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/Settings/SettingsStorage.cs b/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/Settings/SettingsStorage.Packaged.cs
similarity index 91%
rename from src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/Settings/SettingsStorage.cs
rename to src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/Settings/SettingsStorage.Packaged.cs
index 918010f76..57e7a96f2 100644
--- a/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/Settings/SettingsStorage.cs
+++ b/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/Settings/SettingsStorage.Packaged.cs
@@ -1,4 +1,5 @@
-using DevToys.Core.Settings;
+#if MSIX_PACKAGED || __WASM__
+using DevToys.Core.Settings;
using Windows.Storage;
namespace DevToys.Wasdk.Core.Settings;
@@ -30,3 +31,4 @@ internal sealed class SettingsStorage : ISettingsStorage
_localSettings.Values[settingName] = value;
}
}
+#endif
diff --git a/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/Settings/SettingsStorage.Unpackaged.cs b/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/Settings/SettingsStorage.Unpackaged.cs
new file mode 100644
index 000000000..669fb9151
--- /dev/null
+++ b/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/Core/Settings/SettingsStorage.Unpackaged.cs
@@ -0,0 +1,96 @@
+#if !MSIX_PACKAGED && !__WASM__
+using System.Collections.Concurrent;
+using DevToys.Api;
+using DevToys.Api.Core;
+using DevToys.Core.Settings;
+
+namespace DevToys.Wasdk.Core.Settings;
+
+[Export(typeof(ISettingsStorage))]
+internal sealed class SettingsStorage : ISettingsStorage
+{
+ private const string SettingsFileName = "settings.ini";
+
+ private readonly IFileStorage _fileStorage;
+ private readonly Lazy<ConcurrentDictionary<string, string>> _settings;
+
+ [ImportingConstructor]
+ public SettingsStorage(IFileStorage fileStorage)
+ {
+ _fileStorage = fileStorage;
+
+ _settings
+ = new Lazy<ConcurrentDictionary<string, string>>(
+ LoadAllSettings());
+ }
+
+ public void ResetSetting(string settingName)
+ {
+ _settings.Value.Remove(settingName, out string _);
+ }
+
+ public bool TryReadSetting(string settingName, out object? value)
+ {
+ if (_settings.Value.ContainsKey(settingName))
+ {
+ value = _settings.Value[settingName];
+ return true;
+ }
+
+ value = null;
+ return false;
+ }
+
+ public void WriteSetting(string settingName, object? value)
+ {
+ _settings.Value[settingName] = value?.ToString() ?? string.Empty;
+ SaveAllSettingsAsync().Forget();
+ }
+
+ private ConcurrentDictionary<string, string> LoadAllSettings()
+ {
+ var result = new ConcurrentDictionary<string, string>();
+
+ if (_fileStorage.FileExists(SettingsFileName))
+ {
+ using Stream stream = _fileStorage.OpenReadFile(SettingsFileName);
+ using TextReader textReader = new StreamReader(stream);
+
+ string? line = null;
+ do
+ {
+ line = textReader.ReadLine();
+ if (!string.IsNullOrWhiteSpace(line))
+ {
+ int equalSign = line.IndexOf('=');
+ if (equalSign > 0)
+ {
+ string settingName = line.Substring(0, equalSign);
+ string settingValue = line.Substring(equalSign + 1);
+ result[settingName] = settingValue;
+ }
+ }
+ } while (line != null);
+ }
+
+ return result;
+ }
+
+ private Task SaveAllSettingsAsync()
+ {
+ return Task.Run(() =>
+ {
+ lock (_fileStorage)
+ {
+ using Stream stream = _fileStorage.OpenWriteFile(SettingsFileName, replaceIfExist: true);
+ using TextWriter textWriter = new StreamWriter(stream);
+
+ foreach (KeyValuePair<string, string> item in _settings.Value)
+ {
+ textWriter.WriteLine($"{item.Key}={item.Value}");
+ }
+ }
+ });
+ }
+}
+#endif
diff --git a/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/DevToys.Wasdk.csproj b/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/DevToys.Wasdk.csproj
index 7894ba3c1..db2b9171e 100644
--- a/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/DevToys.Wasdk.csproj
+++ b/src/app/dev/platforms/desktop/windows/DevToys.Wasdk/DevToys.Wasdk.csproj
@@ -28,6 +28,7 @@
<!-- Only for Packaged deployment -->
<PropertyGroup Condition="'$(Unpackaged)' != 'true'">
+ <DefineConstants>$(DefineConstants);MSIX_PACKAGED</DefineConstants>
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
<PublishAppxPackage>True</PublishAppxPackage>
<AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms>
diff --git a/src/app/dev/platforms/web/DevToys.Wasm/DevToys.Wasm.csproj b/src/app/dev/platforms/web/DevToys.Wasm/DevToys.Wasm.csproj
index 63b9723cf..e0e7cc12b 100644
--- a/src/app/dev/platforms/web/DevToys.Wasm/DevToys.Wasm.csproj
+++ b/src/app/dev/platforms/web/DevToys.Wasm/DevToys.Wasm.csproj
@@ -34,7 +34,7 @@
<EmbeddedResource Include="WasmScripts\AppManifest.js" />
</ItemGroup>
<ItemGroup>
- <LinkerDescriptor Include="LinkerConfig.xml" />
+ <LinkerDescriptor Update="Properties\DevToys.Wasm.xml" />
</ItemGroup>
<ItemGroup>
<!--
@@ -44,7 +44,6 @@
You can safely remove this ItemGroup completely.
-->
<None Include="Program.cs" />
- <None Include="LinkerConfig.xml" />
<None Include="wwwroot\web.config" />
</ItemGroup>
diff --git a/src/app/dev/platforms/web/DevToys.Wasm/LinkerConfig.xml b/src/app/dev/platforms/web/DevToys.Wasm/LinkerConfig.xml
deleted file mode 100644
index 5ed9e064d..000000000
--- a/src/app/dev/platforms/web/DevToys.Wasm/LinkerConfig.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<linker>
- <assembly fullname="DevToys.Wasm" />
- <assembly fullname="Uno.UI" />
- <assembly fullname="Microsoft.Extensions.Options" />
-
- <assembly fullname="System.Core">
- <!-- This is required by JSon.NET and any expression.Compile caller -->
- <type fullname="System.Linq.Expressions*" />
- </assembly>
-</linker>
diff --git a/src/app/dev/shared/App.xaml.cs b/src/app/dev/shared/App.xaml.cs
index a95e3db98..038644bfb 100644
--- a/src/app/dev/shared/App.xaml.cs
+++ b/src/app/dev/shared/App.xaml.cs
@@ -1,17 +1,20 @@
-using DevToys.Api;
+using System.IO;
+using DevToys.Api;
using DevToys.Api.Core.Theme;
-using DevToys.Api.Core.Threading;
+using DevToys.Core.Logging;
using DevToys.Core.Mef;
using DevToys.Core.Settings;
using DevToys.UI;
using DevToys.UI.Framework.Controls;
using DevToys.UI.Views;
+using DevToys.Wasdk.Core.FileStorage;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml;
using Uno.Extensions;
using Uno.Logging;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Core;
+using ILogger = Microsoft.Extensions.Logging.ILogger;
using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs;
using UnhandledExceptionEventArgs = Microsoft.UI.Xaml.UnhandledExceptionEventArgs;
@@ -23,11 +26,13 @@ namespace DevToys;
public sealed partial class App : Application
{
// Always keep an instance of MefComposer alive so GC doesn't purge it.
- private readonly Task<MefComposer> _mefComposer;
+ private readonly MefComposer _mefComposer;
- private readonly Task<IMefProvider> _mefProvider;
- private readonly AsyncLazy<ISettingsProvider> _settingsProvider;
- private readonly AsyncLazy<IThemeListener> _themeListener;
+ private readonly IMefProvider _mefProvider;
+ private readonly Lazy<ISettingsProvider> _settingsProvider;
+ private readonly Lazy<IThemeListener> _themeListener;
+ private readonly ILoggerFactory _loggerFactory;
+ private readonly ILogger _logger;
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
@@ -35,30 +40,29 @@ public sealed partial class App : Application
/// </summary>
public App()
{
- InitializeLogging();
+ this.InitializeComponent();
- this.UnhandledException += OnUnhandledException;
+ _loggerFactory = InitializeLogging();
+ _logger = this.Log();
+ _logger.LogInformation("App is starting...");
- this.InitializeComponent();
+ this.UnhandledException += OnUnhandledException;
#if HAS_UNO || NETFX_CORE
this.Suspending += OnSuspending;
#endif
_mefComposer
- = Task.Run(
- () => new MefComposer(
- new[]
- {
- typeof(MainWindow).Assembly
- }));
-
- _mefProvider
- = Task.Run(
- async () => (await _mefComposer).Provider);
-
- _settingsProvider = new AsyncLazy<ISettingsProvider>(async () => (await _mefProvider).Import<ISettingsProvider>());
- _themeListener = new AsyncLazy<IThemeListener>(async () => (await _mefProvider).Import<IThemeListener>());
+ = new MefComposer(
+ new[]
+ {
+ typeof(MainWindow).Assembly
+ });
+
+ _mefProvider = _mefComposer.Provider;
+
+ _settingsProvider = new Lazy<ISettingsProvider>(_mefProvider.Import<ISettingsProvider>);
+ _themeListener = new Lazy<IThemeListener>(_mefProvider.Import<IThemeListener>());
}
internal MainWindow? MainWindow { get; private set; }
@@ -68,7 +72,7 @@ public sealed partial class App : Application
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
- protected override async void OnLaunched(LaunchActivatedEventArgs args)
+ protected override void OnLaunched(LaunchActivatedEventArgs args)
{
#if DEBUG
if (Debugger.IsAttached)
@@ -78,14 +82,13 @@ public sealed partial class App : Application
#endif
// Set the user-defined language.
- string? languageIdentifier = (await _settingsProvider.GetValueAsync()).GetSetting(PredefinedSettings.Language);
+ string? languageIdentifier = _settingsProvider.Value.GetSetting(PredefinedSettings.Language);
LanguageDefinition languageDefinition
= LanguageManager.Instance.AvailableLanguages.FirstOrDefault(l => string.Equals(l.InternalName, languageIdentifier))
?? LanguageManager.Instance.AvailableLanguages[0];
LanguageManager.Instance.SetCurrentCulture(languageDefinition);
- IMefProvider mefProvider = await _mefProvider;
- IThemeListener themeListener = await _themeListener.GetValueAsync();
+ IThemeListener themeListener = _themeListener.Value;
#if __WINDOWS__
// On Windows 10 version 1607 or later, this code signals that this app wants to participate in prelaunch
@@ -93,19 +96,20 @@ public sealed partial class App : Application
#endif
#if __WINDOWS__
- MainWindow = new MainWindow(new BackdropWindow(), themeListener, mefProvider);
+ MainWindow = new MainWindow(new BackdropWindow(), themeListener, _mefProvider);
#elif __MACCATALYST__
// Important! Keep the full name `Microsoft.UI.Xaml.Window.Current` otherwise the Mac app won't build.
// See https://blog.mzikmund.com/2020/04/resolving-uno-platform-uiwindow-does-not-contain-a-definition-for-current-issue/
- MainWindow = new MainWindow(new BackdropWindow(Microsoft.UI.Xaml.Window.Current), themeListener, mefProvider);
+ MainWindow = new MainWindow(new BackdropWindow(Microsoft.UI.Xaml.Window.Current), themeListener, _mefProvider);
#else
- MainWindow = new MainWindow(new BackdropWindow(Window.Current), themeListener, mefProvider);
+ MainWindow = new MainWindow(new BackdropWindow(Window.Current), themeListener, _mefProvider);
#endif
// Apply the app color theme.
themeListener.ApplyDesiredColorTheme();
MainWindow.Activated += MainWindow_Activated;
+ MainWindow.Closed += MainWindow_Closed;
MainWindow.Show();
@@ -120,9 +124,19 @@ public sealed partial class App : Application
}
}
- private async void MainWindow_Activated(BackdropWindow sender, WindowActivatedEventArgs args)
+ private void MainWindow_Closed(BackdropWindow sender, EventArgs args)
{
- (await _themeListener.GetValueAsync()).UpdateThemeIfNeeded();
+ _logger.LogInformation("App is shutting down...");
+ _loggerFactory.Dispose();
+
+ Guard.IsNotNull(MainWindow);
+ MainWindow.Activated -= MainWindow_Activated;
+ MainWindow.Closed -= MainWindow_Closed;
+ }
+
+ private void MainWindow_Activated(BackdropWindow sender, WindowActivatedEventArgs args)
+ {
+ _themeListener.Value.UpdateThemeIfNeeded();
}
/// <summary>
@@ -145,12 +159,13 @@ public sealed partial class App : Application
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
- ILogger logger = this.Log();
- if (logger.IsEnabled(LogLevel.Error))
+ if (_logger.IsEnabled(LogLevel.Error))
{
- logger.Error($"Unhandled exception !!!", e.Exception);
+ _logger.Error($"Unhandled exception !!!", e.Exception);
}
+ _loggerFactory.Dispose();
+
// TODO:
// Maybe we need to dispose all tools in case if they have on-going work so they have a chance to finish correctly?
// Also, use IMarketingService to NotifyAppEncounteredAProblemAsync ?
@@ -159,9 +174,8 @@ public sealed partial class App : Application
/// <summary>
/// Configures global Uno Platform logging
/// </summary>
- private static void InitializeLogging()
+ private static ILoggerFactory InitializeLogging()
{
-#if DEBUG
// Logging is disabled by default for release builds, as it incurs a significant
// initialization cost from Microsoft.Extensions.Logging setup. If startup performance
// is a concern for your application, keep this disabled. If you're running on web or
@@ -171,6 +185,7 @@ public sealed partial class App : Application
ILoggerFactory factory = LoggerFactory.Create((ILoggingBuilder builder) =>
{
+#if DEBUG
#if __WASM__
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
#elif __MACCATALYST__
@@ -180,20 +195,27 @@ public sealed partial class App : Application
#else
builder.AddConsole();
builder.AddDebug();
+#endif
#endif
+ // To save logs on local hard drive.
+ builder.AddFile(new FileStorage());
+
// Exclude logs below this level
+#if DEBUG
+ builder.SetMinimumLevel(LogLevel.Trace);
+#else
builder.SetMinimumLevel(LogLevel.Information);
+#endif
// Default filters for Uno Platform namespaces
builder.AddFilter("Uno", LogLevel.Warning);
builder.AddFilter("Windows", LogLevel.Warning);
builder.AddFilter("Microsoft", LogLevel.Warning);
+#if DEBUG
if (Debugger.IsAttached)
{
- builder.SetMinimumLevel(LogLevel.Debug);
-
// Generic Xaml events
builder.AddFilter("Windows.UI.Xaml", LogLevel.Debug);
builder.AddFilter("Windows.UI.Xaml.VisualStateGroup", LogLevel.Debug);
@@ -221,6 +243,7 @@ public sealed partial class App : Application
// Debug JS interop
builder.AddFilter("Uno.Foundation.WebAssemblyRuntime", LogLevel.Debug);
}
+#endif
});
global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory;
@@ -228,6 +251,6 @@ public sealed partial class App : Application
#if HAS_UNO
global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize();
#endif
-#endif
+ return factory;
}
}
diff --git a/src/app/dev/shared/LinkerConfig.xml b/src/app/dev/shared/LinkerConfig.xml
new file mode 100644
index 000000000..320de3bd2
--- /dev/null
+++ b/src/app/dev/shared/LinkerConfig.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ This file specifies which parts of the BCL or the app must not be
+ trimmed by the IL Linker even if they aren't referenced by user code.
+-->
+<linker>
+ <assembly fullname="mscorlib">
+ <!--
+ Preserve the methods in WasmRuntime because its methods are called by
+ JavaScript client-side code to implement timers.
+ Fixes: https://github.com/dotnet/blazor/issues/239
+ -->
+ <type fullname="System.Threading.WasmRuntime" />
+ </assembly>
+ <assembly fullname="System.Core">
+ <!--
+ System.Linq.Expressions* is required by Json.NET and any
+ expression.Compile caller. The assembly isn't stripped.
+ -->
+ <type fullname="System.Linq.Expressions*" />
+ </assembly>
+ <assembly fullname="Uno.UI" />
+ <assembly fullname="Microsoft.Extensions.Options" />
+ <assembly fullname="DevToys.API" />
+ <assembly fullname="DevToys.Core" />
+ <assembly fullname="DevToys.CLI" />
+ <assembly fullname="DevToys.Localization" />
+ <assembly fullname="DevToys.MauiBlazor" />
+ <assembly fullname="DevToys.MonacoEditor" />
+ <assembly fullname="DevToys.UI" />
+ <assembly fullname="DevToys.Wasdk" />
+ <assembly fullname="DevToys.Wasm" />
+ <assembly fullname="DevToys.Tools" />
+</linker>
\ No newline at end of file
diff --git a/src/build/Build.cs b/src/build/Build.cs
index 1c36ec388..84204cc09 100644
--- a/src/build/Build.cs
+++ b/src/build/Build.cs
@@ -100,11 +100,48 @@ class Build : NukeBuild
SetAppVersion(RootDirectory);
});
+ Target BuildGenerators => _ => _
+ .DependentFor(Publish)
+ .After(Restore)
+ .After(SetVersion)
+ .Executes(() =>
+ {
+ Log.Information($"Building generators ...");
+ RootDirectory
+ .GlobFiles("**/generators/*.csproj")
+ .ForEach(f =>
+ DotNetBuild(s => s
+ .SetProjectFile(f)
+ .SetConfiguration(Configuration)
+ .SetSelfContained(true)
+ .SetPublishTrimmed(false)
+ .SetVerbosity(DotNetVerbosity.Quiet)));
+ });
+
+ Target BuildPlugins => _ => _
+ .DependentFor(Publish)
+ .After(Restore)
+ .After(SetVersion)
+ .After(BuildGenerators)
+ .Executes(() =>
+ {
+ Log.Information($"Building plugins ...");
+ Project project = WindowsSolution!.GetProject("DevToys.Tools");
+ DotNetBuild(s => s
+ .SetProjectFile(project)
+ .SetConfiguration(Configuration)
+ .SetSelfContained(false)
+ .SetPublishTrimmed(false)
+ .SetVerbosity(DotNetVerbosity.Quiet));
+ });
+
#pragma warning disable IDE0051 // Remove unused private members
Target UnitTests => _ => _
.DependentFor(Publish)
.After(Restore)
.After(SetVersion)
+ .After(BuildGenerators)
+ .After(BuildPlugins)
.OnlyWhenDynamic(() => RunTests)
.Executes(() =>
{
@@ -121,6 +158,8 @@ class Build : NukeBuild
Target Publish => _ => _
.DependsOn(SetVersion)
.DependsOn(Restore)
+ .DependsOn(BuildGenerators)
+ .DependsOn(BuildPlugins)
.Executes(() =>
{
if (PlatformTargets!.Contains(PlatformTarget.Windows))
@@ -140,7 +179,8 @@ class Build : NukeBuild
.SetPublishTrimmed(false) // TODO?
.SetVerbosity(DotNetVerbosity.Quiet)
.SetProcessArgumentConfigurator(_ => _
- .Add("/p:RuntimeIdentifierOverride=" + dotnetParameters.RuntimeIdentifier))
+ .Add("/p:RuntimeIdentifierOverride=" + dotnetParameters.RuntimeIdentifier)
+ .Add($"/bl:\"{RootDirectory / "publish" / dotnetParameters.OutputPath}.binlog\""))
.SetOutput(RootDirectory / "publish" / dotnetParameters.OutputPath));
}
@@ -161,7 +201,8 @@ class Build : NukeBuild
.SetVerbosity(DotNetVerbosity.Quiet)
.SetProcessArgumentConfigurator(_ => _
.Add("/p:RuntimeIdentifierOverride=" + dotnetParameters.RuntimeIdentifier)
- .Add("/p:Unpackaged=" + dotnetParameters.Portable))
+ .Add("/p:Unpackaged=" + dotnetParameters.Portable)
+ .Add($"/bl:\"{RootDirectory / "publish" / dotnetParameters.OutputPath}.binlog\""))
.SetOutput(RootDirectory / "publish" / dotnetParameters.OutputPath));
}
}
@@ -189,7 +230,8 @@ class Build : NukeBuild
.SetNoRestore(true) /* workaround for https://github.com/xamarin/xamarin-macios/issues/15664#issuecomment-1233123515 */
.SetProcessArgumentConfigurator(_ => _
.Add("/p:RuntimeIdentifierOverride=" + dotnetParameters.RuntimeIdentifier)
- .Add("/p:CreatePackage=True")) /* Will create an installable .pkg */
+ .Add("/p:CreatePackage=True") /* Will create an installable .pkg */
+ .Add($"/bl:\"{RootDirectory / "publish" / dotnetParameters.OutputPath}.binlog\""))
.SetOutputDirectory(RootDirectory / "publish" / dotnetParameters.OutputPath));
}
}
@@ -209,8 +251,11 @@ class Build : NukeBuild
.SetSelfContained(dotnetParameters.Portable)
.SetPublishSingleFile(true)
.SetPublishReadyToRun(true)
- .SetPublishTrimmed(dotnetParameters.Portable)
+ .SetPublishTrimmed(false)
+ //.SetPublishTrimmed(dotnetParameters.Portable) // TODO?
.SetVerbosity(DotNetVerbosity.Quiet)
+ .SetProcessArgumentConfigurator(_ => _
+ .Add($"/bl:\"{RootDirectory / "publish" / dotnetParameters.OutputPath}.binlog\""))
.SetOutput(RootDirectory / "publish" / dotnetParameters.OutputPath));
}
}
diff --git a/src/generators/Directory.Build.props b/src/generators/Directory.Build.props
new file mode 100644
index 000000000..e339c870a
--- /dev/null
+++ b/src/generators/Directory.Build.props
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <!-- This file prevents unintended imports of unrelated MSBuild files -->
+ <!-- Uncomment to include parent Directory.Build.props file -->
+ <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
+
+ <PropertyGroup>
+ <BaseOutputPath>bin\</BaseOutputPath>
+ <OutputPath>$(BaseOutputPath)\</OutputPath>
+ <BaseIntermediateOutputPath>obj\$(Platform)\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
+ <IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
+ <GeneratedFilesDir>$(BaseIntermediateOutputPath)Generated Files\</GeneratedFilesDir>
+ </PropertyGroup>
+</Project>
diff --git a/src/generators/Directory.Build.targets b/src/generators/Directory.Build.targets
new file mode 100644
index 000000000..340280a69
--- /dev/null
+++ b/src/generators/Directory.Build.targets
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <!-- This file prevents unintended imports of unrelated MSBuild files -->
+ <!-- Uncomment to include parent Directory.Build.targets file -->
+ <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
+
+</Project>
diff --git a/src/generators/ResxHelperGenerator/CultureHelperGenerator.cs b/src/generators/ResxHelperGenerator/CultureHelperGenerator.cs
index a5ab374cf..8b7f4be41 100644
--- a/src/generators/ResxHelperGenerator/CultureHelperGenerator.cs
+++ b/src/generators/ResxHelperGenerator/CultureHelperGenerator.cs
@@ -31,7 +31,7 @@ public class CultureHelperGenerator : ISourceGenerator
if (InitialCheckUp(context, out string projectRootPath, out string projectRootNamespace))
{
- string[] cultures = DetectAllCutlures(projectRootPath);
+ string[] cultures = DetectAllCutlures(context);
if (!context.CancellationToken.IsCancellationRequested)
{
@@ -79,14 +79,14 @@ public class CultureHelperGenerator : ISourceGenerator
return true;
}
- private string[] DetectAllCutlures(string projectRootPath)
+ private string[] DetectAllCutlures(GeneratorExecutionContext context)
{
var cultures = new HashSet<string>() { "en-US" };
- string[] resxFiles = Directory.GetFiles(projectRootPath, "*.resx", SearchOption.AllDirectories);
- for (int i = 0; i < resxFiles.Length; i++)
+ var resxFiles = context.AdditionalFiles.Where(f => Path.GetExtension(f.Path).ToLower() == ".resx").ToList();
+ for (int i = 0; i < resxFiles.Count; i++)
{
- string filePath = resxFiles[i].Trim();
+ string filePath = resxFiles[i].Path.Trim();
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
string cultureName = fileNameWithoutExtension.Split(new[] { '.' }, System.StringSplitOptions.RemoveEmptyEntries).Last();
if (cultureName.Length == 2 || (cultureName.Length == 5 && cultureName.Contains("-")))