Skip to content

Conversation

mandel-macaque
Copy link
Member

Add a validation that will ensure that category methods are:

  1. Partial
  2. Static
  3. Extension methods
  4. Extension methods for the correct type.

Tests have been added to make sure that we indeed get the correct warnings/errors.

mandel-macaque and others added 3 commits September 10, 2025 12:29
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 validation that will ensure that category methods are:

1. Partial
2. Static
3. Extension methods
4. Extension methods for the correct type.

Tests have been added to make sure that we indeed get the correct
warnings/errors.
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 validation to ensure category methods follow proper C# extension method conventions for Objective-C category bindings. It validates that category methods are partial, static, extension methods with the correct first parameter type matching the category's extended type.

  • Added comprehensive validation logic for category method structure and type safety
  • Created new diagnostic descriptors (RBI0042-RBI0044) for specific category method errors
  • Added test coverage for all validation scenarios

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

File Description
CategoryAnalyzerTests.cs New test file with comprehensive test cases for category method validation scenarios
CategoryValidator.cs Added ValidMethods validation logic and registered new diagnostic strategies
RgenDiagnostics.cs Added three new diagnostic descriptors for category method validation errors
Resources.resx Added resource strings for new diagnostic messages and descriptions
Files not reviewed (1)
  • src/rgen/Microsoft.Macios.Bindings.Analyzer/Resources.Designer.cs: Language not supported

);

/// <summary>
/// Disgnostic descriptor for when a category method is not partial
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.

Typo in XML documentation comments: 'Disgnostic' should be 'Diagnostic' in all three instances.

Copilot uses AI. Check for mistakes.

);

/// <summary>
/// Disgnostic descriptor for when a category method is not and extension
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.

Typo in XML documentation comments: 'Disgnostic' should be 'Diagnostic' in all three instances.

Copilot uses AI. Check for mistakes.

);

/// <summary>
/// Disgnostic descriptor for when a category method is not and extension of the category's target type
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.

Typo in XML documentation comments: 'Disgnostic' should be 'Diagnostic' in all three instances.

Copilot uses AI. Check for mistakes.

<value>Category methods have to be partial.</value>
</data>
<data name="RBI0042MessageFormat" xml:space="preserve">
<value>The method '{0}' must me partial</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.

Two typos in resource strings: 'must me partial' should be 'must be partial' and 'categoyr' should be 'category'.

Copilot uses AI. Check for mistakes.

</data>
<data name="RBI0044MessageFormat" xml:space="preserve">
<value>Extension method '{0}' in category '{1}' must have the first parameter type match the category's extended type '{2}' found '{3}'</value>
<comment>{0} is the name of the method, {1} the name of the categoyr, {2} is the category type and {3} is the type found</comment>
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.

Two typos in resource strings: 'must me partial' should be 'must be partial' and 'categoyr' should be 'category'.

Copilot uses AI. Check for mistakes.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #a39e9ae] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

1 tests crashed, 0 tests failed, 116 tests passed.

Failures

❌ monotouch tests (macOS)

🔥 Failed catastrophically on VSTS: test results - monotouch_macos (no summary found).

Html Report (VSDrops) Download

Successes

✅ 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. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 10 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 10 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: a39e9ae30337fa6d05c378d9c930f71693b33c17 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #775591f] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 775591f209dcfcd002711d4564303def0a330227 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #e7bdc2e] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 119 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. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 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 10 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: e7bdc2ecfed644861f039f49eac337bb161cd5b5 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: d5747f14fcf84ddad53e26f2cb16cbc87c3fb521 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #775591f] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 775591f209dcfcd002711d4564303def0a330227 [PR build]

@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: 775591f209dcfcd002711d4564303def0a330227 [PR build]

@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
Copy link
Collaborator

✅ [CI Build #775591f] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 775591f209dcfcd002711d4564303def0a330227 [PR build]

@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: d5747f14fcf84ddad53e26f2cb16cbc87c3fb521 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 775591f209dcfcd002711d4564303def0a330227 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 775591f209dcfcd002711d4564303def0a330227 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 775591f209dcfcd002711d4564303def0a330227 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 775591f209dcfcd002711d4564303def0a330227 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #d5747f1] 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. 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: d5747f14fcf84ddad53e26f2cb16cbc87c3fb521 [PR build]

Base automatically changed from dev/mandel/constructors-uikit to main 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