Skip to content
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

Inconsistent handling of null and boxed null parameter #101

Closed
axunonb opened this issue Feb 13, 2018 · 1 comment
Closed

Inconsistent handling of null and boxed null parameter #101

axunonb opened this issue Feb 13, 2018 · 1 comment

Comments

@axunonb
Copy link
Member

axunonb commented Feb 13, 2018

Obviously there are cases where exceptions are thrown even when ErrorAction.ThrowError is not set.

Smart.Default.Settings.FormatErrorAction = ErrorAction.MaintainTokens;
Smart.Default.Settings.ParseErrorAction = ErrorAction.MaintainTokens;
var result = Smart.Format("{dummy}", null); // always throws an exception - interpreted as IEnumerable
result = Smart.Format("{dummy}", (object) null); // works

Closes axuno/MailMergeLib#14

@axunonb
Copy link
Member Author

axunonb commented Feb 14, 2018

The current handling of a null parameter is inconsistent:

object boxedNull = null;
if (boxedNull != null) throw new Exception("This never happens!");
Smart.Format("{dummy}", null); // throws exception
Smart.Format("{dummy}", boxedNull); // works as expected

Will be fixed in the way that null will be handled as a valid argument.

axunonb added a commit that referenced this issue Feb 14, 2018
@axunonb axunonb closed this as completed Feb 14, 2018
@axunonb axunonb changed the title Format or parse error should not throw exception unless ErrorAction.ThrowError is set Inconsistent handling of null and boxed null parameter Feb 14, 2018
axunonb added a commit to axuno/MailMergeLib that referenced this issue Feb 14, 2018
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

No branches or pull requests

1 participant