Skip to content

Conversation

@josesimoes
Copy link
Member

@josesimoes josesimoes commented Nov 12, 2025

Description

  • Add checks for null objects and perform accordingly.

Motivation and Context

  • Handles the specific case where a generic type parameter that is a reference type has a null value, which is exactly what happens when a null is adde to a List and then try to search for it.
  • Checks if we're trying to unbox a null reference by verifying the data type is DATATYPE_OBJECT and dereferencing to check for null
    . It throws CLR_E_NULL_REFERENCE if the reference is null, which matches the standard .NET CLR behavior. Also allows normal unboxing to proceed for non-null references.
  • Boxing null is legal: object x = (object)null;
  • Unboxing null is illegal: int x = (int)null; (throws NullReferenceException).

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dev Containers (changes related with Dev Containers, has no impact on code or features)
  • Dependencies/declarations (update dependencies or assembly declarations and changes associated, has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).

- Add checks for null objects and perform accordingly.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@josesimoes josesimoes added the Area: Common libs Everything related with common libraries label Nov 12, 2025
nfbot and others added 2 commits November 12, 2025 23:49
Automated fixes for code style.
…02e26-74da-43e6-850d-3ae918843334

Code style fixes for nanoframework/nf-interpreter PR#3237
@josesimoes
Copy link
Member Author

@coderrabitai review

@josesimoes josesimoes merged commit 9892998 into nanoframework:develop Nov 13, 2025
26 checks passed
@josesimoes josesimoes deleted the fix-box-unbox branch November 13, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Common libs Everything related with common libraries Type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants