-
Notifications
You must be signed in to change notification settings - Fork 8k
Add internal methods to check Preferences #25514
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
Conversation
|
Looks good to my amateur eyes. I would think we would need test cases for all the various places variable preference can be set beyond just the -verbose and -debug switches, including things like cross-module scopes, etc. I feel like an ideal version of this would be a WriteDebug overload that takes a delegate etc. and simply doesn't do that execution, but the time for that was 15 years ago, so this is the next best option that is simple to utilize. I think the caveat is though anything external that wants to use this is going to need a preprocessor directive or its going to only work on 7.6+, I don't think we can really polyfill in extension members for this once c# 14 is availalble. |
|
@JustinGrote The current status is that these are just internal helper methods. This is the first step. Later, we can discuss whether they are needed publicly. As for the tests, they will be required if these methods become public. Now they are just internal helpers and do not change the existing code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
FWIW my two cents is that these should stay internal. I do think there is room for conditionally generated messages in a public API, but for that I would prefer it be surfaced in form of message factory delegates (and maybe overloads for format strings, but that's probably over kill).
(I realized all of that is sort of off topic for this PR, just getting my thoughts out).
Thanks Ilya!
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
@SeeminglyScience Thanks for fast review! |
|
📣 Hey @@iSazonov, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
PR Summary
Add internal methods to check Preferences. It allows to check if output enabled before doing expensive work.
It is implemented only in
MshCommandRuntimeclass withtruedefaults for other implementations of ICommandRuntime2/ICommandRuntime interfaces since extending of interfaces is changing public API. Although this can now be done using default interface implementations (without breaking changes), new public APIs require approval by the working group and the committee, as well as changes to the SDK package. All this can be done later after the PR.PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header