You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The EnableUnsafeBinaryFormatterSerialization setting controls both runtime and compile-time behavior.
138
+
The behavior is slightly different depending on the project type and target runtime.
139
+
140
+
If the property is explicitly set to TRUE:
141
+
- The APIs are obsolete as warning, and calls to the APIs will succeed at runtime.
142
+
143
+
If the property is explicitly set to FALSE:
144
+
- On .NET 5 & 6, the APIs are obsolete as warning, and calls to the APIs will fail at runtime.
145
+
- On .NET 7+, the APIs are obsolete as error, and calls to the APIs will fail at runtime.
146
+
147
+
If the property is not explicitly TRUE or FALSE:
148
+
- On .NET 5 & 6, the APIs are obsolete as warning, and calls to the APIs will succeed at runtime.
149
+
- On .NET 7, the APIs are obsolete as error, but calls to the APIs will succeed at runtime.
150
+
- On .NET 8+, the APIs are obsolete as error, and calls to the APIs will fail at runtime
151
+
unless the SDK has opted in to keeping legacy BinaryFormatter behavior around.
152
+
153
+
n.b. The APIs are already marked obsolete (as warning) in .NET 5, so we don't need to special-case
154
+
them unless we want to upgrade them to warn-as-error.
155
+
-->
156
+
157
+
<PropertyGroupCondition="'$(EnableUnsafeBinaryFormatterSerialization)' != 'true' AND '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '7.0'))">
158
+
<!--
159
+
Certain project types need to re-enable BinaryFormatter by default; it will still be warn-as-error but will work at runtime.
160
+
WinForms: enabled through 8.0 (but not after)
161
+
WPF: enabled through 8.0 (but not after)
162
+
-->
163
+
<_ProjectTypeRequiresBinaryFormatterCondition="'$(UseWindowsForms)' == 'true' AND $([MSBuild]::VersionLessThanOrEquals($(TargetFrameworkVersion), '8.0'))">true</_ProjectTypeRequiresBinaryFormatter>
164
+
<_ProjectTypeRequiresBinaryFormatterCondition="'$(UseWPF)' == 'true' AND $([MSBuild]::VersionLessThanOrEquals($(TargetFrameworkVersion), '8.0'))">true</_ProjectTypeRequiresBinaryFormatter>
0 commit comments