Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] Set .NET6 defaults for bindings projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Jul 1, 2021
1 parent 0ed14fe commit 7f99d6a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@
<GenerateDependencyFile Condition=" '$(GenerateDependencyFile)' == '' ">false</GenerateDependencyFile>
<CopyLocalLockFileAssemblies Condition=" '$(CopyLocalLockFileAssemblies)' == '' ">false</CopyLocalLockFileAssemblies>
<ComputeNETCoreBuildOutputFiles Condition=" '$(ComputeNETCoreBuildOutputFiles)' == '' ">false</ComputeNETCoreBuildOutputFiles>
<!-- jar2xml is not supported -->
<AndroidClassParser>class-parse</AndroidClassParser>
<!-- mono-symbolicate is not supported -->
<MonoSymbolArchive>false</MonoSymbolArchive>
<AndroidCodegenTarget Condition=" '$(AndroidCodegenTarget)' == '' ">XAJavaInterop1</AndroidCodegenTarget>
<!--
Disable @(Content) from referenced projects
See: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L16
-->
<_GetChildProjectCopyToPublishDirectoryItems>false</_GetChildProjectCopyToPublishDirectoryItems>
<UseMonoRuntime Condition=" '$(UseMonoRuntime)' == '' ">true</UseMonoRuntime>

<!-- Bindings properties -->
<!-- jar2xml is not supported -->
<AndroidClassParser>class-parse</AndroidClassParser>
<!-- Anything other than XAJavaInterop1 is not supported -->
<AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget>
<EnableBindingStaticAndDefaultInterfaceMethods Condition=" '$(EnableBindingStaticAndDefaultInterfaceMethods)' == '' ">true</EnableBindingStaticAndDefaultInterfaceMethods>
<EnableBindingNestedInterfaceTypes Condition=" '$(EnableBindingNestedInterfaceTypes)' == '' ">true</EnableBindingNestedInterfaceTypes>
<EnableBindingInterfaceConstants Condition=" '$(EnableBindingInterfaceConstants)' == '' ">true</EnableBindingInterfaceConstants>

<!-- Mono components -->
<AndroidEnableProfiler Condition=" '$(AndroidEnableProfiler)' == ''">false</AndroidEnableProfiler>
</PropertyGroup>
Expand Down
12 changes: 9 additions & 3 deletions src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public class BindingsGenerator : AndroidDotnetToolTask

public string LangVersion { get; set; }

public bool EnableInterfaceMembersPreview { get; set; }
public bool EnableBindingStaticAndDefaultInterfaceMethods { get; set; }
public bool EnableBindingNestedInterfaceTypes { get; set; }
public bool EnableBindingInterfaceConstants { get; set; }
public string Nullable { get; set; }

public ITaskItem[] TransformFiles { get; set; }
Expand Down Expand Up @@ -172,10 +174,14 @@ protected override string GenerateCommandLineCommands ()
if (SupportsCSharp8) {
var features = new List<string> ();

if (EnableInterfaceMembersPreview) {
if (EnableBindingInterfaceConstants)
features.Add ("interface-constants");

if (EnableBindingNestedInterfaceTypes)
features.Add ("nested-interface-types");

if (EnableBindingStaticAndDefaultInterfaceMethods)
features.Add ("default-interface-methods");
}

if (string.Equals (Nullable, "enable", StringComparison.OrdinalIgnoreCase))
features.Add ("nullable-reference-types");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ Copyright (C) 2012 Xamarin Inc. All rights reserved.
<_AndroidIsBindingProject>True</_AndroidIsBindingProject>
</PropertyGroup>

<!-- Convert legacy DIM preview flag into new Enable* flags -->
<PropertyGroup Condition="'$(_EnableInterfaceMembers)' == 'True'">
<EnableBindingStaticAndDefaultInterfaceMethods Condition=" '$(EnableBindingStaticAndDefaultInterfaceMethods)' == '' ">True</EnableBindingStaticAndDefaultInterfaceMethods>
<EnableBindingNestedInterfaceTypes Condition=" '$(EnableBindingNestedInterfaceTypes)' == '' ">True</EnableBindingNestedInterfaceTypes>
<EnableBindingInterfaceConstants Condition=" '$(EnableBindingInterfaceConstants)' == '' ">True</EnableBindingInterfaceConstants>
</PropertyGroup>

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

<PropertyGroup>
Expand Down

0 comments on commit 7f99d6a

Please sign in to comment.