Skip to content

serialization: Allow enums when no type filter has an opinion - #10234

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
Tragetaschen:fix-enum-handling
Jul 1, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
Tragetaschen:fix-enum-handling

Conversation

@Tragetaschen

@Tragetaschen Tragetaschen commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

The TypeConverter rewrite in 10.2.0 (#10032) split InspectType into a bool? core and a bool wrapper and changed the call sites from "throw on explicit deny" (== false) to "throw unless explicitly allowed". That flipped filter silence from allow to deny, so any enum that is not in TypeManifestOptions.AllowedTypes and matched by no filter now fails type validation, even though enums need no registration to round-trip.

Enums carry no behavior and are serialized through their underlying integral type, so they cannot act as deserialization gadgets. Treat a filter-silent enum as allowed while still honoring an explicit filter deny, which short-circuits before this check. Fixes #10227.

Microsoft Reviewers: Open in CodeFlow

@Tragetaschen

Copy link
Copy Markdown
Contributor Author

I thought about adding this as a new, internal ITypeFilter. Let me know if this is the more idiomatic approach.

The TypeConverter rewrite in 10.2.0 (dotnet#10032) split InspectType into a
bool? core and a bool wrapper and changed the call sites from "throw on
explicit deny" (== false) to "throw unless explicitly allowed". That
flipped filter silence from allow to deny, so any enum that is not in
TypeManifestOptions.AllowedTypes and matched by no filter now fails type
validation, even though enums need no registration to round-trip.

Enums carry no behavior and are serialized through their underlying
integral type, so they cannot act as deserialization gadgets. Treat a
filter-silent enum as allowed while still honoring an explicit filter
deny, which short-circuits before this check. Fixes dotnet#10227.
@ReubenBond
ReubenBond enabled auto-merge June 30, 2026 22:16
@ReubenBond
ReubenBond disabled auto-merge July 1, 2026 21:10
@ReubenBond
ReubenBond merged commit f4a7593 into dotnet:main Jul 1, 2026
174 of 176 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Protobuf generated enum types are not allowed to be serialized

2 participants