Repository: AvaloniaUI/Avalonia
File: src/Windows/Avalonia.Win32/OpenGl/Angle/AngleWin32EglDisplay.cs (C#)

Code before:
                void* pAdapter = null;
                // As for now, we only need to redefine default adapter only on ARM64 just in case of Adreno GPU.
                var redefineDefaultAdapter = RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
                if (redefineDefaultAdapter)
                {
                    ushort adapterIndex = 0;
                    var adapters = new List<(IDXGIAdapter1 adapter, string name)>();
                    while (factory.EnumAdapters1(adapterIndex, &pAdapter) == 0)
                    {
                        var adapter = MicroComRuntime.CreateProxyFor<IDXGIAdapter1>(pAdapter, true);
                        var desc = adapter.Desc1;
                        var name = Marshal.PtrToStringUni(new IntPtr(desc.Description))!.ToLowerInvariant();
                        adapters.Add((adapter, name));
                        adapterIndex++;
                    }

                    if (adapters.Count == 0)
                        throw new OpenGlException("No adapters found");

                    chosenAdapter = adapters
                        .OrderByDescending(x =>
                            // Put adreno in lower priority - it's broken in Avalonia.
                            x.name.Contains("adreno") ? -1
                            : x.name.Contains("nvidia") ? 2
                            : x.name.Contains("amd") ? 1
                            : 0)
                        .First().adapter
                        .CloneReference();

                    foreach (var a in adapters)
                        a.adapter.Dispose();
                }
                else
                {
                    if (factory.EnumAdapters1(0, &pAdapter) != 0)
                        throw new OpenGlException("No adapters found");
                    chosenAdapter = MicroComRuntime.CreateProxyFor<IDXGIAdapter1>(pAdapter, true);
                }
            }

            IntPtr pD3dDevice;
            using (chosenAdapter)
                DirectXUnmanagedMethods.D3D11CreateDevice(chosenAdapter?.GetNativeIntPtr() ?? IntPtr.Zero,
                    D3D_DRIVER_TYPE.D3D_DRIVER_TYPE_UNKNOWN,
                    IntPtr.Zero, 0, featureLevels, (uint)featureLevels.Length,
                    7, out pD3dDevice, out _, null);


            if (pD3dDevice == IntPtr.Zero)
                throw new Win32Exception("Unable to create D3D11 Device");


Review comment (suggestion):
```suggestion
                            x.name.Contains("adreno") ? -1 : 0)
```

Code after:
                void* pAdapter = null;
                // As for now, we only need to redefine default adapter only on ARM64 just in case of Adreno GPU.
                var redefineDefaultAdapter = RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
                if (redefineDefaultAdapter)
                {
                    ushort adapterIndex = 0;
                    var adapters = new List<(IDXGIAdapter1 adapter, string name)>();
                    while (factory.EnumAdapters1(adapterIndex, &pAdapter) == 0)
                    {
                        var adapter = MicroComRuntime.CreateProxyFor<IDXGIAdapter1>(pAdapter, true);
                        var desc = adapter.Desc1;
                        var name = Marshal.PtrToStringUni(new IntPtr(desc.Description))!.ToLowerInvariant();
                        adapters.Add((adapter, name));
                        adapterIndex++;
                    }

                    if (adapters.Count == 0)
                        throw new OpenGlException("No adapters found");

                    chosenAdapter = adapters
                        .OrderByDescending(x =>
                            // Put adreno in lower priority - it's broken in Avalonia.
                            x.name.Contains("adreno") ? -1 : 0)
                        .First().adapter
                        .CloneReference();

                    foreach (var a in adapters)
                        a.adapter.Dispose();
                }
                else
                {
                    if (factory.EnumAdapters1(0, &pAdapter) != 0)
                        throw new OpenGlException("No adapters found");
                    chosenAdapter = MicroComRuntime.CreateProxyFor<IDXGIAdapter1>(pAdapter, true);
                }
            }

            IntPtr pD3dDevice;
            using (chosenAdapter)
                DirectXUnmanagedMethods.D3D11CreateDevice(chosenAdapter?.GetNativeIntPtr() ?? IntPtr.Zero,
                    D3D_DRIVER_TYPE.D3D_DRIVER_TYPE_UNKNOWN,
                    IntPtr.Zero, 0, featureLevels, (uint)featureLevels.Length,
                    7, out pD3dDevice, out _, null);


            if (pD3dDevice == IntPtr.Zero)
                throw new Win32Exception("Unable to create D3D11 Device");

            var d3dDevice = MicroComRuntime.CreateProxyFor<ID3D11Device>(pD3dDevice, true);
            var angleDevice = IntPtr.Zero;
            var display = IntPtr.Zero;