| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| return string.Format(CultureInfo.InvariantCulture, $"{0}> {File}", | ||
| FromStream == RedirectionStream.All ? "*" : ((int)FromStream).ToString(CultureInfo.InvariantCulture)); |
There was a problem hiding this comment.
The code can be insterted in {0}.
(In C# 11 even multilines are supported https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11#newlines-in-string-interpolations but we should switch from C# 10 to 11 in our msbuild files.)
Sorry, something went wrong.
| { | ||
| string payLoadData = BitConverter.ToString(fragmentData.blob, fragmentData.offset, fragmentData.length); | ||
| payLoadData = string.Format(CultureInfo.InvariantCulture, "0x{0}", payLoadData.Replace("-", string.Empty)); | ||
| payLoadData = string.Format(CultureInfo.InvariantCulture, $"0x{payLoadData.Replace("-", string.Empty)}"); |
There was a problem hiding this comment.
Perhaps follow works (or will in .Net 8, or C# 11)
$"0x{payLoadData.AsSpan().Replace("-", string.Empty)}");
Sorry, something went wrong.
| CimTestCimSessionContext testCimSessionContext = context as CimTestCimSessionContext; | ||
| uint sessionId = this.sessionState.GenerateSessionId(); | ||
| string originalSessionName = testCimSessionContext.CimSessionWrapper.Name; | ||
| string sessionName = originalSessionName ?? string.Format(CultureInfo.CurrentUICulture, @"{0}{1}", CimSessionState.CimSessionClassName, sessionId); |
There was a problem hiding this comment.
Really we should replace all string.Format with string.Create
Sorry, something went wrong.
There was a problem hiding this comment.
Follow up PR?
Sorry, something went wrong.
There was a problem hiding this comment.
No, current changes haven't value. Idea is to use new API to reduce allocations. There is no string.Format with interpalated string handler. I guess I misled you. Please use string.Create.
(You can find all new APIs with interpolated handlers starting with https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/InterpolatedStringHandlerAttribute.cs,382762ca0bf5bcac,references)
Sorry, something went wrong.
There was a problem hiding this comment.
Also please don't change our trace.WriteLine() and other such callsites - this requires changes in the APIs themselves, which is not always easy. See example #18246.
Sorry, something went wrong.
| // at a time => bufferSize.Y == 1. Then, we can safely leave bufferSize.Y unchanged | ||
| // to retry with a smaller bufferSize.X. | ||
| Dbg.Assert(bufferSize.Y == 1, string.Format(CultureInfo.InvariantCulture, "bufferSize.Y should be 1, but is {0}", bufferSize.Y)); | ||
| Dbg.Assert(bufferSize.Y == 1, string.Format(CultureInfo.InvariantCulture, $"bufferSize.Y should be 1, but is {bufferSize.Y}")); |
There was a problem hiding this comment.
Dbg.Assert is our API. In follow PR we could modernize it to support interpolated string handler and then remove string.Format from such callsites.
The same for StringUtil.Format API.
Sorry, something went wrong.
…mand.cs Co-authored-by: Ilya <darpa@yandex.ru>
| uint sessionId = this.sessionState.GenerateSessionId(); | ||
| string originalSessionName = testCimSessionContext.CimSessionWrapper.Name; | ||
| string sessionName = originalSessionName ?? string.Format(CultureInfo.CurrentUICulture, @"{0}{1}", CimSessionState.CimSessionClassName, sessionId); | ||
| string sessionName = originalSessionName ?? string.Create(CultureInfo.CurrentUICulture, $@"{CimSessionState.CimSessionClassName}{sessionId}"); |
There was a problem hiding this comment.
We can remove verbatim string literal @. Below I see the same too.
Sorry, something went wrong.
| } | ||
|
|
||
| parameters.Append(string.Format(CultureInfo.CurrentUICulture, @"'{0}' = {1}", key, parameterList[key])); | ||
| parameters.Append(string.Format(CultureInfo.CurrentUICulture, $@"'{key}' = {parameterList[key]}")); |
There was a problem hiding this comment.
We can use StringBuilder.AppendFormat
Sorry, something went wrong.
| if (result == null) | ||
| { | ||
| throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "DataErrorInfoValidationResult not returned by ValidationRule: {0}", rule.ToString())); | ||
| throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, $"DataErrorInfoValidationResult not returned by ValidationRule: {rule.ToString()}")); |
There was a problem hiding this comment.
The same. And we can remove ToString().
Sorry, something went wrong.
| } | ||
|
|
||
| patterns.Add(string.Format(CultureInfo.InvariantCulture, "(?<{0}>){1}", FullTextRuleGroupName, ValuePattern)); | ||
| patterns.Add(string.Format(CultureInfo.InvariantCulture, $"(?<{FullTextRuleGroupName}>){ValuePattern}")); |
There was a problem hiding this comment.
The same. I stop review. Please replace all Format with Create.
Sorry, something went wrong.
There was a problem hiding this comment.
I'm still working on it, its [WIP]. I'll change it to draft
Sorry, something went wrong.
| { | ||
| result.AppendFormat(null, "-Culture '{0}' ", CodeGeneration.EscapeSingleQuotedStringContent(runspaceConnectionInfo.Culture.ToString())); | ||
| result.AppendFormat(null, "-UICulture '{0}' ", CodeGeneration.EscapeSingleQuotedStringContent(runspaceConnectionInfo.UICulture.ToString())); | ||
| result.AppendFormat(null, $"-Culture '{CodeGeneration.EscapeSingleQuotedStringContent(runspaceConnectionInfo.Culture.ToString())}' "); |
There was a problem hiding this comment.
ToString() can be removed in interpolated strings.
Sorry, something went wrong.
|
CarloToso The PR is too large. I suggest to split it by 5-10-15 files. |
Sorry, something went wrong.
|
This PR has 592 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience! Quantification details
Label : Extra Large Size : +262 -330 Percentile : 86.4% Total files changed: 103 Change summary by file extension: .cs : +262 -330 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) |
Sorry, something went wrong.
|
Ilya (@iSazonov) You are right this PR is too big, I'll leave it open until until I've finished splitting it, then I'll close it |
Sorry, something went wrong.
|
PR split in 7 parts |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Use interpolated strings with String.Format(), StringBuilder.AppendFormat(), String.Create()
PR Context
Proposed by Ilya (@iSazonov)
PR Checklist
(which runs in a different PS Host).