diff --git a/src/Playwright/Core/APIResponse.cs b/src/Playwright/Core/APIResponse.cs index 236e7c6ce..47e053ed0 100644 --- a/src/Playwright/Core/APIResponse.cs +++ b/src/Playwright/Core/APIResponse.cs @@ -94,7 +94,7 @@ public async Task TextAsync() internal async Task FetchLogAsync() { var response = await _context.SendMessageToServerAsync("fetchLog", new Dictionary { ["fetchUid"] = FetchUid() }).ConfigureAwait(false); - return response.Value.GetProperty("log").ToObject(); + return response!.Value.GetProperty("log").ToObject(); } public ValueTask DisposeAsync() => new(_context.SendMessageToServerAsync("disposeAPIResponse", new Dictionary { ["fetchUid"] = FetchUid() })); diff --git a/src/Playwright/Core/ElementHandle.cs b/src/Playwright/Core/ElementHandle.cs index 44f3ab0d8..d27d91270 100644 --- a/src/Playwright/Core/ElementHandle.cs +++ b/src/Playwright/Core/ElementHandle.cs @@ -120,7 +120,7 @@ public async Task ScreenshotAsync(ElementHandleScreenshotOptions? option }).ToArray(); } - var result = (await SendMessageToServerAsync("screenshot", args).ConfigureAwait(false)).Value.GetProperty("binary").GetBytesFromBase64(); + var result = (await SendMessageToServerAsync("screenshot", args).ConfigureAwait(false))!.Value.GetProperty("binary").GetBytesFromBase64(); if (!string.IsNullOrEmpty(options.Path)) { @@ -161,7 +161,7 @@ public Task ScrollIntoViewIfNeededAsync(ElementHandleScrollIntoViewIfNeededOptio public async Task BoundingBoxAsync() { - var result = (await SendMessageToServerAsync("boundingBox").ConfigureAwait(false)).Value; + var result = (await SendMessageToServerAsync("boundingBox").ConfigureAwait(false))!.Value; if (result.TryGetProperty("value", out var value)) { return value.ToObject(); @@ -303,9 +303,9 @@ public Task DispatchEventAsync(string type, object? eventInit = null) return null; } - public async Task InnerHTMLAsync() => (await SendMessageToServerAsync("innerHTML").ConfigureAwait(false)).Value.GetProperty("value").ToString(); + public async Task InnerHTMLAsync() => (await SendMessageToServerAsync("innerHTML").ConfigureAwait(false))!.Value.GetProperty("value").ToString(); - public async Task InnerTextAsync() => (await SendMessageToServerAsync("innerText").ConfigureAwait(false)).Value.GetProperty("value").ToString(); + public async Task InnerTextAsync() => (await SendMessageToServerAsync("innerText").ConfigureAwait(false))!.Value.GetProperty("value").ToString(); public async Task TextContentAsync() => (await SendMessageToServerAsync("textContent").ConfigureAwait(false))?.GetProperty("value").ToString(); @@ -353,7 +353,7 @@ private async Task> _selectOptionAsync(IEnumerable(); + }).ConfigureAwait(false))!.Value.GetProperty("values").ToObject(); } private async Task> _selectOptionAsync(IEnumerable values, bool? noWaitAfter, bool? force, float? timeout) @@ -363,7 +363,7 @@ private async Task> _selectOptionAsync(IEnumerable(); + }).ConfigureAwait(false))!.Value.GetProperty("values").ToObject(); } public Task CheckAsync(ElementHandleCheckOptions? options = default) @@ -407,7 +407,7 @@ public Task TapAsync(ElementHandleTapOptions? options = default) public async Task IsVisibleAsync() => (await SendMessageToServerAsync("isVisible").ConfigureAwait(false))?.GetProperty("value").GetBoolean() ?? default; public async Task InputValueAsync(ElementHandleInputValueOptions? options = null) - => (await SendMessageToServerAsync("inputValue").ConfigureAwait(false)).Value.GetProperty("value").ToString(); + => (await SendMessageToServerAsync("inputValue").ConfigureAwait(false))!.Value.GetProperty("value").ToString(); public Task SetCheckedAsync(bool checkedState, ElementHandleSetCheckedOptions? options = null) => SendMessageToServerAsync(checkedState ? "check" : "uncheck", new Dictionary diff --git a/src/Playwright/Core/Frame.cs b/src/Playwright/Core/Frame.cs index 98a04aec7..de92b0901 100644 --- a/src/Playwright/Core/Frame.cs +++ b/src/Playwright/Core/Frame.cs @@ -162,7 +162,7 @@ public IFrameLocator FrameLocator(string selector) => new FrameLocator(this, selector); [MethodImpl(MethodImplOptions.NoInlining)] - public async Task TitleAsync() => (await SendMessageToServerAsync("title").ConfigureAwait(false)).Value.GetProperty("value").ToString(); + public async Task TitleAsync() => (await SendMessageToServerAsync("title").ConfigureAwait(false))!.Value.GetProperty("value").ToString(); [MethodImpl(MethodImplOptions.NoInlining)] public Task WaitForTimeoutAsync(float timeout) @@ -194,7 +194,7 @@ public async Task> SelectOptionAsync(string selector, IEnu ["strict"] = options?.Strict, ["force"] = options?.Force, ["timeout"] = Timeout(options?.Timeout), - }).ConfigureAwait(false)).Value.GetProperty("values").ToObject().ToList().AsReadOnly(); + }).ConfigureAwait(false))!.Value.GetProperty("values").ToObject().ToList().AsReadOnly(); [MethodImpl(MethodImplOptions.NoInlining)] public Task> SelectOptionAsync(string selector, SelectOptionValue values, FrameSelectOptionOptions? options = default) @@ -215,7 +215,7 @@ internal async Task> SelectOptionAsync(string selector, IE ["strict"] = options?.Strict, ["force"] = options?.Force, ["timeout"] = Timeout(options?.Timeout), - }).ConfigureAwait(false)).Value.GetProperty("values").ToObject().ToList().AsReadOnly(); + }).ConfigureAwait(false))!.Value.GetProperty("values").ToObject().ToList().AsReadOnly(); [MethodImpl(MethodImplOptions.NoInlining)] public async Task WaitForLoadStateAsync(LoadState? state = default, FrameWaitForLoadStateOptions? options = default) @@ -364,12 +364,12 @@ internal async Task QueryCountAsync(string selector) { ["selector"] = selector, }).ConfigureAwait(false); - return result.Value.GetProperty("value").GetInt32(); + return result!.Value.GetProperty("value").GetInt32(); } [MethodImpl(MethodImplOptions.NoInlining)] public async Task ContentAsync() - => (await SendMessageToServerAsync("content").ConfigureAwait(false)).Value.GetProperty("value").ToString(); + => (await SendMessageToServerAsync("content").ConfigureAwait(false))!.Value.GetProperty("value").ToString(); [MethodImpl(MethodImplOptions.NoInlining)] public Task FocusAsync(string selector, FrameFocusOptions? options = default) @@ -414,7 +414,7 @@ public async Task InnerHTMLAsync(string selector, FrameInnerHTMLOptions? ["selector"] = selector, ["timeout"] = Timeout(options?.Timeout), ["strict"] = options?.Strict, - }).ConfigureAwait(false)).Value.GetProperty("value").ToString(); + }).ConfigureAwait(false))!.Value.GetProperty("value").ToString(); [MethodImpl(MethodImplOptions.NoInlining)] public async Task InnerTextAsync(string selector, FrameInnerTextOptions? options = default) @@ -423,7 +423,7 @@ public async Task InnerTextAsync(string selector, FrameInnerTextOptions? ["selector"] = selector, ["timeout"] = Timeout(options?.Timeout), ["strict"] = options?.Strict, - }).ConfigureAwait(false)).Value.GetProperty("value").ToString(); + }).ConfigureAwait(false))!.Value.GetProperty("value").ToString(); [MethodImpl(MethodImplOptions.NoInlining)] public async Task TextContentAsync(string selector, FrameTextContentOptions? options = default) @@ -654,7 +654,7 @@ public async Task InputValueAsync(string selector, FrameInputValueOption ["selector"] = selector, ["timeout"] = Timeout(options?.Timeout), ["strict"] = options?.Strict, - }).ConfigureAwait(false)).Value.GetProperty("value").ToString(); + }).ConfigureAwait(false))!.Value.GetProperty("value").ToString(); [MethodImpl(MethodImplOptions.NoInlining)] public async Task QuerySelectorAsync(string selector) @@ -944,8 +944,8 @@ internal async Task ExpectAsync(string? selector, string expr ["isNot"] = options.IsNot, ["timeout"] = options.Timeout, }).ConfigureAwait(false); - var parsed = result.Value.ToObject(); - if (result.Value.TryGetProperty("received", out var received) && received.ValueKind == JsonValueKind.Object) + var parsed = result!.Value.ToObject(); + if (result!.Value.TryGetProperty("received", out var received) && received.ValueKind == JsonValueKind.Object) { if (received.TryGetProperty("value", out var receivedValue)) { diff --git a/src/Playwright/Core/JSHandle.cs b/src/Playwright/Core/JSHandle.cs index 3c6ab27b2..3df0f2909 100644 --- a/src/Playwright/Core/JSHandle.cs +++ b/src/Playwright/Core/JSHandle.cs @@ -90,7 +90,7 @@ public async Task GetPropertyAsync(string propertyName) => await Send public async Task> GetPropertiesAsync() { var result = new Dictionary(); - var channelResult = (await SendMessageToServerAsync("getPropertyList").ConfigureAwait(false)).Value + var channelResult = (await SendMessageToServerAsync("getPropertyList").ConfigureAwait(false))!.Value .GetProperty("properties").ToObject>(_connection.DefaultJsonSerializerOptions); foreach (var kv in channelResult) diff --git a/src/Playwright/Core/LocalUtils.cs b/src/Playwright/Core/LocalUtils.cs index 070da57f2..e97853188 100644 --- a/src/Playwright/Core/LocalUtils.cs +++ b/src/Playwright/Core/LocalUtils.cs @@ -100,7 +100,7 @@ internal async Task ConnectAsync(string wsEndpoint, IEnumerable("pipe", _connection); + }).ConfigureAwait(false))!.Value.GetObject("pipe", _connection); internal void AddStackToTracingNoReply(List stack, int id) => SendMessageToServerAsync("addStackToTracingNoReply", new Dictionary @@ -127,7 +127,7 @@ internal async Task TracingStartedAsync(string? tracesDir, string traceN { "tracesDir", tracesDir }, { "traceName", traceName }, }).ConfigureAwait(false); - return response.Value.GetProperty("stacksId").ToString(); + return response!.Value.GetProperty("stacksId").ToString(); } } diff --git a/src/Playwright/Core/Locator.cs b/src/Playwright/Core/Locator.cs index 7113106c0..8065dd228 100644 --- a/src/Playwright/Core/Locator.cs +++ b/src/Playwright/Core/Locator.cs @@ -652,7 +652,7 @@ public async Task AriaSnapshotAsync(LocatorAriaSnapshotOptions? options ["mode"] = options?.Mode, ["depth"] = options?.Depth, }).ConfigureAwait(false); - return result.Value.GetProperty("snapshot").ToString(); + return result!.Value.GetProperty("snapshot").ToString(); } public async Task NormalizeAsync() @@ -661,7 +661,7 @@ public async Task NormalizeAsync() { ["selector"] = _selector, }).ConfigureAwait(false); - var resolvedSelector = result.Value.GetProperty("resolvedSelector").ToString(); + var resolvedSelector = result!.Value.GetProperty("resolvedSelector").ToString(); return new Locator(_frame, resolvedSelector); } } diff --git a/src/Playwright/Core/Page.cs b/src/Playwright/Core/Page.cs index 91426a7c3..1cd398624 100644 --- a/src/Playwright/Core/Page.cs +++ b/src/Playwright/Core/Page.cs @@ -713,7 +713,7 @@ public async Task ScreenshotAsync(PageScreenshotOptions? options = defau ["frame"] = ((Locator)locator)._frame, ["selector"] = ((Locator)locator)._selector, }).ToArray(), - }).ConfigureAwait(false)).Value.GetProperty("binary").GetBytesFromBase64(); + }).ConfigureAwait(false))!.Value.GetProperty("binary").GetBytesFromBase64(); if (!string.IsNullOrEmpty(options.Path)) { @@ -910,7 +910,7 @@ public async Task PdfAsync(PagePdfOptions? options = default) ["height"] = options?.Height, ["outline"] = options?.Outline, ["tagged"] = options?.Tagged, - }).ConfigureAwait(false)).Value.GetProperty("pdf").GetBytesFromBase64(); + }).ConfigureAwait(false))!.Value.GetProperty("pdf").GetBytesFromBase64(); if (!string.IsNullOrEmpty(options?.Path)) { @@ -1517,7 +1517,7 @@ public async Task> ConsoleMessagesAsync(PageConso { ["filter"] = options?.Filter, }).ConfigureAwait(false); - var initializers = response.Value.GetProperty("messages").ToObject>(_connection.DefaultJsonSerializerOptions); + var initializers = response!.Value.GetProperty("messages").ToObject>(_connection.DefaultJsonSerializerOptions); return initializers.Select(initializer => new ConsoleMessage(initializer, this, null)).ToList(); } @@ -1532,14 +1532,14 @@ public Task ClearPageErrorsAsync() public async Task> PageErrorsAsync() { var response = await SendMessageToServerAsync("pageErrors").ConfigureAwait(false); - var errors = response.Value.GetProperty("errors").ToObject>(_connection.DefaultJsonSerializerOptions); + var errors = response!.Value.GetProperty("errors").ToObject>(_connection.DefaultJsonSerializerOptions); return errors.Select(error => string.IsNullOrEmpty(error.Error.Stack) ? $"{error.Error.Name}: {error.Error.Message}" : error.Error.Stack).ToList(); } public async Task> RequestsAsync() { var response = await SendMessageToServerAsync("requests").ConfigureAwait(false); - return response.Value.GetProperty("requests").ToObject>(_connection.DefaultJsonSerializerOptions); + return response!.Value.GetProperty("requests").ToObject>(_connection.DefaultJsonSerializerOptions); } [MethodImpl(MethodImplOptions.NoInlining)] @@ -1551,14 +1551,14 @@ public async Task AriaSnapshotAsync(PageAriaSnapshotOptions? options = d ["mode"] = options?.Mode, ["depth"] = options?.Depth, }).ConfigureAwait(false); - return result.Value.GetProperty("snapshot").ToString(); + return result!.Value.GetProperty("snapshot").ToString(); } [MethodImpl(MethodImplOptions.NoInlining)] public async Task PickLocatorAsync() { var result = await SendMessageToServerAsync("pickLocator").ConfigureAwait(false); - var selector = result.Value.GetProperty("selector").ToString(); + var selector = result!.Value.GetProperty("selector").ToString(); return Locator(selector); } @@ -1588,7 +1588,7 @@ private async Task AddLocatorHandlerImplAsync(ILocator locator, object handler, ["noWaitAfter"] = options?.NoWaitAfter, }).ConfigureAwait(false); - _locatorHandlers.Add(response.Value.GetProperty("uid").GetInt32(), new LocatorHandler((Locator)locator, handler, options?.Times)); + _locatorHandlers.Add(response!.Value.GetProperty("uid").GetInt32(), new LocatorHandler((Locator)locator, handler, options?.Times)); } private async Task Channel_LocatorHandlerTriggeredAsync(int uid) diff --git a/src/Playwright/Core/Request.cs b/src/Playwright/Core/Request.cs index f177b2f93..9b1a6e71e 100644 --- a/src/Playwright/Core/Request.cs +++ b/src/Playwright/Core/Request.cs @@ -190,7 +190,7 @@ public async Task SizesAsync() throw new PlaywrightException("Unable to fetch resources sizes."); } - return (await res.SendMessageToServerAsync("sizes").ConfigureAwait(false)).Value.GetProperty("sizes").ToObject(); + return (await res.SendMessageToServerAsync("sizes").ConfigureAwait(false))!.Value.GetProperty("sizes").ToObject(); } [MethodImpl(MethodImplOptions.NoInlining)] @@ -224,7 +224,7 @@ private async Task GetRawHeadersTaskAsync() return await WrapApiCallAsync( async () => { - var headerList = (await SendMessageToServerAsync("rawRequestHeaders").ConfigureAwait(false)).Value.GetProperty("headers").ToObject>(); + var headerList = (await SendMessageToServerAsync("rawRequestHeaders").ConfigureAwait(false))!.Value.GetProperty("headers").ToObject>(); return new RawHeaders(headerList); }, true).ConfigureAwait(false); diff --git a/src/Playwright/Core/Response.cs b/src/Playwright/Core/Response.cs index 69e1b97b4..ed5de47dc 100644 --- a/src/Playwright/Core/Response.cs +++ b/src/Playwright/Core/Response.cs @@ -69,14 +69,14 @@ internal Response(ChannelOwner parent, string guid, ResponseInitializer initiali [MethodImpl(MethodImplOptions.NoInlining)] public async Task HttpVersionAsync() - => (await SendMessageToServerAsync("httpVersion").ConfigureAwait(false)).Value.GetProperty("value").ToString(); + => (await SendMessageToServerAsync("httpVersion").ConfigureAwait(false))!.Value.GetProperty("value").ToString(); [MethodImpl(MethodImplOptions.NoInlining)] public async Task> AllHeadersAsync() => (await GetRawHeadersAsync().ConfigureAwait(false)).Headers; [MethodImpl(MethodImplOptions.NoInlining)] - public async Task BodyAsync() => (await SendMessageToServerAsync("body").ConfigureAwait(false)).Value.GetProperty("binary").GetBytesFromBase64(); + public async Task BodyAsync() => (await SendMessageToServerAsync("body").ConfigureAwait(false))!.Value.GetProperty("binary").GetBytesFromBase64(); [MethodImpl(MethodImplOptions.NoInlining)] public async Task FinishedAsync() @@ -144,6 +144,6 @@ private Task GetRawHeadersAsync() private async Task GetRawHeadersTaskAsync() { - return new((await SendMessageToServerAsync("rawResponseHeaders").ConfigureAwait(false)).Value.GetProperty("headers").ToObject>()); + return new((await SendMessageToServerAsync("rawResponseHeaders").ConfigureAwait(false))!.Value.GetProperty("headers").ToObject>()); } } diff --git a/src/Playwright/Core/Stream.cs b/src/Playwright/Core/Stream.cs index dc4180707..ae3669811 100644 --- a/src/Playwright/Core/Stream.cs +++ b/src/Playwright/Core/Stream.cs @@ -49,7 +49,7 @@ public async Task ReadAsync(int size) { ["size"] = size, }).ConfigureAwait(false); - return response.Value.GetProperty("binary").GetBytesFromBase64(); + return response!.Value.GetProperty("binary").GetBytesFromBase64(); } [MethodImpl(MethodImplOptions.NoInlining)] diff --git a/src/Playwright/Core/Tracing.cs b/src/Playwright/Core/Tracing.cs index d018fd484..e1dde25ab 100644 --- a/src/Playwright/Core/Tracing.cs +++ b/src/Playwright/Core/Tracing.cs @@ -67,7 +67,7 @@ await SendMessageToServerAsync( { ["title"] = options?.Title, ["name"] = options?.Name, - }).ConfigureAwait(false)).Value.GetProperty("traceName").ToString(); + }).ConfigureAwait(false))!.Value.GetProperty("traceName").ToString(); await StartCollectingStacksAsync(traceName).ConfigureAwait(false); } @@ -78,7 +78,7 @@ public async Task StartChunkAsync(TracingStartChunkOptions? options = default) { ["title"] = options?.Title, ["name"] = options?.Name, - }).ConfigureAwait(false)).Value.GetProperty("traceName").ToString(); + }).ConfigureAwait(false))!.Value.GetProperty("traceName").ToString(); await StartCollectingStacksAsync(traceName).ConfigureAwait(false); } @@ -169,7 +169,7 @@ private async Task DoStopChunkAsync(string? filePath) var artifact = result.GetObject("artifact", _connection); List entries = new(); - if (result.Value.TryGetProperty("entries", out var entriesElement)) + if (result!.Value.TryGetProperty("entries", out var entriesElement)) { foreach (var current in entriesElement.EnumerateArray()) { @@ -265,7 +265,7 @@ internal async Task RecordIntoHarAsync(string har, Page? page, HarConten { ["page"] = page, ["options"] = recordHarArgs, - }).ConfigureAwait(false)).Value.GetProperty("harId").ToString(); + }).ConfigureAwait(false))!.Value.GetProperty("harId").ToString(); _harRecorders.Add(harId, new(har, contentPolicy, resourcesDir)); return harId; } @@ -305,7 +305,7 @@ private async Task ExportHarAsync(string harId) throw new PlaywrightException("Cannot save zipped HAR in thin clients"); } List entries = new(); - if (entriesResult.Value.TryGetProperty("entries", out var entriesElement)) + if (entriesResult!.Value.TryGetProperty("entries", out var entriesElement)) { foreach (var current in entriesElement.EnumerateArray()) { diff --git a/src/Playwright/Core/Worker.cs b/src/Playwright/Core/Worker.cs index bd643f59e..ecf98b656 100644 --- a/src/Playwright/Core/Worker.cs +++ b/src/Playwright/Core/Worker.cs @@ -97,7 +97,7 @@ public async Task EvaluateAsync(string expression, object? arg = null) { ["expression"] = expression, ["arg"] = ScriptsHelper.SerializedArgument(arg), - }).ConfigureAwait(false)).Value.GetProperty("value")); + }).ConfigureAwait(false))!.Value.GetProperty("value")); [MethodImpl(MethodImplOptions.NoInlining)] public async Task EvaluateHandleAsync(string expression, object? arg = null) diff --git a/src/Playwright/Helpers/SetInputFilesHelpers.cs b/src/Playwright/Helpers/SetInputFilesHelpers.cs index e9caa6920..57e6c5991 100644 --- a/src/Playwright/Helpers/SetInputFilesHelpers.cs +++ b/src/Playwright/Helpers/SetInputFilesHelpers.cs @@ -96,7 +96,7 @@ public static async Task ConvertInputFilesAsync(IEnumerable< ["lastModifiedMs"] = new DateTimeOffset(File.GetLastWriteTime(file)).ToUnixTimeMilliseconds(), }).ToArray(), }).ConfigureAwait(false); - var writableStreams = result.Value.GetProperty("writableStreams").EnumerateArray(); + var writableStreams = result!.Value.GetProperty("writableStreams").EnumerateArray(); if (writableStreams.Count() != files.Count()) { throw new Exception("Mismatch between the number of files and the number of writeable streams"); @@ -118,7 +118,7 @@ public static async Task ConvertInputFilesAsync(IEnumerable< } return new() { - DirectoryStream = result.Value.TryGetProperty("rootDir", out var rootDir) ? rootDir.ToObject(context._connection.DefaultJsonSerializerOptions) : null, + DirectoryStream = result!.Value.TryGetProperty("rootDir", out var rootDir) ? rootDir.ToObject(context._connection.DefaultJsonSerializerOptions) : null, Streams = localDirectory != null ? null : [.. streams], }; } diff --git a/src/Playwright/Transport/Connection.cs b/src/Playwright/Transport/Connection.cs index d48b4dcc9..0c4e85ada 100644 --- a/src/Playwright/Transport/Connection.cs +++ b/src/Playwright/Transport/Connection.cs @@ -202,7 +202,7 @@ await _queue.EnqueueAsync(() => if (typeof(T) == typeof(JsonElement?)) { - return (T)(object)result; + return (T)(object)result!; } else if (result == null) {