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
Set up a .settings file #3555
Comments
Can I be assigned to this? |
@rkapka absolutely! I'm so sorry I didn't send you the team invite before!! I thought I had actually... |
In relation with the discussion in #3534, I am not sure how moving the default hotkeys into a I see another issue: serializing/deserializing the commands that were assigned to hotkeys. If I assign a |
The way I see this, having the default hotkeys in the settings file allows to completely remove the hotkeys from the commands. Then only the hotkey bindings know about commands but commands have no idea about the existence of hotkeys. |
@MDoerner The latest version of the PR I mentioned works just like this. When creating the default hotkeys, a command is passed to the hotkey and the command itself knows nothing about the hotkey he's been bound to. But in order to get the collection of commands available for binding, I inject it into Am I missing something? |
@rkapka The idea of introducing the This means you don't have a circular dependency, because |
Follow-up discussion in chat |
First of all, many thanks for looking closer at the matter in chat.
Exactly.
Are we talking about injecting the commands? I have been trying to do that previously, but without success. If I set up
and register hotkeys in this way:
then I get this exception:
|
First of all, I have not tried to figure out where the CW exception is coming from, so far. Let me recapitulate where the circular dependency in PR #3534 is coming from. After that, I will pose some design/functionality questions to determine whether the settings file actually solves the problem. Finally, I would like to point out some options we have in case we want to take the route where the circular dependency cannot be avoided easily. The Base ProblemThe basic problem why constructor injecting the commands registered for Design/Functionality DecisionsThe question I would like to raise here is: "Does the To put this into perspective: whoever creates the hotkey bindings definilty needs the commands since the hotkeys need to know the command to execute. However, in principle, the settings provider only needs the types or any other key identifying the commands. As we do no longer read the default hotkeys from the commands after this issue has been resolved, whether the "Do we care whether there might be settings provided for commands that are not loaded or can we live with simply not binding the hotkey if the command is not loaded and still displaying the setting?" For the next section, I will assume that we care; otherwise, there is no cycle anymore. Breaking the CycleIn this section, I would like to present two ways to break the cycle, based on the corresponding section of Dependency Injection in .NET. The first possibility is a redesign of how we present the settings dialog. To truly break the cycle, we could employ an observer patter, or in other words an event-based approach. More precisely, we could inject some show settings broadcaster with a show settings event to which some presenter actually showing the dialog registers, That would invert one arrow in the cycle since the view models no longer depend on the presenter; they only depend on the broadcaster. Admittedly, this design is a bit unintuitive and confusing. Exactly because of this, this is not used to break the cycle in the WPF MVVM example in the book. Option two is to use property injection. However, this is not as easy as just changing the registration code to use property injection. We truly have to inject after everything in the cycle is resolved. ( |
I thought a bit about the problem with the dependency cycle again and another point at which we could break the cycle came to my mind: between the commands and the presenters. In the particular example of |
I am still not 100% sure that we can get rid of the dependency cycle without using techniques described in Breaking the Cycle section.
|
Let me explain why I think that the need break a cycle depends on whether we only want to provide settings for commands that are loaded or do not care. Provided, we do not care that we might provide hotkey settings for commands that are not really loaded, the |
@rkapka I wonder.. @rubberduck203 confirmed earlier this week that the reason we hadn't gone with standard .net configuration settings was because we are a DLL project and apparently app.config files don't work when you're not an app. I'm confused now, can this work or not? |
@retailcoder I'm pretty sure that while we can't necessarily use the standard .net configuration settings, it'd be a huge boon to RD to have something that has the same behaviour. If that means shipping a default configuration inside the If that means writing explicit code to merge our default configuration and a user-configuration, so be it. If app.config files don't work, we can still use alternative means of specifying a default configuration. IIUC the PR does that already, by encoding the default settings as XML inside a resource file. |
@retailcoder I investigated this matter a little bit and these are my thoughts: The The code in my PR works. It loads the defaults and merges them with user-specific settings. I guess it just doesn't read the defaults from the I believe this StackOverflow thread might help. If I understand the top-voted answer correctly, if there is one RD DLL for all users of a machine, then they will have to share the defaults at the moment - but is that an issue? |
ref. discussion on #3534
Let's put all the default settings in a .net-standard
.settings
file (i.e. accessible from project properties), at "application" level; that file would end up in the RD install folder and in no way would interfere with user settings. The contents of that file would be version-specific, and the file itself would be essentially treated as read-only: nothing ever writes to it.This will require changes to all inspection classes (they all pass a hard-coded default severity through the base class constructor!), and remote a TON of shitty default-config setup code, notably for hotkeys.
Then the mechanics for loading user settings become brain-dead simple:
rubberduck.config
user settings file (i.e. the xml file we're currently using); if so, load what can be loaded & override the loaded defaults. If user settings contain unknown or otherwise unloadable nodes, ignore them & keep processing.rubberduck.config
xml file.The text was updated successfully, but these errors were encountered: