Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use BooleanBoxes for default values in DependencyProperty metadata #10711

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

Conversation

h3xds1nz
Copy link
Member

@h3xds1nz h3xds1nz commented Apr 6, 2025

Description

While we have SetValue special-cased for BooleanBoxes and a lot of bool-DPs have properly set their default values with BooleanBoxes.TrueBox or BooleanBoxes.FalseBox, there are quite a few outliers as I've noticed today when digging through the boxed booleans on the heap.

Therefore, this PR does 3 things:

  1. Replace boxing of unique values in default values with our pre-defined boxes
  2. Adjusts MilCodeGen to generate DPs with the pre-defined boxes as well
  3. I've declared MS.Internal.KnownBoxes as a global using, since it is used in most of our classes
    3.1) Since we have 1-3 classes there, that doesn't bring any code bloat
    3.2) That means I've removed the usings in all other files

I didn't do anything in Ribbon because it WindowsBase doesn't have internals visible to the assembly.

Customer Impact

Decreases number of booleans by a big amount, decreased memory usage, improved perf slightly.

Regression

No.

Testing

Local build.

Risk

I did most of the work replacement work with either MilCodeGen or regex, but there were a few manual changes, so it should be fine. Note that using the boxes is not a new thing, this just makes sure all boolean DPs use it.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested review from a team as code owners April 6, 2025 19:04
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Apr 6, 2025
Copy link

codecov bot commented Apr 6, 2025

Codecov Report

Attention: Patch coverage is 16.58986% with 181 lines in your changes missing coverage. Please review.

Project coverage is 11.23853%. Comparing base (3cc9d57) to head (52c25da).

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #10711         +/-   ##
===================================================
+ Coverage   11.17950%   11.23853%   +0.05902%     
===================================================
  Files           3314        3314                 
  Lines         665182      665185          +3     
  Branches       74668       74667          -1     
===================================================
+ Hits           74364       74757        +393     
+ Misses        589525      589128        -397     
- Partials        1293        1300          +7     
Flag Coverage Δ
Debug 11.23853% <16.58986%> (+0.05902%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# for free to join this conversation on GitHub. Already have an account? # 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.

2 participants