Repository: microsoft/PowerToys
File: src/modules/previewpane/SvgPreviewHandler/SvgPreviewControl.cs (C#)

Code before:
        /// Adds a WebView2 Control to Control Collection.
        /// </summary>
        /// <param name="svgData">Svg to display on Browser Control.</param>
        private void AddWebViewControl(string svgData)
        {
            _browser = new WebView2();
            _browser.Dock = DockStyle.Fill;

            ConfiguredTaskAwaitable<CoreWebView2Environment>.ConfiguredTaskAwaiter
               webView2EnvironmentAwaiter = CoreWebView2Environment
                   .CreateAsync(userDataFolder: _webView2UserDataFolder)
                   .ConfigureAwait(true).GetAwaiter();
            webView2EnvironmentAwaiter.OnCompleted(() =>
            {
                InvokeOnControlThread(async () =>
                {
                    try
                    {
                        _webView2Environment = webView2EnvironmentAwaiter.GetResult();
                        await _browser.EnsureCoreWebView2Async(_webView2Environment).ConfigureAwait(true);
                        await _browser.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync("window.addEventListener('contextmenu', window => {window.preventDefault();});");
                        _browser.CoreWebView2.SetVirtualHostNameToFolderMapping(VirtualHostName, AssemblyDirectory, CoreWebView2HostResourceAccessKind.Allow);
                        _browser.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false;

                        // WebView2.NavigateToString() limitation. See docs.
                        if (svgData.Length > 2 * 1024 * 1024)
                        {
                            string filename = _webView2UserDataFolder + "\\" + Guid.NewGuid().ToString() + ".html";
                            File.WriteAllText(filename, svgData);
                            _browser.Source = new Uri(filename);
                        }
                        else
                        {
                            _browser.NavigateToString(svgData);
                        }

                        Controls.Add(_browser);
                    }
                    catch (Exception)
                    {
                    }
                });
            });
        }

        /// <summary>
        /// Adds a Text Box in Controls for showing information about blocked elements.
        /// </summary>
        /// <param name="message">Message to be displayed in textbox.</param>
        private void AddTextBoxControl(string message)
        {

Review comment (suggestion):
Should it be > or >= ? Did you test actual limitation?
Maybe add https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.navigatetostring?view=webview2-dotnet-1.0.864.35#remarks to the comments here for reference.
(I think there's a pattern for this already in `.github/actions/spell-check/patterns.txt` )

Code after:
            _browser.Dock = DockStyle.Fill;

            ConfiguredTaskAwaitable<CoreWebView2Environment>.ConfiguredTaskAwaiter
               webView2EnvironmentAwaiter = CoreWebView2Environment
                   .CreateAsync(userDataFolder: _webView2UserDataFolder)
                   .ConfigureAwait(true).GetAwaiter();
            webView2EnvironmentAwaiter.OnCompleted(() =>
            {
                InvokeOnControlThread(async () =>
                {
                    try
                    {
                        _webView2Environment = webView2EnvironmentAwaiter.GetResult();
                        await _browser.EnsureCoreWebView2Async(_webView2Environment).ConfigureAwait(true);
                        await _browser.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync("window.addEventListener('contextmenu', window => {window.preventDefault();});");
                        _browser.CoreWebView2.SetVirtualHostNameToFolderMapping(VirtualHostName, AssemblyDirectory, CoreWebView2HostResourceAccessKind.Allow);
                        _browser.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false;

                        // WebView2.NavigateToString() limitation
                        // See https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.navigatetostring?view=webview2-dotnet-1.0.864.35#remarks
                        // While testing the limit, it turned out it is ~1.5MB, so to be on a safe side we go for 1.5m bytes
                        if (svgData.Length > 1_500_000)
                        {
                            string filename = _webView2UserDataFolder + "\\" + Guid.NewGuid().ToString() + ".html";
                            File.WriteAllText(filename, svgData);
                            _browser.Source = new Uri(filename);
                        }
                        else
                        {
                            _browser.NavigateToString(svgData);
                        }

                        Controls.Add(_browser);
                    }
                    catch (Exception)
                    {
                    }
                });
            });
        }

        /// <summary>
        /// Adds a Text Box in Controls for showing information about blocked elements.
        /// </summary>
        /// <param name="message">Message to be displayed in textbox.</param>
        private void AddTextBoxControl(string message)
        {
            _textBox = new RichTextBox();
            _textBox.Text = message;
            _textBox.BackColor = Color.LightYellow;
            _textBox.Multiline = true;