server icon indicating copy to clipboard operation
server copied to clipboard

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

Open benbryant0 opened this issue 7 months ago â€ĸ 4 comments

đŸŽŸī¸ 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 avatar Jun 07 '25 10:06 benbryant0

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 avatar Jun 07 '25 10:06 benbryant0

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 avatar Jun 07 '25 14:06 bitwarden-bot

@bitwarden/team-secrets-manager-dev, @bitwarden/team-billing-dev: For the files changed, no CODEOWNER has been defined, yet. Please create a separate task to look for files that would fall under your ownership and update the CODEOWNERs file. Pinging @justindbaur as he's been championing the NRT work â¤ī¸

djsmith85 avatar Jun 24 '25 14:06 djsmith85

@benbryant0 We've now enabled nullable repo wide and this PR would need some updating. Do you still want to pursue this?

justindbaur avatar Sep 05 '25 17:09 justindbaur