Remove code which delete GUID from Progress, Verbose, Debug and Warning messages#18871
Conversation
|
As the the pattern is known at compile time, could we use a regular expression source generator? |
src/System.Management.Automation/engine/hostifaces/HostUtilities.cs
Outdated
Show resolved
Hide resolved
We could. But first I would like to know where we create this prefix. If it's remoting only, it's probably not worth it. |
| return message; | ||
| } | ||
|
|
||
| const string pattern = @"^([\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:\[.*\]:).*"; |
There was a problem hiding this comment.
| const string pattern = @"^([\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:\[.*\]:).*"; | |
| const string pattern = @"^[\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:\[.*\]:"; |
Remove the unnecessary capturing group and refactor:
message = message.Substring(matchResult.Length);`There was a problem hiding this comment.
Eh, I don't know that is real format of the messages - perhaps we need the capture group.
There was a problem hiding this comment.
It looks like line 548 below uses the capture group. I would suggest replacing [\d\w] with [a-fA-F0-9] as \w is any alphanumeric character.
There was a problem hiding this comment.
@SteveL-MSFT I mean line 548 can become message = message.Substring(matchResult.Length);
src/System.Management.Automation/engine/hostifaces/HostUtilities.cs
Outdated
Show resolved
Hide resolved
|
I'm trying to find out why this was originally needed and if it's still needed at all. I was able to find a related methods called |
|
I see only AddSourceTagToError and CreateInformationalMessage. |
|
@PaulHigin confirmed that this is used by remoting/jobs to de-multiplex multi-sessions so that alleviates my concern if this is dead code. |
| @@ -499,21 +499,27 @@ internal static List<string> GetSuggestion(HistoryInfo lastHistory, object lastE | |||
| /// Remove the GUID from the message if the message is in the pre-defined format. | |||
There was a problem hiding this comment.
Can we update this comment to include:
| /// Remove the GUID from the message if the message is in the pre-defined format. | |
| /// Remove the GUID from the message (added by remoting/jobs for concurrent operations to be de-multiplexed) if the message is in the pre-defined format. |
| return message; | ||
| } | ||
|
|
||
| const string pattern = @"^([\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:).*"; |
There was a problem hiding this comment.
Since you're already updating this, perhaps we should change this regex a bit. Replace [\d\w] (which would accept any alphanumeric character making \d redundant anyways) to [a-fA-F0-9] to accept any hex digit.
There was a problem hiding this comment.
@PaulHigin Could you please point the code (for error and progress bar too) where we add the GUID? Can there be some GUIDs and should we use capture group?
| return message; | ||
| } | ||
|
|
||
| const string pattern = @"^([\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:\[.*\]:).*"; |
There was a problem hiding this comment.
It looks like line 548 below uses the capture group. I would suggest replacing [\d\w] with [a-fA-F0-9] as \w is any alphanumeric character.
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
PaulHigin
left a comment
There was a problem hiding this comment.
LGTM
To be honest I don't remember if/where Guids are added to remote information messages, or if they even are anymore. I seem to remember that in some cases they were added but, again, I cannot remember or find those cases in the code base. The RemoteData object contains all session routing information so I don't know why/when an information message would need a guid.
|
I cannot find too. I guess it is not used for years. I suggest to delete the code (RemoveIdentifierInfoFromMessage and RemoveGuidFromMessage) and wait feedbacks while we are at preview time. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
I suggest making these changes for clarity reasons. |
@daxian-dbw What do you think about the proposal? |
That sounds good to me :) |
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
@iSazonov Please update issue title before merge. |
There was a problem hiding this comment.
LGTM. As @xtqqczze reminded, please update the PR title and description before merging. Thanks!
Oh, please refer to Paul's comment #18871 (review) in the PR description for context information.
|
Done. |
|
@SteveL-MSFT Please take another look when you get a chance. Thanks! |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
@SteveL-MSFT Friendly ping. |
|
🎉 Handy links: |
PR Summary
Since nobody can find where GUID is added to a message we can remove RemoveGuidFromMessage and RemoveIdentifierInfoFromMessage methods and wait feedback. I guess it is not used for years (maybe it was in psworkflows?).
Notice, the methods are perf expensive since process every message by Regex.
See also #18871 (review)
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).