User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: Assert while restarting Noesis (trying to init after shutdown)

17 Nov 2021, 16:17

Thank you!
 
AndreN
Posts: 11
Joined: 01 Sep 2015, 08:28

Re: Assert while restarting Noesis (trying to init after shutdown)

22 Apr 2022, 11:10

Hello,

I just want to comment on that topic.

I also run into this situation (Init after Shutdown) when trying to implement unit-tests for code, which needs the Noesis C# SDK.
Currently I handle the Init and Shutdown in a IDisposable context, thus when the context is created it calls Init and it calls Shutdown when the context is disposed.
This works very nice in the application itself without the need of having global objects.

However in case of unit-tests, the natural solution would be to set the context up for every test and to dispose it after every test (in teardown). This obviously does not work when an Init after a Shutdown is not possible.

So, the only solution I can think of here is having the context on global level as singleton, where shutdown is only called when objects from the global memory gets finalized by the garbage collector. Then the application can just use the context from global level and tests share together the same context. This is not ideal, because tests are then sharing memory resources, which can lead to a lot of further strange behavior. But I can't come up with a better idea for now.

Therefore, also for test purpose, it would help to make calls to Init possible after a Shutdown. However, I understand that this is a major change in the library with high risk of breaking legacy code. And I also understand that running tests against Noesis C# SDK might not be the priority for many customers.
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: Assert while restarting Noesis (trying to init after shutdown)

25 Apr 2022, 19:06

However in case of unit-tests, the natural solution would be to set the context up for every test and to dispose it after every test (in teardown). This obviously does not work when an Init after a Shutdown is not possible.
Many things happens at Init time, I don't think calling it per test would be a good idea. Anyway, right now the only solution is doing this globally, in your process. There are plans to slightly improve this, but as you said, changes at this level can break legacy code but it will happen soon or later. We still have to solve internal things in the reflection mechanism to property solve this.

Anway, thanks a lot for your feedback!

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 6 guests