Skip to content

Complete the nullable annotations - #1162

Merged
drewnoakes merged 8 commits into
zeromq:masterfrom
drewnoakes:nullable-annotations-100-percent
May 25, 2026
Merged

drewnoakes merged 8 commits into
zeromq:masterfrom
drewnoakes:nullable-annotations-100-percent

Conversation

@drewnoakes

Copy link
Copy Markdown
Member

This gets all the code null annotated. There are several places where the design makes it hard to avoid null forgiveness operators, so they have been added where needed. In future we may pay those off.

Motivated by the error reported in #1159 and fixed in #1160.

@drewnoakes
drewnoakes force-pushed the nullable-annotations-100-percent branch from 5e5f07b to 684fffd Compare May 24, 2026 12:35
drewnoakes and others added 8 commits May 24, 2026 22:39
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the JetBrains.Annotations package reference from Directory.Build.props
and all project-level version overrides. Strip [CanBeNull], [NotNull], and
[UsedImplicitly] attributes from all source files, along with their using
directives. No other JetBrains annotation types were in use.

The five files that still have #nullable disable will get proper native
nullable annotations in subsequent commits.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
These attributes were introduced in .NET 5 but are needed for the
netstandard2.1 and net472 targets. They will be used when annotating
late-initialized fields in subsequent commits.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove #nullable disable and annotate the generic linked-chunk queue:

- Chunk.Next and Chunk.Previous are now Chunk? (nullable linked-list links)
- Use null-forgiving operator at linked-list navigation points where
  queue invariants guarantee non-null (Pop, Push, Unpush)
- Replace default(T) with default! for slot clearing
- Remove redundant Debug.Assert(Values != null) after array construction

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove #nullable disable and annotate all nullable types:
- m_next is now Trie?[]? (nullable array of nullable elements)
- TrieDelegate data/arg parameters are nullable
- Use null-forgiving operator where trie invariants guarantee non-null
- Fix downstream XSub.cs warning from nullable delegate arg
- Remove unused using and redundant Debug.Assert

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove #nullable disable and annotate all nullable types:
- m_pipes is now HashSet<Pipe>? (null when no subscriptions)
- m_next is now MultiTrie?[]? (nullable array of nullable elements)
- MultiTrieDelegate data/arg parameters are nullable
- Remove bogus Debug.Assert(prefix != null) for Span<byte> (fixes CA2265)
- Use null-forgiving operator where trie invariants guarantee non-null
- Fix downstream XPub.cs warnings from nullable delegate arg

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove #nullable disable and annotate all nullable types:
- m_reaper is now Reaper? (late-initialized in CreateSocket)
- m_slots is now IMailbox?[]? (late-initialized, elements nullable)
- ChooseIOThread returns IOThread? (already matched by ZObject wrapper)
- Use null-forgiving operator where lifecycle invariants guarantee non-null
- Remove redundant Debug.Assert(addr != null) on non-nullable parameter

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove #nullable disable and annotate all nullable types:
- m_handle, m_session, m_socket, m_ioObject are lifecycle-nullable
- m_encoder, m_decoder, m_mechanism are nullable until handshake
- m_inpos, m_outpos are nullable buffer positions
- Use null-forgiving operator where state machine invariants guarantee
  non-null (post-Plug, post-handshake, post-V3-handshake)
- Remove redundant null assignments in constructor for nullable fields

This is the file that motivated the nullable annotation effort (PR zeromq#1160).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@drewnoakes
drewnoakes force-pushed the nullable-annotations-100-percent branch from 684fffd to 5ee2b20 Compare May 24, 2026 12:42
@drewnoakes
drewnoakes merged commit 1768960 into zeromq:master May 25, 2026
3 checks passed
@drewnoakes
drewnoakes deleted the nullable-annotations-100-percent branch May 25, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant