Warn when using BinaryFormatter resources while targeting .NET 8+ #8453
Labels
Area-NetSDK
Iteration:2023March
Partner request
size:3
Task: GenerateResource
Problems with the task itself, resgen.exe, and resx resources in general.
triaged
Milestone
.NET 8 will make
BinaryFormatter
functionality opt-in, and there's cross-team work to ensure that users have good alternatives and are guided to use them.GenerateResource
can pass BinaryFormatter-serialized resource objects from a source.resx
file to.resources
files embedded by the compiler:msbuild/src/Tasks/ResourceHandling/MSBuildResXReader.cs
Lines 186 to 192 in 03de075
We should add a warning when we hit that case, so users are aware that they have BinaryFormatter exposure.
By default the warning should fire only when the user targets .NET 8+. The easiest way to implement this is probably to add a new argument to
GenerateResource
along the lines ofWarnOnBinaryFormatterResources
, pass it in as a property in common.targets, and then set a default value for it in the .NET SDK.The warning must be overridable, because even in the long term (after .NET 9's removal of BinaryFormatter from the BCL) we expect it to be possible for applications to explicitly opt into BinaryFormatter support, and resources are likely to be a particularly long-lived use case.
The text was updated successfully, but these errors were encountered: