Commit 79a0141
authored
Return a default for unknown API levels (#90)
Context: dotnet/android#4873
Context: dotnet/android#4873 (comment)
When xamarin-android is built to support .NET 5, the .NET 5 install
directory contains a single `AndroidApiInfo.xml` file:
<AndroidApiInfo>
<Id>30</Id>
<Level>30</Level>
<Name>R</Name>
<Version>v11.0</Version>
<Stable>True</Stable>
</AndroidApiInfo>
`AndroidVersions`, meanwhile, is setup to read a *set* of
`AndroidApiInfo.xml` files (aad97f1) to "dynamically" compute mappings
between possible `$(TargetFrameworkVersion)` values, API-levels, and
IDs for those API levels.
When there is only one such file, if you call:
int? apiLevel = androidVersions.GetApiLevelFromId (29);
then `apiLevel` will always be `null`, because (at present)
`AndroidVersions.KnownVersions` doesn't know about API-29 or API-30.
We *could* update `AndroidVersions.KnownVersions` to contain entries
for API-29 & API-30, but doing so means that we reintroduce the
scenario that `AndroidVersions` was added to help defend against: a
need/requirement to update `AndroidVersions.KnownVersions` *every time*
a new API level was released, lest ~everything break.
We *don't* want to require `AndroidVersions.KnownVersions` updates.
To allow a .NET 5-like environment to work *without* updating
`KnownVersions`, update the various `GetApiLevelFromId()` methods to
return the incoming API level as a fallback. If `"29"` comes in, then
`29` can be returned and assumed to be a valid API level.1 parent 3974fc3 commit 79a0141
File tree
2 files changed
+9
-6
lines changed- src/Xamarin.Android.Tools.AndroidSdk
- tests/Xamarin.Android.Tools.AndroidSdk-Tests
2 files changed
+9
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
| 109 | + | |
| 110 | + | |
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
| |||
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
118 | | - | |
| 120 | + | |
| 121 | + | |
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
207 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| |||
0 commit comments