Skip to content

Fix a second batch of v22 regen regressions (CS1750/CS0182/CS0102/CS0535/CS0246 + ref readonly) - #827

Merged
tannergooding merged 6 commits into
dotnet:mainfrom
tannergooding:tannergooding-fix-v22-regen-bugs
Jul 19, 2026
Merged

Fix a second batch of v22 regen regressions (CS1750/CS0182/CS0102/CS0535/CS0246 + ref readonly)#827
tannergooding merged 6 commits into
dotnet:mainfrom
tannergooding:tannergooding-fix-v22-regen-bugs

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Fixes a second batch of v22.1.8 (clang 22.1.8) regressions found regenerating terrafx.interop.windows. Each is an independent codegen bug with a focused commit carrying its fix, a regression test, and unified baselines. All six were verified against faithful synthetic repros with the release generator, and the full generator suite is green (4164 passed, 0 warnings).

Bug Code Symptom
B1 CS1750 unsigned default parameter drops the (uint) cast
B2 CS0182 transparent-struct default wrapped in a non-const cast
A CS0102 __uuidof constant alias emits a duplicate IID
E (silent) ref readonly dropped from GUID #define aliases
C CS0535 multi-level COM inheritance drops the immediate base's members
D CS0246 dropped using System.Numerics; while still using Matrix4x4

B1 — unsigned default parameter drops the (uint) cast (CS1750)

A bare negative literal default on an unsigned parameter emitted unchecked(-1), which is int and won't bind to the uint parameter. An explicit UINT(-1) default was unaffected; only a bare -1 lost the cast.

extern "C" void MyFunction(unsigned int value = -1);

Now emits uint value = unchecked((uint)(-1)).


B2 — transparent-struct default wrapped in a non-const cast (CS0182)

A transparent-struct-typed default was wrapped in ((HRESULT)(0)), which isn't a constant expression and fails inside DefaultParameterValue. Emit the bare constant (DefaultParameterValue(0)), matching v21.


A — __uuidof constant alias emits a duplicate IID (CS0102)

A static const IID& alias initialized from __uuidof names the same IID_ symbol the interface's uuid already emits via _uuidsToGenerate, so a second definition was generated (same member name twice, plus a Guid*-typed field assigned a Guid). Skip the redundant declaration.


E — ref readonly dropped from GUID #define aliases

For #define IID_X IID_Y aliases the generator kept a => ref IID_Y body but lost the ref readonly on the return type, leaving a by-value Guid return paired with a ref body — semantically a copy, and CS8149 in isolation. Preserve the reference so the alias stays zero-copy.

-public static Guid IID_IOInet => ref IID_IInternet;
+public static ref readonly Guid IID_IOInet => ref IID_IInternet;

C — multi-level COM inheritance drops the immediate base's members (CS0535)

IStreamAsync : IStream : ISequentialStream : IUnknown. When the intermediate base is reached through a forward typedef struct IStream IStream; (as MIDL interfaces are declared), clang binds it to a non-definition redeclaration whose members were dropped — so IStreamAsync flattened IUnknown/ISequentialStream then jumped straight to its own member, skipping IStream's SeekClone. Resolve the record to its definition so every inherited vtbl slot flattens in order.


D — dropped using System.Numerics; while still using Matrix4x4 (CS0246)

A namespaced type (System.Numerics.Matrix4x4) used only as a generic-pointer-wrapper template argument dropped its using, leaving the Matrix4x4 reference unresolved. Keep the using.


Baselines are unified to the repo convention: B1/B2 collapse to a single {Mode} file (identical across all 16 variants); A/E/C/D collapse to {Mode} + {Mode}.Compatible (the Compatible config differs only by down-level codegen — collection expressions vs new byte[], InlineArray vs fixed).

tannergooding and others added 6 commits July 18, 2026 18:32
A bare negative literal default on an unsigned parameter emitted `unchecked(-1)`, which is `int` and fails to bind to the `uint` parameter (CS1750). Keep the explicit `(uint)` cast.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A transparent-struct-typed default was wrapped in `((HRESULT)(0))`, which isn't a constant expression and fails inside `DefaultParameterValue` (CS0182). Emit the bare constant.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A `static const IID&` alias initialized from `__uuidof` names the same `IID_` symbol the interface's uuid already emits, so a second definition was generated (CS0102). Skip the redundant declaration.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A `#define IID_X IID_Y` alias over a `ref readonly Guid` IID dropped the `ref readonly` return, leaving a by-value `Guid` return paired with a `=> ref` body. Preserve the reference so it stays a zero-copy alias.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
When an intermediate base is reached via a forward `typedef struct X X;` (as MIDL interfaces are declared), clang bound it to a non-definition redeclaration whose members were dropped, so multi-level COM interfaces lost the base's vtbl slots (CS0535). Resolve the record to its definition.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A namespaced type used only as a generic-pointer-wrapper template argument dropped its `using`, leaving the `Matrix4x4` reference unresolved (CS0246). Keep the using.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding
tannergooding merged commit 85cd61c into dotnet:main Jul 19, 2026
12 checks passed
@tannergooding
tannergooding deleted the tannergooding-fix-v22-regen-bugs branch July 19, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant