Skip to content

Conversation

@Nechepso
Copy link
Contributor

Since commit 666db5c shipped in version 0.11.0, a CronExpression can no longer be compared with null using the overloaded equality operators without a CS8625 nullable warning being produced. The following code shows the issue:

CronExpression? a = /* A CronExpression that may or may not be null. */;
if (a != null) { // <-- This line triggers CS8625: Cannot convert null literal to non-nullable reference type
    // [...]
}

This PR modifies the overloaded equality operators' arguments nullability to accept null values in order to make the previous example compile without warnings.

@odinserj: I also took the liberty to enable NRT annotation/checking in the Directory.Build.props of the tests folder (and treat all nullability-related warnings as errors) to align it with the src folder's one. I tested it and as expected, without the other changes introduced by this PR, the unit tests would not compile anymore. Let me know whether you want to keep it this way or not.

@odinserj
Copy link
Member

Awesome, @Nechepso, this is surely expected! Merging and releasing

@odinserj odinserj merged commit 24954e9 into HangfireIO:main Aug 12, 2025
2 checks passed
@odinserj
Copy link
Member

Done – https://github.com/HangfireIO/Cronos/releases/tag/v0.11.1

@Nechepso
Copy link
Contributor Author

Thanks a lot! That was fast. 😄

@odinserj
Copy link
Member

Welcome, 28 minutes, thanks to tests and automated pipeline 😅

@Nechepso Nechepso deleted the fix-CronExpression-equality-operator-overloads-nullability branch August 13, 2025 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants