Skip to content

[BUG] NullReferenceException in Connection.WrapApiCallAsync  #2074

@limitisbsc

Description

@limitisbsc

Context:

  • Playwright Version: 1.20.1
  • Operating System: Windows
  • .NET version: net6.0
  • Browser: Firefox

Related pull request
check namespace for null #2067

Describe the bug
If ReflectedType is null a NullReferenceException is thrown
Line in question at https://github.com/microsoft/playwright-dotnet/blob/main/src/Playwright/Transport/Connection.cs#L442

                string cSharpNamespace = sf.GetMethod().ReflectedType.Namespace;
                bool playwrightInternal = cSharpNamespace != null &&
                                          (cSharpNamespace == "Microsoft.Playwright" ||
                                          cSharpNamespace.StartsWith("Microsoft.Playwright.Core", StringComparison.InvariantCultureIgnoreCase) ||
                                          cSharpNamespace.StartsWith("Microsoft.Playwright.Transport", StringComparison.InvariantCultureIgnoreCase) ||
                                          cSharpNamespace.StartsWith("Microsoft.Playwright.Helpers", StringComparison.InvariantCultureIgnoreCase));

screenshot

Fix

                string cSharpNamespace = sf.GetMethod().ReflectedType?.Namespace;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions