Nullability annotations on NSUrl (#15356)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com> Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
This commit is contained in:
Родитель
6f2a34c1d7
Коммит
4b86732da5
|
@ -49,13 +49,14 @@ namespace Foundation {
|
|||
// Converts from an NSURL to a System.Uri
|
||||
public static implicit operator Uri? (NSUrl? url)
|
||||
{
|
||||
if (url is null) {
|
||||
if (url?.AbsoluteString is not string absoluteUrl) {
|
||||
return null;
|
||||
}
|
||||
if (Uri.TryCreate (url.AbsoluteString, UriKind.Absolute, out var uri))
|
||||
|
||||
if (Uri.TryCreate (absoluteUrl, UriKind.Absolute, out var uri))
|
||||
return uri;
|
||||
else
|
||||
return new Uri (url.AbsoluteString, UriKind.Relative);
|
||||
return new Uri (absoluteUrl, UriKind.Relative);
|
||||
}
|
||||
|
||||
public static implicit operator NSUrl? (Uri? uri)
|
||||
|
|
|
@ -711,15 +711,12 @@ namespace Foundation {
|
|||
return null;
|
||||
}
|
||||
|
||||
void UpdateManagedCookieContainer (NSUrl url, NSHttpCookie[] cookies)
|
||||
void UpdateManagedCookieContainer (Uri absoluteUri, NSHttpCookie[] cookies)
|
||||
{
|
||||
var uri = new Uri (url.AbsoluteString);
|
||||
if (sessionHandler.cookieContainer is not null && cookies.Length > 0)
|
||||
lock (sessionHandler.inflightRequestsLock) { // ensure we lock when writing to the collection
|
||||
var cookiesContents = new string [cookies.Length];
|
||||
for (var index = 0; index < cookies.Length; index++)
|
||||
cookiesContents [index] = cookies [index].GetHeaderValue ();
|
||||
sessionHandler.cookieContainer.SetCookies (uri, string.Join (',', cookiesContents)); // as per docs: The contents of an HTTP set-cookie header as returned by a HTTP server, with Cookie instances delimited by commas.
|
||||
var cookiesContents = Array.ConvertAll(cookies, static cookie => cookie.GetHeaderValue());
|
||||
sessionHandler.cookieContainer.SetCookies (absoluteUri, string.Join (',', cookiesContents)); // as per docs: The contents of an HTTP set-cookie header as returned by a HTTP server, with Cookie instances delimited by commas.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,6 +731,7 @@ namespace Foundation {
|
|||
try {
|
||||
var urlResponse = (NSHttpUrlResponse)response;
|
||||
var status = (int)urlResponse.StatusCode;
|
||||
var absoluteUri = new Uri(urlResponse.Url.AbsoluteString!);
|
||||
|
||||
var content = new NSUrlSessionDataTaskStreamContent (inflight.Stream, () => {
|
||||
if (!inflight.Completed) {
|
||||
|
@ -751,7 +749,7 @@ namespace Foundation {
|
|||
Content = content,
|
||||
RequestMessage = inflight.Request
|
||||
};
|
||||
httpResponse.RequestMessage.RequestUri = new Uri (urlResponse.Url.AbsoluteString);
|
||||
httpResponse.RequestMessage.RequestUri = absoluteUri;
|
||||
|
||||
foreach (var v in urlResponse.AllHeaderFields) {
|
||||
// NB: Cocoa trolling us so hard by giving us back dummy dictionary entries
|
||||
|
@ -768,7 +766,7 @@ namespace Foundation {
|
|||
// cookie container. Once we have the cookies from the response, we need to update the managed cookie container
|
||||
if (session.Configuration.HttpCookieStorage is not null) {
|
||||
var cookies = session.Configuration.HttpCookieStorage.CookiesForUrl (response.Url);
|
||||
UpdateManagedCookieContainer (response.Url, cookies);
|
||||
UpdateManagedCookieContainer (absoluteUri, cookies);
|
||||
for (var index = 0; index < cookies.Length; index++) {
|
||||
httpResponse.Headers.TryAddWithoutValidation (SetCookie, cookies [index].GetHeaderValue ());
|
||||
}
|
||||
|
|
|
@ -5760,18 +5760,23 @@ namespace Foundation
|
|||
NSUrl _FromStringRelative (string url, NSUrl relative);
|
||||
|
||||
[Export ("absoluteString")]
|
||||
[NullAllowed]
|
||||
string AbsoluteString { get; }
|
||||
|
||||
[Export ("absoluteURL")]
|
||||
[NullAllowed]
|
||||
NSUrl AbsoluteUrl { get; }
|
||||
|
||||
[Export ("baseURL")]
|
||||
[NullAllowed]
|
||||
NSUrl BaseUrl { get; }
|
||||
|
||||
[Export ("fragment")]
|
||||
[NullAllowed]
|
||||
string Fragment { get; }
|
||||
|
||||
[Export ("host")]
|
||||
[NullAllowed]
|
||||
string Host { get; }
|
||||
|
||||
[Internal]
|
||||
|
@ -5789,42 +5794,54 @@ namespace Foundation
|
|||
[Deprecated (PlatformName.WatchOS, 6,0, message: "Always return 'null'. Use and parse 'Path' instead.")]
|
||||
[Deprecated (PlatformName.TvOS, 13,0, message: "Always return 'null'. Use and parse 'Path' instead.")]
|
||||
[Export ("parameterString")]
|
||||
[NullAllowed]
|
||||
string ParameterString { get;}
|
||||
|
||||
[Export ("password")]
|
||||
[NullAllowed]
|
||||
string Password { get;}
|
||||
|
||||
[Export ("path")]
|
||||
[NullAllowed]
|
||||
string Path { get;}
|
||||
|
||||
[Export ("query")]
|
||||
[NullAllowed]
|
||||
string Query { get;}
|
||||
|
||||
[Export ("relativePath")]
|
||||
[NullAllowed]
|
||||
string RelativePath { get;}
|
||||
|
||||
[Export ("pathComponents")]
|
||||
[NullAllowed]
|
||||
string [] PathComponents { get; }
|
||||
|
||||
[Export ("lastPathComponent")]
|
||||
[NullAllowed]
|
||||
string LastPathComponent { get; }
|
||||
|
||||
[Export ("pathExtension")]
|
||||
[NullAllowed]
|
||||
string PathExtension { get; }
|
||||
|
||||
[Export ("relativeString")]
|
||||
string RelativeString { get;}
|
||||
|
||||
[Export ("resourceSpecifier")]
|
||||
[NullAllowed]
|
||||
string ResourceSpecifier { get;}
|
||||
|
||||
[Export ("scheme")]
|
||||
[NullAllowed]
|
||||
string Scheme { get;}
|
||||
|
||||
[Export ("user")]
|
||||
[NullAllowed]
|
||||
string User { get;}
|
||||
|
||||
[Export ("standardizedURL")]
|
||||
[NullAllowed]
|
||||
NSUrl StandardizedUrl { get; }
|
||||
|
||||
[Export ("URLByAppendingPathComponent:isDirectory:")]
|
||||
|
@ -5871,6 +5888,7 @@ namespace Foundation
|
|||
[NoiOS][NoMacCatalyst][NoWatch][NoTV]
|
||||
[Export ("URLFromPasteboard:")]
|
||||
[Static]
|
||||
[return: NullAllowed]
|
||||
NSUrl FromPasteboard (NSPasteboard pasteboard);
|
||||
|
||||
[NoiOS][NoMacCatalyst][NoWatch][NoTV]
|
||||
|
@ -5890,9 +5908,11 @@ namespace Foundation
|
|||
bool WriteBookmarkData (NSData data, NSUrl bookmarkFileUrl, NSUrlBookmarkCreationOptions options, out NSError error);
|
||||
|
||||
[Export("filePathURL")]
|
||||
[NullAllowed]
|
||||
NSUrl FilePathUrl { get; }
|
||||
|
||||
[Export("fileReferenceURL")]
|
||||
[NullAllowed]
|
||||
NSUrl FileReferenceUrl { get; }
|
||||
|
||||
[Export ("getResourceValue:forKey:error:"), Internal]
|
||||
|
|
|
@ -1117,11 +1117,6 @@
|
|||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::AppendPathExtension(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::CreateFileUrl(System.String[])' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::FromBookmarkData(Foundation.NSData,Foundation.NSUrlBookmarkResolutionOptions,Foundation.NSUrl,System.Boolean&,Foundation.NSError&)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_AbsoluteUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_BaseUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_FilePathUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_FileReferenceUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_StandardizedUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::RemoveLastPathComponent()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::RemovePathExtension()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::ResolveAlias(Foundation.NSUrl,Foundation.NSUrlBookmarkResolutionOptions,Foundation.NSError&)' is missing an [NullAllowed] on return type
|
||||
|
@ -1208,18 +1203,6 @@
|
|||
!missing-null-allowed! 'System.String Foundation.NSTimeZone::Abbreviation()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSTimeZone::Abbreviation(Foundation.NSDate)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSTimeZone::GetLocalizedName(Foundation.NSTimeZoneNameStyle,Foundation.NSLocale)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_AbsoluteString()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Fragment()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Host()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_LastPathComponent()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Password()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Path()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_PathExtension()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Query()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_RelativePath()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_ResourceSpecifier()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Scheme()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_User()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrlComponents::AsString()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrlCredential::get_Password()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrlCredential::get_User()' is missing an [NullAllowed] on return type
|
||||
|
@ -1245,7 +1228,6 @@
|
|||
!missing-null-allowed! 'System.String[] Foundation.NSOrthography::LanguagesForScript(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String[] Foundation.NSTextCheckingResult::get_AlternativeStrings()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String[] Foundation.NSTextCheckingResult::get_GrammarDetails()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String[] Foundation.NSUrl::get_PathComponents()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String[] Foundation.NSUserDefaults::StringArrayForKey(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.Void Foundation.NSArray::SetValueForKey(Foundation.NSObject,Foundation.NSString)' is missing an [NullAllowed] on parameter #0
|
||||
!missing-null-allowed! 'System.Void Foundation.NSCalendar::set_Locale(Foundation.NSLocale)' is missing an [NullAllowed] on parameter #0
|
||||
|
|
|
@ -614,7 +614,6 @@
|
|||
!missing-null-allowed! 'Foundation.NSUrl AppKit.NSWorkspace::UrlForApplication(Foundation.NSUrl)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl AppKit.NSWorkspace::UrlForApplication(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSBundle::GetUrlForImageResource(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::FromPasteboard(AppKit.NSPasteboard)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl[] AppKit.NSDocumentController::UrlsFromRunningOpenPanel()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl[] AppKit.NSSharingService::get_AttachmentFileUrls()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'ObjCRuntime.Class AppKit.NSDocumentController::DocumentClassForType(System.String)' is missing an [NullAllowed] on return type
|
||||
|
|
|
@ -1129,11 +1129,6 @@
|
|||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::AppendPathExtension(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::CreateFileUrl(System.String[])' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::FromBookmarkData(Foundation.NSData,Foundation.NSUrlBookmarkResolutionOptions,Foundation.NSUrl,System.Boolean&,Foundation.NSError&)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_AbsoluteUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_BaseUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_FilePathUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_FileReferenceUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::get_StandardizedUrl()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::RemoveLastPathComponent()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::RemovePathExtension()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::ResolveAlias(Foundation.NSUrl,Foundation.NSUrlBookmarkResolutionOptions,Foundation.NSError&)' is missing an [NullAllowed] on return type
|
||||
|
@ -1220,18 +1215,6 @@
|
|||
!missing-null-allowed! 'System.String Foundation.NSTimeZone::Abbreviation()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSTimeZone::Abbreviation(Foundation.NSDate)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSTimeZone::GetLocalizedName(Foundation.NSTimeZoneNameStyle,Foundation.NSLocale)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_AbsoluteString()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Fragment()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Host()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_LastPathComponent()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Password()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Path()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_PathExtension()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Query()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_RelativePath()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_ResourceSpecifier()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_Scheme()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrl::get_User()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrlComponents::AsString()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrlCredential::get_Password()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String Foundation.NSUrlCredential::get_User()' is missing an [NullAllowed] on return type
|
||||
|
@ -1257,7 +1240,6 @@
|
|||
!missing-null-allowed! 'System.String[] Foundation.NSOrthography::LanguagesForScript(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String[] Foundation.NSTextCheckingResult::get_AlternativeStrings()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String[] Foundation.NSTextCheckingResult::get_GrammarDetails()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String[] Foundation.NSUrl::get_PathComponents()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.String[] Foundation.NSUserDefaults::StringArrayForKey(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'System.Void Foundation.NSArray::SetValueForKey(Foundation.NSObject,Foundation.NSString)' is missing an [NullAllowed] on parameter #0
|
||||
!missing-null-allowed! 'System.Void Foundation.NSCalendar::set_Locale(Foundation.NSLocale)' is missing an [NullAllowed] on parameter #0
|
||||
|
|
|
@ -718,7 +718,6 @@
|
|||
!missing-null-allowed! 'Foundation.NSUrl AppKit.NSWorkspace::UrlForApplication(Foundation.NSUrl)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl AppKit.NSWorkspace::UrlForApplication(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSBundle::GetUrlForImageResource(System.String)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl Foundation.NSUrl::FromPasteboard(AppKit.NSPasteboard)' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl[] AppKit.NSDocumentController::UrlsFromRunningOpenPanel()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'Foundation.NSUrl[] AppKit.NSSharingService::get_AttachmentFileUrls()' is missing an [NullAllowed] on return type
|
||||
!missing-null-allowed! 'ObjCRuntime.Class AppKit.NSDocumentController::DocumentClassForType(System.String)' is missing an [NullAllowed] on return type
|
||||
|
|
Загрузка…
Ссылка в новой задаче