dotnet-inspect-correctness

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

dotnet-inspect: correctness and safety

dotnet-inspect:正确性与安全性

Use this skill to judge whether code is sound and safe to call: what it can throw, how it handles errors, and where it steps outside safe, managed execution. This is single-version analysis; for how these signals change between versions, use the compatibility skill.
bash
dnx dotnet-inspect -y -- <command>
使用该技能判断代码是否可靠且调用安全:它可能抛出什么异常、如何处理错误,以及在哪些地方脱离了安全的托管执行环境。这是单版本分析;若要查看这些信号在不同版本间的变化,请使用兼容性技能。
bash
dnx dotnet-inspect -y -- <command>

What can it throw? (exception surface)

它可能抛出什么异常?(异常范围)

There is no dedicated "Exceptions" section; exception behavior comes from method-body analysis.
Exception Regions
shows the exact catch/filter/finally layout; graph fields and hidden facts summarize behavior:
bash
dnx dotnet-inspect -y -- member Type Method:1 -S "Exception Regions"
dnx dotnet-inspect -y -- member Type Method:1 -S "Call Graph" --fields "Throws,ThrowSites,ExceptionTypes,ConstructedExceptions,Catch,Finally"
dnx dotnet-inspect -y -- member Type Method:1 -S "Call Graph" --fields "Throws,Catch,Finally"
dnx dotnet-inspect -y -- member Type Method:1 -S Facts --tsv
Throws
/
ThrowSites
count throw sites;
ExceptionTypes
/
ConstructedExceptions
name the exception types;
Catch
/
Finally
show handling.
Exception Regions
retains IL ranges and caught types.
-S Facts
(member, single method) lists the hidden facts in the body and supports
--tsv
.
没有专门的“异常”章节;异常行为来自方法体分析。
Exception Regions
展示了确切的捕获/筛选/最终块布局;图表字段和隐藏事实汇总了相关行为:
bash
dnx dotnet-inspect -y -- member Type Method:1 -S "Exception Regions"
dnx dotnet-inspect -y -- member Type Method:1 -S "Call Graph" --fields "Throws,ThrowSites,ExceptionTypes,ConstructedExceptions,Catch,Finally"
dnx dotnet-inspect -y -- member Type Method:1 -S "Call Graph" --fields "Throws,Catch,Finally"
dnx dotnet-inspect -y -- member Type Method:1 -S Facts --tsv
Throws
/
ThrowSites
统计抛出点数量;
ExceptionTypes
/
ConstructedExceptions
列出异常类型;
Catch
/
Finally
展示处理逻辑。
Exception Regions
保留了IL范围和捕获的类型。
-S Facts
(成员、单个方法)列出方法体内的隐藏事实,并支持
--tsv
格式。

Is it memory-safe? (unsafe operations)

它是否内存安全?(不安全操作)

bash
dnx dotnet-inspect -y -- member Type Method:1 --library MyLib.dll -S "Unsafe Operations,IL"
-S "Unsafe Operations"
shows the unsafe operations in a single method body, with IL evidence. For the library-wide safety surface (unsafe members, P/Invoke methods) and provenance/supply-chain signals, see the
signals
skill.
For one crash or profiler coordinate, use
library --il-offset 0x06000001+0x5
for the default source-location, member, instruction, exception, callsite, and return-address context. Safety evidence is opt-in:
--il-offset 0x06000001+0x5 -S "Context: Safety"
.
To confirm whether one definite unsafe operation appeared at an adjacent version boundary, first correlate caller-selected package cells:
bash
dnx dotnet-inspect -y -- timeline --package MyLib@1.0.0..2.0.0 \
  -t MyType -m Method \
  --finding analysis.unsafety --at first --at last
Repeat
--at
for sparse probes or use
--at all
for an explicitly bounded dense traversal. A gap-spanning
Added
row locates a candidate boundary; it does not claim the exact introduction version. Confirm the adjacent pair:
bash
dnx dotnet-inspect -y -- diff --package MyLib@1.4.0..1.5.0 \
  -t MyType -m Method \
  --finding analysis.unsafety
PairFinding.Added
is the introduction proof.
Present
and
Removed
distinguish persistence from disappearance; the command compares only the two supplied endpoints.
bash
dnx dotnet-inspect -y -- member Type Method:1 --library MyLib.dll -S "Unsafe Operations,IL"
-S "Unsafe Operations"
展示单个方法体内的不安全操作,并提供IL证据。若要查看库级别的安全范围(不安全成员、P/Invoke方法)以及来源/供应链信号,请查看
signals
技能。
对于单个崩溃或探查器坐标,使用
library --il-offset 0x06000001+0x5
获取默认的源位置、成员、指令、异常、调用点和返回地址上下文。安全证据为可选开启:
--il-offset 0x06000001+0x5 -S "Context: Safety"
要确认某个明确的不安全操作是否出现在相邻版本边界,首先关联调用者选择的包单元:
bash
dnx dotnet-inspect -y -- timeline --package MyLib@1.0.0..2.0.0 \
  -t MyType -m Method \
  --finding analysis.unsafety --at first --at last
重复
--at
参数可进行稀疏探查,或使用
--at all
进行明确边界内的密集遍历。跨版本间隙的
Added
行定位了候选边界,但不代表确切的引入版本。请确认相邻版本对:
bash
dnx dotnet-inspect -y -- diff --package MyLib@1.4.0..1.5.0 \
  -t MyType -m Method \
  --finding analysis.unsafety
PairFinding.Added
是引入的证据。
Present
Removed
区分了持续存在与消失的情况;该命令仅比较提供的两个端点版本。