Add unit tests for Xamarin.Android.Tools.Aidl.CSharpCodeGenerator#11460
Open
Copilot wants to merge 3 commits into
Open
Add unit tests for Xamarin.Android.Tools.Aidl.CSharpCodeGenerator#11460Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
…ce, oneway, IBinder, CharSequence Agent-Logs-Url: https://github.com/dotnet/android/sessions/324cdc7a-1571-4d01-9842-9dd4c7a8ba2b Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/android/sessions/324cdc7a-1571-4d01-9842-9dd4c7a8ba2b Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add unit tests for Xamarin.Android.Tools.Aidl.CSharpCodeGenerator
Add unit tests for Xamarin.Android.Tools.Aidl.CSharpCodeGenerator
May 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands unit test coverage for Xamarin.Android.Tools.Aidl.CSharpCodeGenerator by adding a focused NUnit fixture that validates previously-uncovered generator branches using golden TestData/*.txt snapshots, and by extending the shared test helper to vary ParcelableHandling.
Changes:
- Extend
AidlCompilerTestBase.RunTestto accept an optionalParcelableHandlingargument. - Add
CSharpCodeGeneratorTestscovering parcelable modes, multiple interfaces,onewaymethods,IBinder,CharSequence, and parse-error reporting. - Add golden snapshot files for the new scenarios under
tests/.../TestData/.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Xamarin.Android.Tools.Aidl-Tests/AidlCompilerTestBase.cs | Adds ParcelableHandling parameter plumbing to exercise generator modes. |
| tests/Xamarin.Android.Tools.Aidl-Tests/CSharpCodeGeneratorTests.cs | New NUnit fixture targeting specific generator code paths without MSBuild integration tests. |
| tests/Xamarin.Android.Tools.Aidl-Tests/TestData/ParcelableStub.txt | Golden output for ParcelableHandling.Stub. |
| tests/Xamarin.Android.Tools.Aidl-Tests/TestData/ParcelableIgnore.txt | Golden output for ParcelableHandling.Ignore. |
| tests/Xamarin.Android.Tools.Aidl-Tests/TestData/OnewayMethods.txt | Golden output for method-level oneway generation behavior. |
| tests/Xamarin.Android.Tools.Aidl-Tests/TestData/MultipleInterfaces.txt | Golden output for multiple interfaces in one compilation unit. |
| tests/Xamarin.Android.Tools.Aidl-Tests/TestData/IBinderTypes.txt | Golden output for IBinder parameter/return codegen. |
| tests/Xamarin.Android.Tools.Aidl-Tests/TestData/CharSequenceType.txt | Golden output for CharSequence mapping via Android.Text.TextUtils. |
| @@ -0,0 +1,56 @@ | |||
| using System; | |||
| using System.IO; | |||
| [Test] | ||
| public void MultipleInterfaces () => RunTest (nameof (MultipleInterfaces)); | ||
|
|
||
| [Test] |
Comment on lines
+101
to
+105
| __data.WriteInterfaceToken (descriptor); | ||
| __data.WriteInt (code); | ||
| remote.Transact (ITestStub.TransactionFireAndForget, __data, __reply, 0); | ||
| __reply.ReadException (); | ||
|
|
| remote.Transact (ITestStub.TransactionSetBinder, __data, __reply, 0); | ||
| __reply.ReadException (); | ||
|
|
||
| } finally { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CSharpCodeGeneratorhad limited unit coverage — the existing 6 tests mirrored the MSBuild integration tests inAidlTest.cs, leaving several generator code paths only reachable via expensive MSBuild builds.Changes
AidlCompilerTestBase—RunTestnow takes an optionalParcelableHandlingso generator behavior under each mode is exercisable.CSharpCodeGeneratorTestsfixture targeting previously-uncovered code paths:ParcelableIgnore/ParcelableStub/ParcelableError— all threeParcelableHandlingbranches (theStubParcelablemethod had no coverage).MultipleInterfaces— multipleinterfacedeclarations in a single compilation unit.OnewayMethods—onewaymethods omitreply.WriteNoException ()inOnTransact.IBinderTypes—IBinderparameters/returns route throughWriteStrongBinder/ReadStrongBinder.CharSequenceType—CharSequencemaps toJava.Lang.ICharSequenceviaAndroid.Text.TextUtils.ParseErrorIsReported— invalid AIDL surfaces parser messages withnulloutput.TestData/*.txtgolden files, generated via the existingGENERATE_OUTPUTworkflow and inspected.Example
Note for reviewers
The
OnewayMethodsgolden output captures a pre-existing quirk: the generatedProxystill calls__reply.ReadException ()even though the stub side skipsreply.WriteNoException (). The test snapshots current behavior rather than asserting correctness; worth a follow-up if intentional asymmetry is not desired.