Skip to content

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

Description

@drieseng

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:

var fi = new System.IO.FileInfo(@"c:\temp\x.log");
var dir = Assert.IsNotNull(fi.Directory);
Assert.AreEqual("temp", dir.Name);

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/assertionAssert / StringAssert / CollectionAssert APIs.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions