Repository navigation
[Mono.Android] Fix handwritten XML doc warnings and narrow NoWarn - #13871
Open
simonrozsival wants to merge 2 commits into
Open
simonrozsival wants to merge 2 commits into
simonrozsival wants to merge 2 commits into
Conversation
Commit aab6791 stopped passing `--doc-copyright` to `java-source-utils` when generating `android-javadoc.xml`, so `<javadoc-metadata>` no longer contains a `<copyright>` child element. `JavadocInfo.GetExtra` unconditionally dereferenced `javadocMetadata.Element ("copyright").Elements ()`, causing `NullReferenceException` whenever `Mono.Android.csproj` was built with `-p:IncludeAndroidJavadoc=True`. Guard the `<copyright>` lookup and only append copyright elements when present (matching `BoundProperty.AddJavadocs`, which already handles a null `Copyright`). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fix all handwritten XML documentation comment warnings in `src/Mono.Android/` that were masked under `IncludeAndroidJavadoc=True`: - `ValueTypeFactory.cs`: document missing `handle` and `transfer` parameters on `CreateReferenceMixedDictionary` (`CS1573`). - `ITypeMap.cs`: qualify `Java.Interop.JavaPeerProxy` in `<see cref>` (`CS1574`). - `AndroidMessageHandler.cs`: fix `<see cref>` targets to `AndroidHttpResponseMessage.Dispose(bool)` and `TrustedCerts` (`CS1574`). - `JniMarshalTyped.tt` / `JniMarshalTyped.cs`: replace unsupported function-pointer parameter syntax in `<see cref>` with `JniMarshal.SafeInvokeAction` (`CS1584`, `CS1658`). - `TrimmableTypeMapTypeManager.cs`: replace XML doc comment on local function `TryGetBuiltInReferenceJniName` with a regular comment (`CS1587`). Remove `CS1574`, `CS1584`, and `CS1658` from the `IncludeAndroidJavadoc=True` `<NoWarn>` in `Mono.Android.csproj`, as zero generated binding Javadoc comments emit them across API 37 and API 37.2. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the documentation fixes and optional copyright metadata handling.
No open issues 🎉
What changed in this PR
Fixes Mono.Android XML documentation warnings and a generator crash caused by optional copyright metadata after documentation notices were moved.
Changes:
- Corrects handwritten XML documentation and keeps the marshal template and generated source aligned.
- Removes suppression of
CS1574,CS1584, andCS1658. - Handles missing copyright metadata without losing documentation links.
| File | Description |
|---|---|
src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs |
Corrects two documentation references. |
src/Mono.Android/Mono.Android.csproj |
Narrows Javadoc warning suppression. |
src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs |
Converts local-function documentation to a regular comment. |
src/Mono.Android/Microsoft.Android.Runtime/ITypeMap.cs |
Qualifies the proxy attribute documentation reference. |
src/Mono.Android/Java.Interop/ValueTypeFactory.cs |
Documents two missing parameters. |
src/Mono.Android/Java.Interop/JniMarshalTyped.tt |
Fixes the template’s method reference syntax. |
src/Mono.Android/Java.Interop/JniMarshalTyped.cs |
Mirrors the template documentation fix. |
src/generator/Java.Interop.Tools.Generator.ObjectModel/JavadocInfo.cs |
Guards absent copyright metadata. |
Review effort: Balanced
|
Reviewed the diff and checked each fix against the sources it touches:
Copilot also reviewed this one and recommended approval with no open issues; my checks above agree. Nothing further to flag. |
This branch has not been deployed
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.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
11ed658137c375ecf963418283ab0f00432b2d1aJavadocInfoNRE are fixed and verified across API 37 and API 37.2IncludeAndroidJavadoc=Truebuilds, ReleaseGenerateDocumentationFile=true,CheckApiCompatibility, and 524/524 generator unit tests.↓ CI and API 37.1 Javadoc builds have not yet run.
IncludeAndroidJavadoc=Truebuilds directly reproduced theJavadocInfo.GetExtraNullReferenceException(missing<copyright>element afteraab67910e6) and all 8 handwritten compiler diagnostics.Mono.Android.xmlverifies resolvedcreftargets and confirmsCS1574,CS1584, andCS1658drop to zero occurrences across API 37 and API 37.2.Context: #12220 (
aab67910e6), #5651When
$(IncludeAndroidJavadoc)isTrue,src/Mono.Android/Mono.Android.csprojsuppressesCS1572;CS1573;CS1574;CS1584;CS1587;CS1591;CS1658to accommodate imported Android Javadoc comments. That blanket suppression masked eight real XML documentation bugs in handwrittenMono.Androidsources, and three of those warning codes (CS1574,CS1584,CS1658) are no longer emitted by generated bindings at all.Additionally, building
Mono.Android.csprojwith-p:IncludeAndroidJavadoc=Truefailed in the_GenerateBindingtarget with:Guard missing
<copyright>inJavadocInfo.GetExtraCommit
aab67910e6stopped passing--doc-copyrighttojava-source-utils, soandroid-javadoc.xmlno longer contains a<javadoc-metadata>/<copyright>element.JavadocInfo.GetExtrastill unconditionally dereferencedjavadocMetadata.Element ("copyright").Elements ().Guard the
<copyright>lookup and only append copyright elements when present, matchingBoundProperty.AddJavadocs, which already handles anullCopyright.Handwritten XML documentation fixes and narrowed
$(NoWarn)Unmasking XML documentation warnings under
-p:IncludeAndroidJavadoc=Truesurfaced eight non-CS1591warnings in handwrittensrc/Mono.Android/sources:ValueTypeFactory.cs(CS1573x2): document thehandleandtransferparameters onCreateReferenceMixedDictionary.ITypeMap.cs(CS1574): qualifyJava.Interop.JavaPeerProxyin<see cref>so it resolves fromMicrosoft.Android.Runtime.AndroidMessageHandler.cs(CS1574x2): update<see cref>targets toAndroidHttpResponseMessage.Dispose(bool)andTrustedCerts(fixing aTrustCertstypo).JniMarshalTyped.ttand generatedJniMarshalTyped.cs(CS1584,CS1658): replace unsupported function-pointer parameter syntax in<see cref>withJniMarshal.SafeInvokeAction.TrimmableTypeMapTypeManager.cs(CS1587): convert the XML doc comment on local functionTryGetBuiltInReferenceJniNameto a regular comment.With those fixed, generated binding Javadoc across API 37 and API 37.2 emits zero
CS1574,CS1584, orCS1658warnings (while still emittingCS1572,CS1573,CS1587, andCS1591, plus one unsuppressedCS1571inAndroid.Webkit.PluginDatafrom AOSP's duplicate@param length). RemoveCS1574,CS1584, andCS1658from$(NoWarn)in the$(IncludeAndroidJavadoc) == 'True'property group ofMono.Android.csprojso future handwrittencrefand syntax errors are caught.Validation
bin/Debug/dotnet/dotnet build src/Mono.Android/Mono.Android.csproj -c Debug -p:IncludeAndroidJavadoc=True --no-dependencies -p:TreatWarningsAsErrors=false -p:WarningsAsErrors=(API 37): passed; 0 handwritten warnings, only 1 generatedCS1571(Android.Webkit.PluginData.cs),CheckApiCompatibilityreported 0 issues.bin/Debug/dotnet/dotnet build src/Mono.Android/Mono.Android.csproj -c Debug --no-dependencies -p:AndroidApiLevel=37.2 -p:AndroidPlatformId=37.2 -p:AndroidFrameworkVersion=v17.2 -p:IsUnstableVersion=false -p:IncludeAndroidJavadoc=True -p:_AndroidJavadocXml=../../bin/BuildDebug/android-javadoc-37.2.xml -p:TreatWarningsAsErrors=false -p:WarningsAsErrors=: passed; 0 handwritten warnings, only 1 generatedCS1571.bin/Debug/dotnet/dotnet build src/Mono.Android/Mono.Android.csproj -c Debug --no-dependencies: passed with 0 warnings and 0 errors.bin/Debug/dotnet/dotnet build src/Mono.Android/Mono.Android.csproj -c Release -p:DotNetPreviewTool="$PWD/bin/Debug/dotnet/dotnet" -p:GenerateDocumentationFile=true -p:NoWarn=CS1591: passed with 0Mono.Androidwarnings (TreatWarningsAsErrors=true) and 0CheckApiCompatibilityissues.bin/Debug/dotnet/dotnet build src/Mono.Android/Mono.Android.csproj -c Release --no-dependencies -p:DotNetPreviewTool="$PWD/bin/Debug/dotnet/dotnet": passed with 0 warnings and 0 errors.bin/Debug/dotnet/dotnet test tests/generator-Tests/generator-Tests.csproj -c Debug: 506/506 passed.bin/Debug/dotnet/dotnet test tests/Java.Interop.Tools.Generator-Tests/Java.Interop.Tools.Generator-Tests.csproj -c Debug: 18/18 passed.