[Analyzer Proposal]: Warn on FixedAddressValueType/ThreadStatic on instance fields.
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
### 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
```cs
class C
{
[FixedAddressValueType]
public Int128 S; // Warns
[ThreadStatic]
public int I; // Warns
}
```
### Alternative Designs
See #129664 for discussion about this.
### Risks
_No response_
Contributor guide
Research direction
Start by reading the discussion in #129664 and locate the analyzer entry point responsible for field attributes; no file or test is named in this issue. The work is done when instance fields using FixedAddressValueType or ThreadStatic produce warnings, while static fields do not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100