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

Enable nullability in ArrayEditor #12675

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

Conversation

gpetrou
Copy link
Contributor

@gpetrou gpetrou commented Dec 23, 2024

Proposed changes

  • Enable nullability in ArrayEditor.
Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.07980%. Comparing base (b0f86f1) to head (7ddb206).

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #12675         +/-   ##
===================================================
- Coverage   76.08157%   76.07980%   -0.00177%     
===================================================
  Files           3257        3257                 
  Lines         642145      642089         -56     
  Branches       47286       47286                 
===================================================
- Hits          488554      488500         -54     
- Misses        150041      150045          +4     
+ Partials        3550        3544          -6     
Flag Coverage Δ
Debug 76.07980% <100.00000%> (-0.00177%) ⬇️
integration 18.09422% <20.00000%> (+0.00191%) ⬆️
production 50.01260% <100.00000%> (+0.00611%) ⬆️
test 96.96608% <100.00000%> (-0.00442%) ⬇️
unit 47.46481% <100.00000%> (+0.00719%) ⬆️

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

@@ -22,12 +20,12 @@ public ArrayEditor(Type type) : base(type)
/// Gets or sets the data type this collection contains.
/// </summary>
protected override Type CreateCollectionItemType()
=> CollectionType?.GetElementType();
=> CollectionType?.GetElementType()!;
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment, explaining in detail why CollectionType?.GetElement()! will never return null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can actually be null, but changing it seems to require changing the base class which does not return null.
@lonitra should I change the base class? Alternatively, I could return string.Empty here instead, but this would mean a breaking change.

Copy link
Member

Choose a reason for hiding this comment

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

The base class does not guarantee that CollectionType is not null, it should throw in the constructor when a null is passed in. Once we throw this exception, we can get rid of the question mark -
protected override Type CreateCollectionItemType() => CollectionType.GetElementType()!;

And for GetElementType returning null, I would throw InvalidOprationException, it could happen only if this type is not an array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Tanya-Solyanik I added a separate commit with the proposed changes, but this affects lots of tests. Are we sure that we want to apply this change? If yes, I will update the tests. If not, any other suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please update the tests.

@Tanya-Solyanik Tanya-Solyanik added the waiting-author-feedback The team requires more information from the author label Jan 7, 2025
@dotnet-policy-service dotnet-policy-service bot removed the waiting-author-feedback The team requires more information from the author label Jan 11, 2025
@LeafShi1 LeafShi1 added the waiting-review This item is waiting on review by one or more members of team label Jan 20, 2025

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt: Language not supported
@Tanya-Solyanik Tanya-Solyanik added waiting-author-feedback The team requires more information from the author and removed waiting-review This item is waiting on review by one or more members of team labels Jan 23, 2025
@ricardobossan ricardobossan added waiting-review This item is waiting on review by one or more members of team and removed waiting-author-feedback The team requires more information from the author labels Jan 23, 2025
@Tanya-Solyanik Tanya-Solyanik added waiting-author-feedback The team requires more information from the author and removed waiting-review This item is waiting on review by one or more members of team labels Jan 23, 2025
@gpetrou gpetrou force-pushed the ArrayEditor branch 5 times, most recently from 4146557 to fe38e2a Compare February 9, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: NRT area-NRT waiting-author-feedback The team requires more information from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants