Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Playwright/Core/APIResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task<string> TextAsync()
internal async Task<string[]> FetchLogAsync()
{
var response = await _context.SendMessageToServerAsync("fetchLog", new Dictionary<string, object?> { ["fetchUid"] = FetchUid() }).ConfigureAwait(false);
return response.Value.GetProperty("log").ToObject<string[]>();
return response!.Value.GetProperty("log").ToObject<string[]>();
}

public ValueTask DisposeAsync() => new(_context.SendMessageToServerAsync("disposeAPIResponse", new Dictionary<string, object?> { ["fetchUid"] = FetchUid() }));
Expand Down
14 changes: 7 additions & 7 deletions src/Playwright/Core/ElementHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public async Task<byte[]> 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))
{
Expand Down Expand Up @@ -161,7 +161,7 @@ public Task ScrollIntoViewIfNeededAsync(ElementHandleScrollIntoViewIfNeededOptio

public async Task<ElementHandleBoundingBoxResult?> 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<ElementHandleBoundingBoxResult>();
Expand Down Expand Up @@ -303,9 +303,9 @@ public Task DispatchEventAsync(string type, object? eventInit = null)
return null;
}

public async Task<string> InnerHTMLAsync() => (await SendMessageToServerAsync("innerHTML").ConfigureAwait(false)).Value.GetProperty("value").ToString();
public async Task<string> InnerHTMLAsync() => (await SendMessageToServerAsync("innerHTML").ConfigureAwait(false))!.Value.GetProperty("value").ToString();

public async Task<string> InnerTextAsync() => (await SendMessageToServerAsync("innerText").ConfigureAwait(false)).Value.GetProperty("value").ToString();
public async Task<string> InnerTextAsync() => (await SendMessageToServerAsync("innerText").ConfigureAwait(false))!.Value.GetProperty("value").ToString();

public async Task<string?> TextContentAsync() => (await SendMessageToServerAsync("textContent").ConfigureAwait(false))?.GetProperty("value").ToString();

Expand Down Expand Up @@ -353,7 +353,7 @@ private async Task<IReadOnlyList<string>> _selectOptionAsync(IEnumerable<SelectO
["options"] = values,
["force"] = force,
["timeout"] = _frame.Timeout(timeout),
}).ConfigureAwait(false)).Value.GetProperty("values").ToObject<string[]>();
}).ConfigureAwait(false))!.Value.GetProperty("values").ToObject<string[]>();
}

private async Task<IReadOnlyList<string>> _selectOptionAsync(IEnumerable<IElementHandle> values, bool? noWaitAfter, bool? force, float? timeout)
Expand All @@ -363,7 +363,7 @@ private async Task<IReadOnlyList<string>> _selectOptionAsync(IEnumerable<IElemen
["elements"] = values,
["force"] = force,
["timeout"] = _frame.Timeout(timeout),
}).ConfigureAwait(false)).Value.GetProperty("values").ToObject<string[]>();
}).ConfigureAwait(false))!.Value.GetProperty("values").ToObject<string[]>();
}

public Task CheckAsync(ElementHandleCheckOptions? options = default)
Expand Down Expand Up @@ -407,7 +407,7 @@ public Task TapAsync(ElementHandleTapOptions? options = default)
public async Task<bool> IsVisibleAsync() => (await SendMessageToServerAsync("isVisible").ConfigureAwait(false))?.GetProperty("value").GetBoolean() ?? default;

public async Task<string> 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<string, object?>
Expand Down
20 changes: 10 additions & 10 deletions src/Playwright/Core/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public IFrameLocator FrameLocator(string selector)
=> new FrameLocator(this, selector);

[MethodImpl(MethodImplOptions.NoInlining)]
public async Task<string> TitleAsync() => (await SendMessageToServerAsync("title").ConfigureAwait(false)).Value.GetProperty("value").ToString();
public async Task<string> TitleAsync() => (await SendMessageToServerAsync("title").ConfigureAwait(false))!.Value.GetProperty("value").ToString();

[MethodImpl(MethodImplOptions.NoInlining)]
public Task WaitForTimeoutAsync(float timeout)
Expand Down Expand Up @@ -194,7 +194,7 @@ public async Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IEnu
["strict"] = options?.Strict,
["force"] = options?.Force,
["timeout"] = Timeout(options?.Timeout),
}).ConfigureAwait(false)).Value.GetProperty("values").ToObject<string[]>().ToList().AsReadOnly();
}).ConfigureAwait(false))!.Value.GetProperty("values").ToObject<string[]>().ToList().AsReadOnly();

