Skip to content

Conversation

mandel-macaque
Copy link
Member

Add a new analyzer error that will ensure that the classes that inherit from UIView or NSView do have a initWithFrame: constructor exposed.

Add a new analyzer error that will ensure that the classes that inherit
from UIView or NSView do have a initWithFrame: constructor exposed.
Copy link
Contributor

@Copilot 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

This PR adds a new analyzer error (RBI0041) to ensure that classes inheriting from UIView or NSView expose the required initWithFrame: constructor. This is a binding requirement for view classes to properly support initialization with frame rectangles.

Key changes include:

  • Extended type inheritance tracking to identify view classes
  • Added new analyzer validation for required constructors
  • Comprehensive test coverage for both UIView and NSView scenarios

Reviewed Changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
TypeSymbolExtensions.Core.cs Added view detection logic and updated inheritance tracking method signature
SemanticModelExtensions.Generator.cs Extended symbol data extraction to include TypeInfo parameter
TypeInfo.cs & TypeInfo.Transformer.cs Added IsView property to track view inheritance
Binding.cs & Binding.Generator.cs Added TypeInfo field to binding data model
ClassValidator.cs Implemented validation logic for required constructors
RgenDiagnostics.cs & Resources.resx Added RBI0041 diagnostic descriptor and messages
Test files Added comprehensive test coverage for the new analyzer functionality
Files not reviewed (1)
  • src/rgen/Microsoft.Macios.Bindings.Analyzer/Resources.Designer.cs: Language not supported

/// </summary>
public bool IsView {
get => isView;
init => isView= value;
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

Missing space before assignment operator. Should be isView = value;

Copilot uses AI. Check for mistakes.

diagnostic: analyzerDiagnotics [0],
diagnosticId: "RBI0041",
severity: DiagnosticSeverity.Error,
message: "The class 'TestClass' inherits from UIView but does not expose a 'initWithFrame:' constructor");
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The error message is incorrect for NSView test case. It should say 'inherits from NSView' instead of 'inherits from UIView' for the NSViewInitWithFrameMissing test.

Suggested change
message: "The class 'TestClass' inherits from UIView but does not expose a 'initWithFrame:' constructor");
message: "The class 'TestClass' inherits from NSView but does not expose a 'initWithFrame:' constructor");

Copilot uses AI. Check for mistakes.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Member

@rolfbjarne rolfbjarne left a comment

Choose a reason for hiding this comment

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

Did we miss this in our existing bindings somewhere?

Also I'm not sure this is correct: there's no reason a UIView subclass can't offer a different constructor (say "initWithFrame:someOtherOption:" and then call UIView's "initWithFrame:" ctor)

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

mandel-macaque and others added 2 commits September 17, 2025 10:26
1. Remove old comment and provide a correct one
2. Provide the protocol name in the error RI00041
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #769e2f2] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 769e2f225f14c0d40ac12abe169a36e644e5d22a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #769e2f2] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 769e2f225f14c0d40ac12abe169a36e644e5d22a [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

✅ API diff vs stable

.NET ( No breaking changes )

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 769e2f225f14c0d40ac12abe169a36e644e5d22a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #769e2f2] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 769e2f225f14c0d40ac12abe169a36e644e5d22a [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #769e2f2] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 769e2f225f14c0d40ac12abe169a36e644e5d22a [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #769e2f2] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 769e2f225f14c0d40ac12abe169a36e644e5d22a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #769e2f2] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 769e2f225f14c0d40ac12abe169a36e644e5d22a [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #769e2f2] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 769e2f225f14c0d40ac12abe169a36e644e5d22a [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #769e2f2] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 115 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 769e2f225f14c0d40ac12abe169a36e644e5d22a [PR build]

@mandel-macaque mandel-macaque merged commit 2b6451b into main Sep 18, 2025
40 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/constructors-uikit branch September 18, 2025 11:55
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.

4 participants