Skip to content

feat(serialization): add type and assembly allow-list helpers - #10228

Merged
ReubenBond merged 13 commits into
mainfrom
reubenbond/serialization-opt-ins
Jul 31, 2026
Merged

ReubenBond merged 13 commits into
mainfrom
reubenbond/serialization-opt-ins

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Jun 15, 2026

Copy link
Copy Markdown
Member

TypeManifestOptions.AllowedTypes expects Orleans-formatted runtime type names, which is awkward for callers to construct correctly and only covers individual type names.

This adds AddAllowedType(Type) and AddAllowedAssembly(Assembly) helpers, plus an AllowedAssemblies allow-list, so callers can opt in a specific type or an entire assembly using the same formatting Orleans uses internally.

TypeConverter now expands configured allowed type names into their component type-name entries and honors configured assembly names during fail-closed validation against the resolved Type.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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 an AllowedAssemblies allow-list.
  • Update TypeConverter validation to honor AllowedAssemblies and 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

Comment thread src/Orleans.Serialization/TypeSystem/TypeConverter.cs Outdated
Comment thread src/Orleans.Serialization/README.md Outdated
@ReubenBond
ReubenBond marked this pull request as ready for review June 17, 2026 01:15
@ReubenBond
ReubenBond requested a review from Copilot June 17, 2026 15:22
@ReubenBond
ReubenBond force-pushed the reubenbond/serialization-opt-ins branch from 9efbcfb to 2625b9f Compare June 17, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 3

Comment thread src/Orleans.Serialization/TypeSystem/TypeConverter.cs Outdated
Comment thread src/Orleans.Serialization/README.md Outdated
Comment thread src/Orleans.Serialization/TypeSystem/TypeConverter.cs
@ReubenBond
ReubenBond force-pushed the reubenbond/serialization-opt-ins branch from c576c54 to ace447a Compare June 18, 2026 17:25
@ReubenBond ReubenBond changed the title Add serialization type allow-list helpers feat(serialization): add type and assembly allow-list helpers Jun 19, 2026
Comment thread src/Orleans.Serialization/TypeSystem/TypeConverter.cs Fixed
@ReubenBond
ReubenBond force-pushed the reubenbond/serialization-opt-ins branch from 2f2ec32 to 3b3b8b5 Compare July 6, 2026 18:39
ReubenBond and others added 11 commits July 9, 2026 13:36
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
ReubenBond force-pushed the reubenbond/serialization-opt-ins branch from 7fafb83 to e4d3eb5 Compare July 9, 2026 20:45
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Suppressed comments (1)

src/Orleans.Serialization/TypeSystem/TypeConverter.cs:611

  • InspectGenericArguments uses LINQ (GenericTypeArguments.Select(InspectTypeCore)), which allocates an iterator and can add overhead on a hot path (type formatting/parsing). This file had to add using System.Linq; solely for that. Consider replacing this with a simple foreach to 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

Comment thread src/Orleans.Serialization/TypeSystem/TypeConverter.cs Fixed
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 17:31
Comment thread src/Orleans.Serialization/TypeSystem/TypeConverter.cs Dismissed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Suppressed comments (1)

src/Orleans.Serialization/TypeSystem/TypeConverter.cs:399

  • IsNamedTypeAllowed returns true for names present in _allowedTypesConfiguration without updating the _allowedTypes cache. For configs which allow types by unqualified name (eg options.AllowedTypes.Add(typeof(Foo).FullName)), this means the same assembly-qualified QualifiedType will miss the cache on every call and still pay the cost of running ITypeNameFilter instances (via InspectTypeNameFilters) 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

@ReubenBond
ReubenBond merged commit e06dc27 into main Jul 31, 2026
69 of 70 checks passed
@ReubenBond
ReubenBond deleted the reubenbond/serialization-opt-ins branch July 31, 2026 20:26
This was referenced Aug 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 31, 2026
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.

2 participants