Skip to content

Conversation

mandel-macaque
Copy link
Member

Create two helper methods that will allow to interact with a tcs which is used in Async methods.

@mandel-macaque mandel-macaque requested a review from Copilot June 28, 2025 16:09
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 introduces two helper methods for generating TaskCompletionSource invocations and adds corresponding unit tests.

  • Adds TcsSetException and TcsSetResult helpers in BindingSyntaxFactory
  • Implements test data and theory-based tests for both helpers

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/rgen/Microsoft.Macios.Generator/Emitters/BindingSyntaxFactory.cs Added TcsSetException and TcsSetResult methods
tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryRuntimeTests.cs Added test data classes and theory tests for new helpers
Comments suppressed due to low confidence (2)

tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryRuntimeTests.cs:1008

  • [nitpick] The class name repeats "Tests" and could be simplified. Consider renaming to TcsSetExceptionData or TestDataTcsSetException to avoid redundancy.
	class TestDataTcsSetExceptionTests : IEnumerable<object []> {

tests/rgen/Microsoft.Macios.Generator.Tests/Emitters/BindingSyntaxFactoryRuntimeTests.cs:1032

  • [nitpick] Test method names include the suffix "Tests", which is redundant. You could rename the method to TcsSetException or TcsSetException_ReturnsExpectedSyntax for clarity.
	void TcsSetExceptionTests (string tcsVariableName, ImmutableArray<ArgumentSyntax> arguments, string expectedDeclaration)

Comment on lines 309 to 316
var argumentList = ArgumentList (
SeparatedList<ArgumentSyntax> (arguments.ToSyntaxNodeOrTokenArray ()));
return InvocationExpression (
MemberAccessExpression (
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName (tcsVariableName),
IdentifierName ("SetException").WithTrailingTrivia (Space)))
.WithArgumentList (argumentList);
Copy link

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

[nitpick] The implementations of TcsSetException and TcsSetResult are nearly identical. Consider extracting a common method that takes the method name as a parameter to reduce duplication.

Suggested change
var argumentList = ArgumentList (
SeparatedList<ArgumentSyntax> (arguments.ToSyntaxNodeOrTokenArray ()));
return InvocationExpression (
MemberAccessExpression (
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName (tcsVariableName),
IdentifierName ("SetException").WithTrailingTrivia (Space)))
.WithArgumentList (argumentList);
return TcsSetMethod(tcsVariableName, "SetException", arguments);

Copilot uses AI. Check for mistakes.

@mandel-macaque mandel-macaque force-pushed the dev/mandel/tcs-set-methods branch from 51af7ed to 2d7044a Compare June 28, 2025 16:23
@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 6 commits June 28, 2025 13:38
)

This commit allows to generate the strong delegate for a weak delegate
in a bindings. The API provides two ways to configure the strong
property:

1. StrongDelegateType: provide a Type for the new property.
2. StrongDelegateName: Allow to choose the generated property name. If
empty the name will be the name of the WeakDelefate with the Weak prefix
removed.

We have some tests updates:

1. Remove the warnings from the tests. Some are due to the API being
experimenta, other due to a rename. We will remove all errors in a
comming PR.
2. Remove the strong delegate property from the test source since it is
now generated.

This completes the work for support properties (so far).

---------

Co-authored-by: GitHub Actions Autoformatter <[email protected]>
Create two helper methods that will allow to interact with a tcs which
is used in Async methods.
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #0cb2ab2] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 0cb2ab27307327452f64f3f03150e3c3c459e356 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: 0cb2ab27307327452f64f3f03150e3c3c459e356 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❗ API diff for current PR / commit (Breaking changes)

.NET ( ❗ 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: 0cb2ab27307327452f64f3f03150e3c3c459e356 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #0cb2ab2] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 0cb2ab27307327452f64f3f03150e3c3c459e356 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 0cb2ab27307327452f64f3f03150e3c3c459e356 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 0cb2ab27307327452f64f3f03150e3c3c459e356 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 0cb2ab27307327452f64f3f03150e3c3c459e356 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

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

Pipeline on Agent
Hash: 0cb2ab27307327452f64f3f03150e3c3c459e356 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build #0cb2ab2] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 2 tests failed, 113 tests passed.

Failures

❌ monotouch tests (iOS)

2 tests failed, 6 tests passed.
  • monotouch-test/iOS - simulator/Debug (LinkSdk): Crashed
  • monotouch-test/iOS - simulator/Release (NativeAOT, x64): HarnessException (Harness exception for 'monotouch-test': System.AggregateException: One or more errors occurred. (A task was canceled.)
    ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
    at System.Threading.Tasks.Task.GetExceptions(Boolean includeTaskCanceledExceptions)
    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
    at System.Threading.Tasks.Task1.get_Result() at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.get_TestExecutionStarted() at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.ParseResult() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.AsyncStateMachineBox1.ExecutionContextCallback(Object s) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.AsyncStateMachineBox1.MoveNext(Thread threadPoolThread) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.AsyncStateMachineBox1.MoveNext() at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(IAsyncStateMachineBox box, Boolean allowInlining) at System.Threading.Tasks.Task.RunContinuations(Object continuationObject) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.SetExistingTaskResult(Task1 task, TResult result) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult() at Microsoft.DotNet.XHarness.iOS.Shared.CrashSnapshotReporter.EndCaptureAsync(TimeSpan timeout) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.AsyncStateMachineBox1.ExecutionContextCallback(Object s) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.AsyncStateMachineBox1.MoveNext(Thread threadPoolThread) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.AsyncStateMachineBox1.MoveNext() at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(IAsyncStateMachineBox box, Boolean allowInlining) at System.Threading.Tasks.Task.RunContinuations(Object continuationObject) at System.Threading.Tasks.Task.DelayPromise.CompleteTimedOut() at System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool) at System.Threading.TimerQueue.FireNextTimers() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() at System.Threading.Thread.StartCallback() --- End of stack trace from previous location --- --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.get_Result()
    at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.get_TestExecutionStarted()
    at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.ParseResult()
    at Xharness.AppRunner.RunAsync() in /Users/builder/azdo/_work/2/s/macios/tests/xharness/AppRunner.cs:line 424
    at Xharness.Jenkins.TestTasks.RunSimulator.RunTestAsync() in /Users/builder/azdo/_work/2/s/macios/tests/xharness/Jenkins/TestTasks/RunSimulator.cs:line 123
    at Xharness.Jenkins.TestTasks.RunTest.ExecuteAsync() in /Users/builder/azdo/_work/2/s/macios/tests/xharness/Jenkins/TestTasks/RunTest.cs:line 113
    at Xharness.Jenkins.TestTasks.TestTasks.RunInternalAsync() in /Users/builder/azdo/_work/2/s/macios/tests/xharness/Jenkins/TestTasks/TestTask.cs:line 233)

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 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 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: 0cb2ab27307327452f64f3f03150e3c3c459e356 [PR build]

@mandel-macaque
Copy link
Member Author

Failing tests are unrelated to code changes.

@mandel-macaque mandel-macaque merged commit de62f1b into dev/mandel/bump-nuget-deps Jun 30, 2025
37 of 40 checks passed
@mandel-macaque mandel-macaque deleted the dev/mandel/tcs-set-methods branch June 30, 2025 22:08
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.

3 participants