[MethodImpl(MethodImplOptions.NoInlining)]
public Task<IReadOnlyList<string>> SelectOptionAsync(string selector, SelectOptionValue values, FrameSelectOptionOptions? options = default)
Expand All @@ -215,7 +215,7 @@ internal async Task<IReadOnlyList<string>> SelectOptionAsync(string selector, IE
["strict"] = options?.Strict,
["force"] = options?.Force,
["timeout"] = Timeout(options?.Timeout),
}).ConfigureAwait(false)).Value.GetProperty("values").ToObject<string[]>().ToList().AsReadOnly();
}).ConfigureAwait(false))!.Value.GetProperty("values").ToObject<string[]>().ToList().AsReadOnly();

[MethodImpl(MethodImplOptions.NoInlining)]
public async Task WaitForLoadStateAsync(LoadState? state = default, FrameWaitForLoadStateOptions? options = default)
Expand Down Expand Up @@ -364,12 +364,12 @@ internal async Task<int> 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<string> 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)
Expand Down Expand Up @@ -414,7 +414,7 @@ public async Task<string> 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<string> InnerTextAsync(string selector, FrameInnerTextOptions? options = default)
Expand All @@ -423,7 +423,7 @@ public async Task<string> 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<string?> TextContentAsync(string selector, FrameTextContentOptions? options = default)
Expand Down Expand Up @@ -654,7 +654,7 @@ public async Task<string> 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<IElementHandle> QuerySelectorAsync(string selector)
Expand Down Expand Up @@ -944,8 +944,8 @@ internal async Task<FrameExpectResult> ExpectAsync(string? selector, string expr
["isNot"] = options.IsNot,
["timeout"] = options.Timeout,
}).ConfigureAwait(false);
var parsed = result.Value.ToObject<FrameExpectResult>();
if (result.Value.TryGetProperty("received", out var received) && received.ValueKind == JsonValueKind.Object)
var parsed = result!.Value.ToObject<FrameExpectResult>();
if (result!.Value.TryGetProperty("received", out var received) && received.ValueKind == JsonValueKind.Object)
{
if (received.TryGetProperty("value", out var receivedValue))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Playwright/Core/JSHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public async Task<IJSHandle> GetPropertyAsync(string propertyName) => await Send
public async Task<Dictionary<string, IJSHandle>> GetPropertiesAsync()
{
var result = new Dictionary<string, IJSHandle>();
var channelResult = (await SendMessageToServerAsync("getPropertyList").ConfigureAwait(false)).Value
var channelResult = (await SendMessageToServerAsync("getPropertyList").ConfigureAwait(false))!.Value
.GetProperty("properties").ToObject<List<JSElementProperty>>(_connection.DefaultJsonSerializerOptions);

foreach (var kv in channelResult)
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/LocalUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ internal async Task<JsonPipe> ConnectAsync(string wsEndpoint, IEnumerable<KeyVal
{ "slowMo", slowMo },
{ "timeout", timeout ?? 0 },
{ "exposeNetwork", exposeNetwork },
}).ConfigureAwait(false)).Value.GetObject<JsonPipe>("pipe", _connection);
}).ConfigureAwait(false))!.Value.GetObject<JsonPipe>("pipe", _connection);

internal void AddStackToTracingNoReply(List<StackFrame> stack, int id)
=> SendMessageToServerAsync("addStackToTracingNoReply", new Dictionary<string, object?>
Expand All @@ -127,7 +127,7 @@ internal async Task<string> TracingStartedAsync(string? tracesDir, string traceN
{ "tracesDir", tracesDir },
{ "traceName", traceName },
}).ConfigureAwait(false);
return response.Value.GetProperty("stacksId").ToString();
return response!.Value.GetProperty("stacksId").ToString();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/Locator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ public async Task<string> 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<ILocator> NormalizeAsync()
Expand All @@ -661,7 +661,7 @@ public async Task<ILocator> NormalizeAsync()
{
["selector"] = _selector,
}).ConfigureAwait(false);
var resolvedSelector = result.Value.GetProperty("resolvedSelector").ToString();
var resolvedSelector = result!.Value.GetProperty("resolvedSelector").ToString();
return new Locator(_frame, resolvedSelector);
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/Playwright/Core/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ public async Task<byte[]> 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))
{
Expand Down Expand Up @@ -910,7 +910,7 @@ public async Task<byte[]> 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))
{
Expand Down Expand Up @@ -1517,7 +1517,7 @@ public async Task<IReadOnlyList<IConsoleMessage>> ConsoleMessagesAsync(PageConso
{
["filter"] = options?.Filter,
}).ConfigureAwait(false);
var initializers = response.Value.GetProperty("messages").ToObject<List<ConsoleMessageInitializer>>(_connection.DefaultJsonSerializerOptions);
var initializers = response!.Value.GetProperty("messages").ToObject<List<ConsoleMessageInitializer>>(_connection.DefaultJsonSerializerOptions);
return initializers.Select(initializer => new ConsoleMessage(initializer, this, null)).ToList();
}

Expand All @@ -1532,14 +1532,14 @@ public Task ClearPageErrorsAsync()
public async Task<IReadOnlyList<string>> PageErrorsAsync()
{
var response = await SendMessageToServerAsync("pageErrors").ConfigureAwait(false);
var errors = response.Value.GetProperty("errors").ToObject<List<SerializedError>>(_connection.DefaultJsonSerializerOptions);
var errors = response!.Value.GetProperty("errors").ToObject<List<SerializedError>>(_connection.DefaultJsonSerializerOptions);
return errors.Select(error => string.IsNullOrEmpty(error.Error.Stack) ? $"{error.Error.Name}: {error.Error.Message}" : error.Error.Stack).ToList();
}

public async Task<IReadOnlyList<IRequest>> RequestsAsync()
{
var response = await SendMessageToServerAsync("requests").ConfigureAwait(false);
return response.Value.GetProperty("requests").ToObject<List<Request>>(_connection.DefaultJsonSerializerOptions);
return response!.Value.GetProperty("requests").ToObject<List<Request>>(_connection.DefaultJsonSerializerOptions);
}

[MethodImpl(MethodImplOptions.NoInlining)]
Expand All @@ -1551,14 +1551,14 @@ public async Task<string> 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<ILocator> 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);
}

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Core/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public async Task<RequestSizesResult> SizesAsync()
throw new PlaywrightException("Unable to fetch resources sizes.");
}

return (await res.SendMessageToServerAsync("sizes").ConfigureAwait(false)).Value.GetProperty("sizes").ToObject<RequestSizesResult>();
return (await res.SendMessageToServerAsync("sizes").ConfigureAwait(false))!.Value.GetProperty("sizes").ToObject<RequestSizesResult>();
}

[MethodImpl(MethodImplOptions.NoInlining)]
Expand Down Expand Up @@ -224,7 +224,7 @@ private async Task<RawHeaders> GetRawHeadersTaskAsync()
return await WrapApiCallAsync(
async () =>
{
var headerList = (await SendMessageToServerAsync("rawRequestHeaders").ConfigureAwait(false)).Value.GetProperty("headers").ToObject<List<NameValue>>();
var headerList = (await SendMessageToServerAsync("rawRequestHeaders").ConfigureAwait(false))!.Value.GetProperty("headers").ToObject<List<NameValue>>();
return new RawHeaders(headerList);
},
true).ConfigureAwait(false);
Expand Down
6 changes: 3 additions & 3 deletions src/Playwright/Core/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ internal Response(ChannelOwner parent, string guid, ResponseInitializer initiali

[MethodImpl(MethodImplOptions.NoInlining)]
public async Task<string> 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<Dictionary<string, string>> AllHeadersAsync()
=> (await GetRawHeadersAsync().ConfigureAwait(false)).Headers;

[MethodImpl(MethodImplOptions.NoInlining)]
public async Task<byte[]> BodyAsync() => (await SendMessageToServerAsync("body").ConfigureAwait(false)).Value.GetProperty("binary").GetBytesFromBase64();
public async Task<byte[]> BodyAsync() => (await SendMessageToServerAsync("body").ConfigureAwait(false))!.Value.GetProperty("binary").GetBytesFromBase64();

[MethodImpl(MethodImplOptions.NoInlining)]
public async Task<string?> FinishedAsync()
Expand Down Expand Up @@ -144,6 +144,6 @@ private Task<RawHeaders> GetRawHeadersAsync()

private async Task<RawHeaders> GetRawHeadersTaskAsync()
{
return new((await SendMessageToServerAsync("rawResponseHeaders").ConfigureAwait(false)).Value.GetProperty("headers").ToObject<List<NameValue>>());
return new((await SendMessageToServerAsync("rawResponseHeaders").ConfigureAwait(false))!.Value.GetProperty("headers").ToObject<List<NameValue>>());
}
}
2 changes: 1 addition & 1 deletion src/Playwright/Core/Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task<byte[]> ReadAsync(int size)
{
["size"] = size,
}).ConfigureAwait(false);
return response.Value.GetProperty("binary").GetBytesFromBase64();
return response!.Value.GetProperty("binary").GetBytesFromBase64();
}

[MethodImpl(MethodImplOptions.NoInlining)]
Expand Down
Loading
Loading