Commit Graph
4 Commits
Author SHA1 Message Date
Jon Hanna bf2e5a29aa Correct ParamName in exception for invalid JsonToken on ‎WriteToken
Fixes #755

Also consolidates WriteTokenInternal into matching WriteToken (slightly reduce
assembly size).

Also extend ExceptionAssert.Throws to return exception for further examination.
2015-12-20 21:34:21 +00:00
Jon Hanna 40bd051809 Suppress finaliser in Dispose if there's a protected Dispose(bool)
Fixes #746
2015-12-18 19:03:36 +00:00
Jon Hanna dbbe944b19 Move reflection calls until after branches that may mean they're unused
A handful of cases where reflection calls are made prior to branches that
might lead to the results not being used.
2015-12-17 18:27:12 +00:00
Jon Hanna 7e6194b61b Use GetValueOrDefault() over Value when Nullable<T> known non-null
GetValueOrDefault() is an easily-inlined access to a field as this
will hold the correct value for both HasValue and !HasValue cases.
The Value property in comparison contains a branch on a check that the
Nullable<T> has its internal hasValue flag to decide whether to throw
InvalidOperationException or not.

Hence when a nullable type is known to have a value (not be null) and
one wants the value, rather than to possibly trigger the exception-throw
GetValueOrDefault() has a slight performance benefit over Value.

Accordingly, replace calls to the Value property with calls to
GetValueOrDefault() when previous checks or assignments guarantee the
value is not null.
2015-12-15 19:15:58 +00:00