From d6c0447859d16dc28da39a6ea254437cd57eee6a Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 18 Aug 2021 12:11:04 +0200 Subject: [PATCH] [dotnet] Update logic for default global namespaces and fix the templates. Fixes #12457. * Add 'ImplicitUsings=true' to all the templates. * Make the implicit global namespaces C#-only. * Add the implicit global namespaces to the 'Using' itemgroup instead of the 'Import' itemgroup. * Make sure the global namespaces are set from AutoImport.props, so that the user may remove any global namespace they don't want in their project file (by doing something like: ``) Ref: https://github.com/dotnet/sdk/issues/19521 Ref: https://github.com/dotnet/sdk/issues/19793 Fixes https://github.com/xamarin/xamarin-macios/issues/12457. --- .../Microsoft.MacCatalyst.Sdk/Sdk/AutoImport.props | 1 + dotnet/Microsoft.iOS.Sdk/Sdk/AutoImport.props | 1 + dotnet/Microsoft.macOS.Sdk/Sdk/AutoImport.props | 1 + dotnet/Microsoft.tvOS.Sdk/Sdk/AutoImport.props | 1 + dotnet/Microsoft.watchOS.Sdk/Sdk/AutoImport.props | 1 + .../maccatalyst/MacCatalystApp1.csproj | 1 + .../Microsoft.iOS.Templates/ios/iOSApp1.csproj | 1 + .../Microsoft.iOS.Templates/ioslib/iOSLib1.csproj | 1 + .../macos/macOSApp1.csproj | 1 + .../Microsoft.tvOS.Templates/tvos/tvOSApp1.csproj | 1 + ...t.MacCatalyst.Sdk.ImplicitNamespaceImports.props | 13 ++++++++----- ...Microsoft.iOS.Sdk.ImplicitNamespaceImports.props | 13 ++++++++----- ...crosoft.macOS.Sdk.ImplicitNamespaceImports.props | 13 ++++++++----- ...icrosoft.tvOS.Sdk.ImplicitNamespaceImports.props | 13 ++++++++----- dotnet/targets/Xamarin.Shared.Sdk.props | 3 --- tests/dotnet/UnitTests/TemplateTest.cs | 1 - 16 files changed, 42 insertions(+), 24 deletions(-) diff --git a/dotnet/Microsoft.MacCatalyst.Sdk/Sdk/AutoImport.props b/dotnet/Microsoft.MacCatalyst.Sdk/Sdk/AutoImport.props index bec641d41ad8..0ba5cc02ef81 100644 --- a/dotnet/Microsoft.MacCatalyst.Sdk/Sdk/AutoImport.props +++ b/dotnet/Microsoft.MacCatalyst.Sdk/Sdk/AutoImport.props @@ -1,3 +1,4 @@ + diff --git a/dotnet/Microsoft.iOS.Sdk/Sdk/AutoImport.props b/dotnet/Microsoft.iOS.Sdk/Sdk/AutoImport.props index 01d5383cb887..83ef903c8b4f 100644 --- a/dotnet/Microsoft.iOS.Sdk/Sdk/AutoImport.props +++ b/dotnet/Microsoft.iOS.Sdk/Sdk/AutoImport.props @@ -1,3 +1,4 @@ + diff --git a/dotnet/Microsoft.macOS.Sdk/Sdk/AutoImport.props b/dotnet/Microsoft.macOS.Sdk/Sdk/AutoImport.props index 918e7b9ad484..4a14b1ed8dab 100644 --- a/dotnet/Microsoft.macOS.Sdk/Sdk/AutoImport.props +++ b/dotnet/Microsoft.macOS.Sdk/Sdk/AutoImport.props @@ -1,3 +1,4 @@ + diff --git a/dotnet/Microsoft.tvOS.Sdk/Sdk/AutoImport.props b/dotnet/Microsoft.tvOS.Sdk/Sdk/AutoImport.props index 89b739355968..37faf34376e2 100644 --- a/dotnet/Microsoft.tvOS.Sdk/Sdk/AutoImport.props +++ b/dotnet/Microsoft.tvOS.Sdk/Sdk/AutoImport.props @@ -1,3 +1,4 @@ + diff --git a/dotnet/Microsoft.watchOS.Sdk/Sdk/AutoImport.props b/dotnet/Microsoft.watchOS.Sdk/Sdk/AutoImport.props index ca0479bdaaba..e909c261726c 100644 --- a/dotnet/Microsoft.watchOS.Sdk/Sdk/AutoImport.props +++ b/dotnet/Microsoft.watchOS.Sdk/Sdk/AutoImport.props @@ -1,3 +1,4 @@ + diff --git a/dotnet/Templates/Microsoft.MacCatalyst.Templates/maccatalyst/MacCatalystApp1.csproj b/dotnet/Templates/Microsoft.MacCatalyst.Templates/maccatalyst/MacCatalystApp1.csproj index 8b6d851d3743..88fd065da8b1 100644 --- a/dotnet/Templates/Microsoft.MacCatalyst.Templates/maccatalyst/MacCatalystApp1.csproj +++ b/dotnet/Templates/Microsoft.MacCatalyst.Templates/maccatalyst/MacCatalystApp1.csproj @@ -5,5 +5,6 @@ MacCatalystApp1 Exe enable + true diff --git a/dotnet/Templates/Microsoft.iOS.Templates/ios/iOSApp1.csproj b/dotnet/Templates/Microsoft.iOS.Templates/ios/iOSApp1.csproj index 509800f424d2..887acc2eb3a7 100644 --- a/dotnet/Templates/Microsoft.iOS.Templates/ios/iOSApp1.csproj +++ b/dotnet/Templates/Microsoft.iOS.Templates/ios/iOSApp1.csproj @@ -4,5 +4,6 @@ iOSApp1 Exe enable + true diff --git a/dotnet/Templates/Microsoft.iOS.Templates/ioslib/iOSLib1.csproj b/dotnet/Templates/Microsoft.iOS.Templates/ioslib/iOSLib1.csproj index 64e83d5cbef7..984bbf660e67 100644 --- a/dotnet/Templates/Microsoft.iOS.Templates/ioslib/iOSLib1.csproj +++ b/dotnet/Templates/Microsoft.iOS.Templates/ioslib/iOSLib1.csproj @@ -3,5 +3,6 @@ net6.0-ios iOSLib1 enable + true diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macos/macOSApp1.csproj b/dotnet/Templates/Microsoft.macOS.Templates/macos/macOSApp1.csproj index 885d47ba82f2..2d0a6b324cfd 100644 --- a/dotnet/Templates/Microsoft.macOS.Templates/macos/macOSApp1.csproj +++ b/dotnet/Templates/Microsoft.macOS.Templates/macos/macOSApp1.csproj @@ -4,5 +4,6 @@ macOSApp1 Exe enable + true \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvos/tvOSApp1.csproj b/dotnet/Templates/Microsoft.tvOS.Templates/tvos/tvOSApp1.csproj index dff9551ee5b3..cf0351ad5c28 100644 --- a/dotnet/Templates/Microsoft.tvOS.Templates/tvos/tvOSApp1.csproj +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvos/tvOSApp1.csproj @@ -4,5 +4,6 @@ tvOSApp1 Exe enable + true diff --git a/dotnet/targets/Microsoft.MacCatalyst.Sdk.ImplicitNamespaceImports.props b/dotnet/targets/Microsoft.MacCatalyst.Sdk.ImplicitNamespaceImports.props index 11080e7ef127..501bb805518b 100644 --- a/dotnet/targets/Microsoft.MacCatalyst.Sdk.ImplicitNamespaceImports.props +++ b/dotnet/targets/Microsoft.MacCatalyst.Sdk.ImplicitNamespaceImports.props @@ -18,10 +18,13 @@ --> - - - - - + + + + + diff --git a/dotnet/targets/Microsoft.iOS.Sdk.ImplicitNamespaceImports.props b/dotnet/targets/Microsoft.iOS.Sdk.ImplicitNamespaceImports.props index b1f93fd573ea..849d76fcfa6f 100644 --- a/dotnet/targets/Microsoft.iOS.Sdk.ImplicitNamespaceImports.props +++ b/dotnet/targets/Microsoft.iOS.Sdk.ImplicitNamespaceImports.props @@ -18,10 +18,13 @@ --> - - - - - + + + + + diff --git a/dotnet/targets/Microsoft.macOS.Sdk.ImplicitNamespaceImports.props b/dotnet/targets/Microsoft.macOS.Sdk.ImplicitNamespaceImports.props index 11c0483e7986..5874f46852a0 100644 --- a/dotnet/targets/Microsoft.macOS.Sdk.ImplicitNamespaceImports.props +++ b/dotnet/targets/Microsoft.macOS.Sdk.ImplicitNamespaceImports.props @@ -18,10 +18,13 @@ --> - - - - - + + + + + diff --git a/dotnet/targets/Microsoft.tvOS.Sdk.ImplicitNamespaceImports.props b/dotnet/targets/Microsoft.tvOS.Sdk.ImplicitNamespaceImports.props index 50e58beb4d9e..afce3dae2e3f 100644 --- a/dotnet/targets/Microsoft.tvOS.Sdk.ImplicitNamespaceImports.props +++ b/dotnet/targets/Microsoft.tvOS.Sdk.ImplicitNamespaceImports.props @@ -18,10 +18,13 @@ --> - - - - - + + + + + diff --git a/dotnet/targets/Xamarin.Shared.Sdk.props b/dotnet/targets/Xamarin.Shared.Sdk.props index 9f55fc11ad23..7fcfbf48b5e5 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.props +++ b/dotnet/targets/Xamarin.Shared.Sdk.props @@ -6,9 +6,6 @@ - - - diff --git a/tests/dotnet/UnitTests/TemplateTest.cs b/tests/dotnet/UnitTests/TemplateTest.cs index d9121a770574..73d8d9c36e99 100644 --- a/tests/dotnet/UnitTests/TemplateTest.cs +++ b/tests/dotnet/UnitTests/TemplateTest.cs @@ -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);