8000 Replace boxing IList in HighlightChangedEventArgs and seal derived classes by edwardneal · Pull Request #9559 · dotnet/wpf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Replace boxing IList in HighlightChangedEventArgs and seal derived classes #9559

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

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

Conversation

edwardneal
Copy link
@edwardneal edwardneal commented Aug 12, 2024

Description

The Ranges property on the internal class HighlightChangedEventArgs was declared as an IList, but was always backed by an instance of ReadOnlyList<TextSegment>. Retrieving a list of text segments would thus always box an instance of the TextSegment struct. I've changed this property to declare it as an IList<TextSegment>.

I also swapped an ArrayList with a List<int> in FixedDocument.cs, which stored a list of page numbers.

Finally, I marked all the five classes derived from HighlightChangedEventArgs as sealed. All fives of these classes were private, so there's no API surface change here.

Customer Impact

Reduced memory usage/GC pressure.

Regression

No.

Testing

Local build and tests, sample application runs.

Risk

Low. The Ranges property is only read by DocumentSequenceTextContainer, FixedDocument and FlowDocument. In all three locations, it's indexed into and the result was explicitly cast to a TextSegment.

Microsoft Reviewers: Open in CodeFlow

@dipeshmsft
Copy link
Member

LGTM, @edwardneal can you resolve the above merge-conflicts ?

Copy link
codecov bot commented May 14, 2025

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Project coverage is 13.58559%. Comparing base (1d1d056) to head (8e5f948).

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main       #9559         +/-   ##
===================================================
+ Coverage   13.43262%   13.58559%   +0.15296%     
===================================================
  Files           3316        3316                 
  Lines         664822      664822                 
  Branches       74651       74651                 
===================================================
+ Hits           89303       90320       +1017     
+ Misses        572923      571903       -1020     
- Partials        2596        2599          +3     
Flag Coverage Δ
Debug 13.58559% <0.00000%> (+0.15296%) ⬆️

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.

@edwardneal
Copy link
Author

Thanks @dipeshmsft, I've just resolved them.

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 Included in test pass PR metadata: Label to tag PRs, to facilitate with triage Status:Completed Status:Proposed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0