MSTEST0039:使用较新的“Assert.Throws”方法
properties | 值 |
---|---|
规则 ID | MSTEST0039 |
标题 | 使用较新的“Assert.Throws”方法 |
类别 | 使用情况 |
修复是中断修复还是非中断修复 | 非中断 |
默认已启用 | 是 |
默认严重性 | 信息 |
在版本 中引入 | 3.8.0 |
有代码修复吗 | 是 |
原因
不再推荐使用 Assert.ThrowsException 或 Assert.ThrowsExceptionAsync这两种标号。
规则说明
不建议使用 Assert.ThrowsException 和 Assert.ThrowsExceptionAsync,将来可能会被弃用。
如何解决违规
使用 Assert.ThrowsExactly
或 Assert.ThrowsExactlyAsync
而不是 Assert.ThrowsException
或 Assert.ThrowsExceptionAsync
。
何时禁止显示警告
不禁止显示此规则发出的警告。 强烈建议从旧 API 迁移到新 API。