Skip to content

Commit 3a1462a

Browse files
committed
[build] Use $(AndroidPlatformId) when desired
Context: 485e39b Context: eb08bb4 ...and doubtless others... Three MSBuild properties control the `android.jar` which is bound and the `$(TargetFrameworkVersion)` of `Mono.Android.dll`: * `$(AndroidApiLevel)`: The API level that is bound. Must be an int. * `$(AndroidFrameworkVersion)`: The `$(TargetFrameworkVersion)` of the generated `Mono.Android.dll`. Must be *mostly* parseable by `System.Version` except with a leading `v`. * `$(AndroidPlatformId)`: The "ID" of the API level. *Most* of the time, `$(AndroidApiLevel)` and `$(AndroidPlatformId)` will be *identical*: for API-29, they're both `29`. Where they differ is for new *preview* API levels, such as API-R: `$(AndroidApiLevel)` will be 30, but `$(AndroidPlatformId)` is `R`. The distinction is important because various filesystem paths within the Android SDK use the "id" and *not* the API level when they differ, e.g. the API-R `android.jar` is installed into: $(AndroidSdkDirectory)/platforms/android-R/android.jar We thus need to be *careful* when distinguishing between `$(AndroidApiLevel)` and `$(AndroidPlatformId)`, using the former when an integer is *required*, and using the latter whenever it refers to filesystem paths. Unfortunately, we *haven't* been careful, because these values really only differ for ~4 months out of the year, and for only one `$(TargetFrameworkVersion)` version. Start bringing some sanity...and finding bugs while we do so: `api-xml-adjuster.targets` should use `%(AndroidApiInfo.Id)` and *not* `%(AndroidApiLevel.Level)`, as it references filesystem locations. Consequently, `src/Mono.Android/Profiles/api-30.params.txt` must be renamed to `src/Mono.Android/Profiles/api-R.params.txt` so that it correctly embeds the `$(AndroidPlatformId)` value. `Mono.Android.targets` should likewise use `$(AndroidPlatformId)` and not `$(AndroidApiLevel)` when using filesystem paths from the SDK. For good measure, `Mono.Android.csproj` now overrides `$(IntermediateOutputPath)` to contain `$(AndroidPlatformId)`, because why not (MOAR CONSISTENCY!). These changes, unfortunately, introduce breakage, which will need to be addressed: *Because* API-R was installed into `$(AndroidSdkDirectory)/platforms/android-R`, `api-versions.xml` *was not previously used* because `Mono.Android.targets` was using `$(AndroidApiLevel)`, and `platforms/android-30/data/api-version.xml` does not yet exist. (It will come June! But not now.) As it didn't exist, it hit the fallback path and usd `platform-tools/api/api-versions.xml` (4cd2060). You would *think* this wouldn't be a problem, but the API-R `api-versions.xml` is *missing* members relative to platform-tools, resulting in members *missing* `RegisterAttribute.ApiSince` values, which `Microsoft.DotNet.ApiCompat.exe` reports, e.g.: CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.TrimToSize()' changed from '[RegisterAttribute("trimToSize", "()V", "", ApiSince=9)]' in the contract to '[RegisterAttribute("trimToSize", "()V", "")]' in the implementation The "ignored" errors from a20be39 are no longer triggered, so they are removed, e.g.: CannotAddAbstractMembers : Member 'Android.Telephony.CellInfo.CellIdentity' is abstract in the implementation but is missing in the contract Instead, *different* errors around `CellInfo` are reported, which don't make sense to @jonpryor, e.g. MembersMustExist : Member 'Android.Telephony.CellInfoGsm.CellIdentity.get()' does not exist in the implementation but it does exist in the contract. This doesn't "make sense" because that member *does* exist in the implementation...
1 parent b054f38 commit 3a1462a

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

build-tools/api-xml-adjuster/api-xml-adjuster.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</_Api>
1616
</ItemGroup>
1717
<CreateItem Include="@(_Api)"
18-
AdditionalMetadata="ParameterDescription=$(_TopDir)\src\Mono.Android\Profiles\api-%(_Api.Level).params.txt;ClassParseXml=$(_OutputPath)api\api-%(_Api.Level).xml.class-parse;ApiAdjustedXml=$(_OutputPath)api\api-%(_Api.Level).xml.in">
18+
AdditionalMetadata="ParameterDescription=$(_TopDir)\src\Mono.Android\Profiles\api-%(_Api.Id).params.txt;ClassParseXml=$(_OutputPath)api\api-%(_Api.Id).xml.class-parse;ApiAdjustedXml=$(_OutputPath)api\api-%(_Api.Id).xml.in">
1919
<Output TaskParameter="Include" ItemName="ApiFileDefinition"/>
2020
</CreateItem>
2121
</Target>

