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

[BUG] Locator WithResolver not testable #382

Open
dpvreony opened this issue Aug 6, 2019 · 0 comments
Open

[BUG] Locator WithResolver not testable #382

dpvreony opened this issue Aug 6, 2019 · 0 comments

Comments

@dpvreony
Copy link
Member

dpvreony commented Aug 6, 2019

from @anaisbetts
Consider the following:

  1. Test Initial project structure #1 calls WithResolver(), as a part of that by default we suppress auto-registration - this is implemented as an atomic refcount, we add a ref
  2. Test Platform-independent Bitmaps #2 kicks off, it calls WithResolver(false) - we set the resolver, but because the prev ref is still at 1, the new resolver doesn't get initialized
  3. Test Initial project structure #1 finally finishes, we remove our ref (edited)

The ThreadStatic trick is definitely like, a compromise
Basically the core idea is, if you try to Set the locator, and you're in a unit test, we'll per-thread set it
If you're in the app, we never do this ThreadStatic bizness
MainThreadScheduler works similarly
So it means you can have two tests who pave Locator at the same time, and they might work, ofc if you schedule a Task everything falls over
But, we make you fall over a little less often
What you really want is "TaskContextStatic", i.e. something that follows the same "context" across a bunch of threads

Which I think exists now, but definitely didn't at the time
Maybe this is https://docs.microsoft.com/en-us/dotnet/api/system.threading.asynclocal-1?redirectedfrom=MSDN&view=netframework-4.8?

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