Repository: AvaloniaUI/Avalonia
File: samples/ControlCatalog.Desktop/Program.cs (C#)

Code before:
                        break;
                }
            }

            var builder = BuildAvaloniaApp();

            double GetScaling()
            {
                var idx = Array.IndexOf(args, "--scaling");
                if (idx != 0 && args.Length > idx + 1 &&
                    double.TryParse(args[idx + 1], NumberStyles.Any, CultureInfo.InvariantCulture, out var scaling))
                    return scaling;
                return 1;
            }
            SurfaceOrientation GetOrientation()
            {
                var idx = Array.IndexOf(args, "--orientation");
                if (idx != 0 && args.Length > idx + 1 &&
                    Enum.TryParse<SurfaceOrientation>(args[idx + 1], true, out var orientation))
                    return orientation;
                return SurfaceOrientation.Rotation0;
            }
            string? GetCard()
            {
                var idx = Array.IndexOf(args, "--card");
                if (idx != 0 && args.Length > idx + 1)
                    return args[idx + 1];
                return null;
            }
            if (args.Contains("--fbdev"))
            {
                 SilenceConsole();
                 return builder.StartLinuxFbDev(args, new FbDevOutputOptions()
                 {
                     Scaling = GetScaling()
                 });
            }
            else if (args.Contains("--vnc"))
            {
                return builder.StartWithHeadlessVncPlatform(null, 5901, args, ShutdownMode.OnMainWindowClose);
            }
            else if (args.Contains("--full-headless"))
            {
                return builder
                    .UseHeadless(new AvaloniaHeadlessPlatformOptions
                    {
                        UseHeadlessDrawing = true
                    })
                    .AfterSetup(_ =>
                    {
                        DispatcherTimer.RunOnce(async () =>

Review comment (bug):
Should be `idx >= 0`, otherwise that's parsing the first argument instead. (I'm aware that this bug was already present before and several times in this file.)

Code after:
                        break;
                }
            }

            var builder = BuildAvaloniaApp();

            double GetScaling()
            {
                var idx = Array.IndexOf(args, "--scaling");
                if (idx != 0 && args.Length > idx + 1 &&
                    double.TryParse(args[idx + 1], NumberStyles.Any, CultureInfo.InvariantCulture, out var scaling))
                    return scaling;
                return 1;
            }
            SurfaceOrientation GetOrientation()
            {
                var idx = Array.IndexOf(args, "--orientation");
                if (idx >= 0 && args.Length > idx + 1 &&
                    Enum.TryParse<SurfaceOrientation>(args[idx + 1], true, out var orientation))
                    return orientation;
                return SurfaceOrientation.Rotation0;
            }
            string? GetCard()
            {
                var idx = Array.IndexOf(args, "--card");
                if (idx >= 0 && args.Length > idx + 1)
                    return args[idx + 1];
                return null;
            }
            if (args.Contains("--fbdev"))
            {
                 SilenceConsole();
                 return builder.StartLinuxFbDev(args, new FbDevOutputOptions()
                 {
                     Scaling = GetScaling()
                 });
            }
            else if (args.Contains("--vnc"))
            {
                return builder.StartWithHeadlessVncPlatform(null, 5901, args, ShutdownMode.OnMainWindowClose);
            }
            else if (args.Contains("--full-headless"))
            {
                return builder
                    .UseHeadless(new AvaloniaHeadlessPlatformOptions
                    {
                        UseHeadlessDrawing = true
                    })
                    .AfterSetup(_ =>
                    {
                        DispatcherTimer.RunOnce(async () =>