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
9 changes: 0 additions & 9 deletions dotnet/src/webdriver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ csharp_library(
"**/*.cs",
]) + ["//dotnet/src/webdriver/DevTools:srcs"] + devtools_version_targets(),
out = "WebDriver",
internals_visible_to = [
"WebDriver.Tests",
],
langversion = "14.0",
nullable = "enable",
target_frameworks = [
Expand Down Expand Up @@ -81,9 +78,6 @@ csharp_library(
"**/*.cs",
]) + ["//dotnet/src/webdriver/DevTools:srcs"] + devtools_version_targets(),
out = "WebDriver",
internals_visible_to = [
"WebDriver.Tests",
],
langversion = "14.0",
nullable = "enable",
resources = [],
Expand Down Expand Up @@ -118,9 +112,6 @@ csharp_library(
defines = [
"NET8_0_OR_GREATER",
],
internals_visible_to = [
"WebDriver.Tests",
],
langversion = "14.0",
nullable = "enable",
resources = [],
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/webdriver/BiDi/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ protected Command(string method)
public long Id { get; internal set; }
}

internal abstract class Command<TParameters, TResult>(TParameters @params, string method) : Command(method)
public abstract class Command<TParameters, TResult>(TParameters @params, string method) : Command(method)
where TParameters : Parameters
where TResult : EmptyResult
{
[JsonPropertyOrder(2)]
public TParameters Params { get; } = @params;
}

internal record Parameters
public record Parameters
{
public static Parameters Empty { get; } = new Parameters();
}
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/webdriver/Internal/Logging/ILogContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public interface ILogContext : IDisposable
/// </summary>
/// <typeparam name="T">The type for which to retrieve the logger.</typeparam>
/// <returns>An instance of <see cref="ILogger"/> for the specified type.</returns>
internal ILogger GetLogger<T>();
ILogger GetLogger<T>();

/// <summary>
/// Gets a logger for the specified type.
/// </summary>
/// <param name="type">The type for which to retrieve the logger.</param>
/// <returns>An instance of <see cref="ILogger"/> for the specified type.</returns>
internal ILogger GetLogger(Type type);
ILogger GetLogger(Type type);

/// <summary>
/// Checks whether logs emitting is enabled for a logger and a log event level.
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/Internal/Logging/ILogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.Internal.Logging;
/// <summary>
/// Defines the interface through which log messages are emitted.
/// </summary>
internal interface ILogger
public interface ILogger
{
/// <summary>
/// Writes a trace-level log message.
Expand Down
6 changes: 3 additions & 3 deletions dotnet/src/webdriver/Internal/Logging/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static ILogContext CreateContext(LogEventLevel minimumLevel)
/// Gets or sets the current log context.
/// </summary>
[AllowNull]
internal static ILogContext CurrentContext
public static ILogContext CurrentContext
{
get => _logContextManager.CurrentContext;
set => _logContextManager.CurrentContext = value;
Expand All @@ -77,7 +77,7 @@ internal static ILogContext CurrentContext
/// </summary>
/// <typeparam name="T">The type to get the logger for.</typeparam>
/// <returns>The logger.</returns>
internal static ILogger GetLogger<T>()
public static ILogger GetLogger<T>()
{
return _logContextManager.CurrentContext.GetLogger<T>();
}
Expand All @@ -87,7 +87,7 @@ internal static ILogger GetLogger<T>()
/// </summary>
/// <param name="type">The type to get the logger for.</param>
/// <returns>The logger.</returns>
internal static ILogger GetLogger(Type type)
public static ILogger GetLogger(Type type)
{
return _logContextManager.CurrentContext.GetLogger(type);
}
Expand Down
4 changes: 0 additions & 4 deletions dotnet/src/webdriver/Selenium.WebDriver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>-->

<ItemGroup>
<InternalsVisibleTo Include="WebDriver.Tests" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
Expand Down
46 changes: 46 additions & 0 deletions dotnet/test/webdriver/BiDi/Session/SessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// under the License.
// </copyright>

using System.Text.Json;
using System.Text.Json.Serialization;
using OpenQA.Selenium.BiDi;

namespace OpenQA.Selenium.Tests.BiDi.Session;

internal class SessionTests : BiDiTestFixture
Expand Down Expand Up @@ -54,4 +58,46 @@ public void ShouldRespectCancellationToken()
() => bidi.StatusAsync(cancellationToken: cts.Token),
Throws.InstanceOf<TaskCanceledException>());
}

[Test]
public void AsModuleShouldReturnSameInstanceForSameType()
{
Assert.That(bidi.AsModule<CustomModule>(), Is.SameAs(bidi.AsModule<CustomModule>()));
}

[Test]
public async Task CustomModuleShouldExecuteCommand()
{
var customModule = bidi.AsModule<CustomModule>();

var result = await customModule.DoSomethingAsync();

Assert.That(result, Is.Not.Null);
}
}

class CustomModule : Module
{
private CustomModuleJsonSerializerContext _jsonContext = null!;

Comment thread
nvborisenko marked this conversation as resolved.
public async Task<DoSomethingResult> DoSomethingAsync(DoSomethingOptions options = null)
Comment thread
nvborisenko marked this conversation as resolved.
{
return await ExecuteCommandAsync(new DoSomethingCommand(), options, _jsonContext.DoSomethingCommand, _jsonContext.DoSomethingResult, CancellationToken.None);
}

protected override void Initialize(IBiDi bidi, JsonSerializerOptions jsonSerializerOptions)
{
_jsonContext = new CustomModuleJsonSerializerContext(jsonSerializerOptions);
}
}

[JsonSerializable(typeof(DoSomethingCommand))]
[JsonSerializable(typeof(DoSomethingResult))]
partial class CustomModuleJsonSerializerContext : JsonSerializerContext;

class DoSomethingCommand()
: Command<Parameters, DoSomethingResult>(Parameters.Empty, "session.status");

record DoSomethingResult : EmptyResult;

record DoSomethingOptions : CommandOptions;
10 changes: 1 addition & 9 deletions dotnet/test/webdriver/Internal/Logging/LogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,6 @@ public void ShouldCreateContextWithCustomLevel()
Assert.That(logger.Level, Is.EqualTo(LogEventLevel.Warn));
}

[Test]
public void ShouldCreateContextWithNullLogHandlers()
{
var context = new LogContext(LogEventLevel.Info, null, null, null, handlers: null);

Assert.That(context.Handlers, Is.Empty);
}

[Test]
public void ContextShouldChangeLevel()
{
Expand Down Expand Up @@ -320,5 +312,5 @@ public void Handle(LogEvent logEvent)
Events.Add(logEvent);
}

public IList<LogEvent> Events { get; internal set; } = new List<LogEvent>();
public IList<LogEvent> Events { get; internal set; } = [];
Comment thread
nvborisenko marked this conversation as resolved.
}
Loading