Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Warning for Assert.AreNotSame calls with value types #4478

Copy link
Copy link

Description

@Youssef1313
Issue body actions

Summary

Similar to #4352, we should also warn when Assert.AreNotSame is called with at least one argument being a value type.
Such assert will never fail and is likely not the intent.

Background and Motivation

Searching quickly with grep.app, I found a violation example here:

https://github.com/jmpoep/vmprotect-3.5.1/blob/d8fcb7c0ffd4fb45a8cfbd770c8b117d7dbe52b5/runtime/VMProtect.Runtime/Tests/UnitTestProject/UnitTest1.cs#L34

The linked assert will not fail even if hwid.ToString().Length is zero, which is clearly not the intent of the assertion.

Proposed Feature

An analyzer to warn when Assert.AreNotSame is called with value types.

Alternative Designs

AB#2331954

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

area/analyzersMSTest.Analyzers Roslyn analyzers and code fixes.MSTest.Analyzers Roslyn analyzers and code fixes.state/in-prA PR is open for this issue.A PR is open for this issue.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.