Explorar o código

Make IDriver.Force16Colors get-only as per code review

- Changed IDriver.Force16Colors from get/set to get-only
- Simplified DriverImpl.Force16Colors implementation to remove setter
- Updated documentation to clarify Force16Colors is read-only per driver instance
- Addresses code review feedback about inconsistent interface declaration

Co-authored-by: tig <[email protected]>
copilot-swe-agent[bot] hai 1 semana
pai
achega
a81341a3b6
Modificáronse 2 ficheiros con 6 adicións e 6 borrados
  1. 1 5
      Terminal.Gui/Drivers/DriverImpl.cs
  2. 5 1
      Terminal.Gui/Drivers/IDriver.cs

+ 1 - 5
Terminal.Gui/Drivers/DriverImpl.cs

@@ -206,11 +206,7 @@ internal class DriverImpl : IDriver
     public bool SupportsTrueColor => true;
 
     /// <inheritdoc/>
-    bool IDriver.Force16Colors
-    {
-        get => _instanceForce16Colors || !SupportsTrueColor;
-        set => throw new InvalidOperationException ("Force16Colors is read-only per driver instance. Set Terminal.Gui.Drivers.Driver.Force16Colors static property before driver creation.");
-    }
+    public bool Force16Colors => _instanceForce16Colors || !SupportsTrueColor;
 
     /// <inheritdoc/>
     public bool GetForce16Colors () => _instanceForce16Colors || !SupportsTrueColor;

+ 5 - 1
Terminal.Gui/Drivers/IDriver.cs

@@ -93,8 +93,12 @@ public interface IDriver
     ///         Will be forced to <see langword="true"/> if <see cref="IDriver.SupportsTrueColor"/> is
     ///         <see langword="false"/>, indicating that the <see cref="IDriver"/> cannot support TrueColor.
     ///     </para>
+    ///     <para>
+    ///         This property is read-only. To change the Force16Colors setting, set
+    ///         <c>Terminal.Gui.Drivers.Driver.Force16Colors</c> before creating the driver instance.
+    ///     </para>
     /// </remarks>
-    bool Force16Colors { get; set; }
+    bool Force16Colors { get; }
 
     /// <summary>
     ///     Gets whether the <see cref="IDriver"/> is using 16 colors instead of TrueColors.