Skip to content
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

API Compat doesn't validate changes to structs that would break compat #43628

Open
ericstj opened this issue Sep 23, 2024 · 1 comment
Open

Comments

@ericstj
Copy link
Member

ericstj commented Sep 23, 2024

Describe the bug

Today we synthesize private fields to structs to ensure that when omitting their internal/private API we don't break the following rules:

// SynthesizeDummyFields yields private fields for the namedType, because they can be part of the API contract.
// - A struct containing a field that is a reference type cannot be used as a reference.
// - A struct containing nonempty fields needs to be fully initialized. (See "definite assignment" rules)
// "non-empty" means either unmanaged types like ints and enums, or reference types that are not the root.
// - A struct containing generic fields cannot have struct layout cycles.

We should add rules to API compat to validate that such changes don't occur to a struct.

  1. Adding a reference type field to a struct that didn't previously have a reference type field.
  2. Adding non-empty fields to a struct that didn't previously have non-empty fields.
  3. Adding fields to a struct that use a generic type when it previously did not have fields that used the generic type.

To Reproduce

Omit all the _dummy* fields from the reference source in runtime.
Build.

Expect: API Compat emits diagnostics for all the missing fields.
Actual: No diagnostics.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-ApiCompat untriaged Request triage from a team member labels Sep 23, 2024
Copy link
Contributor

@dotnet/area-infrastructure-libraries a new issue has been filed in the ApiCompat area, please triage

@ViktorHofer ViktorHofer removed the untriaged Request triage from a team member label Mar 10, 2025
@ViktorHofer ViktorHofer added this to the Backlog milestone Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants