Repository: microsoft/PowerToys
File: src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/Main.cs (C#)

Code before:
        public List<Result> Query(Query query)
        {
            ArgumentNullException.ThrowIfNull(query);

            // Parse
            ConvertModel convertModel = InputInterpreter.Parse(query);
            if (convertModel == null)
            {
                return new List<Result>();
            }

            // Convert
            return UnitHandler.Convert(convertModel)
                .Select(x => GetResult(x))
                .ToList();
        }

        private Result GetResult(UnitConversionResult result)
        {
            return new Result
            {
                ContextData = result,
                Title = result.ToString(null),
                IcoPath = _icon_path,
                Score = 300,
                SubTitle = (result.UnitNameFrom == "usounce" ? "From US Ounce - " : (result.UnitNameFrom == "imperialounce" ? "From Imperial Ounce - " : string.Empty)) + string.Format(CultureInfo.CurrentCulture, CopyToClipboard, result.QuantityInfo.Name),
                Action = c =>
                {
                    var ret = false;
                    var thread = new Thread(() =>
                    {
                        try
                        {
                            Clipboard.SetText(result.ConvertedValue.ToString(UnitConversionResult.Format, CultureInfo.CurrentCulture));
                            ret = true;
                        }
                        catch (ExternalException)
                        {
                            MessageBox.Show(Properties.Resources.copy_failed);
                        }
                    });
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                    thread.Join();
                    return ret;
                },
            };
        }

        private ContextMenuResult CreateContextMenuEntry(UnitConversionResult result)
        {

Review comment (suggestion):
Please add "From {0}" to resex and use it with `string.Fromat()`. In resex we need a comment like `Like "Convert from Unit".`.

And I wondering if we can improve it by having two or three different resex strings containing all subtitle elements and a switch case before `return new Result ...`. The code line looks a bit messy.

Code after:
        public List<Result> Query(Query query)
        {
            ArgumentNullException.ThrowIfNull(query);

            // Parse
            ConvertModel convertModel = InputInterpreter.Parse(query);
            if (convertModel == null)
            {
                return new List<Result>();
            }

            // Convert
            return UnitHandler.Convert(convertModel)
                .Select(x => GetResult(x))
                .ToList();
        }

        private Result GetResult(UnitConversionResult result)
        {
            return new Result
            {
                ContextData = result,
                Title = result.ToString(null),
                IcoPath = _icon_path,
                Score = 300,
                SubTitle = string.Format(CultureInfo.CurrentCulture, CopyToClipboard, result.QuantityInfo.Name),
                Action = c =>
                {
                    var ret = false;
                    var thread = new Thread(() =>
                    {
                        try
                        {
                            Clipboard.SetText(result.ConvertedValue.ToString(UnitConversionResult.Format, CultureInfo.CurrentCulture));
                            ret = true;
                        }
                        catch (ExternalException)
                        {
                            MessageBox.Show(Properties.Resources.copy_failed);
                        }
                    });
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                    thread.Join();
                    return ret;
                },
            };
        }

        private ContextMenuResult CreateContextMenuEntry(UnitConversionResult result)
        {