Skip to content

Readonly structs in standard library #893

@KalleOlaviNiemitalo

Description

@KalleOlaviNiemitalo

Describe the bug

Of the struct types listed in Annex C of the C# 7.x draft, only a few are specified as readonly struct. In .NET however, most of them are defined as readonly struct.
Is this allowed, and is it an extension?

Example

Types that are readonly struct in .NET but plain struct in Annex C include:

  • System.Int32
  • System.Span<T>
  • System.Runtime.CompilerServices.TaskAwaiter<TResult>

Expected behavior

Could be solved in any of these ways:

  • make them readonly struct in the standard, too
  • declare that an implementation can add readonly to standard library struct types
  • as above, but also change every readonly struct in Annex C to plain struct

Additional context

Similar to #870 on attributes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions