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

add net8.0 target #3080

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add net8.0 target #3080

wants to merge 1 commit into from

Conversation

mus65
Copy link

@mus65 mus65 commented Dec 8, 2024

  • add net8.0 target to projects
  • fix all compiler warnings introduced by the new targets
  • removed unneeded dependencies since they are part of the .NET runtime

Some of these changes make sense regardless of the multi-targeting. Some of the #ifs could obviously be avoided by ignoring the warning instead. I opted for #if almost everywhere for now.

fixes #3033

- add net8.0 target to projects
- fix all compiler warnings introduced by the new targets
- removed unneeded dependencies since they are part of the
  .NET runtime

fixes microsoft#3033
@mus65 mus65 marked this pull request as ready for review December 8, 2024 12:46
@mus65
Copy link
Author

mus65 commented Dec 8, 2024

I assume the test failures are unrelated.

@@ -184,6 +184,7 @@ dotnet_diagnostic.CA1305.severity = error
dotnet_diagnostic.CA1307.severity = none
dotnet_diagnostic.CA1308.severity = none
dotnet_diagnostic.CA1508.severity = none
dotnet_diagnostic.CA1510.severity = none
Copy link
Author

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 #ifing this is not worth it.

<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Copy link
Author

Choose a reason for hiding this comment

The 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

Starting in .NET 5, these analyzers are included with the .NET SDK and you don't need to install them separately.

@@ -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));
Copy link
Author

Choose a reason for hiding this comment

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

to avoid null reference warning.

@@ -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);
Copy link
Author

Choose a reason for hiding this comment

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

This API was changed to accept a List because of CA1851.

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.
""");
Copy link
Author

Choose a reason for hiding this comment

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

To fix CA1861.

@@ -314,105 +314,78 @@ internal void Dispatch(PlaywrightServerMessage message)

private ChannelOwner CreateRemoteObject(string parentGuid, ChannelOwnerType type, string guid, JsonElement? initializer)
{
ChannelOwner result = null;
Copy link
Author

Choose a reason for hiding this comment

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

Refactored this to avoid CA2000.

@@ -399,16 +399,25 @@ internal class VisitorInfo
internal VisitorInfo()
{
Visited = new Dictionary<long, int>();
IDGenerator = new ObjectIDGenerator();
Copy link
Author

Choose a reason for hiding this comment

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

ObjectIDGeneratoris obsolete since it's part of the BinaryFormatter API. Replaced this with a simple implementation based on dotnet/runtime#98168 (comment) .

@@ -186,7 +191,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)
Copy link
Author

Choose a reason for hiding this comment

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

to fix CA1859.

@@ -345,7 +344,7 @@ private static object ParseEvaluateResultToExpando(JsonElement result, IDictiona

if (result.TryGetProperty("e", out var error))
{
return new Exception(error.GetProperty("s").ToString());
return new PlaywrightException(error.GetProperty("s").ToString());
Copy link
Author

Choose a reason for hiding this comment

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

To fix CA2201. Not sure if this is OK to change?

await _process.StandardInput.BaseStream.WriteAsync(ll, 0, 4, _readerCancellationSource.Token).ConfigureAwait(false);
await _process.StandardInput.BaseStream.WriteAsync(message, 0, len, _readerCancellationSource.Token).ConfigureAwait(false);
#endif
Copy link
Author

Choose a reason for hiding this comment

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

To fix CA1835.

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.

Multi-target to reduce dependencies
2 participants