-
Notifications
You must be signed in to change notification settings - Fork 247
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
add net8.0 target #3080
base: main
Are you sure you want to change the base?
add net8.0 target #3080
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,6 @@ | |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is part of the SDK since .NET 5, so unnecessary. see https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview?tabs=net-9
|
||
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ public void ApplyToTest(Test test) | |
{ | ||
if (_combinations.Any(combination => | ||
{ | ||
var requirements = (Enum.GetValues(typeof(Targets)) as Targets[]).Where(x => combination.HasFlag(x)); | ||
var requirements = ((Targets[])Enum.GetValues(typeof(Targets))).Where(x => combination.HasFlag(x)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to avoid null reference warning. |
||
return requirements.All(flag => | ||
flag switch | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,7 +122,11 @@ public async Task<byte[]> ScreenshotAsync(ElementHandleScreenshotOptions options | |
if (!string.IsNullOrEmpty(options.Path)) | ||
{ | ||
Directory.CreateDirectory(new FileInfo(options.Path).Directory.FullName); | ||
#if NET | ||
await File.WriteAllBytesAsync(options.Path, result).ConfigureAwait(false); | ||
#else | ||
File.WriteAllBytes(options.Path, result); | ||
#endif | ||
} | ||
|
||
return result; | ||
|
@@ -204,7 +208,7 @@ public async Task SetInputFilesAsync(IEnumerable<string> files, ElementHandleSet | |
{ | ||
throw new PlaywrightException("Cannot set input files to detached element."); | ||
} | ||
var converted = await SetInputFilesHelpers.ConvertInputFilesAsync(files, (BrowserContext)frame.Page.Context).ConfigureAwait(false); | ||
var converted = await SetInputFilesHelpers.ConvertInputFilesAsync(files.ToList(), (BrowserContext)frame.Page.Context).ConfigureAwait(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This API was changed to accept a List because of CA1851. |
||
await SendMessageToServerAsync("setInputFiles", new Dictionary<string, object> | ||
{ | ||
["payloads"] = converted.Payloads, | ||
|
@@ -221,7 +225,7 @@ public Task SetInputFilesAsync(FilePayload files, ElementHandleSetInputFilesOpti | |
|
||
public async Task SetInputFilesAsync(IEnumerable<FilePayload> files, ElementHandleSetInputFilesOptions options = default) | ||
{ | ||
var converted = SetInputFilesHelpers.ConvertInputFiles(files); | ||
var converted = SetInputFilesHelpers.ConvertInputFiles(files.ToList()); | ||
await SendMessageToServerAsync("setInputFiles", new Dictionary<string, object> | ||
{ | ||
["payloads"] = converted.Payloads, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,12 +70,11 @@ public IFrame Frame | |
var frame = _initializer.Frame; | ||
if (frame.Page == null) | ||
{ | ||
throw new PlaywrightException(string.Join("\n", new string[] | ||
{ | ||
"Frame for this navigation request is not available, because the request", | ||
"was issued before the frame is created. You can check whether the request", | ||
"is a navigation request by calling isNavigationRequest() method.", | ||
})); | ||
throw new PlaywrightException(""" | ||
Frame for this navigation request is not available, because the request | ||
was issued before the frame is created. You can check whether the request | ||
is a navigation request by calling isNavigationRequest() method. | ||
"""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To fix CA1861. |
||
} | ||
return frame; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ private static (string[] LocalPaths, string LocalDirectory) ResolvePathsAndDirec | |
return (localPaths?.ToArray(), localDirectory); | ||
} | ||
|
||
private static IEnumerable<string> GetFilesRecursive(string directory) | ||
private static List<string> GetFilesRecursive(string directory) | ||
{ | ||
var files = new List<string>(); | ||
files.AddRange(Directory.GetFiles(directory)); | ||
|
@@ -76,16 +76,16 @@ private static IEnumerable<string> GetFilesRecursive(string directory) | |
return files; | ||
} | ||
|
||
public static async Task<SetInputFilesFiles> ConvertInputFilesAsync(IEnumerable<string> files, BrowserContext context) | ||
public static async Task<SetInputFilesFiles> ConvertInputFilesAsync(List<string> files, BrowserContext context) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mentioned above: This API was changed to accept a List because of CA1851. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If they were to accept a breaking change then |
||
{ | ||
if (!files.Any()) | ||
if (files.Count == 0) | ||
{ | ||
return new() { Payloads = [] }; | ||
} | ||
var (localPaths, localDirectory) = ResolvePathsAndDirectoryForInputFiles(files.ToList()); | ||
var (localPaths, localDirectory) = ResolvePathsAndDirectoryForInputFiles(files); | ||
if (context._connection.IsRemote) | ||
{ | ||
files = localDirectory != null ? GetFilesRecursive(localDirectory) : localPaths; | ||
files = localDirectory != null ? GetFilesRecursive(localDirectory) : localPaths.ToList(); | ||
var result = await context.SendMessageToServerAsync("createTempFiles", new Dictionary<string, object> | ||
{ | ||
["rootDirName"] = localDirectory != null ? new DirectoryInfo(localDirectory).Name : null, | ||
|
@@ -97,12 +97,12 @@ public static async Task<SetInputFilesFiles> ConvertInputFilesAsync(IEnumerable< | |
}).ToArray(), | ||
}).ConfigureAwait(false); | ||
var writableStreams = result.Value.GetProperty("writableStreams").EnumerateArray(); | ||
if (writableStreams.Count() != files.Count()) | ||
if (writableStreams.Count() != files.Count) | ||
{ | ||
throw new Exception("Mismatch between the number of files and the number of writeable streams"); | ||
throw new PlaywrightException("Mismatch between the number of files and the number of writeable streams"); | ||
} | ||
var streams = new List<WritableStream>(); | ||
for (var i = 0; i < files.Count(); i++) | ||
for (var i = 0; i < files.Count; i++) | ||
{ | ||
#pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task | ||
await using (var writeableStream = context._connection.GetObject(writableStreams.ElementAt(i).GetProperty("guid").ToString()) as WritableStream) | ||
|
@@ -122,7 +122,7 @@ public static async Task<SetInputFilesFiles> ConvertInputFilesAsync(IEnumerable< | |
return new() { LocalPaths = localPaths, LocalDirectory = localDirectory }; | ||
} | ||
|
||
public static SetInputFilesFiles ConvertInputFiles(IEnumerable<FilePayload> files) | ||
public static SetInputFilesFiles ConvertInputFiles(List<FilePayload> files) | ||
{ | ||
var filePayloadExceedsSizeLimit = files.Sum(f => f.Buffer.Length) > SizeLimitInBytes; | ||
if (filePayloadExceedsSizeLimit) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -615,7 +615,11 @@ public static Dictionary<string, string> ParseQueryString(this string query) | |
|
||
var result = new Dictionary<string, string>(); | ||
|
||
#if NET | ||
if (query.StartsWith('?')) | ||
#else | ||
if (query.StartsWith("?", StringComparison.InvariantCultureIgnoreCase)) | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To fix CA1867. |
||
{ | ||
query = query.Substring(1, query.Length - 1); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled CA1510 because the throw helpers are not available on netstandard2.0 and
#if
ing this is not worth it.