Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning for Assert.AreNotSame calls with value types #4478

Open
Youssef1313 opened this issue Dec 30, 2024 · 1 comment
Open

Warning for Assert.AreNotSame calls with value types #4478

Youssef1313 opened this issue Dec 30, 2024 · 1 comment
Assignees

Comments

@Youssef1313
Copy link
Member

Youssef1313 commented Dec 30, 2024

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

@Youssef1313
Copy link
Member Author

FYI @Evangelink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant