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
[xabt] Fix NRT annotations in Xamarin.Android.Build.Tasks, part 3 (#10362)
Context: #10326
Removes all null-forgiving operators (`!`) from
`MarshalMethodsAssemblyRewriter.cs` and replaces them with proper null
checks and `ArgumentNullException` throws, following the repository's
nullable reference types guidelines.
The changes ensure that instead of suppressing null warnings with `!`,
the code explicitly checks for null values and throws appropriate
exceptions. Variable declarations have been updated to use nullable
types that match the return types of `FindType` and `FindMethod`
methods:
```csharp
// Before:
TypeDefinition runtime = FindType(monoAndroidRuntime, "Android.Runtime.AndroidRuntimeInternal", required: true)!;
// After:
TypeDefinition? runtime = FindType(monoAndroidRuntime, "Android.Runtime.AndroidRuntimeInternal", required: true);
if (runtime == null)
throw new ArgumentNullException(nameof(runtime));
```
Also improves the `.github/copilot-instructions.md` to be clearer
about avoiding null-forgiving operators when implementing nullable
reference types.
Co-authored-by: Jonathan Peppers <[email protected]>
@@ -118,6 +134,8 @@ public void Rewrite (bool brokenExceptionTransitions)
118
134
// TODO the code should probably go to different assemblies than Mono.Android (to avoid recursive dependencies)
119
135
varrootAssembly=resolver.Resolve("Mono.Android")??thrownewInvalidOperationException($"[{targetArch}] Internal error: unable to load the Mono.Android assembly");
0 commit comments