Skip to content

[Analyzer Proposal]: Warn on FixedAddressValueType/ThreadStatic on instance fields. #131094

Description

@MichalPetryka

Background and motivation

The runtime ignores FixedAddressValueType/ThreadStatic if the field isn't static, this might lead to unexpected GC holes/logic bugs if the programmer doesn't know this.

API Proposal

Warn on FixedAddressValueType/ThreadStatic if the field isn't static.

API Usage

class C
{
    [FixedAddressValueType]
    public Int128 S; // Warns
    [ThreadStatic]
    public int I; // Warns
}

Alternative Designs

See #129664 for discussion about this.

Risks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtime.CompilerServicescode-analyzerMarks an issue that suggests a Roslyn analyzeruntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions