Problem
In CreateDynamicFeatureManifest.GenerateFeatureManifest, the targetSdkVersion attribute is added inside an if that checks MinSdkVersion instead of TargetSdkVersion. This is a copy-paste error with two consequences:
- If
MinSdkVersion is set but TargetSdkVersion is null/empty, new XAttribute (androidNS + "targetSdkVersion", TargetSdkVersion) is called with a null value and throws ArgumentNullException.
- If
MinSdkVersion is empty but TargetSdkVersion is set, the targetSdkVersion attribute is never emitted.
Location
- File(s):
src/Xamarin.Android.Build.Tasks/Tasks/CreateDynamicFeatureManifest.cs
- Line(s): 65-68
Current Code
if (!MinSdkVersion.IsNullOrEmpty ())
usesSdk.Add (new XAttribute (androidNS + "minSdkVersion", MinSdkVersion));
if (!MinSdkVersion.IsNullOrEmpty ())
usesSdk.Add (new XAttribute (androidNS + "targetSdkVersion", TargetSdkVersion));
Suggested Fix
Gate the targetSdkVersion attribute on TargetSdkVersion (matching the minSdkVersion line above it):
if (!MinSdkVersion.IsNullOrEmpty ())
usesSdk.Add (new XAttribute (androidNS + "minSdkVersion", MinSdkVersion));
if (!TargetSdkVersion.IsNullOrEmpty ())
usesSdk.Add (new XAttribute (androidNS + "targetSdkVersion", TargetSdkVersion));
Guidelines
- Project targets
netstandard2.0; the existing IsNullOrEmpty () extension method is already used here, so no new APIs are introduced.
- Follow dotnet/android formatting (tabs, space before
().
Acceptance Criteria
Fix-finder metadata
- Script:
05-general-mistakes
- Score:
26/30 (actionability: 10, safety: 6, scope: 10)
Generated by Nightly Fix Finder · 59.9 AIC · ⌖ 17.3 AIC · ⊞ 9.4K · ◷
Problem
In
CreateDynamicFeatureManifest.GenerateFeatureManifest, thetargetSdkVersionattribute is added inside anifthat checksMinSdkVersioninstead ofTargetSdkVersion. This is a copy-paste error with two consequences:MinSdkVersionis set butTargetSdkVersionisnull/empty,new XAttribute (androidNS + "targetSdkVersion", TargetSdkVersion)is called with a null value and throwsArgumentNullException.MinSdkVersionis empty butTargetSdkVersionis set, thetargetSdkVersionattribute is never emitted.Location
src/Xamarin.Android.Build.Tasks/Tasks/CreateDynamicFeatureManifest.csCurrent Code
Suggested Fix
Gate the
targetSdkVersionattribute onTargetSdkVersion(matching theminSdkVersionline above it):Guidelines
netstandard2.0; the existingIsNullOrEmpty ()extension method is already used here, so no new APIs are introduced.().Acceptance Criteria
targetSdkVersionattribute is emitted only whenTargetSdkVersionis non-emptyMinSdkVersionis set andTargetSdkVersionis null/emptyFix-finder metadata
05-general-mistakes26/30(actionability: 10, safety: 6, scope: 10)