Repository navigation
[Mono.Android] Treat obsolete attributes as errors - #13124
Closed
simonrozsival wants to merge 3 commits into
Closed
simonrozsival wants to merge 3 commits into
simonrozsival wants to merge 3 commits into
Conversation
This release follow-up marks Android.Runtime.PreserveAttribute, Android.LinkerSafeAttribute, and Java.Interop.DoNotPackageAttribute as compiler errors before their planned removal. Keep the existing messages, migrate the linker test to DynamicDependencyAttribute, and record the expected API compatibility differences. Follow up to #13109. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Existing build tests still compile PreserveAttribute and DoNotPackageAttribute usages and will now fail with CS0619.
2 open findings
What changed in this PR
Makes three obsolete Mono.Android attributes produce compiler errors and updates linker/API compatibility metadata.
Changes:
- Marks obsolete attributes with
error: true. - Replaces linker test preservation with
DynamicDependency. - Records API compatibility differences.
| File | Description |
|---|---|
Android.Runtime/PreserveAttribute.cs |
Makes usage a compiler error. |
Android/LinkerSafeAttribute.cs |
Makes usage a compiler error. |
Java.Interop/DoNotPackageAttribute.cs |
Makes usage a compiler error. |
System.Linq/LinqExpressionTest.cs |
Replaces Preserve with DynamicDependency. |
acceptable-breakages-vReference-net11.0.txt |
Records obsolete metadata changes. |
🧠 Review effort: Balanced
| namespace Android.Runtime { | ||
|
|
||
| [Obsolete ("Please use [System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute]")] | ||
| [Obsolete ("Please use [System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute]", error: true)] |
| AllowMultiple=true, | ||
| Inherited=false)] | ||
| [Obsolete ("This attribute is deprecated and will be removed in a future release. Use the @(AndroidExternalJavaLibrary) MSBuild item group instead.")] | ||
| [Obsolete ("This attribute is deprecated and will be removed in a future release. Use the @(AndroidExternalJavaLibrary) MSBuild item group instead.", error: true)] |
Move the DynamicDependencyAttribute onto a ModuleInitializer method so the dependency is rooted independently of the target test method. This keeps LinqExpressionTest and its members available for linker-based discovery, without referencing PreserveAttribute after it becomes an error. Co-authored-by: Copilot App <[email protected]>
Remove the preservation hint from LinqExpressionTest after verifying that Release linking still discovers and runs it. The complete on-device runtime suite passes without PreserveAttribute or DynamicDependencyAttribute. Co-authored-by: Copilot App <[email protected]>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include:This separate release-branch follow-up responds to Jonathan Peppers' review
request in #13109. It makes
Android.Runtime.PreserveAttribute,Android.LinkerSafeAttribute, andJava.Interop.DoNotPackageAttributecompiler errors without changing theirexisting obsolete messages. The linker test now uses
DynamicDependencyAttribute, and the expected metadata differences arerecorded in the API compatibility baseline.
Validation
dotnet build src/Mono.Android/Mono.Android.csproj --no-restore -p:JavaCPath=/Users/simon/Library/Java/JavaVirtualMachines/jdk-23.0.2+7/Contents/Home/bin/javac -p:JarPath=/Users/simon/Library/Java/JavaVirtualMachines/jdk-23.0.2+7/Contents/Home/bin/jar -v:minimal— passed (28 warnings, 0 errors).dotnet build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj --no-restore -p:JavaCPath=/Users/simon/Library/Java/JavaVirtualMachines/jdk-23.0.2+7/Contents/Home/bin/javac -p:JarPath=/Users/simon/Library/Java/JavaVirtualMachines/jdk-23.0.2+7/Contents/Home/bin/jar -v:quiet— passed (95 warnings, 0 errors). This builds the test assembly; tests were not executed.