Skip to content

Proposal: allow explicitlty declaring blittable structs as unmanaged #1495

Closed
@Ultrahead

Description

@Ultrahead

This is a cosmetic proposal since the C# compiler enforces blittable constraints and indicate errors where applicable (for example with stackalloc).

The idea is to allow something like:

public unmanaged struct MyBlittable
{
   ... no reference-type fields allowed ...
}

By explicitly declaring a struct as "unmanaged" you are making clear your intention, which can be useful for code comprehension and maintenance. So, if someone on your team (or even your-self after a while) is about to modify the code in the struct, that person will know that, for some reason, no reference type fields where allowed on such struct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions