Add NU1704 warning for packages using deprecated MonoAndroid framework#7229
Add NU1704 warning for packages using deprecated MonoAndroid framework#7229
Conversation
Emit NU1704 when a project targeting net11.0-android or later references a package that resolves MonoAndroid framework assets instead of the modern net6.0-android+ TFMs. The warning is gated on SdkAnalysisLevel >= 11.0.100 and only applies to Android-targeting projects with framework version >= 11. The detection inspects compile-time and runtime assembly paths in the lock file target library for 'monoandroid' folder segments, following the pattern of the previously removed MaccatalystFallback helper.
# Conflicts: # src/NuGet.Core/NuGet.Common/PublicAPI.Unshipped.txt
|
NU1704 doesn't seem to be documented at https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings do I assume it's a new warning for NuGet 7/.NET 11? The PR title or description wasn't making it obvious if the warning itself is new or just the scenario... Since I couldn't find any docs for it I will ask this question. The PR description mentions lockfiles so will using lockfiles be a pre-condition to get this warning? Could a warning be issued without it or could some docs be further clarified? |
|
NU1704 is a new warning I'm introducing. It's similar to the NU1703 for xamarin.ios (before it was removed in #4362 because we decided xamarin.ios would not be supported). I'll add a docs PR too. |
|
Hey @sbomer Thanks for getting this conversation going. While the implementation is correct, we normally start with an https://github.com/nuget/home/issues and sometimes a spec for changes like this. https://github.com/NuGet/Home/blob/dev/meta/template.md The reasoning being that adding a new warning is considered disruptive and a breaking change as well meaning as it may be. We'd also probably be curious about the blast radius, so how many projects would be affected, but I doubt that's something we can easily figure out right now. I'll tag the PR as a breaking change and bot will follow with more links. |
|
Added When you commit this breaking change:
You can refer to the .NET SDK breaking change guidelines |
| } | ||
| } | ||
|
|
||
| // Log NU1704 warning if the package uses the deprecated MonoAndroid framework |
There was a problem hiding this comment.
breaking change mechanics aside, i wonder if we should just re-use Nu1703.
It existed for a very very short time and it's unlikely anyone is specifying it their project file based on some of the comments we've made when we reverted it.
There was a problem hiding this comment.
I considered this but noticed we did document NU1703 with text that references xamarin.ios, so I went with a new warning. Happy to use NU1703 instead if we are ok with changing that doc.
There was a problem hiding this comment.
I'll let someone else from the team chip in too before you go and make that change. I am comfortable with changing that documentation too.
Oh there's this thing I meant to link to but I forgot in the previous comment: https://github.com/NuGet/NuGet.Client/blob/dev/docs/feature-guide.md#warnings-and-defaults
So whatever we add, we'll need to gate on SDKAnalysisLevel.
There was a problem hiding this comment.
/cc @rolfbjarne
I think it would be OK to reuse the code and just include Xamarin.Android and Xamarin.iOS both in the docs.
I think this is false anyway:
While net6.0-maccatalyst (and higher .NET versions) support using Xamarin.iOS dependencies, this is not guaranteed to be 100% compatible.
I don't think they would work at all?
However, Xamarin.Android class libraries are more in the "not guaranteed to be 100% compatible", but could actually work.
There was a problem hiding this comment.
While net6.0-maccatalyst (and higher .NET versions) support using Xamarin.iOS dependencies, this is not guaranteed to be 100% compatible.
I don't think they would work at all?
No, this doesn't work.
In fact Xamarin.iOS.dll never worked in .NET, so I'm fine with reusing the warning number, nobody should have seen NU1703 in the first place.
Per PR feedback on NuGet/NuGet.Client#7229, reuse the NU1703 warning code for the MonoAndroid deprecation scenario. The previous NU1703 for Xamarin.iOS never shipped, so the code is safe to repurpose. Remove NU1704 doc and references from TOC and index.
Emit NU1704 when a project targeting net11.0-android or later references a package that resolves MonoAndroid framework assets instead of the modern net6.0-android+ TFMs. The warning is gated on SdkAnalysisLevel >= 11.0.100 and only applies to Android-targeting projects with framework version >= 11.
The detection inspects compile-time and runtime assembly paths in the lock file target library for 'monoandroid' folder segments, following the pattern of the previously removed MaccatalystFallback helper.
Bug
Adds the warning mentioned in dotnet/android#11028.
Description
PR Checklist