From 35bfb0f83e5fc08cc04398e7aa98d77774412d3f Mon Sep 17 00:00:00 2001 From: Jeremy Sinclair <4016293+snickler@users.noreply.github.com> Date: Wed, 16 Feb 2022 11:06:10 -0500 Subject: [PATCH] [PT Run] Replace tblimp-Microsoft.Search.Interop package with source implementation (#16363) * Removed Search Interop tlb package. Added minimal Search API Com implementation * Added CSearchManagerImp * Updated Main with proper reference to CSearchManagerImp. Switched WindowsIndexerTest to use Indexer.Interop classes * Updated with proper SearchAPI Interop implementation * Deleted initial CSearchManager file that didn't work * Updated namespaces to match folder structure * Removed the interfaces and classes not being used from SearchAPI. Added suppressions * Updated spell check. Renamed CSearch call back to original * Fix spell check * Switched back to original class name for Search Manager in tests * Removed Microsoft.Search.Interop.dll from setup * Removed Microsoft.Search.Interop package from PowerLauncher and signing scripts --- .github/actions/spell-check/expect.txt | 3 + .pipelines/ESRPSigning_core.json | 1 - .pipelines/versionAndSignCheck.ps1 | 7 +- installer/PowerToysSetup/Product.wxs | 2 +- .../Interop/CSearchCatalogManager.cs | 17 +++ .../Interop/CSearchCatalogManagerClass.cs | 133 +++++++++++++++++ .../Interop/CSearchManager.cs | 17 +++ .../Interop/CSearchManagerClass.cs | 91 ++++++++++++ .../Interop/CSearchQueryHelper.cs | 17 +++ .../Interop/CSearchQueryHelperClass.cs | 134 ++++++++++++++++++ .../Interop/ISearchCatalogManager.cs | 131 +++++++++++++++++ .../Interop/ISearchManager.cs | 90 ++++++++++++ .../Interop/ISearchQueryHelper.cs | 134 ++++++++++++++++++ .../Plugins/Microsoft.Plugin.Indexer/Main.cs | 2 +- .../Microsoft.Plugin.Indexer.csproj | 3 - .../SearchHelper/WindowsSearchAPI.cs | 2 +- .../PowerLauncher/PowerLauncher.csproj | 3 - .../Wox.Test/Plugins/WindowsIndexerTest.cs | 2 +- 18 files changed, 773 insertions(+), 16 deletions(-) create mode 100644 src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchCatalogManager.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchCatalogManagerClass.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchManager.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchManagerClass.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchQueryHelper.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchQueryHelperClass.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchCatalogManager.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchManager.cs create mode 100644 src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchQueryHelper.cs diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 7c7e272ead..3784cc07a4 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -264,6 +264,7 @@ Cls cls CLSCTX clsid +Clusion cmder Cmdlet cmdline @@ -1503,6 +1504,7 @@ pesi PEXCEPTION pfn pfo +pft pgp pguid phbm @@ -2234,6 +2236,7 @@ vsonline vstemplate VSTHRD VSTT +vtable VTABLE Vtbl WBounds diff --git a/.pipelines/ESRPSigning_core.json b/.pipelines/ESRPSigning_core.json index aa871e6f15..1f137e1338 100644 --- a/.pipelines/ESRPSigning_core.json +++ b/.pipelines/ESRPSigning_core.json @@ -158,7 +158,6 @@ }, { "MatchedPath": [ - "Microsoft.Search.Interop.dll", "ModernWpf.dll", "ModernWpf.Controls.dll", "System.IO.Abstractions.dll", diff --git a/.pipelines/versionAndSignCheck.ps1 b/.pipelines/versionAndSignCheck.ps1 index 76409b320e..1dd784e3e8 100644 --- a/.pipelines/versionAndSignCheck.ps1 +++ b/.pipelines/versionAndSignCheck.ps1 @@ -28,11 +28,8 @@ if($items.Count -eq 0) $items | ForEach-Object { if($_.VersionInfo.FileVersion -eq "1.0.0.0" ) { - if(-not $_.Name.EndsWith("Microsoft.Search.Interop.dll")) - { - Write-Host "Version not set: " + $_.FullName - $totalFailure++; - } + Write-Host "Version not set: " + $_.FullName + $totalFailure++; } } diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index 96d10f7e2d..cf3f079099 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -1349,7 +1349,7 @@ - + diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchCatalogManager.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchCatalogManager.cs new file mode 100644 index 0000000000..50456b552f --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchCatalogManager.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace Microsoft.Plugin.Indexer.Interop +{ + [CoClass(typeof(CSearchCatalogManagerClass))] + [Guid("AB310581-AC80-11D1-8DF3-00C04FB6EF50")] + [ComImport] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1715:Identifiers should have correct prefix", Justification = "Using original name from type lib")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:Interface names should begin with I", Justification = "Using original name from type lib")] + public interface CSearchCatalogManager : ISearchCatalogManager + { + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchCatalogManagerClass.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchCatalogManagerClass.cs new file mode 100644 index 0000000000..a95292ecab --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchCatalogManagerClass.cs @@ -0,0 +1,133 @@ +// 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.CompilerServices; +using System.Runtime.InteropServices; + +namespace Microsoft.Plugin.Indexer.Interop +{ + [ComConversionLoss] + [Guid("AAB49DD5-AD0B-40AE-B654-AE8976BF6BD2")] + [ClassInterface((short)0)] + [ComImport] + [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1212:Property accessors should follow order", Justification = "The order of the property accessors must match the order in which the methods were defined in the vtable")] + public class CSearchCatalogManagerClass : ISearchCatalogManager, CSearchCatalogManager + { + [DispId(1610678272)] + public virtual extern string Name + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern IntPtr GetParameter([MarshalAs(UnmanagedType.LPWStr), In] string pszName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void SetParameter([MarshalAs(UnmanagedType.LPWStr), In] string pszName, [In] ref object pValue); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void GetCatalogStatus( + out object pStatus, + out object pPausedReason); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void Reset(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void Reindex(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void ReindexMatchingURLs([MarshalAs(UnmanagedType.LPWStr), In] string pszPattern); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void ReindexSearchRoot([MarshalAs(UnmanagedType.LPWStr), In] string pszRoot); + + [DispId(1610678280)] + public virtual extern uint ConnectTimeout + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678282)] + public virtual extern uint DataTimeout + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern int NumberOfItems(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void NumberOfItemsToIndex( + out int plIncrementalCount, + out int plNotificationQueue, + out int plHighPriorityQueue); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1055:URI-like return values should not be strings", Justification = "Keeping original method name")] + public virtual extern string URLBeingIndexed(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern uint GetURLIndexingState([MarshalAs(UnmanagedType.LPWStr), In] string psz); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + public virtual extern object GetPersistentItemsChangedSink(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void RegisterViewForNotification( + [MarshalAs(UnmanagedType.LPWStr), In] string pszView, + [MarshalAs(UnmanagedType.Interface), In] object pViewChangedSink, + out uint pdwCookie); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void GetItemsChangedSink( + [MarshalAs(UnmanagedType.Interface), In] object pISearchNotifyInlineSite, + [In] ref Guid riid, + out IntPtr ppv, + out Guid pGUIDCatalogResetSignature, + out Guid pGUIDCheckPointSignature, + out uint pdwLastCheckPointNumber); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void UnregisterViewForNotification([In] uint dwCookie); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void SetExtensionClusion([MarshalAs(UnmanagedType.LPWStr), In] string pszExtension, [In] int fExclude); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + public virtual extern object EnumerateExcludedExtensions(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + public virtual extern CSearchQueryHelper GetQueryHelper(); + + [DispId(1610678295)] + public virtual extern int DiacriticSensitivity + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + public virtual extern object GetCrawlScopeManager(); + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchManager.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchManager.cs new file mode 100644 index 0000000000..c603149bec --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchManager.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace Microsoft.Plugin.Indexer.Interop +{ + [CoClass(typeof(CSearchManagerClass))] + [Guid("AB310581-AC80-11D1-8DF3-00C04FB6EF69")] + [ComImport] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1715:Identifiers should have correct prefix", Justification = "Using original name from type lib")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:Interface names should begin with I", Justification = "Using original name from type lib")] + public interface CSearchManager : ISearchManager + { + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchManagerClass.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchManagerClass.cs new file mode 100644 index 0000000000..642fd62fe4 --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchManagerClass.cs @@ -0,0 +1,91 @@ +// 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.CompilerServices; +using System.Runtime.InteropServices; + +namespace Microsoft.Plugin.Indexer.Interop +{ + [Guid("7D096C5F-AC08-4F1F-BEB7-5C22C517CE39")] + [TypeLibType(2)] + [ClassInterface((short)0)] + [ComConversionLoss] + [ComImport] + public class CSearchManagerClass : ISearchManager, CSearchManager + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void GetIndexerVersionStr([MarshalAs(UnmanagedType.LPWStr)] out string ppszVersionString); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void GetIndexerVersion(out uint pdwMajor, out uint pdwMinor); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern IntPtr GetParameter([MarshalAs(UnmanagedType.LPWStr), In] string pszName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void SetParameter([MarshalAs(UnmanagedType.LPWStr), In] string pszName, [In] ref object pValue); + + [DispId(1610678276)] + public virtual extern string ProxyName + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678277)] + public virtual extern string BypassList + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void SetProxy( + [In] object sUseProxy, + [In] int fLocalByPassProxy, + [In] uint dwPortNumber, + [MarshalAs(UnmanagedType.LPWStr), In] string pszProxyName, + [MarshalAs(UnmanagedType.LPWStr), In] string pszByPassList); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + public virtual extern CSearchCatalogManager GetCatalog([MarshalAs(UnmanagedType.LPWStr), In] string pszCatalog); + + [DispId(1610678280)] + public virtual extern string UserAgent + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + } + + [DispId(1610678282)] + public virtual extern object UseProxy + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678283)] + public virtual extern int LocalBypass + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678284)] + public virtual extern uint PortNumber + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchQueryHelper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchQueryHelper.cs new file mode 100644 index 0000000000..2c2dcf7858 --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchQueryHelper.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace Microsoft.Plugin.Indexer.Interop +{ + [Guid("AB310581-AC80-11D1-8DF3-00C04FB6EF63")] + [CoClass(typeof(CSearchQueryHelperClass))] + [ComImport] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1715:Identifiers should have correct prefix", Justification = "Using original name from type lib")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:Interface names should begin with I", Justification = "Using original name from type lib")] + public interface CSearchQueryHelper : ISearchQueryHelper + { + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchQueryHelperClass.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchQueryHelperClass.cs new file mode 100644 index 0000000000..8cdc78a5eb --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/CSearchQueryHelperClass.cs @@ -0,0 +1,134 @@ +// 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.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Microsoft.Plugin.Indexer.Interop +{ + [ClassInterface((short)0)] + [Guid("B271E955-09E1-42E1-9B95-5994A534B613")] + [ComImport] + [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1212:Property accessors should follow order", Justification = "The order of the property accessors must match the order in which the methods were defined in the vtable")] + public class CSearchQueryHelperClass : ISearchQueryHelper, CSearchQueryHelper + { + [DispId(1610678272)] + public virtual extern string ConnectionString + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678273)] + public virtual extern uint QueryContentLocale + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678275)] + public virtual extern uint QueryKeywordLocale + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678277)] + public virtual extern object QueryTermExpansion + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678279)] + public virtual extern object QuerySyntax + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678281)] + public virtual extern string QueryContentProperties + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678283)] + public virtual extern string QuerySelectColumns + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678285)] + public virtual extern string QueryWhereRestrictions + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678287)] + public virtual extern string QuerySorting + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + public virtual extern string GenerateSQLFromUserQuery([MarshalAs(UnmanagedType.LPWStr), In] string pszQuery); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public virtual extern void WriteProperties( + [In] int itemID, + [In] uint dwNumberOfColumns, + [In] ref object pColumns, + [In] ref object pValues, + [In] ref object pftGatherModifiedTime); + + [DispId(1610678291)] + public virtual extern int QueryMaxResults + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchCatalogManager.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchCatalogManager.cs new file mode 100644 index 0000000000..a8d4c09411 --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchCatalogManager.cs @@ -0,0 +1,131 @@ +// 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.CompilerServices; +using System.Runtime.InteropServices; + +namespace Microsoft.Plugin.Indexer.Interop +{ + [Guid("AB310581-AC80-11D1-8DF3-00C04FB6EF50")] + [ComConversionLoss] + [InterfaceType(1)] + [ComImport] + [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1212:Property accessors should follow order", Justification = "The order of the property accessors must match the order in which the methods were defined in the vtable")] + public interface ISearchCatalogManager + { + [DispId(1610678272)] + string Name + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + IntPtr GetParameter([MarshalAs(UnmanagedType.LPWStr), In] string pszName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void SetParameter([MarshalAs(UnmanagedType.LPWStr), In] string pszName, [In] ref object pValue); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void GetCatalogStatus(out object pStatus, out object pPausedReason); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void Reset(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void Reindex(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void ReindexMatchingURLs([MarshalAs(UnmanagedType.LPWStr), In] string pszPattern); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void ReindexSearchRoot([MarshalAs(UnmanagedType.LPWStr), In] string pszRoot); + + [DispId(1610678280)] + uint ConnectTimeout + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678282)] + uint DataTimeout + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + int NumberOfItems(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void NumberOfItemsToIndex( + out int plIncrementalCount, + out int plNotificationQueue, + out int plHighPriorityQueue); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1055:URI-like return values should not be strings", Justification = "Keeping original method name")] + string URLBeingIndexed(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + uint GetURLIndexingState([MarshalAs(UnmanagedType.LPWStr), In] string psz); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + object GetPersistentItemsChangedSink(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void RegisterViewForNotification( + [MarshalAs(UnmanagedType.LPWStr), In] string pszView, + [MarshalAs(UnmanagedType.Interface), In] object pViewChangedSink, + out uint pdwCookie); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void GetItemsChangedSink( + [MarshalAs(UnmanagedType.Interface), In] object pISearchNotifyInlineSite, + [In] ref Guid riid, + out IntPtr ppv, + out Guid pGUIDCatalogResetSignature, + out Guid pGUIDCheckPointSignature, + out uint pdwLastCheckPointNumber); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void UnregisterViewForNotification([In] uint dwCookie); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void SetExtensionClusion([MarshalAs(UnmanagedType.LPWStr), In] string pszExtension, [In] int fExclude); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + object EnumerateExcludedExtensions(); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + CSearchQueryHelper GetQueryHelper(); + + [DispId(1610678295)] + int DiacriticSensitivity + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + object GetCrawlScopeManager(); + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchManager.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchManager.cs new file mode 100644 index 0000000000..a500f2bdae --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchManager.cs @@ -0,0 +1,90 @@ +// 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.CompilerServices; +using System.Runtime.InteropServices; + +namespace Microsoft.Plugin.Indexer.Interop +{ + [ComConversionLoss] + [Guid("AB310581-AC80-11D1-8DF3-00C04FB6EF69")] + [InterfaceType(1)] + [ComImport] + public interface ISearchManager + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void GetIndexerVersionStr([MarshalAs(UnmanagedType.LPWStr)] out string ppszVersionString); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void GetIndexerVersion(out uint pdwMajor, out uint pdwMinor); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + IntPtr GetParameter([MarshalAs(UnmanagedType.LPWStr), In] string pszName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void SetParameter([MarshalAs(UnmanagedType.LPWStr), In] string pszName, [In] ref object pValue); + + [DispId(1610678276)] + string ProxyName + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678277)] + string BypassList + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void SetProxy( + [In] object sUseProxy, + [In] int fLocalByPassProxy, + [In] uint dwPortNumber, + [MarshalAs(UnmanagedType.LPWStr), In] string pszProxyName, + [MarshalAs(UnmanagedType.LPWStr), In] string pszByPassList); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.Interface)] + CSearchCatalogManager GetCatalog([MarshalAs(UnmanagedType.LPWStr), In] string pszCatalog); + + [DispId(1610678280)] + string UserAgent + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + } + + [DispId(1610678282)] + object UseProxy + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678283)] + int LocalBypass + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678284)] + uint PortNumber + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchQueryHelper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchQueryHelper.cs new file mode 100644 index 0000000000..d2e2938bdb --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Interop/ISearchQueryHelper.cs @@ -0,0 +1,134 @@ +// 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.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Microsoft.Plugin.Indexer.Interop +{ + [Guid("AB310581-AC80-11D1-8DF3-00C04FB6EF63")] + [InterfaceType(1)] + [ComImport] + [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1212:Property accessors should follow order", Justification = "The order of the property accessors must match the order in which the methods were defined in the vtable")] + public interface ISearchQueryHelper + { + [DispId(1610678272)] + string ConnectionString + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678273)] + uint QueryContentLocale + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678275)] + uint QueryKeywordLocale + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678277)] + object QueryTermExpansion + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678279)] + object QuerySyntax + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + + [DispId(1610678281)] + string QueryContentProperties + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678283)] + string QuerySelectColumns + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678285)] + string QueryWhereRestrictions + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [DispId(1610678287)] + string QuerySorting + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: MarshalAs(UnmanagedType.LPWStr)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + get; + } + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [return: MarshalAs(UnmanagedType.LPWStr)] + string GenerateSQLFromUserQuery([MarshalAs(UnmanagedType.LPWStr), In] string pszQuery); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + void WriteProperties( + [In] int itemID, + [In] uint dwNumberOfColumns, + [In] ref object pColumns, + [In] ref object pValues, + [In] ref object pftGatherModifiedTime); + + [DispId(1610678291)] + int QueryMaxResults + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + [param: In] + set; + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + get; + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Main.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Main.cs index d7a2dda123..80edec4026 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Main.cs @@ -11,9 +11,9 @@ using System.Text.RegularExpressions; using System.Windows.Controls; using ManagedCommon; using Microsoft.Plugin.Indexer.DriveDetection; +using Microsoft.Plugin.Indexer.Interop; using Microsoft.Plugin.Indexer.SearchHelper; using Microsoft.PowerToys.Settings.UI.Library; -using Microsoft.Search.Interop; using Wox.Infrastructure; using Wox.Infrastructure.Storage; using Wox.Plugin; diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Microsoft.Plugin.Indexer.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Microsoft.Plugin.Indexer.csproj index bad53a2746..881e82db62 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Microsoft.Plugin.Indexer.csproj +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/Microsoft.Plugin.Indexer.csproj @@ -47,9 +47,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - NU1701 - diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs index d831e6a787..bd47f240f3 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; -using Microsoft.Search.Interop; +using Microsoft.Plugin.Indexer.Interop; using Wox.Plugin.Logger; namespace Microsoft.Plugin.Indexer.SearchHelper diff --git a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj index bfda975469..dcc26a0773 100644 --- a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj +++ b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj @@ -107,9 +107,6 @@ - - NU1701 - diff --git a/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs b/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs index 2f51ec6a22..86e4915359 100644 --- a/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs +++ b/src/modules/launcher/Wox.Test/Plugins/WindowsIndexerTest.cs @@ -7,8 +7,8 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Plugin.Indexer; using Microsoft.Plugin.Indexer.DriveDetection; +using Microsoft.Plugin.Indexer.Interop; using Microsoft.Plugin.Indexer.SearchHelper; -using Microsoft.Search.Interop; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using Wox.Plugin;