feat(serialization): add type and assembly allow-list helpers - #10228
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds convenience APIs for configuring serialization type allow-lists using Orleans runtime type-name formatting, and extends fail-closed type validation to support assembly allow-listing and unconditional enum allowance.
Changes:
- Add
TypeManifestOptions.AddAllowedType(Type)/AddAllowedAssembly(Assembly)plus anAllowedAssembliesallow-list. - Update
TypeConvertervalidation to honorAllowedAssembliesand treat enums as allowed under fail-closed validation. - Update unit tests, README, and generated API surface to cover/reflect the new configuration options.
Show a summary per file
| File | Description |
|---|---|
| test/Orleans.Serialization.UnitTests/TypeConverterTests.cs | Updates allow-list tests to use new helpers; adds coverage for constructed nested generics, allowed assemblies, and enums. |
| src/Orleans.Serialization/TypeSystem/TypeConverter.cs | Implements configured assembly allow-listing, enum allowance, and improved allow-list handling for configured allowed types. |
| src/Orleans.Serialization/README.md | Documents enum allowance and the new allow-list helper APIs. |
| src/Orleans.Serialization/Configuration/TypeManifestOptions.cs | Adds AllowedAssemblies and helper methods to format/insert allowed types and assemblies consistently. |
| src/api/Orleans.Serialization/Orleans.Serialization.cs | Updates public API surface to include the new options members and helper methods. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 2
ReubenBond
marked this pull request as ready for review
June 17, 2026 01:15
ReubenBond
force-pushed
the
reubenbond/serialization-opt-ins
branch
from
June 17, 2026 15:22
9efbcfb to
2625b9f
Compare
ReubenBond
force-pushed
the
reubenbond/serialization-opt-ins
branch
from
June 18, 2026 17:25
c576c54 to
ace447a
Compare
ReubenBond
force-pushed
the
reubenbond/serialization-opt-ins
branch
from
July 6, 2026 18:39
2f2ec32 to
3b3b8b5
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ReubenBond
force-pushed
the
reubenbond/serialization-opt-ins
branch
from
July 9, 2026 20:45
7fafb83 to
e4d3eb5
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot's findings
Suppressed comments (1)
src/Orleans.Serialization/TypeSystem/TypeConverter.cs:611
InspectGenericArgumentsuses LINQ (GenericTypeArguments.Select(InspectTypeCore)), which allocates an iterator and can add overhead on a hot path (type formatting/parsing). This file had to addusing System.Linq;solely for that. Consider replacing this with a simpleforeachto avoid allocations and keep the method allocation-free.
private bool? InspectGenericArguments(Type type)
{
foreach (var result in type.GenericTypeArguments.Select(InspectTypeCore))
{
if (result != true)
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot's findings
Suppressed comments (1)
src/Orleans.Serialization/TypeSystem/TypeConverter.cs:399
IsNamedTypeAllowedreturnstruefor names present in_allowedTypesConfigurationwithout updating the_allowedTypescache. For configs which allow types by unqualified name (egoptions.AllowedTypes.Add(typeof(Foo).FullName)), this means the same assembly-qualifiedQualifiedTypewill miss the cache on every call and still pay the cost of runningITypeNameFilterinstances (viaInspectTypeNameFilters) each time.
Since InspectTypeNameFilters has already had an opportunity to deny (false) before this branch, it should be safe to cache the allow decision for the current QualifiedType key here as well, improving performance and making caching behavior more consistent.
if (_allowedTypesConfiguration.Contains(type.Type))
{
return true;
}
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
This was referenced Aug 28, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TypeManifestOptions.AllowedTypesexpects Orleans-formatted runtime type names, which is awkward for callers to construct correctly and only covers individual type names.This adds
AddAllowedType(Type)andAddAllowedAssembly(Assembly)helpers, plus anAllowedAssembliesallow-list, so callers can opt in a specific type or an entire assembly using the same formatting Orleans uses internally.TypeConverternow expands configured allowed type names into their component type-name entries and honors configured assembly names during fail-closed validation against the resolvedType.Assembly. Type-name filters can still deny uncached names, type filters can still deny resolved types, and constructed generic arguments must be independently allowed.Microsoft Reviewers: Open in CodeFlow