Skip to content

[compression] Add nullability to (generated and manual) bindings - #14916

Merged
tj-devel709 merged 11 commits into
dotnet:mainfrom
tj-devel709:Nullable-Compression-WithManuel
May 16, 2022
Merged

[compression] Add nullability to (generated and manual) bindings#14916
tj-devel709 merged 11 commits into
dotnet:mainfrom
tj-devel709:Nullable-Compression-WithManuel

Conversation

@tj-devel709

Copy link
Copy Markdown
Member

This PR aims to bring nullability changes to Compression.
Following the steps here:

  1. I am adding nullable enable to all manual files that are not "API_SOURCES" in src/frameworks.sources and making the required nullability changes
  2. Changing all throw new ArgumentNullException ("object")); to ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (object)); for size saving optimization as well to mark that this framework contains nullability changes
  3. Changing any == null or != null to is null and is not null

I am replacing this older PR: #14408
with this one! @mandel-macaque helped me through this process making this API a little cleaner than my previous PR!

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Comment thread src/Compression/Compression.cs Outdated
Inflater Inflater {
get {
if (_inflater is null)
_inflater = new Inflater (_algorithm);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks more appropriate to throw an exception here:

Suggested change
_inflater = new Inflater (_algorithm);
throw new InvalidOperationException ("Can't access an inflater when decompressing");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like the idea, since we should have init the inflater in the constructor, and we can get the nullability check or throw. Using this + the property trick makes the clone simpler to understand.

Comment thread src/Compression/Compression.cs Outdated
Deflater Deflater {
get {
if (_deflater is null)
_deflater = new Deflater (_algorithm);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
_deflater = new Deflater (_algorithm);
throw new InvalidOperationException ("Can't access a deflater when compressing");

Comment thread src/Compression/Compression.cs Outdated
Byte[] Buffer {
get {
if (_buffer is null)
_buffer = ArrayPool<byte>.Shared.Rent (DefaultBufferSize);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
_buffer = ArrayPool<byte>.Shared.Rent (DefaultBufferSize);
throw new InvalidOperationException ("Buffer has not been initialized");

and keep EnsureBufferInitialized.

Automatically initializing can sometimes run into problems where the field is cleared, and then inadvertently re-created, which causes for some hard-to-find bugs. It's easier if an exception is thrown in that scenario.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@mandel-macaque mandel-macaque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving if rolf comment is addressed.

Comment thread src/Compression/Compression.cs Outdated
Inflater Inflater {
get {
if (_inflater is null)
_inflater = new Inflater (_algorithm);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like the idea, since we should have init the inflater in the constructor, and we can get the nullability check or throw. Using this + the property trick makes the clone simpler to understand.

@Rolf

This comment was marked as off-topic.

@mandel-macaque

This comment was marked as off-topic.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@tj-devel709

Copy link
Copy Markdown
Member Author

@rolfbjarne ready for re-review!

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@tj-devel709

Copy link
Copy Markdown
Member Author

There are some important test failures that I need to address here!

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

ðŸ”Ĩ Tests failed catastrophically on VSTS: simulator tests iOS (no summary found). ðŸ”Ĩ

Result file D:\a\1\s\Reports\TestSummary-simulator\TestSummary.md not found.

Pipeline on Agent XAMBOT-1043.Monterey'
Merge ce5bf71 into 1da4351

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

📚 [PR Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMBOT-1017.Monterey'
Hash: 931541736fea910c62717e370830f4b351f6978e

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

ðŸ’ŧ [PR Build] Tests on macOS Mac Catalina (10.15) passed ðŸ’ŧ

✅ All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Hash: 931541736fea910c62717e370830f4b351f6978e

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Failed tests are:

  • xammac_tests
  • monotouch-test

Pipeline on Agent
Hash: 931541736fea910c62717e370830f4b351f6978e

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

📋 [PR Build] API Diff 📋

API Current PR diff

â„đïļ API Diff (from PR only) (please review changes)

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

API diff

✅ API Diff from stable

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

Generator diff

✅ Generator Diff (no change)

Pipeline on Agent XAMBOT-1108.Monterey'
Hash: 931541736fea910c62717e370830f4b351f6978e

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [CI Build] Tests passed on VSTS: simulator tests iOS. ✅

Tests passed on VSTS: simulator tests iOS.

🎉 All 148 tests passed 🎉

Pipeline on Agent XAMBOT-1109.Monterey'
Merge 9315417 into 4800775

@tj-devel709
tj-devel709 merged commit b5ffa8d into dotnet:main May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not-notes-worthy Ignore for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants