Commit Graph
712 Commits
Author SHA1 Message Date
Layomi Akinrinade 354ab2ad95 [JSON source gen 1/3] Implement APIs needed by JSON source generator (#51149)
* Rename JsonClassInfo to JsonTypeInfo

* Move existing metadata types to new Metadata sub-folder/sub-namespace

* Add JsonMetadataServices and APIs needed by source generator

* Add tests and address feedback

* Rename ClassType to ConverterStrategy and clean up usage

* Move JsonSerializerContext to S.T.J.Serialization namespace and address doc feedback
2021-04-14 19:55:48 -07:00
Stephen Toub cab8e14b74 Enable JsonSerializerOptions cache clearing for hot reload metadata update (#51160)
* Enable JsonSerializerOptions cache clearing for hot reload metadata update

* Address PR feedback
2021-04-14 19:58:30 -04:00
Steve Harter ee0719079c Add JsonNode feature (#51025) 2021-04-14 12:30:38 -05:00
81d3a993ca System.Text.Json: Add IAsyncEnumerable support (#50778)
* implement IAsyncEnumerable JsonConverter

* Prototype of IAsyncEnumerable deserialize with Stream

* Use a Queue + test buffersizes

* Avoid 1 item lag

* Add support for Serialize

* Misc cleanup on test

* extend DeserializeAsyncEnumerable test coverage

also removes SerializeAsyncEnumerable components

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IAsyncEnumerableConverterFactory.cs

Co-authored-by: Stephen Toub <[email protected]>

* address feedback

* tweak test buffer values

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IAsyncEnumerableOfTConverter.cs

Co-authored-by: Stephen Toub <[email protected]>

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IAsyncEnumerableOfTConverter.cs

Co-authored-by: Stephen Toub <[email protected]>

* address feedback

* increase delayInterval in serialization tests

* address feedback

* address feedback

* add test on exceptional IAsyncDisposable disposal

* address feedback

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/ReadAsyncState.cs

Co-authored-by: Layomi Akinrinade <[email protected]>

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/WriteStack.cs

Co-authored-by: Layomi Akinrinade <[email protected]>

* fix build and remove dead code

* address feedback

* Revert unneeded JsonClassInfo.ElementType workaround

* remove state allocation on async deserialization methods

* remove tooling artifacts

* address feedback

* reset AsyncEnumeratorIsPendingCompletion field

Co-authored-by: Steve Harter <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
Co-authored-by: Layomi Akinrinade <[email protected]>
2021-04-12 17:06:01 +01:00
Layomi Akinrinade 40ab8c9c75 Add a System.Text.Json threat model doc (#50541)
* Add a System.Text.Json threat model doc

* Address review feedback
2021-04-02 21:30:24 -07:00
Sychev Vadim 4f8be1992c Add check for JsonConverterFactory (#50219) (#50329) 2021-03-28 13:46:02 +01:00
kronicandkronic 62170c1147 remove repetitions ';' (#50236)
Co-authored-by: kronic <[email protected]>
2021-03-25 20:59:08 -04:00
Stephen Toub 0817e748b7 Seal internal types in libraries (#50225) 2021-03-25 20:50:33 -04:00
Layomi Akinrinade d73c261729 Align dictionary key converter/metadata retrieval with pattern for collection elements (#50074)
* Align dictionary key converter/metadata retrieval with pattern for collection elements

* Address review feedback
2021-03-24 22:54:44 +00:00
Steve Pfister bc5b227c9f Remove openssl dependency from android (#49282) 2021-03-23 00:17:12 -04:00
Levi Broderick c569bc1222 System.Text.Encodings.Web refactoring and code modernization (#49373)
- Unify workhorse implementations across all inbox encoders
- Refactor most unsafe code from TextEncoder workhorse routines into standalone helpers
- Fix bounds check logic in workhorse routines
- SSSE3-optimize central workhorse routine
- Remove vestigial code from the library and unit test project
- Add significant unit test coverage for the workhorse routines and unsafe helpers
- Ref: CVE-2021-26701 (MSRC 62749)
2021-03-18 18:14:53 -07:00
Steve MacLean e867be6cab Enable macOS-arm64 libraries tests on runtime-staging rolling builds (#49445)
* Disable failing Apple Silicon Libraries tests

-  Use tests.proj to disable catastrophically failing libraries tests
-  Add ActiveIssues where XUnit didn't crash

* Enable CoreCLR lib tests for Apple Silicon in Runtime-Staging
2021-03-18 14:03:08 -04:00
2d0fe49001 [main] Update dependencies from mono/linker (#49577)
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Eric Erhardt <[email protected]>
Co-authored-by: Marek Safar <[email protected]>
Co-authored-by: Alexander Köplinger <[email protected]>
2021-03-17 20:56:33 +01:00
Ulrich WeigandandStephen Toub 604ea079b5 Big-endian fix for JsonClassInfo.GetKey (#49708)
* Big-endian fix for JsonClassInfo.GetKey

* Skip assertion in JsonClassInfo.GetKey on big-endian
  (code will not ensure the properties tested here)

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.Cache.cs

Co-authored-by: Stephen Toub <[email protected]>
2021-03-17 06:42:35 -04:00
Santiago Fernandez Madero 689bac6222 Fix APICompat errors for atttributes on parameters (#49408) 2021-03-11 00:03:10 -08:00
Steve MacLean 34294fabcb [macOS-arm64] Disable failing libraries tests (#49400)
* Disable tests for XUnit crashes on Apple Silicon

* Apple Silicon Disable System.IO.MemoryMappedFiles.Tests

* Apple Silicon disable DirectoryServices.Protocols.Tests

* Apple Silicon disable Cryptography tests

M1 helix missing usable libssl

* Apple Silicon disable TestVirtualMemorySize64

* Apple Silicon disable ImportCollectionsFromContainerOnly

* Apple Silicon disable XmlWriterApi tests

* Fix whitespace
2021-03-10 12:02:50 -05:00
David Cantú 11ff8a576a Remove unnecessary check on polymorphic serialization (#48464) 2021-03-09 19:11:17 -08:00
Ispiriants Artur 6919fc2cac Don't box every single value type dictionary key. (#46460)
During slow path deserialization fallback to storing dictionary key
as object only when Read returns false.
2021-03-03 11:56:55 -08:00
Sychev Vadim 83313abbe2 New tests that JsonIncludeAttribute and JsonNumberHandlingAttribute are honored during deserialization (#47904)
* New test that JsonIncludeAttribute is honored during deserialization

ArgumentDeserialization_Honors_JsonInclude test is added #47855

* New test that JsonNumberHandlingAttribute is honored during deserialization

ArgumentDeserialization_Honors_JsonNumberHandling test is added #47855

* Extended Point_MembersHave_JsonInclude class for variety of test cases

Added new lines
2021-03-03 11:47:12 -08:00
Sychev Vadim 2f9f6dd736 IntPtr and UIntPtr were added as DisallowedTypes (#47899)
* IntPtr and UIntPtr were added as DisallowedTypes

NotSupportedException is fired when IntPtr/UIntPtr is being serialized/deserialized

* Returned typeof(T) calls back
2021-03-03 11:39:04 -08:00
Stephen Toub 8fdcecc4dd Use MemoryExtensions.LastIndexOf in ReThrowWithPath (#48650)
Enable string.LastIndexOf (and some of the other StringComparison paths) to be trimmed in a default Blazor wasm app, and don't require an ICU fallback as only ordinal is required here.
2021-03-03 10:28:31 -05:00
Viktor Hofer 3553284bea Rename mention to master branch to main (#48824) 2021-03-01 10:09:31 +01:00
Eric Mutta 8c88d1d9a1 Fix doc comment typo in JsonSerializerOptions.cs (#48590)
The following sentence in the doc comments for the `IgnoreReadOnlyFields` member:

> A property is read-only if it isn't marked with the <c>readonly</c> keyword.

Should read:

> A field is read-only if it is marked with the <c>readonly</c> keyword.
2021-02-22 13:54:03 +00:00
Eric MuttaandEirik Tsarpalis 5b5ac99749 Fix another doc comment typo in JsonSerializerOptions.cs (#48591)
* Fix another doc comment typo in JsonSerializerOptions.cs

The following sentence in the doc comments for the `IncludeFields` member:

> Determines whether fields are handled serialization and deserialization.

Should read:

> Determines whether fields are handled **during** serialization and deserialization.

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs

Co-authored-by: Eirik Tsarpalis <[email protected]>
2021-02-22 13:52:10 +00:00
David Cantú fd9886d8f0 Add option to ignore reference cycles on serialization (#46101)
* Add option to ignore reference cycles on serialization

* Fix whitespace

* Combine IsValueType check on WriteCoreAsObject

* Add missing null-forgiving operator

* Fix perf regression by using ReferenceHandlerStrategy field in JsonSerializerOptions

* Address suggestions

* Rename API to IgnoreCycles

* Add missing letter to test class name

* Fix CI issue with nullable annotation
2021-02-17 20:04:19 -08:00
Marek Safar 2d30f34139 Clean up libraries trimming illink configuration (#48153) 2021-02-17 12:35:24 +01:00
Newell Clark 8f91099069 Fix undisposed enumerators (#48322)
-Fix converters not disposing enumerators (issue #46349)
-Add tests
2021-02-16 10:33:44 -08:00
Viktor Hofer d77092decb Use live dependencies for netcoreapp3.0 depencies (#48176)
* Use live dependencies for netcoreapp3.0 deps
2021-02-16 12:24:23 +01:00
Stephen Toub a9c5eadd95 Remove superfluous #nullable enables (#48033)
And enable nullable annotations in test projects
2021-02-10 14:04:48 -05:00
Youssef VictorandDan Moseley 5d5c3e7a58 Enable markdownlint rule (MD009) (#40887)
* Create markdownlint.yml

* Create markdownlint-problem-matcher.json

* Create .markdownlint.json

* Update .markdownlint.json

* fix violations

* fixes

* Remove "push" section

As advised by @viktorhofer so it's quite clear it only runs in CI.

Co-authored-by: Dan Moseley <[email protected]>
2021-02-08 10:43:40 -08:00
Stephen Toub a3cbb03a29 Fix tests failing xunit analyzers after dependency update (#47954) 2021-02-06 11:23:13 -05:00
Stephen Toub 2b0e2785e5 Use [NotNullWhen(true)] in more places (#47598)
* Use [NotNullWhen(true)] in more places

Did a quick search/audit for methods that returned bool and took nullable object as the first input, and added [NotNullWhen(true)] where it was obviously correct.

* Address PR feedback
2021-01-30 06:09:28 -05:00
Kenneth Pouncey c72b54243a [browser][tests][outerloop] Standup OuterLoop tests on CI (#45949)
* [browser][tests][outerloop] Standup OuterLoop tests on CI

* System.Collections.NonGeneric.Tests passing

* System.Console.Tests passing

* System.Diagnostics.DiagnosticSource.Tests passing

* System.Globalization.Tests passing

- See active issue https://github.com/dotnet/runtime/issues/45951

* System.IO.FileSystem.Tests passing after deactivating test cannot wait on monitors on this runtime.

* System.IO.FileSystem.Tests passing - See active issue: https://github.com/dotnet/runtime/issues/45954

* Remove fat fingered code.

* Threads not supported on Browser

* Browser does not support monitor

* Browser does not support monitor

* Browser does not support wait on monitors

* Browser does not support wait on monitors

* Add ActiveIssue for DataFlow tests TestNullTarget_CompletionNoCaching

* Add ActiveIssue for DataFlow tests

* Add ActiveIssue for DataFlow tests

* Add threading support conditional

* Change all Cannot wait on monitors on this runtime Browser platform checks to

[ConditionalXXXX(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]

As was suggested in comments

* Address review comment for monitors not supported

* Address review comments

* Add threading supported condition.

```
fail: [FAIL] System.Text.Json.Serialization.Tests.EnumConverterTests.VeryLargeAmountOfEnumsToSerialize
[08:10:56] info: System.PlatformNotSupportedException : Cannot wait on monitors on this runtime.
```
2021-01-20 14:45:27 +01:00
Ahson Khan f76f1ef234 Remove unnecessary ! (null-forgiving) operator use within an if (not null) block (#47054) 2021-01-15 17:01:49 -08:00
Mikel Blanchard f3ec6dcada Improve perf of serializing Nullable<T> (#46788) 2021-01-15 10:15:59 -06:00
Viktor Hofer ceaa8ae8f7 Inline package descriptions and remove descriptions.json files across the repo (#46306)
* Support runtime package descriptions

* Update arcade Packaging pkg

* Inline pkg descriptions for coreclr

* Inline pkg descriptions for mono

* Inline pkg descriptions for installer

* Inline pkg descriptions for libraries
2020-12-22 16:07:56 +01:00
Eric Erhardt 56f5a0d2d1 Fix a few spelling mistakes (#45930)
paramterless => parameterless
Polymorhic => Polymorphic
2020-12-10 22:01:59 -06:00
Jan Kotas a5d0bcf19f Delete redundant DivMod implementation (#45652) 2020-12-06 12:42:39 -08:00
Santiago Fernandez Madero 87c3cb7674 Disable Long Running JSON tests on Checked CoreCLR (#45505)
* Disable Long Running JSON tests on Checked CoreCLR

* PR Feedback
2020-12-03 14:39:39 -08:00
Stephen Toub 2c155c26bf Fix spelling of OverideEventProvider (#45113)
* Fix spelling of OverideEventProvider

* Fix a few more "overrides" in comments
2020-11-25 09:35:39 -05:00
Stephen ToubandJeremy Barton f9a8abc8a5 Remove more LINQ usage from various dotnet/runtime libraries (#44964)
* Remove unnecessary OrderBy / copy from MemoryCache.Compact

* Replace First() in ILEmitResolverBuilder with [0]

* Remove stale "using System.Linq;" from System.Text.Json

* Remove stale "using System.Linq;" from System.Security.Cryptography.X509Certificates

* Remove some LINQ usage from System.Security.Cryptography.Pkcs

* Remove System.Linq reference from System.Private.Xml

* Remove System.Linq reference from System.Net.WebHeaderCollection

* Remove stale "using System.Linq;" from CookieContainer

* Remove stale "using System.Linq;" from AltSvcHeaderParser

* Remove Enumerable.Contains on a string from System.IO.Packaging

* Remove System.Linq dependency from System.Diagnostics.Process

* Remove LINQ usage from Microsoft.Extensions.Options

* Remove LINQ usage from Microsoft.Extensions.Logging

* Remove LINQ usage from Microsoft.Extensions.Logging.Console

* Remove LINQ from CollectionExtensions.GetAssets/RuntimeFiles

* Update src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Rfc3161TimestampToken.cs

Co-authored-by: Jeremy Barton <[email protected]>

Co-authored-by: Jeremy Barton <[email protected]>
2020-11-20 18:58:31 -05:00
Marcus TurewiczandDavid Cantu 9d60485697 Handle unicode and e-notation differences between S.T.J and J.N tests (#35042)
* Handle unicode and e-notation differences between S.T.J and J.N tests

Fixes #32350

* Remove TODO

* Bumping CI

* Bump CI

* Handle relaxed escaping and precision properly

* Move else if

* Move else if back

* Remove relaxedEscaping param and skip whitespace

* Apply Jozkee final touches

* Add missing period

Co-authored-by: David Cantu <[email protected]>
2020-11-17 13:55:51 -08:00
Viktor Hofer ed295782bf Add workflow to update solution files with SlnGen and update them initially (#44703)
* Add slngen infra

* Update all solution files
2020-11-17 18:23:30 +01:00
Steve Harter a41e10078e Remove dependency on System.Linq from debug build (#44531) 2020-11-12 09:39:28 -06:00
Charles Stoner c1a21a0319 Resolve warnings for assignment or explicit cast of possibly null type parameter value (#43925) 2020-11-09 20:11:57 -08:00
Stephen Toub d4c1c9a7da Change async void System.Text.Json test to be async Task (#44418) 2020-11-09 12:11:30 -08:00
devskoandLayomi Akinrinade e691753245 JSON continuation tests (#42393)
* Repro #42070

* formatting

* namespace

* Fix

* never forget the header

* More tests
- Test continuation at every position inside the tested object
- Many member with primitive and nullable types
- One more level of nested object
- All combinations of class/struct for tested and nested object
- tested and nested object with parametrized ctor for some properties

* Addressed feedback

* refactoring

* Test with original repro data from #42070

* custom converter to ensure the padding is written in front of the tested object

* rename

* test data moved to Strings.resx

* Using test data from SR

* Generalize continuation tests for payloads of any length
Tweak the payload and expect `JsonException`

* merge

* Test deserialize with Utf8JsonReader and ReadOnlySequence

* Again with value typed nested object

* Add tests for splitted whitespaces

* Addressed feedback
Added dictionary test

* Validate line and position of failure in tweaked payloads
more tweaks

* Fixed comment

Co-authored-by: Layomi Akinrinade <[email protected]>
2020-11-02 13:37:52 -08:00
Layomi Akinrinade c0b645d7f0 Set default value for value-type ctor params properly (#43831)
* Set default value for value-type ctor params properly

* Address review feedback
2020-10-30 11:38:27 -07:00
Layomi Akinrinade 4d3ca5fb4a Set number handling for properties read after deserializing ctor params (#43829)
* Set number handling for properties read after deserializing ctor params

* Use DeserializeWrapper pattern for tests
2020-10-30 10:39:43 -07:00
Steve Harter f8e1365a73 Address JsonElement doc and test feedback (#43832) 2020-10-30 09:36:55 -05:00