-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GenAPI cannot decode records when reading from metadata #32196
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Related: dotnet/roslyn#67335 |
|
This seems to be important, especially when 8.0 packages will be added to SBRP. Keeping in 8.0 for now. |
Seems like I was wrong in my statement above - genapi does recognize the type as a record type - when it happens to be from source, or a record class. It misses record structs when read from metadata - I filed dotnet/roslyn#69326. Interestingly - for a record struct ignoring that it's a record doesn't make a difference -- it's just more verbose. After realizing this I thought that this bug might just be cosmetic - that we'd emit more than necessary but it would still compile. This is not the case for record classes because there are members included that cannot be represented in C# (eg: Perhaps we can just filter out all compiler generated members on record classes. I gave this a try manually and found that it wasn't quite enough - since it looks like the compiler doesn't annotate the public constructor with CompilerGenerated and defining it results in the compiler omitting the Deconstruct method (which does have the annotation). We could omit the generated constructor - we'd have to identify it as the one constructor that doesn't call any others ( |
Describe the bug
GenAPI does not emit records correctly.
To Reproduce
Compile this and point GenAPI to it.
Expect: Same output
Actual:
Related: #32165
AFAICT there isn't anything preserved in metadata to indicate that a type is a record. Perhaps we could use a heuristic -- look for all the members https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/records.
The text was updated successfully, but these errors were encountered: