From 531e836b2d1bc1ee2b2b8dffb879644d92ba24a7 Mon Sep 17 00:00:00 2001 From: Michael Hawker <24302614+michael-hawker@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:19:09 -0700 Subject: [PATCH 1/4] Add MicrosoftLearnDocSearch Extension Prototype --- .../Assets/LockScreenLogo.scale-200.png | Bin 0 -> 438 bytes .../Assets/SplashScreen.scale-200.png | Bin 0 -> 5550 bytes .../Assets/Square150x150Logo.scale-200.png | Bin 0 -> 1775 bytes .../Assets/Square44x44Logo.scale-200.png | Bin 0 -> 652 bytes ...x44Logo.targetsize-24_altform-unplated.png | Bin 0 -> 289 bytes .../Assets/StoreLogo.png | Bin 0 -> 462 bytes .../Assets/Wide310x150Logo.scale-200.png | Bin 0 -> 2166 bytes .../MicrosoftLearnExtension/LinkAction.cs | 26 ++++++ .../MicrosoftLearnExtension.csproj | 53 ++++++++++++ ...MicrosoftLearnExtensionCommandsProvider.cs | 33 ++++++++ .../Package.appxmanifest | 78 ++++++++++++++++++ .../Pages/MicrosoftLearnExtensionPage.cs | 74 +++++++++++++++++ .../Exts/MicrosoftLearnExtension/Program.cs | 36 ++++++++ .../Properties/launchSettings.json | 10 +++ .../SampleExtension.cs | 39 +++++++++ .../MicrosoftLearnExtension/SearchResult.cs | 18 ++++ .../SearchResultList.cs | 20 +++++ .../Exts/MicrosoftLearnExtension/app.manifest | 19 +++++ 18 files changed, 406 insertions(+) create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/LockScreenLogo.scale-200.png create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/SplashScreen.scale-200.png create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Square150x150Logo.scale-200.png create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Square44x44Logo.scale-200.png create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Square44x44Logo.targetsize-24_altform-unplated.png create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/StoreLogo.png create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Wide310x150Logo.scale-200.png create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/LinkAction.cs create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtension.csproj create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtensionCommandsProvider.cs create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Package.appxmanifest create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Pages/MicrosoftLearnExtensionPage.cs create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Program.cs create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/Properties/launchSettings.json create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/SampleExtension.cs create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/SearchResult.cs create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/SearchResultList.cs create mode 100644 src/modules/cmdpal/Exts/MicrosoftLearnExtension/app.manifest diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/LockScreenLogo.scale-200.png b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..67dacd6442ec3d16bce0af66db101d8aea8ef06d GIT binary patch literal 438 zcmeAS@N?(olH%oJU|`_o^7L>C0x}Fhn1c;ShBN(aXJB9~_jGX#skn7zx@pp8-gon^hgIGQs}VZ=?Afzp zVVP3BZaf;xvR50bezaDYU4Bu}e^Ksf!_c5IlIgok6K- zIzOWei@rQl2S=P8i-F*t8lDHr3_m3fxHEh*Z0KirlFT5_c%q%bj%flvV-1UfJktXX z54)U8beEo*)*4@R?9}5dYBSpVUhGvPr{xIo>1#@(l^?sGK z>5uqMKmN_R{OL=M^rt`Z;^$9qazJor$3aF;1^d+Wgg?6?ZEPqf(0s|!Iddgr5?f72n02 z>?DBm$HYwu{t%brrNT^{MO(tkiC@nH(2}}GagAo=JB6`lf@B6mpz3Ubt!S~1Z z_MYcH=bY!9`_Z<%R<$@QQR47{;N!zyORob$rs zjg1xRqah8%Cy}HE@v#4_un&dQluq)yf~&VS690DRm5o7YKPboCKl83#)d=41FUd_K z>qxa8JJQglg1>?vmjhu#84i5s3?*P0Dq(00M*rYn)5yTtaJhHr%o^1|b9kqBR__ez z$hzvp;imfNiCc@wC3pFA?!TWVCtYeX&s%S=y|$0I>|gzSPEV0Wz2Hm3KwXZ1<`5^O z0xD`lq^AVaG}mdgLAvrNo%mYfwSWJ=*!0xP+H8ERr6-pgyagd0PKxqx07KbRb!J~pPD6|l0OL5t0 z#~Aenw~AF^GY6KggqbyrSO}zzWyH=i))s&Vd~?w_Xh>olW({>eE@NIgM#)kD4(fe# zECq?9jRRxt))7c!*%PDQWtVe^w6iXh#qrOM>lup)K0rs}PGK=goumy#uoTc6(56nd zE=g-~HU~J&0m3;JW8&Jsoh0_GHpI2_=R-%~e$9)xAwEz}M)%vj8H$w6);>kbaZKP< zQo>^DDUsfB7+W<#D`6d$fR@GOFzUs!xEwIXio8~AN+GZds)JjTu{KW$^J2&1_C+~Z z3&qJ9e2st$9lNocAMh{*Y%yl>yNU$&{i(!%y zNqyvoz%SjZ%yqdzIfj^+G%(>eSW5=a6j-)&9Ta(5m~29zh>d|*?}@Ux9H1HsWALoy zz}l3sJ4T75gJYaFsA!AUAa*R2ZeKmrjzCuze61`B)a?_WB$Kh815eawWth)=;=7 zyW*PnCO5w=#e}J|h?l$^r|{~hRt{a558@p`#RtxZuTTA>H~h7?Q$@_zpy2+d=!J0U z)D87d7}n1%{9r*b=JE_M?3+x zgul-Tu6JK~{qmC`ruFt}>(*~Z8XK33{_mALqbX7d`wQK0gyC-BFOz)?w%EmFW>#Bs zMVbkbcG1C7tsJ+l*;nLQOIHYy?Jhg)B5XBC8~EM?<;GfUvI5Hr$a!kzAvWm!fGe@+TK;d@OYwuM0764 zPi*aIgK(HK8FHy2m=Q`ElUEypca}3s#sKEJi7GZtBWVljS&lu=LE2SRd$jY2V8h4K zB%0619Est@{B)+q$DuS&Pi|Im%)4Xku_(P|9AqCCIa@;dmRdW~naqN31Wv9~Q(5mC z+&i$1S;4S|%V?LO`om08JW^2!xFms2hG&^35^+xnLg^t4=Xe72-~yS7$8@loXU<50 zT2N1-__8B!0i~DiSb8W<%ziP^9-A+)E)hFQ8yrpqQljE)AQ}e_9fAx@4{hiWRW71K z<<#&s3+}vd$wf8s&MWpmj=?SiD+X>vk{PDt(VY!0Q&1RKS8yM5IaVrR7uB+rW6Vop zJXT60eQUl5H1#)Vh_y@QPmSpO=T~`Fm5SfhZsY_9RS*iq>0cKK z7s`6UbwEy-Y6P;QQBhShyl@195_ut~pR z`BUky0=OsM_uBwxNS*u_1l&*IVJOaY&d|eRWUjD@xdA;ujQ=CXF+_WStREJmb^`4y bf3>Oa!Yk_w%6wRkibYix_e-|stjvD_tX9%7 literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Square150x150Logo.scale-200.png b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..d735d9bac7ad52575a8100a09291111956508c56 GIT binary patch literal 1775 zcmZvde@qi+9LBFl3tUO3c2WZp_=mFCAM+13wh%{Fz{&N3BC++-EZb#sP^XSDVkIjuY)~?;U z()HsL*V0!ybM+S#B`H4{`YK9}7p88zb+}U8SEo_u`)m9yp@UUNH0qLx*^A$_R^5KK zfbEJpT5|PXH{$3Y(eIi2_$mR7em6@@JMUT=;@gTBgo1Cmfk6v}dzXLtZ!uZUBZ?!|~ zJGI!;-7F0Lk=0hriPyJw)Rjw7lHAitV9MMF;H>xnK)Ua=A&9)ti8QB7Uw;!>S`L@^bYMb7tZF_bSu4= z>z9Pr`p@lT>{Cg)KqB^GLL(VTT1=c$nVfJaT3Id;Hm~61yog4P=Ow627EYoO34O)u zzu~nF`oNqQbv~E_gUkiS5o0ip`%wCo33&|ayAEOAb2am)`oT5Qa;KN0J#K3#G#XYa@=c!^Q$#?7T)6bqt8{SW&{ BmR$e< literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Square44x44Logo.scale-200.png b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..4e6ec9fbc28ced28ecbc695e22492f8ee825015b GIT binary patch literal 652 zcmeAS@N?(olH%oJU|`_o^7L>C0x}{%n1c;S7EU!VVPIf#@pN$vskrs#(ssc^4iYX8 zt?w>%$#Ri>u=?1v1wt7OEW$?i`iG=%zW8>whL`Kj8gt|8@m|c?53Dj1c)9l6&5Qkf zCBvksKlO#7=to`WuTzdkOIG=~hP-W3KJ#)VbIUq*z8i^cwm~|_g;=$whE~1X%jEs! z!j7EFM-QY=5q0y+y(9EokIn3iR?nPUJBlUh%5vY^6-coyQs6l*99m_~zoKlS-YTvhCK;zcES2^UFGO3XktJ}ztzq-J#R956KykZj0KU@#KAet;oGXa$N`w!o}tmTX?GotfO1?A|FltOs0`xf{CO#2CbT zbr|%dA{k;#HZknTNMS6vc*5y1(*(Qw*eD0(L<F@vhhDOlW`-)B)*24p*w67)}&Gh6db#8X#9ejzfk={N>gAzPZj=wx5!^ zu6trm3!+X93a@hm`*7CKS-}95P<;%XKn0871LY3ZU<_95D>{dHSO?cYz5xEGZ{PzX z4%V&Q2God^&s(_-3h0p^S9v_!eQj4fTRMOwOCi?lSk9%<=vAz}jM-*PQtH@Odn1LZcd n^j#o>W$4xn+CT+ep9lJ{OAO?njobhL002ovPDHLkV1f+_Tb*>o literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/StoreLogo.png b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/StoreLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..b32ed0a8d7861f0634c38d309444ee045e88df88 GIT binary patch literal 462 zcmeAS@N?(olH%oJU|`_o^7L>C0y2z1n1c;S%Gq~pWME+I_jGX#skrs#hH24Z1_8Ik zO6R4!AE-8!&R8e2?oh$R3AZMEN&LSNW^XcQi6x;C5w^*M81L>&&D& zV&cCEm#$fMW!I{DWN&Zkf7ZreMY-$GdyE84W~~biXzKuuEI4 z(B@v@!FVRck*EKIfWTp8o0g*=IQSnLDjagI;OY1vAjhm^({j84tI$HAs{9UyW40gP z9($ZDa>!ZZOd0bBlXOdg|IfGb{L{8uc225yqILu8AJO@_E$bM>w)j8z-Se^I*Z~P{ zrw0<;E(;{M-4Z0a-3_qf$AX3u+6@+m1Vj_oFeC{&hcp;6I41A~_%*5-6j`l~ Yul|Re-hKfXM+}~>elF{r5}J6q04VglT>t<8 literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Wide310x150Logo.scale-200.png b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..e6d439a3e63211bd2116734e2aab2fa8c657350c GIT binary patch literal 2166 zcmd5;YfM{Z82;MQLsRTl!t4kqFxZ4;Vj0QoLFXb>3Kcizjf4}qh$Sk(#zJ6lCL)XmF-uE39>~%aUzk3Xz)-F7y4)IXx797^8pu)jp@+ z`&{1lJKtC9^ZT_jX_8Ee5Ryp?pV7RCkkE*b;1LM{k3LMFyoONhe4*y4;@Uv?rs|!W zC5c0~o}<$Z634dT9sSi!Bgb<-dw4i>h5o^Fqv!3+_LE1q*lyg~_FnbOo?VmYx|iSV z&HQb6-$?OAgqoBH#gGVn1aj&Q0ZJW1NDg8cqe}#jB@_eAl_F*thENuPxa#j%@H)); z&sn0iBVN|AsO<~F?&K%m?^+>4Uwo2s!4?Axn`F}YCw7VFpWVdAp_e(+>s^LgMU^$d zyA?%}{+CRzbSjGlKu~)=ye~+m`G}uAAEf*HO6+~k3d7>{;EA+>K!bNs7(=E85LcY!mZxh z;;s(cM&F&Q-h)<8E0CYebEo+syj><8NRm)$_h6o*u2Q5SK}>Em>+>Agq=u}DH$WU; zJuOXc~#++hFIS%yZZ%w3DaWx(bgKCN|^FD@0MEF)@5Hgxt{LRVo!n)~Ru1_}?}6Jm@13rsLU21$d;hnYh( z1LX$0GY%5CGFZPFGIh+nL09A!zyuv)4GAR!&H6YzP=}R*XaArp@LTGaV~-#xD#-a2mYz1n=}gJ?@arE}Yf8(P zmx|4CWOkP84sMRx0X@fj*S9mDD(syJf_^Z4KyI*L>sT@hIZx?1%|GyuGAV8h z$9j4oi7{`c^O%|_I4D@-yM|=nVXYv`n0@Z6e*9>z zAUHXDzXx~ff$>G}LLVeh9&w`05Y2YEl^swdl!d~>1GI7v5%2bfk9kK-e=3ZQoq>s& z(a&Kklq%iJWhj*S0)Mqd?kKp+U{w4~_uV0MyJZJ@>s1jNYkuv^gBKn{s0%L3|HCa9 r?GtP>7dK3txws=3b`pP)ml0c=CyvKHsB*%82~?QBU(^0{B~0coCxOka literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/LinkAction.cs b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/LinkAction.cs new file mode 100644 index 000000000000..524fc6759d6a --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/LinkAction.cs @@ -0,0 +1,26 @@ +// 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.Diagnostics; +using Microsoft.CmdPal.Extensions.Helpers; + +namespace MicrosoftLearnExtension; + +internal sealed partial class LinkAction : InvokableCommand +{ + private readonly SearchResult _post; + + internal LinkAction(SearchResult post) + { + this._post = post; + this.Name = "Open link"; + this.Icon = new("\uE8A7"); + } + + public override CommandResult Invoke() + { + Process.Start(new ProcessStartInfo(_post.Url) { UseShellExecute = true }); + return CommandResult.KeepOpen(); + } +} diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtension.csproj b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtension.csproj new file mode 100644 index 000000000000..a3d160b8e7a4 --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtension.csproj @@ -0,0 +1,53 @@ + + + + WinExe + MicrosoftLearnExtension + app.manifest + win-$(Platform).pubxml + false + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtensionCommandsProvider.cs b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtensionCommandsProvider.cs new file mode 100644 index 000000000000..7fac60305414 --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtensionCommandsProvider.cs @@ -0,0 +1,33 @@ +// 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; +using Microsoft.CmdPal.Extensions; +using Microsoft.CmdPal.Extensions.Helpers; + +namespace MicrosoftLearnExtension; + +public partial class MicrosoftLearnExtensionActionsProvider : ICommandProvider +{ + public string DisplayName => $"Microsoft Learn Doc Search Extension for cmdpal Commands"; + + public IconDataType Icon => new(string.Empty); + + private readonly IListItem[] _commands = [ + new ListItem(new MicrosoftLearnExtensionPage()), + ]; + +#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize + public void Dispose() => throw new NotImplementedException(); +#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize + + public IListItem[] TopLevelCommands() + { + return _commands; + } +} diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Package.appxmanifest b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Package.appxmanifest new file mode 100644 index 000000000000..49214efe595e --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Package.appxmanifest @@ -0,0 +1,78 @@ + + + + + + + + Microsoft Learn Doc Search Extension for cmdpal + A Lone Developer + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Pages/MicrosoftLearnExtensionPage.cs b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Pages/MicrosoftLearnExtensionPage.cs new file mode 100644 index 000000000000..eb3af041f51f --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Pages/MicrosoftLearnExtensionPage.cs @@ -0,0 +1,74 @@ +// 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.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using System.Xml.Linq; +using Microsoft.CmdPal.Extensions; +using Microsoft.CmdPal.Extensions.Helpers; +using Windows.UI.WebUI; + +namespace MicrosoftLearnExtension; + +internal sealed partial class MicrosoftLearnExtensionPage : DynamicListPage +{ + private static readonly string EndPointUrl = "https://learn.microsoft.com/api/search"; + + // TODO: Provide options to search different locales and products + private static readonly string Locale = "en-us"; + private static readonly string Product = "/devrel/b3627ad5-057f-488f-8b97-08be347b4be5"; // Windows App SDK + + private static readonly JsonSerializerOptions JsonOptions = new() + { + PropertyNameCaseInsensitive = true, + }; + + public MicrosoftLearnExtensionPage() + { + Icon = new("https://learn.microsoft.com/favicon.ico"); + Name = "Microsoft Learn Doc Search"; + } + + private static async Task> SearchMicrosoftLearn(string query) + { + if (string.IsNullOrWhiteSpace(query)) + { + return new(); // TODO: Should have a hint of 'type query' item... + } + + //// TODO: Sanitize input? + using HttpClient client = new HttpClient(); + + var response = await client.GetStringAsync($"{EndPointUrl}?locale={Locale}&$filter=products/any(product:product eq '{Product}')&search={query}"); + + return JsonSerializer.Deserialize(response, JsonOptions).Results.ToList(); + } + + public override ISection[] GetItems(string query) + { + var t = DoGetItems(query); + t.ConfigureAwait(false); + return t.Result; + } + + private async Task DoGetItems(string query) + { + List items = await SearchMicrosoftLearn(query); + this.Loading = false; + var s = new ListSection() + { + Title = "Posts", + Items = items.Select((post) => new ListItem(new LinkAction(post)) + { + Title = post.Title, + Subtitle = post.Description, + }).ToArray(), + }; + return [s]; + } +} diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Program.cs b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Program.cs new file mode 100644 index 000000000000..f3ef9bc8c756 --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Program.cs @@ -0,0 +1,36 @@ +// 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.Threading; +using Microsoft.CmdPal.Extensions; + +namespace MicrosoftLearnExtension; + +public class Program +{ + [MTAThread] + public static void Main(string[] args) + { + if (args.Length > 0 && args[0] == "-RegisterProcessAsComServer") + { + using ExtensionServer server = new(); + var extensionDisposedEvent = new ManualResetEvent(false); + var extensionInstance = new SampleExtension(extensionDisposedEvent); + + // We are instantiating an extension instance once above, and returning it every time the callback in RegisterExtension below is called. + // This makes sure that only one instance of SampleExtension is alive, which is returned every time the host asks for the IExtension object. + // If you want to instantiate a new instance each time the host asks, create the new instance inside the delegate. + server.RegisterExtension(() => extensionInstance); + + // This will make the main thread wait until the event is signalled by the extension class. + // Since we have single instance of the extension object, we exit as sooon as it is disposed. + extensionDisposedEvent.WaitOne(); + } + else + { + Console.WriteLine("Not being launched as a Extension... exiting."); + } + } +} diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Properties/launchSettings.json b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Properties/launchSettings.json new file mode 100644 index 000000000000..87144dfaff28 --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "MicrosoftLearnExtension (Package)": { + "commandName": "MsixPackage" + }, + "MicrosoftLearnExtension (Unpackaged)": { + "commandName": "Project" + } + } +} diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/SampleExtension.cs b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/SampleExtension.cs new file mode 100644 index 000000000000..65c31cdf941f --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/SampleExtension.cs @@ -0,0 +1,39 @@ +// 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.Runtime.InteropServices; +using System.Threading; +using Microsoft.CmdPal.Extensions; + +namespace MicrosoftLearnExtension; + +[ComVisible(true)] +[Guid("11771f22-a54a-400c-8c3d-5c9c31b4429c")] +[ComDefaultInterface(typeof(IExtension))] +public sealed partial class SampleExtension : IExtension +{ + private readonly ManualResetEvent _extensionDisposedEvent; + + public SampleExtension(ManualResetEvent extensionDisposedEvent) + { + this._extensionDisposedEvent = extensionDisposedEvent; + } + + public object GetProvider(ProviderType providerType) + { + switch (providerType) + { + case ProviderType.Commands: + return new MicrosoftLearnExtensionActionsProvider(); + default: + return null; + } + } + + public void Dispose() + { + this._extensionDisposedEvent.Set(); + } +} diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/SearchResult.cs b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/SearchResult.cs new file mode 100644 index 000000000000..a44915183b93 --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/SearchResult.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; + +namespace MicrosoftLearnExtension; + +// We don't care about members not listed below - https://learn.microsoft.com/dotnet/standard/serialization/system-text-json/missing-members +[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Skip)] +public class SearchResult +{ + public string Title { get; set; } + + public string Url { get; set; } + + public string Description { get; set; } +} diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/SearchResultList.cs b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/SearchResultList.cs new file mode 100644 index 000000000000..f18eedac9c02 --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/SearchResultList.cs @@ -0,0 +1,20 @@ +// 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.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace MicrosoftLearnExtension; + +[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Skip)] +public class SearchResultList +{ + public SearchResult[] Results { get; set; } + + public int Count { get; set; } +} diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/app.manifest b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/app.manifest new file mode 100644 index 000000000000..bcafb9bc5b8d --- /dev/null +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/app.manifest @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + PerMonitorV2 + + + From a14a9d937ffb50402d02e571041e7540cc5f2772 Mon Sep 17 00:00:00 2001 From: Michael Hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 30 Jan 2025 16:35:50 -0800 Subject: [PATCH 2/4] Attempt to update extension to work with version in main Seems like list isn't updating itself --- PowerToys.sln | 23 ++++++++++++- .../MicrosoftLearnExtension.csproj | 11 +++--- ...MicrosoftLearnExtensionCommandsProvider.cs | 23 +++++-------- .../Pages/MicrosoftLearnExtensionPage.cs | 34 +++++++++++-------- .../SampleExtension.cs | 6 ++-- src/modules/cmdpal/terminate_extensions.bat | 1 + 6 files changed, 61 insertions(+), 37 deletions(-) diff --git a/PowerToys.sln b/PowerToys.sln index 73c3e0681e69..3cdded328572 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -716,6 +716,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZoomItModuleInterface", "sr EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZoomItSettingsInterop", "src\modules\ZoomIt\ZoomItSettingsInterop\ZoomItSettingsInterop.vcxproj", "{CA7D8106-30B9-4AEC-9D05-B69B31B8C461}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicrosoftLearnExtension", "src\modules\cmdpal\Exts\MicrosoftLearnExtension\MicrosoftLearnExtension.csproj", "{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -3412,6 +3414,24 @@ Global {CA7D8106-30B9-4AEC-9D05-B69B31B8C461}.Release|x64.Build.0 = Release|x64 {CA7D8106-30B9-4AEC-9D05-B69B31B8C461}.Release|x86.ActiveCfg = Release|x64 {CA7D8106-30B9-4AEC-9D05-B69B31B8C461}.Release|x86.Build.0 = Release|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|ARM64.Build.0 = Debug|ARM64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x64.ActiveCfg = Debug|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x64.Build.0 = Debug|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x64.Deploy.0 = Debug|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x86.ActiveCfg = Debug|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x86.Build.0 = Debug|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x86.Deploy.0 = Debug|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|ARM64.ActiveCfg = Release|ARM64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|ARM64.Build.0 = Release|ARM64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|ARM64.Deploy.0 = Release|ARM64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x64.ActiveCfg = Release|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x64.Build.0 = Release|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x64.Deploy.0 = Release|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x86.ActiveCfg = Release|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x86.Build.0 = Release|x64 + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x86.Deploy.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3679,14 +3699,15 @@ Global {453CBB73-A3CB-4D0B-8D24-6940B86FE21D} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2} {C0CE3B5E-16D3-495D-B335-CA791B660162} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2} {3A9A7297-92C4-4F16-B6F9-8D4AB652C86C} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2} - {605E914B-7232-4789-AF46-BF5D3DDFC14E} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2} {D5E5F5EA-1B6C-4A73-88BE-304F36C9E4EE} = {9873BA05-4C41-4819-9283-CF45D795431B} + {605E914B-7232-4789-AF46-BF5D3DDFC14E} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2} {7F5B9557-5878-4438-A721-3E28296BA193} = {9873BA05-4C41-4819-9283-CF45D795431B} {E81A7D20-9862-ABDB-0AAE-9BC5B517A9F9} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2} {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} {0A84F764-3A88-44CD-AA96-41BDBD48627B} = {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C} {E4585179-2AC1-4D5F-A3FF-CFC5392F694C} = {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C} {CA7D8106-30B9-4AEC-9D05-B69B31B8C461} = {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C} + {1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775} = {071E18A4-A530-46B8-AB7D-B862EE55E24E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0} diff --git a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtension.csproj b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtension.csproj index a3d160b8e7a4..3802e92da0fa 100644 --- a/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtension.csproj +++ b/src/modules/cmdpal/Exts/MicrosoftLearnExtension/MicrosoftLearnExtension.csproj @@ -1,4 +1,4 @@ - + WinExe @@ -7,6 +7,9 @@ win-$(Platform).pubxml false true + $(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPalExtensions\$(RootNamespace) + false + false @@ -26,6 +29,7 @@ +