question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Return T from Assert.IsInstanceOfType<T>()

See original GitHub issue

This PR introduced the generic version of the Assert.IsInstanceOfType<T>(). It will be much more useful to return the T from the method, so the two lines of code

Assert.IsInstanceOfType<MyType>(obj);
var myTypeObj = (MyType)obj;

can be replaced with a single line

var myTypeObj = Assert.IsInstanceOfType<MyType>(obj);

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
gao-arturcommented, Jul 11, 2023

Removing UwpMinimum and WinUiMinimum helped. Thanks! For some reason, VS didn’t recognize the dotnet 8 sdk installed by the Build.cmd and I had to install it from here. But now I can build the code.

1reaction
gao-arturcommented, Jul 11, 2023

Sure. Will do it by the end of the week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does Assert.IsInstanceOfType(0.GetType(), typeof(int)) ...
I'm kind of new to unit testing, using Microsoft.VisualStudio.TestTools.UnitTesting ;. The 0.GetType() is actually System.RuntimeType , so what ...
Read more >
Assert.IsInstanceOfType Method
Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in...
Read more >
Add Assert.IsType<T>(object obj) · Issue #413
xUnit has a nice Assert method: public static T IsType<T>(object @object) that is lacking from MS Test. MS Test has an "old" method:...
Read more >
The Assert.IsInstanceOfType Headache - Developer Aspirin
GetType() method returns System.RuntimeType instead of the type of the object. target itself is a specific base class and the instance is ...
Read more >
Assert.IsInstanceOf
IsInstanceOf succeeds if the object provided as an actual value is an instance of the expected type. Assert.IsInstanceOf(Type expected, object actual); Assert.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found