dotnet / dotnet/sdk

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

Open
#43,628 1 comment 0 reactions 0 assignees View on GitHub
Area-ApiCompat
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### 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:
https://github.com/dotnet/sdk/blob/58eb155e30a393656dd290486143f02f958898fc/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/INamedTypeSymbolExtensions.cs#L90-L94

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.