Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/SearchPlatAPI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{02EA681E-C7D
api\SearchPlatAPI.h = api\SearchPlatAPI.h
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.SearchPlatform", "projection\Microsoft.SearchPlatform.vcxproj", "{7615F03F-E56D-4DB4-B23D-AC4FB80DB36F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All @@ -26,6 +28,14 @@ Global
{E520B4B7-EACC-A761-6E5F-D14F0A095CE4}.Release|x64.Build.0 = Release|x64
{E520B4B7-EACC-A761-6E5F-D14F0A095CE4}.Release|x86.ActiveCfg = Release|Win32
{E520B4B7-EACC-A761-6E5F-D14F0A095CE4}.Release|x86.Build.0 = Release|Win32
{7615F03F-E56D-4DB4-B23D-AC4FB80DB36F}.Debug|x64.ActiveCfg = Debug|x64
{7615F03F-E56D-4DB4-B23D-AC4FB80DB36F}.Debug|x64.Build.0 = Debug|x64
{7615F03F-E56D-4DB4-B23D-AC4FB80DB36F}.Debug|x86.ActiveCfg = Debug|x64
{7615F03F-E56D-4DB4-B23D-AC4FB80DB36F}.Debug|x86.Build.0 = Debug|x64
{7615F03F-E56D-4DB4-B23D-AC4FB80DB36F}.Release|x64.ActiveCfg = Release|x64
{7615F03F-E56D-4DB4-B23D-AC4FB80DB36F}.Release|x64.Build.0 = Release|x64
{7615F03F-E56D-4DB4-B23D-AC4FB80DB36F}.Release|x86.ActiveCfg = Release|x64
{7615F03F-E56D-4DB4-B23D-AC4FB80DB36F}.Release|x86.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
39 changes: 39 additions & 0 deletions src/projection/FileSearch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "pch.h"
#include "FileSearch.h"
#include "QueryResult.h"
#include "FileSearch.g.cpp"

using namespace winrt::Windows;

namespace winrt::Microsoft::SearchPlatform::implementation
{
// File search provider
FileSearch::FileSearch()
{
}

FileSearch::~FileSearch()
{
m_searchProvider.reset();
}

winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::SearchPlatform::QueryResult> FileSearch::Search(hstring const& query)
{
// Initialize the search platform API
m_searchProvider = std::make_unique<searchapi::FileSearchProvider>();
m_searchProvider->PrepareForSearch({}, {}); // No included or excluded scopes for now

std::vector<searchapi::QueryResult> results = m_searchProvider->Search(query.c_str());

auto resultVector = winrt::single_threaded_vector<winrt::Microsoft::SearchPlatform::QueryResult>();
for (const auto& result : results)
{
const auto& qr = winrt::make_self<winrt::Microsoft::SearchPlatform::implementation::QueryResult>();
qr->_propSet = result.propSet;
qr->_uri = result.uri;
const winrt::Microsoft::SearchPlatform::QueryResult& r = *qr;
resultVector.Append(r);
}
return resultVector;
}
}
24 changes: 24 additions & 0 deletions src/projection/FileSearch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include "FileSearch.g.h"
#include "QueryResult.h"
#include "../api/SearchPlatAPI.h"

namespace winrt::Microsoft::SearchPlatform::implementation
{
struct FileSearch : FileSearchT<FileSearch>
{
FileSearch();
~FileSearch();

winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::SearchPlatform::QueryResult> Search(hstring const& query);

private:
std::unique_ptr<searchapi::FileSearchProvider> m_searchProvider;
};
}

namespace winrt::Microsoft::SearchPlatform::factory_implementation
{
BASIC_FACTORY(FileSearch);
}
13 changes: 13 additions & 0 deletions src/projection/FileSearch.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import "QueryResult.idl";

namespace Microsoft.SearchPlatform
{
runtimeclass FileSearch
{
FileSearch();
IVector<QueryResult> Search(String query);
};
}
3 changes: 3 additions & 0 deletions src/projection/Microsoft.SearchPlatform.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXPORTS
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
220 changes: 220 additions & 0 deletions src/projection/Microsoft.SearchPlatform.vcxproj

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/projection/QueryResult.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "pch.h"
#include "QueryResult.h"
#include "QueryResult.g.cpp"

using namespace winrt::Windows;

namespace winrt::Microsoft::SearchPlatform::implementation
{
// QueryResult implementation (if needed in the future)
}
21 changes: 21 additions & 0 deletions src/projection/QueryResult.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include "QueryResult.g.h"

namespace winrt::Microsoft::SearchPlatform::implementation
{
struct QueryResult : QueryResultT<QueryResult>
{
QueryResult() = default;
winrt::Windows::Foundation::Collections::IPropertySet _propSet{ nullptr };
winrt::hstring _uri;

winrt::Windows::Foundation::Collections::IPropertySet PropSet() const { return _propSet; }
winrt::hstring Uri() const { return _uri; }
};
}

namespace winrt::Microsoft::SearchPlatform::factory_implementation
{
// BASIC_FACTORY(QueryResult);
}
11 changes: 11 additions & 0 deletions src/projection/QueryResult.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

namespace Microsoft.SearchPlatform
{
runtimeclass QueryResult
{
Windows.Foundation.Collections.IPropertySet PropSet { get; };
String Uri { get; };
};
}
21 changes: 21 additions & 0 deletions src/projection/init.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation
// Licensed under the MIT license.

#include "pch.h"

#pragma warning(suppress : 26440) // Not interested in changing the specification of DllMain to make it noexcept given it's an interface to the OS.
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD reason, LPVOID /*reserved*/)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstDll);
break;
case DLL_PROCESS_DETACH:
break;
default:
break;
}