src/Mono.Android/Mono.Android.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
9797
<PropertyGroup>
9898
<ImplicitlyExpandDesignTimeFacades>False</ImplicitlyExpandDesignTimeFacades>
99-
<IntermediateOutputPath>$(IntermediateOutputPath)android-$(AndroidApiLevel)\</IntermediateOutputPath>
99+
<IntermediateOutputPath>$(IntermediateOutputPath)android-$(AndroidPlatformId)\</IntermediateOutputPath>
100100
</PropertyGroup>
101101
<Import Project="Mono.Android.targets" />
102102
<PropertyGroup>

src/Mono.Android/Mono.Android.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
Outputs="$(IntermediateOutputPath)mcw\Mono.Android.projitems">
8080
<MakeDir Directories="$(IntermediateOutputPath)mcw" />
8181
<PropertyGroup>
82-
<_ApiVersions Condition="Exists('$(AndroidSdkDirectory)\platforms\android-$(AndroidApiLevel)\data\api-versions.xml')">"$(AndroidSdkDirectory)\platforms\android-$(AndroidApiLevel)\data\api-versions.xml"</_ApiVersions>
82+
<_ApiVersions Condition="Exists('$(AndroidSdkDirectory)\platforms\android-$(AndroidPlatformId)\data\api-versions.xml')">"$(AndroidSdkDirectory)\platforms\android-$(AndroidPlatformId)\data\api-versions.xml"</_ApiVersions>
8383
<_ApiVersions Condition="'$(_ApiVersions)'==''">"$(AndroidSdkDirectory)\platform-tools\api\api-versions.xml"</_ApiVersions>
8484
</PropertyGroup>
8585
<PropertyGroup>
Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
Compat issues with assembly Mono.Android:
2-
CannotAddAbstractMembers : Member 'Android.Telephony.CellInfo.CellIdentity' is abstract in the implementation but is missing in the contract.
3-
CannotAddAbstractMembers : Member 'Android.Telephony.CellInfo.CellSignalStrength' is abstract in the implementation but is missing in the contract.
4-
CannotAddAbstractMembers : Member 'Android.Telephony.CellInfo.CellIdentity.get()' is abstract in the implementation but is missing in the contract.
5-
CannotAddAbstractMembers : Member 'Android.Telephony.CellInfo.CellSignalStrength.get()' is abstract in the implementation but is missing in the contract.
2+
MembersMustExist : Member 'Android.Telephony.CellInfoCdma.CellIdentity.get()' does not exist in the implementation but it does exist in the contract.
3+
MembersMustExist : Member 'Android.Telephony.CellInfoCdma.CellSignalStrength.get()' does not exist in the implementation but it does exist in the contract.
4+
MembersMustExist : Member 'Android.Telephony.CellInfoGsm.CellIdentity.get()' does not exist in the implementation but it does exist in the contract.
5+
MembersMustExist : Member 'Android.Telephony.CellInfoGsm.CellSignalStrength.get()' does not exist in the implementation but it does exist in the contract.
6+
MembersMustExist : Member 'Android.Telephony.CellInfoLte.CellIdentity.get()' does not exist in the implementation but it does exist in the contract.
7+
MembersMustExist : Member 'Android.Telephony.CellInfoLte.CellSignalStrength.get()' does not exist in the implementation but it does exist in the contract.
8+
MembersMustExist : Member 'Android.Telephony.CellInfoTdscdma.CellIdentity.get()' does not exist in the implementation but it does exist in the contract.
9+
MembersMustExist : Member 'Android.Telephony.CellInfoTdscdma.CellSignalStrength.get()' does not exist in the implementation but it does exist in the contract.
10+
MembersMustExist : Member 'Android.Telephony.CellInfoWcdma.CellIdentity.get()' does not exist in the implementation but it does exist in the contract.
11+
MembersMustExist : Member 'Android.Telephony.CellInfoWcdma.CellSignalStrength.get()' does not exist in the implementation but it does exist in the contract.
12+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuffer.Capacity()' changed from '[RegisterAttribute("capacity", "()I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("capacity", "()I", "")]' in the implementation.
13+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuffer.IndexOf(System.String)' changed from '[RegisterAttribute("indexOf", "(Ljava/lang/String;)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("indexOf", "(Ljava/lang/String;)I", "")]' in the implementation.
14+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuffer.LastIndexOf(System.String)' changed from '[RegisterAttribute("lastIndexOf", "(Ljava/lang/String;)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("lastIndexOf", "(Ljava/lang/String;)I", "")]' in the implementation.
15+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.Capacity()' changed from '[RegisterAttribute("capacity", "()I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("capacity", "()I", "")]' in the implementation.
16+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.CodePointAt(System.Int32)' changed from '[RegisterAttribute("codePointAt", "(I)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("codePointAt", "(I)I", "")]' in the implementation.
17+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.CodePointBefore(System.Int32)' changed from '[RegisterAttribute("codePointBefore", "(I)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("codePointBefore", "(I)I", "")]' in the implementation.
18+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.CodePointCount(System.Int32, System.Int32)' changed from '[RegisterAttribute("codePointCount", "(II)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("codePointCount", "(II)I", "")]' in the implementation.
19+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.EnsureCapacity(System.Int32)' changed from '[RegisterAttribute("ensureCapacity", "(I)V", "", ApiSince=9)]' in the contract to '[RegisterAttribute("ensureCapacity", "(I)V", "")]' in the implementation.
20+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.GetChars(System.Int32, System.Int32, System.Char[], System.Int32)' changed from '[RegisterAttribute("getChars", "(II[CI)V", "", ApiSince=9)]' in the contract to '[RegisterAttribute("getChars", "(II[CI)V", "")]' in the implementation.
21+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.IndexOf(System.String)' changed from '[RegisterAttribute("indexOf", "(Ljava/lang/String;)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("indexOf", "(Ljava/lang/String;)I", "")]' in the implementation.
22+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.IndexOf(System.String, System.Int32)' changed from '[RegisterAttribute("indexOf", "(Ljava/lang/String;I)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("indexOf", "(Ljava/lang/String;I)I", "")]' in the implementation.
23+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.LastIndexOf(System.String)' changed from '[RegisterAttribute("lastIndexOf", "(Ljava/lang/String;)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("lastIndexOf", "(Ljava/lang/String;)I", "")]' in the implementation.
24+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.LastIndexOf(System.String, System.Int32)' changed from '[RegisterAttribute("lastIndexOf", "(Ljava/lang/String;I)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("lastIndexOf", "(Ljava/lang/String;I)I", "")]' in the implementation.
25+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.OffsetByCodePoints(System.Int32, System.Int32)' changed from '[RegisterAttribute("offsetByCodePoints", "(II)I", "", ApiSince=9)]' in the contract to '[RegisterAttribute("offsetByCodePoints", "(II)I", "")]' in the implementation.
26+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.SetCharAt(System.Int32, System.Char)' changed from '[RegisterAttribute("setCharAt", "(IC)V", "", ApiSince=9)]' in the contract to '[RegisterAttribute("setCharAt", "(IC)V", "")]' in the implementation.
27+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.SetLength(System.Int32)' changed from '[RegisterAttribute("setLength", "(I)V", "", ApiSince=9)]' in the contract to '[RegisterAttribute("setLength", "(I)V", "")]' in the implementation.
28+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.Substring(System.Int32)' changed from '[RegisterAttribute("substring", "(I)Ljava/lang/String;", "", ApiSince=9)]' in the contract to '[RegisterAttribute("substring", "(I)Ljava/lang/String;", "")]' in the implementation.
29+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.Substring(System.Int32, System.Int32)' changed from '[RegisterAttribute("substring", "(II)Ljava/lang/String;", "", ApiSince=9)]' in the contract to '[RegisterAttribute("substring", "(II)Ljava/lang/String;", "")]' in the implementation.
30+
CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Java.Lang.StringBuilder.TrimToSize()' changed from '[RegisterAttribute("trimToSize", "()V", "", ApiSince=9)]' in the contract to '[RegisterAttribute("trimToSize", "()V", "")]' in the implementation.
31+

0 commit comments

Comments
 (0)