Skip to content

Commit f308554

Browse files
authored
[xabt] Enable nullable in LayoutAttribute.Partial.cs (#12326)
`LayoutAttribute.FromTypeDefinition()` can legitimately return `null` when no layout attribute exists, but its file disabled nullable analysis. - Enable nullable reference type analysis for the file. - Mark the factory return type and `SingleOrDefault()` result as nullable. - Preserve the existing null-handling behavior. - Fixes #12325
1 parent e6a55b4 commit f308554

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#nullable disable
1+
#nullable enable
22

33
using System;
44
using System.Collections.Generic;
@@ -22,9 +22,9 @@ partial class LayoutAttribute
2222
TypeDefinition? type;
2323
ICollection<string>? specified;
2424

25-
public static LayoutAttribute FromTypeDefinition (TypeDefinition type, TypeDefinitionCache cache)
25+
public static LayoutAttribute? FromTypeDefinition (TypeDefinition type, TypeDefinitionCache cache)
2626
{
27-
CustomAttribute attr = type.GetCustomAttributes ("Android.App.LayoutAttribute")
27+
CustomAttribute? attr = type.GetCustomAttributes ("Android.App.LayoutAttribute")
2828
.SingleOrDefault ();
2929
if (attr == null)
3030
return null;

0 commit comments

Comments
 (0)