Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prevent trimming of unused CachingContext.Count method
  • Loading branch information
eiriktsarpalis committed Feb 15, 2022
commit 097aed3f47f9c92f87a8f26f4bfe6e789a4a5575
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<linker>
<assembly fullname="System.Text.Json">
<type fullname="System.Text.Json.JsonSerializerOptions+CachingContext">
<!-- Internal API used by tests only. -->
<method name="get_Count" />
</type>
</assembly>
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ internal sealed class CachingContext
public CachingContext(JsonSerializerOptions options)
{
Options = options;
_ = Count;
}

public JsonSerializerOptions Options { get; }
// Property only accessed by reflection in testing -- do not remove.
// If changing please ensure that src/ILLink.Descriptors.LibraryBuild.xml is up-to-date.
public int Count => _converterCache.Count + _jsonTypeInfoCache.Count;
public JsonConverter GetOrAddConverter(Type type) => _converterCache.GetOrAdd(type, Options.GetConverterFromType);
public JsonTypeInfo GetOrAddJsonTypeInfo(Type type) => _jsonTypeInfoCache.GetOrAdd(type, Options.GetJsonTypeInfoFromContextOrCreate);
Expand Down