Skip to content

Conversation

@Sergio0694
Copy link
Member

Title. Not 100% sure there can't be some edge cases where we cap the interfaces but then some code is invalid because it relies on some generic instantiations not yet discovered, but then again this shouldn't really ever be hit in the first place.

Introduce TryAddExposedInterfaceType to centralize adding tracked projected Windows Runtime interfaces and enforce a hard cap of 128 entries. Replace direct interfaces.Add calls with the helper so discovery will emit WellKnownInteropExceptions.ExceededNumberOfExposedWindowsRuntimeInterfaceTypesWarning (id 84) and stop adding further interfaces when the limit is reached. Adds the new warning factory in WellKnownInteropExceptions and preserves existing warning-as-error behavior via args.TreatWarningsAsErrors.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a hard cap to the number of projected WinRT interfaces tracked for exposed types to prevent runaway discovery, and introduces a warning when the limit is hit.

Changes:

  • Adds a new well-known warning (ID 84) for exposed types exceeding the tracked interface limit.
  • Updates interop type discovery to stop tracking additional interface types once 128 have been collected.
  • Refactors repeated interface-add logic into a helper method.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/WinRT.Interop.Generator/Errors/WellKnownInteropExceptions.cs Adds a new warning for exceeding the max tracked WinRT interface count.
src/WinRT.Interop.Generator/Discovery/InteropTypeDiscovery.cs Enforces the 128-interface cap during discovery via a new helper method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Ensure finalization blocks always run by replacing loop breaks with explicit goto labels (FinalizeUserDefinedType and FinalizeSzArrayType) in InteropTypeDiscovery. Update TryAddDiscoveredInterface to short-circuit when an interface is already present and to explicitly ignore the builder Add return value. Change TypeSignatureEquatableSet.Builder.Add to return a bool (forwarding the underlying set.Add result) and add a Contains method so callers can check membership before adding. These changes fix control-flow gaps that skipped finalization logic and improve correctness when handling duplicate interface discoveries.
Correct a typo in src/WinRT.Interop.Generator/Errors/WellKnownInteropExceptions.cs XML summary comment: changed 'limited' to 'limit'. This is a documentation-only change with no functional impact.
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