Repository navigation
Attempt to fix browser-wasm test failures. - #87680
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsAttempts to fix the browser-wasm test failures that #87637 introduced. cc @stephentoub
|
| { | ||
| // browser-wasm compat -- ensure the linker doesn't trim away constructor parameter names from KVP. | ||
| Type[] genericArguments = typeToConvert.GetGenericArguments(); | ||
| Type keyValuePairType = typeof(KeyValuePair<,>).MakeGenericType(genericArguments); |
There was a problem hiding this comment.
@eerhardt the code in line 51 is redundant, but it's there to have the linker not trim away the constructor parameter names of KeyValuePair. Do you know of any incantations that might let us avoid it in this case?
There was a problem hiding this comment.
I believe if you put a [DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors, typeof(KeyValuePair<,>)] on this method, the trimmer will see that you are going to access the constructor through reflection and not trim away the parameter names.
cc @vitek-karas
There was a problem hiding this comment.
Good point, we are doing that already to get tests to work in Blazor:
I'd be inclined to just put that annotation in the relevant tests rather than arbitrarily doing it for KVP in product code.
There was a problem hiding this comment.
I'd be inclined to just put that annotation in the relevant tests rather than arbitrarily doing it for KVP in product code.
Agreed, especially since this code is marked "RequiresUnreferencedCode". That is the stance we've taken elsewhere in STJ w.r.t. trimming and our "unsafe" APIs. For example - #53317
|
Can confirm that the blazor-wasm legs are green with this change, merging to unblock CI. |
* Address feedback from #87680. * Update src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/JsonSerializerWrapper.Reflection.cs Co-authored-by: Eric Erhardt <[email protected]> --------- Co-authored-by: Eric Erhardt <[email protected]>
Attempts to fix the browser-wasm test failures that #87637 introduced. cc @stephentoub