Skip to content

[PM-22470] Enable NRT for more Core project files #5937

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

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

Conversation

benbryant0
Copy link
Contributor

@benbryant0 benbryant0 commented Jun 7, 2025

🎟️ Tracking

Related to this ADR, but until that's accepted I'm working in the other direction and enabling per-file instead (as discussed here).

📔 Objective

nullabubblelubble

This PR enables NRT (nullable reference types) for almost all remaining files in Core/Utilities and Core/SecretsManager (all the files that didn't result in changes matching anyone in CODEOWNERS)

I've split the changes into commits based on the folders. The only changes that required more than just annotations were a few changes in Core/Utilities, so I broke those out into another commit and I'll dump some notes/explanations as another comment.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@benbryant0
Copy link
Contributor Author

benbryant0 commented Jun 7, 2025

BitPayClient

Returns null instead of throwing when _bpClient isn't initialized.

The one caller of GetInvoicesAsync handles null and returns immediately. The caller of CreateInvoicesAsync will now throw a nullref instead of the method itself.

StrictEmailAddressListAttribute

No behaviour change, just using pattern matching and cleaning up a bit.

LoggerFactoryExtensions

Shouldn't be any change, just split it off because it's weird.
globalSettings is initialised at the start of the method, but then has its members inconsistently accessed with null-conditional operators. Seems unnecessary and causes errors with NRT turned on.

CustomRedisProcessingStrategy

Shouldn't be any change. Looks like the cache only has this key set with an initialized value inside the same class.

JsonHelpers

CreateDictionaryContract: this seems like it really should be fine; just won't throw in a case that doesn't seem valid for this custom resolver anyway.
PermissiveStringConverter.Read: reader.GetString() says it only returns null when the token type is null, and that's not the case here.
MsEpochConverter.Write: seems like it just has to be a bug. But that class isn't referenced anywhere anyway.

AssemblyHelpers

Assembly.GetEntryAssembly() only returns null if the assembly was loaded by unmanaged code.
AssemblyInformationalVersionAttribute seems to always be automatically generated (it's added by the build process even for an empty project).
GetGitHash doesn't seem like it should throw or return null since the relevant property is added by Directory.Build.props, but one caller null-coalesces the result of GetGitHash so better to be safe I guess.

@benbryant0 benbryant0 changed the title Nrt/core part2 Enable NRT for more Core project files Jun 7, 2025
@bitwarden-bot
Copy link

Thank you for your contribution! We've added this to our internal Community PR board for review.
ID: PM-22470
Link: https://bitwarden.atlassian.net/browse/PM-22470

Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process.

@bitwarden-bot bitwarden-bot changed the title Enable NRT for more Core project files [PM-22470] Nrt/core part2 Jun 7, 2025
@benbryant0 benbryant0 changed the title [PM-22470] Nrt/core part2 [PM-22470] Enable NRT for more Core project files Jun 7, 2025
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