Commit Graph
1401 Commits
Author SHA1 Message Date
James Newton-King c9bbe2f188 -Fixed JsonWriter.ReadAsXXX methods not erroring on missing commas 2017-02-06 09:08:47 +13:00
James Newton-King 744be1a712 -Use static nametable in camel case contract resolver 2017-01-29 16:10:43 +13:00
James Newton-King 1914b91bdb -Removed obsolete constructor from DefaultContractResolver
-Removed obsolete async methods from JsonConvert
-Moved contract sharing logic from DefaultContractResolver to CamelCasePropertyNamesContractResolver
2017-01-28 20:25:01 +13:00
James Newton-King bfddda84f4 -Tests 2017-01-23 17:56:31 +13:00
James Newton-King 73b5d2c409 -Test 2017-01-23 15:10:10 +13:00
James Newton-King c9cfff4fed -Changed exception thrown when parsing invalid Unicode escape sequence to JsonReaderException 2017-01-23 15:07:16 +13:00
James Newton-King 07b513cb83 -Removed obsolete JsonConverter.GetSchema
-Removed obsolete OnDeserialized, OnDeserializing, OnSerialized, OnSerializing, OnError from JsonContract
-Removed obsolete JsonDictionaryContract.PropertyNameResolver
-Removed obsolete ConstructorParameters, OverrideConstructor, ParametrizedConstructor from JsonObjectContract
2017-01-22 22:28:22 +13:00
James Newton-King e1ec6e9a18 -Build 2017-01-19 20:01:53 +13:00
James Newton-King b35988c31f -Updated pre-release to beta2 2017-01-19 19:26:18 +13:00
James Newton-King 304607a37b Merge branch 'master' of https://github.com/JamesNK/Newtonsoft.Json 2017-01-19 19:24:57 +13:00
James Newton-King c4104766ed -Derp 2017-01-19 19:24:46 +13:00
James Newton-King 2e7b24e9b1 -Added support for TypeConverters to netstandard1.0+ 2017-01-19 17:43:07 +13:00
James Newton-King 55afb9aa72 -Added AutoCompleteOnClose to JsonWriter to control whether JSON is auto-completed on JsonWriter.Close 2017-01-19 14:19:52 +13:00
James Newton-King 56e3d7575b -Fixed deserializing non-string values in some XML nodes 2017-01-19 11:49:09 +13:00
Jon Hanna 8956d3ca9c Fix issues that are variants of those #1182 (#1184)
* Catch excessive objects in json being parsed, even if following a comment.