return TRUE;
}
17 changes: 17 additions & 0 deletions src/projection/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- The packages.config acts as the global version for all of the NuGet packages contained within. -->
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.2903.40" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.240111.5" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.231216.1" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.8.250907003" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK.Base" version="1.8.250831001" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK.Foundation" version="1.8.250906002" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK.WinUI" version="1.8.250906003" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK.Runtime" version="1.8.250907003" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK.DWrite" version="1.8.25090401" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK.InteractiveExperiences" version="1.8.250906004" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK.Widgets" version="1.8.250904007" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK.AI" version="1.8.37" targetFramework="native" />
<package id="Microsoft.Windows.SDK.BuildTools.MSIX" version="1.7.20250829.1" targetFramework="native" />
</packages>
4 changes: 4 additions & 0 deletions src/projection/pch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#include "pch.h"
114 changes: 114 additions & 0 deletions src/projection/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
// pch.h
// Header for platform projection include files
//

#pragma once

#define NOMCX
#define NOHELP
#define NOCOMM

// Manually include til after we include Windows.Foundation to give it winrt superpowers
#define BLOCK_TIL

///////////////////////////////////////////////////////////////////////////////////
// Below is the contents of Terminal's LibraryIncludes.h

// C
#include <climits>
#include <cwchar>
#include <cwctype>

// STL

// Block minwindef.h min/max macros to prevent <algorithm> conflict
#define NOMINMAX
// Exclude rarely-used stuff from Windows headers
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include <algorithm>
#include <atomic>
#include <cmath>
#include <deque>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <memory_resource>
#include <memory>
#include <mutex>
#include <new>
#include <numeric>
#include <optional>
#include <queue>
#include <regex>
#include <set>
#include <shared_mutex>
#include <span>
#include <stdexcept>
#include <string_view>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// WIL
#include <wil/com.h>
#include <wil/resource.h>
#include <wil/safecast.h>
#include <wil/stl.h>
#include <wil/filesystem.h>
// Due to the use of RESOURCE_SUPPRESS_STL in result.h, we need to include resource.h first, which happens
// implicitly through the includes above. If RESOURCE_SUPPRESS_STL is gone, the order doesn't matter anymore.
#include <wil/result.h>
#include <wil/nt_result_macros.h>

#define BASIC_FACTORY(typeName) \
struct typeName : typeName##T<typeName, implementation::typeName> \
{ \
};

//////////////////////////////////////////////////////////////////////////////////////

// This is inexplicable, but for whatever reason, cppwinrt conflicts with the
// SDK definition of this function, so the only fix is to undef it.
// from WinBase.h
// Windows::UI::Xaml::Media::Animation::IStoryboard::GetCurrentTime
#ifdef GetCurrentTime
#undef GetCurrentTime
#endif

#include <wil/cppwinrt.h>

#include <winrt/Windows.ApplicationModel.Resources.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>

#include <winrt/Windows.Graphics.Imaging.h>
#include <Windows.Graphics.Imaging.Interop.h>

#include <winrt/Microsoft.UI.Text.h>
#include <winrt/Microsoft.UI.Xaml.Controls.h>
// #include <winrt/Microsoft.UI.Xaml.Markup.h>
#include <winrt/Microsoft.UI.Xaml.Media.h>
#include <winrt/Microsoft.UI.Xaml.Media.Imaging.h>

// #include <winrt/Microsoft.UI.Xaml.Controls.h>

// Manually include til after we include Windows.Foundation to give it winrt superpowers
//#include "til.h"
#define _TIL_INLINEPREFIX __declspec(noinline) inline
//#include "til_string.h"

// #include <cppwinrt_utils.h>
//#include <wil/cppwinrt_helpers.h> // must go after the CoreDispatcher type is defined