Giter VIP home page Giter VIP logo

Comments (8)

AArnott avatar AArnott commented on July 4, 2024

What OS and .NET runtime are you running your test on?

from xunit.stafact.

LarsPal avatar LarsPal commented on July 4, 2024

from xunit.stafact.

AArnott avatar AArnott commented on July 4, 2024

It should work in that environment. Can you share a minimal repro zip file?

from xunit.stafact.

LarsPal avatar LarsPal commented on July 4, 2024

Here is a small project that shows the problem.
StaFactTestProject.zip

from xunit.stafact.

AArnott avatar AArnott commented on July 4, 2024

Wow. That seems ... totally broken. I'll see what I can do to fix it.

from xunit.stafact.

AArnott avatar AArnott commented on July 4, 2024

Ok, the reason is your test project targets something less than net472. xunit.stafact now targets net472 so although VS test discovery will find your test, xunit cannot run it since xunit.stafact.dll targets a newer framework than your test. Bump your test to net472 to resolve.

from xunit.stafact.

LarsPal avatar LarsPal commented on July 4, 2024

Thanks! It's working with 4.7.2. Is it correct that, if running your sample then this
Assert.Equal(originalThread, Environment.CurrentManagedThreadId);
will fail for StaFact but not for [UIFact], [WinFormsFact] or [WpfFact]?
Should you not get the same ThreadId also for StaFact?

from xunit.stafact.

AArnott avatar AArnott commented on July 4, 2024

If you're talking about that Assert appearing after an await, yes it would be expected to fail.

Awaits rely on a SynchronizationContext.Current or TaskScheduler.Current to get you back to the original "context" to execute the rest of an async method on. They can't just magically get you on a given thread. STA threads are no different: the only thing that can get an await to resume on that same thread is if a SynchronizationContext is applied. But STAFact is just a plain vanilla STA thread. If your purpose is to get UI-thread like semantics where a SynchronizationContext is applied to the thread so await brings you back to the original thread, then you should use those other attributes you named.

from xunit.stafact.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.