No diagnostics reported for struct cycle across instance and static fields
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
**Version Used**:
**Steps to Reproduce**:
Compile the following:
```csharp
struct C
{
static D x;
}
struct D
{
C> y;
}
```
**Expected Behavior**:
Error reported for cycle. For instance, the pre-Roslyn compiler reports:
```
(3,17): error CS0523: Struct member 'C.x' of type 'D' causes a cycle in the struct layout
(8,13): error CS0523: Struct member 'D.y' of type 'C>' causes a cycle in the struct layout
```
**Actual Behavior**:
No errors reported.
`peverify.exe` fails with the resulting assembly:
```
>peverify c.dll
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.0
Copyright (c) Microsoft Corporation. All rights reserved.
[token 0x02000004] Type load failed.
[token 0x02000005] Type load failed.
2 Error(s) Verifying c.dll
```
See https://github.com/dotnet/roslyn/pull/75702#discussion_r1833778832
Contributor guide
Research direction
Reproduce the issue by compiling the C# generic structs shown in the report and running peverify.exe on the resulting assembly. Read the discussion on PR #75702, then trace the compiler's struct-layout cycle diagnostics; done means both CS0523 errors are reported and the generated assembly passes verification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100