Skip to content

Commit 8d3b64e

Browse files
Ensure that IsDarkModeEnabled always returns a valid result.
1 parent 89e5fe3 commit 8d3b64e

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/System.Windows.Forms/src/System/Windows/Forms/Application.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,9 @@ public static DarkMode EnvironmentDarkMode
328328
{
329329
DarkMode.Enabled => true,
330330
DarkMode.Disabled => false,
331-
_ => throw new InvalidOperationException("DefaultDarkMode is not set.")
331+
332+
// We return false even if DarkMode is not supported so that we ALWAYS have a valid result here.
333+
_ => false
332334
}
333335
};
334336

src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,9 @@ private PropertyGridView CreateGridView(IServiceProvider? serviceProvider)
16211621
}
16221622

16231623
[Conditional("DEBUG")]
1624+
#pragma warning disable CA1822 // Mark members as static
16241625
internal void CheckInCreate()
1626+
#pragma warning restore CA1822 // Mark members as static
16251627
{
16261628
#if DEBUG
16271629
if (_inGridViewCreate)

src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/StatusStripTests.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,11 @@ public void StatusStrip_Ctor_Default()
121121
Assert.Null(control.Region);
122122
Assert.NotNull(control.Renderer);
123123
Assert.Same(control.Renderer, control.Renderer);
124-
Assert.IsType<ToolStripSystemRenderer>(control.Renderer);
125-
Assert.Equal(ToolStripRenderMode.System, control.RenderMode);
124+
125+
// TODO: Assume control.Renderer can be either ToolStripSystemRenderer or ToolStripProfessionalRenderer for the Moment.
126+
Assert.True(control.Renderer is ToolStripSystemRenderer or ToolStripProfessionalRenderer, "Renderer is not one of the expected types.");
127+
Assert.True(control.RenderMode is ToolStripRenderMode.System or ToolStripRenderMode.ManagerRenderMode);
128+
126129
Assert.True(control.ResizeRedraw);
127130
Assert.Equal(200, control.Right);
128131
Assert.Equal(RightToLeft.No, control.RightToLeft);
@@ -1257,15 +1260,15 @@ private class NonReadOnlyControlsStatusStrip : StatusStrip
12571260

12581261
private class SubStatusStrip : StatusStrip
12591262
{
1260-
public new const int ScrollStateAutoScrolling = StatusStrip.ScrollStateAutoScrolling;
1263+
public new const int ScrollStateAutoScrolling = ScrollableControl.ScrollStateAutoScrolling;
12611264

1262-
public new const int ScrollStateHScrollVisible = StatusStrip.ScrollStateHScrollVisible;
1265+
public new const int ScrollStateHScrollVisible = ScrollableControl.ScrollStateHScrollVisible;
12631266

1264-
public new const int ScrollStateVScrollVisible = StatusStrip.ScrollStateVScrollVisible;
1267+
public new const int ScrollStateVScrollVisible = ScrollableControl.ScrollStateVScrollVisible;
12651268

1266-
public new const int ScrollStateUserHasScrolled = StatusStrip.ScrollStateUserHasScrolled;
1269+
public new const int ScrollStateUserHasScrolled = ScrollableControl.ScrollStateUserHasScrolled;
12671270

1268-
public new const int ScrollStateFullDrag = StatusStrip.ScrollStateFullDrag;
1271+
public new const int ScrollStateFullDrag = ScrollableControl.ScrollStateFullDrag;
12691272

12701273
public new bool CanEnableIme => base.CanEnableIme;
12711274

0 commit comments

Comments
 (0)