Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add additional net8.0 TFM #2893

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 5 additions & 1 deletion src/Playwright.Examples/Playwright.Examples.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -9,6 +9,10 @@
<NoWarn>CA2007</NoWarn>
<ReleaseVersion>0.0.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup>
<PublishAot>true</PublishAot>
</PropertyGroup>


<!-- Required since we're not actually referencing Playwright -->
<Import Project="../Playwright.Tests/build/Playwright.Tests.targets" />
Expand Down
Binary file added src/Playwright.Examples/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/Playwright/Helpers/JsonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Playwright.Transport.Converters;
#if NET8_0_OR_GREATER
using System.Text.Json.Serialization.Metadata;
#endif

namespace Microsoft.Playwright.Helpers;

Expand Down Expand Up @@ -98,6 +101,9 @@ internal static JsonSerializerOptions GetNewDefaultSerializerOptions(bool keepNu
new JsonStringEnumMemberConverter(),
},
};
#if NET8_0_OR_GREATER
options.TypeInfoResolver = new DefaultJsonTypeInfoResolver();
#endif
if (!keepNulls)
{
options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/Playwright.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Summary>The .NET port of Playwright, used to automate Chromium, Firefox and WebKit with a single API.</Summary>
<Description>Playwright enables reliable end-to-end testing for modern web apps. It is built to enable cross-browser web automation that is ever-green, capable, reliable and fast. Learn more at https://playwright.dev/dotnet/.</Description>
<PackageIcon>icon.png</PackageIcon>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DocumentationFile>Microsoft.Playwright.xml</DocumentationFile>
<RunWithWarnings>true</RunWithWarnings>
Expand All @@ -17,7 +17,7 @@
<ReleaseVersion>0.0.0</ReleaseVersion>
<BuildFromSource>True</BuildFromSource>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<NoWarn>1701;1702;CS0067;1734;NU5110;NU5111</NoWarn>
<NoWarn>1701;1702;CS0067;1734;NU5110;NU5111;CA1849;CA1861;CA1867;VSTHRD103;CA1510;CA1851;CA1835;CA2000</NoWarn>
<AssemblyName>Microsoft.Playwright</AssemblyName>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
Expand Down
9 changes: 8 additions & 1 deletion src/Playwright/Transport/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.Json;
#if NET8_0_OR_GREATER
using System.Text.Json.Serialization.Metadata;
#endif
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Playwright.Core;
Expand Down Expand Up @@ -59,7 +62,10 @@ public Connection(LocalUtils localUtils = null)
JsonSerializerOptions NewJsonSerializerOptions(bool keepNulls)
{
var options = JsonExtensions.GetNewDefaultSerializerOptions(keepNulls);

#if NET8_0_OR_GREATER
Console.WriteLine("Using reflection: JsonSerializer.IsReflectionEnabledByDefault: " + JsonSerializer.IsReflectionEnabledByDefault);
options.TypeInfoResolver = new DefaultJsonTypeInfoResolver();
#endif
// Workaround for https://github.com/dotnet/runtime/issues/46522
options.Converters.Add(new ChannelOwnerConverterFactory(this));
// Workaround for https://github.com/dotnet/runtime/issues/46522
Expand Down Expand Up @@ -312,6 +318,7 @@ internal void Dispatch(PlaywrightServerMessage message)
}
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "We dispose manually inside the protocol")]
private ChannelOwner CreateRemoteObject(string parentGuid, ChannelOwnerType type, string guid, JsonElement? initializer)
{
ChannelOwner result = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ private static object ParseEvaluateResultToExpando(JsonElement result, IDictiona
return null;
}

#pragma warning disable SYSLIB0050 // Type or member is obsolete
internal class VisitorInfo
{
internal VisitorInfo()
Expand All @@ -393,4 +394,5 @@ internal VisitorInfo()
internal long Identity(object obj)
=> IDGenerator.GetId(obj, out _);
}
#pragma warning restore SYSLIB0050 // Type or member is obsolete
}
2 changes: 1 addition & 1 deletion src/Playwright/Transport/StdIOTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private static void StartProcessWithUTF8IOEncoding(Process process)
}
}

private static Task ScheduleTransportTaskAsync(Func<CancellationToken, Task> func, CancellationToken cancellationToken)
private static Task<Task> ScheduleTransportTaskAsync(Func<CancellationToken, Task> func, CancellationToken cancellationToken)
=> Task.Factory.StartNew(() => func(cancellationToken), cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);

private void Dispose(bool disposing)
Expand Down
Loading