Problem
JdkPackage.cs is shipped product code in the Xamarin.Installer.AndroidSDK project (part of Xamarin.Android.sln). That project does not enable nullable reference types at the project level — its .csproj has no <Nullable> property — so this file is not opted into NRT. It is a clean, immutable data model in which every reference-type property is assigned in the constructor, making it an ideal, low-risk first candidate for opting into nullable reference types.
Location
- File(s):
src/Xamarin.Installer.AndroidSDK/Xamarin.Installer.AndroidSDK/Common/JdkPackage.cs
- Line(s): top of file (new line 1)
Current Code
using System;
using System.Collections.Generic;
using System.Linq;
namespace Xamarin.Installer.AndroidSDK.Common
{
public class JdkPackage : IJdkComponent
{
public JdkPackage(string displayName, bool obsolete, bool preview, string licenseId, PackageVendor vendor, AndroidRevision revision, List<JdkArchive> archives)
{
DisplayName = displayName;
Obsolete = obsolete;
Preview = preview;
Vendor = vendor;
Revision = revision;
Archives = archives;
LicenseID = licenseId;
}
public Guid UniqueID { get; } = Guid.NewGuid();
public string DisplayName { get; }
// ... bool/string/PackageVendor/AndroidRevision/IList<JdkArchive> members, all get-only ...
}
}
Suggested Fix
Add #nullable enable as the very first line of the file (no preceding blank lines):
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
Then build the Xamarin.Installer.AndroidSDK project. Because the constructor initializes every reference-type property (DisplayName, LicenseID, Vendor, Revision, Archives) and there are no uninitialized non-nullable fields or null-returning members, the file is expected to compile with no new nullable warnings and no further code changes. All constructor parameters and properties are required by design and should remain non-nullable.
Guidelines
- Add
#nullable enable at the very top, with no preceding blank lines (preserve the file's existing UTF-8 BOM/encoding).
- Never use the
! (null-forgiving) operator — refactor or check for null explicitly.
- The owning project (
Xamarin.Installer.AndroidSDK.csproj) targets netstandard2.0. If any null-validation is ever needed, use the netstandard2.0-compatible form if (x == null) throw new ArgumentNullException (nameof (x)); — do not use ArgumentNullException.ThrowIfNull (x), which does not exist before .NET 6 and will not compile here.
- Keep all currently-required constructor parameters and properties non-nullable; only mark a member nullable (
string?) if it is genuinely optional.
- Follow the repo's documented nullable reference type conventions.
Acceptance Criteria
Fix-finder metadata
- Script:
01-nullable-reference-types
- Score:
27/30 (actionability: 9, safety: 8, scope: 10)
Generated by Nightly Fix Finder for issue #11685 · 934.9 AIC · ⌖ 49.9 AIC · ⊞ 40.7K · ◷
Problem
JdkPackage.csis shipped product code in theXamarin.Installer.AndroidSDKproject (part ofXamarin.Android.sln). That project does not enable nullable reference types at the project level — its.csprojhas no<Nullable>property — so this file is not opted into NRT. It is a clean, immutable data model in which every reference-type property is assigned in the constructor, making it an ideal, low-risk first candidate for opting into nullable reference types.Location
src/Xamarin.Installer.AndroidSDK/Xamarin.Installer.AndroidSDK/Common/JdkPackage.csCurrent Code
Suggested Fix
Add
#nullable enableas the very first line of the file (no preceding blank lines):Then build the
Xamarin.Installer.AndroidSDKproject. Because the constructor initializes every reference-type property (DisplayName,LicenseID,Vendor,Revision,Archives) and there are no uninitialized non-nullable fields or null-returning members, the file is expected to compile with no new nullable warnings and no further code changes. All constructor parameters and properties are required by design and should remain non-nullable.Guidelines
#nullable enableat the very top, with no preceding blank lines (preserve the file's existing UTF-8 BOM/encoding).!(null-forgiving) operator — refactor or check fornullexplicitly.Xamarin.Installer.AndroidSDK.csproj) targetsnetstandard2.0. If any null-validation is ever needed, use the netstandard2.0-compatible formif (x == null) throw new ArgumentNullException (nameof (x));— do not useArgumentNullException.ThrowIfNull (x), which does not exist before .NET 6 and will not compile here.string?) if it is genuinely optional.Acceptance Criteria
#nullable enableis added as the first line ofJdkPackage.cs.!null-forgiving operator is introduced.Xamarin.Installer.AndroidSDKproject builds with no new warnings.Fix-finder metadata
01-nullable-reference-types27/30(actionability: 9, safety: 8, scope: 10)