* Include line info on excessive content for deserialisation.
2017-01-19 10:33:30 +13:00
James Newton-King 76600dcc5b Merge branch 'master' of https://github.com/JamesNK/Newtonsoft.Json 2017-01-17 11:44:24 +13:00
James Newton-King ecd137eefa -Optimized serializing XML elements to JSON 2017-01-17 11:44:04 +13:00
Florian Greinacher 7819b3c5ef Handle F# lists that implement IReadOnlyCollection<T> (F# 4.1 and above) (#1181)
Fixes #1180
2017-01-17 09:45:43 +13:00
James Newton-King 285b4c9a85 -Marked SerializationBinder as obsolete 2017-01-16 19:55:21 +13:00
Jon Hanna 9727996b1a Throw for CheckAdditionalContent when extra content is preceded by comments. (#1183)
Fixes #1182
2017-01-16 14:48:52 +13:00
James Newton-King 7e4b3448c7 -Optimized XML serialization memory usage for elements with one child element name 2017-01-16 11:09:11 +13:00
James Newton-King 473baa639b -Optimized IXmlNode memory usage when no child nodes or attributes 2017-01-15 18:37:06 +13:00
Jon Hanna b3e2d61708 Optimise XmlNodeConverter (#1176)
* Short-circuit SerializeGroupedNodes on no child nodes.

Avoids creating unused Dictionary.

* Don't create Dictionary in ReadAttributeElements if it'll be empty.

* Reduce calls to JsonReader.TokenType virtual property.

* Remove duplicate finished boolean.

Different reasons for finishing the ReadAttributeElements loop are
noted, but the difference isn't acted on, so merge them.

* Check correct XML is from correct TokenType immediately.

(This changes the exception message in the case of it also being an
invalid objectType, but not the exception type).
2017-01-15 18:14:00 +13:00
Jon Hanna 0ef9ec292b Don't explicitly check for Failed or Cancelled Statuses (#1179)
Between discussion at #1137 and a few rounds of revision at #1159 we
arrived at an optimisation where tasks that are both heavily hit and
very likely to return in a completed state are checked for a status of
either RanToCompletion, Canceled or Faulted and a path is taken where
no await is needed for any of those.

The Canceled and Faulted tasks are returned immediately, allowing that
state to be passed to the caller.

However, these are exceptional cases, and if we just continued the
subsequent await would raise the appropriate exception. Checking for
all three cases instead of just RanToCompletion is optimising for those
execptional conditions at cost (in the form of a larger comparison
segment of code) to the more common cases of the task either being
completed or still running.

Simplify this back to a check just for RanToCompletion.
2017-01-15 14:34:37 +13:00
Jon Hanna 3b583b886f Replace some null checks with conditionl operator, reducing field access (#1178) 2017-01-15 09:48:42 +13:00
Jon Hanna 7cb4f634e7 Optimise BinaryConverter's reflection object creation. (#1177)
Make the test for a type being S.D.L.Binary a single test as Binary is
a sealed class and therefore there's no need to test bases.

Make the stored ReflectionObject static, reducing size and repeated
allocations if BinaryConverter is explicitly created by the user.
2017-01-15 09:47:55 +13:00
James Newton-King 1513b11d73 -JsonTextReader new line async performance (#1172) 2017-01-15 09:45:24 +13:00
Jon Hanna dcae8e220d Some optimisations to async reading. (#1171)
MoveToContentAsync is often called in states where it will immediately
return true without any reading. In this case return AsyncUtils.True
avoiding allocation or async state-machine.

DoReadAsync is a very heavily hit method, and can often be fulfilled
without creating another state machine, so do this.

The remaining looping async case is the only use of ParsePostValueAsync,
so inline it into the calling method, so there is one less task
allocation.

Return value of EatWhitespaceAsync is never used, returning void reduces
the number of locals an hence the size of the state-machine. Do the same
for EatWhitespace though the impact is less.
2017-01-13 20:41:18 +13:00
James Newton-King ba04246a16 -Improved SplitFullyQualifiedTypeName allocations 2017-01-13 01:07:13 +13:00
Florian Greinacher b8e60c773b Change ifdefs to be by feature, not by platform (#1146)
* First pass

* Second pass

* Third pass

* Temporarily change build script to build only portable

* Add portable features for release build

* Add feature constants to build script

* Add more feature constants to build script

* Fix build issues

* Fix build issues

* Get rid of constants in build.ps1

* HAVE_NUMERICS -> HAVE_BIG_INTEGER

* Remove HAVE_NULLABLE

* Remove HAVE_NUMERICS from csprojs

* Add missing ifdef

* Add feature defines to pj

* Re-enable netstd builds

* Fix defines in pj

* Trying to get better build outputs

* Trying to get the build error

* Use newer cli

* Address review feedback; make netstd build work

* Introduce HAVE_DB_NULL_TYPE

* Adapt to upstream changes; address remaining review feedback

* Adapt to upstream changes; address remaining review feedback

* Rename some constants for constistency

* Address review feedback

* -Fixed build with signed assembly

* Fix merge erorr

* Address review feedback

* Introduce HAVE_NON_SERIALIZED_ATTRIBUTE

* HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE
2017-01-12 11:07:02 +13:00
James Newton-King eb96cb9f62 Merge pull request #1159 from JonHanna/fault_on_fault
Don't eat exceptions from faulted Tasks.
2017-01-11 09:30:42 +13:00
Jon Hanna 82bfde49e0 Don't eat exceptions from faulted Tasks.
If explicitly testing for IsCompleted then one must also test for
IsFaulted and if not handling the exception, return the faulted Task.
2017-01-10 11:12:46 +00:00
James Newton-King 21f4d95263 Merge pull request #1158 from JonHanna/pass_cancellation
Pass CancellationToken in JObject and JConstructor.WriteToAsync
2017-01-10 08:30:54 +13:00
Jon Hanna dd8d6217a1 Pass CancellationToken in JObject and JConstructor.WriteToAsync
Missed by mistake.
2017-01-09 11:28:41 +00:00
James Newton-King 0654fa5833 -Derp 2017-01-09 23:44:08 +13:00
James Newton-King b29b7e8483 -Derp 2017-01-09 23:44:08 +13:00
James Newton-King 08eb6845e2 -Async write performance 2017-01-09 23:44:08 +13:00
James Newton-King 5fefa723ad -Perf tests 2017-01-09 23:44:08 +13:00
Jon Hanna c9b2ec8055 Async JToken methods 2017-01-09 23:44:08 +13:00
James Newton-King dde1d905df -Build 2017-01-09 17:16:56 +13:00
Jon Hanna 7a93892d03 Optimise WriteEscapedJavaScriptString
Skip attempting write when string is empty.

FirstCharToEscape was introduced for the async version and gives a
faster means to identify the first block before any escaping, so may as
well use it here too.

Conversely, WriteEscapedStringThroughBuffer was introduced to share
code between the sync and async versions, but later optimisations meant
it was no longer used by the async. Inline the code back again.
2017-01-09 17:12:00 +13:00
James Newton-King de82488549 -Minor code cleanup
-Fixed CA warning
2017-01-09 16:46:11 +13:00
James Newton-King 6c7e41537b Merge pull request #1153 from JonHanna/shortcircuit_same_compared
Short-circuit on reference equality in ValueEquals and JValue.Compare
2017-01-09 15:17:53 +13:00
James Newton-King ba79136e4e Merge pull request #1151 from JonHanna/singleton_empty_array
Use singleton for zero-element arrays.
2017-01-09 15:11:14 +13:00
Jon Hanna ff3bfaf51b Use singleton for zero-element arrays.
Create an easily-inlinable method that accesses the array used
by Enumerable.Empty (and hence not just shared within this project
but likely with the client assembly or other libraries it uses)
and use it anywhere a zero-element array is used, reducing allocations.
2017-01-09 01:50:03 +00:00
Jon Hanna ea6a21c4f3 Optimise DynamicProxyMetaObject (#1152)
* Remove unnecessary ToArray call.

* Remove Value property.

One use compares with null, so cast to T is a waste.

This leaves just one other use, so it can be inlined.

* Remove _dontFallbackFirst

Is always true. Remove it and branches for it being false.

* Don't use Expression.Convert to reference types to object.

The end-result is a no-op, so don't waste the allocation.
2017-01-09 14:44:56 +13:00
Jon Hanna f1aa441b62 Short-circuit on reference equality in ValueEquals and JValue.Compare
Covers the both-null case previously checked for, so no extra cost, and
skips all further work.

Also make two `is` checks a null-check after `as`.
2017-01-09 01:18:02 +00:00
Jon Hanna cad2ec3a09 Reduce enumeration of rightResults in BooleanQueryExpression.IsMatch (#1155)
If Operator is Exists or leftResults is empty don't obtain rightResults,
as not relevant.

Otherwise if rightResults is not an ICollection<JToken> load it into an
List so it won't be recomputed on each enumeration of leftResults.
2017-01-09 14:12:49 +13:00
Jon Hanna ec2659e3ad Merge ifs into following switch on same expression in ReadAsBytes (#1147) 2017-01-09 14:01:18 +13:00
Jon Hanna 859d12e338 Remove redundant call to Cast<>() (#1154) 2017-01-09 10:38:36 +13:00