- Notifications
You must be signed in to change notification settings - Fork564
Fix NRT annotations in Xamarin.Android.Build.Tasks to follow repository guidelines#10327
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
src\Xamarin.Android.Build.Tasks\
jonathanpeppers left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Can you look at the files insrc/Xamarin.Android.Build.Tasks/Utilities, we are more interested in you fixing the files inside than these changes.
I'll fix the Array.Empty() and string.Empty patterns in the Utilities directory as well. Found 9 Array.Empty() instances and 1 string.Empty assignment that need to be updated to follow the repository guidelines. |
…ectoryCo-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
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.
No, look for#nullable disable directives insrc/Xamarin.Android.Build.Tasks/Utilities and fix them.
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Fixed all 34
This addresses all the files with |
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingDebugNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingDebugNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGeneratorCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGeneratorCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGeneratorCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGeneratorCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGeneratorCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGeneratorCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGeneratorCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGeneratorCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingDebugNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingDebugNativeAssemblyGenerator.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…ion messagesCo-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
jonathanpeppers commentedJul 23, 2025
/azp run |
| Azure Pipelines successfully started running 1 pipeline(s). |
jonathanpeppers commentedJul 24, 2025
Fix the build errors/warnings. If it is too hard to fix them all, revert the changes in the file and we can address in a future PR: |
…ld errorsCo-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Fixed the build errors by reverting all changes in the Utilities directory back to their original state with |
jonathanpeppers commentedJul 24, 2025
Can you try fixing Try fixing one or two at least that would be easy. |
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Successfully converted |
This simple buffer manager class only requires enabling nullable reference types without complex nullable annotation changes, as it primarily manages dictionary operations with straightforward null handling patterns.Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
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.
Fix these:
(CoreCompile target) -> /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(184,32): error CS8604: Possible null reference argument for parameter 'resourceClass' in 'void GenerateResourceDesignerAssembly.CreateIntField(TypeDefinitionCache cache, string resourceClass, string fieldName, int value, TypeDefinition resourceDesigner, ModuleDefinition module, FieldAttributes attributes = FieldAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(184,52): error CS8604: Possible null reference argument for parameter 'fieldName' in 'void GenerateResourceDesignerAssembly.CreateIntField(TypeDefinitionCache cache, string resourceClass, string fieldName, int value, TypeDefinition resourceDesigner, ModuleDefinition module, FieldAttributes attributes = FieldAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(185,34): error CS8604: Possible null reference argument for parameter 'resourceClass' in 'void GenerateResourceDesignerAssembly.CreateIntProperty(TypeDefinitionCache cache, string resourceClass, string propertyName, int value, TypeDefinition resourceDesigner, ModuleDefinition module, MethodAttributes attributes = MethodAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(185,54): error CS8604: Possible null reference argument for parameter 'propertyName' in 'void GenerateResourceDesignerAssembly.CreateIntProperty(TypeDefinitionCache cache, string resourceClass, string propertyName, int value, TypeDefinition resourceDesigner, ModuleDefinition module, MethodAttributes attributes = MethodAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(189,37): error CS8604: Possible null reference argument for parameter 'resourceClass' in 'void GenerateResourceDesignerAssembly.CreateIntArrayField(TypeDefinitionCache cache, string resourceClass, string fieldName, int[] values, TypeDefinition resourceDesigner, ModuleDefinition module, FieldAttributes attributes = FieldAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(189,57): error CS8604: Possible null reference argument for parameter 'fieldName' in 'void GenerateResourceDesignerAssembly.CreateIntArrayField(TypeDefinitionCache cache, string resourceClass, string fieldName, int[] values, TypeDefinition resourceDesigner, ModuleDefinition module, FieldAttributes attributes = FieldAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(189,71): error CS8604: Possible null reference argument for parameter 'values' in 'void GenerateResourceDesignerAssembly.CreateIntArrayField(TypeDefinitionCache cache, string resourceClass, string fieldName, int[] values, TypeDefinition resourceDesigner, ModuleDefinition module, FieldAttributes attributes = FieldAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(190,39): error CS8604: Possible null reference argument for parameter 'resourceClass' in 'void GenerateResourceDesignerAssembly.CreateIntArrayProperty(TypeDefinitionCache cache, string resourceClass, string propertyName, int[] values, TypeDefinition resourceDesigner, ModuleDefinition module, MethodAttributes attributes = MethodAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(190,59): error CS8604: Possible null reference argument for parameter 'propertyName' in 'void GenerateResourceDesignerAssembly.CreateIntArrayProperty(TypeDefinitionCache cache, string resourceClass, string propertyName, int[] values, TypeDefinition resourceDesigner, ModuleDefinition module, MethodAttributes attributes = MethodAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesignerAssembly.cs(190,73): error CS8604: Possible null reference argument for parameter 'values' in 'void GenerateResourceDesignerAssembly.CreateIntArrayProperty(TypeDefinitionCache cache, string resourceClass, string propertyName, int[] values, TypeDefinition resourceDesigner, ModuleDefinition module, MethodAttributes attributes = MethodAttributes.Public, TypeAttributes typeAttributes = TypeAttributes.NestedPublic)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/DummyCustomAttributeProvider.cs(20,66): error CS8603: Possible null reference return. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/DummyCustomAttributeProvider.cs(22,37): error CS8603: Possible null reference return. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/DummyCustomAttributeProvider.cs(24,56): error CS8603: Possible null reference return. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/DummyCustomAttributeProvider.cs(26,113): error CS8603: Possible null reference return. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/DummyCustomAttributeProvider.cs(28,111): error CS8603: Possible null reference return. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/DummyCustomAttributeProvider.cs(30,60): error CS8603: Possible null reference return. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrBufferManager.cs(23,10): error CS8618: Non-nullable field 'bufferVariableNames' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrBufferManager.cs(62,42): error CS8604: Possible null reference argument for parameter 'key' in 'bool Dictionary<object, Dictionary<string, string>>.TryGetValue(object key, out Dictionary<string, string> value)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrBufferManager.cs(86,42): error CS8604: Possible null reference argument for parameter 'key' in 'bool Dictionary<object, Dictionary<string, string>>.TryGetValue(object key, out Dictionary<string, string> value)'. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/ManagedMarshalMethodsLookupInfo.cs(96,27): error CS8618: Non-nullable property 'NativeCallbackWrapper' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/ManagedMarshalMethodsLookupInfo.cs(88,25): error CS8618: Non-nullable property 'DeclaringType' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/ManagedMarshalMethodsLookupInfo.cs(80,29): error CS8618: Non-nullable property 'Assembly' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MetadataExtensions.cs(32,14): error CS8603: Possible null reference return. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MetadataExtensions.cs(37,13): error CS8603: Possible null reference return. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MetadataExtensions.cs(44,11): error CS8603: Possible null reference return. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj] /Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Utilities/MetadataExtensions.cs(73,52): error CS8602: Dereference of a possibly null reference. [/Users/builder/azdo/_work/2/s/android/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj]Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
... Fixed the nullable reference warnings in GenerateResourceDesignerAssembly.cs by adding proper null checks for r.ResourceTypeName, r.Identifier, and r.Ids before calling methods that expect non-nullable parameters. All CS8604 errors mentioned in the build output are now resolved. Commit:4559ed9 |
jonathanpeppers commentedJul 24, 2025
Can you fix these now: |
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
... Fixed all nullable reference type build errors in the Utilities directory files:
The project now builds successfully with no nullable reference type errors. Commit:07fd878 |
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.
The MAUI integration lane looks like it failed because MAUI has build failures on net10.0 branch.
209d846 intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Context:#10326
This PR systematically updates Nullable Reference Types (NRT) annotations across the
src/Xamarin.Android.Build.Tasks/Tasks/directory to follow the repository's coding guidelines as defined in.github/copilot-instructions.md.Changes Made
This pull request primarily focuses on code modernization and cleanup for the
Xamarin.Android.Build.Tasksproject. The changes include replacingArray.Empty<T>()with[]for initializing arrays and switching fromstring.Emptyto""for string initialization. Additionally, nullable annotations have been enabled in a utility file to improve code safety. These updates aim to simplify the codebase and align it with modern C# conventions.Code Modernization
Replaced
Array.Empty<T>()with[]for array initialization across multiple files. This change simplifies array initialization syntax. Examples includeRuntimePackLibraryDirectories,ReferenceSatellitePaths, andInputAssemblies.[1][2][3][4][5]Updated string initialization from
string.Emptyto""for consistency and brevity. Examples includeCodeGenerationTarget,OutputDirectory, andNuGetPackageId.[1][2][3][4][5]Nullable Annotations
DummyCustomAttributeProvider.csto improve code safety and nullability handling.Logical Enhancements
GenerateResourceDesignerAssembly.csto skip processing resources with null identifiers or type names, ensuring robustness in resource handling.[1][2]💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.