Skip to content

Fix nullable annotations in *Operations#74

Open
campersau wants to merge 2 commits intotestcontainers:mainfrom
campersau:fixnullableoperations
Open

Fix nullable annotations in *Operations#74
campersau wants to merge 2 commits intotestcontainers:mainfrom
campersau:fixnullableoperations

Conversation

@campersau
Copy link

Some parameters can be null like

ContainersPruneParameters parameters = null

so the parameters should be marked as nullable

ContainersPruneParameters? parameters = null

Also replaced default(CancellationToken) with default for consistency.

Changes only affect *Operations interfaces / classes.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I have two quick questions.

Some operation interfaces still use ... CancellationToken cancellationToken);. Probably something we should align too?

}

public Task CreateImageAsync(ImagesCreateParameters parameters, Stream imageStream, AuthConfig authConfig, IDictionary<string, string> headers, IProgress<JSONMessage> progress, CancellationToken cancellationToken = default(CancellationToken))
public Task CreateImageAsync(ImagesCreateParameters parameters, Stream? imageStream, AuthConfig authConfig, IDictionary<string, string>? headers, IProgress<JSONMessage> progress, CancellationToken cancellationToken = default)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't checked all of them, but it seems the interface sometimes uses different signatures (nullable) compared to the implementation. The interface looks like this (see imageStream, headers):

Task CreateImageAsync(ImagesCreateParameters parameters, Stream imageStream, AuthConfig authConfig, IDictionary<string, string> headers, IProgress<JSONMessage> progress, CancellationToken cancellationToken = default);

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I have made some arguments nullable in the implementation (since they can be) to avoid nullable warnings.
The implementation can actually allow null even though it is not defined in the interface.

If you want I can mark all arguments nullable when they can actually be null in the implementation.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn Mar 3, 2026

Choose a reason for hiding this comment

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

If you want I can mark all arguments nullable when they can actually be null in the implementation.

That's probably the cleanest approach. WDYT?

@campersau campersau force-pushed the fixnullableoperations branch from 1504220 to 209db97 Compare March 3, 2026 08:51
@campersau
Copy link
Author

Some operation interfaces still use ... CancellationToken cancellationToken);. Probably something we should align too?

I have fixed them. There were just 3 in the interfaces and two of them are actually obsolete.

@campersau
Copy link
Author

Also some interfaces are implemented explicitly and others are not. If you want I can also make them consistent (either way).

@HofmeisterAn
Copy link
Collaborator

Also some interfaces are implemented explicitly and others are not. If you want I can also make them consistent (either way).

If we change it, it would be great to align and make it consistent (as long as it's not too much work). I don't think there's a need to implement them explicitly?

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.

2 participants