Skip to content

Commit

Permalink
[Mono.Android] nullability for AndroidMessageHandler.RequestNeedsAuth…
Browse files Browse the repository at this point in the history
…orization (#7454)

Context: https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.membernotnullwhenattribute

The `MemberNotNullWhenAttribute ` annotation allows `RequestedAuthentication` to be used without a
null-check after testing, `RequestNeedsAuthorization`, when nullability analysis is enabled.

* Only apply annotation when building for .NET 7+

Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
  • Loading branch information
mstefarov and jonathanpeppers authored Oct 14, 2022
1 parent 04d3fc9 commit 91669a4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.Linq;
Expand Down Expand Up @@ -233,6 +234,9 @@ public int MaxAutomaticRedirections
/// If <c>true</c> then the server requested authorization and the application must use information
/// found in <see cref="RequestedAuthentication"/> to set the value of <see cref="PreAuthenticationData"/>
/// </summary>
#if NETCOREAPP
[MemberNotNullWhen(true, nameof(RequestedAuthentication))]
#endif
public bool RequestNeedsAuthorization {
get { return RequestedAuthentication?.Count > 0; }
}
Expand Down

0 comments on commit 91669a4

Please sign in to comment.