You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Xamarin.Android.Build.Tasks] fix NRE in XAJavaTypeScanner (#9087)
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=9842772&view=logs&j=9a1c0345-5071-55ee-c0f3-a2911782c698&t=1e33272b-48f7-5132-3788-3179300312b4
We saw a `NullReferenceException` in `XAJavaTypeScanner` in the build
linked above:
Microsoft.Android.Sdk.Darwin/34.0.95/tools/Xamarin.Android.Common.targets(1536,3): error XAGJS7001: System.NullReferenceException: Object reference not set to an instance of an object.
Microsoft.Android.Sdk.Darwin/34.0.95/tools/Xamarin.Android.Common.targets(1536,3): error XAGJS7001: at Xamarin.Android.Tasks.XAJavaTypeScanner.GetJavaTypes(ICollection`1 inputAssemblies, XAAssemblyResolver resolver)
Microsoft.Android.Sdk.Darwin/34.0.95/tools/Xamarin.Android.Common.targets(1536,3): error XAGJS7001: at Xamarin.Android.Tasks.GenerateJavaStubs.Run(XAAssemblyResolver res, Boolean useMarshalMethods)
Microsoft.Android.Sdk.Darwin/34.0.95/tools/Xamarin.Android.Common.targets(1536,3): error XAGJS7001: at Xamarin.Android.Tasks.GenerateJavaStubs.RunTask()
Microsoft.Android.Sdk.Darwin/34.0.95/tools/Xamarin.Android.Common.targets(1536,3): error XAGJS7001: at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25
I added `#nullable enable` to `XAJavaTypeScanner.cs`, and fixed the
one warning that existed around `resolver.Load()`. Now, when
`resolver.Load()` returns `null`, we'll log the Debug message:
[{targetArch}] Unable to load assembly '…'
Copy file name to clipboardExpand all lines: src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
#nullable enable
1
2
usingSystem;
2
3
usingSystem.Collections.Generic;
3
4
usingSystem.IO;
@@ -48,7 +49,11 @@ public List<TypeDefinition> GetJavaTypes (ICollection<ITaskItem> inputAssemblies
48
49
thrownewInvalidOperationException($"Internal error: assembly '{asmItem.ItemSpec}' should be in the '{targetArch}' architecture, but is in '{arch}' instead.");
0 commit comments