Commit 1e337ae
authored
Remove Newtonsoft.Json dependency and enhance FieldValueHelper enum resolution (#274)
* Remove Newtonsoft.Json dependency and enhance FieldValueHelper enum resolution
Remove the transitive Newtonsoft.Json dependency that was unnecessarily pulled in via Foundatio.JsonNet, completing the System.Text.Json migration:
- Delete AggregationsNewtonsoftJsonConverter and BucketsNewtonsoftJsonConverter
- Remove all [Newtonsoft.Json.*] attributes from IAggregate, IBucket, FindResults, FindHit, and CountResult models (STJ equivalents already in place)
- Remove Foundatio.JsonNet PackageReference/ProjectReference from csproj
- Update SerializerTestHelper to STJ-only
Additionally, enhance FieldValueHelper.GetEnumStringValue to resolve enum values using [EnumMember(Value)] as a fallback after [JsonStringEnumMemberName], fixing silent Elasticsearch query bugs when custom enum serialization names are used.
Add comprehensive FieldValueHelper unit tests covering enum attribute resolution and all primitive type conversions.
* Migrate test serialization from Newtonsoft to STJ and cache enum lookups
- Replace all JsonConvert usage in ES tests with System.Text.Json.JsonSerializer
- Add ConcurrentDictionary cache for enum string resolution in FieldValueHelper
- Use GetField instead of GetMember for more efficient reflection
* Remove enum cache — reflection cost is negligible for query-builder call site
* Add bounded per-type enum lookup cache for GetEnumStringValue
Caches attribute resolution per enum Type (not per value), so growth is bounded by the number of distinct enum types in the app. Flags combinations and undefined values fall through to ToString() without polluting the cache.
* Add edge-case tests and remove redundant deserialization blocks
* Apply suggestion from @niemyjski1 parent 93b97ab commit 1e337ae
12 files changed
Lines changed: 283 additions & 212 deletions
File tree
- src
- Foundatio.Repositories.Elasticsearch/Utility
- Foundatio.Repositories
- Models
- Aggregations
- Serialization
- tests
- Foundatio.Repositories.Elasticsearch.Tests
- Foundatio.Repositories.Tests/Serialization
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
2 | 7 | | |
3 | 8 | | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
7 | 12 | | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
25 | 32 | | |
26 | 33 | | |
27 | 34 | | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
31 | 65 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | 5 | | |
9 | 6 | | |
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
| |||
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
84 | | - | |
85 | 83 | | |
86 | 84 | | |
87 | 85 | | |
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
91 | | - | |
92 | 89 | | |
93 | 90 | | |
94 | 91 | | |
| |||
201 | 198 | | |
202 | 199 | | |
203 | 200 | | |
204 | | - | |
205 | 201 | | |
206 | 202 | | |
207 | 203 | | |
| |||
287 | 283 | | |
288 | 284 | | |
289 | 285 | | |
290 | | - | |
291 | 286 | | |
292 | 287 | | |
293 | 288 | | |
| |||
Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 11 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
498 | 497 | | |
499 | 498 | | |
500 | 499 | | |
501 | | - | |
502 | | - | |
| 500 | + | |
| 501 | + | |
503 | 502 | | |
504 | 503 | | |
505 | 504 | | |
| |||
521 | 520 | | |
522 | 521 | | |
523 | 522 | | |
524 | | - | |
525 | | - | |
| 523 | + | |
| 524 | + | |
526 | 525 | | |
527 | | - | |
| 526 | + | |
528 | 527 | | |
529 | 528 | | |
530 | 529 | | |
| |||
565 | 564 | | |
566 | 565 | | |
567 | 566 | | |
568 | | - | |
569 | | - | |
| 567 | + | |
| 568 | + | |
570 | 569 | | |
571 | 570 | | |
572 | 571 | | |
| |||
600 | 599 | | |
601 | 600 | | |
602 | 601 | | |
603 | | - | |
604 | | - | |
| 602 | + | |
| 603 | + | |
605 | 604 | | |
606 | 605 | | |
607 | 606 | | |
| |||
631 | 630 | | |
632 | 631 | | |
633 | 632 | | |
634 | | - | |
635 | | - | |
| 633 | + | |
| 634 | + | |
636 | 635 | | |
637 | 636 | | |
638 | 637 | | |
| |||
642 | 641 | | |
643 | 642 | | |
644 | 643 | | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | 644 | | |
661 | 645 | | |
662 | 646 | | |
| |||
0 commit comments