Skip to content

Commit a1fab8b

Browse files
[Xamarin.Android.Build.Tasks] fix NRT warnings & other warnings (#9483)
Introduces the setting to `Xamarin.Android.Build.Tasks.csproj`: <WarningsAsErrors>Nullable</WarningsAsErrors> Then I fixed the existing warnings. Down the road this will make it easier to adopt `#enable nullable`, and eventually `Nullable=enable` the entire project. Trying to do that now results in 1,000+ warnings... Most of these are types that could easily be null, and they weren't marked as nullable with `?`. Luckily, the code appears to be checking for null in these places already. For `*Attribute` types that need `IJniNameProviderAttribute.Name`, I explicitly implemented a non-nullable version of this property in `*Attribute.Partial.cs` files.
1 parent 7cb783c commit a1fab8b

29 files changed

+73
-28
lines changed

src/Xamarin.Android.Build.Tasks/Mono.Android/ActivityAttribute.Partial.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ namespace Android.App {
1616

1717
partial class ActivityAttribute {
1818

19-
string _ParentActivity;
20-
TypeDefinition type;
21-
ICollection<string> specified;
19+
string? _ParentActivity;
20+
TypeDefinition? type;
21+
ICollection<string>? specified;
2222

2323
static partial void AddManualMapping ()
2424
{

src/Xamarin.Android.Build.Tasks/Mono.Android/ApplicationAttribute.Partial.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ namespace Android.App {
1818

1919
partial class ApplicationAttribute {
2020

21-
string _BackupAgent;
22-
ICustomAttributeProvider provider;
21+
string? _BackupAgent;
22+
ICustomAttributeProvider? provider;
2323

24-
ICollection<string> specified;
24+
ICollection<string>? specified;
2525

2626
static partial void AddManualMapping ()
2727
{

src/Xamarin.Android.Build.Tasks/Mono.Android/BroadcastReceiverAttribute.Partial.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Android.Content {
1212

1313
partial class BroadcastReceiverAttribute {
1414

15-
ICollection<string> specified;
15+
ICollection<string>? specified;
1616

1717
public static BroadcastReceiverAttribute FromTypeDefinition (TypeDefinition type, TypeDefinitionCache cache)
1818
{

src/Xamarin.Android.Build.Tasks/Mono.Android/ContentProviderAttribute.Partial.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static string[] ToStringArray (object value)
2828
return values.Select (v => (string) v.Value).ToArray ();
2929
}
3030

31-
ICollection<string> specified;
31+
ICollection<string>? specified;
3232

3333
public static ContentProviderAttribute FromTypeDefinition (TypeDefinition type, TypeDefinitionCache cache)
3434
{

src/Xamarin.Android.Build.Tasks/Mono.Android/GrantUriPermissionAttribute.Partial.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Android.Content {
1212

1313
partial class GrantUriPermissionAttribute {
1414

15-
ICollection<string> specified;
15+
ICollection<string>? specified;
1616

1717
public static IEnumerable<GrantUriPermissionAttribute> FromTypeDefinition (TypeDefinition type, TypeDefinitionCache cache)
1818
{

src/Xamarin.Android.Build.Tasks/Mono.Android/InstrumentationAttribute.Partial.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Android.App {
1212

1313
partial class InstrumentationAttribute {
1414

15-
ICollection<string> specified;
15+
ICollection<string>? specified;
1616

1717
public static IEnumerable<InstrumentationAttribute> FromCustomAttributeProvider (ICustomAttributeProvider provider, TypeDefinitionCache cache)
1818
{

src/Xamarin.Android.Build.Tasks/Mono.Android/LayoutAttribute.Partial.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace Android.App
1717

1818
partial class LayoutAttribute
1919
{
20-
TypeDefinition type;
21-
ICollection<string> specified;
20+
TypeDefinition? type;
21+
ICollection<string>? specified;
2222

2323
public static LayoutAttribute FromTypeDefinition (TypeDefinition type, TypeDefinitionCache cache)
2424
{

src/Xamarin.Android.Build.Tasks/Mono.Android/MetaDataAttribute.Partial.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Android.App {
1212

1313
partial class MetaDataAttribute {
1414

15-
ICollection<string> specified;
15+
ICollection<string>? specified;
1616

1717
public static IEnumerable<MetaDataAttribute> FromCustomAttributeProvider (ICustomAttributeProvider type, TypeDefinitionCache cache)
1818
{

src/Xamarin.Android.Build.Tasks/Mono.Android/PermissionAttribute.Partial.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Android.App {
1717

1818
partial class PermissionAttribute {
1919

20-
ICollection<string> specified;
20+
ICollection<string>? specified;
2121

2222
public static IEnumerable<PermissionAttribute> FromCustomAttributeProvider (ICustomAttributeProvider provider, TypeDefinitionCache cache)
2323
{

src/Xamarin.Android.Build.Tasks/Mono.Android/PermissionGroupAttribute.Partial.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Android.App {
1717

1818
partial class PermissionGroupAttribute {
1919

20-
ICollection<string> specified;
20+
ICollection<string>? specified;
2121

2222
public static IEnumerable<PermissionGroupAttribute> FromCustomAttributeProvider (ICustomAttributeProvider provider, TypeDefinitionCache cache)
2323
{

0 commit comments

Comments
 (0)