Skip to content

Conversation

jtschuster
Copy link
Member

@jtschuster jtschuster commented Aug 27, 2025

PreserveAttribute has been obsolete for some time, so the functionality of the trimmer step which marks the types based on the can be removed. Instead, we can warn if we see any references to the type within an assembly.

Context: dotnet/runtime#107211

@jonathanpeppers
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

<_TrimmerCustomSteps
Include="$(_AndroidLinkerCustomStepAssembly)"
BeforeStep="MarkStep"
Type="Microsoft.Android.Sdk.ILLink.WarnOnPreserveAttribute" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, maybe you forgot to commit 1 file.

If this is for .NET 11, I think we could also put error:true here:

[Obsolete ("Please use [System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute]")]

It has been marked [Obsolete] a long time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, forgot to re-add the file after renaming it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like adding the error=true causes and API compat issue and we'll need to add [Obsolete] to the definition in Java.Interop?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the one in java-interop is just for tests:

Or did you find it when viewing the assembly in ILSpy?

@jtschuster jtschuster force-pushed the RemovePreserveAttributeStep branch from c3fa811 to 1056379 Compare August 27, 2025 18:48
@jtschuster
Copy link
Member Author

/azp run

Copy link

Commenter does not have sufficient privileges for PR 10449 in repo dotnet/android

@jonathanpeppers
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jtschuster jtschuster marked this pull request as ready for review August 27, 2025 20:50
@jtschuster jtschuster requested a review from grendello as a code owner August 27, 2025 20:50
@jonathanpeppers
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jonathanpeppers
Copy link
Member

We can look how to fix this later:

       (_CheckApiCompatibility target) -> 
         /Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.targets(216,5): error : CompatApi command: dotnet "/Users/builder/.nuget/packages/microsoft.dotnet.apicompat/7.0.0-beta.22103.1/tools/net472/../netcoreapp3.1/Microsoft.DotNet.ApiCompat.dll" "/Users/builder/azdo/_work/3/s/android/tests/api-compatibility/reference/net10.0/Mono.Android.dll" -i "/Users/builder/azdo/_work/3/s/android/bin/Release/lib/xamarin.android/xbuild-frameworks/Microsoft.Android/36" --allow-default-interface-methods --baseline "/Users/builder/azdo/_work/3/s/android/tests/api-compatibility/acceptable-breakages-vReference-net10.0.txt" --validate-baseline --exclude-attributes "/Users/builder/azdo/_work/3/s/android/tests/api-compatibility/api-compat-exclude-attributes.txt"  [/Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.csproj::TargetFramework=net10.0]
       /Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.targets(216,5): error : CheckApiCompatibility found nonacceptable Api breakages for ApiLevel: v16.0. [/Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.csproj::TargetFramework=net10.0]
       /Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.targets(216,5): error : Compat issues with assembly Mono.Android: [/Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.csproj::TargetFramework=net10.0]
       /Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.targets(216,5): error : CannotRemoveAttribute : Attribute 'System.ObsoleteAttribute' exists on 'Android.Runtime.PreserveAttribute' in the contract but not the implementation. [/Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.csproj::TargetFramework=net10.0]
       /Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.targets(216,5): error : Total Issues: 1 [/Users/builder/azdo/_work/3/s/android/src/Mono.Android/Mono.Android.csproj::TargetFramework=net10.0]

I think there is just a text file to update, so it can see the attribute changed.

@jtschuster
Copy link
Member Author

/azp run

Copy link

Commenter does not have sufficient privileges for PR 10449 in repo dotnet/android

@grendello
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to hold this until we've branched and main is .NET 11.

I'll come back to this and merge then. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants