Skip to content

Commit

Permalink
[One .NET] add %(Platform) to any global @(Using)
Browse files Browse the repository at this point in the history
Context: dotnet/maui#3018 (review)

In order for the .NET MAUI workload to properly implement implicit
global usings:

1. The .NET MAUI workload will add many `@(Using)` entries that
   conflict with each platform's APIs.

2. We need *something* to identify `@(Using)` is for a specific
   platform, so we can use a new `%(Platform)` metadata for this.

3. Late in .NET MAUI's MSBuild targets, we can do:

    <ItemGroup Condition=" '$(UseMaui)' == 'true' and ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable') ">
      <Using Remove="@(Using->HasMetadata('Platform'))" />
    </ItemGroup>

In .NET 7, we might have a nicer design around this, but for now this
is the plan for .NET 6.
  • Loading branch information
jonathanpeppers committed Nov 1, 2021
1 parent ece56b6 commit 3095cca
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ https://github.com/dotnet/designs/blob/4703666296f5e59964961464c25807c727282cae/
</PropertyGroup>

<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable') ">
<Using Include="Android.App" />
<Using Include="Android.Widget" />
<Using Include="Android.OS.Bundle" Alias="Bundle" />
<Using Include="Android.App" Platform="Android" />
<Using Include="Android.Widget" Platform="Android" />
<Using Include="Android.OS.Bundle" Alias="Bundle" Platform="Android" />
</ItemGroup>

<ItemGroup Condition=" '$(EnableDefaultAndroidItems)' == 'true' ">
Expand Down

0 comments on commit 3095cca

Please sign in to comment.