Problem
CheckForObsoletePreserveAttributeStep.cs line 27 passes a hardcoded string literal to LogCodedWarning instead of using a resource string from Properties.Resources. This means the customer-facing warning message is not localizable, which is inconsistent with the rest of the codebase where all coded warnings use resource strings.
Location
- File(s):
src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/CheckForObsoletePreserveAttributeStep.cs
- Line(s): 27
Current Code
log.LogCodedWarning ("IL6001", $"Assembly '{assembly.Name.Name}' contains reference to obsolete attribute 'Android.Runtime.PreserveAttribute'. Members with this attribute may be trimmed. Please use System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute instead");
Suggested Fix
1. Add a using alias at the top of CheckForObsoletePreserveAttributeStep.cs (matching the pattern used by other files in the same Linker/MonoDroid.Tuner/ directory, e.g. FixAbstractMethodsStep.cs and FixLegacyResourceDesignerStep.cs):
using Resources = Xamarin.Android.Tasks.Properties.Resources;
2. Replace line 27 with:
log.LogCodedWarning ("IL6001", Resources.IL6001, assembly.Name.Name);
3. Add resource entry to the English src/Xamarin.Android.Build.Tasks/Properties/Resources.resx (alphabetically among existing entries):
<data name="IL6001" xml:space="preserve">
<value>Assembly '{0}' contains reference to obsolete attribute 'Android.Runtime.PreserveAttribute'. Members with this attribute may be trimmed. Please use System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute instead</value>
</data>
4. Add the corresponding property to src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs:
/// <summary>
/// Looks up a localized string similar to Assembly '{0}' contains reference to obsolete attribute 'Android.Runtime.PreserveAttribute'. Members with this attribute may be trimmed. Please use System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute instead.
/// </summary>
public static string IL6001 {
get {
return ResourceManager.GetString("IL6001", resourceCulture);
}
}
Guidelines
- Only modify the English
Resources.resx — never modify non-English *.resx or *.lcl files
- Follow Mono formatting style (tabs, space before
()
- The owning project (
Xamarin.Android.Build.Tasks.csproj) targets netstandard2.0 — the suggested fix only uses Properties.Resources and LogCodedWarning, both available on netstandard2.0
- Keep the warning code as
IL6001 (do not change it to an XA code — this is a trimmer-pipeline step and the code is verified by an existing test)
- The using alias pattern (
using Resources = Xamarin.Android.Tasks.Properties.Resources;) is the established convention in the Linker/MonoDroid.Tuner/ directory
Acceptance Criteria
Fix-finder metadata
- Script:
08-string-literal-error-messages
- Score:
26/30 (actionability: 10, safety: 8, scope: 8)
Generated by Nightly Fix Finder · ● 24.9M · ◷
Problem
CheckForObsoletePreserveAttributeStep.csline 27 passes a hardcoded string literal toLogCodedWarninginstead of using a resource string fromProperties.Resources. This means the customer-facing warning message is not localizable, which is inconsistent with the rest of the codebase where all coded warnings use resource strings.Location
src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/CheckForObsoletePreserveAttributeStep.csCurrent Code
Suggested Fix
1. Add a using alias at the top of
CheckForObsoletePreserveAttributeStep.cs(matching the pattern used by other files in the sameLinker/MonoDroid.Tuner/directory, e.g.FixAbstractMethodsStep.csandFixLegacyResourceDesignerStep.cs):2. Replace line 27 with:
3. Add resource entry to the English
src/Xamarin.Android.Build.Tasks/Properties/Resources.resx(alphabetically among existing entries):4. Add the corresponding property to
src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs:Guidelines
Resources.resx— never modify non-English*.resxor*.lclfiles()Xamarin.Android.Build.Tasks.csproj) targetsnetstandard2.0— the suggested fix only usesProperties.ResourcesandLogCodedWarning, both available onnetstandard2.0IL6001(do not change it to an XA code — this is a trimmer-pipeline step and the code is verified by an existing test)using Resources = Xamarin.Android.Tasks.Properties.Resources;) is the established convention in theLinker/MonoDroid.Tuner/directoryAcceptance Criteria
Resources.IL6001)using Resources = Xamarin.Android.Tasks.Properties.Resources;alias is added to the fileIL6001is added to the EnglishResources.resxResources.Designer.csis updated with theIL6001propertyLinkerTests.cs(which checks for"warning IL6001"and"obsolete attribute 'Android.Runtime.PreserveAttribute'") still passes — the message text must not changeFix-finder metadata
08-string-literal-error-messages26/30(actionability:10, safety:8, scope:8)