Commit d471b4a
authored
[Mono.Android] Add NRT annotations. (#4227)
Context: dotnet/java-interop@01d0684
Annotates all API levels of `Mono.Android.dll` with
[C#8 Nullable Reference Type][0] (NRT) annotations, pulled directly
from the Java `.jar` files.
Additionally, our hand written code has been audited and updated to
include NRT annotations.
~~ Notes ~~
There are 8 new warnings caused by this change of the form:
Android.Runtime/JavaDictionary.cs(655,24): warning CS8714: The type 'K' cannot be used as type parameter 'TKey' in the generic type or method 'IDictionary<TKey, TValue>'. Nullability of type argument 'K' doesn't match 'notnull' constraint.
This is due to the BCL being improperly annotated. The change has
since been reverted, but it has not made it into various distribution
packs:
dotnet/runtime#793
There are a considerable number of warnings (~400) caused by
mismatched annotations when members are overridden, such as:
CS8610: Nullability of reference types in type of parameter 'baz' doesn't match overridden member.
While it may be desirable to fix these, it is a non-trivial job that
will be prioritized separately.
In the mean time, this set of warnings has been disabled:
<NoWarn>8609;8610;8614;8617;8613;8764;8765;8766;8767</NoWarn>
Finally, when `$(AndroidGenerateJniMarshalMethods)`=True and
`jnimarshalmethod-gen.exe` is executed, the resulting app was crashing
because `MagicRegistrationMap.CallRegisterMethodByIndex()` had a
parameter change from `int` to `int?`. Fix this by calling
`Nullable<int>.GetValueOrDefault()` with the `switch`.
`MonoDroidMarkStep.UpdateRegistrationSwitch()` now emits IL like:
.method private hidebysig static bool
CallRegisterMethodByIndex([Java.Interop]Java.Interop.JniNativeMethodRegistrationArguments arguments,
[mscorlib]System.Nullable`1<int32> typeIdx) cil managed
{
// Code size 9285 (0x2445)
.maxstack 2
.locals init ([mscorlib]System.Nullable`1<int32> V_0)
IL_0000: ldarg.1
IL_0001: stloc.0
IL_0002: ldloca.s V_0
IL_0004: call instance !0 [mscorlib]System.Nullable`1<int32>::GetValueOrDefault()
IL_0009: switch (
…
Co-authored-by: Radek Doulik <[email protected]>
[0]: https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references1 parent a574834 commit d471b4a
File tree
169 files changed
+1327
-1129
lines changed- Documentation/release-notes
- external
- src
- Mono.Android
- Android.Accounts
- Android.Animation
- Android.App.Admin
- Android.App
- Android.Bluetooth
- Android.Content.Res
- Android.Content
- Android.Graphics
- Android.Hardware.Camera2.Params
- Android.Hardware
- Android.InputMethodServices
- Android.Locations
- Android.Media
- Android.Net.Wifi
- Android.Net
- Android.OS.Storage
- Android.OS
- Android.Preferences
- Android.Runtime
- Android.Telephony
- Android.Text.Format
- Android.Text
- Android.Util
- Android.Views.Accessibility
- Android.Views.InputMethods
- Android.Views
- Android.Widget
- Android
- Java.Interop
- Java.Lang.Reflect
- Java.Lang
- Java.Nio
- Javax.Microedition.Khronos.Egl
- Org.Apache.Http.Impl.Conn
- System.Drawing
- System.Linq
- Xamarin.Android.Net
- Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner
- Xamarin.Android.NamingCustomAttributes
- Android.App
- Android.Content
- Android.Runtime
- Java.Interop
- Xamarin.Android.Tools.JavadocImporter
- tests/api-compatibility
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
169 files changed
+1327
-1129
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
Submodule Java.Interop updated from c19794e to ce8dc40
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
0 commit comments