Skip to content
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

Prefer use of interpolated strings in PresentationUI and ReachFramework #8739

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

halgab
Copy link
Contributor

@halgab halgab commented Jan 28, 2024

Follow-up to #8519

Description

We replace as many manual string concatenations and string.Format with interpolated strings. This saves allocations in many instances, and makes for a more readable code.

Customer Impact

Less allocations

Regression

No

Testing

CI

Risk

Low. Most changes are automated using the IDE

Microsoft Reviewers: Open in CodeFlow

@ghost ghost assigned halgab Jan 28, 2024
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Jan 28, 2024
@ghost ghost requested review from dipeshmsft and singhashish-wpf January 28, 2024 20:57
@ghost ghost added the Community Contribution A label for all community Contributions label Jan 28, 2024
@halgab halgab marked this pull request as ready for review January 28, 2024 22:07
@halgab halgab requested a review from a team as a code owner January 28, 2024 22:07
sigStatus.ToString(),
height,
width);
string resourceName = $@"{sigStatus}_{height}x{width}";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing InvariantCulture here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the winforms repo, when doing such refactorings, a choice was made to ignore the invariant culture for int. I am no specialist but apparently it has no impact on integer formatting. I can put it back just for peace of mind

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, as long as there is no format requested, the culture is not used (other than for negative sign, which shouldn't be an issue for width/height).

https://github.com/dotnet/runtime/blob/2f43856e78faebe7347fdd76acc26de7ffaec539/src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs#L919-L925

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants