Stevvvvvvvvvvvvvvvvvie
Stevvvvvvvvvvvvvvvvvie
CC#
Created by Stevvvvvvvvvvvvvvvvvie on 8/15/2023 in #help
✅ Use static class or DI?
I have a situation where i am not sure, whether i should use dependency injection or just a static class. In my software, some clients are connection to a server. After the connection is set up, some data is stored (basically a dictionary with an client id + some data). In my current approach, i would just use a class "ClientCache" containing the cached data and a static dictionary with an id as key and a ClientCache as value. I chose this approach, as the ClientCache does not have any dependencies or context. If i register it to the service container, it would just be a singleton. Using DI for this specific class would not have any advantages at all (it just would mean a little more work). That said, there is one problem: the testing. The static dictionary is shared between all tests. Therefor i need to manually ensure, that the id is unique in all tests. Apart from that, everything is testable very well and there are no drawbacks if i am not using DI. Now my question: is it fine to give the developer the "responsibility" to ensure, that the client ids are unique or should i use the DI approach instead? Basically i think the static approach would be way cleaner, but i am not sure if that justifies the risks of invalid test cases/test setups (i think rather small risks, as the behavior would probably be pretty inconsistent if the tests use the same id) Thanks in advance for any input on this topic!
9 replies
CC#
Created by Stevvvvvvvvvvvvvvvvvie on 7/21/2023 in #help
RosylnPackage- Pack was not loaded successfully
I am trying currently trying to look into the roslyn project (i started adding some custom operator just for learning) And when i try to launch visual studio (using the RoslynDeployment run config) i get an error message, that the RosylnPackage- Pack was not loaded successfully. In the ActivtyLog it says something like "SetSite failed for package [RoslynPackage]", mentioning that there was a export required, but 0 found applying the current restrictions Has somebody an idea what is going wrong?
2 replies