From d9ce0e8eaec84bb9a63f8740d1c440fa8bf4f809 Mon Sep 17 00:00:00 2001 From: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:42:39 +0100 Subject: [PATCH] Merge upstream PT #6 (#288) --- .configurations/configuration.dsc.yaml | 1 - .../configuration.vsEnterprise.dsc.yaml | 1 - .../configuration.vsProfessional.dsc.yaml | 1 - .github/actions/spell-check/allow/code.txt | 18 +- .github/actions/spell-check/allow/names.txt | 17 ++ .github/actions/spell-check/excludes.txt | 1 + .github/actions/spell-check/expect.txt | 13 +- .github/actions/spell-check/patterns.txt | 2 +- .pipelines/UpdateVersions.ps1 | 130 ++++++++++++ .../v2/ci-test-with-canary-webview2.yml | 42 ++++ .../v2/ci-using-the-latest-winappsdk.yml | 50 +++++ .pipelines/v2/oneFuzz.yml | 55 +++++ .pipelines/v2/templates/job-build-project.yml | 42 +++- .pipelines/v2/templates/job-fuzz.yml | 36 ++++ .pipelines/v2/templates/job-test-project.yml | 26 +++ .pipelines/v2/templates/pipeline-ci-build.yml | 17 ++ .../templates/steps-ensure-dotnet-version.yml | 5 + ...eps-update-winappsdk-and-restore-nuget.yml | 56 +++++ .pipelines/verifyDepsJsonLibraryVersions.ps1 | 2 +- COMMUNITY.md | 8 + Directory.Packages.props | 5 +- NOTICE.md | 5 +- PowerToys.sln | 17 +- README.md | 18 +- .../modules/launcher/new-plugin-checklist.md | 3 +- src/Monaco/monacoSpecialLanguages.js | 2 +- src/Monaco/monaco_languages.json | 2 +- Solution.props => src/Solution.props | 0 .../FilePreviewCommon.csproj | 1 + .../FilePreviewJsonSerializerContext.cs | 14 ++ .../Formatters/JsonFormatter.cs | 4 +- src/common/FilePreviewCommon/MonacoHelper.cs | 10 +- .../AdvancedPaste.FuzzTests.csproj | 26 +++ .../AdvancedPaste.FuzzTests/Fuzz.md | 45 +++++ .../AdvancedPaste.FuzzTests/FuzzTests.cs | 32 +++ .../AdvancedPaste.FuzzTests/Logger.cs | 46 +++++ .../AdvancedPaste.FuzzTests/MSTestSettings.cs | 5 + .../OneFuzzConfig.json | 47 +++++ .../AdvancedPaste/AdvancedPaste.csproj | 2 + .../AdvancedPasteXAML/App.xaml.cs | 2 +- .../AdvancedPaste/Helpers/JsonHelper.cs | 20 ++ .../AdvancedPaste/Helpers/UserSettings.cs | 4 +- .../EnvironmentVariables.csproj | 2 + .../FileLocksmithUI/FileLocksmithUI.csproj | 2 + .../Hosts/Hosts.Tests/Hosts.Tests.csproj | 2 + src/modules/Hosts/Hosts/Hosts.csproj | 2 + .../HostsUILib/Helpers/DuplicateService.cs | 2 +- .../Hosts/HostsUILib/Helpers/HostsService.cs | 2 +- .../Hosts/HostsUILib/HostsUILib.csproj | 1 + .../HostsUILib/ViewModels/MainViewModel.cs | 2 + .../shell_context_menu_win10.cpp | 11 +- src/modules/PowerOCR/PowerOCR/OCROverlay.xaml | 4 +- .../PowerOCR/PowerOCR/OCROverlay.xaml.cs | 30 ++- .../Controls/SearchBar.xaml | 4 +- .../Microsoft.CmdPal.UI.Poc.csproj | 4 +- .../fancyzones/FancyZonesLib/WindowUtils.cpp | 3 +- .../plugin.json | 2 +- .../Main.cs | 151 +++++++++++--- .../Properties/Resources.Designer.cs | 27 +++ .../Properties/Resources.resx | 9 + .../plugin.json | 4 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../Microsoft.Plugin.Folder/plugin.json | 2 +- .../Microsoft.Plugin.Shell/plugin.json | 2 +- .../Plugins/Microsoft.Plugin.Uri/plugin.json | 2 +- .../Microsoft.Plugin.WindowWalker/plugin.json | 2 +- .../ExtendedCalculatorParserTests.cs | 10 +- .../QueryTests.cs | 3 + .../CalculateEngine.cs | 4 +- .../CalculateHelper.cs | 4 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../plugin.json | 2 +- .../launcher/PowerLauncher/MainWindow.xaml | 191 +++++++++--------- .../launcher/PowerLauncher/MainWindow.xaml.cs | 5 + .../PowerLauncher/Plugin/PluginManager.cs | 5 +- .../launcher/PowerLauncher/SettingsReader.cs | 5 + src/modules/peek/Peek.UI/Peek.UI.csproj | 2 + .../poweraccent/PowerAccent.Core/Languages.cs | 23 ++- .../MarkdownPreviewHandler.csproj | 3 +- .../MarkdownPreviewHandlerControl.cs | 4 +- .../RegistryPreview/RegistryPreview.csproj | 2 + .../PowerLauncherPluginSettings.cs | 4 + .../Settings.UI/PowerToys.Settings.csproj | 2 + .../SettingsXAML/Styles/TextBlock.xaml | 5 + .../SettingsXAML/Views/AdvancedPaste.xaml | 106 +++++----- .../SettingsXAML/Views/PowerLauncherPage.xaml | 45 ++++- .../Settings.UI/Strings/en-us/Resources.resw | 13 +- .../ViewModels/PowerAccentViewModel.cs | 1 + .../PowerLauncherPluginViewModel.cs | 14 ++ .../ViewModels/PowerOcrViewModel.cs | 16 +- 99 files changed, 1322 insertions(+), 274 deletions(-) create mode 100644 .pipelines/UpdateVersions.ps1 create mode 100644 .pipelines/v2/ci-test-with-canary-webview2.yml create mode 100644 .pipelines/v2/ci-using-the-latest-winappsdk.yml create mode 100644 .pipelines/v2/oneFuzz.yml create mode 100644 .pipelines/v2/templates/job-fuzz.yml create mode 100644 .pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml rename Solution.props => src/Solution.props (100%) create mode 100644 src/common/FilePreviewCommon/Formatters/FilePreviewJsonSerializerContext.cs create mode 100644 src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/AdvancedPaste.FuzzTests.csproj create mode 100644 src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/Fuzz.md create mode 100644 src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/FuzzTests.cs create mode 100644 src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/Logger.cs create mode 100644 src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/MSTestSettings.cs create mode 100644 src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/OneFuzzConfig.json diff --git a/.configurations/configuration.dsc.yaml b/.configurations/configuration.dsc.yaml index a6256da512..df3eeea441 100644 --- a/.configurations/configuration.dsc.yaml +++ b/.configurations/configuration.dsc.yaml @@ -12,7 +12,6 @@ properties: id: vsPackage directives: description: Install Visual Studio 2022 Community (Any edition will work) - allowPrerelease: true settings: id: Microsoft.VisualStudio.2022.Community source: winget diff --git a/.configurations/configuration.vsEnterprise.dsc.yaml b/.configurations/configuration.vsEnterprise.dsc.yaml index 34d73f4975..84e05ed511 100644 --- a/.configurations/configuration.vsEnterprise.dsc.yaml +++ b/.configurations/configuration.vsEnterprise.dsc.yaml @@ -12,7 +12,6 @@ properties: id: vsPackage directives: description: Install Visual Studio 2022 Enterprise (Any edition will work) - allowPrerelease: true settings: id: Microsoft.VisualStudio.2022.Enterprise source: winget diff --git a/.configurations/configuration.vsProfessional.dsc.yaml b/.configurations/configuration.vsProfessional.dsc.yaml index 3c08d05856..6ac0babf9f 100644 --- a/.configurations/configuration.vsProfessional.dsc.yaml +++ b/.configurations/configuration.vsProfessional.dsc.yaml @@ -12,7 +12,6 @@ properties: id: vsPackage directives: description: Install Visual Studio 2022 Professional (Any edition will work) - allowPrerelease: true settings: id: Microsoft.VisualStudio.2022.Professional source: winget diff --git a/.github/actions/spell-check/allow/code.txt b/.github/actions/spell-check/allow/code.txt index b9a7ad1d63..8c53e52827 100644 --- a/.github/actions/spell-check/allow/code.txt +++ b/.github/actions/spell-check/allow/code.txt @@ -78,7 +78,14 @@ sinclairinat stylecop uipi yinwang - +myaccess +onmicrosoft +aep +epsf +howto +onefuzzconfig +oip +onefuzzingestionpreparationtool # KEYS @@ -246,3 +253,12 @@ pwa AOT Aot + +# YML +onefuzz + +# NameInCode +leilzh + +#Tools +OIP diff --git a/.github/actions/spell-check/allow/names.txt b/.github/actions/spell-check/allow/names.txt index ee025ebd03..c851fbf45f 100644 --- a/.github/actions/spell-check/allow/names.txt +++ b/.github/actions/spell-check/allow/names.txt @@ -46,6 +46,8 @@ betsegaw bricelam bsky CCcat +chenmy +chemwolf Chinh chrdavis Chrzan @@ -63,6 +65,7 @@ Deondre DHowett ductdo Essey +Feng ethanfangg ferraridavide frankychen @@ -79,6 +82,7 @@ Griese grzhan Guo hanselman +haoliuu Harmath Heiko Hemmerlein @@ -93,6 +97,7 @@ Jaswal jefflord Jordi jyuwono +kai Kairu Kamra Kantarci @@ -110,6 +115,7 @@ Markovic martinchrzan martinmoene Melman +Mengyuan Mikhayelyan msft Mykhailo @@ -122,11 +128,13 @@ oldnewthing onegreatworld palenshus pedrolamas +Peiyao peteblois phoboslab Ponten Pooja Pylyp +Qingpeng quachpas Quriz randyrants @@ -155,14 +163,23 @@ Taras TBM tilovell Triet +urnotdfs waaverecords +wang Whuihuan +Xiaofeng Xpg +Yaqing +yaqingmi ycv yeelam Yuniardi yuyoyuppe Zeol +Zhao +Zhaopeng +zhaopy +zhaoqpcn Zoltan Zykova diff --git a/.github/actions/spell-check/excludes.txt b/.github/actions/spell-check/excludes.txt index 384b22e776..5e2a5ffff1 100644 --- a/.github/actions/spell-check/excludes.txt +++ b/.github/actions/spell-check/excludes.txt @@ -101,6 +101,7 @@ ^\Qsrc/modules/colorPicker/ColorPickerUI/Shaders/GridShader.cso\E$ ^\Qsrc/modules/MouseUtils/MouseJump.Common/NativeMethods/User32/UI/WindowsAndMessaging/User32.SYSTEM_METRICS_INDEX.cs\E$ ^\Qsrc/modules/MouseUtils/MouseJumpUI/MainForm.resx\E$ +^\Qsrc/modules/MouseUtils/MouseJump.Common/NativeMethods/User32/UI/WindowsAndMessaging/User32.SYSTEM_METRICS_INDEX.cs\E$ ^\Qsrc/modules/MouseWithoutBorders/App/Form/frmAbout.cs\E$ ^\Qsrc/modules/MouseWithoutBorders/App/Form/frmInputCallback.resx\E$ ^\Qsrc/modules/MouseWithoutBorders/App/Form/frmLogon.resx\E$ diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index e34159b80c..e6d1c42c83 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -221,7 +221,6 @@ CONFIGW CONFLICTINGMODIFIERKEY CONFLICTINGMODIFIERSHORTCUT CONOUT -contentdialog contentfiles CONTEXTHELP CONTEXTMENUHANDLER @@ -672,6 +671,7 @@ imagingdevices ime imgflip inbox +Indo inetcpl Infobar INFOEXAMPLE @@ -707,7 +707,6 @@ INVALIDINDEX invalidoperatioexception ipcmanager IPREVIEW -ipreviewhandlervisualssetfont irprops isbi ISearch @@ -770,6 +769,7 @@ lhwnd LIBID libraryincludes lindex +linkid LINKOVERLAY LINQTo listview @@ -783,7 +783,7 @@ LOADFROMFILE LOBYTE localappdata LOCALDISPLAY -LOCALPACKAGE +localpackage LOCALSYSTEM LOCATIONCHANGE LOGFONT @@ -1048,7 +1048,6 @@ NResize nsunt NTAPI ntdll -ntfs NTSTATUS NTZm nullonfailure @@ -1083,7 +1082,6 @@ osvi OUTOFCONTEXT outpin Outptr -outputtype outsettings OVERLAPPEDWINDOW overlaywindow @@ -1211,7 +1209,6 @@ programdata projectname PROPBAG PROPERTYKEY -propkey Propset PROPVARIANT prvpane @@ -1258,6 +1255,7 @@ QUNS QXZ RAII RAlt +randi Rasterization Rasterize RAWINPUTDEVICE @@ -1768,6 +1766,7 @@ wic wifi wil winapi +winappsdk wincolor windir WINDOWCREATED @@ -1782,8 +1781,6 @@ windowssettings WINDOWSTYLES WINDOWSTYLESICON WINEVENT -winexe -winforms winget wingetcreate Winhook diff --git a/.github/actions/spell-check/patterns.txt b/.github/actions/spell-check/patterns.txt index cc3ce104af..457e7e0800 100644 --- a/.github/actions/spell-check/patterns.txt +++ b/.github/actions/spell-check/patterns.txt @@ -131,7 +131,7 @@ _mm_(?!dd)\w+ # hit-count: 4 file-count: 4 # microsoft -\b(?:https?://|)(?:(?:(?:blogs|download\.visualstudio|developer|docs|msdn2?|research)\.|)microsoft|blogs\.msdn)\.co(?:m|\.\w\w)/[-_a-zA-Z0-9()=./%]* +\b(?:https?://|)(?:(?:(?:blogs|download\.visualstudio|developer|docs|learn|msdn2?|research)\.|)microsoft|blogs\.msdn)\.co(?:m|\.\w\w)/[-_a-zA-Z0-9()=./%#]* aka\.ms/[a-zA-Z0-9]+ diff --git a/.pipelines/UpdateVersions.ps1 b/.pipelines/UpdateVersions.ps1 new file mode 100644 index 0000000000..c19dfb5dec --- /dev/null +++ b/.pipelines/UpdateVersions.ps1 @@ -0,0 +1,130 @@ +Param( + # Using the default value of 1.6 for winAppSdkVersionNumber and useExperimentalVersion as false + [Parameter(Mandatory=$False,Position=1)] + [string]$winAppSdkVersionNumber = "1.6", + + # When the pipeline calls the PS1 file, the passed parameters are converted to string type + [Parameter(Mandatory=$False,Position=2)] + [boolean]$useExperimentalVersion = $False +) + +function Update-NugetConfig { + param ( + [string]$filePath = "nuget.config" + ) + + Write-Host "Updating nuget.config file" + [xml]$xml = Get-Content -Path $filePath + + # Add localpackages source into nuget.config + $packageSourcesNode = $xml.configuration.packageSources + $addNode = $xml.CreateElement("add") + $addNode.SetAttribute("key", "localpackages") + $addNode.SetAttribute("value", "localpackages") + $packageSourcesNode.AppendChild($addNode) | Out-Null + + # Remove tag and its content + $packageSourceMappingNode = $xml.configuration.packageSourceMapping + if ($packageSourceMappingNode) { + $xml.configuration.RemoveChild($packageSourceMappingNode) | Out-Null + } + + # print nuget.config after modification + $xml.OuterXml + # Save the modified nuget.config file + $xml.Save($filePath) +} + +$sourceLink = "https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json" + +# Execute nuget list and capture the output +if ($useExperimentalVersion) { + # The nuget list for experimental versions will cost more time + # So, we will not use -AllVersions to wast time + # But it can only get the latest experimental version + Write-Host "Fetching WindowsAppSDK with experimental versions" + $nugetOutput = nuget list Microsoft.WindowsAppSDK ` + -Source $sourceLink ` + -Prerelease + # Filter versions based on the specified version prefix + $escapedVersionNumber = [regex]::Escape($winAppSdkVersionNumber) + $filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK $escapedVersionNumber\." } + $latestVersions = $filteredVersions +} else { + Write-Host "Fetching stable WindowsAppSDK versions for $winAppSdkVersionNumber" + $nugetOutput = nuget list Microsoft.WindowsAppSDK ` + -Source $sourceLink ` + -AllVersions + # Filter versions based on the specified version prefix + $escapedVersionNumber = [regex]::Escape($winAppSdkVersionNumber) + $filteredVersions = $nugetOutput | Where-Object { $_ -match "Microsoft.WindowsAppSDK $escapedVersionNumber\." } + $latestVersions = $filteredVersions | Sort-Object { [version]($_ -split ' ')[1] } -Descending | Select-Object -First 1 +} + +Write-Host "Latest versions found: $latestVersions" +# Extract the latest version number from the output +$latestVersion = $latestVersions -split "`n" | ` + Select-String -Pattern 'Microsoft.WindowsAppSDK\s*([0-9]+\.[0-9]+\.[0-9]+-*[a-zA-Z0-9]*)' | ` + ForEach-Object { $_.Matches[0].Groups[1].Value } | ` + Sort-Object -Descending | ` + Select-Object -First 1 + +if ($latestVersion) { + $WinAppSDKVersion = $latestVersion + Write-Host "Extracted version: $WinAppSDKVersion" + Write-Host "##vso[task.setvariable variable=WinAppSDKVersion]$WinAppSDKVersion" +} else { + Write-Host "Failed to extract version number from nuget list output" + exit 1 +} + +# Update packages.config files +Get-ChildItem -Recurse packages.config | ForEach-Object { + $content = Get-Content $_.FullName -Raw + if ($content -match 'package id="Microsoft.WindowsAppSDK"') { + $newVersionString = 'package id="Microsoft.WindowsAppSDK" version="' + $WinAppSDKVersion + '"' + $oldVersionString = 'package id="Microsoft.WindowsAppSDK" version="[-.0-9a-zA-Z]*"' + $content = $content -replace $oldVersionString, $newVersionString + Set-Content -Path $_.FullName -Value $content + Write-Host "Modified " $_.FullName + } +} + +# Update Directory.Packages.props file +$propsFile = "Directory.Packages.props" +if (Test-Path $propsFile) { + $content = Get-Content $propsFile -Raw + if ($content -match '' + $oldVersionString = '' + $content = $content -replace $oldVersionString, $newVersionString + Set-Content -Path $propsFile -Value $content + Write-Host "Modified " $propsFile + } +} + +# Update .vcxproj files +Get-ChildItem -Recurse *.vcxproj | ForEach-Object { + $content = Get-Content $_.FullName -Raw + if ($content -match '\\Microsoft.WindowsAppSDK.') { + $newVersionString = '\Microsoft.WindowsAppSDK.' + $WinAppSDKVersion + '\' + $oldVersionString = '\\Microsoft.WindowsAppSDK.[-.0-9a-zA-Z]*\\' + $content = $content -replace $oldVersionString, $newVersionString + Set-Content -Path $_.FullName -Value $content + Write-Host "Modified " $_.FullName + } +} + +# Update .csproj files +Get-ChildItem -Recurse *.csproj | ForEach-Object { + $content = Get-Content $_.FullName -Raw + if ($content -match 'PackageReference Include="Microsoft.WindowsAppSDK"') { + $newVersionString = 'PackageReference Include="Microsoft.WindowsAppSDK" Version="'+ $WinAppSDKVersion + '"' + $oldVersionString = 'PackageReference Include="Microsoft.WindowsAppSDK" Version="[-.0-9a-zA-Z]*"' + $content = $content -replace $oldVersionString, $newVersionString + Set-Content -Path $_.FullName -Value $content + Write-Host "Modified " $_.FullName + } +} + +Update-NugetConfig diff --git a/.pipelines/v2/ci-test-with-canary-webview2.yml b/.pipelines/v2/ci-test-with-canary-webview2.yml new file mode 100644 index 0000000000..01f0454186 --- /dev/null +++ b/.pipelines/v2/ci-test-with-canary-webview2.yml @@ -0,0 +1,42 @@ +trigger: none +pr: none +schedules: + - cron: "0 0 * * *" # every day at midnight + displayName: "Daily midnight Build" + branches: + include: + - main + always: false # only run if there's code changes! + +name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr) + +parameters: + - name: buildPlatforms + type: object + default: + - x64 + - arm64 + - name: enableMsBuildCaching + type: boolean + displayName: "Enable MSBuild Caching" + default: false + - name: runTests + type: boolean + displayName: "Run Tests" + default: true + - name: useVSPreview + type: boolean + displayName: "Build Using Visual Studio Preview" + default: false + - name: useLatestWebView2 + type: boolean + default: false + +extends: + template: templates/pipeline-ci-build.yml + parameters: + buildPlatforms: ${{ parameters.buildPlatforms }} + enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} + runTests: ${{ parameters.runTests }} + useVSPreview: ${{ parameters.useVSPreview }} + useLatestWebView2: ${{ parameters.useLatestWebView2 }} diff --git a/.pipelines/v2/ci-using-the-latest-winappsdk.yml b/.pipelines/v2/ci-using-the-latest-winappsdk.yml new file mode 100644 index 0000000000..cc9f00f80d --- /dev/null +++ b/.pipelines/v2/ci-using-the-latest-winappsdk.yml @@ -0,0 +1,50 @@ +trigger: none +pr: none +schedules: + - cron: "0 0 * * *" # every day at midnight + displayName: "Daily midnight Build" + branches: + include: + - main + always: false # only run if there's code changes! + +name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr) + +parameters: + - name: buildPlatforms + type: object + default: + - x64 + - arm64 + - name: enableMsBuildCaching + type: boolean + displayName: "Enable MSBuild Caching" + default: false + - name: runTests + type: boolean + displayName: "Run Tests" + default: true + - name: useVSPreview + type: boolean + displayName: "Build Using Visual Studio Preview" + default: false + - name: useLatestWinAppSDK + type: boolean + default: true + - name: winAppSDKVersionNumber + type: string + default: 1.6 + - name: useExperimentalVersion + type: boolean + default: false + +extends: + template: templates/pipeline-ci-build.yml + parameters: + buildPlatforms: ${{ parameters.buildPlatforms }} + enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} + runTests: ${{ parameters.runTests }} + useVSPreview: ${{ parameters.useVSPreview }} + useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }} + winAppSDKVersionNumber: ${{ parameters.winAppSDKVersionNumber }} + useExperimentalVersion: ${{ parameters.useExperimentalVersion }} diff --git a/.pipelines/v2/oneFuzz.yml b/.pipelines/v2/oneFuzz.yml new file mode 100644 index 0000000000..2bcbf36050 --- /dev/null +++ b/.pipelines/v2/oneFuzz.yml @@ -0,0 +1,55 @@ +pr: none +trigger: none + +schedules: + - cron: "0 0 * * 1" + displayName: Weekly fuzzing submission + branches: + include: + - main + always: true +name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr) + +parameters: + - name: platform + type: string + default: x64 # for fuzzing, we only use x64 for now + - name: enableMsBuildCaching + type: boolean + displayName: "Enable MSBuild Caching" + default: false + - name: useVSPreview + type: boolean + displayName: "Build Using Visual Studio Preview" + default: false + +stages: + - stage: Build_${{ parameters.platform }} + displayName: Build ${{ parameters.platform }} + jobs: + - template: templates/job-build-project.yml + parameters: + pool: + ${{ if eq(variables['System.CollectionId'], 'cb55739e-4afe-46a3-970f-1b49d8ee7564') }}: + name: SHINE-INT-L + ${{ else }}: + name: SHINE-OSS-L + ${{ if eq(parameters.useVSPreview, true) }}: + demands: ImageOverride -equals SHINE-VS17-Preview + buildPlatforms: + - ${{ parameters.platform }} + buildConfigurations: [Release] + enablePackageCaching: true + enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} + runTests: true + useVSPreview: ${{ parameters.useVSPreview }} + + - stage: OneFuzz + displayName: Fuzz ${{ parameters.platform }} + dependsOn: + - Build_${{parameters.platform}} + jobs: + - template: templates/job-fuzz.yml + parameters: + platform: ${{ parameters.platform }} + configuration: Release diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml index 96a479ca3d..b22308bda4 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -56,6 +56,15 @@ parameters: - name: versionNumber type: string default: '0.0.1' + - name: useLatestWinAppSDK + type: boolean + default: false + - name: winAppSDKVersionNumber + type: string + default: 1.6 + - name: useExperimentalVersion + type: boolean + default: false - name: csProjectsToPublish type: object default: @@ -103,6 +112,10 @@ jobs: ${{ else }}: MSBuildMainBuildTargets: Build ${{ insert }}: ${{ parameters.variables }} + ${{ if eq(parameters.useLatestWinAppSDK, true) }}: + RestoreAdditionalProjectSourcesArg: '/p:RestoreAdditionalProjectSources="$(Build.SourcesDirectory)\localpackages\NugetPackages"' + ${{ else }}: + RestoreAdditionalProjectSourcesArg: '' displayName: Build timeoutInMinutes: 240 cancelTimeoutInMinutes: 1 @@ -135,6 +148,11 @@ jobs: sdk: true version: '6.0' + - template: steps-ensure-dotnet-version.yml + parameters: + sdk: true + version: '8.0' + - template: steps-ensure-dotnet-version.yml parameters: sdk: true @@ -178,8 +196,15 @@ jobs: "packages.config" | "$(Agent.OS)" "packages.config" path: packages - - - template: .\steps-restore-nuget.yml + + - ${{ if eq(parameters.useLatestWinAppSDK, true)}}: + - template: .\steps-update-winappsdk-and-restore-nuget.yml + parameters: + versionNumber: ${{ parameters.winAppSDKVersionNumber }} + useExperimentalVersion: ${{ parameters.useExperimentalVersion }} + + - ${{ if eq(parameters.useLatestWinAppSDK, false)}}: + - template: .\steps-restore-nuget.yml - pwsh: |- & "$(build.sourcesdirectory)\.pipelines\verifyAndSetLatestVCToolsVersion.ps1" @@ -210,6 +235,7 @@ jobs: ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) /t:$(MSBuildMainBuildTargets) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -267,6 +293,7 @@ jobs: /bl:$(LogOutputDirectory)\build-bug-report.binlog ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -287,6 +314,7 @@ jobs: /bl:$(LogOutputDirectory)\build-webcam-report.binlog ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -307,6 +335,7 @@ jobs: /bl:$(LogOutputDirectory)\build-styles-report.binlog ${{ parameters.additionalBuildOptions }} $(MSBuildCacheParameters) + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -329,6 +358,7 @@ jobs: /p:PowerToysRoot=$(Build.SourcesDirectory) /p:PublishProfile=InstallationPublishProfile.pubxml /bl:$(LogOutputDirectory)\publish-${{ join('_',split(project, '/')) }}.binlog + $(RestoreAdditionalProjectSourcesArg) platform: $(BuildPlatform) configuration: $(BuildConfiguration) msbuildArchitecture: x64 @@ -358,9 +388,11 @@ jobs: & '.pipelines/verifyPossibleAssetConflicts.ps1' -targetDir '$(build.sourcesdirectory)\$(BuildPlatform)\$(BuildConfiguration)\WinUI3Apps' displayName: Audit WinAppSDK applications path asset conflicts - - pwsh: |- - & '.pipelines/verifyNoticeMdAgainstNugetPackages.ps1' -path '$(build.sourcesdirectory)\' - displayName: Verify NOTICE.md and NuGet packages match + # To streamline the pipeline and prevent errors, skip this step during compatibility tests with the latest WinAppSDK. + - ${{ if eq(parameters.useLatestWinAppSDK, false) }}: + - pwsh: |- + & '.pipelines/verifyNoticeMdAgainstNugetPackages.ps1' -path '$(build.sourcesdirectory)\' + displayName: Verify NOTICE.md and NuGet packages match - ${{ if eq(parameters.runTests, true) }}: # Publish test results which ran in MSBuild diff --git a/.pipelines/v2/templates/job-fuzz.yml b/.pipelines/v2/templates/job-fuzz.yml new file mode 100644 index 0000000000..b4e380194e --- /dev/null +++ b/.pipelines/v2/templates/job-fuzz.yml @@ -0,0 +1,36 @@ +parameters: + - name: configuration + type: string + default: "Release" + - name: platform + type: string + default: "" + - name: inputArtifactStem + type: string + default: "" + +jobs: + - job: OneFuzz + pool: + vmImage: windows-2022 + variables: + ArtifactName: build-${{ parameters.platform }}-${{ parameters.configuration }}${{ parameters.inputArtifactStem }} + steps: + - checkout: self + submodules: false + clean: true + fetchDepth: 1 + fetchTags: false + + - download: current + displayName: Download artifacts + artifact: $(ArtifactName) + patterns: |- + **/tests/*.FuzzTests/** + + - task: onefuzz-task@0 + inputs: + onefuzzOSes: Windows + env: + onefuzzDropDirectory: $(Pipeline.Workspace)\$(ArtifactName)\x64\Release\x64\Release\tests + SYSTEM_ACCESSTOKEN: $(System.AccessToken) diff --git a/.pipelines/v2/templates/job-test-project.yml b/.pipelines/v2/templates/job-test-project.yml index 212dbeccd8..0bf4641e42 100644 --- a/.pipelines/v2/templates/job-test-project.yml +++ b/.pipelines/v2/templates/job-test-project.yml @@ -8,6 +8,9 @@ parameters: - name: inputArtifactStem type: string default: "" + - name: useLatestWebView2 + type: boolean + default: false jobs: - job: Test${{ parameters.platform }}${{ parameters.configuration }} @@ -34,6 +37,29 @@ jobs: fetchDepth: 1 fetchTags: false + - ${{ if eq(parameters.useLatestWebView2, true) }}: + - powershell: | + $edge_url = 'https://go.microsoft.com/fwlink/?linkid=2084649&Channel=Canary&language=en' + $timeout = New-TimeSpan -Minutes 6 + $timeoutSeconds = [int]$timeout.TotalSeconds + $command = { + Invoke-WebRequest -Uri $using:edge_url -OutFile $(Pipeline.Workspace)\MicrosoftEdgeSetup.exe + Write-Host "##[command]Installing Canary channel of Microsoft Edge" + Start-Process $(Pipeline.Workspace)\MicrosoftEdgeSetup.exe -ArgumentList '/silent /install' -Wait + } + + $job = Start-Job -ScriptBlock $command + Wait-Job $job -Timeout $timeoutSeconds + if ($job.State -eq "Running") { + Stop-Job $job + Write-Host "##[warning]The job was stopped because it exceeded the time limit." + } + displayName: "Install the latest MSEdge Canary" + + - script: + reg add "HKLM\Software\Policies\Microsoft\Edge\WebView2\ReleaseChannels" /v PowerToys.exe /t REG_SZ /d "3" + displayName: "Enable WebView2 Canary Channel" + - download: current displayName: Download artifacts artifact: build-${{ parameters.platform }}-${{ parameters.configuration }}${{ parameters.inputArtifactStem }} diff --git a/.pipelines/v2/templates/pipeline-ci-build.yml b/.pipelines/v2/templates/pipeline-ci-build.yml index 71ebd6a33b..8183b50c02 100644 --- a/.pipelines/v2/templates/pipeline-ci-build.yml +++ b/.pipelines/v2/templates/pipeline-ci-build.yml @@ -22,6 +22,18 @@ parameters: - name: useVSPreview type: boolean default: false + - name: useLatestWebView2 + type: boolean + default: false + - name: useLatestWinAppSDK + type: boolean + default: false + - name: winAppSDKVersionNumber + type: string + default: 1.6 + - name: useExperimentalVersion + type: boolean + default: false stages: # Allow manual builds to skip pre-check @@ -55,6 +67,10 @@ stages: enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }} runTests: ${{ parameters.runTests }} useVSPreview: ${{ parameters.useVSPreview }} + useLatestWinAppSDK: ${{ parameters.useLatestWinAppSDK }} + ${{ if eq(parameters.useLatestWinAppSDK, true) }}: + winAppSDKVersionNumber: ${{ parameters.winAppSDKVersionNumber }} + useExperimentalVersion: ${{ parameters.useExperimentalVersion }} - ${{ if eq(parameters.runTests, true) }}: - stage: Test_${{ platform }} @@ -66,3 +82,4 @@ stages: parameters: platform: ${{ platform }} configuration: Release + useLatestWebView2: ${{ parameters.useLatestWebView2 }} diff --git a/.pipelines/v2/templates/steps-ensure-dotnet-version.yml b/.pipelines/v2/templates/steps-ensure-dotnet-version.yml index c3204d065a..b327b8004f 100644 --- a/.pipelines/v2/templates/steps-ensure-dotnet-version.yml +++ b/.pipelines/v2/templates/steps-ensure-dotnet-version.yml @@ -16,6 +16,10 @@ parameters: steps: - pwsh: |- curl.exe -J -L -O "https://dot.net/v1/dotnet-install.ps1" + if (-not (Test-Path dotnet-install.ps1)) { + Write-Error "Failed to download dotnet-install.ps1" + exit 1 + } $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" & ./dotnet-install.ps1 -Channel "${{parameters.version}}" -InstallDir $NEW_DOTNET_ROOT Write-Host "##vso[task.setvariable variable=DOTNET_ROOT]${NEW_DOTNET_ROOT}" @@ -25,3 +29,4 @@ steps: displayName: "Install .NET ${{parameters.version}} SDK" ${{ else }}: displayName: "Install .NET ${{parameters.version}}" + retryCountOnTaskFailure: 3 diff --git a/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml new file mode 100644 index 0000000000..1fccd6de74 --- /dev/null +++ b/.pipelines/v2/templates/steps-update-winappsdk-and-restore-nuget.yml @@ -0,0 +1,56 @@ +parameters: + - name: versionNumber + type: string + default: 1.6 + - name: useExperimentalVersion + type: boolean + default: false + +steps: +- task: NuGetAuthenticate@1 + displayName: 'NuGet Authenticate' + +- task: PowerShell@2 + displayName: Update WinAppSDK Versions + inputs: + filePath: '$(build.sourcesdirectory)\.pipelines\UpdateVersions.ps1' + arguments: > + -winAppSdkVersionNumber ${{ parameters.versionNumber }} + -useExperimentalVersion $${{ parameters.useExperimentalVersion }} + +- script: echo $(WinAppSDKVersion) + displayName: 'Display WinAppSDK Version Found' + +- task: DownloadPipelineArtifact@2 + displayName: 'Download WindowsAppSDK' + inputs: + buildType: 'specific' + project: '55e8140e-57ac-4e5f-8f9c-c7c15b51929d' + definition: '104083' + buildVersionToDownload: 'latestFromBranch' + branchName: 'refs/heads/release/${{ parameters.versionNumber }}-stable' + artifactName: 'WindowsAppSDK_Nuget_And_MSIX' + targetPath: '$(Build.SourcesDirectory)\localpackages' + +- script: dir $(Build.SourcesDirectory)\localpackages\NugetPackages + displayName: 'List downloaded packages' + +- task: NuGetCommand@2 + displayName: 'Install WindowsAppSDK' + inputs: + command: 'custom' + arguments: > + install "Microsoft.WindowsAppSDK" + -Source "$(Build.SourcesDirectory)\localpackages\NugetPackages" + -Version "$(WinAppSDKVersion)" + -OutputDirectory "$(Build.SourcesDirectory)\localpackages\output" + -FallbackSource "https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json" + +- task: NuGetCommand@2 + displayName: 'Restore NuGet packages' + inputs: + command: 'restore' + feedsToUse: 'config' + nugetConfigPath: '$(build.sourcesdirectory)\nuget.config' + restoreSolution: '$(build.sourcesdirectory)\**\*.sln' + includeNuGetOrg: false \ No newline at end of file diff --git a/.pipelines/verifyDepsJsonLibraryVersions.ps1 b/.pipelines/verifyDepsJsonLibraryVersions.ps1 index 7d5fc02c10..3837514b46 100644 --- a/.pipelines/verifyDepsJsonLibraryVersions.ps1 +++ b/.pipelines/verifyDepsJsonLibraryVersions.ps1 @@ -15,7 +15,7 @@ Param( $referencedFileVersionsPerDll = @{} $totalFailures = 0 -Get-ChildItem $targetDir -Recurse -Filter *.deps.json -Exclude UITests-FancyZones*,MouseJump.Common.UnitTests* | ForEach-Object { +Get-ChildItem $targetDir -Recurse -Filter *.deps.json -Exclude UITests-FancyZones*,MouseJump.Common.UnitTests*,AdvancedPaste.FuzzTests* | ForEach-Object { # Temporarily exclude FancyZones UI tests because of Appium.WebDriver dependencies $depsJsonFullFileName = $_.FullName $depsJsonFileName = $_.Name diff --git a/COMMUNITY.md b/COMMUNITY.md index d992c09ba4..64d77c9f37 100644 --- a/COMMUNITY.md +++ b/COMMUNITY.md @@ -181,6 +181,14 @@ Other contributors: - [@shuaiyuanxx](https://github.com/shuaiyuanxx) - Shawn Yuan - Dev - [@moooyo](https://github.com/moooyo) - Yu Leng - Dev - [@haoliuu](https://github.com/haoliuu) - Hao Liu - Dev +- [@chenmy77](https://github.com/chenmy77) - Mengyuan Chen - Dev +- [@chemwolf6922](https://github.com/chemwolf6922) - Feng Wang - Dev +- [@yaqingmi](https://github.com/yaqingmi) - Yaqing Mi - Dev +- [@zhaoqpcn](https://github.com/zhaoqpcn) - Qingpeng Zhao - Dev +- [@urnotdfs](https://github.com/urnotdfs) - Xiaofeng Wang - Dev +- [@zhaopy536](https://github.com/zhaopy536) - Peiyao Zhao - Dev +- [@wang563681252](https://github.com/wang563681252) - Zhaopeng Wang - Dev +- [@vanzue](https://github.com/vanzue) - Kai Tao - Dev # Former PowerToys core team members diff --git a/Directory.Packages.props b/Directory.Packages.props index 0db5ef1bad..6bc26b40f3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -20,9 +20,6 @@ - - - @@ -30,7 +27,7 @@ - + diff --git a/NOTICE.md b/NOTICE.md index 17b86e6280..6530938112 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -1302,7 +1302,8 @@ EXHIBIT A -Mozilla Public License. - AdaptiveCards.Templating 2.0.2 - Appium.WebDriver 4.4.5 - Azure.AI.OpenAI 1.0.0-beta.17 -- CommunityToolkit.Mvvm 8.4.0-preview2 +- CommunityToolkit.Common 8.4.0 +- CommunityToolkit.Mvvm 8.4.0 - CommunityToolkit.WinUI.Animations 8.2.241112-preview1 - CommunityToolkit.WinUI.Collections 8.2.241112-preview1 - CommunityToolkit.WinUI.Controls.Primitives 8.2.241112-preview1 @@ -1320,7 +1321,7 @@ EXHIBIT A -Mozilla Public License. - hyjiacan.pinyin4net 4.1.1 - Interop.Microsoft.Office.Interop.OneNote 1.1.0.2 - LazyCache 2.4.0 -- Mages 2.0.2 +- Mages 3.0.0 - Markdig.Signed 0.34.0 - MessagePack 2.5.187 - Microsoft.Bcl.AsyncInterfaces 9.0.0 diff --git a/PowerToys.sln b/PowerToys.sln index 00ab0d1eb1..cb692338c5 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -179,7 +179,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Build.targets = Directory.Build.targets Directory.Packages.props = Directory.Packages.props src\Monaco.props = src\Monaco.props - Solution.props = Solution.props + src\Solution.props = src\Solution.props src\Version.props = src\Version.props EndProjectSection EndProject @@ -715,6 +715,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.Ext.Window EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedPaste.UnitTests", "src\modules\AdvancedPaste\AdvancedPaste.UnitTests\AdvancedPaste.UnitTests.csproj", "{D5E5F5EA-1B6C-4A73-88BE-304F36C9E4EE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedPaste.FuzzTests", "src\modules\AdvancedPaste\AdvancedPaste.FuzzTests\AdvancedPaste.FuzzTests.csproj", "{7F5B9557-5878-4438-A721-3E28296BA193}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -3379,6 +3381,18 @@ Global {453CBB73-A3CB-4D0B-8D24-6940B86FE21D}.Release|x86.ActiveCfg = Release|x64 {453CBB73-A3CB-4D0B-8D24-6940B86FE21D}.Release|x86.Build.0 = Release|x64 {453CBB73-A3CB-4D0B-8D24-6940B86FE21D}.Release|x86.Deploy.0 = Release|x64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Debug|ARM64.Build.0 = Debug|ARM64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Debug|x64.ActiveCfg = Debug|x64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Debug|x64.Build.0 = Debug|x64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Debug|x86.ActiveCfg = Debug|x64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Debug|x86.Build.0 = Debug|x64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Release|ARM64.ActiveCfg = Release|ARM64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Release|ARM64.Build.0 = Release|ARM64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Release|x64.ActiveCfg = Release|x64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Release|x64.Build.0 = Release|x64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Release|x86.ActiveCfg = Release|x64 + {7F5B9557-5878-4438-A721-3E28296BA193}.Release|x86.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3652,6 +3666,7 @@ Global {0DB0F63A-D2F8-4DA3-A650-2D0B8724218E} = {CA716AE6-FE5C-40AC-BB8F-2C87912687AC} {3A9A7297-92C4-4F16-B6F9-8D4AB652C86C} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2} {D5E5F5EA-1B6C-4A73-88BE-304F36C9E4EE} = {9873BA05-4C41-4819-9283-CF45D795431B} + {7F5B9557-5878-4438-A721-3E28296BA193} = {9873BA05-4C41-4819-9283-CF45D795431B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0} diff --git a/README.md b/README.md index 4bc45824cf..df5b8acb10 100644 --- a/README.md +++ b/README.md @@ -42,17 +42,17 @@ Go to the [Microsoft PowerToys GitHub releases page][github-release-link] and cl [github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.88%22 [github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+milestone%3A%22PowerToys+0.87%22 -[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.87.0/PowerToysUserSetup-0.87.0-x64.exe -[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.87.0/PowerToysUserSetup-0.87.0-arm64.exe -[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.87.0/PowerToysSetup-0.87.0-x64.exe -[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.87.0/PowerToysSetup-0.87.0-arm64.exe - +[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.87.1/PowerToysUserSetup-0.87.1-x64.exe +[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.87.1/PowerToysUserSetup-0.87.1-arm64.exe +[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.87.1/PowerToysSetup-0.87.1-x64.exe +[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.87.1/PowerToysSetup-0.87.1-arm64.exe + | Description | Filename | sha256 hash | |----------------|----------|-------------| -| Per user - x64 | [PowerToysUserSetup-0.87.0-x64.exe][ptUserX64] | A6549B8D78985CC995F091624D1A2B70907CAC8954334C1CAF61D26EBCF8A449 | -| Per user - ARM64 | [PowerToysUserSetup-0.87.0-arm64.exe][ptUserArm64] | 3557D4F35AA52571334712A48F51D116F389FA8C43C6B27FE321A7525067E7AE | -| Machine wide - x64 | [PowerToysSetup-0.87.0-x64.exe][ptMachineX64] | 600CDC7F9AC296AA8B554CA34A0C7EA2D9B1E7E8E41BD096840851B416E63A3C | -| Machine wide - ARM64 | [PowerToysSetup-0.87.0-arm64.exe][ptMachineArm64] | 387B5BF1BD923BDA215D7DF1D82A197AE12CD91A71A73267768E26757F7A5FE6 | +| Per user - x64 | [PowerToysUserSetup-0.87.1-x64.exe][ptUserX64] | 8EFAF47ED00BF230D2C2CC3CB6765C903A6A47E0AAED0BBB329CEF918207B486 | +| Per user - ARM64 | [PowerToysUserSetup-0.87.1-arm64.exe][ptUserArm64] | 212FC8055789BD2DC4DE554B9AEE291A9C077907E263A302939266263A9D512B | +| Machine wide - x64 | [PowerToysSetup-0.87.1-x64.exe][ptMachineX64] | 69AD65DDAC6436AEF292D2CC6AB1530021CE98083CB3F5FD3380A52A3B0DBB9A | +| Machine wide - ARM64 | [PowerToysSetup-0.87.1-arm64.exe][ptMachineArm64] | AEC9F1D02F1E23F0C1FCFDF95C337C962902394F44C0568012DF78BEDB45CF19 | This is our preferred method. diff --git a/doc/devdocs/modules/launcher/new-plugin-checklist.md b/doc/devdocs/modules/launcher/new-plugin-checklist.md index 7287e4305e..e1bb7fae09 100644 --- a/doc/devdocs/modules/launcher/new-plugin-checklist.md +++ b/doc/devdocs/modules/launcher/new-plugin-checklist.md @@ -16,7 +16,7 @@ "Author": string, "Version": "1.0.0", // For future compatibility "Language": "csharp", // So far we support only csharp - "Website": "https://aka.ms/powertoys", + "Website": "https://aka.ms/powertoys", // Has to be an absolute uri starting with "http://" or "https://". "ExecuteFileName": string, // Should be {Type}.PowerToys.Run.Plugin.{PluginName}.dll "IcoPathDark": string, // Path to dark theme icon. The path is relative to the root plugin folder "IcoPathLight": string // Path to light theme icon. The path is relative to the root plugin folder @@ -42,3 +42,4 @@ In the PR that adds a new plugin, reference a new issue to track the work for fu - [ ] Add the resource folder to https://github.com/microsoft/PowerToys/blob/21247c0bb09a1bee3d14d6efa53d0c247f7236af/installer/PowerToysSetup/Product.wxs#L825 - [ ] Add the resource files under the section https://github.com/microsoft/PowerToys/blob/21247c0bb09a1bee3d14d6efa53d0c247f7236af/installer/PowerToysSetup/Product.wxs#L882 +- [ ] Your plugin's executable file (DLL) has to have correct version informations after building it. (This version information will be shown on the settings page.) diff --git a/src/Monaco/monacoSpecialLanguages.js b/src/Monaco/monacoSpecialLanguages.js index 7039548513..5a76713a66 100644 --- a/src/Monaco/monacoSpecialLanguages.js +++ b/src/Monaco/monacoSpecialLanguages.js @@ -7,7 +7,7 @@ import { srtDefinition } from './customLanguages/srt.js'; export async function registerAdditionalLanguages(monaco){ await languageDefinitions(); registerAdditionalLanguage("cppExt", [".ino", ".pde"], "cpp", monaco); - registerAdditionalLanguage("xmlExt", [".wsdl", ".csproj", ".vcxproj", ".vbproj", ".fsproj"], "xml", monaco); + registerAdditionalLanguage("xmlExt", [".wsdl", ".csproj", ".vcxproj", ".vbproj", ".fsproj", ".resx", ".resw"], "xml", monaco); registerAdditionalLanguage("txtExt", [".sln", ".log", ".vsconfig", ".env", ".ahk", ".ion"], "txt", monaco); registerAdditionalLanguage("razorExt", [".razor"], "razor", monaco); registerAdditionalLanguage("vbExt", [".vbs"], "vb", monaco); diff --git a/src/Monaco/monaco_languages.json b/src/Monaco/monaco_languages.json index 027e3ffc42..8f0408dc9b 100644 --- a/src/Monaco/monaco_languages.json +++ b/src/Monaco/monaco_languages.json @@ -1 +1 @@ -{"list":[{"id":"plaintext","extensions":[".txt"],"aliases":["Plain Text","text"],"mimetypes":["text/plain"]},{"id":"abap","extensions":[".abap"],"aliases":["abap","ABAP"]},{"id":"apex","extensions":[".cls"],"aliases":["Apex","apex"],"mimetypes":["text/x-apex-source","text/x-apex"]},{"id":"azcli","extensions":[".azcli"],"aliases":["Azure CLI","azcli"]},{"id":"bat","extensions":[".bat",".cmd"],"aliases":["Batch","bat"]},{"id":"bicep","extensions":[".bicep"],"aliases":["Bicep"]},{"id":"cameligo","extensions":[".mligo"],"aliases":["Cameligo"]},{"id":"clojure","extensions":[".clj",".cljs",".cljc",".edn"],"aliases":["clojure","Clojure"]},{"id":"coffeescript","extensions":[".coffee"],"aliases":["CoffeeScript","coffeescript","coffee"],"mimetypes":["text/x-coffeescript","text/coffeescript"]},{"id":"c","extensions":[".c",".h"],"aliases":["C","c"]},{"id":"cpp","extensions":[".cpp",".cc",".cxx",".hpp",".hh",".hxx"],"aliases":["C++","Cpp","cpp"]},{"id":"csharp","extensions":[".cs",".csx",".cake"],"aliases":["C#","csharp"]},{"id":"csp","extensions":[],"aliases":["CSP","csp"]},{"id":"css","extensions":[".css"],"aliases":["CSS","css"],"mimetypes":["text/css"]},{"id":"cypher","extensions":[".cypher",".cyp"],"aliases":["Cypher","OpenCypher"]},{"id":"dart","extensions":[".dart"],"aliases":["Dart","dart"],"mimetypes":["text/x-dart-source","text/x-dart"]},{"id":"dockerfile","extensions":[".dockerfile"],"filenames":["Dockerfile"],"aliases":["Dockerfile"]},{"id":"ecl","extensions":[".ecl"],"aliases":["ECL","Ecl","ecl"]},{"id":"elixir","extensions":[".ex",".exs"],"aliases":["Elixir","elixir","ex"]},{"id":"flow9","extensions":[".flow"],"aliases":["Flow9","Flow","flow9","flow"]},{"id":"fsharp","extensions":[".fs",".fsi",".ml",".mli",".fsx",".fsscript"],"aliases":["F#","FSharp","fsharp"]},{"id":"freemarker2","extensions":[".ftl",".ftlh",".ftlx"],"aliases":["FreeMarker2","Apache FreeMarker2"]},{"id":"freemarker2.tag-angle.interpolation-dollar","aliases":["FreeMarker2 (Angle/Dollar)","Apache FreeMarker2 (Angle/Dollar)"]},{"id":"freemarker2.tag-bracket.interpolation-dollar","aliases":["FreeMarker2 (Bracket/Dollar)","Apache FreeMarker2 (Bracket/Dollar)"]},{"id":"freemarker2.tag-angle.interpolation-bracket","aliases":["FreeMarker2 (Angle/Bracket)","Apache FreeMarker2 (Angle/Bracket)"]},{"id":"freemarker2.tag-bracket.interpolation-bracket","aliases":["FreeMarker2 (Bracket/Bracket)","Apache FreeMarker2 (Bracket/Bracket)"]},{"id":"freemarker2.tag-auto.interpolation-dollar","aliases":["FreeMarker2 (Auto/Dollar)","Apache FreeMarker2 (Auto/Dollar)"]},{"id":"freemarker2.tag-auto.interpolation-bracket","aliases":["FreeMarker2 (Auto/Bracket)","Apache FreeMarker2 (Auto/Bracket)"]},{"id":"go","extensions":[".go"],"aliases":["Go"]},{"id":"graphql","extensions":[".graphql",".gql"],"aliases":["GraphQL","graphql","gql"],"mimetypes":["application/graphql"]},{"id":"handlebars","extensions":[".handlebars",".hbs"],"aliases":["Handlebars","handlebars","hbs"],"mimetypes":["text/x-handlebars-template"]},{"id":"hcl","extensions":[".tf",".tfvars",".hcl"],"aliases":["Terraform","tf","HCL","hcl"]},{"id":"html","extensions":[".html",".htm",".shtml",".xhtml",".mdoc",".jsp",".asp",".aspx",".jshtm"],"aliases":["HTML","htm","html","xhtml"],"mimetypes":["text/html","text/x-jshtm","text/template","text/ng-template"]},{"id":"ini","extensions":[".ini",".properties",".gitconfig"],"filenames":["config",".gitattributes",".gitconfig",".editorconfig"],"aliases":["Ini","ini"]},{"id":"java","extensions":[".java",".jav"],"aliases":["Java","java"],"mimetypes":["text/x-java-source","text/x-java"]},{"id":"javascript","extensions":[".js",".es6",".jsx",".mjs",".cjs"],"firstLine":"^#!.*\\bnode","filenames":["jakefile"],"aliases":["JavaScript","javascript","js"],"mimetypes":["text/javascript"]},{"id":"julia","extensions":[".jl"],"aliases":["julia","Julia"]},{"id":"kotlin","extensions":[".kt",".kts"],"aliases":["Kotlin","kotlin"],"mimetypes":["text/x-kotlin-source","text/x-kotlin"]},{"id":"less","extensions":[".less"],"aliases":["Less","less"],"mimetypes":["text/x-less","text/less"]},{"id":"lexon","extensions":[".lex"],"aliases":["Lexon"]},{"id":"lua","extensions":[".lua"],"aliases":["Lua","lua"]},{"id":"liquid","extensions":[".liquid",".html.liquid"],"aliases":["Liquid","liquid"],"mimetypes":["application/liquid"]},{"id":"m3","extensions":[".m3",".i3",".mg",".ig"],"aliases":["Modula-3","Modula3","modula3","m3"]},{"id":"markdown","extensions":[".md",".markdown",".mdown",".mkdn",".mkd",".mdwn",".mdtxt",".mdtext"],"aliases":["Markdown","markdown"]},{"id":"mdx","extensions":[".mdx"],"aliases":["MDX","mdx"]},{"id":"mips","extensions":[".s"],"aliases":["MIPS","MIPS-V"],"mimetypes":["text/x-mips","text/mips","text/plaintext"]},{"id":"msdax","extensions":[".dax",".msdax"],"aliases":["DAX","MSDAX"]},{"id":"mysql","extensions":[],"aliases":["MySQL","mysql"]},{"id":"objective-c","extensions":[".m"],"aliases":["Objective-C"]},{"id":"pascal","extensions":[".pas",".p",".pp"],"aliases":["Pascal","pas"],"mimetypes":["text/x-pascal-source","text/x-pascal"]},{"id":"pascaligo","extensions":[".ligo"],"aliases":["Pascaligo","ligo"]},{"id":"perl","extensions":[".pl",".pm"],"aliases":["Perl","pl"]},{"id":"pgsql","extensions":[],"aliases":["PostgreSQL","postgres","pg","postgre"]},{"id":"php","extensions":[".php",".php4",".php5",".phtml",".ctp"],"aliases":["PHP","php"],"mimetypes":["application/x-php"]},{"id":"pla","extensions":[".pla"]},{"id":"postiats","extensions":[".dats",".sats",".hats"],"aliases":["ATS","ATS/Postiats"]},{"id":"powerquery","extensions":[".pq",".pqm"],"aliases":["PQ","M","Power Query","Power Query M"]},{"id":"powershell","extensions":[".ps1",".psm1",".psd1"],"aliases":["PowerShell","powershell","ps","ps1"]},{"id":"proto","extensions":[".proto"],"aliases":["protobuf","Protocol Buffers"]},{"id":"pug","extensions":[".jade",".pug"],"aliases":["Pug","Jade","jade"]},{"id":"python","extensions":[".py",".rpy",".pyw",".cpy",".gyp",".gypi"],"aliases":["Python","py"],"firstLine":"^#!/.*\\bpython[0-9.-]*\\b"},{"id":"qsharp","extensions":[".qs"],"aliases":["Q#","qsharp"]},{"id":"r","extensions":[".r",".rhistory",".rmd",".rprofile",".rt"],"aliases":["R","r"]},{"id":"razor","extensions":[".cshtml"],"aliases":["Razor","razor"],"mimetypes":["text/x-cshtml"]},{"id":"redis","extensions":[".redis"],"aliases":["redis"]},{"id":"redshift","extensions":[],"aliases":["Redshift","redshift"]},{"id":"restructuredtext","extensions":[".rst"],"aliases":["reStructuredText","restructuredtext"]},{"id":"ruby","extensions":[".rb",".rbx",".rjs",".gemspec",".pp"],"filenames":["rakefile","Gemfile"],"aliases":["Ruby","rb"]},{"id":"rust","extensions":[".rs",".rlib"],"aliases":["Rust","rust"]},{"id":"sb","extensions":[".sb"],"aliases":["Small Basic","sb"]},{"id":"scala","extensions":[".scala",".sc",".sbt"],"aliases":["Scala","scala","SBT","Sbt","sbt","Dotty","dotty"],"mimetypes":["text/x-scala-source","text/x-scala","text/x-sbt","text/x-dotty"]},{"id":"scheme","extensions":[".scm",".ss",".sch",".rkt"],"aliases":["scheme","Scheme"]},{"id":"scss","extensions":[".scss"],"aliases":["Sass","sass","scss"],"mimetypes":["text/x-scss","text/scss"]},{"id":"shell","extensions":[".sh",".bash"],"aliases":["Shell","sh"]},{"id":"sol","extensions":[".sol"],"aliases":["sol","solidity","Solidity"]},{"id":"aes","extensions":[".aes"],"aliases":["aes","sophia","Sophia"]},{"id":"sparql","extensions":[".rq"],"aliases":["sparql","SPARQL"]},{"id":"sql","extensions":[".sql"],"aliases":["SQL"]},{"id":"st","extensions":[".st",".iecst",".iecplc",".lc3lib",".TcPOU",".TcDUT",".TcGVL",".TcIO"],"aliases":["StructuredText","scl","stl"]},{"id":"swift","aliases":["Swift","swift"],"extensions":[".swift"],"mimetypes":["text/swift"]},{"id":"systemverilog","extensions":[".sv",".svh"],"aliases":["SV","sv","SystemVerilog","systemverilog"]},{"id":"verilog","extensions":[".v",".vh"],"aliases":["V","v","Verilog","verilog"]},{"id":"tcl","extensions":[".tcl"],"aliases":["tcl","Tcl","tcltk","TclTk","tcl/tk","Tcl/Tk"]},{"id":"twig","extensions":[".twig"],"aliases":["Twig","twig"],"mimetypes":["text/x-twig"]},{"id":"typescript","extensions":[".ts",".tsx",".cts",".mts"],"aliases":["TypeScript","ts","typescript"],"mimetypes":["text/typescript"]},{"id":"vb","extensions":[".vb"],"aliases":["Visual Basic","vb"]},{"id":"wgsl","extensions":[".wgsl"],"aliases":["WebGPU Shading Language","WGSL","wgsl"]},{"id":"xml","extensions":[".xml",".xsd",".dtd",".ascx",".csproj",".config",".props",".targets",".wxi",".wxl",".wxs",".xaml",".svg",".svgz",".opf",".xslt",".xsl"],"firstLine":"(\\<\\?xml.*)|(\\ + PowerToys FilePreviewCommon diff --git a/src/common/FilePreviewCommon/Formatters/FilePreviewJsonSerializerContext.cs b/src/common/FilePreviewCommon/Formatters/FilePreviewJsonSerializerContext.cs new file mode 100644 index 0000000000..c6d5961407 --- /dev/null +++ b/src/common/FilePreviewCommon/Formatters/FilePreviewJsonSerializerContext.cs @@ -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; +using System.Text.Json.Serialization; + +namespace Microsoft.PowerToys.FilePreviewCommon.Monaco.Formatters; + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(JsonDocument))] +internal sealed partial class FilePreviewJsonSerializerContext : JsonSerializerContext +{ +} diff --git a/src/common/FilePreviewCommon/Formatters/JsonFormatter.cs b/src/common/FilePreviewCommon/Formatters/JsonFormatter.cs index 91b7013c6f..7d969db56d 100644 --- a/src/common/FilePreviewCommon/Formatters/JsonFormatter.cs +++ b/src/common/FilePreviewCommon/Formatters/JsonFormatter.cs @@ -14,7 +14,6 @@ namespace Microsoft.PowerToys.FilePreviewCommon.Monaco.Formatters private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions { - WriteIndented = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, }; @@ -28,7 +27,8 @@ namespace Microsoft.PowerToys.FilePreviewCommon.Monaco.Formatters using (var jDocument = JsonDocument.Parse(value, new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip })) { - return JsonSerializer.Serialize(jDocument, _serializerOptions); + FilePreviewJsonSerializerContext context = new(_serializerOptions); + return JsonSerializer.Serialize(jDocument, context.JsonDocument); } } } diff --git a/src/common/FilePreviewCommon/MonacoHelper.cs b/src/common/FilePreviewCommon/MonacoHelper.cs index e8442c0bff..303cacbde2 100644 --- a/src/common/FilePreviewCommon/MonacoHelper.cs +++ b/src/common/FilePreviewCommon/MonacoHelper.cs @@ -6,9 +6,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Reflection; using System.Text.Json; - using Microsoft.PowerToys.FilePreviewCommon.Monaco.Formatters; namespace Microsoft.PowerToys.FilePreviewCommon @@ -38,15 +36,15 @@ namespace Microsoft.PowerToys.FilePreviewCommon private static string GetRuntimeMonacoDirectory() { - string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty; + string baseDirectory = AppContext.BaseDirectory ?? string.Empty; // If the executable is within "WinUI3Apps", correct the path first. - if (Path.GetFileName(exePath) == "WinUI3Apps") + if (Path.GetFileName(baseDirectory) == "WinUI3Apps") { - exePath = Path.Combine(exePath, ".."); + baseDirectory = Path.Combine(baseDirectory, ".."); } - string monacoPath = Path.Combine(exePath, "Assets", "Monaco"); + string monacoPath = Path.Combine(baseDirectory, "Assets", "Monaco"); return Directory.Exists(monacoPath) ? monacoPath : diff --git a/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/AdvancedPaste.FuzzTests.csproj b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/AdvancedPaste.FuzzTests.csproj new file mode 100644 index 0000000000..f22ee39381 --- /dev/null +++ b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/AdvancedPaste.FuzzTests.csproj @@ -0,0 +1,26 @@ + + + net8.0-windows10.0.19041.0 + latest + enable + enable + + + ..\..\..\..\$(Platform)\$(Configuration)\tests\AdvancedPaste.FuzzTests\ + + + + + + + + + + + + + + PreserveNewest + + + diff --git a/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/Fuzz.md b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/Fuzz.md new file mode 100644 index 0000000000..7e83a77b8f --- /dev/null +++ b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/Fuzz.md @@ -0,0 +1,45 @@ +# Fuzzing .NET Code with OneFuzz + +This document explains the purpose of the project, the rationale for using specific technologies, and key instructions for fuzz testing .NET code using OneFuzz. + +## Overview + +This project demonstrates fuzz testing for .NET applications. It uses a `.NET 8 (Windows)` project where a code file is linked to the project. The linked file contains the functions required for fuzz testing. + +## Why Use .NET 8 (Windows)? + +1. **Current Support**: At the time of writing, OneFuzz supports only .NET 8 projects. The Fuzz team is actively working on .NET 9 support. +2. **Interim Solution**: Until .NET 9 support is available, .NET 8 serves as a robust and temporary solution for fuzz testing, enabling direct code linking for efficient development. + +## Requesting Access + +To log into the production instance of OneFuzz with the CLI, you **must request access**. Visit the internal [OneFuzz Access Request Page](https://myaccess.microsoft.com/@microsoft.onmicrosoft.com#/access-packages/6df691eb-e3d1-444b-b4b2-9e944dc794be) for details. + +## How to Fuzz .NET Code + +To set up and run fuzz testing on .NET code, follow the detailed guide available [Fuzz .NET Code](https://eng.ms/docs/cloud-ai-platform/azure-edge-platform-aep/aep-security/epsf-edge-and-platform-security-fundamentals/the-onefuzz-service/onefuzz/howto/fuzzing-dotnet-code). + +## Running a .NET Fuzz Target Locally + +Testing a .NET fuzz target locally requires specific configurations. For a step-by-step guide, see the section on [Running a .NET Fuzz Target Locally](https://eng.ms/docs/cloud-ai-platform/azure-edge-platform-aep/aep-security/epsf-edge-and-platform-security-fundamentals/the-onefuzz-service/onefuzz/howto/fuzzing-dotnet-code#extra-running-a-net-fuzz-target-locally). + +## Writing a Good OneFuzzConfig.json + +The `OneFuzzConfig.json` file provides critical information for deploying fuzzing jobs using the OneFuzz Ingestion Preparation Tool and Ingestion Service. + +### Structure + +The primary structure is an array of configuration entries. Outside the array, the `configVersion` field is used to track changes to the configuration schema. + +For more details on how to write and structure this file, see the [OneFuzzConfig V3 Documentation](https://eng.ms/docs/cloud-ai-platform/azure-edge-platform-aep/aep-security/epsf-edge-and-platform-security-fundamentals/the-onefuzz-service/onefuzz/onefuzzconfig/onefuzzconfigv3). + +## Tools + +### OneFuzz Ingestion Preparation (OIP) Tool + +The OIP tool helps prepare data for ingestion and fuzz testing. Learn more about [OneFuzz Ingestion Preparation (OIP) Tool](https://eng.ms/docs/cloud-ai-platform/azure-edge-platform-aep/aep-security/epsf-edge-and-platform-security-fundamentals/the-onefuzz-service/onefuzz/oip/onefuzzingestionpreparationtool). + +### OneFuzz CLI + +The CLI provides commands to manage and execute fuzzing jobs. Download and set up the CLI by following this [guide](https://eng.ms/docs/cloud-ai-platform/azure-edge-platform-aep/aep-security/epsf-edge-and-platform-security-fundamentals/the-onefuzz-service/onefuzz/howto/downloading-cli). + diff --git a/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/FuzzTests.cs b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/FuzzTests.cs new file mode 100644 index 0000000000..a23618862c --- /dev/null +++ b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/FuzzTests.cs @@ -0,0 +1,32 @@ +// 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 AdvancedPaste.Helpers; +using Windows.ApplicationModel.DataTransfer; + +// OneFuzz currently does not support .NET 9 code testing, so this is a temporary solution. +// Create a .NET 8 project and use a file link to include the code for testing first. +namespace AdvancedPaste.FuzzTests +{ + public class FuzzTests + { + public static void FuzzToJsonFromXmlOrCsv(ReadOnlySpan input) + { + try + { + var dataPackage = new DataPackage(); + dataPackage.SetText(input.ToString()); + _ = Task.Run(async () => await JsonHelper.ToJsonFromXmlOrCsvAsync(dataPackage.GetView())).Result; + } + catch (Exception ex) when (ex is ArgumentException) + { + // This is an example. It's important to filter out any *expected* exceptions from our code here. + // However, catching all exceptions is considered an anti-pattern because it may suppress legitimate + // issues, such as a NullReferenceException thrown by our code. In this case, we still re-throw + // the exception, as the ToJsonFromXmlOrCsvAsync method is not expected to throw any exceptions. + throw; + } + } + } +} diff --git a/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/Logger.cs b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/Logger.cs new file mode 100644 index 0000000000..4f47fe5713 --- /dev/null +++ b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/Logger.cs @@ -0,0 +1,46 @@ +// 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; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +// This is used for fuzz testing and ensures that the project links only to JsonHelper, +// avoiding unnecessary connections to additional files +namespace ManagedCommon +{ + public static class Logger + { + // An empty method to simulate logging information + public static void LogTrace() + { + // Do nothing + } + + // An empty method to simulate logging information + public static void LogInfo(string message) + { + // Do nothing + } + + // An empty method to simulate logging warnings + public static void LogWarning(string message) + { + // Do nothing + } + + // An empty method to simulate logging errors + public static void LogError(string message, Exception? ex = null) + { + // Do nothing + } + + public static void LogDebug(string message, Exception? ex = null) + { + // Do nothing + } + } +} diff --git a/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/MSTestSettings.cs b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/MSTestSettings.cs new file mode 100644 index 0000000000..5b05c0b86e --- /dev/null +++ b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/MSTestSettings.cs @@ -0,0 +1,5 @@ +// 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. + +[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)] diff --git a/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/OneFuzzConfig.json b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/OneFuzzConfig.json new file mode 100644 index 0000000000..41bdc8c58a --- /dev/null +++ b/src/modules/AdvancedPaste/AdvancedPaste.FuzzTests/OneFuzzConfig.json @@ -0,0 +1,47 @@ +{ + "configVersion": 3, + "entries": [ + { + "fuzzer": { + "$type": "libfuzzerDotNet", + "dll": "AdvancedPaste.FuzzTests.dll", + "class": "AdvancedPaste.FuzzTests.FuzzTests", + "method": "FuzzToJsonFromXmlOrCsv", + "FuzzingTargetBinaries": [ + "PowerToys.AdvancedPaste.dll" + ] + }, + "adoTemplate": { + // supply the values appropriate to your + // project, where bugs will be filed + "org": "microsoft", + "project": "OS", + "AssignedTo": "leilzh@microsoft.com", + "AreaPath": "OS\\Windows Client and Services\\WinPD\\DEEP-Developer Experience, Ecosystem and Partnerships\\SHINE\\PowerToys", + "IterationPath": "OS\\Future" + }, + "jobNotificationEmail": "leilzh@microsoft.com", + "skip": false, + "rebootAfterSetup": false, + "oneFuzzJobs": [ + // at least one job is required + { + "projectName": "AdvancedPaste", + "targetName": "AdvancedPaste-dotnet-fuzzer" + } + ], + "jobDependencies": [ + // this should contain, at minimum, + // the DLL and PDB files + // you will need to add any other files required + // (globs are supported) + "AdvancedPaste.FuzzTests.dll", + "AdvancedPaste.FuzzTests.pdb", + "Microsoft.Windows.SDK.NET.dll", + "Newtonsoft.Json.dll", + "WinRT.Runtime.dll" + ], + "SdlWorkItemId": 49911822 + } + ] +} diff --git a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPaste.csproj b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPaste.csproj index 865921cc4d..d8bae88834 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPaste.csproj +++ b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPaste.csproj @@ -72,6 +72,8 @@ + + diff --git a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/App.xaml.cs b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/App.xaml.cs index 327558ad9f..3ac3baa9d0 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/App.xaml.cs +++ b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/App.xaml.cs @@ -263,7 +263,7 @@ namespace AdvancedPaste if (disposing) { EtwTrace?.Dispose(); - window.Dispose(); + window?.Dispose(); } disposedValue = true; diff --git a/src/modules/AdvancedPaste/AdvancedPaste/Helpers/JsonHelper.cs b/src/modules/AdvancedPaste/AdvancedPaste/Helpers/JsonHelper.cs index 2aed82f1b3..8329e15230 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste/Helpers/JsonHelper.cs +++ b/src/modules/AdvancedPaste/AdvancedPaste/Helpers/JsonHelper.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Xml; @@ -33,6 +34,19 @@ namespace AdvancedPaste.Helpers private static readonly Regex CsvRemoveStartAndEndQuotationMarksRegex = new Regex(@"^""(?=(""{2})+)|(?<=(""{2})+)""$"); private static readonly Regex CsvReplaceDoubleQuotationMarksRegex = new Regex(@"""{2}"); + private static bool IsJson(string text) + { + try + { + _ = JsonDocument.Parse(text); + return true; + } + catch (Exception) + { + return false; + } + } + internal static async Task ToJsonFromXmlOrCsvAsync(DataPackageView clipboardData) { Logger.LogTrace(); @@ -46,6 +60,12 @@ namespace AdvancedPaste.Helpers var text = await clipboardData.GetTextAsync(); string jsonText = string.Empty; + // If the text is already JSON, return it + if (IsJson(text)) + { + return text; + } + // Try convert XML try { diff --git a/src/modules/AdvancedPaste/AdvancedPaste/Helpers/UserSettings.cs b/src/modules/AdvancedPaste/AdvancedPaste/Helpers/UserSettings.cs index e2c2e07c84..8d5f51314d 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste/Helpers/UserSettings.cs +++ b/src/modules/AdvancedPaste/AdvancedPaste/Helpers/UserSettings.cs @@ -154,8 +154,8 @@ namespace AdvancedPaste.Settings { if (disposing) { - _cancellationTokenSource.Dispose(); - _watcher.Dispose(); + _cancellationTokenSource?.Dispose(); + _watcher?.Dispose(); } _disposedValue = true; diff --git a/src/modules/EnvironmentVariables/EnvironmentVariables/EnvironmentVariables.csproj b/src/modules/EnvironmentVariables/EnvironmentVariables/EnvironmentVariables.csproj index 7e4cb21480..2dcbc1e237 100644 --- a/src/modules/EnvironmentVariables/EnvironmentVariables/EnvironmentVariables.csproj +++ b/src/modules/EnvironmentVariables/EnvironmentVariables/EnvironmentVariables.csproj @@ -69,6 +69,8 @@ + + diff --git a/src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj b/src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj index c95831337d..f4b28d3922 100644 --- a/src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj +++ b/src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithUI.csproj @@ -65,6 +65,8 @@ + + diff --git a/src/modules/Hosts/Hosts.Tests/Hosts.Tests.csproj b/src/modules/Hosts/Hosts.Tests/Hosts.Tests.csproj index 8d332f9ea5..0f0a57ba6b 100644 --- a/src/modules/Hosts/Hosts.Tests/Hosts.Tests.csproj +++ b/src/modules/Hosts/Hosts.Tests/Hosts.Tests.csproj @@ -20,6 +20,8 @@ runtime + + diff --git a/src/modules/Hosts/Hosts/Hosts.csproj b/src/modules/Hosts/Hosts/Hosts.csproj index 10b5457d7c..cf595dd44b 100644 --- a/src/modules/Hosts/Hosts/Hosts.csproj +++ b/src/modules/Hosts/Hosts/Hosts.csproj @@ -68,6 +68,8 @@ + + diff --git a/src/modules/Hosts/HostsUILib/Helpers/DuplicateService.cs b/src/modules/Hosts/HostsUILib/Helpers/DuplicateService.cs index 75b17d5f48..d50d2b1bd1 100644 --- a/src/modules/Hosts/HostsUILib/Helpers/DuplicateService.cs +++ b/src/modules/Hosts/HostsUILib/Helpers/DuplicateService.cs @@ -14,7 +14,7 @@ using Microsoft.UI.Dispatching; namespace HostsUILib.Helpers { - public class DuplicateService : IDuplicateService, IDisposable + public partial class DuplicateService : IDuplicateService, IDisposable { private record struct Check(string Address, string[] Hosts); diff --git a/src/modules/Hosts/HostsUILib/Helpers/HostsService.cs b/src/modules/Hosts/HostsUILib/Helpers/HostsService.cs index 3270681c5e..b07eb8f93c 100644 --- a/src/modules/Hosts/HostsUILib/Helpers/HostsService.cs +++ b/src/modules/Hosts/HostsUILib/Helpers/HostsService.cs @@ -21,7 +21,7 @@ using Microsoft.Win32; namespace HostsUILib.Helpers { - public class HostsService : IHostsService, IDisposable + public partial class HostsService : IHostsService, IDisposable { private const string _backupSuffix = $"_PowerToysBackup_"; private const int _defaultBufferSize = 4096; // From System.IO.File source code diff --git a/src/modules/Hosts/HostsUILib/HostsUILib.csproj b/src/modules/Hosts/HostsUILib/HostsUILib.csproj index b5f99bcdac..21e7822000 100644 --- a/src/modules/Hosts/HostsUILib/HostsUILib.csproj +++ b/src/modules/Hosts/HostsUILib/HostsUILib.csproj @@ -1,6 +1,7 @@  + Library diff --git a/src/modules/Hosts/HostsUILib/ViewModels/MainViewModel.cs b/src/modules/Hosts/HostsUILib/ViewModels/MainViewModel.cs index 42371e3361..60a036bdb8 100644 --- a/src/modules/Hosts/HostsUILib/ViewModels/MainViewModel.cs +++ b/src/modules/Hosts/HostsUILib/ViewModels/MainViewModel.cs @@ -202,7 +202,9 @@ namespace HostsUILib.ViewModels } _entries.CollectionChanged += Entries_CollectionChanged; +#pragma warning disable IL2026 // Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code Entries = new AdvancedCollectionView(_entries, true); +#pragma warning restore IL2026 // Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code Entries.SortDescriptions.Add(new SortDescription(nameof(Entry.Id), SortDirection.Ascending)); ApplyFilters(); OnPropertyChanged(nameof(Entries)); diff --git a/src/modules/NewPlus/NewShellExtensionContextMenu.win10/shell_context_menu_win10.cpp b/src/modules/NewPlus/NewShellExtensionContextMenu.win10/shell_context_menu_win10.cpp index c54631df09..09e948d9b2 100644 --- a/src/modules/NewPlus/NewShellExtensionContextMenu.win10/shell_context_menu_win10.cpp +++ b/src/modules/NewPlus/NewShellExtensionContextMenu.win10/shell_context_menu_win10.cpp @@ -38,9 +38,9 @@ IFACEMETHODIMP shell_context_menu_win10::QueryContextMenu(HMENU menu_handle, UIN return E_FAIL; } - if (menu_flags & CMF_DEFAULTONLY) + if (menu_flags & (CMF_DEFAULTONLY | CMF_VERBSONLY | CMF_OPTIMIZEFORINVOKE)) { - return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0); + return E_UNEXPECTED; } try @@ -217,6 +217,13 @@ IFACEMETHODIMP shell_context_menu_win10::InvokeCommand(CMINVOKECOMMANDINFO* para return E_FAIL; } + if (HIWORD(params->lpVerb)!=0) + { + // Not a menu command. It's likely a string verb command from another menu. + // The logic to interpret lpVerb is explained here: https://learn.microsoft.com/en-us/previous-versions//bb776881(v=vs.85)#invokecommand-method + return E_FAIL; + } + // Get selected menu item (a template or the "Open templates" item) const auto selected_menu_item_index = LOWORD(params->lpVerb) - 1; if (selected_menu_item_index < 0) diff --git a/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml b/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml index 19944b04bf..f28d642b6b 100644 --- a/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml +++ b/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml @@ -95,7 +95,7 @@ @@ -156,6 +155,7 @@