-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Context: dotnet/android#6118
We have an issue in .NET 6 Android applications, where every Android app has a method like:
protected override void OnCreate(Bundle? savedInstanceState)We don't want to include <Import Include="Android.OS" />, because Android.OS.Environment would conflict with System.Environment. Developers would likely use System.Environment, so we don't want to cause an issue there.
So our plan is to add the global using:
global using Bundle = global::Android.OS.Bundle;Unfortunately, it's not possible to use the @(Import) item group to do this, because it always prefixes global:::
Line 46 in 86946f5
| <_ImportFileLine Include="global using global::%(_UniqueImport.Identity)%3B"/> |
What we did for now is generate our own C# file for this one line.
This seems OK, but is it worth adding some support to @(Import) so you could do something like:
<Import Include="Bundle = global::Android.OS.Bundle" />Maybe the dotnet/sdk could simply skip the global:: prefix if the string contains it?