Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: SettingsProperty constructor ignores serializeAs parameter if it is not SettingsSerializeAs.Binary #106295

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

buyaa-n
Copy link
Contributor

@buyaa-n buyaa-n commented Aug 12, 2024

As mentioned in the issue the SettingsProperty constructor ignores serializeAs parameter if it is not SettingsSerializeAs.Binary, the regression caused by #50531 which allows BinaryFormatter serialization only when an AppContext switch: System.Configuration.ConfigurationManager.EnableUnsafeBinaryFormatterInPropertyValueSerialization is set, and throws otherwise.

The current fix is setting the SerializeAs property with the serializeAs parameter when it is not SettingsSerializeAs.Binary, though we might want to remove the AppContext switch logic and throw for SettingsSerializeAs.Binary as now the BinaryFormatter is removed and accessing the property values throws PlatformNotSupportedException on serialization even if the switch is on. The related test SerializeAndDeserializeWithSettingsSerializeAsBinary now throws PNSE on VS, skipped when run from command line.

Fixes #104732

@buyaa-n buyaa-n merged commit eb9c01f into dotnet:main Aug 13, 2024
84 checks passed
@buyaa-n buyaa-n deleted the set-serializeas branch August 13, 2024 20:47
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SettingsProperty constructor ignores serializeAs parameter if it is not SettingsSerializeAs.Binary
2 participants