-
Notifications
You must be signed in to change notification settings - Fork 514
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
Add iOS/Mac default global usings in MSBuild targets #12084
Comments
The templates have these usings (with number of occurrences):
If I understand correctly, the
<ItemGroup Condition="'$(DisableImplicitNamespaceImports_Apple)' != 'true'">
<Import Include="Foundation" />
<Import Include="UIKit" Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'MacCatalyst'" />
<Import Include="AppKit" Condition="'$(_PlatformName)' == 'macOS'" />
</ItemGroup> One question comes up: should the condition be based on a single property for all our platforms ( |
Another question: if the user sets |
Probably do it per platform ( The logic in web is to default Are there any other usings that are commonly used in apps but not in the templates? For example Thought the more usings we add, the higher the risk of bringing in types that collide with types brought in by the Maui usings, as the iOS types will be brought in for the iOS build of multitargeted Maui apps. This will also be an issue for Android /cc |
I thought we'd decided on |
This is not strictly true. For example, in the the Web SDK we add System.Net.Http.Json: https://github.com/dotnet/sdk/blob/main/src/WebSdk/Web/Sdk/Sdk.props#L64. However for some of the proposed ones that are very general such as System.Text, it's worth having a conversation with the maintainers of the base .NET SDK where that should go. |
OK, I believe that means that while the web logic is not incorrect, it's also slightly more complex than necessary (there's no need to make our additions to the
Yes, |
. Also update our templates to remove any using statements for implicitly imported namespaces. Fixes xamarin#12084.
…12173) * [dotnet] Add support for implicit namespace imports. Fixes #12084. Also update our templates to remove any using statements for implicitly imported namespaces. Fixes #12084. * [monotouch-test] Fix compilation error due to implicit namespace causing type conflict. Fixes these errors: xamarin-macios/tests/monotouch-test/ImageIO/MutableImageMetadataTest.cs(54,54): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties' xamarin-macios/tests/monotouch-test/ImageIO/MutableImageMetadataTest.cs(54,88): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties' xamarin-macios/tests/monotouch-test/ImageIO/ImageMetadataTest.cs(40,54): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties' xamarin-macios/tests/monotouch-test/ImageIO/ImageMetadataTest.cs(40,88): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties'
. Also update our templates to remove any using statements for implicitly imported namespaces. Fixes xamarin#12084.
…e imports. Fixes #12084. (#12196) * [dotnet] Add support for implicit namespace imports. Fixes #12084. Also update our templates to remove any using statements for implicitly imported namespaces. Fixes #12084. * [monotouch-test] Fix compilation error due to implicit namespace causing type conflict. Fixes these errors: xamarin-macios/tests/monotouch-test/ImageIO/MutableImageMetadataTest.cs(54,54): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties' xamarin-macios/tests/monotouch-test/ImageIO/MutableImageMetadataTest.cs(54,88): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties' xamarin-macios/tests/monotouch-test/ImageIO/ImageMetadataTest.cs(40,54): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties' xamarin-macios/tests/monotouch-test/ImageIO/ImageMetadataTest.cs(40,88): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties' Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Following the pattern in dotnet/sdk#18459, the iOS/Mac SDK targets should contain default global usings that can be disabled by an MSBuild property.
Namespaces to be imported by default:
iOS: CoreGraphics, Foundation, UIKit
tvOS: CoreGraphics, Foundation, UIKit
macOS: AppKit, CoreGraphics, Foundation
Mac Catalyst: CoreGraphics, Foundation, UIKit
The text was updated successfully, but these errors were encountered: