Skip to content

Add CallerArgumentExpression to IsNull/IsNotNull #254

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

Merged
merged 1 commit into from
May 17, 2024

Conversation

CoryCharlton
Copy link
Member

@CoryCharlton CoryCharlton commented May 17, 2024

Description

  • Add CallerArgumentExpression to IsNull/IsNotNull.

Motivation and Context

Improved failure messages without additional work / tech debt. Prior to this change a set of tests like the following would all show the same error: "Assert.IsNull failed."

var test = new();
Assert.IsNull(test.Condition1);
Assert.IsNull(test.Condition2);
Assert.IsNull(test.Condition3); // Assume this test fails

After adding the CallerArgumentExpressionAttribute the default failure message changes to "Assert.IsNull failed. test.Condition3" and it's clear which test failed.

How Has This Been Tested?

Manually

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)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), 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).
  • I have added new tests to cover my changes.

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@josesimoes josesimoes merged commit 551ac18 into nanoframework:main May 17, 2024
4 checks passed
@josesimoes
Copy link
Member

@CoryCharlton I've merged this without publishing a new release. Am I right to presume that you'll be adding this to the other asserts in the coming days? At your pace and as time permits, of course. 😅

@CoryCharlton
Copy link
Member Author

@CoryCharlton I've merged this without publishing a new release. Am I right to presume that you'll be adding this to the other asserts in the coming days? At your pace and as time permits, of course. 😅

@josesimoes I will have another PR for the remaining methods. I'll keep it to a single PR with clear, targeted, commits.

@CoryCharlton CoryCharlton deleted the improve_null_asserts branch May 17, 2024 17:35
@CoryCharlton CoryCharlton mentioned this pull request May 20, 2024
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants