Skip to content

Investigate the binary compatibility of readonly structs  #1280

@martintmk

Description

@martintmk

When reading this document:
https://learn.microsoft.com/en-us/dotnet/core/compatibility/library-change-rules

This section got me concerned:

If a struct has only public fields or has no fields at all, callers can declare locals of that struct type without calling the struct's constructor or first initializing the local to default(T), so long as all public fields are set on the struct before first use. Adding any new fields - public or nonpublic - to such a struct is a source breaking change for these callers, as the compiler will now require the additional fields to be initialized.

We need to investigate whether we can use read-only structs for argument classes. If adding a new member breaks binary compatibility, we should use classes instead.

As an alternative, at least on hot-paths, we can use argument pooling to reduce allocations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8Issues related to the new version 8 of the Polly library.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions