-
Notifications
You must be signed in to change notification settings - Fork 4.9k
[release/3.1] Handle binary formatted payloads with ResX mangled generic type names #42209
[release/3.1] Handle binary formatted payloads with ResX mangled generic type names #42209
Conversation
…dotnet#42102) * Handle binary formatted payloads with ResX mangled generic type names ResXSerializationBinder on desktop corrupted type names for generic parameters in the binary formatted payload. It would also undo this in the reader, but we don't benefit from that in .NETCore since we don't deserialize during build: we just copy the preserialized payload into the resources. To handle this, we use a serialization binder to un-mangle the type names in a way similar to ResXSerializationBinder. We do it slightly differently so that we only do it when needed, since relying on the binder to resolve the type bypasses the type cache in BinaryFormatter. * Respond to feedback. release/3.1 - regenerate TestData.resources
That error looks like your neutral assembly is missing embedded resources. This could be an issue with MSBuild or SDK. It shouldn't be related to this PR, since this PR is impacting the formatting of the content inside the resources not the embedding of the resources itself. Let me see if I can find a candidate change that would have caused the error you're seeing. |
@owlyowl it could be dotnet/msbuild#4597 or dotnet/msbuild#4740. Can you open a new issue in https://github.com/microsoft/msbuild and share either a repro project or more information about the DLLs you've built (eg: open them up in ILSpy or ILDasm and examine the embedded resources and their names). |
Hi Eric just wondering your best contact email for sharing the repo with you? |
Release/3.1 port of #42102.
Description
When a resource contains a serialized type with generic parameters the resource cannot be deserialized on .NETCore. This is caused by a bug in .NETFramework's ResXReader/Writer that we can't fix (nor would that be feasible since we want to deal with old/bad resx files). To handle this we will detect these malformed type names and correct them in with a custom SerializationBinder at runtime.
Customer Impact
Customer cannot deserialize resource. This may prevent the use of some 3rd party controls, or block porting Windows Forms applications from .NETFramework to .NETCore.
Regression?
.NET Framework: Yes. Previous version of .NETCore: No
Risk
Low: This PR could impact performance, but we've minimized this by only using the custom binder to load types when we detect that a type name is bad. We've profiled the type-name checking step to ensure that it is minimal.