Skip to content

[πŸ› Bug]: Incorrect NRT annotations for CreateDefaultService APIsΒ #15320

@MaceWindu

Description

@MaceWindu

What happened?

Following API (at least for Edge and Firefox drivers, but I suspect others too) allow user to pass optional driver path (and executable name) or at least doesn't assert it is specified:

https://github.com/SeleniumHQ/selenium/blob/selenium-4.29.0/dotnet/src/webdriver/Edge/EdgeDriverService.cs#L99

https://github.com/SeleniumHQ/selenium/blob/selenium-4.29.0/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs#L219

With NRT annotations enabled in 4.29.0 they now generate build error when nullable parameter passed.

How can we reproduce the issue?

class Test
{
    public DriverService Create(string? optionalPathToDriver, string? exeName, bool isEdge)
    {
        // Possible null reference argument for parameter 'driverPath' in 'FirefoxDriverService FirefoxDriverService.CreateDefaultService(string driverPath)'.
        // Possible null reference argument for parameter 'driverPath' in 'EdgeDriverService EdgeDriverService.CreateDefaultService(string driverPath, string driverExecutableFileName)'.
        return isEdge
            ? EdgeDriverService.CreateDefaultService(optionalPathToDriver, exeName)
            : FirefoxDriverService.CreateDefaultService(optionalPathToDriver, exeName);
    }
}

Relevant log output

irrelevant

Operating System

irrelevant

Selenium version

4.29.0 [.NET]

What are the browser(s) and version(s) where you see this issue?

irrelevant

What are the browser driver(s) and version(s) where you see this issue?

irrelevant

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-dotnet.NET BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions