Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dotnet] Update logic for default global namespaces and fix the templates. Fixes #12457. #12471

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dotnet/Microsoft.MacCatalyst.Sdk/Sdk/AutoImport.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\targets\Microsoft.MacCatalyst.Sdk.DefaultItems.props" />
<Import Project="..\targets\Microsoft.MacCatalyst.Sdk.ImplicitNamespaceImports.props" />
</Project>
1 change: 1 addition & 0 deletions dotnet/Microsoft.iOS.Sdk/Sdk/AutoImport.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\targets\Microsoft.iOS.Sdk.DefaultItems.props" />
<Import Project="..\targets\Microsoft.iOS.Sdk.ImplicitNamespaceImports.props" />
</Project>
1 change: 1 addition & 0 deletions dotnet/Microsoft.macOS.Sdk/Sdk/AutoImport.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\targets\Microsoft.macOS.Sdk.DefaultItems.props" />
<Import Project="..\targets\Microsoft.macOS.Sdk.ImplicitNamespaceImports.props" />
</Project>
1 change: 1 addition & 0 deletions dotnet/Microsoft.tvOS.Sdk/Sdk/AutoImport.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\targets\Microsoft.tvOS.Sdk.DefaultItems.props" />
<Import Project="..\targets\Microsoft.tvOS.Sdk.ImplicitNamespaceImports.props" />
</Project>
1 change: 1 addition & 0 deletions dotnet/Microsoft.watchOS.Sdk/Sdk/AutoImport.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\targets\Microsoft.watchOS.Sdk.DefaultItems.props" />
<Import Project="..\targets\Microsoft.watchOS.Sdk.ImplicitNamespaceImports.props" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">MacCatalystApp1</RootNamespace>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">iOSApp1</RootNamespace>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<TargetFramework>net6.0-ios</TargetFramework>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">iOSLib1</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">macOSApp1</RootNamespace>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">tvOSApp1</RootNamespace>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- There's a master switch, DisableImplicitNamespaceImports, which, if set, will prevent all implicit namespace imports - this is done automatically, we don't have to check DisableImplicitNamespaceImports here -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'MacCatalyst' And '$(DisableImplicitNamespaceImports_MacCatalyst)' != 'true'">
<Import Include="CoreGraphics" />
<Import Include="Foundation" />
<Import Include="UIKit" />
<!--
These implicit usings are C#-specific, and governed by a single global property: ImplicitUsings, which can be either 'true' or 'enable'.
Ref: https://github.com/dotnet/sdk/issues/19793#issuecomment-900620060
-->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'MacCatalyst' And '$(Language)' == 'C#' And ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable')">
<Using Include="CoreGraphics" />
<Using Include="Foundation" />
<Using Include="UIKit" />
</ItemGroup>
</Project>
13 changes: 8 additions & 5 deletions dotnet/targets/Microsoft.iOS.Sdk.ImplicitNamespaceImports.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- There's a master switch, DisableImplicitNamespaceImports, which, if set, will prevent all implicit namespace imports - this is done automatically, we don't have to check DisableImplicitNamespaceImports here -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'iOS' And '$(DisableImplicitNamespaceImports_iOS)' != 'true'">
<Import Include="CoreGraphics" />
<Import Include="Foundation" />
<Import Include="UIKit" />
<!--
These implicit usings are C#-specific, and governed by a single global property: ImplicitUsings, which can be either 'true' or 'enable'.
Ref: https://github.com/dotnet/sdk/issues/19793#issuecomment-900620060
-->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'iOS' And '$(Language)' == 'C#' And ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable')">
<Using Include="CoreGraphics" />
<Using Include="Foundation" />
<Using Include="UIKit" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- There's a master switch, DisableImplicitNamespaceImports, which, if set, will prevent all implicit namespace imports - this is done automatically, we don't have to check DisableImplicitNamespaceImports here -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'macOS' And '$(DisableImplicitNamespaceImports_macOS)' != 'true'">
<Import Include="AppKit" />
<Import Include="CoreGraphics" />
<Import Include="Foundation" />
<!--
These implicit usings are C#-specific, and governed by a single global property: ImplicitUsings, which can be either 'true' or 'enable'.
Ref: https://github.com/dotnet/sdk/issues/19793#issuecomment-900620060
-->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'macOS' And '$(Language)' == 'C#' And ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable')">
<Using Include="AppKit" />
<Using Include="CoreGraphics" />
<Using Include="Foundation" />
</ItemGroup>
</Project>
13 changes: 8 additions & 5 deletions dotnet/targets/Microsoft.tvOS.Sdk.ImplicitNamespaceImports.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- There's a master switch, DisableImplicitNamespaceImports, which, if set, will prevent all implicit namespace imports - this is done automatically, we don't have to check DisableImplicitNamespaceImports here -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'tvOS' And '$(DisableImplicitNamespaceImports_tvOS)' != 'true'">
<Import Include="CoreGraphics" />
<Import Include="Foundation" />
<Import Include="UIKit" />
<!--
These implicit usings are C#-specific, and governed by a single global property: ImplicitUsings, which can be either 'true' or 'enable'.
Ref: https://github.com/dotnet/sdk/issues/19793#issuecomment-900620060
-->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'tvOS' And '$(Language)' == 'C#' And ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable')">
<Using Include="CoreGraphics" />
<Using Include="Foundation" />
<Using Include="UIKit" />
</ItemGroup>
</Project>
3 changes: 0 additions & 3 deletions dotnet/targets/Xamarin.Shared.Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
<!-- This contains the OS versions we support for target platform -->
<Import Project="Microsoft.$(_PlatformName).Sdk.SupportedTargetPlatforms.props" />

<!-- This contains support for implicit namespace imports -->
<Import Project="Microsoft.$(_PlatformName).Sdk.ImplicitNamespaceImports.props" />

<Import Project="Xamarin.Shared.Sdk.TargetFrameworkInference.props" />

<PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion tests/dotnet/UnitTests/TemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public void AreAllTemplatesListed ()

[Test]
[TestCaseSource (nameof (Templates))]
[Ignore ("https://github.com/xamarin/xamarin-macios/issues/12457")]
public void CreateAndBuildTemplate (string platform, string template)
{
Configuration.IgnoreIfIgnoredPlatform (platform);
Expand Down