Skip to content

WIP :: Bugfix :: Fix F# exception serialization to preserve fields#19342

Draft
T-Gro wants to merge 2 commits intomainfrom
codegen/fix-exception-serialization
Draft

WIP :: Bugfix :: Fix F# exception serialization to preserve fields#19342
T-Gro wants to merge 2 commits intomainfrom
codegen/fix-exception-serialization

Conversation

@T-Gro
Copy link
Member

@T-Gro T-Gro commented Feb 20, 2026

Fixes F# exceptions losing their field values during serialization.

Exceptions with fields now emit a GetObjectData override and a deserialization constructor that save/restore the fields via SerializationInfo, enabling correct ISerializable roundtrips.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/10.0.300.md

@T-Gro T-Gro force-pushed the codegen/fix-exception-serialization branch 3 times, most recently from c9b17c0 to f6f7424 Compare February 20, 2026 17:31
@T-Gro
Copy link
Member Author

T-Gro commented Feb 20, 2026

/azp run fsharp-ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@T-Gro T-Gro force-pushed the codegen/fix-exception-serialization branch from f6f7424 to 675d541 Compare February 20, 2026 19:29
Fixes #878

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro force-pushed the codegen/fix-exception-serialization branch from 675d541 to 4b0a72e Compare February 20, 2026 19:29
The generated GetObjectData override on F# exception types must have the
[SecurityCritical] attribute to match the security accessibility of
Exception.GetObjectData on .NET Framework. Without this, the CLR rejects
the override with 'Inheritance security rules violated', causing FS0193
errors when any project references FSharp.Core (which contains
MatchFailureException with the new GetObjectData override).

Also update IL baselines and FSharp.Core surface area baseline.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Serialization of F#-defined exception variants doesn't serialize fields

1 participant