microsoft / microsoft/testfx

Make Assert.IsNotNull generic and have it return the value that was checked

Open
#10,918 4 comments 0 reactions 0 assignees View on GitHub
area/assertion
Dominant language
C#
Stars
1k
Forks
312
Avg merge
8h 30m
Merged PRs (30d)
469

Description

## Summary

I'm 120% sure that the boat has long sailed for this proposal (with probably very good reasons, such as code side explosion), but I'll try anyway.

It would've been nice if the `Assert.IsNotNull()` overloads where generic and returned the value that was passed to it.
This would've allowed for nice code like this:
```c#
var fi = new System.IO.FileInfo(@"c:\temp\x.log");
var dir = Assert.IsNotNull(fi.Directory);
Assert.AreEqual("temp", dir.Name);
```

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing Assert.IsNotNull overloads in the MSTest framework and review how assertion APIs are organized. Assess the proposed generic return behavior and overload implications; done means the supported API behavior is defined and validated without an unmanageable overload expansion.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.