-
Notifications
You must be signed in to change notification settings - Fork 564
Fix null-forgiving operator usage in MarshalMethodsAssemblyRewriter #10362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: jonathanpeppers <[email protected]>
jonathanpeppers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot continue your work/checklist.
Co-authored-by: jonathanpeppers <[email protected]>
Co-authored-by: jonathanpeppers <[email protected]>
I'm continuing the work on fixing NRT annotations in the Utilities folder. I've successfully converted 2 files so far:
Some files have complex interdependencies that require converting multiple files together. I'm working through them systematically, starting with the simpler standalone files first. Progress is in commit d9bcb70. |
Co-authored-by: jonathanpeppers <[email protected]>
Co-authored-by: jonathanpeppers <[email protected]>
src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: jonathanpeppers <[email protected]>
src\Xamarin.Android.Build.Tasks\
jonathanpeppers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot fix the errors:
(CoreCompile target) ->
/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs(50,29): error CS8600: Converting null literal or possible null value to non-nullable type. [/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]
/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs(53,53): error CS8600: Converting null literal or possible null value to non-nullable type. [/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]
/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs(57,40): error CS8600: Converting null literal or possible null value to non-nullable type. [/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]
/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs(60,48): error CS8600: Converting null literal or possible null value to non-nullable type. [/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]
/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs(64,42): error CS8600: Converting null literal or possible null value to non-nullable type. [/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]
/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs(67,52): error CS8600: Converting null literal or possible null value to non-nullable type. [/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]
/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsAssemblyRewriter.cs(74,37): error CS8600: Converting null literal or possible null value to non-nullable type. [/Users/builder/azdo/_work/7/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]
Co-authored-by: jonathanpeppers <[email protected]>
Head branch was pushed to by a user without write access
... Fixed the CS8600 compilation errors by making all variables that receive return values from FindType and FindMethod nullable to match their return types. The variables are now properly declared as nullable (TypeDefinition?, MethodDefinition?) and include appropriate null checks with ArgumentNullException throws. Build completed successfully with no errors in commit 500fd3c. |
Removes all null-forgiving operators (
!) fromMarshalMethodsAssemblyRewriter.csand replaces them with proper null checks andArgumentNullExceptionthrows, 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 ofFindTypeandFindMethodmethods:Also improves the
.github/copilot-instructions.mdto be clearer about avoiding null-forgiving operators when implementing nullable reference types.Context #10326.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.