Skip to content

Conversation

@rorso
Copy link

@rorso rorso commented Nov 3, 2021

Optional arguments to allow reading active files. The current code allways tries to open the file r/w with share=None
Suitable default values to not break existing code.

@Hexman768
Copy link
Collaborator

@rorso What does opening a file in share mode actually allow the user to do? This seems like it could cause bad interactions between applications if one app overwrites the changes made in another.

@rorso
Copy link
Author

rorso commented Jul 8, 2025

The main reason is to have the possibility to restrict the component to open a file in strict r/o mode in view-only applications. Used as a live viewer for a 3rd party log, but with full color and "tail" function.

The default open modes request too much permissions i.e. exclusive access which conflicts with the background application already having "exclusive access".

@Hexman768
Copy link
Collaborator

@rorso Gotcha, I do like that idea as it is another possible use case that was not previously covered.

The only thing that makes me a bit uncomfortable even though you have included a default option with it, is modifying a the signature of a public method. I am not sure if it would just be better to add another public method, and just have the old one call the new one with default value parameters.

@PavelTorgashov What do you think is the best move here?

@rorso
Copy link
Author

rorso commented Jul 9, 2025

Oh, difficult question. This quick hack did fit well with my own application without breaking anything, when I resync with your master.

I really do not have much experience with the need to have a stable public interface for shared use. So I can't imagine how these optional parameters could break any existing implementation.

The cleanest ways probably would be defining a second interface to the class to explicitly allow for new enhancements. But this would have been way too much hassle for at least my use case. 

Having a OpenBindingFile_v2() and respective OpenFile_v2()  would certainly be another pragmatic option. But that's a bit archaic, neglecting the possibilities to write "clean and beautiful" c# code.

Probably you don't want to merge the change but take just the idea to allow for specifying the open/share mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants