-
Notifications
You must be signed in to change notification settings - Fork 533
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
Android project templates use latest C# language idioms #6076
Milestone
Comments
12 tasks
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Jul 23, 2021
Fixes: dotnet#6075 Fixes: dotnet#6076 Context: xamarin/xamarin-macios#12173 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` by default and do no include `using` statements. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file.
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Jul 23, 2021
Fixes: dotnet#6075 Fixes: dotnet#6076 Context: xamarin/xamarin-macios#12173 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` by default and do no include `using` statements. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file.
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Jul 26, 2021
Fixes: dotnet#6075 Fixes: dotnet#6076 Context: xamarin/xamarin-macios#12173 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` by default and do no include `using` statements. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file.
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 4, 2021
Fixes: dotnet#6075 Fixes: dotnet#6076 Context: xamarin/xamarin-macios#12173 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` by default and do no include `using` statements. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. I also had to write our own target to generate the using for `Bundle`, because the dotnet/sdk always prepends `global::`: https://github.com/dotnet/sdk/blob/86946f52cd012cefd811b25287a8da034bf082a3/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateImplicitNamespaceImports.targets#L46
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 4, 2021
Fixes: dotnet#6075 Fixes: dotnet#6076 Context: xamarin/xamarin-macios#12173 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` by default and do no include `using` statements. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. I also had to write our own target to generate the using for `Bundle`, because the dotnet/sdk always prepends `global::`: https://github.com/dotnet/sdk/blob/86946f52cd012cefd811b25287a8da034bf082a3/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateImplicitNamespaceImports.targets#L46
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 4, 2021
Fixes: dotnet#6075 Fixes: dotnet#6076 Context: xamarin/xamarin-macios#12173 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` by default and do no include `using` statements. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. I also had to write our own target to generate the using for `Bundle`, because the dotnet/sdk always prepends `global::`: https://github.com/dotnet/sdk/blob/86946f52cd012cefd811b25287a8da034bf082a3/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateImplicitNamespaceImports.targets#L46
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 5, 2021
Fixes: dotnet#6075 Fixes: dotnet#6076 Context: xamarin/xamarin-macios#12173 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` by default and do no include `using` statements. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. I also had to write our own target to generate the using for `Bundle`, because the dotnet/sdk always prepends `global::`: https://github.com/dotnet/sdk/blob/86946f52cd012cefd811b25287a8da034bf082a3/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateImplicitNamespaceImports.targets#L46
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 17, 2021
Fixes: dotnet#6075 Fixes: dotnet#6076 Context: xamarin/xamarin-macios#12173 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` and `ImplicitUsings=enable` by default and do not include `using` statements in `.cs` files. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. So `AutoImport.props` should become: <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" /> </ItemGroup> So these items are present at the time `.csproj` files are evaluated. Any templates will add: <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> If users want to configure these settings, they can remove `$(ImplicitUsings)` from the `.csproj` completely or remove specific `@(Using)` items: <ItemGroup> <Using Remove="Android.App" /> </ItemGroup>
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 17, 2021
Context: dotnet/sdk#19521 Fixes: dotnet#6075 Fixes: dotnet#6076 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` and `ImplicitUsings=enable` by default and do not include `using` statements in `.cs` files. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. So `AutoImport.props` should become: <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" /> </ItemGroup> So these items are present at the time `.csproj` files are evaluated. Any templates will add: <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> If users want to configure these settings, they can remove `$(ImplicitUsings)` from the `.csproj` completely or remove specific `@(Using)` items: <ItemGroup> <Using Remove="Android.App" /> </ItemGroup>
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 19, 2021
Context: dotnet/sdk#19521 Fixes: dotnet#6075 Fixes: dotnet#6076 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` and `ImplicitUsings=enable` by default and do not include `using` statements in `.cs` files. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. So `AutoImport.props` should become: <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" /> </ItemGroup> So these items are present at the time `.csproj` files are evaluated. Any templates will add: <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> If users want to configure these settings, they can remove `$(ImplicitUsings)` from the `.csproj` completely or remove specific `@(Using)` items: <ItemGroup> <Using Remove="Android.App" /> </ItemGroup>
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 19, 2021
Context: dotnet/sdk#19521 Fixes: dotnet#6075 Fixes: dotnet#6076 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` and `ImplicitUsings=enable` by default and do not include `using` statements in `.cs` files. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. So `AutoImport.props` should become: <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" /> </ItemGroup> So these items are present at the time `.csproj` files are evaluated. Any templates will add: <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> If users want to configure these settings, they can remove `$(ImplicitUsings)` from the `.csproj` completely or remove specific `@(Using)` items: <ItemGroup> <Using Remove="Android.App" /> </ItemGroup>
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 20, 2021
Context: dotnet/sdk#19521 Fixes: dotnet#6075 Fixes: dotnet#6076 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` and `ImplicitUsings=enable` by default and do not include `using` statements in `.cs` files. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. So `AutoImport.props` should become: <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" /> </ItemGroup> So these items are present at the time `.csproj` files are evaluated. Any templates will add: <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> If users want to configure these settings, they can remove `$(ImplicitUsings)` from the `.csproj` completely or remove specific `@(Using)` items: <ItemGroup> <Using Remove="Android.App" /> </ItemGroup>
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 23, 2021
Context: dotnet/sdk#19521 Fixes: dotnet#6075 Fixes: dotnet#6076 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` and `ImplicitUsings=enable` by default and do not include `using` statements in `.cs` files. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. So `AutoImport.props` should become: <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" /> </ItemGroup> So these items are present at the time `.csproj` files are evaluated. Any templates will add: <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> If users want to configure these settings, they can remove `$(ImplicitUsings)` from the `.csproj` completely or remove specific `@(Using)` items: <ItemGroup> <Using Remove="Android.App" /> </ItemGroup>
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 23, 2021
Context: dotnet/sdk#19521 Fixes: dotnet#6075 Fixes: dotnet#6076 We need to make two sets of changes for C# 10: 1. Support "global usings". Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Use `$(Nullable)` `enable` by default in project templates. To test this, our .NET 6 MSBuild tests use `Nullable=enable` and `ImplicitUsings=enable` by default and do not include `using` statements in `.cs` files. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`. So `AutoImport.props` should become: <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" /> </ItemGroup> So these items are present at the time `.csproj` files are evaluated. Any templates will add: <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> If users want to configure these settings, they can remove `$(ImplicitUsings)` from the `.csproj` completely or remove specific `@(Using)` items: <ItemGroup> <Using Remove="Android.App" /> </ItemGroup>
jonpryor
pushed a commit
that referenced
this issue
Aug 25, 2021
Fixes: #6075 Fixes: #6076 Context: dotnet/sdk#19521 We need to make two sets of changes for C# 10: 1. Support ["global usings"][0]. Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Set `$(Nullable)`=enable by default in project templates, i.e. enable [C#8 nullable reference types][1] by default. To test this, our .NET 6 MSBuild tests use `$(Nullable)`=enable and `$(ImplicitUsings)`=enable by default and do not include `using` statements in `.cs` files. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`, and the `System` namespace will be in `@(Using)` by default. `AutoImport.props` should become: <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" /> </ItemGroup> so that these `using`s are present at the time `.csproj` files are compiled. Any templates will add: <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> If users want to configure these settings, they can remove `$(ImplicitUsings)` from the `.csproj` completely, or remove specific `@(Using)` items: <ItemGroup> <Using Remove="Android.App" /> </ItemGroup> [0]: https://github.com/dotnet/csharplang/blob/b89d4c934041db923f7238b1427cd5f3ae71ed4b/proposals/csharp-10.0/GlobalUsingDirective.md#global-using-alias-directives [1]: https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references
jonathanpeppers
added a commit
that referenced
this issue
Aug 25, 2021
Fixes: #6075 Fixes: #6076 Context: dotnet/sdk#19521 We need to make two sets of changes for C# 10: 1. Support ["global usings"][0]. Our .NET 6 templates should have no `using` statements at the top of `.cs` files. 2. Set `$(Nullable)`=enable by default in project templates, i.e. enable [C#8 nullable reference types][1] by default. To test this, our .NET 6 MSBuild tests use `$(Nullable)`=enable and `$(ImplicitUsings)`=enable by default and do not include `using` statements in `.cs` files. I've made a new `MainActivity.cs` for our .NET 6 MSBuild tests. The "legacy" Xamarin.Android tests will use the original file. Our default `global using` are: global using global::Android.App; global using global::Android.Widget; global using Bundle = global::Android.OS.Bundle; The last one is intentionally not bringing in `Android.OS`, because `Android.OS.Environment` would conflict with `System.Environment`, and the `System` namespace will be in `@(Using)` by default. `AutoImport.props` should become: <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" /> </ItemGroup> so that these `using`s are present at the time `.csproj` files are compiled. Any templates will add: <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> If users want to configure these settings, they can remove `$(ImplicitUsings)` from the `.csproj` completely, or remove specific `@(Using)` items: <ItemGroup> <Using Remove="Android.App" /> </ItemGroup> [0]: https://github.com/dotnet/csharplang/blob/b89d4c934041db923f7238b1427cd5f3ae71ed4b/proposals/csharp-10.0/GlobalUsingDirective.md#global-using-alias-directives [1]: https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references
ghost
locked as resolved and limited conversation to collaborators
Jun 2, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In .NET 6, the included C# project templates will use the latest language idioms.
See the parent Epic for details.
Depends on:
The text was updated successfully, but these errors were encountered: