dotnet-inspect

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

dotnet-inspect

dotnet-inspect

Query .NET library APIs — the same commands work across NuGet packages, platform libraries (System., Microsoft.AspNetCore.), and local .dll/.nupkg files.
跨NuGet包、平台库(System.、Microsoft.AspNetCore.)和本地.dll/.nupkg文件查询.NET库API —— 相同的命令可在所有场景下使用。

When to Use This Skill

何时使用该工具

  • "What types are in this package?"
    find
    searches by glob pattern
  • "What's the API surface?"
    api
    lists types, members, signatures, type shape
  • "What changed between versions?"
    diff
    classifies breaking/additive changes
  • "What extends this type?"
    extensions
    finds extension methods/properties
  • "What implements this interface?"
    implements
    finds concrete types
  • "What version/metadata does this have?"
    package
    and
    library
    inspect metadata
  • “此包中有哪些类型?” —— 使用
    find
    命令通过通配符模式搜索
  • “API接口是什么?” ——
    api
    命令列出类型、成员、签名、类型结构
  • “不同版本之间有哪些变化?” ——
    diff
    命令分类显示破坏性/新增变化
  • “哪些内容扩展了该类型?” ——
    extensions
    命令查找扩展方法/属性
  • “哪些类型实现了该接口?” ——
    implements
    命令查找具体类型
  • “它的版本/元数据是什么?” ——
    package
    library
    命令检查元数据

Search Scope

搜索范围

Search commands (
find
,
extensions
,
implements
) work across all of .NET:
bash
dnx dotnet-inspect -y -- find "Chat*"                    # default scope (platform + curated)
dnx dotnet-inspect -y -- find "Chat*" --platform         # platform frameworks only
dnx dotnet-inspect -y -- find "Chat*" --extensions       # Microsoft.Extensions.* packages
dnx dotnet-inspect -y -- find "Chat*" --aspnetcore       # Microsoft.AspNetCore.* packages
dnx dotnet-inspect -y -- find "Chat*" --platform --extensions  # combine scopes
dnx dotnet-inspect -y -- find "Chat*" --package Foo      # specific NuGet package
dnx dotnet-inspect -y -- find "Chat*" --platform --package Foo  # platform + a specific package
Scope flags are combinable — use multiple flags to widen the search.
--package
works on all commands.
api
,
library
,
diff
also accept
--platform <name>
for a specific platform library.
搜索命令(
find
extensions
implements
)可在整个.NET生态中使用:
bash
dnx dotnet-inspect -y -- find "Chat*"                    # 默认范围(平台+精选库)
dnx dotnet-inspect -y -- find "Chat*" --platform         # 仅平台框架
dnx dotnet-inspect -y -- find "Chat*" --extensions       # 仅Microsoft.Extensions.*包
dnx dotnet-inspect -y -- find "Chat*" --aspnetcore       # 仅Microsoft.AspNetCore.*包
dnx dotnet-inspect -y -- find "Chat*" --platform --extensions  # 组合范围
dnx dotnet-inspect -y -- find "Chat*" --package Foo      # 指定NuGet包
dnx dotnet-inspect -y -- find "Chat*" --platform --package Foo  # 平台+指定包
范围标志可组合使用——使用多个标志扩大搜索范围。
--package
适用于所有命令。
api
library
diff
命令也支持
--platform <name>
来指定具体的平台库。

Examples by Task

按任务分类的示例

List API surface

列出API接口

bash
dnx dotnet-inspect -y -- api System.Text.Json                              # all types in library
dnx dotnet-inspect -y -- api System.Text.Json JsonSerializer               # members of a type
dnx dotnet-inspect -y -- api 'HashSet<T>' --platform System.Collections --shape  # type shape diagram
dnx dotnet-inspect -y -- api JsonSerializer --package System.Text.Json -m Serialize  # filter to member
bash
dnx dotnet-inspect -y -- api System.Text.Json                              # 库中的所有类型
dnx dotnet-inspect -y -- api System.Text.Json JsonSerializer               # 类型的成员
dnx dotnet-inspect -y -- api 'HashSet<T>' --platform System.Collections --shape  # 类型结构示意图
dnx dotnet-inspect -y -- api JsonSerializer --package System.Text.Json -m Serialize  # 筛选成员

Search for types

搜索类型

bash
dnx dotnet-inspect -y -- find "*Handler*" --package System.CommandLine
dnx dotnet-inspect -y -- find "Option*,Argument*,Command*" --package System.CommandLine --terse
dnx dotnet-inspect -y -- find "*Logger*"
bash
dnx dotnet-inspect -y -- find "*Handler*" --package System.CommandLine
dnx dotnet-inspect -y -- find "Option*,Argument*,Command*" --package System.CommandLine --terse
dnx dotnet-inspect -y -- find "*Logger*"

Compare versions (migrations)

比较版本(迁移场景)

bash
dnx dotnet-inspect -y -- diff --package System.CommandLine@2.0.0-beta4.22272.1..2.0.2
dnx dotnet-inspect -y -- diff --package System.Text.Json@9.0.0..10.0.0 --breaking
dnx dotnet-inspect -y -- diff JsonSerializer --package System.Text.Json@9.0.0..10.0.0
bash
dnx dotnet-inspect -y -- diff --package System.CommandLine@2.0.0-beta4.22272.1..2.0.2
dnx dotnet-inspect -y -- diff --package System.Text.Json@9.0.0..10.0.0 --breaking
dnx dotnet-inspect -y -- diff JsonSerializer --package System.Text.Json@9.0.0..10.0.0

Find extensions and implementors

查找扩展和实现类

bash
dnx dotnet-inspect -y -- extensions HttpClient                   # what extends HttpClient?
dnx dotnet-inspect -y -- extensions IServiceCollection           # across default scope
dnx dotnet-inspect -y -- implements Stream                       # what extends Stream?
dnx dotnet-inspect -y -- implements IDisposable --platform       # across all platform frameworks
bash
dnx dotnet-inspect -y -- extensions HttpClient                   # 哪些内容扩展了HttpClient?
dnx dotnet-inspect -y -- extensions IServiceCollection           # 在默认范围内查找
dnx dotnet-inspect -y -- implements Stream                       # 哪些类型继承自Stream?
dnx dotnet-inspect -y -- implements IDisposable --platform       # 在所有平台框架中查找

Inspect packages and libraries

检查包和库

bash
dnx dotnet-inspect -y -- package System.Text.Json                # metadata, latest version
dnx dotnet-inspect -y -- package System.Text.Json --versions     # available versions
dnx dotnet-inspect -y -- library System.Text.Json                # library metadata, symbols
dnx dotnet-inspect -y -- library ./bin/MyLib.dll                 # local file
bash
dnx dotnet-inspect -y -- package System.Text.Json                # 元数据、最新版本
dnx dotnet-inspect -y -- package System.Text.Json --versions     # 可用版本
dnx dotnet-inspect -y -- library System.Text.Json                # 库元数据、符号
dnx dotnet-inspect -y -- library ./bin/MyLib.dll                 # 本地文件

Command Reference

命令参考

CommandPurpose
api
Public API surface — types, members, signatures,
--shape
for hierarchy
find
Search for types by glob pattern across any scope
diff
Compare API surfaces between versions — breaking/additive classification
extensions
Find extension methods/properties for a type
implements
Find types implementing an interface or extending a base class
package
Package metadata, files, versions, dependencies
library
Library metadata, symbols, references, dependencies
命令用途
api
公共API接口 —— 类型、成员、签名,
--shape
参数可查看层级结构
find
跨任意范围通过通配符模式搜索类型
diff
比较不同版本间的API接口 —— 分类显示破坏性/新增变化
extensions
查找类型的扩展方法/属性
implements
查找实现接口或继承基类的类型
package
包元数据、文件、版本、依赖项
library
库元数据、符号、引用、依赖项

Key Syntax

关键语法

  • Generic types need quotes:
    'Option<T>'
    ,
    'IEnumerable<T>'
  • Positional args for
    api
    :
    api <source> <type> <member>
    (not flags)
  • Diff ranges use
    ..
    :
    --package System.Text.Json@9.0.0..10.0.0
  • Signatures include
    params
    and default values from metadata
  • 泛型类型需要加引号:
    'Option<T>'
    'IEnumerable<T>'
  • api命令的位置参数
    api <源> <类型> <成员>
    (非标志参数)
  • 版本对比范围使用
    ..
    --package System.Text.Json@9.0.0..10.0.0
  • 签名包含元数据中的
    params
    和默认值

Installation

安装

Use
dnx
(like
npx
). Always use
-y
and
--
to prevent interactive prompts:
bash
dnx dotnet-inspect -y -- <command>
使用
dnx
(类似
npx
)。请始终使用
-y
--
以避免交互式提示:
bash
dnx dotnet-inspect -y -- <command>

Full Documentation

完整文档

For comprehensive syntax, edge cases, and the flag compatibility matrix:
bash
dnx dotnet-inspect -y -- llmstxt
如需了解全面的语法、边缘情况和标志兼容性矩阵:
bash
dnx dotnet-inspect -y -- llmstxt