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

Clean up the Converters implementation #16820

Merged
merged 2 commits into from
Mar 18, 2024
Merged

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Mar 5, 2024

I thought the Converters.idl file had a really neat ordering,
and I felt like the .cpp implementation fell short of this.

This PR reorders the functions in the implementation to match the IDL.
It also gets rid of some unnecessary math (int vs. float, clamping)
and removes another use of std::stringstream (= bad STL class).

@lhecker lhecker added the Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. label Mar 5, 2024
}

winrt::Windows::UI::Text::FontWeight Converters::DoubleToFontWeight(double value)
// Numbers
double Converters::PercentageToPercentageValue(double value)
Copy link
Member

Choose a reason for hiding this comment

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

Won't this cause the XAML UI to occasionally display something stupid like 99.000000000000000000000000001%?

Copy link
Member

@DHowett DHowett Mar 5, 2024

Choose a reason for hiding this comment

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

making the signature double (double), that is

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point. I'll test this. The only time this should occur is when we convert between float and double, so I'll just find and test all the places where we do that (shouldn't be too many?).

Copy link
Member Author

@lhecker lhecker Mar 5, 2024

Choose a reason for hiding this comment

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

This does result in something stupid like that, but not in the way you might have thought:
AppendPercentageSign has no limitation in the decimal places during stringification which results in these issues. It seems we simply didn't notice because we were lucky.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

Wow, git with colorMoved is WAY better for this review than github.
image

@DHowett DHowett enabled auto-merge (squash) March 14, 2024 19:54
@DHowett DHowett merged commit 287422b into main Mar 18, 2024
20 checks passed
@DHowett DHowett deleted the dev/lhecker/ui-helpers-cleanup branch March 18, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants