Skip to content

Conversation

@mxschmitt
Copy link
Contributor

public string? ApiName { get; set; }

public List<StackFrame> Frames { get; set; }
public List<StackFrame> Frames { get; set; } = null!;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: !null in this context means the same as using the required keyword. We can't use the required keyword tho since its not available with our TFM we support (netstandard2.0).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is TFM we support ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats our TFM:

<TargetFramework>netstandard2.0</TargetFramework>

Its supported only in net7+

using System.Text.Json;
using Microsoft.Playwright.Transport;

#nullable enable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did it go away?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already in line 24.

public string? ApiName { get; set; }

public List<StackFrame> Frames { get; set; }
public List<StackFrame> Frames { get; set; } = null!;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is TFM we support ?

internal bool _isInternalType;

internal ChannelOwner(ChannelOwner parent, string guid) : this(parent, null, guid)
internal ChannelOwner(ChannelOwner parent, string guid) : this(parent, parent._connection, guid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can parent be null here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in this scenario. It can be null when using the other overload. I'll follow-up once I touch more places aka. Connection.cs which will automatically yield this.

keepNulls);
var message = new Dictionary<string, object>
{
["id"] = id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change? Previously it was type-checked, now it's just a dict.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove use-less wrapping type - this is similar to Python now.

{
var createObjectInfo = message.Params.Value.ToObject<CreateObjectInfo>(DefaultJsonSerializerOptions);
CreateRemoteObject(message.Guid, createObjectInfo.Type, createObjectInfo.Guid, createObjectInfo.Initializer);
CreateRemoteObject(message.Guid, message.Params.Value.GetProperty("type").ToObject<ChannelOwnerType>(), message.Params.GetString("guid", false)!, message.Params?.GetProperty("initializer"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, the previous code was arguably more type-safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally its similar and more explicit without going through the JsonSerializer infra + we don't need this extra type. I think for use-cases where we don't need to share a type this is preferred (like we do in other places as well).

public string Name { get; set; } = null!;

public string MimeType { get; set; }
public string MimeType { get; set; } = null!;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null! is a very indirect way to say that the field is required!

@mxschmitt mxschmitt merged commit 3b1f24d into main May 22, 2025
15 checks passed
@mxschmitt mxschmitt deleted the add-nullable-2 branch May 22, 2025 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants