You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Mono.Android] Enumify API-36.1, API-36.1 is "Stable" (#10515)
Context: http://github.com/jpobst/BindingStudio
Context: #10005
Use jpobst/BindingStudio to begin enumifying API-36.1.
Note: current dotnet/java-interop emits an "extra" `,` on `map.csv`
output, which would make for a "noisy" diff (every line changed!).
The diff size is reduced by removing trailing commas:
sed 's/,$//' < src/Mono.Android/new-map.csv > src/Mono.Android/map.csv
This keeps the diff to a reasonable size.
TODO: update `map.csv` to current BindingStudio output after this
is merged.
Update `build-tools/manifest-attribute-codegen` so that:
1. It can be executed from topdir.
2. Warning message are actually emitted when using `dotnet build`.
Previously, only the fact that the executed command failed would
be printed, but none of the tool output, which was needed!
~~ Stable API-36.1 ~~
Normally when we declare a new API level as "stable", it is the
*only* API that is built.
For API-36.1, this is not the case: we want to continue building
API-36, *and also* build API-36.1, *and also* using the the API-36.1
build artifacts doesn't require `$(EnablePreviewFeatures)`=true.
Mirror #10005:
* build both API levels by "repurposing" the
`$(AndroidLatestUnstable*)` MSBuild properties as an
"alternate set" of stable API levels.
* What "really" indicates a `Mono.Android.dll` is unstable is the
presence of `ANDROID_UNSTABLE` when building it.
This is conditional on `$(IsUnstableVersion)`.
Update `$(IsUnstableVersion)` so that it uses the
[MSBuild version-comparison functions][0] to compare
`$(AndroidApiLevel)` against `$(AndroidLatestStableApiLevel)`
(previous behavior) *and also* against
`$(AndroidLatestStableApiLevel2)` (new property).
This allows API-36.1 to be built via the `*Unstable*` properties
while not defining `ANDROID_UNSTABLE.`
~~ Fix assertion failure in <CheckApiCompatibility/> ~~
When attempting to declare API-36.1 as the latest stable API,
my local (Debug) build promptly started *crashing*.
Which was rather unexpected.
The most useful lesson in this context: *do not* call
`Debug.Assert()` or throw exceptions from code which is called from
the Thread Pool. `Debug.Assert()` -- in Debug config builds -- will
immediately exit the process, which in turn means that MSBuild `binlog`
output is *incomplete*, as MSBuild never gets a chance to flush
everything (courtesy of the process aborting!).
Throwing an exception is very similar: unhandled exceptions on the
thread pool cause the process to abort. MSBuild never has a chance
to write complete binlog data.
Plumb logging through to `CodeGenDiff` so that the assertion failure
can instead become an "Internal Error" message. This fixes the crash.
Then there's the matter of the former assertion failure now error
message: why was `currentObject.InternalCounter` negative?
`currentObject.InternalCounter` was negative because of this line
(newlines added for readability, but it's all one line):
public static void AddEventHandler<TInterface, TImplementor>(
[System.Runtime.CompilerServices.NullableAttribute((byte)2)] ref System.WeakReference? implementor,
System.Func<TImplementor> creator,
System.Action<TInterface> setListener,
System.Action<TImplementor> add)
where TInterface : class
where TImplementor : Java.Lang.Object, TInterface
{
}
The `where TInterface : class ` was matching this check:
content.IndexOf (" class ", StringComparison.Ordinal)
and thus the method was being interpreted as the introduction of
a new type declaration instead of something to add to the existing
`currentObject` scope. This meant that the new
`currentObject.InternalCounter` was 0, then we hit `}` to decrement
`.InternalCounter`, resulting in a negative value.
Fix this by checking for ` partial class `, as was done previously
with ` partial struct `, as `Microsoft.DotNet.GenAPI.dll` always
emits the `partial` modifier on everything except `enum`s.
This fixes the now internal error message former assertion.
[0]: https://learn.microsoft.com/en-us/visualstudio/msbuild/property-functions?iew=vs-2022#msbuild-version-comparison-functions
- Use the DropDown in the middle to select the enum to use
388
-
- When selected, the members of that enum will be shown in the box below the enum
389
-
- Alternatively, search for a enum by enum member name using the Search box in the right
390
-
- If desired enum is found, clicking it will populate dropdown
391
-
- Click "Save"
534
+
* `//attr/@path` is the XPath expression to the parameter to update
535
+
* `//attr/@name` the XML attribute to update. For return types, this is `type`.
536
+
* The value of the `<attr/>` is `Android.Graphics.Color`.
392
537
393
-
Use `File` -> `Save` to save your work often!
394
538
395
539
### Finishing the method map
396
540
397
541
The official `methodmap.csv` uses a slightly different format than the one used for enumification.
398
542
399
543
Using BindingStudio:
544
+
400
545
- Ensure the "new api level method map" CSV file is loaded.
401
546
- Choose `Tools` -> `Export Final Method Map`
402
547
- Choose a temporary file name
@@ -405,26 +550,41 @@ Using BindingStudio:
405
550
406
551
Congrats! Enumification is complete!
407
552
408
-
---- Somewhat outdated docs below, update when we do this year's stabilization ----
553
+
But wait, there's more!
554
+
555
+
### New `AndroidManifest.xml` elements and attributes
409
556
410
-
6) new AndroidManifest.xml elements and attributes
557
+
`build-tools/manifest-attribute-codegen/manifest-attribute-codegen.cs` can be
558
+
compiled to a tool that collects all Manifest elements and attributes with the
559
+
API level since when each of them became available. New members are supposed
560
+
to be added to the existing `(FooBar)Attribute.cs` and
561
+
`(FooBar)Attribute.Partial.cs`in`src/Mono.Android` and
562
+
`src/Xamarin.Android.Build.Tasks`, respectively.
411
563
412
-
`build-tools/manifest-attribute-codegen/manifest-attribute-codegen.cs` can be compiled to a tool that collects all Manifest elements and attributes with the API level since when each of them became available. New members are supposed to be added to the existing `(FooBar)Attribute.cs` and `(FooBar)Attribute.Partial.cs`in`src/Mono.Android` and `src/Xamarin.Android.Build.Tasks` respectively.
564
+
See [`build-tools/manifest-attribute-codegen/README.md`](../../build-tools/manifest-attribute-codegen/README.md)
565
+
for details.
413
566
414
-
Note that there are documented and undocumented XML nodes, and we don't have to deal with undocumented ones.
567
+
Note that there are documented and undocumented XML nodes, and we don't have to
These sre located in [Xamarin.Android.Common.props.in](../../src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in). The following MSBuild properties need to be updated to ensure
Defaults to `$(XABuildToolsFolder)` within `Configuration.props`.
581
+
* `$(AndroidSdkPlatformToolsVersion)`: Android SDK `platform-tools` version
582
+
Defaults to `$(XAPlatformToolsVersion)` within `Configuration.props`.
422
583
423
-
`AndroidSdkBuildToolsVersion`
424
-
`AndroidSdkPlatformToolsVersion`
425
-
`AndroidSdkToolsVersion`
584
+
The major version should generally match the new API level. For Android P this will be 28.x.x . If a version which exactly matches the API Level is not available then the latest version should be used.
426
585
427
-
The major version should match the new API level. For Android P this will be 28.x.x . If a version which exactly matches the API Level is not available then the latest version should be used.
586
+
A separate PR should be created which bumps the values within `Configuration.props`
Copy file name to clipboardExpand all lines: build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs
LogError($"CheckApiCompatibility found nonacceptable Api breakages for ApiLevel: {ApiLevel}.{Environment.NewLine}{string.Join(Environment.NewLine,lines)}");
0 commit comments