winmd-api-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

WinMD API Search

WinMD API搜索

This skill helps you find the right Windows API for any capability and get its full details. It searches a local cache of all WinMD metadata from:
  • Windows Platform SDK — all
    Windows.*
    WinRT APIs (always available, no restore needed)
  • WinAppSDK / WinUI — bundled as a baseline in the cache generator (always available, no restore needed)
  • NuGet packages — any additional packages in restored projects that contain
    .winmd
    files
  • Project-output WinMD — class libraries (C++/WinRT, C#) that produce
    .winmd
    as build output
Even on a fresh clone with no restore or build, you still get full Platform SDK + WinAppSDK coverage.
这个技能可以帮助你为任意功能找到合适的Windows API并获取其完整详情。它会搜索所有WinMD元数据的本地缓存,这些元数据来自:
  • Windows Platform SDK — 所有
    Windows.*
    WinRT API(始终可用,无需还原)
  • WinAppSDK / WinUI — 作为基线捆绑在缓存生成器中(始终可用,无需还原)
  • NuGet packages — 已还原项目中所有包含
    .winmd
    文件的额外依赖包
  • Project-output WinMD — 生成
    .winmd
    作为构建输出的类库(C++/WinRT、C#)
即使是刚克隆、没有执行过还原或构建的项目,你也能获得完整的Platform SDK + WinAppSDK覆盖。

When to Use This Skill

何时使用这个技能

  • User wants to build a feature and you need to find which API provides that capability
  • User asks "how do I do X?" where X involves a platform feature (camera, files, notifications, sensors, AI, etc.)
  • You need the exact methods, properties, events, or enumeration values of a type before writing code
  • You're unsure which control, class, or interface to use for a UI or system task
  • 用户想要构建某个功能,你需要找到哪个API提供了对应的能力
  • 用户询问「我如何实现X?」,其中X涉及平台功能(相机、文件、通知、传感器、AI等)
  • 你需要在编写代码前获取某个类型的精确方法、属性、事件或枚举值
  • 你不确定应该为UI或系统任务使用哪个控件、类或接口

Prerequisites

前置要求

  • .NET SDK 8.0 or later — required to build the cache generator. Install from dotnet.microsoft.com if not available.
  • .NET SDK 8.0 或更高版本 — 构建缓存生成器的必要条件。如果未安装,可以从dotnet.microsoft.com下载安装。

Cache Setup (Required Before First Use)

缓存设置(首次使用前必须配置)

All query and search commands read from a local JSON cache. You must generate the cache before running any queries.
powershell
undefined
所有查询和搜索命令都从本地JSON缓存读取数据。运行任何查询前你必须先生成缓存。
powershell
undefined

All projects in the repo (recommended for first run)

仓库内所有项目(首次运行推荐)

..github\skills\winmd-api-search\scripts\Update-WinMdCache.ps1
..github\skills\winmd-api-search\scripts\Update-WinMdCache.ps1

Single project

单个项目

..github\skills\winmd-api-search\scripts\Update-WinMdCache.ps1 -ProjectDir <project-folder>

No project restore or build is needed for baseline coverage (Platform SDK + WinAppSDK). For additional NuGet packages, the project needs `dotnet restore` (which generates `project.assets.json`) or a `packages.config` file.

Cache is stored at `Generated Files\winmd-cache\`, deduplicated per-package+version.
..github\skills\winmd-api-search\scripts\Update-WinMdCache.ps1 -ProjectDir <project-folder>

基线覆盖(Platform SDK + WinAppSDK)不需要项目还原或构建。如果需要包含额外的NuGet包,项目需要执行`dotnet restore`(会生成`project.assets.json`)或者有`packages.config`文件。

缓存存储在`Generated Files\winmd-cache\`下,按包+版本去重。

What gets indexed

索引内容

SourceWhen available
Windows Platform SDKAlways (reads from local SDK install)
WinAppSDK (latest)Always (bundled as baseline in cache generator)
WinAppSDK RuntimeWhen installed on the system (detected via
Get-AppxPackage
)
Project NuGet packagesAfter
dotnet restore
or with
packages.config
Project-output
.winmd
After project build (class libraries that produce WinMD)
Note: This cache directory should be in
.gitignore
— it's generated, not source.
来源可用条件
Windows Platform SDK始终可用(从本地SDK安装路径读取)
WinAppSDK(最新版)始终可用(作为基线捆绑在缓存生成器中)
WinAppSDK Runtime系统已安装时(通过
Get-AppxPackage
检测)
项目NuGet包执行
dotnet restore
后或存在
packages.config
文件时
项目输出
.winmd
项目构建后(生成WinMD的类库)
注意: 该缓存目录应该加入
.gitignore
— 它是生成的文件,不属于源码。

How to Use

使用方法

Pick the path that matches the situation:

选择符合场景的路径:

Discover — "I don't know which API to use"

探索 —「我不知道该用哪个API」

The user describes a capability in their own words. You need to find the right API.
0. Ensure the cache exists
If the cache hasn't been generated yet, run
Update-WinMdCache.ps1
first — see Cache Setup above.
1. Translate user language → search keywords
Map the user's daily language to programming terms. Try multiple variations:
User saysSearch keywords to try (in order)
"take a picture"
camera
,
capture
,
photo
,
MediaCapture
"load from disk"
file open
,
picker
,
FileOpen
,
StorageFile
"describe what's in it"
image description
,
Vision
,
Recognition
"show a popup"
dialog
,
flyout
,
popup
,
ContentDialog
"drag and drop"
drag
,
drop
,
DragDrop
"save settings"
settings
,
ApplicationData
,
LocalSettings
Start with simple everyday words. If results are weak or irrelevant, try the more technical variation.
2. Run searches
powershell
.\.github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action search -Query "<keyword>"
This returns ranked namespaces with top matching types and the JSON file path.
If results have low scores (below 60) or are irrelevant, fall back to searching online documentation:
  1. Use web search to find the right API on Microsoft Learn, for example:
    • site:learn.microsoft.com/uwp/api <capability keywords>
      for
      Windows.*
      APIs
    • site:learn.microsoft.com/windows/windows-app-sdk/api/winrt <capability keywords>
      for
      Microsoft.*
      WinAppSDK APIs
  2. Read the documentation pages to identify which type matches the user's requirement.
  3. Once you know the type name, come back and use
    -Action members
    or
    -Action enums
    to get the exact local signatures.
3. Read the JSON to choose the right API
Read the file at the path(s) from the top results. The JSON has all types in that namespace — full members, signatures, parameters, return types, enumeration values.
Read and decide which types and members fit the user's requirement.
4. Look up official documentation for context
The cache contains only signatures — no descriptions or usage guidance. For explanations, examples, and remarks, look up the type on Microsoft Learn:
Namespace prefixDocumentation base URL
Windows.*
https://learn.microsoft.com/uwp/api/{fully.qualified.typename}
Microsoft.*
(WinAppSDK)
https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/{fully.qualified.typename}
For example,
Microsoft.UI.Xaml.Controls.NavigationView
maps to:
https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.navigationview
5. Use the API knowledge to answer or write code

用户用自己的话描述所需的能力,你需要找到合适的API。
0. 确认缓存已存在
如果还没生成缓存,先运行
Update-WinMdCache.ps1
— 参考上文缓存设置
1. 将用户语言转换为搜索关键词
将用户的日常语言映射为编程术语,尝试多种变体:
用户表述可尝试的搜索关键词(按顺序)
"拍照"
camera
,
capture
,
photo
,
MediaCapture
"从磁盘加载"
file open
,
picker
,
FileOpen
,
StorageFile
"描述里面的内容"
image description
,
Vision
,
Recognition
"显示弹窗"
dialog
,
flyout
,
popup
,
ContentDialog
"拖拽"
drag
,
drop
,
DragDrop
"保存设置"
settings
,
ApplicationData
,
LocalSettings
先从简单的日常用词开始,如果结果得分低或不相关,再尝试更专业的变体。
2. 执行搜索
powershell
.\.github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action search -Query "<keyword>"
这会返回排序后的命名空间,包含匹配度最高的类型以及JSON文件路径
如果结果得分低(低于60)或不相关,可以回退到在线文档搜索:
  1. 使用网页搜索在Microsoft Learn上找到合适的API,例如:
    • site:learn.microsoft.com/uwp/api <capability keywords>
      用于查找
      Windows.*
      APIs
    • site:learn.microsoft.com/windows/windows-app-sdk/api/winrt <capability keywords>
      用于查找
      Microsoft.*
      WinAppSDK APIs
  2. 阅读文档页面,找到符合用户需求的类型。
  3. 知道类型名称后,回到这里使用
    -Action members
    -Action enums
    获取精确的本地签名。
3. 读取JSON选择合适的API
读取顶部结果中路径对应的文件,JSON包含该命名空间下的所有类型 — 完整的成员、签名、参数、返回类型、枚举值。
阅读并判断哪些类型和成员符合用户需求。
4. 查阅官方文档获取上下文
缓存仅包含签名 — 没有描述或使用指引。如需解释、示例和备注,可以在Microsoft Learn上查找对应类型:
命名空间前缀文档基础URL
Windows.*
https://learn.microsoft.com/uwp/api/{fully.qualified.typename}
Microsoft.*
(WinAppSDK)
https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/{fully.qualified.typename}
例如,
Microsoft.UI.Xaml.Controls.NavigationView
对应的URL是:
https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.navigationview
5. 利用API知识回答问题或编写代码

Lookup — "I know the API, show me the details"

查找 —「我知道这个API,给我看详情」

You already know (or suspect) the type or namespace name. Go direct:
powershell
undefined
你已经知道(或猜测)类型或命名空间名称,可以直接查询:
powershell
undefined

Get all members of a known type

获取已知类型的所有成员

..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action members -TypeName "Microsoft.UI.Xaml.Controls.NavigationView"
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action members -TypeName "Microsoft.UI.Xaml.Controls.NavigationView"

Get enum values

获取枚举值

..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action enums -TypeName "Microsoft.UI.Xaml.Visibility"
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action enums -TypeName "Microsoft.UI.Xaml.Visibility"

List all types in a namespace

列出命名空间下的所有类型

..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action types -Namespace "Microsoft.UI.Xaml.Controls"
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action types -Namespace "Microsoft.UI.Xaml.Controls"

Browse namespaces

浏览命名空间

..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action namespaces -Filter "Microsoft.UI"

If you need full detail beyond what `-Action members` shows, use `-Action search` to get the JSON file path, then read the JSON file directly.

---
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action namespaces -Filter "Microsoft.UI"

如果需要比`-Action members`显示的更完整的详情,可以使用`-Action search`获取JSON文件路径,然后直接读取JSON文件。

---

Other Commands

其他命令

powershell
undefined
powershell
undefined

List cached projects

列出已缓存的项目

..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action projects
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action projects

List packages for a project

列出项目的依赖包

..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action packages
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action packages

Show stats

显示统计信息

..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action stats

> If only one project is cached, `-Project` is auto-selected.
> If multiple projects exist, add `-Project <name>` (use `-Action projects` to see available names).
> In scan mode, manifest names include a short hash suffix to avoid collisions; you can pass the base project name without the suffix if it's unambiguous.
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action stats

> 如果仅缓存了一个项目,`-Project`会自动选中。
> 如果存在多个项目,添加`-Project <name>`(使用`-Action projects`查看可用名称)。
> 在扫描模式下,清单名称包含短哈希后缀以避免冲突;如果没有歧义,你可以传递不带后缀的基础项目名称。

Search Scoring

搜索评分

The search ranks type names and member names against your query:
ScoreMatch typeExample
100Exact name
Button
Button
80Starts with
Navigation
NavigationView
60Contains
Dialog
ContentDialog
50PascalCase initials
ASB
AutoSuggestBox
40Multi-keyword AND
navigation item
NavigationViewItem
20Fuzzy character match
NavVw
NavigationView
Results are grouped by namespace. Higher-scored namespaces appear first.
搜索会根据你的查询对类型名称和成员名称进行排名:
得分匹配类型示例
100完全匹配名称
Button
Button
80前缀匹配
Navigation
NavigationView
60包含匹配
Dialog
ContentDialog
50PascalCase首字母匹配
ASB
AutoSuggestBox
40多关键词与匹配
navigation item
NavigationViewItem
20模糊字符匹配
NavVw
NavigationView
结果按命名空间分组,得分更高的命名空间排在前面。

Troubleshooting

故障排查

IssueFix
"Cache not found"Run
Update-WinMdCache.ps1
"Multiple projects cached"Add
-Project <name>
"Namespace not found"Use
-Action namespaces
to list available ones
"Type not found"Use fully qualified name (e.g.,
Microsoft.UI.Xaml.Controls.Button
)
Stale after NuGet updateRe-run
Update-WinMdCache.ps1
Cache in git historyAdd
Generated Files/
to
.gitignore
问题解决方法
"Cache not found"运行
Update-WinMdCache.ps1
"Multiple projects cached"添加
-Project <name>
"Namespace not found"使用
-Action namespaces
列出可用的命名空间
"Type not found"使用完全限定名(例如
Microsoft.UI.Xaml.Controls.Button
NuGet更新后缓存过期重新运行
Update-WinMdCache.ps1
缓存出现在git历史中
Generated Files/
添加到
.gitignore

References

参考