MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: Inappropriate use of CHECK_FEATURE_RETURN in InitializeFindOptions sample code

Open
#5,064 8 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

What happened?

The CHECK_FEATURE_RETURN macro can't be used in the proposed InitializeFindOptions method:

wil::com_ptr<ICoreWebView2FindOptions> AppWindow::InitializeFindOptions(const std::wstring& findTerm)
{
    // Query for the ICoreWebView2Environment5 interface.
    auto webView2Environment5 = m_webViewEnvironment.try_query<ICoreWebView2Environment5>();
    CHECK_FEATURE_RETURN(webView2Environment5);

    // Initialize Find options
    wil::com_ptr<ICoreWebView2FindOptions> find_options;
    CHECK_FAILURE(webView2Environment5->CreateFindOptions(&find_options));
    CHECK_FAILURE(find_options->put_FindTerm(findTerm.c_str()));

    return find_options;
}

This is because it returns true upon success. So I adapted by adding a new macro:

#define CHECK_FEATURE_RETURN_NULL(feature) { if (!feature) { FeatureNotAvailable(); return nullptr; } }

The sample code should be revised.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Prerelease (Edge Canary/Dev/Beta)

Runtime Version

134.0.3101.0 canary

SDK Version

1.0.3079 prerelease

Framework

Win32

Operating System

Windows 11

OS Version

10.0.26100 24H2

Repro steps

Try to use the sample in the Find documentation for Win32.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.